Commit 159c74ce15ca924d251ae41a213cf80490acd70d

Authored by YunaiV
1 parent 60171ce7

订单:

1. review 发货
2. review 拼团逻辑
Showing 18 changed files with 112 additions and 131 deletions
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApi.java
... ... @@ -18,7 +18,7 @@ public interface BargainRecordApi {
18 18 *
19 19 * @param reqDTO 请求 DTO
20 20 */
21   - void createRecord(@Valid BargainRecordCreateReqDTO reqDTO);
  21 + void createBargainRecord(@Valid BargainRecordCreateReqDTO reqDTO);
22 22  
23 23 /**
24 24 * 查询砍价是否成功
... ... @@ -27,6 +27,6 @@ public interface BargainRecordApi {
27 27 * @param orderId 订单编号
28 28 * @return 砍价是否成功
29 29 */
30   - boolean validateRecordSuccess(Long userId, Long orderId);
  30 + boolean isBargainRecordSuccess(Long userId, Long orderId);
31 31  
32 32 }
... ...
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java
... ... @@ -21,7 +21,7 @@ public interface CombinationRecordApi {
21 21 *
22 22 * @param reqDTO 请求 DTO
23 23 */
24   - void createRecord(@Valid CombinationRecordCreateReqDTO reqDTO);
  24 + void createCombinationRecord(@Valid CombinationRecordCreateReqDTO reqDTO);
25 25  
26 26 /**
27 27 * 查询拼团记录是否成功
... ... @@ -30,7 +30,7 @@ public interface CombinationRecordApi {
30 30 * @param orderId 订单编号
31 31 * @return 拼团是否成功
32 32 */
33   - boolean validateRecordSuccess(Long userId, Long orderId);
  33 + boolean isCombinationRecordSuccess(Long userId, Long orderId);
34 34  
35 35 /**
36 36 * 获取拼团记录
... ...
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordRespDTO.java
1 1 package cn.iocoder.yudao.module.promotion.api.combination.dto;
2 2  
  3 +import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
3 4 import lombok.Data;
4 5  
5   -import javax.validation.constraints.NotNull;
6   -
7 6 /**
8 7 * 拼团记录 Response DTO
9 8 *
... ... @@ -15,32 +14,28 @@ public class CombinationRecordRespDTO {
15 14 /**
16 15 * 拼团活动编号
17 16 */
18   - @NotNull(message = "拼团活动编号不能为空")
19 17 private Long activityId;
20 18 /**
21   - * spu 编号
  19 + * SPU 编号
22 20 */
23   - @NotNull(message = "spu 编号不能为空")
24 21 private Long spuId;
25 22 /**
26   - * sku 编号
  23 + * SKU 编号
27 24 */
28   - @NotNull(message = "sku 编号不能为空")
29 25 private Long skuId;
30 26 /**
31 27 * 用户编号
32 28 */
33   - @NotNull(message = "用户编号不能为空")
34 29 private Long userId;
35 30 /**
36 31 * 订单编号
37 32 */
38   - @NotNull(message = "订单编号不能为空")
39 33 private Long orderId;
40 34 /**
41   - * 开团状态:正在开团 拼团成功 拼团失败
  35 + * 开团状态
  36 + *
  37 + * 枚举 {@link CombinationRecordStatusEnum}
42 38 */
43   - @NotNull(message = "开团状态不能为空")
44 39 private Integer status;
45 40  
46 41 }
... ...
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java
... ... @@ -62,22 +62,26 @@ public interface ErrorCodeConstants {
62 62 ErrorCode COMBINATION_ACTIVITY_STATUS_DISABLE = new ErrorCode(1013010002, "拼团活动已关闭不能修改");
63 63 ErrorCode COMBINATION_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1013010003, "拼团活动未关闭或未结束,不能删除");
64 64 ErrorCode COMBINATION_RECORD_NOT_EXISTS = new ErrorCode(1013010004, "拼团不存在");
65   - ErrorCode COMBINATION_RECORD_EXISTS = new ErrorCode(1013010005, "拼团失败,已参与过该拼团");
66   - ErrorCode COMBINATION_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1013010006, "拼团失败,父拼团不存在");
67   - ErrorCode COMBINATION_RECORD_USER_FULL = new ErrorCode(1013010007, "拼团失败,拼团人数已满");
68   - ErrorCode COMBINATION_RECORD_FAILED_HAVE_JOINED = new ErrorCode(1013010008, "拼团失败,已参与其它拼团");
69   - ErrorCode COMBINATION_RECORD_FAILED_TIME_END = new ErrorCode(1013010009, "拼团失败,活动已经结束");
70   - ErrorCode COMBINATION_RECORD_FAILED_SINGLE_LIMIT_COUNT_EXCEED = new ErrorCode(1013010010, "拼团失败,单次限购超出");
71   - ErrorCode COMBINATION_RECORD_FAILED_TOTAL_LIMIT_COUNT_EXCEED = new ErrorCode(1013010011, "拼团失败,单次限购超出");
72   -
73   - // ========== 砍价活动 1013011000 ==========
74   - ErrorCode BARGAIN_ACTIVITY_NOT_EXISTS = new ErrorCode(1013011000, "砍价活动不存在");
75   - ErrorCode BARGAIN_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1013011001, "存在商品参加了其它砍价活动");
76   - ErrorCode BARGAIN_ACTIVITY_STATUS_DISABLE = new ErrorCode(1013011002, "砍价活动已关闭不能修改");
77   - ErrorCode BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1013011003, "砍价活动未关闭或未结束,不能删除");
78   - ErrorCode BARGAIN_RECORD_NOT_EXISTS = new ErrorCode(1013011004, "砍价记录不存在");
79   - ErrorCode BARGAIN_RECORD_EXISTS = new ErrorCode(1013011005, "砍价失败,已参与过该砍价");
80   - ErrorCode BARGAIN_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1013011006, "砍价失败,父砍价不存在");
81   - ErrorCode BARGAIN_RECORD_USER_FULL = new ErrorCode(1013011007, "砍价失败,砍价人数已满");
  65 +
  66 + // ========== 拼团记录 1013011000 ==========
  67 + ErrorCode COMBINATION_RECORD_EXISTS = new ErrorCode(1013011000, "拼团失败,已参与过该拼团");
  68 + ErrorCode COMBINATION_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1013011001, "拼团失败,父拼团不存在");
  69 + ErrorCode COMBINATION_RECORD_USER_FULL = new ErrorCode(1013011002, "拼团失败,拼团人数已满");
  70 + ErrorCode COMBINATION_RECORD_FAILED_HAVE_JOINED = new ErrorCode(1013011003, "拼团失败,已参与其它拼团");
  71 + ErrorCode COMBINATION_RECORD_FAILED_TIME_END = new ErrorCode(1013011004, "拼团失败,活动已经结束");
  72 + ErrorCode COMBINATION_RECORD_FAILED_SINGLE_LIMIT_COUNT_EXCEED = new ErrorCode(1013011005, "拼团失败,单次限购超出");
  73 + ErrorCode COMBINATION_RECORD_FAILED_TOTAL_LIMIT_COUNT_EXCEED = new ErrorCode(1013011006, "拼团失败,单次限购超出");
  74 +
  75 + // ========== 砍价活动 1013012000 ==========
  76 + ErrorCode BARGAIN_ACTIVITY_NOT_EXISTS = new ErrorCode(1013012000, "砍价活动不存在");
  77 + ErrorCode BARGAIN_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1013012001, "存在商品参加了其它砍价活动");
  78 + ErrorCode BARGAIN_ACTIVITY_STATUS_DISABLE = new ErrorCode(1013012002, "砍价活动已关闭不能修改");
  79 + ErrorCode BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1013012003, "砍价活动未关闭或未结束,不能删除");
  80 +
  81 + // ========== 砍价记录 1013013000 ==========
  82 + ErrorCode BARGAIN_RECORD_NOT_EXISTS = new ErrorCode(1013013000, "砍价记录不存在");
  83 + ErrorCode BARGAIN_RECORD_EXISTS = new ErrorCode(1013013001, "砍价失败,已参与过该砍价");
  84 + ErrorCode BARGAIN_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1013013002, "砍价失败,父砍价不存在");
  85 + ErrorCode BARGAIN_RECORD_USER_FULL = new ErrorCode(1013013003, "砍价失败,砍价人数已满");
82 86  
83 87 }
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApiImpl.java
... ... @@ -12,12 +12,12 @@ import org.springframework.stereotype.Service;
12 12 public class BargainRecordApiImpl implements BargainRecordApi {
13 13  
14 14 @Override
15   - public void createRecord(BargainRecordCreateReqDTO reqDTO) {
  15 + public void createBargainRecord(BargainRecordCreateReqDTO reqDTO) {
16 16  
17 17 }
18 18  
19 19 @Override
20   - public boolean validateRecordSuccess(Long userId, Long orderId) {
  20 + public boolean isBargainRecordSuccess(Long userId, Long orderId) {
21 21 return false;
22 22 }
23 23  
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java
... ... @@ -23,12 +23,12 @@ public class CombinationRecordApiImpl implements CombinationRecordApi {
23 23 private CombinationRecordService recordService;
24 24  
25 25 @Override
26   - public void createRecord(CombinationRecordCreateReqDTO reqDTO) {
  26 + public void createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) {
27 27 recordService.createCombinationRecord(reqDTO);
28 28 }
29 29  
30 30 @Override
31   - public boolean validateRecordSuccess(Long userId, Long orderId) {
  31 + public boolean isCombinationRecordSuccess(Long userId, Long orderId) {
32 32 return CombinationRecordStatusEnum.isSuccess(recordService.getCombinationRecord(userId, orderId).getStatus());
33 33 }
34 34  
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainActivityController.java
... ... @@ -3,8 +3,7 @@ package cn.iocoder.yudao.module.promotion.controller.admin.bargain;
3 3 import cn.hutool.core.collection.CollUtil;
4 4 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
5 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6   -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
7   -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityBaseVO;
  6 +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO;
8 7 import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO;
9 8 import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityRespVO;
10 9 import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO;
... ... @@ -32,13 +31,10 @@ public class BargainActivityController {
32 31 @Resource
33 32 private BargainActivityService activityService;
34 33  
35   - @Resource
36   - private ProductSpuApi productSpuApi;
37   -
38 34 @PostMapping("/create")
39 35 @Operation(summary = "创建砍价活动")
40 36 @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:create')")
41   - public CommonResult<Long> createBargainActivity(@Valid @RequestBody BargainActivityBaseVO createReqVO) {
  37 + public CommonResult<Long> createBargainActivity(@Valid @RequestBody BargainActivityCreateReqVO createReqVO) {
42 38 return success(activityService.createBargainActivity(createReqVO));
43 39 }
44 40  
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/BargainActivityCreateReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +import lombok.EqualsAndHashCode;
  6 +import lombok.ToString;
  7 +
  8 +@Schema(description = "管理后台 - 砍价活动创建 Request VO")
  9 +@Data
  10 +@EqualsAndHashCode(callSuper = true)
  11 +@ToString(callSuper = true)
  12 +public class BargainActivityCreateReqVO extends BargainActivityBaseVO {
  13 +
  14 +}
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/BargainActivityPageReqVO.java
... ... @@ -15,7 +15,7 @@ public class BargainActivityPageReqVO extends PageParam {
15 15 @Schema(description = "砍价名称", example = "赵六")
16 16 private String name;
17 17  
18   - @Schema(description = "活动状态:0开启 1关闭", example = "0")
  18 + @Schema(description = "活动状态", example = "0")
19 19 private Integer status;
20 20  
21 21 }
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java
... ... @@ -42,8 +42,8 @@ public interface CombinationActivityConvert {
42 42  
43 43 CombinationProductRespVO convert(CombinationProductDO bean);
44 44  
45   - default CombinationActivityRespVO convert(CombinationActivityDO bean, List<CombinationProductDO> productDOs) {
46   - return convert(bean).setProducts(convertList2(productDOs));
  45 + default CombinationActivityRespVO convert(CombinationActivityDO activity, List<CombinationProductDO> products) {
  46 + return convert(activity).setProducts(convertList2(products));
47 47 }
48 48  
49 49 List<CombinationActivityRespVO> convertList(List<CombinationActivityDO> list);
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java
... ... @@ -40,24 +40,24 @@ public interface SeckillActivityConvert {
40 40  
41 41 PageResult<SeckillActivityRespVO> convertPage(PageResult<SeckillActivityDO> page);
42 42  
43   - default PageResult<SeckillActivityRespVO> convertPage(PageResult<SeckillActivityDO> page, List<SeckillProductDO> seckillProducts, List<ProductSpuRespDTO> spuList) {
44   - Map<Long, ProductSpuRespDTO> spuMap = CollectionUtils.convertMap(spuList, ProductSpuRespDTO::getId);
  43 + default PageResult<SeckillActivityRespVO> convertPage(PageResult<SeckillActivityDO> page,
  44 + List<SeckillProductDO> seckillProducts,
  45 + List<ProductSpuRespDTO> spuList) {
45 46 PageResult<SeckillActivityRespVO> pageResult = convertPage(page);
  47 + // 拼接商品
  48 + Map<Long, ProductSpuRespDTO> spuMap = CollectionUtils.convertMap(spuList, ProductSpuRespDTO::getId);
46 49 pageResult.getList().forEach(item -> {
47   - MapUtils.findAndThen(spuMap, item.getSpuId(), spu -> {
48   - item.setSpuName(spu.getName());
49   - item.setPicUrl(spu.getPicUrl());
50   - });
51   -
52 50 item.setProducts(convertList2(seckillProducts));
  51 + MapUtils.findAndThen(spuMap, item.getSpuId(),
  52 + spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()));
53 53 });
54 54 return pageResult;
55 55 }
56 56  
57   - SeckillActivityDetailRespVO convert1(SeckillActivityDO seckillActivity);
  57 + SeckillActivityDetailRespVO convert1(SeckillActivityDO activity);
58 58  
59   - default SeckillActivityDetailRespVO convert(SeckillActivityDO seckillActivity, List<SeckillProductDO> seckillProducts) {
60   - return convert1(seckillActivity).setProducts(convertList2(seckillProducts));
  59 + default SeckillActivityDetailRespVO convert(SeckillActivityDO activity, List<SeckillProductDO> products) {
  60 + return convert1(activity).setProducts(convertList2(products));
61 61 }
62 62  
63 63 @Mappings({
... ... @@ -77,6 +77,6 @@ public interface SeckillActivityConvert {
77 77 return CollectionUtils.convertList(products, item -> convert(activity, item).setActivityStatus(activity.getStatus()));
78 78 }
79 79  
80   - List<SeckillProductRespVO> convertList2(List<SeckillProductDO> productDOs);
  80 + List<SeckillProductRespVO> convertList2(List<SeckillProductDO> list);
81 81  
82 82 }
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainActivityDO.java
1 1 package cn.iocoder.yudao.module.promotion.dal.dataobject.bargain;
2 2  
  3 +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
3 4 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
4 5 import com.baomidou.mybatisplus.annotation.KeySequence;
5 6 import com.baomidou.mybatisplus.annotation.TableId;
... ... @@ -38,7 +39,6 @@ public class BargainActivityDO extends BaseDO {
38 39 * 活动开始时间
39 40 */
40 41 private LocalDateTime startTime;
41   -
42 42 /**
43 43 * 活动结束时间
44 44 */
... ... @@ -46,6 +46,8 @@ public class BargainActivityDO extends BaseDO {
46 46  
47 47 /**
48 48 * 活动状态
  49 + *
  50 + * 枚举 {@link CommonStatusEnum}
49 51 */
50 52 private Integer status;
51 53  
... ... @@ -66,10 +68,14 @@ public class BargainActivityDO extends BaseDO {
66 68 */
67 69 private Integer bargainPrice;
68 70 /**
  71 + * 砍价活动库存
  72 + */
  73 + private Integer stock;
  74 +
  75 + /**
69 76 * 达到该人数,才能砍到低价
70 77 */
71 78 private Integer userSize;
72   -
73 79 /**
74 80 * 最大帮砍次数
75 81 */
... ... @@ -79,22 +85,14 @@ public class BargainActivityDO extends BaseDO {
79 85 * 总限购数量
80 86 */
81 87 private Integer totalLimitCount;
82   -
83   - /**
84   - * 砍价活动库存
85   - */
86   - private Integer stock;
87   -
88 88 /**
89 89 * 用户每次砍价的最小金额,单位:分
90 90 */
91 91 private Integer randomMinPrice;
92   -
93 92 /**
94 93 * 用户每次砍价的最大金额,单位:分
95 94 */
96 95 private Integer randomMaxPrice;
97   -
98 96 /**
99 97 * 砍价成功数量
100 98 */
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java
1 1 package cn.iocoder.yudao.module.promotion.service.bargain;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4   -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityBaseVO;
  4 +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO;
5 5 import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO;
6 6 import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO;
7 7 import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
... ... @@ -21,7 +21,7 @@ public interface BargainActivityService {
21 21 * @param createReqVO 创建信息
22 22 * @return 编号
23 23 */
24   - Long createBargainActivity(@Valid BargainActivityBaseVO createReqVO);
  24 + Long createBargainActivity(@Valid BargainActivityCreateReqVO createReqVO);
25 25  
26 26 /**
27 27 * 更新砍价活动
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java
1 1 package cn.iocoder.yudao.module.promotion.service.bargain;
2 2  
3   -import cn.hutool.core.collection.CollUtil;
4   -import cn.hutool.core.collection.CollectionUtil;
5 3 import cn.hutool.core.util.ObjectUtil;
6 4 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
7 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
8   -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
9 6 import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi;
10 7 import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
11   -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
12   -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
13   -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityBaseVO;
  8 +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO;
14 9 import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO;
15 10 import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO;
16 11 import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert;
17 12 import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
18 13 import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainActivityMapper;
19   -import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainRecordMapper;
20 14 import org.springframework.stereotype.Service;
21 15 import org.springframework.transaction.annotation.Transactional;
22 16 import org.springframework.validation.annotation.Validated;
... ... @@ -27,7 +21,6 @@ import java.util.List;
27 21 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
28 22 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.anyMatch;
29 23 import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS;
30   -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS;
31 24 import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
32 25  
33 26 /**
... ... @@ -39,62 +32,27 @@ import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
39 32 @Validated
40 33 public class BargainActivityServiceImpl implements BargainActivityService {
41 34  
42   -
43 35 @Resource
44 36 private BargainActivityMapper bargainActivityMapper;
45   - @Resource
46   - private BargainRecordMapper recordMapper;
47   - @Resource
48   - private ProductSpuApi productSpuApi;
  37 +
49 38 @Resource
50 39 private ProductSkuApi productSkuApi;
51 40  
52   - private static void validateSku(Long skuId, List<ProductSkuRespDTO> skus) {
53   - // 校验商品 sku 是否存在
54   - if (!CollectionUtils.convertSet(skus, ProductSkuRespDTO::getId).contains(skuId)) {
55   - throw exception(SKU_NOT_EXISTS);
56   - }
57   - }
58   -
59 41 @Override
60   - @Transactional(rollbackFor = Exception.class)
61   - public Long createBargainActivity(BargainActivityBaseVO createReqVO) {
  42 + public Long createBargainActivity(BargainActivityCreateReqVO createReqVO) {
62 43 // 校验商品 SPU 是否存在是否参加的别的活动
63 44 validateBargainConflict(createReqVO.getSpuId(), null);
64   - // 获取所选 spu下的所有 sku
65   - List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(CollectionUtil.newArrayList(createReqVO.getSpuId()));
66   - validateSku(createReqVO.getSkuId(), skus);
  45 + // 校验商品 sku 是否存在
  46 + validateSku(createReqVO.getSkuId());
67 47  
68 48 // 插入砍价活动
69   - BargainActivityDO activityDO = BargainActivityConvert.INSTANCE.convert(createReqVO);
70   - // TODO 营销相关属性初始化 砍价成功更新相关属性
71   - activityDO.setSuccessCount(0);
72   - activityDO.setStatus(CommonStatusEnum.ENABLE.getStatus());
  49 + BargainActivityDO activityDO = BargainActivityConvert.INSTANCE.convert(createReqVO)
  50 + .setStatus(CommonStatusEnum.ENABLE.getStatus()).setSuccessCount(0);
73 51 bargainActivityMapper.insert(activityDO);
74   - // 返回
75 52 return activityDO.getId();
76 53 }
77 54  
78   - private void validateBargainConflict(Long spuId, Long activityId) {
79   - // 校验商品 spu 是否存在
80   - List<ProductSpuRespDTO> spuList = productSpuApi.getSpuList(CollUtil.newArrayList(spuId));
81   - if (CollUtil.isEmpty(spuList)) {
82   - throw exception(SPU_NOT_EXISTS);
83   - }
84   - // 查询所有开启的砍价活动
85   - List<BargainActivityDO> activityDOs = bargainActivityMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus());
86   - // 更新时排除自己
87   - if (activityId != null) {
88   - activityDOs.removeIf(item -> ObjectUtil.equal(item.getId(), activityId));
89   - }
90   - // 校验商品 spu 是否参加了其它活动
91   - if (anyMatch(activityDOs, s -> ObjectUtil.equal(s.getId(), spuId))) {
92   - throw exception(BARGAIN_ACTIVITY_SPU_CONFLICTS);
93   - }
94   - }
95   -
96 55 @Override
97   - @Transactional(rollbackFor = Exception.class)
98 56 public void updateBargainActivity(BargainActivityUpdateReqVO updateReqVO) {
99 57 // 校验存在
100 58 BargainActivityDO activityDO = validateBargainActivityExists(updateReqVO.getId());
... ... @@ -104,15 +62,31 @@ public class BargainActivityServiceImpl implements BargainActivityService {
104 62 }
105 63 // 校验商品冲突
106 64 validateBargainConflict(updateReqVO.getSpuId(), updateReqVO.getId());
107   - // 获取所选 spu下的所有 sku
108   - List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(CollectionUtil.newArrayList(updateReqVO.getSpuId()));
109 65 // 校验商品 sku 是否存在
110   - validateSku(updateReqVO.getSkuId(), skus);
  66 + validateSku(updateReqVO.getSkuId());
111 67  
112 68 // 更新
113 69 BargainActivityDO updateObj = BargainActivityConvert.INSTANCE.convert(updateReqVO);
114 70 bargainActivityMapper.updateById(updateObj);
  71 + }
  72 +
  73 + private void validateBargainConflict(Long spuId, Long activityId) {
  74 + // 查询所有开启的砍价活动
  75 + List<BargainActivityDO> activityList = bargainActivityMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus());
  76 + if (activityId != null) { // 更新时排除自己
  77 + activityList.removeIf(item -> ObjectUtil.equal(item.getId(), activityId));
  78 + }
  79 + // 校验商品 spu 是否参加了其它活动
  80 + if (anyMatch(activityList, activity -> ObjectUtil.equal(activity.getSpuId(), spuId))) {
  81 + throw exception(BARGAIN_ACTIVITY_SPU_CONFLICTS);
  82 + }
  83 + }
115 84  
  85 + private void validateSku(Long skuId) {
  86 + ProductSkuRespDTO sku = productSkuApi.getSku(skuId);
  87 + if (sku == null) {
  88 + throw exception(SKU_NOT_EXISTS);
  89 + }
116 90 }
117 91  
118 92 @Override
... ... @@ -139,7 +113,7 @@ public class BargainActivityServiceImpl implements BargainActivityService {
139 113  
140 114 @Override
141 115 public BargainActivityDO getBargainActivity(Long id) {
142   - return validateBargainActivityExists(id);
  116 + return bargainActivityMapper.selectById(id);
143 117 }
144 118  
145 119 @Override
... ...
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java
... ... @@ -16,6 +16,7 @@ public class TradeOrderDeliveryReqVO {
16 16 @NotNull(message = "订单编号不能为空")
17 17 private Long id;
18 18  
  19 + // TODO @puhui999:可以去掉 type;如果无需发货,则 logisticsId 传递 0;logisticsNo 传递空串
19 20 @Schema(description = "发货类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
20 21 @InEnum(DeliveryTypeEnum.class)
21 22 @NotNull(message = "发货类型不能为空")
... ... @@ -29,5 +30,4 @@ public class TradeOrderDeliveryReqVO {
29 30 @NotEmpty(message = "发货物流单号不能为空")
30 31 private String logisticsNo;
31 32  
32   -
33 33 }
... ...
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java
... ... @@ -150,7 +150,8 @@ public class AppTradeOrderController {
150 150 @Operation(summary = "确认交易订单收货")
151 151 @Parameter(name = "id", description = "交易订单编号")
152 152 public CommonResult<Boolean> takeOrder(@RequestParam("id") Long id) {
153   - return success(tradeOrderService.receiveOrder(getLoginUserId(), id));
  153 + tradeOrderService.receiveOrder(getLoginUserId(), id);
  154 + return success(true);
154 155 }
155 156  
156 157 @DeleteMapping("/cancel")
... ...
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderService.java
... ... @@ -66,9 +66,8 @@ public interface TradeOrderService {
66 66 *
67 67 * @param userId 用户编号
68 68 * @param id 订单编号
69   - * @return 成功/失败
70 69 */
71   - Boolean receiveOrder(Long userId, Long id);
  70 + void receiveOrder(Long userId, Long id);
72 71  
73 72 /**
74 73 * 获得指定编号的交易订单
... ...
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java
... ... @@ -190,7 +190,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
190 190 CollectionUtils.getSumValue(tradeOrderItemDOS, TradeOrderItemDO::getCount, Integer::sum), orderItemDO.getCount());
191 191 }
192 192  
193   - combinationRecordApi.createRecord(TradeOrderConvert.INSTANCE.convert(order, orderItemDO, createReqVO, user));
  193 + combinationRecordApi.createCombinationRecord(TradeOrderConvert.INSTANCE.convert(order, orderItemDO, createReqVO, user));
194 194 }
195 195 // TODO 秒杀扣减库存是下单就扣除还是等待订单支付成功再扣除
196 196 if (Objects.equals(TradeOrderTypeEnum.SECKILL.getType(), order.getType())) {
... ... @@ -392,10 +392,10 @@ public class TradeOrderServiceImpl implements TradeOrderService {
392 392 return new KeyValue<>(order, payOrder);
393 393 }
394 394  
395   - // TODO @芋艿:后续在 review 下发货逻辑
396 395 @Override
397 396 @Transactional(rollbackFor = Exception.class)
398 397 public void deliveryOrder(Long userId, TradeOrderDeliveryReqVO deliveryReqVO) {
  398 + // TODO @puhui999:只有选择快递的,才可以发货
399 399 // 1.1 校验并获得交易订单(可发货)
400 400 TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId());
401 401 TradeOrderDO updateOrderObj = new TradeOrderDO();
... ... @@ -412,6 +412,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
412 412 }
413 413 updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()).setDeliveryType(DeliveryTypeEnum.EXPRESS.getMode());
414 414 }
  415 + // TODO @puhui999:无需发货时,更新 logisticsId 为 0;
415 416 // 2.2 无需发货
416 417 if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.NULL.getMode())) {
417 418 updateOrderObj.setLogisticsId(null).setLogisticsNo("").setDeliveryType(DeliveryTypeEnum.NULL.getMode());
... ... @@ -458,14 +459,14 @@ public class TradeOrderServiceImpl implements TradeOrderService {
458 459 // 订单类型:拼团
459 460 if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) {
460 461 // 校验订单拼团是否成功
461   - if (combinationRecordApi.validateRecordSuccess(order.getUserId(), order.getId())) {
  462 + if (combinationRecordApi.isCombinationRecordSuccess(order.getUserId(), order.getId())) {
462 463 throw exception(ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS);
463 464 }
464 465 }
465 466 // 订单类类型:砍价
466 467 if (Objects.equals(TradeOrderTypeEnum.BARGAIN.getType(), order.getType())) {
467 468 // 校验订单砍价是否成功
468   - if (bargainRecordApi.validateRecordSuccess(order.getUserId(), order.getId())) {
  469 + if (bargainRecordApi.isBargainRecordSuccess(order.getUserId(), order.getId())) {
469 470 throw exception(ORDER_DELIVERY_FAIL_BARGAIN_RECORD_STATUS_NOT_SUCCESS);
470 471 }
471 472 }
... ... @@ -474,7 +475,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
474 475  
475 476 @Override
476 477 @Transactional(rollbackFor = Exception.class)
477   - public Boolean receiveOrder(Long userId, Long id) {
  478 + public void receiveOrder(Long userId, Long id) {
478 479 // 校验并获得交易订单(可收货)
479 480 TradeOrderDO order = validateOrderReceivable(userId, id);
480 481  
... ... @@ -489,7 +490,6 @@ public class TradeOrderServiceImpl implements TradeOrderService {
489 490 // TODO 芋艿:lili 发送订单变化的消息
490 491  
491 492 // TODO 芋艿:lili 发送商品被购买完成的数据
492   - return Boolean.TRUE;
493 493 }
494 494  
495 495 /**
... ...