Commit a10d77cdfeb008a95b310178066d1ea14aa23be9
1 parent
9358639c
mall+order: 完善部分 TODO 提到的问题
Showing
29 changed files
with
131 additions
and
275 deletions
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuRespDTO.java
| ... | ... | @@ -59,14 +59,13 @@ public class ProductSkuRespDTO { |
| 59 | 59 | * 商品体积,单位:m^3 平米 |
| 60 | 60 | */ |
| 61 | 61 | private Double volume; |
| 62 | - // TODO @puhui999:firstBrokeragePrice ;尴尬,我当时打错了;secondBrokeragePrice | |
| 63 | 62 | /** |
| 64 | 63 | * 一级分销的佣金,单位:分 |
| 65 | 64 | */ |
| 66 | - private Integer firstBrokerageRecord; | |
| 65 | + private Integer firstBrokeragePrice; | |
| 67 | 66 | /** |
| 68 | 67 | * 二级分销的佣金,单位:分 |
| 69 | 68 | */ |
| 70 | - private Integer secondBrokerageRecord; | |
| 69 | + private Integer secondBrokeragePrice; | |
| 71 | 70 | |
| 72 | 71 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java
| ... | ... | @@ -51,10 +51,10 @@ public class ProductSkuBaseVO { |
| 51 | 51 | private Double volume; |
| 52 | 52 | |
| 53 | 53 | @Schema(description = "一级分销的佣金,单位:分", example = "199") |
| 54 | - private Integer firstBrokerageRecord; | |
| 54 | + private Integer firstBrokeragePrice; | |
| 55 | 55 | |
| 56 | 56 | @Schema(description = "二级分销的佣金,单位:分", example = "19") |
| 57 | - private Integer secondBrokerageRecord; | |
| 57 | + private Integer secondBrokeragePrice; | |
| 58 | 58 | |
| 59 | 59 | @Schema(description = "属性数组") |
| 60 | 60 | private List<Property> properties; | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java
| ... | ... | @@ -81,11 +81,11 @@ public class ProductSkuDO extends BaseDO { |
| 81 | 81 | /** |
| 82 | 82 | * 一级分销的佣金,单位:分 |
| 83 | 83 | */ |
| 84 | - private Integer firstBrokerageRecord; | |
| 84 | + private Integer firstBrokeragePrice; | |
| 85 | 85 | /** |
| 86 | 86 | * 二级分销的佣金,单位:分 |
| 87 | 87 | */ |
| 88 | - private Integer secondBrokerageRecord; | |
| 88 | + private Integer secondBrokeragePrice; | |
| 89 | 89 | |
| 90 | 90 | // ========== 营销相关字段 ========= |
| 91 | 91 | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java
| ... | ... | @@ -92,8 +92,8 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { |
| 92 | 92 | o.setMarketPrice(generaInt()); |
| 93 | 93 | o.setStock(generaInt()); |
| 94 | 94 | o.setWarnStock(10); |
| 95 | - o.setFirstBrokerageRecord(generaInt()); | |
| 96 | - o.setSecondBrokerageRecord(generaInt()); | |
| 95 | + o.setFirstBrokeragePrice(generaInt()); | |
| 96 | + o.setSecondBrokeragePrice(generaInt()); | |
| 97 | 97 | // 限制分数为两位数 |
| 98 | 98 | o.setWeight(RandomUtil.randomDouble(10,2, RoundingMode.HALF_UP)); |
| 99 | 99 | o.setVolume(RandomUtil.randomDouble(10,2, RoundingMode.HALF_UP)); |
| ... | ... | @@ -143,8 +143,8 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { |
| 143 | 143 | o.setMarketPrice(generaInt()); |
| 144 | 144 | o.setStock(generaInt()); |
| 145 | 145 | o.setWarnStock(10); |
| 146 | - o.setFirstBrokerageRecord(generaInt()); | |
| 147 | - o.setSecondBrokerageRecord(generaInt()); | |
| 146 | + o.setFirstBrokeragePrice(generaInt()); | |
| 147 | + o.setSecondBrokeragePrice(generaInt()); | |
| 148 | 148 | // 限制分数为两位数 |
| 149 | 149 | o.setWeight(RandomUtil.randomDouble(10,2, RoundingMode.HALF_UP)); |
| 150 | 150 | o.setVolume(RandomUtil.randomDouble(10,2, RoundingMode.HALF_UP)); | ... | ... |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationApi.java renamed to yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationActivityApi.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.api.combination; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationActivityUpdateStockReqDTO; | |
| 4 | - | |
| 5 | -// TODO @puhui999:是不是改成 CombinationActivityApi | |
| 6 | 3 | /** |
| 7 | 4 | * 拼团活动 Api 接口 |
| 8 | 5 | * |
| 9 | 6 | * @author HUIHUI |
| 10 | 7 | */ |
| 11 | -public interface CombinationApi { | |
| 8 | +public interface CombinationActivityApi { | |
| 12 | 9 | |
| 13 | 10 | /** |
| 14 | - * 更新活动库存 | |
| 11 | + * 校验是否满足拼团条件 | |
| 15 | 12 | * |
| 16 | - * @param reqDTO 请求 | |
| 13 | + * @param activityId 活动编号 | |
| 14 | + * @param userId 用户编号 | |
| 15 | + * @param skuId sku 编号 | |
| 16 | + * @param count 数量 | |
| 17 | 17 | */ |
| 18 | - // TODO @puhui999:应该是更新哇?还是校验哈; | |
| 19 | - void validateCombination(CombinationActivityUpdateStockReqDTO reqDTO); | |
| 18 | + void validateCombination(Long activityId, Long userId, Long skuId, Integer count); | |
| 20 | 19 | |
| 21 | 20 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.api.combination; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 4 | -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordRespDTO; | |
| 5 | 4 | |
| 6 | 5 | import javax.validation.Valid; |
| 7 | 6 | import java.time.LocalDateTime; |
| 8 | -import java.util.List; | |
| 9 | 7 | |
| 10 | 8 | // TODO @芋艿:后面也再撸撸这几个接口 |
| 11 | 9 | |
| ... | ... | @@ -33,26 +31,7 @@ public interface CombinationRecordApi { |
| 33 | 31 | boolean isCombinationRecordSuccess(Long userId, Long orderId); |
| 34 | 32 | |
| 35 | 33 | /** |
| 36 | - * 获取拼团记录 | |
| 37 | - * | |
| 38 | - * @param userId 用户编号 | |
| 39 | - * @param activityId 活动编号 | |
| 40 | - * @return 拼团记录列表 | |
| 41 | - */ | |
| 42 | - List<CombinationRecordRespDTO> getRecordListByUserIdAndActivityId(Long userId, Long activityId); | |
| 43 | - | |
| 44 | - /** | |
| 45 | - * 验证组合限制数 | |
| 46 | - * 校验是否满足限购要求 | |
| 47 | - * | |
| 48 | - * @param count 本次购买数量 | |
| 49 | - * @param sumCount 已购买数量合计 | |
| 50 | - * @param activityId 活动编号 | |
| 51 | - */ | |
| 52 | - void validateCombinationLimitCount(Long activityId, Integer count, Integer sumCount); | |
| 53 | - | |
| 54 | - /** | |
| 55 | - * 更新拼团状态为成功 | |
| 34 | + * 更新拼团状态为 成功 | |
| 56 | 35 | * |
| 57 | 36 | * @param userId 用户编号 |
| 58 | 37 | * @param orderId 订单编号 |
| ... | ... | @@ -60,7 +39,7 @@ public interface CombinationRecordApi { |
| 60 | 39 | void updateRecordStatusToSuccess(Long userId, Long orderId); |
| 61 | 40 | |
| 62 | 41 | /** |
| 63 | - * 更新拼团状态为失败 | |
| 42 | + * 更新拼团状态为 失败 | |
| 64 | 43 | * |
| 65 | 44 | * @param userId 用户编号 |
| 66 | 45 | * @param orderId 订单编号 | ... | ... |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationActivityUpdateStockReqDTO.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.api.combination.dto; | |
| 2 | - | |
| 3 | -import lombok.Data; | |
| 4 | - | |
| 5 | -import javax.validation.Valid; | |
| 6 | -import javax.validation.constraints.NotNull; | |
| 7 | - | |
| 8 | -/** | |
| 9 | - * 拼团活动更新活动库存 Request DTO | |
| 10 | - * | |
| 11 | - * @author HUIHUI | |
| 12 | - */ | |
| 13 | -@Data | |
| 14 | -public class CombinationActivityUpdateStockReqDTO { | |
| 15 | - | |
| 16 | - // TODO @puhui999:是不是一个 activityId、count、skuId 参数就完事啦。 | |
| 17 | - | |
| 18 | - @NotNull(message = "活动编号不能为空") | |
| 19 | - private Long activityId; | |
| 20 | - | |
| 21 | - @NotNull(message = "购买数量不能为空") | |
| 22 | - private Integer count; | |
| 23 | - | |
| 24 | - @NotNull(message = "活动商品不能为空") | |
| 25 | - private Item item; | |
| 26 | - | |
| 27 | - @Data | |
| 28 | - @Valid | |
| 29 | - public static class Item { | |
| 30 | - | |
| 31 | - @NotNull(message = "SPU 编号不能为空") | |
| 32 | - private Long spuId; | |
| 33 | - | |
| 34 | - @NotNull(message = "SKU 编号活动商品不能为空") | |
| 35 | - private Long skuId; | |
| 36 | - | |
| 37 | - @NotNull(message = "购买数量不能为空") | |
| 38 | - private Integer count; | |
| 39 | - | |
| 40 | - } | |
| 41 | - | |
| 42 | -} |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateReqDTO.java
| ... | ... | @@ -13,26 +13,39 @@ import javax.validation.constraints.NotNull; |
| 13 | 13 | @Data |
| 14 | 14 | public class CombinationRecordCreateReqDTO { |
| 15 | 15 | |
| 16 | - // TODO @puhui999:注释还是要的哈 | |
| 17 | - | |
| 16 | + /** | |
| 17 | + * 拼团活动编号 | |
| 18 | + */ | |
| 18 | 19 | @NotNull(message = "拼团活动编号不能为空") |
| 19 | 20 | private Long activityId; |
| 20 | - | |
| 21 | + /** | |
| 22 | + * spu 编号 | |
| 23 | + */ | |
| 21 | 24 | @NotNull(message = "spu 编号不能为空") |
| 22 | 25 | private Long spuId; |
| 23 | - | |
| 26 | + /** | |
| 27 | + * sku 编号 | |
| 28 | + */ | |
| 24 | 29 | @NotNull(message = "sku 编号不能为空") |
| 25 | 30 | private Long skuId; |
| 26 | - | |
| 31 | + /** | |
| 32 | + * 订单编号 | |
| 33 | + */ | |
| 27 | 34 | @NotNull(message = "订单编号不能为空") |
| 28 | 35 | private Long orderId; |
| 29 | - | |
| 36 | + /** | |
| 37 | + * 用户编号 | |
| 38 | + */ | |
| 30 | 39 | @NotNull(message = "用户编号不能为空") |
| 31 | 40 | private Long userId; |
| 32 | - | |
| 41 | + /** | |
| 42 | + * 团长编号 | |
| 43 | + */ | |
| 33 | 44 | @NotNull(message = "团长编号不能为空") |
| 34 | 45 | private Long headId; |
| 35 | - | |
| 46 | + /** | |
| 47 | + * 拼团商品单价 | |
| 48 | + */ | |
| 36 | 49 | @NotNull(message = "拼团商品单价不能为空") |
| 37 | 50 | private Integer combinationPrice; |
| 38 | 51 | ... | ... |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApi.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.api.seckill; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillActivityUpdateStockReqDTO; | |
| 4 | - | |
| 5 | 3 | /** |
| 6 | 4 | * 秒杀活动 API 接口 |
| 7 | 5 | * |
| ... | ... | @@ -12,8 +10,10 @@ public interface SeckillActivityApi { |
| 12 | 10 | /** |
| 13 | 11 | * 更新秒杀库存 |
| 14 | 12 | * |
| 15 | - * @param updateStockReqDTO 请求 | |
| 13 | + * @param activityId 活动编号 | |
| 14 | + * @param skuId sku 编号 | |
| 15 | + * @param count 数量 | |
| 16 | 16 | */ |
| 17 | - void updateSeckillStock(SeckillActivityUpdateStockReqDTO updateStockReqDTO); | |
| 17 | + void updateSeckillStock(Long activityId, Long skuId, Integer count); | |
| 18 | 18 | |
| 19 | 19 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/dto/SeckillActivityUpdateStockReqDTO.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.api.seckill.dto; | |
| 2 | - | |
| 3 | -import lombok.Data; | |
| 4 | - | |
| 5 | -import javax.validation.Valid; | |
| 6 | -import javax.validation.constraints.NotNull; | |
| 7 | - | |
| 8 | -/** | |
| 9 | - * 更新秒杀库存 request DTO | |
| 10 | - * | |
| 11 | - * @author HUIHUI | |
| 12 | - */ | |
| 13 | -@Data | |
| 14 | -public class SeckillActivityUpdateStockReqDTO { | |
| 15 | - | |
| 16 | - // TODO @puhui999:可以不用 dto,直接 activityId、skuId、count 即可 | |
| 17 | - | |
| 18 | - @NotNull(message = "活动编号不能为空") | |
| 19 | - private Long activityId; | |
| 20 | - | |
| 21 | - @NotNull(message = "购买数量不能为空") | |
| 22 | - private Integer count; | |
| 23 | - | |
| 24 | - @NotNull(message = "活动商品不能为空") | |
| 25 | - private Item item; | |
| 26 | - | |
| 27 | - @Data | |
| 28 | - @Valid | |
| 29 | - public static class Item { | |
| 30 | - | |
| 31 | - @NotNull(message = "SPU 编号不能为空") | |
| 32 | - private Long spuId; | |
| 33 | - | |
| 34 | - @NotNull(message = "SKU 编号活动商品不能为空") | |
| 35 | - private Long skuId; | |
| 36 | - | |
| 37 | - @NotNull(message = "购买数量不能为空") | |
| 38 | - private Integer count; | |
| 39 | - | |
| 40 | - } | |
| 41 | - | |
| 42 | -} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationApiImpl.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationActivityApiImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.api.combination; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationActivityUpdateStockReqDTO; | |
| 4 | 3 | import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService; |
| 4 | +import org.springframework.stereotype.Service; | |
| 5 | 5 | |
| 6 | 6 | import javax.annotation.Resource; |
| 7 | 7 | |
| ... | ... | @@ -10,14 +10,15 @@ import javax.annotation.Resource; |
| 10 | 10 | * |
| 11 | 11 | * @author HUIHUI |
| 12 | 12 | */ |
| 13 | -public class CombinationApiImpl implements CombinationApi { | |
| 13 | +@Service | |
| 14 | +public class CombinationActivityApiImpl implements CombinationActivityApi { | |
| 14 | 15 | |
| 15 | 16 | @Resource |
| 16 | 17 | private CombinationActivityService activityService; |
| 17 | 18 | |
| 18 | 19 | @Override |
| 19 | - public void validateCombination(CombinationActivityUpdateStockReqDTO reqDTO) { | |
| 20 | - activityService.validateCombination(reqDTO); | |
| 20 | + public void validateCombination(Long activityId, Long userId, Long skuId, Integer count) { | |
| 21 | + activityService.validateCombination(activityId, userId, skuId, count); | |
| 21 | 22 | } |
| 22 | 23 | |
| 23 | 24 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.api.combination; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 4 | -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordRespDTO; | |
| 5 | -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; | |
| 6 | 4 | import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; |
| 7 | 5 | import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; |
| 8 | 6 | import org.springframework.stereotype.Service; |
| 9 | 7 | |
| 10 | 8 | import javax.annotation.Resource; |
| 11 | 9 | import java.time.LocalDateTime; |
| 12 | -import java.util.List; | |
| 13 | 10 | |
| 14 | 11 | /** |
| 15 | 12 | * 拼团活动 API 实现类 |
| ... | ... | @@ -33,16 +30,6 @@ public class CombinationRecordApiImpl implements CombinationRecordApi { |
| 33 | 30 | } |
| 34 | 31 | |
| 35 | 32 | @Override |
| 36 | - public List<CombinationRecordRespDTO> getRecordListByUserIdAndActivityId(Long userId, Long activityId) { | |
| 37 | - return CombinationActivityConvert.INSTANCE.convert(recordService.getRecordListByUserIdAndActivityId(userId, activityId)); | |
| 38 | - } | |
| 39 | - | |
| 40 | - @Override | |
| 41 | - public void validateCombinationLimitCount(Long activityId, Integer count, Integer sumCount) { | |
| 42 | - recordService.validateCombinationLimitCount(activityId, count, sumCount); | |
| 43 | - } | |
| 44 | - | |
| 45 | - @Override | |
| 46 | 33 | public void updateRecordStatusToSuccess(Long userId, Long orderId) { |
| 47 | 34 | recordService.updateCombinationRecordStatusByUserIdAndOrderId(CombinationRecordStatusEnum.SUCCESS.getStatus(), userId, orderId); |
| 48 | 35 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApiImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.api.seckill; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillActivityUpdateStockReqDTO; | |
| 4 | 3 | import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService; |
| 5 | 4 | import org.springframework.stereotype.Service; |
| 6 | 5 | |
| ... | ... | @@ -18,8 +17,8 @@ public class SeckillActivityApiImpl implements SeckillActivityApi { |
| 18 | 17 | private SeckillActivityService activityService; |
| 19 | 18 | |
| 20 | 19 | @Override |
| 21 | - public void updateSeckillStock(SeckillActivityUpdateStockReqDTO updateStockReqDTO) { | |
| 22 | - activityService.updateSeckillStock(updateStockReqDTO); | |
| 20 | + public void updateSeckillStock(Long activityId, Long skuId, Integer count) { | |
| 21 | + activityService.updateSeckillStock(activityId, skuId, count); | |
| 23 | 22 | } |
| 24 | 23 | |
| 25 | 24 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java
| ... | ... | @@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.promotion.convert.combination; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| 6 | +import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; | |
| 7 | +import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; | |
| 6 | 8 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; |
| 7 | 9 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 8 | 10 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordRespDTO; |
| ... | ... | @@ -92,6 +94,19 @@ public interface CombinationActivityConvert { |
| 92 | 94 | |
| 93 | 95 | CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO); |
| 94 | 96 | |
| 97 | + default CombinationRecordDO convert1(CombinationRecordCreateReqDTO reqDTO, CombinationActivityDO activity, MemberUserRespDTO user, | |
| 98 | + ProductSpuRespDTO spu, ProductSkuRespDTO sku) { | |
| 99 | + CombinationRecordDO record = convert(reqDTO); | |
| 100 | + record.setVirtualGroup(false); | |
| 101 | + record.setExpireTime(record.getStartTime().plusHours(activity.getLimitDuration())); | |
| 102 | + record.setUserSize(activity.getUserSize()); | |
| 103 | + record.setNickname(user.getNickname()); | |
| 104 | + record.setAvatar(user.getAvatar()); | |
| 105 | + record.setSpuName(spu.getName()); | |
| 106 | + record.setPicUrl(sku.getPicUrl()); | |
| 107 | + return record; | |
| 108 | + } | |
| 109 | + | |
| 95 | 110 | List<CombinationRecordRespDTO> convert(List<CombinationRecordDO> bean); |
| 96 | 111 | |
| 97 | 112 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java
| ... | ... | @@ -39,7 +39,7 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> { |
| 39 | 39 | default int updateActivityStock(Long id, int count) { |
| 40 | 40 | return update(null, new LambdaUpdateWrapper<BargainActivityDO>() |
| 41 | 41 | .eq(BargainActivityDO::getId, id) |
| 42 | - .gt(BargainActivityDO::getStock, 0) // TODO @puhui999:不是 > 0,是要大于 count 哈 | |
| 42 | + .gt(BargainActivityDO::getStock, count) | |
| 43 | 43 | .setSql("stock = stock - " + count)); |
| 44 | 44 | } |
| 45 | 45 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java
| ... | ... | @@ -34,7 +34,7 @@ public interface SeckillProductMapper extends BaseMapperX<SeckillProductDO> { |
| 34 | 34 | default int updateActivityStock(Long id, int count) { |
| 35 | 35 | return update(null, new LambdaUpdateWrapper<SeckillProductDO>() |
| 36 | 36 | .eq(SeckillProductDO::getId, id) |
| 37 | - .gt(SeckillProductDO::getStock, 0) // TODO @puhui999:不是 > 0,是要大于 count 哈 | |
| 37 | + .gt(SeckillProductDO::getStock, count) | |
| 38 | 38 | .setSql("stock = stock - " + count)); |
| 39 | 39 | } |
| 40 | 40 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.service.combination; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationActivityUpdateStockReqDTO; | |
| 5 | 4 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO; |
| 6 | 5 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageReqVO; |
| 7 | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO; |
| ... | ... | @@ -74,10 +73,13 @@ public interface CombinationActivityService { |
| 74 | 73 | List<CombinationProductDO> getCombinationProductsByActivityIds(Collection<Long> activityIds); |
| 75 | 74 | |
| 76 | 75 | /** |
| 77 | - * 更新拼图活动库存 | |
| 76 | + * 校验是否满足拼团条件 | |
| 78 | 77 | * |
| 79 | - * @param reqDTO 请求 | |
| 78 | + * @param activityId 活动编号 | |
| 79 | + * @param userId 用户编号 | |
| 80 | + * @param skuId sku 编号 | |
| 81 | + * @param count 数量 | |
| 80 | 82 | */ |
| 81 | - void validateCombination(CombinationActivityUpdateStockReqDTO reqDTO); | |
| 83 | + void validateCombination(Long activityId, Long userId, Long skuId, Integer count); | |
| 82 | 84 | |
| 83 | 85 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java
| ... | ... | @@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; |
| 9 | 9 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; |
| 10 | 10 | import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; |
| 11 | 11 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; |
| 12 | -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationActivityUpdateStockReqDTO; | |
| 13 | 12 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO; |
| 14 | 13 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageReqVO; |
| 15 | 14 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO; |
| ... | ... | @@ -33,7 +32,6 @@ import java.util.Map; |
| 33 | 32 | |
| 34 | 33 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 35 | 34 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; |
| 36 | -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | |
| 37 | 35 | import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; |
| 38 | 36 | import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; |
| 39 | 37 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; |
| ... | ... | @@ -85,7 +83,7 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic |
| 85 | 83 | /** |
| 86 | 84 | * 校验拼团商品参与的活动是否存在冲突 |
| 87 | 85 | * |
| 88 | - * @param spuId 商品 SPU 编号 | |
| 86 | + * @param spuId 商品 SPU 编号 | |
| 89 | 87 | * @param activityId 拼团活动编号 |
| 90 | 88 | */ |
| 91 | 89 | private void validateProductConflict(Long spuId, Long activityId) { |
| ... | ... | @@ -104,7 +102,7 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic |
| 104 | 102 | /** |
| 105 | 103 | * 校验拼团商品是否都存在 |
| 106 | 104 | * |
| 107 | - * @param spuId 商品 SPU 编号 | |
| 105 | + * @param spuId 商品 SPU 编号 | |
| 108 | 106 | * @param products 拼团商品 |
| 109 | 107 | */ |
| 110 | 108 | private void validateProductExists(Long spuId, List<CombinationProductBaseVO> products) { |
| ... | ... | @@ -149,7 +147,7 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic |
| 149 | 147 | * 更新拼团商品 |
| 150 | 148 | * |
| 151 | 149 | * @param activity 拼团活动 |
| 152 | - * @param products 该活动的最新商品配置 | |
| 150 | + * @param products 该活动的最新商品配置 | |
| 153 | 151 | */ |
| 154 | 152 | private void updateCombinationProduct(CombinationActivityDO activity, List<CombinationProductBaseVO> products) { |
| 155 | 153 | // 第一步,对比新老数据,获得添加、修改、删除的列表 |
| ... | ... | @@ -214,35 +212,34 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic |
| 214 | 212 | } |
| 215 | 213 | |
| 216 | 214 | @Override |
| 217 | - public void validateCombination(CombinationActivityUpdateStockReqDTO reqDTO) { | |
| 215 | + public void validateCombination(Long activityId, Long userId, Long skuId, Integer count) { | |
| 218 | 216 | // 1.1 校验拼团活动是否存在 |
| 219 | - CombinationActivityDO activity = validateCombinationActivityExists(reqDTO.getActivityId()); | |
| 217 | + CombinationActivityDO activity = validateCombinationActivityExists(activityId); | |
| 220 | 218 | // 1.2 校验活动是否开启 |
| 221 | 219 | if (ObjectUtil.equal(activity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { |
| 222 | 220 | throw exception(COMBINATION_ACTIVITY_STATUS_DISABLE); |
| 223 | 221 | } |
| 224 | 222 | // 1.3 校验是否超出单次限购数量 |
| 225 | - if (activity.getSingleLimitCount() < reqDTO.getCount()) { | |
| 223 | + if (activity.getSingleLimitCount() < count) { | |
| 226 | 224 | throw exception(COMBINATION_RECORD_FAILED_SINGLE_LIMIT_COUNT_EXCEED); |
| 227 | 225 | } |
| 228 | 226 | |
| 229 | 227 | // 2. 校验是否超出总限购数量 |
| 230 | - // TODO @puhui999:userId 应该接口传递哈;要保证 service 无状态 | |
| 231 | - List<CombinationRecordDO> recordList = combinationRecordService.getRecordListByUserIdAndActivityId( | |
| 232 | - getLoginUserId(), reqDTO.getActivityId()); | |
| 233 | - // TODO @puhui999:最好 if true return;减少括号层数 | |
| 234 | - if (CollUtil.isNotEmpty(recordList)) { | |
| 235 | - // 过滤出拼团成功的 | |
| 236 | - // TODO @puhui999:count 要不存一个在 record 里? | |
| 237 | - List<Long> skuIds = convertList(recordList, CombinationRecordDO::getSkuId, | |
| 238 | - item -> ObjectUtil.equals(item.getStatus(), CombinationRecordStatusEnum.SUCCESS.getStatus())); | |
| 239 | - Integer countSum = tradeOrderApi.getOrderItemCountSumByOrderIdAndSkuId(convertList(recordList, | |
| 240 | - CombinationRecordDO::getOrderId, | |
| 241 | - item -> ObjectUtil.equals(item.getStatus(), CombinationRecordStatusEnum.SUCCESS.getStatus())), skuIds); | |
| 242 | - if (activity.getTotalLimitCount() < countSum) { | |
| 243 | - throw exception(COMBINATION_RECORD_FAILED_TOTAL_LIMIT_COUNT_EXCEED); | |
| 244 | - } | |
| 228 | + List<CombinationRecordDO> recordList = combinationRecordService.getRecordListByUserIdAndActivityId(userId, activityId); | |
| 229 | + if (CollUtil.isEmpty(recordList)) { | |
| 230 | + return; | |
| 231 | + } | |
| 232 | + // 过滤出拼团成功的 | |
| 233 | + // TODO @puhui999:count 要不存一个在 record 里? | |
| 234 | + List<Long> skuIds = convertList(recordList, CombinationRecordDO::getSkuId, | |
| 235 | + item -> ObjectUtil.equals(item.getStatus(), CombinationRecordStatusEnum.SUCCESS.getStatus())); | |
| 236 | + Integer countSum = tradeOrderApi.getOrderItemCountSumByOrderIdAndSkuId(convertList(recordList, | |
| 237 | + CombinationRecordDO::getOrderId, | |
| 238 | + item -> ObjectUtil.equals(item.getStatus(), CombinationRecordStatusEnum.SUCCESS.getStatus())), skuIds); | |
| 239 | + if (activity.getTotalLimitCount() < countSum) { | |
| 240 | + throw exception(COMBINATION_RECORD_FAILED_TOTAL_LIMIT_COUNT_EXCEED); | |
| 245 | 241 | } |
| 242 | + | |
| 246 | 243 | } |
| 247 | 244 | |
| 248 | 245 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java
| ... | ... | @@ -57,14 +57,4 @@ public interface CombinationRecordService { |
| 57 | 57 | */ |
| 58 | 58 | List<CombinationRecordDO> getRecordListByUserIdAndActivityId(Long userId, Long activityId); |
| 59 | 59 | |
| 60 | - /** | |
| 61 | - * 验证组合限制数 | |
| 62 | - * 校验是否满足限购要求 | |
| 63 | - * | |
| 64 | - * @param count 本次购买数量 | |
| 65 | - * @param sumCount 已购买数量合计 | |
| 66 | - * @param activityId 活动编号 | |
| 67 | - */ | |
| 68 | - void validateCombinationLimitCount(Long activityId, Integer count, Integer sumCount); | |
| 69 | - | |
| 70 | 60 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
| ... | ... | @@ -128,19 +128,10 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | // 2. 创建拼团记录 |
| 131 | - // TODO @puhui999:可以把 user、spu、sku 一起放 convert 里哈; | |
| 132 | - CombinationRecordDO record = CombinationActivityConvert.INSTANCE.convert(reqDTO); | |
| 133 | - record.setVirtualGroup(false); | |
| 134 | - record.setExpireTime(record.getStartTime().plusHours(activity.getLimitDuration())); | |
| 135 | - record.setUserSize(activity.getUserSize()); | |
| 136 | 131 | MemberUserRespDTO user = memberUserApi.getUser(reqDTO.getUserId()); |
| 137 | - record.setNickname(user.getNickname()); | |
| 138 | - record.setAvatar(user.getAvatar()); | |
| 139 | - ProductSpuRespDTO spu = productSpuApi.getSpu(record.getSpuId()); | |
| 140 | - record.setSpuName(spu.getName()); | |
| 141 | - ProductSkuRespDTO sku = productSkuApi.getSku(record.getSkuId()); | |
| 142 | - record.setPicUrl(sku.getPicUrl()); | |
| 143 | - recordMapper.insert(record); | |
| 132 | + ProductSpuRespDTO spu = productSpuApi.getSpu(reqDTO.getSpuId()); | |
| 133 | + ProductSkuRespDTO sku = productSkuApi.getSku(reqDTO.getSkuId()); | |
| 134 | + recordMapper.insert(CombinationActivityConvert.INSTANCE.convert1(reqDTO, activity, user, spu, sku)); | |
| 144 | 135 | } |
| 145 | 136 | |
| 146 | 137 | @Override |
| ... | ... | @@ -153,20 +144,6 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 153 | 144 | return recordMapper.selectListByUserIdAndActivityId(userId, activityId); |
| 154 | 145 | } |
| 155 | 146 | |
| 156 | - @Override | |
| 157 | - public void validateCombinationLimitCount(Long activityId, Integer count, Integer sumCount) { | |
| 158 | - // 1.1 校验拼团活动 | |
| 159 | - CombinationActivityDO activity = combinationActivityService.validateCombinationActivityExists(activityId); | |
| 160 | - // 校验是否达到限购总限购标准 | |
| 161 | - if ((sumCount + count) > activity.getTotalLimitCount()) { | |
| 162 | - throw exception(COMBINATION_RECORD_FAILED_TOTAL_LIMIT_COUNT_EXCEED); | |
| 163 | - } | |
| 164 | - // 单次购买是否达到限购标准 | |
| 165 | - if (count > activity.getSingleLimitCount()) { | |
| 166 | - throw exception(COMBINATION_RECORD_FAILED_SINGLE_LIMIT_COUNT_EXCEED); | |
| 167 | - } | |
| 168 | - } | |
| 169 | - | |
| 170 | 147 | /** |
| 171 | 148 | * APP 端获取开团记录 |
| 172 | 149 | * | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityService.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.service.seckill; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillActivityUpdateStockReqDTO; | |
| 5 | 4 | import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; |
| 6 | 5 | import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; |
| 7 | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; |
| ... | ... | @@ -37,9 +36,11 @@ public interface SeckillActivityService { |
| 37 | 36 | /** |
| 38 | 37 | * 更新秒杀库存 |
| 39 | 38 | * |
| 40 | - * @param updateStockReqDTO 更新信息 | |
| 39 | + * @param activityId 活动编号 | |
| 40 | + * @param skuId sku 编号 | |
| 41 | + * @param count 数量 | |
| 41 | 42 | */ |
| 42 | - void updateSeckillStock(SeckillActivityUpdateStockReqDTO updateStockReqDTO); | |
| 43 | + void updateSeckillStock(Long activityId, Long skuId, Integer count); | |
| 43 | 44 | |
| 44 | 45 | /** |
| 45 | 46 | * 关闭秒杀活动 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java
| ... | ... | @@ -7,7 +7,6 @@ import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; |
| 7 | 7 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; |
| 8 | 8 | import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; |
| 9 | 9 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; |
| 10 | -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillActivityUpdateStockReqDTO; | |
| 11 | 10 | import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; |
| 12 | 11 | import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; |
| 13 | 12 | import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; |
| ... | ... | @@ -147,32 +146,32 @@ public class SeckillActivityServiceImpl implements SeckillActivityService { |
| 147 | 146 | |
| 148 | 147 | @Override |
| 149 | 148 | @Transactional(rollbackFor = Exception.class) |
| 150 | - public void updateSeckillStock(SeckillActivityUpdateStockReqDTO updateStockReqDTO) { | |
| 149 | + public void updateSeckillStock(Long activityId, Long skuId, Integer count) { | |
| 151 | 150 | // 1、校验秒杀活动是否存在 |
| 152 | - SeckillActivityDO seckillActivity = getSeckillActivity(updateStockReqDTO.getActivityId()); | |
| 151 | + SeckillActivityDO seckillActivity = getSeckillActivity(activityId); | |
| 153 | 152 | // 1.1、校验库存是否充足 |
| 154 | - if (seckillActivity.getTotalStock() < updateStockReqDTO.getCount()) { | |
| 153 | + if (seckillActivity.getTotalStock() < count) { | |
| 155 | 154 | throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL); |
| 156 | 155 | } |
| 157 | 156 | |
| 158 | 157 | // 2、获取活动商品 |
| 159 | - List<SeckillProductDO> products = getSeckillProductListByActivityId(updateStockReqDTO.getActivityId()); | |
| 158 | + List<SeckillProductDO> products = getSeckillProductListByActivityId(activityId); | |
| 160 | 159 | // 2.1、过滤出购买的商品 |
| 161 | - SeckillProductDO product = findFirst(products, item -> ObjectUtil.equal(updateStockReqDTO.getItem().getSkuId(), item.getSkuId())); | |
| 160 | + SeckillProductDO product = findFirst(products, item -> ObjectUtil.equal(skuId, item.getSkuId())); | |
| 162 | 161 | // 2.2、检查活动商品库存是否充足 |
| 163 | - boolean isSufficient = product == null || (product.getStock() == 0 || (product.getStock() < updateStockReqDTO.getItem().getCount()) || (product.getStock() - updateStockReqDTO.getItem().getCount()) < 0); | |
| 162 | + boolean isSufficient = product == null || (product.getStock() == 0 || (product.getStock() < count) || (product.getStock() - count) < 0); | |
| 164 | 163 | if (isSufficient) { |
| 165 | 164 | throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL); |
| 166 | 165 | } |
| 167 | 166 | |
| 168 | 167 | // 3、更新活动商品库存 |
| 169 | - int updateCount = seckillProductMapper.updateActivityStock(product.getId(), updateStockReqDTO.getItem().getCount()); | |
| 168 | + int updateCount = seckillProductMapper.updateActivityStock(product.getId(), count); | |
| 170 | 169 | if (updateCount == 0) { |
| 171 | 170 | throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL); |
| 172 | 171 | } |
| 173 | 172 | |
| 174 | 173 | // 4、更新活动库存 |
| 175 | - updateCount = seckillActivityMapper.updateActivityStock(seckillActivity.getId(), updateStockReqDTO.getCount()); | |
| 174 | + updateCount = seckillActivityMapper.updateActivityStock(seckillActivity.getId(), count); | |
| 176 | 175 | if (updateCount == 0) { |
| 177 | 176 | throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL); |
| 178 | 177 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java
| ... | ... | @@ -14,9 +14,7 @@ import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDT |
| 14 | 14 | import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; |
| 15 | 15 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; |
| 16 | 16 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; |
| 17 | -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationActivityUpdateStockReqDTO; | |
| 18 | 17 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 19 | -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillActivityUpdateStockReqDTO; | |
| 20 | 18 | import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; |
| 21 | 19 | import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; |
| 22 | 20 | import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; |
| ... | ... | @@ -280,15 +278,9 @@ public interface TradeOrderConvert { |
| 280 | 278 | return new BrokerageAddReqBO().setBizId(String.valueOf(item.getId())).setSourceUserId(item.getUserId()) |
| 281 | 279 | .setBasePrice(item.getPayPrice() * item.getCount()) |
| 282 | 280 | .setTitle(BrokerageRecordBizTypeEnum.ORDER.getTitle()) // TODO @疯狂:标题类似:木晴冰雪成功购买云时代的JVM原理与实战;茫农成功购买深入拆解消息队列47讲 |
| 283 | - .setFirstFixedPrice(sku.getFirstBrokerageRecord()).setSecondFixedPrice(sku.getSecondBrokerageRecord()); | |
| 281 | + .setFirstFixedPrice(sku.getFirstBrokeragePrice()).setSecondFixedPrice(sku.getSecondBrokeragePrice()); | |
| 284 | 282 | } |
| 285 | 283 | |
| 286 | - @Mapping(target = "activityId", source = "reqBO.seckillActivityId") | |
| 287 | - SeckillActivityUpdateStockReqDTO convert(TradeBeforeOrderCreateReqBO reqBO); | |
| 288 | - | |
| 289 | - @Mapping(target = "activityId", source = "reqBO.combinationActivityId") | |
| 290 | - CombinationActivityUpdateStockReqDTO convert1(TradeBeforeOrderCreateReqBO reqBO); | |
| 291 | - | |
| 292 | 284 | TradeBeforeOrderCreateReqBO convert(AppTradeOrderCreateReqVO createReqVO); |
| 293 | 285 | |
| 294 | 286 | @Mappings({ | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java
| ... | ... | @@ -180,9 +180,10 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 180 | 180 | @Transactional(rollbackFor = Exception.class) |
| 181 | 181 | public TradeOrderDO createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO) { |
| 182 | 182 | // 1、执行订单创建前置处理器 |
| 183 | - // TODO @puhui999:最好也抽个 beforeOrderCreate 方法; | |
| 183 | + // TODO @puhui999:最好也抽个 beforeOrderCreate 方法;不要 BO 各自处理参数岂不美哉? | |
| 184 | 184 | TradeBeforeOrderCreateReqBO beforeOrderCreateReqBO = TradeOrderConvert.INSTANCE.convert(createReqVO); |
| 185 | 185 | beforeOrderCreateReqBO.setOrderType(validateActivity(createReqVO)); |
| 186 | + beforeOrderCreateReqBO.setUserId(userId); | |
| 186 | 187 | beforeOrderCreateReqBO.setCount(getSumValue(createReqVO.getItems(), AppTradeOrderSettlementReqVO.Item::getCount, Integer::sum)); |
| 187 | 188 | // TODO @puhui999:这里有个纠结点;handler 的定义是只处理指定类型的订单的拓展逻辑;还是通用的 handler,类似可以处理优惠劵等等 |
| 188 | 189 | tradeOrderHandlers.forEach(handler -> handler.beforeOrderCreate(beforeOrderCreateReqBO)); |
| ... | ... | @@ -726,7 +727,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 726 | 727 | } |
| 727 | 728 | |
| 728 | 729 | // TODO 活动相关库存回滚需要活动 id,活动 id 怎么获取?app 端能否传过来 |
| 729 | - tradeOrderHandlers.forEach(handler -> handler.rollbackStock()); | |
| 730 | + tradeOrderHandlers.forEach(handler -> handler.rollback()); | |
| 730 | 731 | |
| 731 | 732 | // 2.回滚库存 |
| 732 | 733 | List<TradeOrderItemDO> orderItems = tradeOrderItemMapper.selectListByOrderId(id); | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/bo/TradeBeforeOrderCreateReqBO.java
| ... | ... | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.trade.service.order.bo; |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | -import javax.validation.Valid; | |
| 7 | 6 | import javax.validation.constraints.NotNull; |
| 8 | 7 | |
| 9 | 8 | // TODO 芋艿:在想想这些参数的定义 |
| ... | ... | @@ -34,25 +33,16 @@ public class TradeBeforeOrderCreateReqBO { |
| 34 | 33 | @Schema(description = "砍价活动编号", example = "123") |
| 35 | 34 | private Long bargainActivityId; |
| 36 | 35 | |
| 37 | - @NotNull(message = "购买数量不能为空") | |
| 38 | - private Integer count; | |
| 39 | - | |
| 40 | - @NotNull(message = "活动商品不能为空") | |
| 41 | - private Item item; | |
| 42 | - | |
| 43 | - @Data | |
| 44 | - @Valid | |
| 45 | - public static class Item { | |
| 36 | + @NotNull(message = "SPU 编号不能为空") | |
| 37 | + private Long spuId; | |
| 46 | 38 | |
| 47 | - @NotNull(message = "SPU 编号不能为空") | |
| 48 | - private Long spuId; | |
| 39 | + @NotNull(message = "SKU 编号活动商品不能为空") | |
| 40 | + private Long skuId; | |
| 49 | 41 | |
| 50 | - @NotNull(message = "SKU 编号活动商品不能为空") | |
| 51 | - private Long skuId; | |
| 42 | + @NotNull(message = "用户编号不能为空") | |
| 43 | + private Long userId; | |
| 52 | 44 | |
| 53 | - @NotNull(message = "购买数量不能为空") | |
| 54 | - private Integer count; | |
| 55 | - | |
| 56 | - } | |
| 45 | + @NotNull(message = "购买数量不能为空") | |
| 46 | + private Integer count; | |
| 57 | 47 | |
| 58 | 48 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBargainHandler.java
| ... | ... | @@ -22,7 +22,7 @@ public class TradeBargainHandler implements TradeOrderHandler { |
| 22 | 22 | |
| 23 | 23 | @Override |
| 24 | 24 | public void beforeOrderCreate(TradeBeforeOrderCreateReqBO reqBO) { |
| 25 | - // 如果是秒杀订单 | |
| 25 | + // 如果是砍价订单 | |
| 26 | 26 | if (ObjectUtil.notEqual(TradeOrderTypeEnum.BARGAIN.getType(), reqBO.getOrderType())) { |
| 27 | 27 | return; |
| 28 | 28 | } |
| ... | ... | @@ -37,7 +37,7 @@ public class TradeBargainHandler implements TradeOrderHandler { |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | @Override |
| 40 | - public void rollbackStock() { | |
| 40 | + public void rollback() { | |
| 41 | 41 | |
| 42 | 42 | } |
| 43 | 43 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationHandler.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.service.order.handler; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.util.ObjectUtil; |
| 4 | -import cn.iocoder.yudao.module.promotion.api.combination.CombinationApi; | |
| 4 | +import cn.iocoder.yudao.module.promotion.api.combination.CombinationActivityApi; | |
| 5 | 5 | import cn.iocoder.yudao.module.promotion.api.combination.CombinationRecordApi; |
| 6 | 6 | import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; |
| 7 | 7 | import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; |
| ... | ... | @@ -20,7 +20,7 @@ import javax.annotation.Resource; |
| 20 | 20 | public class TradeCombinationHandler implements TradeOrderHandler { |
| 21 | 21 | |
| 22 | 22 | @Resource |
| 23 | - private CombinationApi combinationApi; | |
| 23 | + private CombinationActivityApi combinationActivityApi; | |
| 24 | 24 | @Resource |
| 25 | 25 | private CombinationRecordApi combinationRecordApi; |
| 26 | 26 | |
| ... | ... | @@ -32,7 +32,7 @@ public class TradeCombinationHandler implements TradeOrderHandler { |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | // 校验是否满足拼团活动相关限制 |
| 35 | - combinationApi.validateCombination(TradeOrderConvert.INSTANCE.convert1(reqBO)); | |
| 35 | + combinationActivityApi.validateCombination(reqBO.getCombinationActivityId(), reqBO.getUserId(), reqBO.getSkuId(), reqBO.getCount()); | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | @Override |
| ... | ... | @@ -42,7 +42,7 @@ public class TradeCombinationHandler implements TradeOrderHandler { |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | @Override |
| 45 | - public void rollbackStock() { | |
| 45 | + public void rollback() { | |
| 46 | 46 | |
| 47 | 47 | } |
| 48 | 48 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeOrderHandler.java
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeSeckillHandler.java
| ... | ... | @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.trade.service.order.handler; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.util.ObjectUtil; |
| 4 | 4 | import cn.iocoder.yudao.module.promotion.api.seckill.SeckillActivityApi; |
| 5 | -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; | |
| 6 | 5 | import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; |
| 7 | 6 | import cn.iocoder.yudao.module.trade.service.order.bo.TradeAfterOrderCreateReqBO; |
| 8 | 7 | import cn.iocoder.yudao.module.trade.service.order.bo.TradeBeforeOrderCreateReqBO; |
| ... | ... | @@ -28,7 +27,7 @@ public class TradeSeckillHandler implements TradeOrderHandler { |
| 28 | 27 | return; |
| 29 | 28 | } |
| 30 | 29 | |
| 31 | - seckillActivityApi.updateSeckillStock(TradeOrderConvert.INSTANCE.convert(reqBO)); | |
| 30 | + seckillActivityApi.updateSeckillStock(reqBO.getSeckillActivityId(), reqBO.getSkuId(), reqBO.getCount()); | |
| 32 | 31 | } |
| 33 | 32 | |
| 34 | 33 | @Override |
| ... | ... | @@ -37,7 +36,7 @@ public class TradeSeckillHandler implements TradeOrderHandler { |
| 37 | 36 | } |
| 38 | 37 | |
| 39 | 38 | @Override |
| 40 | - public void rollbackStock() { | |
| 39 | + public void rollback() { | |
| 41 | 40 | |
| 42 | 41 | } |
| 43 | 42 | ... | ... |