diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApi.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApi.java index 1c69ea490..d4b3e5b1a 100644 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApi.java +++ b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApi.java @@ -31,10 +31,11 @@ public interface ProductSkuApi { List getSkuList(Collection ids); /** - * 批量扣减sku库存 + * 批量扣减 SKU 库存 * * @param batchReqDTO sku库存信息列表 */ + // TODO @LeeYan9: decrementSkuStockBatch? 啊哈, 动名词; void decrementStockBatch(SkuDecrementStockBatchReqDTO batchReqDTO); } diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/SkuDecrementStockBatchReqDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/SkuDecrementStockBatchReqDTO.java index c0cee91ba..5c045d3d5 100644 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/SkuDecrementStockBatchReqDTO.java +++ b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/SkuDecrementStockBatchReqDTO.java @@ -7,6 +7,7 @@ import lombok.NoArgsConstructor; import java.util.List; /** + * TODO @LeeYan9: 1) 类注释; 2) Product 开头哈; * @author LeeYan9 * @since 2022-08-26 */ @@ -15,7 +16,7 @@ import java.util.List; @AllArgsConstructor public class SkuDecrementStockBatchReqDTO { - + // TODO @LeeYan9: 参数校验 private List items; @Data @@ -24,6 +25,7 @@ public class SkuDecrementStockBatchReqDTO { /** * 商品 SPU 编号,自增 */ + // TODO @LeeYan9: 是不是不用传递哈 private Long productId; /** @@ -38,6 +40,7 @@ public class SkuDecrementStockBatchReqDTO { } + // TODO @LeeYan9: 构造方法, 是不是可以满足啦 public static SkuDecrementStockBatchReqDTO of(List items) { return new SkuDecrementStockBatchReqDTO(items); } diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/SpuInfoRespDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/SpuInfoRespDTO.java index 4392d9ad0..6aae7191b 100644 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/SpuInfoRespDTO.java +++ b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/SpuInfoRespDTO.java @@ -7,6 +7,7 @@ import lombok.Data; import java.util.List; +// TODO @LeeYan9: ProductSpuRespDTO /** * @author LeeYan9 * @since 2022-08-26 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java index 288aaa4da..b29040a23 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java @@ -16,6 +16,7 @@ import java.util.Collections; import java.util.List; /** + * TODO LeeYan9: 类注释; * @author LeeYan9 * @since 2022-09-06 */ @@ -28,6 +29,7 @@ public class ProductSkuApiImpl implements ProductSkuApi { @Override public List getSkusByIds(Collection skuIds) { + // TODO TODO LeeYan9: AllEmpty? if (CollectionUtils.isAnyEmpty(skuIds)) { return Collections.emptyList(); } @@ -38,6 +40,7 @@ public class ProductSkuApiImpl implements ProductSkuApi { @Override @Transactional(rollbackFor = Exception.class) public void decrementStockBatch(SkuDecrementStockBatchReqDTO batchReqDTO) { + // TODO @LeeYan9: 最好 Service 去 for 循环; productSkuMapper.decrementStockBatch(batchReqDTO.getItems()); } } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java index bc914d7a1..3ee034ce4 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java @@ -14,6 +14,8 @@ import java.util.Collections; import java.util.List; /** + * TODO LeeYan9: 类注释; + * * @author LeeYan9 * @since 2022-09-06 */ @@ -26,6 +28,7 @@ public class ProductSpuApiImpl implements ProductSpuApi { @Override public List getSpuList(Collection spuIds) { + // TODO TODO LeeYan9: AllEmpty? if (CollectionUtils.isAnyEmpty(spuIds)) { return Collections.emptyList(); } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java index f77e1f60f..d9845ddfa 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java @@ -38,5 +38,4 @@ public interface ProductSkuConvert { List convertList03(List list); - } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java index 4eb584893..26fe6a028 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java @@ -36,6 +36,5 @@ public interface ProductSpuConvert { AppSpuPageRespVO convertAppResp(ProductSpuDO list); List convertList2(List list); - - + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java index 99f63527f..2d600a314 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java @@ -23,16 +23,13 @@ import javax.servlet.http.HttpServletRequest; @Api(tags = "用户 App - 交易订单") @RestController @RequestMapping("/trade/order") -@RequiredArgsConstructor +@RequiredArgsConstructor // TODO @LeeYan9: 先统一使用 @Resource 注入哈; 项目只有三层, 依赖注入会存在, 所以使用 @Resource; 也因此, 最好全局保持一致 @Validated @Slf4j public class AppTradeOrderController { - // TODO 在思考下; - private final TradeOrderService tradeOrderService; - @GetMapping("/get-create-info") @ApiOperation("基于商品,确认创建订单") @PreAuthenticated @@ -46,15 +43,12 @@ public class AppTradeOrderController { @PreAuthenticated public CommonResult createTradeOrder(@RequestBody AppTradeOrderCreateReqVO createReqVO, HttpServletRequest servletRequest) { -// return success(tradeOrderService.createTradeOrder(UserSecurityContextHolder.getUserId(), -// HttpUtil.getIp(servletRequest), createReqVO)); // 获取登录用户 Long loginUserId = SecurityFrameworkUtils.getLoginUserId(); // 获取用户ip地址 String clientIp = ServletUtil.getClientIP(servletRequest); // 创建交易订单,预支付记录 Long result = tradeOrderService.createTradeOrder(loginUserId, clientIp, createReqVO); - return CommonResult.success(result); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java index e775a2b68..f72ab6b4b 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java @@ -8,16 +8,11 @@ import org.mapstruct.Mapping; import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; -/** - * @author LeeYan9 - * @since 2022-08-26 - */ @Mapper public interface TradeOrderConvert { TradeOrderConvert INSTANCE = Mappers.getMapper(TradeOrderConvert.class); - @Mappings({ @Mapping(source = "order.couponId", target = "couponId"), @Mapping(target = "remark", ignore = true), @@ -25,4 +20,5 @@ public interface TradeOrderConvert { @Mapping(source = "createVO.addressId", target = "receiverAreaId") }) TradeOrderDO convert(AppTradeOrderCreateReqVO createVO, PriceCalculateRespDTO.Order order); + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderItemConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderItemConvert.java index ed26fab7e..ac2e74d2f 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderItemConvert.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderItemConvert.java @@ -7,18 +7,11 @@ import org.mapstruct.factory.Mappers; import java.util.List; -/** - * @author LeeYan9 - * @since 2022-08-26 - */ @Mapper public interface TradeOrderItemConvert { TradeOrderItemConvert INSTANCE = Mappers.getMapper(TradeOrderItemConvert.class); - /** - * @param items sku列表价格 - * @return 订单项 - */ List convertList(List items); + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/pay/PayOrderConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/pay/PayOrderConvert.java index 44a66a424..a32d42526 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/pay/PayOrderConvert.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/pay/PayOrderConvert.java @@ -11,10 +11,6 @@ import org.mapstruct.factory.Mappers; import java.util.Date; -/** - * @author LeeYan9 - * @since 2022-08-26 - */ @Mapper public interface PayOrderConvert { @@ -30,4 +26,5 @@ public interface PayOrderConvert { default Date convertCreateTimeToPayExpireTime(Date cancelTime) { return DateUtil.offsetMinute(new Date(), 30); } + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/price/PriceConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/price/PriceConvert.java index 3b2d173c3..da28b9e3e 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/price/PriceConvert.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/price/PriceConvert.java @@ -7,10 +7,6 @@ import org.mapstruct.Mapping; import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; -/** - * @author LeeYan9 - * @since 2022-08-26 - */ @Mapper public interface PriceConvert { @@ -19,5 +15,6 @@ public interface PriceConvert { @Mappings( @Mapping(source = "userId" , target = "userId") ) - PriceCalculateReqDTO convert(AppTradeOrderCreateReqVO createReqVO , Long userId); + PriceCalculateReqDTO convert(AppTradeOrderCreateReqVO createReqVO, Long userId); + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/sku/ProductSkuConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/sku/ProductSkuConvert.java index 7aa4f554b..916f2d9d8 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/sku/ProductSkuConvert.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/sku/ProductSkuConvert.java @@ -17,5 +17,6 @@ public interface ProductSkuConvert { ProductSkuConvert INSTANCE = Mappers.getMapper(ProductSkuConvert.class); - List convert(List tradeOrderItems); + List convert(List list); + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java index 3b963540b..a62746b1b 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java @@ -4,10 +4,6 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; import org.apache.ibatis.annotations.Mapper; -/** - * @author LeeYan9 - * @since 2022-08-26 - */ @Mapper public interface TradeOrderMapper extends BaseMapperX { } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/orderitem/TradeOrderItemMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/orderitem/TradeOrderItemMapper.java index 987d5a3f5..3a85e0cbb 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/orderitem/TradeOrderItemMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/orderitem/TradeOrderItemMapper.java @@ -4,10 +4,6 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; import org.apache.ibatis.annotations.Mapper; -/** - * @author LeeYan9 - * @since 2022-08-26 - */ @Mapper public interface TradeOrderItemMapper extends BaseMapperX { } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderConfig.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderConfig.java index 8d6ebea15..715169275 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderConfig.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderConfig.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.trade.framework.order.config; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Configuration; +// TODO @LeeYan9: 可以直接给 TradeOrderProperties 一个 @Component生效哈 /** * @author LeeYan9 * @since 2022-09-15 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderService.java index f3fc4b5e1..c70a2a273 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderService.java @@ -3,15 +3,16 @@ package cn.iocoder.yudao.module.trade.service.order; import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO; /** + * TODO @LeeYan9: 类注释 * @author LeeYan9 * @since 2022-08-26 */ public interface TradeOrderService { /** - * 创建交易订单 + * 创建交易订单 TODO @LeeYan9: 方法注释, 和参数要空一行 * @param loginUserId 登录用户 - * @param clientIp 用户ip地址 + * @param clientIp 用户ip地址 // TODO @LeeYan9: 中英文之间, 空一行哈 * @param createReqVO 创建交易订单请求模型 * @return 交易订单创建结果 */ diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java index fb0f22ce9..86a0e844c 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.trade.service.order; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.text.StrBuilder; import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.enums.TerminalEnum; import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; @@ -45,42 +46,41 @@ import java.util.Map; import java.util.Objects; /** + * TODO @LeeYan9: 注释 * @author LeeYan9 * @since 2022-08-26 */ @Service public class TradeOrderServiceImpl implements TradeOrderService { + // TODO @LeeYan9: 相同类型的, 可以放在一起,不用空行; 例如说 Mapper 和 API 和 Properties + @Resource private TradeOrderMapper tradeOrderMapper; - @Resource private TradeOrderItemMapper tradeOrderItemMapper; @Resource private PriceApi priceApi; - @Resource private ProductSkuApi productSkuApi; - @Resource private ProductSpuApi productSpuApi; - @Resource private PayOrderApi payOrderApi; @Resource private TradeOrderProperties tradeOrderProperties; + // TODO LeeYan9: 静态变量, 需要在最前面哈; 另外, 静态变量的注释最好写下; private static final String BLANK_PLACEHOLDER = " "; private static final String MULTIPLIER_PLACEHOLDER = "x"; - @Override @Transactional(rollbackFor = Exception.class) public Long createTradeOrder(Long loginUserId, String clientIp, AppTradeOrderCreateReqVO createReqVO) { - List items = createReqVO.getItems(); + List items = createReqVO.getItems(); // TODO @LeeYan9: 方法第一行, 不用空哈; // 商品SKU检查 sku可售状态,库存 List skuInfos = productSkuApi.getSkuList(CollectionUtils.convertSet(items, Item::getSkuId)); Map skuInfoMap = CollectionUtils.convertMap(skuInfos, ProductSkuRespDTO::getId); @@ -93,33 +93,38 @@ public class TradeOrderServiceImpl implements TradeOrderService { // 价格计算 PriceCalculateReqDTO priceCalculateReqDTO = PriceConvert.INSTANCE.convert(createReqVO, loginUserId); PriceCalculateRespDTO priceResp = priceApi.calculatePrice(priceCalculateReqDTO); + // TODO @LeeYan9: 是可以思考下, 订单的营销优惠记录, 应该记录在哪里, 微信讨论起来! + // 订单信息记录 TradeOrderDO tradeOrderDO = TradeOrderConvert.INSTANCE.convert(createReqVO, priceResp.getOrder()); - fillTradeOrderInfoFromReqInfo(tradeOrderDO,createReqVO,loginUserId, clientIp); + fillTradeOrderInfoFromReqInfo(tradeOrderDO,createReqVO,loginUserId, clientIp); // TODO @LeeYan9: tradeOrderDO, createReqVO, loginUserId, clientIp tradeOrderMapper.insert(tradeOrderDO); // 订单项信息记录 List tradeOrderItems = TradeOrderItemConvert.INSTANCE.convertList(priceResp.getOrder().getItems()); - //-填充订单项-SKU信息 + // 填充订单项-SKU信息 fillItemsInfoFromSkuAndOrder(tradeOrderDO, tradeOrderItems, skuInfoMap); tradeOrderItemMapper.insertBatch(tradeOrderItems); + // TODO @LeeYan9: 先扣减库存哈; 可能会扣减失败; 毕竟 get 和 update 之间, 会有并发的可能性 // 库存扣减 List skuDecrementStockItems = ProductSkuConvert.INSTANCE.convert(tradeOrderItems); productSkuApi.decrementStockBatch(SkuDecrementStockBatchReqDTO.of(skuDecrementStockItems)); // 构建预支付请求参数 + // TODO @LeeYan9: 需要更新到订单上 PayOrderInfoCreateReqDTO payOrderCreateReqDTO = PayOrderConvert.INSTANCE.convert(tradeOrderDO); fillPayOrderInfoFromItems(payOrderCreateReqDTO, tradeOrderItems); // 生成预支付 return payOrderApi.createPayOrder(payOrderCreateReqDTO); } + // TODO @LeeYan9: 填充就好, 不用 from 哈; private void fillTradeOrderInfoFromReqInfo(TradeOrderDO tradeOrderDO, AppTradeOrderCreateReqVO createReqVO, Long loginUserId, String clientIp) { tradeOrderDO.setUserId(loginUserId); tradeOrderDO.setUserIp(clientIp); - tradeOrderDO.setSn(IdUtil.getSnowflakeNextId() + ""); + tradeOrderDO.setSn(IdUtil.getSnowflakeNextId() + ""); // TODO @LeeYan9: 思考下, 怎么生成好点哈; 这个是会展示给用户的; tradeOrderDO.setStatus(TradeOrderStatusEnum.WAITING_PAYMENT.getStatus()); tradeOrderDO.setType(TradeOrderTypeEnum.NORMAL.getType()); tradeOrderDO.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()); @@ -139,7 +144,6 @@ public class TradeOrderServiceImpl implements TradeOrderService { // 填写商品信息 StrBuilder subject = new StrBuilder(); StrBuilder body = new StrBuilder(); - for (TradeOrderItemDO tradeOrderItem : tradeOrderItems) { // append subject subject.append(BLANK_PLACEHOLDER); @@ -151,6 +155,7 @@ public class TradeOrderServiceImpl implements TradeOrderService { body.append(tradeOrderItem.getCount()); } // 设置 subject & body + // TODO @LeeYan9: 可以抽象一个 StrUtils 方法; 或者看看 hutool 有没自带的哈 payOrderInfoCreateReqDTO.setSubject(StrUtils.maxLength(subject.subString(1), 32)); payOrderInfoCreateReqDTO.setBody(StrUtils.maxLength(body.subString(1), 128)); } @@ -182,6 +187,7 @@ public class TradeOrderServiceImpl implements TradeOrderService { } } + // TODO @LeeYan9: checkSpuXXX 会不会好点哈? ps: 这个貌似是 sku 哈 private void checkSaleableAndStockFromSpu(Map skuInfoMap, List items) { // sku 不存在 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceTest.java b/yudao-module-mall/yudao-module-trade-biz/src/main/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceTest.java index 97fb084a8..6b3281d3f 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceTest.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceTest.java @@ -30,6 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; +// TODO @芋艿: 单测的 review; 最后搞; /** * @author LeeYan9 * @since 2022-09-07 diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApi.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApi.java index 9b345c587..36022b172 100644 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApi.java +++ b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApi.java @@ -3,12 +3,13 @@ package cn.iocoder.yudao.module.pay.api.order; import javax.validation.Valid; /** + * 支付单 API 接口 + * * @author LeeYan9 * @since 2022-08-26 */ public interface PayOrderApi { - /** * 创建支付单 * diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderInfoCreateReqDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderInfoCreateReqDTO.java index fe5173cde..fda4b3d8d 100644 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderInfoCreateReqDTO.java +++ b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderInfoCreateReqDTO.java @@ -9,8 +9,10 @@ import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.Date; +// TODO @LeeYan9: 1) 新建一个 dto 包, 然后挪进去哈; 2) 在 order下; Info 可以去掉; /** * 支付单创建 Request DTO + * * @author LeeYan9 */ @Data @@ -53,6 +55,7 @@ public class PayOrderInfoCreateReqDTO implements Serializable { * 支付金额,单位:分 */ @NotNull(message = "支付金额不能为空") + // TODO @LeeYan9: 是不是 @Min 注解呀, 是 Integer 哈 @DecimalMin(value = "0", inclusive = false, message = "支付金额必须大于零") private Integer amount;