订单相关

This commit is contained in:
litianxiang
2026-05-20 15:33:22 +08:00
parent 5ca83caaff
commit 25a0ee1a3f
13 changed files with 163 additions and 18 deletions

View File

@@ -155,14 +155,7 @@
<version>2.0.43</version>
</dependency>
<!-- 动态数据源 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot3-starter</artifactId>
<version>4.3.1</version>
</dependency>
<!-- Lombok -->
<!-- Fastjson -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>

View File

@@ -0,0 +1,62 @@
package com.aida.buyer.config;
import com.baomidou.mybatisplus.core.config.GlobalConfig;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import javax.sql.DataSource;
@Configuration
@MapperScan(basePackages = "com.aida.buyer.module.*.mapper", sqlSessionFactoryRef = "buyerSqlSessionFactory")
public class BuyerDataSourceConfig {
@Autowired
private MybatisPlusInterceptor mybatisPlusInterceptor;
@Autowired
private MetaObjectHandler myMetaObjectHandler;
@Primary
@Bean(name = "buyerDataSource")
@ConfigurationProperties(prefix = "spring.datasource.buyer")
public DataSource dataSource() {
return DataSourceBuilder.create().build();
}
@Primary
@Bean(name = "buyerSqlSessionFactory")
public SqlSessionFactory sqlSessionFactory(
@Qualifier("buyerDataSource") DataSource dataSource,
ApplicationContext applicationContext) throws Exception {
MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
bean.setDataSource(dataSource);
bean.setMapperLocations(applicationContext.getResources("classpath*:/mapper/**/*.xml"));
GlobalConfig globalConfig = new GlobalConfig();
globalConfig.setBanner(false);
globalConfig.setMetaObjectHandler(myMetaObjectHandler);
bean.setGlobalConfig(globalConfig);
bean.setPlugins(mybatisPlusInterceptor);
return bean.getObject();
}
@Primary
@Bean(name = "buyerSqlSessionTemplate")
public SqlSessionTemplate sqlSessionTemplate(
@Qualifier("buyerSqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
return new SqlSessionTemplate(sqlSessionFactory);
}
}

View File

@@ -20,7 +20,7 @@ public class BuyerAccountController {
private final IBuyerAccountService buyerAccountService;
@PostMapping("/sendCode")
@Operation(summary = "忘记密码:发送邮箱验证码")
@Operation(summary = "注册||忘记密码:发送邮箱验证码")
public Boolean sendCode(@Valid @RequestBody SendCodeDTO dto) {
return buyerAccountService.sendCode(dto);
}

View File

@@ -24,7 +24,6 @@ public class RegisterDTO {
@Schema(description = "用户名")
private String username;
@NotBlank(message = "emailVerifyCode is required")
@Schema(description = "邮箱验证码")
private String emailVerifyCode;
}

View File

@@ -11,4 +11,8 @@ public class SendCodeDTO {
@NotBlank(message = "email is required")
@Schema(description = "邮箱")
private String email;
@NotBlank(message = "operationType is required")
@Schema(description = "操作类型FORGET_PWD, REGISTER")
private String operationType;
}

View File

@@ -1,11 +1,9 @@
package com.aida.buyer.module.account.mapper;
import com.aida.buyer.module.account.entity.BuyerAccount;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
@DS("buyer")
public interface BuyerAccountMapper extends BaseMapper<BuyerAccount> {
}

View File

@@ -30,12 +30,13 @@ public class BuyerAccountServiceImpl implements IBuyerAccountService {
public Boolean sendCode(SendCodeDTO dto) {
String email = dto.getEmail();
String operationType = dto.getOperationType();
String code = RandomsUtil.generateVerifyCode(100000L, 999999L);
String cacheKey = "FORGET_PWD_" + email;
String cacheKey = operationType + "_" + email;
LoginCacheUtil.setVerifyCodeCache(cacheKey, code);
SendEmailUtil.sendVerifyCode(email, code);
log.info("Email verification code sent to: {}", email);
log.info("Email verification code sent to: {}code:{}", email, code);
return Boolean.TRUE;
}
@@ -85,7 +86,7 @@ public class BuyerAccountServiceImpl implements IBuyerAccountService {
LoginCacheUtil.setVerifyCodeCache(cacheKey, code);
SendEmailUtil.sendVerifyCode(email, code);
log.info("PreLogin verification code sent to: {}", email);
log.info("PreLogin verification code sent to: {}code:{}", email, code);
PreLoginVO vo = new PreLoginVO();
vo.setUserId(account.getId());

View File

@@ -2,8 +2,10 @@ package com.aida.buyer.module.order.controller;
import com.aida.buyer.common.result.PageResponse;
import com.aida.buyer.common.result.Response;
import com.aida.buyer.module.order.dto.AssetsDTO;
import com.aida.buyer.module.order.dto.BuyerOrdersDTO;
import com.aida.buyer.module.order.service.IBuyerOrderService;
import com.aida.buyer.module.order.vo.AssetsVO;
import com.aida.buyer.module.order.vo.BuyerOrderVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -43,4 +45,10 @@ public class BuyerOrderController {
public Response<Void> createOrder(@RequestBody List<Long> listingIds) {
return buyerOrderService.createOrder(listingIds);
}
@PostMapping("/assets/page")
@Operation(summary = "我的资产分页查询")
public Response<PageResponse<AssetsVO>> getMyAssets(@RequestBody AssetsDTO dto) {
return buyerOrderService.getMyAssets(dto);
}
}

View File

@@ -0,0 +1,29 @@
package com.aida.buyer.module.order.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
@Schema(description = "我的资产分页查询请求参数")
public class AssetsDTO implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "买家ID自动填充无需传入")
private Long buyerId;
@Schema(description = "商品分类列表,支持多选")
private List<String> categories;
@Schema(description = "适用性别 female/male/all不传表示全部")
private String designFor;
@Schema(description = "页码默认1")
private long page = 1;
@Schema(description = "每页数量默认10")
private long size = 10;
}

View File

@@ -3,16 +3,16 @@ package com.aida.buyer.module.order.feign;
import com.aida.buyer.common.result.PageResponse;
import com.aida.buyer.common.result.Response;
import com.aida.buyer.module.feign.annotation.InternalCall;
import com.aida.buyer.module.order.dto.AssetsDTO;
import com.aida.buyer.module.order.dto.BuyerOrdersDTO;
import com.aida.buyer.module.order.dto.CreateOrderDTO;
import com.aida.buyer.module.order.dto.UpdateOrderStatusDTO;
import com.aida.buyer.module.order.vo.AssetsVO;
import com.aida.buyer.module.order.vo.BuyerOrderVO;
import com.aida.buyer.module.order.vo.CreateOrderResultVO;
import com.aida.buyer.module.order.dto.UpdateOrderStatusDTO;
import java.util.List;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
@@ -23,13 +23,19 @@ import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(name = "aida-seller", contextId = "order", path = "/order")
public interface OrderFeignClient {
@InternalCall
@PostMapping("/buyer/orders")
Response<PageResponse<BuyerOrderVO>> getOrdersByBuyerId(@RequestBody BuyerOrdersDTO dto);
@InternalCall
@PostMapping("/create")
Response<CreateOrderResultVO> createOrder(@RequestBody CreateOrderDTO dto);
@InternalCall
@PutMapping("/status/batch")
Response<Void> updateOrderStatus(@RequestBody UpdateOrderStatusDTO dto);
@InternalCall
@PostMapping("/assets/page")
Response<PageResponse<AssetsVO>> getAssetsPage(@RequestBody AssetsDTO dto);
}

View File

@@ -2,7 +2,9 @@ package com.aida.buyer.module.order.service;
import com.aida.buyer.common.result.PageResponse;
import com.aida.buyer.common.result.Response;
import com.aida.buyer.module.order.dto.AssetsDTO;
import com.aida.buyer.module.order.dto.BuyerOrdersDTO;
import com.aida.buyer.module.order.vo.AssetsVO;
import com.aida.buyer.module.order.vo.BuyerOrderVO;
import java.util.List;
@@ -12,4 +14,6 @@ public interface IBuyerOrderService {
Response<PageResponse<BuyerOrderVO>> getMyOrders(BuyerOrdersDTO dto);
Response<Void> createOrder(List<Long> listingIds);
Response<PageResponse<AssetsVO>> getMyAssets(AssetsDTO dto);
}

View File

@@ -6,10 +6,12 @@ import com.aida.buyer.common.result.PageResponse;
import com.aida.buyer.common.result.Response;
import com.aida.buyer.module.account.entity.BuyerAccount;
import com.aida.buyer.module.account.mapper.BuyerAccountMapper;
import com.aida.buyer.module.order.dto.AssetsDTO;
import com.aida.buyer.module.order.dto.BuyerOrdersDTO;
import com.aida.buyer.module.order.dto.CreateOrderDTO;
import com.aida.buyer.module.order.feign.OrderFeignClient;
import com.aida.buyer.module.order.service.IBuyerOrderService;
import com.aida.buyer.module.order.vo.AssetsVO;
import com.aida.buyer.module.order.vo.BuyerOrderVO;
import com.aida.buyer.module.order.vo.CreateOrderResultVO;
import lombok.RequiredArgsConstructor;
@@ -48,4 +50,10 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
// TODO:调用支付模块传入buyerIdresult.getOrderIds()result.getTotalAmount()
return Response.success();
}
@Override
public Response<PageResponse<AssetsVO>> getMyAssets(AssetsDTO dto) {
dto.setBuyerId(UserContext.getBuyerId());
return orderFeignClient.getAssetsPage(dto);
}
}

View File

@@ -0,0 +1,33 @@
package com.aida.buyer.module.order.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
@Schema(description = "我的资产商品明细")
public class AssetsVO implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "商品ID")
@JsonSerialize(using = ToStringSerializer.class)
private Long listingId;
@Schema(description = "商品名称")
private String listingName;
@Schema(description = "商品缩略图URL")
private String thumbnailUrl;
@Schema(description = "成交单价HK$")
private BigDecimal price;
@Schema(description = "购买时间")
private LocalDateTime createTime;
}