Commit 60171ce7e49d4e836db1a25df6f78f7a1714df11
Committed by
Gitee
!571 完善订单发货逻辑、重构砍价活动、完善拼团记录创建逻辑
Merge pull request !571 from puhui999/feature/mall_product
Showing
37 changed files
with
383 additions
and
493 deletions
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApi.java
| @@ -14,10 +14,19 @@ import javax.validation.Valid; | @@ -14,10 +14,19 @@ import javax.validation.Valid; | ||
| 14 | public interface BargainRecordApi { | 14 | public interface BargainRecordApi { |
| 15 | 15 | ||
| 16 | /** | 16 | /** |
| 17 | - * 创建开团记录 | 17 | + * 创建砍价记录 |
| 18 | * | 18 | * |
| 19 | * @param reqDTO 请求 DTO | 19 | * @param reqDTO 请求 DTO |
| 20 | */ | 20 | */ |
| 21 | void createRecord(@Valid BargainRecordCreateReqDTO reqDTO); | 21 | void createRecord(@Valid BargainRecordCreateReqDTO reqDTO); |
| 22 | 22 | ||
| 23 | + /** | ||
| 24 | + * 查询砍价是否成功 | ||
| 25 | + * | ||
| 26 | + * @param userId 用户编号 | ||
| 27 | + * @param orderId 订单编号 | ||
| 28 | + * @return 砍价是否成功 | ||
| 29 | + */ | ||
| 30 | + boolean validateRecordSuccess(Long userId, Long orderId); | ||
| 31 | + | ||
| 23 | } | 32 | } |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java
| 1 | package cn.iocoder.yudao.module.promotion.api.combination; | 1 | package cn.iocoder.yudao.module.promotion.api.combination; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; | 3 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 4 | +import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordRespDTO; | ||
| 4 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO; | 5 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO; |
| 5 | 6 | ||
| 6 | import javax.validation.Valid; | 7 | import javax.validation.Valid; |
| 8 | +import java.util.List; | ||
| 7 | 9 | ||
| 8 | // TODO @芋艿:后面也再撸撸这几个接口 | 10 | // TODO @芋艿:后面也再撸撸这几个接口 |
| 11 | + | ||
| 9 | /** | 12 | /** |
| 10 | * 拼团记录 API 接口 | 13 | * 拼团记录 API 接口 |
| 11 | * | 14 | * |
| @@ -18,7 +21,7 @@ public interface CombinationRecordApi { | @@ -18,7 +21,7 @@ public interface CombinationRecordApi { | ||
| 18 | * | 21 | * |
| 19 | * @param reqDTO 请求 DTO | 22 | * @param reqDTO 请求 DTO |
| 20 | */ | 23 | */ |
| 21 | - void createCombinationRecord(@Valid CombinationRecordCreateReqDTO reqDTO); | 24 | + void createRecord(@Valid CombinationRecordCreateReqDTO reqDTO); |
| 22 | 25 | ||
| 23 | /** | 26 | /** |
| 24 | * 查询拼团记录是否成功 | 27 | * 查询拼团记录是否成功 |
| @@ -27,7 +30,26 @@ public interface CombinationRecordApi { | @@ -27,7 +30,26 @@ public interface CombinationRecordApi { | ||
| 27 | * @param orderId 订单编号 | 30 | * @param orderId 订单编号 |
| 28 | * @return 拼团是否成功 | 31 | * @return 拼团是否成功 |
| 29 | */ | 32 | */ |
| 30 | - boolean isCombinationRecordSuccess(Long userId, Long orderId); | 33 | + boolean validateRecordSuccess(Long userId, Long orderId); |
| 34 | + | ||
| 35 | + /** | ||
| 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); | ||
| 31 | 53 | ||
| 32 | // TODO @puhui999:是不是搞成具体的方法,拼团成功,拼团失败,这种方法; | 54 | // TODO @puhui999:是不是搞成具体的方法,拼团成功,拼团失败,这种方法; |
| 33 | 55 |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordRespDTO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.api.combination.dto; | ||
| 2 | + | ||
| 3 | +import lombok.Data; | ||
| 4 | + | ||
| 5 | +import javax.validation.constraints.NotNull; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * 拼团记录 Response DTO | ||
| 9 | + * | ||
| 10 | + * @author HUIHUI | ||
| 11 | + */ | ||
| 12 | +@Data | ||
| 13 | +public class CombinationRecordRespDTO { | ||
| 14 | + | ||
| 15 | + /** | ||
| 16 | + * 拼团活动编号 | ||
| 17 | + */ | ||
| 18 | + @NotNull(message = "拼团活动编号不能为空") | ||
| 19 | + private Long activityId; | ||
| 20 | + /** | ||
| 21 | + * spu 编号 | ||
| 22 | + */ | ||
| 23 | + @NotNull(message = "spu 编号不能为空") | ||
| 24 | + private Long spuId; | ||
| 25 | + /** | ||
| 26 | + * sku 编号 | ||
| 27 | + */ | ||
| 28 | + @NotNull(message = "sku 编号不能为空") | ||
| 29 | + private Long skuId; | ||
| 30 | + /** | ||
| 31 | + * 用户编号 | ||
| 32 | + */ | ||
| 33 | + @NotNull(message = "用户编号不能为空") | ||
| 34 | + private Long userId; | ||
| 35 | + /** | ||
| 36 | + * 订单编号 | ||
| 37 | + */ | ||
| 38 | + @NotNull(message = "订单编号不能为空") | ||
| 39 | + private Long orderId; | ||
| 40 | + /** | ||
| 41 | + * 开团状态:正在开团 拼团成功 拼团失败 | ||
| 42 | + */ | ||
| 43 | + @NotNull(message = "开团状态不能为空") | ||
| 44 | + private Integer status; | ||
| 45 | + | ||
| 46 | +} |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java
| @@ -64,17 +64,18 @@ public interface ErrorCodeConstants { | @@ -64,17 +64,18 @@ public interface ErrorCodeConstants { | ||
| 64 | ErrorCode COMBINATION_RECORD_NOT_EXISTS = new ErrorCode(1013010004, "拼团不存在"); | 64 | ErrorCode COMBINATION_RECORD_NOT_EXISTS = new ErrorCode(1013010004, "拼团不存在"); |
| 65 | ErrorCode COMBINATION_RECORD_EXISTS = new ErrorCode(1013010005, "拼团失败,已参与过该拼团"); | 65 | ErrorCode COMBINATION_RECORD_EXISTS = new ErrorCode(1013010005, "拼团失败,已参与过该拼团"); |
| 66 | ErrorCode COMBINATION_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1013010006, "拼团失败,父拼团不存在"); | 66 | ErrorCode COMBINATION_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1013010006, "拼团失败,父拼团不存在"); |
| 67 | - ErrorCode COMBINATION_RECORD_USER_FULL = 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, "拼团失败,单次限购超出"); | ||
| 68 | 72 | ||
| 69 | // ========== 砍价活动 1013011000 ========== | 73 | // ========== 砍价活动 1013011000 ========== |
| 70 | ErrorCode BARGAIN_ACTIVITY_NOT_EXISTS = new ErrorCode(1013011000, "砍价活动不存在"); | 74 | ErrorCode BARGAIN_ACTIVITY_NOT_EXISTS = new ErrorCode(1013011000, "砍价活动不存在"); |
| 71 | ErrorCode BARGAIN_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1013011001, "存在商品参加了其它砍价活动"); | 75 | ErrorCode BARGAIN_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1013011001, "存在商品参加了其它砍价活动"); |
| 72 | ErrorCode BARGAIN_ACTIVITY_STATUS_DISABLE = new ErrorCode(1013011002, "砍价活动已关闭不能修改"); | 76 | ErrorCode BARGAIN_ACTIVITY_STATUS_DISABLE = new ErrorCode(1013011002, "砍价活动已关闭不能修改"); |
| 73 | ErrorCode BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1013011003, "砍价活动未关闭或未结束,不能删除"); | 77 | ErrorCode BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1013011003, "砍价活动未关闭或未结束,不能删除"); |
| 74 | - | ||
| 75 | - // TODO @puhui999:拆分成砍价记录 | ||
| 76 | - | ||
| 77 | - ErrorCode BARGAIN_RECORD_NOT_EXISTS = new ErrorCode(1013011004, "砍价不存在"); | 78 | + ErrorCode BARGAIN_RECORD_NOT_EXISTS = new ErrorCode(1013011004, "砍价记录不存在"); |
| 78 | ErrorCode BARGAIN_RECORD_EXISTS = new ErrorCode(1013011005, "砍价失败,已参与过该砍价"); | 79 | ErrorCode BARGAIN_RECORD_EXISTS = new ErrorCode(1013011005, "砍价失败,已参与过该砍价"); |
| 79 | ErrorCode BARGAIN_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1013011006, "砍价失败,父砍价不存在"); | 80 | ErrorCode BARGAIN_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1013011006, "砍价失败,父砍价不存在"); |
| 80 | ErrorCode BARGAIN_RECORD_USER_FULL = new ErrorCode(1013011007, "砍价失败,砍价人数已满"); | 81 | ErrorCode BARGAIN_RECORD_USER_FULL = new ErrorCode(1013011007, "砍价失败,砍价人数已满"); |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApiImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.api.bargain; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainRecordCreateReqDTO; | ||
| 4 | +import org.springframework.stereotype.Service; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * 砍价活动 API 实现类 TODO @puhui999 | ||
| 8 | + * | ||
| 9 | + * @author HUIHUI | ||
| 10 | + */ | ||
| 11 | +@Service | ||
| 12 | +public class BargainRecordApiImpl implements BargainRecordApi { | ||
| 13 | + | ||
| 14 | + @Override | ||
| 15 | + public void createRecord(BargainRecordCreateReqDTO reqDTO) { | ||
| 16 | + | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + @Override | ||
| 20 | + public boolean validateRecordSuccess(Long userId, Long orderId) { | ||
| 21 | + return false; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java
| 1 | package cn.iocoder.yudao.module.promotion.api.combination; | 1 | package cn.iocoder.yudao.module.promotion.api.combination; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; | 3 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 4 | +import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordRespDTO; | ||
| 4 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO; | 5 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO; |
| 6 | +import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; | ||
| 5 | import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; | 7 | import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; |
| 6 | import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; | 8 | import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; |
| 7 | import org.springframework.stereotype.Service; | 9 | import org.springframework.stereotype.Service; |
| 8 | 10 | ||
| 9 | import javax.annotation.Resource; | 11 | import javax.annotation.Resource; |
| 12 | +import java.util.List; | ||
| 10 | 13 | ||
| 11 | /** | 14 | /** |
| 12 | * 拼团活动 API 实现类 | 15 | * 拼团活动 API 实现类 |
| @@ -20,16 +23,26 @@ public class CombinationRecordApiImpl implements CombinationRecordApi { | @@ -20,16 +23,26 @@ public class CombinationRecordApiImpl implements CombinationRecordApi { | ||
| 20 | private CombinationRecordService recordService; | 23 | private CombinationRecordService recordService; |
| 21 | 24 | ||
| 22 | @Override | 25 | @Override |
| 23 | - public void createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { | 26 | + public void createRecord(CombinationRecordCreateReqDTO reqDTO) { |
| 24 | recordService.createCombinationRecord(reqDTO); | 27 | recordService.createCombinationRecord(reqDTO); |
| 25 | } | 28 | } |
| 26 | 29 | ||
| 27 | @Override | 30 | @Override |
| 28 | - public boolean isCombinationRecordSuccess(Long userId, Long orderId) { | 31 | + public boolean validateRecordSuccess(Long userId, Long orderId) { |
| 29 | return CombinationRecordStatusEnum.isSuccess(recordService.getCombinationRecord(userId, orderId).getStatus()); | 32 | return CombinationRecordStatusEnum.isSuccess(recordService.getCombinationRecord(userId, orderId).getStatus()); |
| 30 | } | 33 | } |
| 31 | 34 | ||
| 32 | @Override | 35 | @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 | ||
| 33 | public void updateCombinationRecordStatus(CombinationRecordUpdateStatusReqDTO reqDTO) { | 46 | public void updateCombinationRecordStatus(CombinationRecordUpdateStatusReqDTO reqDTO) { |
| 34 | if (null == reqDTO.getStartTime()) { | 47 | if (null == reqDTO.getStartTime()) { |
| 35 | recordService.updateCombinationRecordStatusByUserIdAndOrderId(reqDTO); | 48 | recordService.updateCombinationRecordStatusByUserIdAndOrderId(reqDTO); |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainActivityController.java
| @@ -4,14 +4,12 @@ import cn.hutool.core.collection.CollUtil; | @@ -4,14 +4,12 @@ import cn.hutool.core.collection.CollUtil; | ||
| 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; | 6 | import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; |
| 7 | -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; | ||
| 8 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityCreateReqVO; | ||
| 9 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO; | ||
| 10 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityRespVO; | ||
| 11 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO; | 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityBaseVO; |
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO; | ||
| 9 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityRespVO; | ||
| 10 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO; | ||
| 12 | import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert; | 11 | import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert; |
| 13 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; | 12 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; |
| 14 | -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainProductDO; | ||
| 15 | import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; | 13 | import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; |
| 16 | import io.swagger.v3.oas.annotations.Operation; | 14 | import io.swagger.v3.oas.annotations.Operation; |
| 17 | import io.swagger.v3.oas.annotations.Parameter; | 15 | import io.swagger.v3.oas.annotations.Parameter; |
| @@ -22,12 +20,8 @@ import org.springframework.web.bind.annotation.*; | @@ -22,12 +20,8 @@ import org.springframework.web.bind.annotation.*; | ||
| 22 | 20 | ||
| 23 | import javax.annotation.Resource; | 21 | import javax.annotation.Resource; |
| 24 | import javax.validation.Valid; | 22 | import javax.validation.Valid; |
| 25 | -import java.util.Collections; | ||
| 26 | -import java.util.List; | ||
| 27 | 23 | ||
| 28 | -import static cn.hutool.core.collection.CollectionUtil.newArrayList; | ||
| 29 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 24 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 30 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | ||
| 31 | 25 | ||
| 32 | @Tag(name = "管理后台 - 砍价活动") | 26 | @Tag(name = "管理后台 - 砍价活动") |
| 33 | @RestController | 27 | @RestController |
| @@ -44,7 +38,7 @@ public class BargainActivityController { | @@ -44,7 +38,7 @@ public class BargainActivityController { | ||
| 44 | @PostMapping("/create") | 38 | @PostMapping("/create") |
| 45 | @Operation(summary = "创建砍价活动") | 39 | @Operation(summary = "创建砍价活动") |
| 46 | @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:create')") | 40 | @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:create')") |
| 47 | - public CommonResult<Long> createBargainActivity(@Valid @RequestBody BargainActivityCreateReqVO createReqVO) { | 41 | + public CommonResult<Long> createBargainActivity(@Valid @RequestBody BargainActivityBaseVO createReqVO) { |
| 48 | return success(activityService.createBargainActivity(createReqVO)); | 42 | return success(activityService.createBargainActivity(createReqVO)); |
| 49 | } | 43 | } |
| 50 | 44 | ||
| @@ -70,9 +64,7 @@ public class BargainActivityController { | @@ -70,9 +64,7 @@ public class BargainActivityController { | ||
| 70 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | 64 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| 71 | @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:query')") | 65 | @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:query')") |
| 72 | public CommonResult<BargainActivityRespVO> getBargainActivity(@RequestParam("id") Long id) { | 66 | public CommonResult<BargainActivityRespVO> getBargainActivity(@RequestParam("id") Long id) { |
| 73 | - BargainActivityDO activity = activityService.getBargainActivity(id); | ||
| 74 | - List<BargainProductDO> products = activityService.getBargainProductsByActivityIds(newArrayList(id)); | ||
| 75 | - return success(BargainActivityConvert.INSTANCE.convert(activity, products)); | 67 | + return success(BargainActivityConvert.INSTANCE.convert(activityService.getBargainActivity(id))); |
| 76 | } | 68 | } |
| 77 | 69 | ||
| 78 | @GetMapping("/page") | 70 | @GetMapping("/page") |
| @@ -85,14 +77,7 @@ public class BargainActivityController { | @@ -85,14 +77,7 @@ public class BargainActivityController { | ||
| 85 | if (CollUtil.isEmpty(pageResult.getList())) { | 77 | if (CollUtil.isEmpty(pageResult.getList())) { |
| 86 | return success(PageResult.empty(pageResult.getTotal())); | 78 | return success(PageResult.empty(pageResult.getTotal())); |
| 87 | } | 79 | } |
| 88 | - | ||
| 89 | - // 拼接数据 | ||
| 90 | -// List<BargainProductDO> products = activityService.getBargainProductsByActivityIds( | ||
| 91 | -// convertSet(pageResult.getList(), BargainActivityDO::getId)); | ||
| 92 | - List<BargainProductDO> products = Collections.emptyList(); | ||
| 93 | - List<ProductSpuRespDTO> spus = productSpuApi.getSpuList( | ||
| 94 | - convertSet(pageResult.getList(), BargainActivityDO::getSpuId)); | ||
| 95 | - return success(BargainActivityConvert.INSTANCE.convertPage(pageResult, products, spus)); | 80 | + return success(BargainActivityConvert.INSTANCE.convertPage(activityService.getBargainActivityPage(pageVO))); |
| 96 | } | 81 | } |
| 97 | 82 | ||
| 98 | } | 83 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityBaseVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/BargainActivityBaseVO.java
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; | 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo; |
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import lombok.Data; | 4 | import lombok.Data; |
| @@ -26,6 +26,22 @@ public class BargainActivityBaseVO { | @@ -26,6 +26,22 @@ public class BargainActivityBaseVO { | ||
| 26 | @NotNull(message = "砍价商品不能为空") | 26 | @NotNull(message = "砍价商品不能为空") |
| 27 | private Long spuId; | 27 | private Long spuId; |
| 28 | 28 | ||
| 29 | + @Schema(description = "商品 skuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") | ||
| 30 | + @NotNull(message = "商品 skuId 不能为空") | ||
| 31 | + private Long skuId; | ||
| 32 | + | ||
| 33 | + @Schema(description = "砍价起始价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") | ||
| 34 | + @NotNull(message = "砍价起始价格不能为空") | ||
| 35 | + private Integer bargainFirstPrice; | ||
| 36 | + | ||
| 37 | + @Schema(description = "砍价底价", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") | ||
| 38 | + @NotNull(message = "砍价底价不能为空") | ||
| 39 | + private Integer bargainPrice; | ||
| 40 | + | ||
| 41 | + @Schema(description = "活动库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") | ||
| 42 | + @NotNull(message = "活动库存不能为空") | ||
| 43 | + private Integer stock; | ||
| 44 | + | ||
| 29 | @Schema(description = "总限购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "16218") | 45 | @Schema(description = "总限购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "16218") |
| 30 | @NotNull(message = "总限购数量不能为空") | 46 | @NotNull(message = "总限购数量不能为空") |
| 31 | private Integer totalLimitCount; | 47 | private Integer totalLimitCount; |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageReqVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/BargainActivityPageReqVO.java
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; | 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | import io.swagger.v3.oas.annotations.media.Schema; | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | import lombok.Data; | 5 | import lombok.Data; |
| 6 | import lombok.EqualsAndHashCode; | 6 | import lombok.EqualsAndHashCode; |
| 7 | import lombok.ToString; | 7 | import lombok.ToString; |
| 8 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 9 | - | ||
| 10 | -import java.time.LocalDateTime; | ||
| 11 | - | ||
| 12 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 13 | 8 | ||
| 14 | @Schema(description = "管理后台 - 砍价活动分页 Request VO") | 9 | @Schema(description = "管理后台 - 砍价活动分页 Request VO") |
| 15 | @Data | 10 | @Data |
| @@ -20,14 +15,6 @@ public class BargainActivityPageReqVO extends PageParam { | @@ -20,14 +15,6 @@ public class BargainActivityPageReqVO extends PageParam { | ||
| 20 | @Schema(description = "砍价名称", example = "赵六") | 15 | @Schema(description = "砍价名称", example = "赵六") |
| 21 | private String name; | 16 | private String name; |
| 22 | 17 | ||
| 23 | - @Schema(description = "开始时间") | ||
| 24 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 25 | - private LocalDateTime[] startTime; | ||
| 26 | - | ||
| 27 | - @Schema(description = "结束时间") | ||
| 28 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 29 | - private LocalDateTime[] endTime; | ||
| 30 | - | ||
| 31 | @Schema(description = "活动状态:0开启 1关闭", example = "0") | 18 | @Schema(description = "活动状态:0开启 1关闭", example = "0") |
| 32 | private Integer status; | 19 | private Integer status; |
| 33 | 20 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityRespVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/BargainActivityRespVO.java
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; | 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product.BargainProductRespVO; | ||
| 4 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | import lombok.Data; | 4 | import lombok.Data; |
| 6 | import lombok.EqualsAndHashCode; | 5 | import lombok.EqualsAndHashCode; |
| @@ -8,8 +7,6 @@ import lombok.ToString; | @@ -8,8 +7,6 @@ import lombok.ToString; | ||
| 8 | 7 | ||
| 9 | import javax.validation.constraints.NotNull; | 8 | import javax.validation.constraints.NotNull; |
| 10 | import java.time.LocalDateTime; | 9 | import java.time.LocalDateTime; |
| 11 | -import java.util.List; | ||
| 12 | - | ||
| 13 | @Schema(description = "管理后台 - 砍价活动 Response VO") | 10 | @Schema(description = "管理后台 - 砍价活动 Response VO") |
| 14 | @Data | 11 | @Data |
| 15 | @EqualsAndHashCode(callSuper = true) | 12 | @EqualsAndHashCode(callSuper = true) |
| @@ -25,17 +22,14 @@ public class BargainActivityRespVO extends BargainActivityBaseVO { | @@ -25,17 +22,14 @@ public class BargainActivityRespVO extends BargainActivityBaseVO { | ||
| 25 | @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") | 22 | @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") |
| 26 | private Long id; | 23 | private Long id; |
| 27 | 24 | ||
| 28 | - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | 25 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-07-01 23:59:59") |
| 29 | private LocalDateTime createTime; | 26 | private LocalDateTime createTime; |
| 30 | 27 | ||
| 31 | - @Schema(description = "砍价成功数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") | 28 | + @Schema(description = "砍价成功数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "999") |
| 32 | private Integer successCount; | 29 | private Integer successCount; |
| 33 | 30 | ||
| 34 | @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | 31 | @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") |
| 35 | @NotNull(message = "活动状态不能为空") | 32 | @NotNull(message = "活动状态不能为空") |
| 36 | private Integer status; | 33 | private Integer status; |
| 37 | 34 | ||
| 38 | - @Schema(description = "砍价商品", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 39 | - private List<BargainProductRespVO> products; | ||
| 40 | - | ||
| 41 | } | 35 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityUpdateReqVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/BargainActivityUpdateReqVO.java
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; | 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product.BargainProductBaseVO; | ||
| 4 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | import lombok.Data; | 4 | import lombok.Data; |
| 6 | import lombok.EqualsAndHashCode; | 5 | import lombok.EqualsAndHashCode; |
| 7 | import lombok.ToString; | 6 | import lombok.ToString; |
| 8 | 7 | ||
| 9 | -import javax.validation.Valid; | ||
| 10 | import javax.validation.constraints.NotNull; | 8 | import javax.validation.constraints.NotNull; |
| 11 | -import java.util.List; | ||
| 12 | 9 | ||
| 13 | @Schema(description = "管理后台 - 砍价活动更新 Request VO") | 10 | @Schema(description = "管理后台 - 砍价活动更新 Request VO") |
| 14 | @Data | 11 | @Data |
| @@ -20,8 +17,4 @@ public class BargainActivityUpdateReqVO extends BargainActivityBaseVO { | @@ -20,8 +17,4 @@ public class BargainActivityUpdateReqVO extends BargainActivityBaseVO { | ||
| 20 | @NotNull(message = "活动编号不能为空") | 17 | @NotNull(message = "活动编号不能为空") |
| 21 | private Long id; | 18 | private Long id; |
| 22 | 19 | ||
| 23 | - @Schema(description = "砍价商品", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 24 | - @Valid | ||
| 25 | - private List<BargainProductBaseVO> products; | ||
| 26 | - | ||
| 27 | } | 20 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityCreateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product.BargainProductBaseVO; | ||
| 4 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | -import lombok.Data; | ||
| 6 | -import lombok.EqualsAndHashCode; | ||
| 7 | -import lombok.ToString; | ||
| 8 | - | ||
| 9 | -import javax.validation.Valid; | ||
| 10 | -import java.util.List; | ||
| 11 | - | ||
| 12 | -@Schema(description = "管理后台 - 砍价活动创建 Request VO") | ||
| 13 | -@Data | ||
| 14 | -@EqualsAndHashCode(callSuper = true) | ||
| 15 | -@ToString(callSuper = true) | ||
| 16 | -public class BargainActivityCreateReqVO extends BargainActivityBaseVO { | ||
| 17 | - | ||
| 18 | - @Schema(description = "砍价商品", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 19 | - @Valid | ||
| 20 | - private List<BargainProductBaseVO> products; | ||
| 21 | - | ||
| 22 | -} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/product/BargainProductBaseVO.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.Data; | ||
| 5 | - | ||
| 6 | -import javax.validation.constraints.NotNull; | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * 砍价商品 Base VO,提供给添加、修改、详细的子 VO 使用 | ||
| 10 | - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||
| 11 | - */ | ||
| 12 | -@Data | ||
| 13 | -public class BargainProductBaseVO { | ||
| 14 | - | ||
| 15 | - @Schema(description = "商品 spuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "123") | ||
| 16 | - @NotNull(message = "商品 spuId 不能为空") | ||
| 17 | - private Long spuId; | ||
| 18 | - | ||
| 19 | - @Schema(description = "商品 skuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "44") | ||
| 20 | - @NotNull(message = "商品 skuId 不能为空") | ||
| 21 | - private Long skuId; | ||
| 22 | - | ||
| 23 | - @Schema(description = "砍价起始价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "33") | ||
| 24 | - @NotNull(message = "砍价起始价格不能为空") | ||
| 25 | - private Integer bargainFirstPrice; | ||
| 26 | - | ||
| 27 | - @Schema(description = "砍价底价", requiredMode = Schema.RequiredMode.REQUIRED, example = "22") | ||
| 28 | - @NotNull(message = "砍价底价不能为空") | ||
| 29 | - private Integer bargainPrice; | ||
| 30 | - | ||
| 31 | - @Schema(description = "活动库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "11") | ||
| 32 | - @NotNull(message = "活动库存不能为空") | ||
| 33 | - private Integer stock; | ||
| 34 | - | ||
| 35 | -} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/product/BargainProductRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.Data; | ||
| 5 | -import lombok.EqualsAndHashCode; | ||
| 6 | -import lombok.ToString; | ||
| 7 | - | ||
| 8 | -import java.time.LocalDateTime; | ||
| 9 | - | ||
| 10 | -@Schema(description = "管理后台 - 砍价商品 Response VO") | ||
| 11 | -@Data | ||
| 12 | -@EqualsAndHashCode(callSuper = true) | ||
| 13 | -@ToString(callSuper = true) | ||
| 14 | -public class BargainProductRespVO extends BargainProductBaseVO { | ||
| 15 | - | ||
| 16 | - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28322") | ||
| 17 | - private Long id; | ||
| 18 | - | ||
| 19 | - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 20 | - private LocalDateTime createTime; | ||
| 21 | - | ||
| 22 | -} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageReqVO.java
| @@ -5,11 +5,6 @@ import io.swagger.v3.oas.annotations.media.Schema; | @@ -5,11 +5,6 @@ import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | import lombok.Data; | 5 | import lombok.Data; |
| 6 | import lombok.EqualsAndHashCode; | 6 | import lombok.EqualsAndHashCode; |
| 7 | import lombok.ToString; | 7 | import lombok.ToString; |
| 8 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 9 | - | ||
| 10 | -import java.time.LocalDateTime; | ||
| 11 | - | ||
| 12 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 13 | 8 | ||
| 14 | @Schema(description = "管理后台 - 拼团活动分页 Request VO") | 9 | @Schema(description = "管理后台 - 拼团活动分页 Request VO") |
| 15 | @Data | 10 | @Data |
| @@ -20,15 +15,8 @@ public class CombinationActivityPageReqVO extends PageParam { | @@ -20,15 +15,8 @@ public class CombinationActivityPageReqVO extends PageParam { | ||
| 20 | @Schema(description = "拼团名称", example = "赵六") | 15 | @Schema(description = "拼团名称", example = "赵六") |
| 21 | private String name; | 16 | private String name; |
| 22 | 17 | ||
| 23 | - @Schema(description = "开始时间") | ||
| 24 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 25 | - private LocalDateTime[] startTime; | ||
| 26 | - | ||
| 27 | - @Schema(description = "结束时间") | ||
| 28 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 29 | - private LocalDateTime[] endTime; | ||
| 30 | - | ||
| 31 | @Schema(description = "活动状态:0开启 1关闭", example = "0") | 18 | @Schema(description = "活动状态:0开启 1关闭", example = "0") |
| 32 | private Integer status; | 19 | private Integer status; |
| 33 | 20 | ||
| 21 | + | ||
| 34 | } | 22 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java
| 1 | package cn.iocoder.yudao.module.promotion.convert.bargain; | 1 | package cn.iocoder.yudao.module.promotion.convert.bargain; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 5 | -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | ||
| 6 | -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; | ||
| 7 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityCreateReqVO; | ||
| 8 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityRespVO; | ||
| 9 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO; | ||
| 10 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product.BargainProductBaseVO; | ||
| 11 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product.BargainProductRespVO; | 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityBaseVO; |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityRespVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO; | ||
| 12 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; |
| 13 | -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainProductDO; | ||
| 14 | import org.mapstruct.Mapper; | 8 | import org.mapstruct.Mapper; |
| 15 | -import org.mapstruct.Mapping; | ||
| 16 | -import org.mapstruct.Mappings; | ||
| 17 | import org.mapstruct.factory.Mappers; | 9 | import org.mapstruct.factory.Mappers; |
| 18 | 10 | ||
| 19 | import java.util.List; | 11 | import java.util.List; |
| 20 | -import java.util.Map; | ||
| 21 | - | ||
| 22 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | ||
| 23 | 12 | ||
| 24 | /** | 13 | /** |
| 25 | * 拼团活动 Convert | 14 | * 拼团活动 Convert |
| @@ -31,62 +20,14 @@ public interface BargainActivityConvert { | @@ -31,62 +20,14 @@ public interface BargainActivityConvert { | ||
| 31 | 20 | ||
| 32 | BargainActivityConvert INSTANCE = Mappers.getMapper(BargainActivityConvert.class); | 21 | BargainActivityConvert INSTANCE = Mappers.getMapper(BargainActivityConvert.class); |
| 33 | 22 | ||
| 34 | - BargainActivityDO convert(BargainActivityCreateReqVO bean); | 23 | + BargainActivityDO convert(BargainActivityBaseVO bean); |
| 35 | 24 | ||
| 36 | BargainActivityDO convert(BargainActivityUpdateReqVO bean); | 25 | BargainActivityDO convert(BargainActivityUpdateReqVO bean); |
| 37 | 26 | ||
| 38 | BargainActivityRespVO convert(BargainActivityDO bean); | 27 | BargainActivityRespVO convert(BargainActivityDO bean); |
| 39 | 28 | ||
| 40 | - BargainProductRespVO convert(BargainProductDO bean); | ||
| 41 | - | ||
| 42 | - default BargainActivityRespVO convert(BargainActivityDO activity, | ||
| 43 | - List<BargainProductDO> products) { | ||
| 44 | - return convert(activity).setProducts(convertList2(products)); | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | List<BargainActivityRespVO> convertList(List<BargainActivityDO> list); | 29 | List<BargainActivityRespVO> convertList(List<BargainActivityDO> list); |
| 48 | 30 | ||
| 49 | PageResult<BargainActivityRespVO> convertPage(PageResult<BargainActivityDO> page); | 31 | PageResult<BargainActivityRespVO> convertPage(PageResult<BargainActivityDO> page); |
| 50 | 32 | ||
| 51 | - default PageResult<BargainActivityRespVO> convertPage(PageResult<BargainActivityDO> page, | ||
| 52 | - List<BargainProductDO> productList, | ||
| 53 | - List<ProductSpuRespDTO> spuList) { | ||
| 54 | - PageResult<BargainActivityRespVO> pageResult = convertPage(page); | ||
| 55 | - // 拼接商品 | ||
| 56 | - Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId); | ||
| 57 | - pageResult.getList().forEach(item -> { | ||
| 58 | - item.setProducts(convertList2(productList)); | ||
| 59 | - MapUtils.findAndThen(spuMap, item.getSpuId(), | ||
| 60 | - spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl())); | ||
| 61 | - }); | ||
| 62 | - return pageResult; | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - List<BargainProductRespVO> convertList2(List<BargainProductDO> productDOs); | ||
| 66 | - | ||
| 67 | - @Mappings({ | ||
| 68 | - @Mapping(target = "id", ignore = true), | ||
| 69 | - @Mapping(target = "activityId", source = "activity.id"), | ||
| 70 | - @Mapping(target = "spuId", source = "activity.spuId"), | ||
| 71 | - @Mapping(target = "skuId", source = "product.skuId"), | ||
| 72 | - @Mapping(target = "bargainFirstPrice", source = "product.bargainFirstPrice"), | ||
| 73 | - @Mapping(target = "bargainPrice", source = "product.bargainPrice"), | ||
| 74 | - @Mapping(target = "stock", source = "product.stock"), | ||
| 75 | - @Mapping(target = "activityStartTime", source = "activity.startTime"), | ||
| 76 | - @Mapping(target = "activityEndTime", source = "activity.endTime") | ||
| 77 | - }) | ||
| 78 | - BargainProductDO convert(BargainActivityDO activity, BargainProductBaseVO product); | ||
| 79 | - | ||
| 80 | - default List<BargainProductDO> convertList(List<? extends BargainProductBaseVO> products, BargainActivityDO activityDO) { | ||
| 81 | - return CollectionUtils.convertList(products, item -> convert(activityDO, item).setActivityStatus(activityDO.getStatus())); | ||
| 82 | - } | ||
| 83 | - | ||
| 84 | - default List<BargainProductDO> convertList(List<BargainProductBaseVO> updateProductVOs, | ||
| 85 | - List<BargainProductDO> products, BargainActivityDO activity) { | ||
| 86 | - Map<Long, Long> productMap = convertMap(products, BargainProductDO::getSkuId, BargainProductDO::getId); | ||
| 87 | - return CollectionUtils.convertList(updateProductVOs, updateProductVO -> convert(activity, updateProductVO) | ||
| 88 | - .setId(productMap.get(updateProductVO.getSkuId())) | ||
| 89 | - .setActivityStatus(activity.getStatus())); | ||
| 90 | - } | ||
| 91 | - | ||
| 92 | } | 33 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java
| @@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | @@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 5 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | 5 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| 6 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; | 6 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; |
| 7 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; | 7 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 8 | +import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordRespDTO; | ||
| 8 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO; | 9 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO; |
| 9 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityRespVO; | 10 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityRespVO; |
| 10 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO; | 11 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO; |
| @@ -41,9 +42,8 @@ public interface CombinationActivityConvert { | @@ -41,9 +42,8 @@ public interface CombinationActivityConvert { | ||
| 41 | 42 | ||
| 42 | CombinationProductRespVO convert(CombinationProductDO bean); | 43 | CombinationProductRespVO convert(CombinationProductDO bean); |
| 43 | 44 | ||
| 44 | - default CombinationActivityRespVO convert(CombinationActivityDO activity, | ||
| 45 | - List<CombinationProductDO> products) { | ||
| 46 | - return convert(activity).setProducts(convertList2(products)); | 45 | + default CombinationActivityRespVO convert(CombinationActivityDO bean, List<CombinationProductDO> productDOs) { |
| 46 | + return convert(bean).setProducts(convertList2(productDOs)); | ||
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | List<CombinationActivityRespVO> convertList(List<CombinationActivityDO> list); | 49 | List<CombinationActivityRespVO> convertList(List<CombinationActivityDO> list); |
| @@ -53,22 +53,20 @@ public interface CombinationActivityConvert { | @@ -53,22 +53,20 @@ public interface CombinationActivityConvert { | ||
| 53 | default PageResult<CombinationActivityRespVO> convertPage(PageResult<CombinationActivityDO> page, | 53 | default PageResult<CombinationActivityRespVO> convertPage(PageResult<CombinationActivityDO> page, |
| 54 | List<CombinationProductDO> productList, | 54 | List<CombinationProductDO> productList, |
| 55 | List<ProductSpuRespDTO> spuList) { | 55 | List<ProductSpuRespDTO> spuList) { |
| 56 | - PageResult<CombinationActivityRespVO> pageResult = convertPage(page); | ||
| 57 | - // 拼接商品 | ||
| 58 | Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId); | 56 | Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId); |
| 57 | + PageResult<CombinationActivityRespVO> pageResult = convertPage(page); | ||
| 59 | pageResult.getList().forEach(item -> { | 58 | pageResult.getList().forEach(item -> { |
| 59 | + MapUtils.findAndThen(spuMap, item.getSpuId(), spu -> { | ||
| 60 | + item.setSpuName(spu.getName()); | ||
| 61 | + item.setPicUrl(spu.getPicUrl()); | ||
| 62 | + }); | ||
| 60 | item.setProducts(convertList2(productList)); | 63 | item.setProducts(convertList2(productList)); |
| 61 | - MapUtils.findAndThen(spuMap, item.getSpuId(), | ||
| 62 | - spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl())); | ||
| 63 | }); | 64 | }); |
| 64 | return pageResult; | 65 | return pageResult; |
| 65 | } | 66 | } |
| 66 | 67 | ||
| 67 | List<CombinationProductRespVO> convertList2(List<CombinationProductDO> productDOs); | 68 | List<CombinationProductRespVO> convertList2(List<CombinationProductDO> productDOs); |
| 68 | 69 | ||
| 69 | - default List<CombinationProductDO> convertList(List<? extends CombinationProductBaseVO> products, CombinationActivityDO activityDO) { | ||
| 70 | - return CollectionUtils.convertList(products, item -> convert(activityDO, item).setActivityStatus(activityDO.getStatus())); | ||
| 71 | - } | ||
| 72 | @Mappings({ | 70 | @Mappings({ |
| 73 | @Mapping(target = "id", ignore = true), | 71 | @Mapping(target = "id", ignore = true), |
| 74 | @Mapping(target = "activityId", source = "activity.id"), | 72 | @Mapping(target = "activityId", source = "activity.id"), |
| @@ -80,6 +78,10 @@ public interface CombinationActivityConvert { | @@ -80,6 +78,10 @@ public interface CombinationActivityConvert { | ||
| 80 | }) | 78 | }) |
| 81 | CombinationProductDO convert(CombinationActivityDO activity, CombinationProductBaseVO product); | 79 | CombinationProductDO convert(CombinationActivityDO activity, CombinationProductBaseVO product); |
| 82 | 80 | ||
| 81 | + default List<CombinationProductDO> convertList(List<? extends CombinationProductBaseVO> products, CombinationActivityDO activity) { | ||
| 82 | + return CollectionUtils.convertList(products, item -> convert(activity, item).setActivityStatus(activity.getStatus())); | ||
| 83 | + } | ||
| 84 | + | ||
| 83 | default List<CombinationProductDO> convertList(List<CombinationProductBaseVO> updateProductVOs, | 85 | default List<CombinationProductDO> convertList(List<CombinationProductBaseVO> updateProductVOs, |
| 84 | List<CombinationProductDO> products, CombinationActivityDO activity) { | 86 | List<CombinationProductDO> products, CombinationActivityDO activity) { |
| 85 | Map<Long, Long> productMap = convertMap(products, CombinationProductDO::getSkuId, CombinationProductDO::getId); | 87 | Map<Long, Long> productMap = convertMap(products, CombinationProductDO::getSkuId, CombinationProductDO::getId); |
| @@ -90,4 +92,6 @@ public interface CombinationActivityConvert { | @@ -90,4 +92,6 @@ public interface CombinationActivityConvert { | ||
| 90 | 92 | ||
| 91 | CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO); | 93 | CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO); |
| 92 | 94 | ||
| 95 | + List<CombinationRecordRespDTO> convert(List<CombinationRecordDO> bean); | ||
| 96 | + | ||
| 93 | } | 97 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java
| @@ -20,8 +20,6 @@ import org.mapstruct.factory.Mappers; | @@ -20,8 +20,6 @@ import org.mapstruct.factory.Mappers; | ||
| 20 | import java.util.List; | 20 | import java.util.List; |
| 21 | import java.util.Map; | 21 | import java.util.Map; |
| 22 | 22 | ||
| 23 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | ||
| 24 | - | ||
| 25 | /** | 23 | /** |
| 26 | * 秒杀活动 Convert | 24 | * 秒杀活动 Convert |
| 27 | * | 25 | * |
| @@ -40,32 +38,28 @@ public interface SeckillActivityConvert { | @@ -40,32 +38,28 @@ public interface SeckillActivityConvert { | ||
| 40 | 38 | ||
| 41 | List<SeckillActivityRespVO> convertList(List<SeckillActivityDO> list); | 39 | List<SeckillActivityRespVO> convertList(List<SeckillActivityDO> list); |
| 42 | 40 | ||
| 43 | - default PageResult<SeckillActivityRespVO> convertPage(PageResult<SeckillActivityDO> page, | ||
| 44 | - List<SeckillProductDO> seckillProducts, | ||
| 45 | - List<ProductSpuRespDTO> spuList) { | 41 | + PageResult<SeckillActivityRespVO> convertPage(PageResult<SeckillActivityDO> page); |
| 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); | ||
| 46 | PageResult<SeckillActivityRespVO> pageResult = convertPage(page); | 45 | PageResult<SeckillActivityRespVO> pageResult = convertPage(page); |
| 47 | - // 拼接商品 | ||
| 48 | - Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId); | ||
| 49 | pageResult.getList().forEach(item -> { | 46 | pageResult.getList().forEach(item -> { |
| 47 | + MapUtils.findAndThen(spuMap, item.getSpuId(), spu -> { | ||
| 48 | + item.setSpuName(spu.getName()); | ||
| 49 | + item.setPicUrl(spu.getPicUrl()); | ||
| 50 | + }); | ||
| 51 | + | ||
| 50 | item.setProducts(convertList2(seckillProducts)); | 52 | item.setProducts(convertList2(seckillProducts)); |
| 51 | - MapUtils.findAndThen(spuMap, item.getSpuId(), | ||
| 52 | - spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl())); | ||
| 53 | }); | 53 | }); |
| 54 | return pageResult; | 54 | return pageResult; |
| 55 | } | 55 | } |
| 56 | - PageResult<SeckillActivityRespVO> convertPage(PageResult<SeckillActivityDO> page); | ||
| 57 | 56 | ||
| 58 | SeckillActivityDetailRespVO convert1(SeckillActivityDO seckillActivity); | 57 | SeckillActivityDetailRespVO convert1(SeckillActivityDO seckillActivity); |
| 59 | 58 | ||
| 60 | - default SeckillActivityDetailRespVO convert(SeckillActivityDO activity, | ||
| 61 | - List<SeckillProductDO> products) { | ||
| 62 | - return convert1(activity).setProducts(convertList2(products)); | 59 | + default SeckillActivityDetailRespVO convert(SeckillActivityDO seckillActivity, List<SeckillProductDO> seckillProducts) { |
| 60 | + return convert1(seckillActivity).setProducts(convertList2(seckillProducts)); | ||
| 63 | } | 61 | } |
| 64 | - List<SeckillProductRespVO> convertList2(List<SeckillProductDO> productDOs); | ||
| 65 | 62 | ||
| 66 | - default List<SeckillProductDO> convertList(List<? extends SeckillProductBaseVO> products, SeckillActivityDO activityDO) { | ||
| 67 | - return CollectionUtils.convertList(products, item -> convert(activityDO, item).setActivityStatus(activityDO.getStatus())); | ||
| 68 | - } | ||
| 69 | @Mappings({ | 63 | @Mappings({ |
| 70 | @Mapping(target = "id", ignore = true), | 64 | @Mapping(target = "id", ignore = true), |
| 71 | @Mapping(target = "activityId", source = "activity.id"), | 65 | @Mapping(target = "activityId", source = "activity.id"), |
| @@ -79,4 +73,10 @@ public interface SeckillActivityConvert { | @@ -79,4 +73,10 @@ public interface SeckillActivityConvert { | ||
| 79 | }) | 73 | }) |
| 80 | SeckillProductDO convert(SeckillActivityDO activity, SeckillProductBaseVO product); | 74 | SeckillProductDO convert(SeckillActivityDO activity, SeckillProductBaseVO product); |
| 81 | 75 | ||
| 76 | + default List<SeckillProductDO> convertList(List<? extends SeckillProductBaseVO> products, SeckillActivityDO activity) { | ||
| 77 | + return CollectionUtils.convertList(products, item -> convert(activity, item).setActivityStatus(activity.getStatus())); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + List<SeckillProductRespVO> convertList2(List<SeckillProductDO> productDOs); | ||
| 81 | + | ||
| 82 | } | 82 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainActivityDO.java
| 1 | package cn.iocoder.yudao.module.promotion.dal.dataobject.bargain; | 1 | package cn.iocoder.yudao.module.promotion.dal.dataobject.bargain; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 5 | import com.baomidou.mybatisplus.annotation.KeySequence; | 4 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 6 | import com.baomidou.mybatisplus.annotation.TableId; | 5 | import com.baomidou.mybatisplus.annotation.TableId; |
| @@ -29,6 +28,7 @@ public class BargainActivityDO extends BaseDO { | @@ -29,6 +28,7 @@ public class BargainActivityDO extends BaseDO { | ||
| 29 | */ | 28 | */ |
| 30 | @TableId | 29 | @TableId |
| 31 | private Long id; | 30 | private Long id; |
| 31 | + | ||
| 32 | /** | 32 | /** |
| 33 | * 砍价活动名称 | 33 | * 砍价活动名称 |
| 34 | */ | 34 | */ |
| @@ -38,6 +38,7 @@ public class BargainActivityDO extends BaseDO { | @@ -38,6 +38,7 @@ public class BargainActivityDO extends BaseDO { | ||
| 38 | * 活动开始时间 | 38 | * 活动开始时间 |
| 39 | */ | 39 | */ |
| 40 | private LocalDateTime startTime; | 40 | private LocalDateTime startTime; |
| 41 | + | ||
| 41 | /** | 42 | /** |
| 42 | * 活动结束时间 | 43 | * 活动结束时间 |
| 43 | */ | 44 | */ |
| @@ -45,8 +46,6 @@ public class BargainActivityDO extends BaseDO { | @@ -45,8 +46,6 @@ public class BargainActivityDO extends BaseDO { | ||
| 45 | 46 | ||
| 46 | /** | 47 | /** |
| 47 | * 活动状态 | 48 | * 活动状态 |
| 48 | - * | ||
| 49 | - * 枚举 {@link CommonStatusEnum} | ||
| 50 | */ | 49 | */ |
| 51 | private Integer status; | 50 | private Integer status; |
| 52 | 51 | ||
| @@ -55,35 +54,50 @@ public class BargainActivityDO extends BaseDO { | @@ -55,35 +54,50 @@ public class BargainActivityDO extends BaseDO { | ||
| 55 | */ | 54 | */ |
| 56 | private Long spuId; | 55 | private Long spuId; |
| 57 | /** | 56 | /** |
| 58 | - * 砍价库存 | 57 | + * 商品 SKU 编号 |
| 59 | */ | 58 | */ |
| 60 | - private Integer stock; | ||
| 61 | - | 59 | + private Long skuId; |
| 60 | + /** | ||
| 61 | + * 砍价起始价格,单位分 | ||
| 62 | + */ | ||
| 63 | + private Integer bargainFirstPrice; | ||
| 64 | + /** | ||
| 65 | + * 砍价底价,单位:分 | ||
| 66 | + */ | ||
| 67 | + private Integer bargainPrice; | ||
| 62 | /** | 68 | /** |
| 63 | * 达到该人数,才能砍到低价 | 69 | * 达到该人数,才能砍到低价 |
| 64 | */ | 70 | */ |
| 65 | private Integer userSize; | 71 | private Integer userSize; |
| 72 | + | ||
| 66 | /** | 73 | /** |
| 67 | * 最大帮砍次数 | 74 | * 最大帮砍次数 |
| 68 | */ | 75 | */ |
| 69 | private Integer bargainCount; | 76 | private Integer bargainCount; |
| 77 | + | ||
| 70 | /** | 78 | /** |
| 71 | * 总限购数量 | 79 | * 总限购数量 |
| 72 | */ | 80 | */ |
| 73 | private Integer totalLimitCount; | 81 | private Integer totalLimitCount; |
| 82 | + | ||
| 83 | + /** | ||
| 84 | + * 砍价活动库存 | ||
| 85 | + */ | ||
| 86 | + private Integer stock; | ||
| 87 | + | ||
| 74 | /** | 88 | /** |
| 75 | * 用户每次砍价的最小金额,单位:分 | 89 | * 用户每次砍价的最小金额,单位:分 |
| 76 | */ | 90 | */ |
| 77 | private Integer randomMinPrice; | 91 | private Integer randomMinPrice; |
| 92 | + | ||
| 78 | /** | 93 | /** |
| 79 | * 用户每次砍价的最大金额,单位:分 | 94 | * 用户每次砍价的最大金额,单位:分 |
| 80 | */ | 95 | */ |
| 81 | private Integer randomMaxPrice; | 96 | private Integer randomMaxPrice; |
| 97 | + | ||
| 82 | /** | 98 | /** |
| 83 | * 砍价成功数量 | 99 | * 砍价成功数量 |
| 84 | */ | 100 | */ |
| 85 | private Integer successCount; | 101 | private Integer successCount; |
| 86 | 102 | ||
| 87 | - // TODO @puhui999:把 BargainProductDO 字段融合过来; | ||
| 88 | - | ||
| 89 | } | 103 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainProductDO.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.dal.dataobject.bargain; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 4 | -import com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 5 | -import com.baomidou.mybatisplus.annotation.TableId; | ||
| 6 | -import com.baomidou.mybatisplus.annotation.TableName; | ||
| 7 | -import lombok.*; | ||
| 8 | - | ||
| 9 | -import java.time.LocalDateTime; | ||
| 10 | - | ||
| 11 | -/** | ||
| 12 | - * 砍价商品 DO | ||
| 13 | - * | ||
| 14 | - * @author HUIHUI | ||
| 15 | - */ | ||
| 16 | -@Deprecated // 应该融合到 BargainActivityDO 表 | ||
| 17 | -@TableName("promotion_bargain_product") | ||
| 18 | -@KeySequence("promotion_bargain_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 19 | -@Data | ||
| 20 | -@EqualsAndHashCode(callSuper = true) | ||
| 21 | -@ToString(callSuper = true) | ||
| 22 | -@Builder | ||
| 23 | -@NoArgsConstructor | ||
| 24 | -@AllArgsConstructor | ||
| 25 | -public class BargainProductDO extends BaseDO { | ||
| 26 | - | ||
| 27 | - /** | ||
| 28 | - * 编号 | ||
| 29 | - */ | ||
| 30 | - @TableId | ||
| 31 | - private Long id; | ||
| 32 | - /** | ||
| 33 | - * 砍价活动编号 | ||
| 34 | - */ | ||
| 35 | - private Long activityId; | ||
| 36 | - /** | ||
| 37 | - * 商品 SPU 编号 | ||
| 38 | - */ | ||
| 39 | - private Long spuId; | ||
| 40 | - /** | ||
| 41 | - * 商品 SKU 编号 | ||
| 42 | - */ | ||
| 43 | - private Long skuId; | ||
| 44 | - /** | ||
| 45 | - * 砍价商品状态 | ||
| 46 | - * | ||
| 47 | - * 关联 {@link BargainActivityDO#getStatus()} | ||
| 48 | - */ | ||
| 49 | - private Integer activityStatus; | ||
| 50 | - /** | ||
| 51 | - * 活动开始时间点 | ||
| 52 | - */ | ||
| 53 | - private LocalDateTime activityStartTime; | ||
| 54 | - /** | ||
| 55 | - * 活动结束时间点 | ||
| 56 | - */ | ||
| 57 | - private LocalDateTime activityEndTime; | ||
| 58 | - /** | ||
| 59 | - * 砍价起始价格,单位分 | ||
| 60 | - */ | ||
| 61 | - private Integer bargainFirstPrice; | ||
| 62 | - /** | ||
| 63 | - * 砍价底价,单位:分 | ||
| 64 | - */ | ||
| 65 | - private Integer bargainPrice; | ||
| 66 | - /** | ||
| 67 | - * 活动库存 | ||
| 68 | - */ | ||
| 69 | - private Integer stock; | ||
| 70 | - | ||
| 71 | -} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java
| @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.bargain; | @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.bargain; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO; | 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO; |
| 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; |
| 8 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 9 | 9 | ||
| @@ -20,6 +20,7 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> { | @@ -20,6 +20,7 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> { | ||
| 20 | default PageResult<BargainActivityDO> selectPage(BargainActivityPageReqVO reqVO) { | 20 | default PageResult<BargainActivityDO> selectPage(BargainActivityPageReqVO reqVO) { |
| 21 | return selectPage(reqVO, new LambdaQueryWrapperX<BargainActivityDO>() | 21 | return selectPage(reqVO, new LambdaQueryWrapperX<BargainActivityDO>() |
| 22 | .likeIfPresent(BargainActivityDO::getName, reqVO.getName()) | 22 | .likeIfPresent(BargainActivityDO::getName, reqVO.getName()) |
| 23 | + .eqIfPresent(BargainActivityDO::getStatus, reqVO.getStatus()) | ||
| 23 | .orderByDesc(BargainActivityDO::getId)); | 24 | .orderByDesc(BargainActivityDO::getId)); |
| 24 | } | 25 | } |
| 25 | 26 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainProductMapper.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.dal.mysql.bargain; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 4 | -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainProductDO; | ||
| 5 | -import org.apache.ibatis.annotations.Mapper; | ||
| 6 | - | ||
| 7 | -import java.util.Collection; | ||
| 8 | -import java.util.List; | ||
| 9 | - | ||
| 10 | -/** | ||
| 11 | - * 砍价商品 Mapper | ||
| 12 | - * | ||
| 13 | - * @author HUIHUI | ||
| 14 | - */ | ||
| 15 | -@Mapper | ||
| 16 | -public interface BargainProductMapper extends BaseMapperX<BargainProductDO> { | ||
| 17 | - | ||
| 18 | - default List<BargainProductDO> selectListByActivityIds(Collection<Long> ids) { | ||
| 19 | - return selectList(BargainProductDO::getActivityId, ids); | ||
| 20 | - } | ||
| 21 | - | ||
| 22 | -} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationActivityMapper.java
| @@ -20,8 +20,6 @@ public interface CombinationActivityMapper extends BaseMapperX<CombinationActivi | @@ -20,8 +20,6 @@ public interface CombinationActivityMapper extends BaseMapperX<CombinationActivi | ||
| 20 | default PageResult<CombinationActivityDO> selectPage(CombinationActivityPageReqVO reqVO) { | 20 | default PageResult<CombinationActivityDO> selectPage(CombinationActivityPageReqVO reqVO) { |
| 21 | return selectPage(reqVO, new LambdaQueryWrapperX<CombinationActivityDO>() | 21 | return selectPage(reqVO, new LambdaQueryWrapperX<CombinationActivityDO>() |
| 22 | .likeIfPresent(CombinationActivityDO::getName, reqVO.getName()) | 22 | .likeIfPresent(CombinationActivityDO::getName, reqVO.getName()) |
| 23 | - .betweenIfPresent(CombinationActivityDO::getStartTime, reqVO.getStartTime()) | ||
| 24 | - .betweenIfPresent(CombinationActivityDO::getEndTime, reqVO.getEndTime()) | ||
| 25 | .eqIfPresent(CombinationActivityDO::getStatus, reqVO.getStatus()) | 23 | .eqIfPresent(CombinationActivityDO::getStatus, reqVO.getStatus()) |
| 26 | .orderByDesc(CombinationActivityDO::getId)); | 24 | .orderByDesc(CombinationActivityDO::getId)); |
| 27 | } | 25 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java
| @@ -20,18 +20,20 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO | @@ -20,18 +20,20 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO | ||
| 20 | CombinationRecordDO::getOrderId, orderId); | 20 | CombinationRecordDO::getOrderId, orderId); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | - // TODO @puhui999 selectByUserIdAndActivityId | 23 | + default List<CombinationRecordDO> selectListByUserIdAndStatus(Long userId, Integer status) { |
| 24 | + return selectList(new LambdaQueryWrapperX<CombinationRecordDO>() | ||
| 25 | + .eq(CombinationRecordDO::getUserId, userId) | ||
| 26 | + .eq(CombinationRecordDO::getStatus, status)); | ||
| 27 | + } | ||
| 24 | /** | 28 | /** |
| 25 | * 查询拼团记录 | 29 | * 查询拼团记录 |
| 26 | * | 30 | * |
| 27 | - * @param headId 团长编号 | ||
| 28 | - * @param activityId 活动编号 | 31 | + * @param headId 团长编号 |
| 29 | * @return 拼团记录 | 32 | * @return 拼团记录 |
| 30 | */ | 33 | */ |
| 31 | - default CombinationRecordDO selectRecordByHeadId(Long headId, Long activityId, Integer status) { | 34 | + default CombinationRecordDO selectOneByHeadId(Long headId, Integer status) { |
| 32 | return selectOne(new LambdaQueryWrapperX<CombinationRecordDO>() | 35 | return selectOne(new LambdaQueryWrapperX<CombinationRecordDO>() |
| 33 | - .eq(CombinationRecordDO::getUserId, headId) | ||
| 34 | - .eq(CombinationRecordDO::getActivityId, activityId) | 36 | + .eq(CombinationRecordDO::getId, headId) |
| 35 | .eq(CombinationRecordDO::getStatus, status)); | 37 | .eq(CombinationRecordDO::getStatus, status)); |
| 36 | } | 38 | } |
| 37 | 39 | ||
| @@ -45,4 +47,16 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO | @@ -45,4 +47,16 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO | ||
| 45 | return selectList(CombinationRecordDO::getStatus, status); | 47 | return selectList(CombinationRecordDO::getStatus, status); |
| 46 | } | 48 | } |
| 47 | 49 | ||
| 50 | + /** | ||
| 51 | + * 查询拼团记录 | ||
| 52 | + * | ||
| 53 | + * @param userId 用户 id | ||
| 54 | + * @param activityId 活动 id | ||
| 55 | + * @return 拼团记录 | ||
| 56 | + */ | ||
| 57 | + default List<CombinationRecordDO> selectListByUserIdAndActivityId(Long userId, Long activityId) { | ||
| 58 | + return selectList(new LambdaQueryWrapperX<CombinationRecordDO>() | ||
| 59 | + .eq(CombinationRecordDO::getUserId, userId) | ||
| 60 | + .eq(CombinationRecordDO::getActivityId, activityId)); | ||
| 61 | + } | ||
| 48 | } | 62 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java
| 1 | package cn.iocoder.yudao.module.promotion.service.bargain; | 1 | package cn.iocoder.yudao.module.promotion.service.bargain; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityCreateReqVO; | ||
| 5 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO; | ||
| 6 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO; | 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityBaseVO; |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO; | ||
| 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; |
| 8 | -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainProductDO; | ||
| 9 | 8 | ||
| 10 | import javax.validation.Valid; | 9 | import javax.validation.Valid; |
| 11 | -import java.util.Collection; | ||
| 12 | -import java.util.List; | ||
| 13 | 10 | ||
| 14 | /** | 11 | /** |
| 15 | * 砍价活动 Service 接口 | 12 | * 砍价活动 Service 接口 |
| @@ -24,7 +21,7 @@ public interface BargainActivityService { | @@ -24,7 +21,7 @@ public interface BargainActivityService { | ||
| 24 | * @param createReqVO 创建信息 | 21 | * @param createReqVO 创建信息 |
| 25 | * @return 编号 | 22 | * @return 编号 |
| 26 | */ | 23 | */ |
| 27 | - Long createBargainActivity(@Valid BargainActivityCreateReqVO createReqVO); | 24 | + Long createBargainActivity(@Valid BargainActivityBaseVO createReqVO); |
| 28 | 25 | ||
| 29 | /** | 26 | /** |
| 30 | * 更新砍价活动 | 27 | * 更新砍价活动 |
| @@ -56,12 +53,5 @@ public interface BargainActivityService { | @@ -56,12 +53,5 @@ public interface BargainActivityService { | ||
| 56 | */ | 53 | */ |
| 57 | PageResult<BargainActivityDO> getBargainActivityPage(BargainActivityPageReqVO pageReqVO); | 54 | PageResult<BargainActivityDO> getBargainActivityPage(BargainActivityPageReqVO pageReqVO); |
| 58 | 55 | ||
| 59 | - /** | ||
| 60 | - * 获得砍价活动商品列表 | ||
| 61 | - * | ||
| 62 | - * @param activityIds 砍价活动 ids | ||
| 63 | - * @return 砍价活动的商品列表 | ||
| 64 | - */ | ||
| 65 | - List<BargainProductDO> getBargainProductsByActivityIds(Collection<Long> activityIds); | ||
| 66 | 56 | ||
| 67 | } | 57 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java
| @@ -10,29 +10,25 @@ import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; | @@ -10,29 +10,25 @@ import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; | ||
| 10 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; | 10 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; |
| 11 | import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; | 11 | import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; |
| 12 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; | 12 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; |
| 13 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityCreateReqVO; | ||
| 14 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO; | ||
| 15 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO; | ||
| 16 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product.BargainProductBaseVO; | 13 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityBaseVO; |
| 14 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO; | ||
| 15 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO; | ||
| 17 | import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert; | 16 | import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert; |
| 18 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; | 17 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; |
| 19 | -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainProductDO; | ||
| 20 | import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainActivityMapper; | 18 | import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainActivityMapper; |
| 21 | -import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainProductMapper; | 19 | +import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainRecordMapper; |
| 22 | import org.springframework.stereotype.Service; | 20 | import org.springframework.stereotype.Service; |
| 23 | import org.springframework.transaction.annotation.Transactional; | 21 | import org.springframework.transaction.annotation.Transactional; |
| 24 | import org.springframework.validation.annotation.Validated; | 22 | import org.springframework.validation.annotation.Validated; |
| 25 | 23 | ||
| 26 | import javax.annotation.Resource; | 24 | import javax.annotation.Resource; |
| 27 | -import java.util.Collection; | ||
| 28 | import java.util.List; | 25 | import java.util.List; |
| 29 | 26 | ||
| 30 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 27 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 31 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.anyMatch; | 28 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.anyMatch; |
| 32 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue; | 29 | +import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; |
| 33 | import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; | 30 | import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; |
| 34 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; | 31 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; |
| 35 | -import static cn.iocoder.yudao.module.promotion.util.PromotionUtils.validateProductSkuAllExists; | ||
| 36 | 32 | ||
| 37 | /** | 33 | /** |
| 38 | * 砍价活动 Service 实现类 | 34 | * 砍价活动 Service 实现类 |
| @@ -43,42 +39,43 @@ import static cn.iocoder.yudao.module.promotion.util.PromotionUtils.validateProd | @@ -43,42 +39,43 @@ import static cn.iocoder.yudao.module.promotion.util.PromotionUtils.validateProd | ||
| 43 | @Validated | 39 | @Validated |
| 44 | public class BargainActivityServiceImpl implements BargainActivityService { | 40 | public class BargainActivityServiceImpl implements BargainActivityService { |
| 45 | 41 | ||
| 42 | + | ||
| 46 | @Resource | 43 | @Resource |
| 47 | private BargainActivityMapper bargainActivityMapper; | 44 | private BargainActivityMapper bargainActivityMapper; |
| 48 | @Resource | 45 | @Resource |
| 49 | - private BargainProductMapper bargainProductMapper; | ||
| 50 | - | 46 | + private BargainRecordMapper recordMapper; |
| 51 | @Resource | 47 | @Resource |
| 52 | private ProductSpuApi productSpuApi; | 48 | private ProductSpuApi productSpuApi; |
| 53 | @Resource | 49 | @Resource |
| 54 | private ProductSkuApi productSkuApi; | 50 | private ProductSkuApi productSkuApi; |
| 55 | 51 | ||
| 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 | + | ||
| 56 | @Override | 59 | @Override |
| 57 | @Transactional(rollbackFor = Exception.class) | 60 | @Transactional(rollbackFor = Exception.class) |
| 58 | - public Long createBargainActivity(BargainActivityCreateReqVO createReqVO) { | 61 | + public Long createBargainActivity(BargainActivityBaseVO createReqVO) { |
| 59 | // 校验商品 SPU 是否存在是否参加的别的活动 | 62 | // 校验商品 SPU 是否存在是否参加的别的活动 |
| 60 | - validateProductBargainConflict(createReqVO.getSpuId(), null); | 63 | + validateBargainConflict(createReqVO.getSpuId(), null); |
| 61 | // 获取所选 spu下的所有 sku | 64 | // 获取所选 spu下的所有 sku |
| 62 | List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(CollectionUtil.newArrayList(createReqVO.getSpuId())); | 65 | List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(CollectionUtil.newArrayList(createReqVO.getSpuId())); |
| 63 | - // 校验商品 sku 是否存在 | ||
| 64 | - validateProductSkuAllExists(skus, createReqVO.getProducts(), BargainProductBaseVO::getSkuId); | 66 | + validateSku(createReqVO.getSkuId(), skus); |
| 65 | 67 | ||
| 66 | // 插入砍价活动 | 68 | // 插入砍价活动 |
| 67 | - BargainActivityDO activity = BargainActivityConvert.INSTANCE.convert(createReqVO); | 69 | + BargainActivityDO activityDO = BargainActivityConvert.INSTANCE.convert(createReqVO); |
| 68 | // TODO 营销相关属性初始化 砍价成功更新相关属性 | 70 | // TODO 营销相关属性初始化 砍价成功更新相关属性 |
| 69 | - activity.setSuccessCount(0); | ||
| 70 | - // 活动总库存 | ||
| 71 | - activity.setStock(getSumValue(createReqVO.getProducts(), BargainProductBaseVO::getStock, Integer::sum)); | ||
| 72 | - activity.setStatus(CommonStatusEnum.ENABLE.getStatus()); | ||
| 73 | - bargainActivityMapper.insert(activity); | ||
| 74 | - // 插入商品 | ||
| 75 | - List<BargainProductDO> productDOs = BargainActivityConvert.INSTANCE.convertList(createReqVO.getProducts(), activity); | ||
| 76 | - bargainProductMapper.insertBatch(productDOs); | 71 | + activityDO.setSuccessCount(0); |
| 72 | + activityDO.setStatus(CommonStatusEnum.ENABLE.getStatus()); | ||
| 73 | + bargainActivityMapper.insert(activityDO); | ||
| 77 | // 返回 | 74 | // 返回 |
| 78 | - return activity.getId(); | 75 | + return activityDO.getId(); |
| 79 | } | 76 | } |
| 80 | 77 | ||
| 81 | - private void validateProductBargainConflict(Long spuId, Long activityId) { | 78 | + private void validateBargainConflict(Long spuId, Long activityId) { |
| 82 | // 校验商品 spu 是否存在 | 79 | // 校验商品 spu 是否存在 |
| 83 | List<ProductSpuRespDTO> spuList = productSpuApi.getSpuList(CollUtil.newArrayList(spuId)); | 80 | List<ProductSpuRespDTO> spuList = productSpuApi.getSpuList(CollUtil.newArrayList(spuId)); |
| 84 | if (CollUtil.isEmpty(spuList)) { | 81 | if (CollUtil.isEmpty(spuList)) { |
| @@ -106,52 +103,16 @@ public class BargainActivityServiceImpl implements BargainActivityService { | @@ -106,52 +103,16 @@ public class BargainActivityServiceImpl implements BargainActivityService { | ||
| 106 | throw exception(BARGAIN_ACTIVITY_STATUS_DISABLE); | 103 | throw exception(BARGAIN_ACTIVITY_STATUS_DISABLE); |
| 107 | } | 104 | } |
| 108 | // 校验商品冲突 | 105 | // 校验商品冲突 |
| 109 | - validateProductBargainConflict(updateReqVO.getSpuId(), updateReqVO.getId()); | 106 | + validateBargainConflict(updateReqVO.getSpuId(), updateReqVO.getId()); |
| 110 | // 获取所选 spu下的所有 sku | 107 | // 获取所选 spu下的所有 sku |
| 111 | List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(CollectionUtil.newArrayList(updateReqVO.getSpuId())); | 108 | List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(CollectionUtil.newArrayList(updateReqVO.getSpuId())); |
| 112 | // 校验商品 sku 是否存在 | 109 | // 校验商品 sku 是否存在 |
| 113 | - validateProductSkuAllExists(skus, updateReqVO.getProducts(), BargainProductBaseVO::getSkuId); | 110 | + validateSku(updateReqVO.getSkuId(), skus); |
| 114 | 111 | ||
| 115 | // 更新 | 112 | // 更新 |
| 116 | BargainActivityDO updateObj = BargainActivityConvert.INSTANCE.convert(updateReqVO); | 113 | BargainActivityDO updateObj = BargainActivityConvert.INSTANCE.convert(updateReqVO); |
| 117 | - // 更新活动库存 | ||
| 118 | - updateObj.setStock(getSumValue(updateReqVO.getProducts(), BargainProductBaseVO::getStock, Integer::sum)); | ||
| 119 | bargainActivityMapper.updateById(updateObj); | 114 | bargainActivityMapper.updateById(updateObj); |
| 120 | - // 更新商品 | ||
| 121 | - updateBargainProduct(updateObj, updateReqVO.getProducts()); | ||
| 122 | - } | ||
| 123 | 115 | ||
| 124 | - /** | ||
| 125 | - * 更新砍价商品 | ||
| 126 | - * | ||
| 127 | - * @param updateObj 更新的活动 | ||
| 128 | - * @param products 商品配置 | ||
| 129 | - */ | ||
| 130 | - private void updateBargainProduct(BargainActivityDO updateObj, List<BargainProductBaseVO> products) { | ||
| 131 | - // 默认全部新增 | ||
| 132 | - List<BargainProductDO> defaultNewList = BargainActivityConvert.INSTANCE.convertList(products, updateObj); | ||
| 133 | - // 数据库中的老数据 | ||
| 134 | - List<BargainProductDO> oldList = bargainProductMapper.selectListByActivityIds(CollUtil.newArrayList(updateObj.getId())); | ||
| 135 | - List<List<BargainProductDO>> lists = CollectionUtils.diffList(oldList, defaultNewList, (oldVal, newVal) -> { | ||
| 136 | - boolean same = ObjectUtil.equal(oldVal.getSkuId(), newVal.getSkuId()); | ||
| 137 | - if (same) { | ||
| 138 | - newVal.setId(oldVal.getId()); | ||
| 139 | - } | ||
| 140 | - return same; | ||
| 141 | - }); | ||
| 142 | - | ||
| 143 | - // create | ||
| 144 | - if (CollUtil.isNotEmpty(lists.get(0))) { | ||
| 145 | - bargainProductMapper.insertBatch(lists.get(0)); | ||
| 146 | - } | ||
| 147 | - // update | ||
| 148 | - if (CollUtil.isNotEmpty(lists.get(1))) { | ||
| 149 | - bargainProductMapper.updateBatch(lists.get(1)); | ||
| 150 | - } | ||
| 151 | - // delete | ||
| 152 | - if (CollUtil.isNotEmpty(lists.get(2))) { | ||
| 153 | - bargainProductMapper.deleteBatchIds(CollectionUtils.convertList(lists.get(2), BargainProductDO::getId)); | ||
| 154 | - } | ||
| 155 | } | 116 | } |
| 156 | 117 | ||
| 157 | @Override | 118 | @Override |
| @@ -178,7 +139,7 @@ public class BargainActivityServiceImpl implements BargainActivityService { | @@ -178,7 +139,7 @@ public class BargainActivityServiceImpl implements BargainActivityService { | ||
| 178 | 139 | ||
| 179 | @Override | 140 | @Override |
| 180 | public BargainActivityDO getBargainActivity(Long id) { | 141 | public BargainActivityDO getBargainActivity(Long id) { |
| 181 | - return bargainActivityMapper.selectById(id); | 142 | + return validateBargainActivityExists(id); |
| 182 | } | 143 | } |
| 183 | 144 | ||
| 184 | @Override | 145 | @Override |
| @@ -186,9 +147,4 @@ public class BargainActivityServiceImpl implements BargainActivityService { | @@ -186,9 +147,4 @@ public class BargainActivityServiceImpl implements BargainActivityService { | ||
| 186 | return bargainActivityMapper.selectPage(pageReqVO); | 147 | return bargainActivityMapper.selectPage(pageReqVO); |
| 187 | } | 148 | } |
| 188 | 149 | ||
| 189 | - @Override | ||
| 190 | - public List<BargainProductDO> getBargainProductsByActivityIds(Collection<Long> activityIds) { | ||
| 191 | - return bargainProductMapper.selectListByActivityIds(activityIds); | ||
| 192 | - } | ||
| 193 | - | ||
| 194 | } | 150 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordService.java
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.service.bargain; | ||
| 2 | + | ||
| 3 | +import org.springframework.stereotype.Service; | ||
| 4 | +import org.springframework.validation.annotation.Validated; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * 砍价记录 Service 实现类 | ||
| 8 | + * | ||
| 9 | + * @author HUIHUI | ||
| 10 | + */ | ||
| 11 | +@Service | ||
| 12 | +@Validated | ||
| 13 | +public class BargainRecordServiceImpl implements BargainRecordService { | ||
| 14 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java
| @@ -4,6 +4,8 @@ import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCr | @@ -4,6 +4,8 @@ import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCr | ||
| 4 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO; | 4 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO; |
| 5 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; | 5 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; |
| 6 | 6 | ||
| 7 | +import java.util.List; | ||
| 8 | + | ||
| 7 | /** | 9 | /** |
| 8 | * 拼团记录 Service 接口 | 10 | * 拼团记录 Service 接口 |
| 9 | * | 11 | * |
| @@ -41,4 +43,23 @@ public interface CombinationRecordService { | @@ -41,4 +43,23 @@ public interface CombinationRecordService { | ||
| 41 | */ | 43 | */ |
| 42 | CombinationRecordDO getCombinationRecord(Long userId, Long orderId); | 44 | CombinationRecordDO getCombinationRecord(Long userId, Long orderId); |
| 43 | 45 | ||
| 46 | + /** | ||
| 47 | + * 获取拼团记录 | ||
| 48 | + * | ||
| 49 | + * @param userId 用户 id | ||
| 50 | + * @param activityId 活动 id | ||
| 51 | + * @return 拼团记录列表 | ||
| 52 | + */ | ||
| 53 | + List<CombinationRecordDO> getRecordListByUserIdAndActivityId(Long userId, Long activityId); | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * 验证组合限制数 | ||
| 57 | + * 校验是否满足限购要求 | ||
| 58 | + * | ||
| 59 | + * @param count 本次购买数量 | ||
| 60 | + * @param sumCount 已购买数量合计 | ||
| 61 | + * @param activityId 活动编号 | ||
| 62 | + */ | ||
| 63 | + void validateCombinationLimitCount(Long activityId, Integer count, Integer sumCount); | ||
| 64 | + | ||
| 44 | } | 65 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
| @@ -14,11 +14,11 @@ import org.springframework.transaction.annotation.Transactional; | @@ -14,11 +14,11 @@ import org.springframework.transaction.annotation.Transactional; | ||
| 14 | import org.springframework.validation.annotation.Validated; | 14 | import org.springframework.validation.annotation.Validated; |
| 15 | 15 | ||
| 16 | import javax.annotation.Resource; | 16 | import javax.annotation.Resource; |
| 17 | +import java.time.LocalDateTime; | ||
| 17 | import java.util.List; | 18 | import java.util.List; |
| 18 | 19 | ||
| 19 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 20 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 20 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; | 21 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; |
| 21 | -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COMBINATION_RECORD_USER_FULL; | ||
| 22 | 22 | ||
| 23 | // TODO 芋艿:等拼团记录做完,完整 review 下 | 23 | // TODO 芋艿:等拼团记录做完,完整 review 下 |
| 24 | /** | 24 | /** |
| @@ -37,6 +37,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -37,6 +37,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 37 | private CombinationRecordMapper recordMapper; | 37 | private CombinationRecordMapper recordMapper; |
| 38 | 38 | ||
| 39 | @Override | 39 | @Override |
| 40 | + @Transactional(rollbackFor = Exception.class) | ||
| 40 | public void updateCombinationRecordStatusByUserIdAndOrderId(CombinationRecordUpdateStatusReqDTO reqDTO) { | 41 | public void updateCombinationRecordStatusByUserIdAndOrderId(CombinationRecordUpdateStatusReqDTO reqDTO) { |
| 41 | // 校验拼团是否存在 | 42 | // 校验拼团是否存在 |
| 42 | CombinationRecordDO recordDO = validateCombinationRecord(reqDTO.getUserId(), reqDTO.getOrderId()); | 43 | CombinationRecordDO recordDO = validateCombinationRecord(reqDTO.getUserId(), reqDTO.getOrderId()); |
| @@ -80,6 +81,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -80,6 +81,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 80 | } | 81 | } |
| 81 | 82 | ||
| 82 | @Override | 83 | @Override |
| 84 | + @Transactional(rollbackFor = Exception.class) | ||
| 83 | public void createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { | 85 | public void createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { |
| 84 | // 1.1 校验拼团活动 | 86 | // 1.1 校验拼团活动 |
| 85 | CombinationActivityDO activity = combinationActivityService.validateCombinationActivityExists(reqDTO.getActivityId()); | 87 | CombinationActivityDO activity = combinationActivityService.validateCombinationActivityExists(reqDTO.getActivityId()); |
| @@ -88,9 +90,19 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -88,9 +90,19 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 88 | if (recordDO != null) { | 90 | if (recordDO != null) { |
| 89 | throw exception(COMBINATION_RECORD_EXISTS); | 91 | throw exception(COMBINATION_RECORD_EXISTS); |
| 90 | } | 92 | } |
| 91 | - // 1.3 父拼团是否存在,是否已经满了 | 93 | + // 1.3 校验用户是否参加了其它拼团 |
| 94 | + List<CombinationRecordDO> recordDOList = recordMapper.selectListByUserIdAndStatus(reqDTO.getUserId(), CombinationRecordStatusEnum.IN_PROGRESS.getStatus()); | ||
| 95 | + if (CollUtil.isNotEmpty(recordDOList)) { | ||
| 96 | + throw exception(COMBINATION_RECORD_FAILED_HAVE_JOINED); | ||
| 97 | + } | ||
| 98 | + // 1.4 校验当前活动是否过期 | ||
| 99 | + if (LocalDateTime.now().isAfter(activity.getEndTime())) { | ||
| 100 | + throw exception(COMBINATION_RECORD_FAILED_TIME_END); | ||
| 101 | + } | ||
| 102 | + // 1.5 父拼团是否存在,是否已经满了 | ||
| 92 | if (reqDTO.getHeadId() != null) { | 103 | if (reqDTO.getHeadId() != null) { |
| 93 | - CombinationRecordDO recordDO1 = recordMapper.selectRecordByHeadId(reqDTO.getHeadId(), reqDTO.getActivityId(), CombinationRecordStatusEnum.IN_PROGRESS.getStatus()); | 104 | + // 查询进行中的父拼团 |
| 105 | + CombinationRecordDO recordDO1 = recordMapper.selectOneByHeadId(reqDTO.getHeadId(), CombinationRecordStatusEnum.IN_PROGRESS.getStatus()); | ||
| 94 | if (recordDO1 == null) { | 106 | if (recordDO1 == null) { |
| 95 | throw exception(COMBINATION_RECORD_HEAD_NOT_EXISTS); | 107 | throw exception(COMBINATION_RECORD_HEAD_NOT_EXISTS); |
| 96 | } | 108 | } |
| @@ -99,7 +111,6 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -99,7 +111,6 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 99 | throw exception(COMBINATION_RECORD_USER_FULL); | 111 | throw exception(COMBINATION_RECORD_USER_FULL); |
| 100 | } | 112 | } |
| 101 | } | 113 | } |
| 102 | - // TODO @puhui999:应该还有一些校验,后续补噶;例如说,一个团,自己已经参与进去了,不能再参与进去; | ||
| 103 | 114 | ||
| 104 | // 2. 创建拼团记录 | 115 | // 2. 创建拼团记录 |
| 105 | CombinationRecordDO record = CombinationActivityConvert.INSTANCE.convert(reqDTO); | 116 | CombinationRecordDO record = CombinationActivityConvert.INSTANCE.convert(reqDTO); |
| @@ -115,6 +126,25 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -115,6 +126,25 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 115 | return validateCombinationRecord(userId, orderId); | 126 | return validateCombinationRecord(userId, orderId); |
| 116 | } | 127 | } |
| 117 | 128 | ||
| 129 | + @Override | ||
| 130 | + public List<CombinationRecordDO> getRecordListByUserIdAndActivityId(Long userId, Long activityId) { | ||
| 131 | + return recordMapper.selectListByUserIdAndActivityId(userId, activityId); | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + @Override | ||
| 135 | + public void validateCombinationLimitCount(Long activityId, Integer count, Integer sumCount) { | ||
| 136 | + // 1.1 校验拼团活动 | ||
| 137 | + CombinationActivityDO activity = combinationActivityService.validateCombinationActivityExists(activityId); | ||
| 138 | + // 校验是否达到限购总限购标准 | ||
| 139 | + if ((sumCount + count) > activity.getTotalLimitCount()) { | ||
| 140 | + throw exception(COMBINATION_RECORD_FAILED_TOTAL_LIMIT_COUNT_EXCEED); | ||
| 141 | + } | ||
| 142 | + // 单次购买是否达到限购标准 | ||
| 143 | + if (count > activity.getSingleLimitCount()) { | ||
| 144 | + throw exception(COMBINATION_RECORD_FAILED_SINGLE_LIMIT_COUNT_EXCEED); | ||
| 145 | + } | ||
| 146 | + } | ||
| 147 | + | ||
| 118 | /** | 148 | /** |
| 119 | * APP 端获取开团记录 | 149 | * APP 端获取开团记录 |
| 120 | * | 150 | * |
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImplTest.java
| @@ -13,7 +13,6 @@ import org.springframework.context.annotation.Import; | @@ -13,7 +13,6 @@ import org.springframework.context.annotation.Import; | ||
| 13 | 13 | ||
| 14 | import javax.annotation.Resource; | 14 | import javax.annotation.Resource; |
| 15 | 15 | ||
| 16 | -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; | ||
| 17 | import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | 16 | import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; |
| 18 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | 17 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; |
| 19 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | 18 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; |
| @@ -152,8 +151,6 @@ public class CombinationActivityServiceImplTest extends BaseDbUnitTest { | @@ -152,8 +151,6 @@ public class CombinationActivityServiceImplTest extends BaseDbUnitTest { | ||
| 152 | // 准备参数 | 151 | // 准备参数 |
| 153 | CombinationActivityPageReqVO reqVO = new CombinationActivityPageReqVO(); | 152 | CombinationActivityPageReqVO reqVO = new CombinationActivityPageReqVO(); |
| 154 | reqVO.setName(null); | 153 | reqVO.setName(null); |
| 155 | - reqVO.setStartTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | ||
| 156 | - reqVO.setEndTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | ||
| 157 | reqVO.setStatus(null); | 154 | reqVO.setStatus(null); |
| 158 | 155 | ||
| 159 | // 调用 | 156 | // 调用 |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java
| @@ -31,10 +31,7 @@ public interface ErrorCodeConstants { | @@ -31,10 +31,7 @@ public interface ErrorCodeConstants { | ||
| 31 | ErrorCode ORDER_COMMENT_STATUS_NOT_FALSE = new ErrorCode(1011000020, "创建交易订单项的评价失败,订单已评价"); | 31 | ErrorCode ORDER_COMMENT_STATUS_NOT_FALSE = new ErrorCode(1011000020, "创建交易订单项的评价失败,订单已评价"); |
| 32 | ErrorCode ORDER_DELIVERY_FAIL_REFUND_STATUS_NOT_NONE = new ErrorCode(1011000021, "交易订单发货失败,订单已退款或部分退款"); | 32 | ErrorCode ORDER_DELIVERY_FAIL_REFUND_STATUS_NOT_NONE = new ErrorCode(1011000021, "交易订单发货失败,订单已退款或部分退款"); |
| 33 | ErrorCode ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS = new ErrorCode(1011000022, "交易订单发货失败,拼团未成功"); | 33 | ErrorCode ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS = new ErrorCode(1011000022, "交易订单发货失败,拼团未成功"); |
| 34 | - // TODO 已移除订单单独发货 | ||
| 35 | - ErrorCode ORDER_DELIVERY_FAILED_ITEMS_NOT_EMPTY = new ErrorCode(1011000023, "订单发货失败,请选择发货商品"); | ||
| 36 | - ErrorCode ORDER_DELIVERY_FAILED_ITEM_NOT_EXISTS = new ErrorCode(1011000024, "订单发货失败,所选发货商品不存在"); | ||
| 37 | - ErrorCode ORDER_DELIVERY_FAILED_ITEM_ALREADY_DELIVERY = new ErrorCode(1011000025, "订单发货失败,所选商品已发货"); | 34 | + ErrorCode ORDER_DELIVERY_FAIL_BARGAIN_RECORD_STATUS_NOT_SUCCESS = new ErrorCode(1011000023, "交易订单发货失败,砍价未成功"); |
| 38 | 35 | ||
| 39 | // ========== After Sale 模块 1011000100 ========== | 36 | // ========== After Sale 模块 1011000100 ========== |
| 40 | ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1011000100, "售后单不存在"); | 37 | ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1011000100, "售后单不存在"); |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java
| @@ -29,7 +29,5 @@ public class TradeOrderDeliveryReqVO { | @@ -29,7 +29,5 @@ public class TradeOrderDeliveryReqVO { | ||
| 29 | @NotEmpty(message = "发货物流单号不能为空") | 29 | @NotEmpty(message = "发货物流单号不能为空") |
| 30 | private String logisticsNo; | 30 | private String logisticsNo; |
| 31 | 31 | ||
| 32 | - // =============== 同城配送 ================ | ||
| 33 | - // TODO | ||
| 34 | 32 | ||
| 35 | } | 33 | } |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java
| @@ -149,9 +149,8 @@ public class AppTradeOrderController { | @@ -149,9 +149,8 @@ public class AppTradeOrderController { | ||
| 149 | @PutMapping("/receive") | 149 | @PutMapping("/receive") |
| 150 | @Operation(summary = "确认交易订单收货") | 150 | @Operation(summary = "确认交易订单收货") |
| 151 | @Parameter(name = "id", description = "交易订单编号") | 151 | @Parameter(name = "id", description = "交易订单编号") |
| 152 | - public CommonResult<Boolean> receiveOrder(@RequestParam("id") Long id) { | ||
| 153 | - tradeOrderService.receiveOrder(getLoginUserId(), id); | ||
| 154 | - return success(true); | 152 | + public CommonResult<Boolean> takeOrder(@RequestParam("id") Long id) { |
| 153 | + return success(tradeOrderService.receiveOrder(getLoginUserId(), id)); | ||
| 155 | } | 154 | } |
| 156 | 155 | ||
| 157 | @DeleteMapping("/cancel") | 156 | @DeleteMapping("/cancel") |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderItemMapper.java
| @@ -25,6 +25,12 @@ public interface TradeOrderItemMapper extends BaseMapperX<TradeOrderItemDO> { | @@ -25,6 +25,12 @@ public interface TradeOrderItemMapper extends BaseMapperX<TradeOrderItemDO> { | ||
| 25 | return selectList(TradeOrderItemDO::getOrderId, orderIds); | 25 | return selectList(TradeOrderItemDO::getOrderId, orderIds); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | + default List<TradeOrderItemDO> selectListByOrderIdAnSkuId(Collection<Long> orderIds, Collection<Long> skuIds) { | ||
| 29 | + return selectList(new LambdaQueryWrapperX<TradeOrderItemDO>() | ||
| 30 | + .in(TradeOrderItemDO::getOrderId, orderIds) | ||
| 31 | + .eq(TradeOrderItemDO::getSkuId, skuIds)); | ||
| 32 | + } | ||
| 33 | + | ||
| 28 | default TradeOrderItemDO selectOrderItemByIdAndUserId(Long orderItemId, Long loginUserId) { | 34 | default TradeOrderItemDO selectOrderItemByIdAndUserId(Long orderItemId, Long loginUserId) { |
| 29 | return selectOne(new LambdaQueryWrapperX<TradeOrderItemDO>() | 35 | return selectOne(new LambdaQueryWrapperX<TradeOrderItemDO>() |
| 30 | .eq(TradeOrderItemDO::getId, orderItemId) | 36 | .eq(TradeOrderItemDO::getId, orderItemId) |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderService.java
| @@ -65,9 +65,10 @@ public interface TradeOrderService { | @@ -65,9 +65,10 @@ public interface TradeOrderService { | ||
| 65 | * 【会员】收货交易订单 | 65 | * 【会员】收货交易订单 |
| 66 | * | 66 | * |
| 67 | * @param userId 用户编号 | 67 | * @param userId 用户编号 |
| 68 | - * @param id 订单编号 | 68 | + * @param id 订单编号 |
| 69 | + * @return 成功/失败 | ||
| 69 | */ | 70 | */ |
| 70 | - void receiveOrder(Long userId, Long id); | 71 | + Boolean receiveOrder(Long userId, Long id); |
| 71 | 72 | ||
| 72 | /** | 73 | /** |
| 73 | * 获得指定编号的交易订单 | 74 | * 获得指定编号的交易订单 |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java
| @@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.common.core.KeyValue; | @@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.common.core.KeyValue; | ||
| 9 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 9 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 10 | import cn.iocoder.yudao.framework.common.enums.TerminalEnum; | 10 | import cn.iocoder.yudao.framework.common.enums.TerminalEnum; |
| 11 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 11 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 12 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 12 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | 13 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 13 | import cn.iocoder.yudao.module.member.api.address.AddressApi; | 14 | import cn.iocoder.yudao.module.member.api.address.AddressApi; |
| 14 | import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; | 15 | import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; |
| @@ -22,7 +23,9 @@ import cn.iocoder.yudao.module.product.api.comment.ProductCommentApi; | @@ -22,7 +23,9 @@ import cn.iocoder.yudao.module.product.api.comment.ProductCommentApi; | ||
| 22 | import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; | 23 | import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; |
| 23 | import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; | 24 | import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; |
| 24 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; | 25 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; |
| 26 | +import cn.iocoder.yudao.module.promotion.api.bargain.BargainRecordApi; | ||
| 25 | import cn.iocoder.yudao.module.promotion.api.combination.CombinationRecordApi; | 27 | import cn.iocoder.yudao.module.promotion.api.combination.CombinationRecordApi; |
| 28 | +import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordRespDTO; | ||
| 26 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO; | 29 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO; |
| 27 | import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi; | 30 | import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi; |
| 28 | import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; | 31 | import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; |
| @@ -108,6 +111,9 @@ public class TradeOrderServiceImpl implements TradeOrderService { | @@ -108,6 +111,9 @@ public class TradeOrderServiceImpl implements TradeOrderService { | ||
| 108 | @Resource | 111 | @Resource |
| 109 | private CombinationRecordApi combinationRecordApi; | 112 | private CombinationRecordApi combinationRecordApi; |
| 110 | 113 | ||
| 114 | + @Resource | ||
| 115 | + private BargainRecordApi bargainRecordApi; | ||
| 116 | + | ||
| 111 | // =================== Order =================== | 117 | // =================== Order =================== |
| 112 | 118 | ||
| 113 | @Override | 119 | @Override |
| @@ -173,8 +179,18 @@ public class TradeOrderServiceImpl implements TradeOrderService { | @@ -173,8 +179,18 @@ public class TradeOrderServiceImpl implements TradeOrderService { | ||
| 173 | // 拼团 | 179 | // 拼团 |
| 174 | if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) { | 180 | if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) { |
| 175 | MemberUserRespDTO user = memberUserApi.getUser(userId); | 181 | MemberUserRespDTO user = memberUserApi.getUser(userId); |
| 182 | + List<CombinationRecordRespDTO> recordRespDTOS = combinationRecordApi.getRecordListByUserIdAndActivityId(userId, createReqVO.getCombinationActivityId()); | ||
| 176 | // TODO 拼团一次应该只能选择一种规格的商品 | 183 | // TODO 拼团一次应该只能选择一种规格的商品 |
| 177 | - combinationRecordApi.createCombinationRecord(TradeOrderConvert.INSTANCE.convert(order, orderItems.get(0), createReqVO, user)); | 184 | + TradeOrderItemDO orderItemDO = orderItems.get(0); |
| 185 | + if (CollUtil.isNotEmpty(recordRespDTOS)) { | ||
| 186 | + List<Long> skuIds = convertList(recordRespDTOS, CombinationRecordRespDTO::getSkuId, item -> ObjectUtil.equals(item.getStatus(), CombinationRecordStatusEnum.SUCCESS.getStatus())); | ||
| 187 | + List<TradeOrderItemDO> tradeOrderItemDOS = tradeOrderItemMapper.selectListByOrderIdAnSkuId(convertList(recordRespDTOS, | ||
| 188 | + CombinationRecordRespDTO::getOrderId, item -> ObjectUtil.equals(item.getStatus(), CombinationRecordStatusEnum.SUCCESS.getStatus())), skuIds); | ||
| 189 | + combinationRecordApi.validateCombinationLimitCount(createReqVO.getCombinationActivityId(), | ||
| 190 | + CollectionUtils.getSumValue(tradeOrderItemDOS, TradeOrderItemDO::getCount, Integer::sum), orderItemDO.getCount()); | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + combinationRecordApi.createRecord(TradeOrderConvert.INSTANCE.convert(order, orderItemDO, createReqVO, user)); | ||
| 178 | } | 194 | } |
| 179 | // TODO 秒杀扣减库存是下单就扣除还是等待订单支付成功再扣除 | 195 | // TODO 秒杀扣减库存是下单就扣除还是等待订单支付成功再扣除 |
| 180 | if (Objects.equals(TradeOrderTypeEnum.SECKILL.getType(), order.getType())) { | 196 | if (Objects.equals(TradeOrderTypeEnum.SECKILL.getType(), order.getType())) { |
| @@ -382,33 +398,23 @@ public class TradeOrderServiceImpl implements TradeOrderService { | @@ -382,33 +398,23 @@ public class TradeOrderServiceImpl implements TradeOrderService { | ||
| 382 | public void deliveryOrder(Long userId, TradeOrderDeliveryReqVO deliveryReqVO) { | 398 | public void deliveryOrder(Long userId, TradeOrderDeliveryReqVO deliveryReqVO) { |
| 383 | // 1.1 校验并获得交易订单(可发货) | 399 | // 1.1 校验并获得交易订单(可发货) |
| 384 | TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId()); | 400 | TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId()); |
| 385 | - | ||
| 386 | - /* TODO | ||
| 387 | - * fix: 首先需要店铺设置配送方式如: 自提 、配送、物流-配送、物流-配送-自提、商家配送 | ||
| 388 | - * 1.如果店铺有设置配送方式用户只填写收货地址的情况下店家后台自己选择配送方式 | ||
| 389 | - * 2.如果店铺只支持到店自提那么下单后默认发货不需要物流 | ||
| 390 | - * 3.如果店铺支持 物流-配送-自提 的情况下后台不需要选择配送方式按前端用户选择的配送方式发货即可 | ||
| 391 | - */ | ||
| 392 | TradeOrderDO updateOrderObj = new TradeOrderDO(); | 401 | TradeOrderDO updateOrderObj = new TradeOrderDO(); |
| 393 | // 判断发货类型 | 402 | // 判断发货类型 |
| 394 | // 2.1 快递发货 | 403 | // 2.1 快递发货 |
| 395 | if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.EXPRESS.getMode())) { | 404 | if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.EXPRESS.getMode())) { |
| 396 | // 校验快递公司 | 405 | // 校验快递公司 |
| 397 | - validateDeliveryExpress(deliveryReqVO); | ||
| 398 | - updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()); | ||
| 399 | - } | ||
| 400 | - // 2.2 用户自提 | ||
| 401 | - if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.PICK_UP.getMode())) { | ||
| 402 | - // TODO 校验自提门店是否存在 | ||
| 403 | - // 重置一下确保快递公司和快递单号为空 | ||
| 404 | - updateOrderObj.setLogisticsId(null).setLogisticsNo(""); | 406 | + DeliveryExpressDO deliveryExpress = deliveryExpressService.getDeliveryExpress(deliveryReqVO.getLogisticsId()); |
| 407 | + if (deliveryExpress == null) { | ||
| 408 | + throw exception(EXPRESS_NOT_EXISTS); | ||
| 409 | + } | ||
| 410 | + if (deliveryExpress.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { | ||
| 411 | + throw exception(EXPRESS_STATUS_NOT_ENABLE); | ||
| 412 | + } | ||
| 413 | + updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()).setDeliveryType(DeliveryTypeEnum.EXPRESS.getMode()); | ||
| 405 | } | 414 | } |
| 406 | - // 2.3 TODO 芋艿:如果无需发货,需要怎么存储?回复:需要把 deliverType 设置为 DeliveryTypeEnum.NULL | 415 | + // 2.2 无需发货 |
| 407 | if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.NULL.getMode())) { | 416 | if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.NULL.getMode())) { |
| 408 | - // TODO 情况一:正常走发货逻辑和用户自提有点像 不同点:不需要自提门店只需要用户确认收货 | ||
| 409 | - // TODO 情况二:用户下单付款后直接确认收货或等待用户确认收货 | ||
| 410 | - // 重置一下确保快递公司和快递单号为空 | ||
| 411 | - updateOrderObj.setLogisticsId(null).setLogisticsNo(""); | 417 | + updateOrderObj.setLogisticsId(null).setLogisticsNo("").setDeliveryType(DeliveryTypeEnum.NULL.getMode()); |
| 412 | } | 418 | } |
| 413 | 419 | ||
| 414 | // 更新 TradeOrderDO 状态为已发货,等待收货 | 420 | // 更新 TradeOrderDO 状态为已发货,等待收货 |
| @@ -427,16 +433,6 @@ public class TradeOrderServiceImpl implements TradeOrderService { | @@ -427,16 +433,6 @@ public class TradeOrderServiceImpl implements TradeOrderService { | ||
| 427 | // TODO 设计:lili:是不是发货后,才支持售后? | 433 | // TODO 设计:lili:是不是发货后,才支持售后? |
| 428 | } | 434 | } |
| 429 | 435 | ||
| 430 | - private void validateDeliveryExpress(TradeOrderDeliveryReqVO deliveryReqVO) { | ||
| 431 | - DeliveryExpressDO deliveryExpress = deliveryExpressService.getDeliveryExpress(deliveryReqVO.getLogisticsId()); | ||
| 432 | - if (deliveryExpress == null) { | ||
| 433 | - throw exception(EXPRESS_NOT_EXISTS); | ||
| 434 | - } | ||
| 435 | - if (deliveryExpress.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { | ||
| 436 | - throw exception(EXPRESS_STATUS_NOT_ENABLE); | ||
| 437 | - } | ||
| 438 | - } | ||
| 439 | - | ||
| 440 | /** | 436 | /** |
| 441 | * 校验交易订单满足被发货的条件 | 437 | * 校验交易订单满足被发货的条件 |
| 442 | * | 438 | * |
| @@ -462,17 +458,23 @@ public class TradeOrderServiceImpl implements TradeOrderService { | @@ -462,17 +458,23 @@ public class TradeOrderServiceImpl implements TradeOrderService { | ||
| 462 | // 订单类型:拼团 | 458 | // 订单类型:拼团 |
| 463 | if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) { | 459 | if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) { |
| 464 | // 校验订单拼团是否成功 | 460 | // 校验订单拼团是否成功 |
| 465 | - if (combinationRecordApi.isCombinationRecordSuccess(order.getUserId(), order.getId())) { | 461 | + if (combinationRecordApi.validateRecordSuccess(order.getUserId(), order.getId())) { |
| 466 | throw exception(ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS); | 462 | throw exception(ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS); |
| 467 | } | 463 | } |
| 468 | } | 464 | } |
| 469 | - // TODO puhui999: 校验订单砍价是否成功 | 465 | + // 订单类类型:砍价 |
| 466 | + if (Objects.equals(TradeOrderTypeEnum.BARGAIN.getType(), order.getType())) { | ||
| 467 | + // 校验订单砍价是否成功 | ||
| 468 | + if (bargainRecordApi.validateRecordSuccess(order.getUserId(), order.getId())) { | ||
| 469 | + throw exception(ORDER_DELIVERY_FAIL_BARGAIN_RECORD_STATUS_NOT_SUCCESS); | ||
| 470 | + } | ||
| 471 | + } | ||
| 470 | return order; | 472 | return order; |
| 471 | } | 473 | } |
| 472 | 474 | ||
| 473 | @Override | 475 | @Override |
| 474 | @Transactional(rollbackFor = Exception.class) | 476 | @Transactional(rollbackFor = Exception.class) |
| 475 | - public void receiveOrder(Long userId, Long id) { | 477 | + public Boolean receiveOrder(Long userId, Long id) { |
| 476 | // 校验并获得交易订单(可收货) | 478 | // 校验并获得交易订单(可收货) |
| 477 | TradeOrderDO order = validateOrderReceivable(userId, id); | 479 | TradeOrderDO order = validateOrderReceivable(userId, id); |
| 478 | 480 | ||
| @@ -487,6 +489,7 @@ public class TradeOrderServiceImpl implements TradeOrderService { | @@ -487,6 +489,7 @@ public class TradeOrderServiceImpl implements TradeOrderService { | ||
| 487 | // TODO 芋艿:lili 发送订单变化的消息 | 489 | // TODO 芋艿:lili 发送订单变化的消息 |
| 488 | 490 | ||
| 489 | // TODO 芋艿:lili 发送商品被购买完成的数据 | 491 | // TODO 芋艿:lili 发送商品被购买完成的数据 |
| 492 | + return Boolean.TRUE; | ||
| 490 | } | 493 | } |
| 491 | 494 | ||
| 492 | /** | 495 | /** |