Commit 651725e3e80e8fc352b8c9e51edec4c99e020adf
1 parent
be2ee905
fix: 完善订单发货逻辑、重构砍价活动、完善拼团记录创建逻辑
Showing
36 changed files
with
305 additions
and
553 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
| @@ -67,17 +67,18 @@ public interface ErrorCodeConstants { | @@ -67,17 +67,18 @@ public interface ErrorCodeConstants { | ||
| 67 | ErrorCode COMBINATION_RECORD_NOT_EXISTS = new ErrorCode(1013010004, "拼团不存在"); | 67 | ErrorCode COMBINATION_RECORD_NOT_EXISTS = new ErrorCode(1013010004, "拼团不存在"); |
| 68 | ErrorCode COMBINATION_RECORD_EXISTS = new ErrorCode(1013010005, "拼团失败,已参与过该拼团"); | 68 | ErrorCode COMBINATION_RECORD_EXISTS = new ErrorCode(1013010005, "拼团失败,已参与过该拼团"); |
| 69 | ErrorCode COMBINATION_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1013010006, "拼团失败,父拼团不存在"); | 69 | ErrorCode COMBINATION_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1013010006, "拼团失败,父拼团不存在"); |
| 70 | - ErrorCode COMBINATION_RECORD_USER_FULL = new ErrorCode(1013010006, "拼团失败,拼团人数已满"); | 70 | + ErrorCode COMBINATION_RECORD_USER_FULL = new ErrorCode(1013010007, "拼团失败,拼团人数已满"); |
| 71 | + ErrorCode COMBINATION_RECORD_FAILED_HAVE_JOINED = new ErrorCode(1013010008, "拼团失败,已参与其它拼团"); | ||
| 72 | + ErrorCode COMBINATION_RECORD_FAILED_TIME_END = new ErrorCode(1013010009, "拼团失败,活动已经结束"); | ||
| 73 | + ErrorCode COMBINATION_RECORD_FAILED_SINGLE_LIMIT_COUNT_EXCEED = new ErrorCode(1013010010, "拼团失败,单次限购超出"); | ||
| 74 | + ErrorCode COMBINATION_RECORD_FAILED_TOTAL_LIMIT_COUNT_EXCEED = new ErrorCode(1013010011, "拼团失败,单次限购超出"); | ||
| 71 | 75 | ||
| 72 | // ========== 砍价活动 1013011000 ========== | 76 | // ========== 砍价活动 1013011000 ========== |
| 73 | ErrorCode BARGAIN_ACTIVITY_NOT_EXISTS = new ErrorCode(1013011000, "砍价活动不存在"); | 77 | ErrorCode BARGAIN_ACTIVITY_NOT_EXISTS = new ErrorCode(1013011000, "砍价活动不存在"); |
| 74 | ErrorCode BARGAIN_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1013011001, "存在商品参加了其它砍价活动"); | 78 | ErrorCode BARGAIN_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1013011001, "存在商品参加了其它砍价活动"); |
| 75 | ErrorCode BARGAIN_ACTIVITY_STATUS_DISABLE = new ErrorCode(1013011002, "砍价活动已关闭不能修改"); | 79 | ErrorCode BARGAIN_ACTIVITY_STATUS_DISABLE = new ErrorCode(1013011002, "砍价活动已关闭不能修改"); |
| 76 | ErrorCode BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1013011003, "砍价活动未关闭或未结束,不能删除"); | 80 | ErrorCode BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1013011003, "砍价活动未关闭或未结束,不能删除"); |
| 77 | - | ||
| 78 | - // TODO @puhui999:拆分成砍价记录 | ||
| 79 | - | ||
| 80 | - ErrorCode BARGAIN_RECORD_NOT_EXISTS = new ErrorCode(1013011004, "砍价不存在"); | 81 | + ErrorCode BARGAIN_RECORD_NOT_EXISTS = new ErrorCode(1013011004, "砍价记录不存在"); |
| 81 | ErrorCode BARGAIN_RECORD_EXISTS = new ErrorCode(1013011005, "砍价失败,已参与过该砍价"); | 82 | ErrorCode BARGAIN_RECORD_EXISTS = new ErrorCode(1013011005, "砍价失败,已参与过该砍价"); |
| 82 | ErrorCode BARGAIN_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1013011006, "砍价失败,父砍价不存在"); | 83 | ErrorCode BARGAIN_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1013011006, "砍价失败,父砍价不存在"); |
| 83 | ErrorCode BARGAIN_RECORD_USER_FULL = new ErrorCode(1013011007, "砍价失败,砍价人数已满"); | 84 | ErrorCode BARGAIN_RECORD_USER_FULL = new ErrorCode(1013011007, "砍价失败,砍价人数已满"); |
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
| @@ -3,13 +3,11 @@ package cn.iocoder.yudao.module.promotion.controller.admin.bargain; | @@ -3,13 +3,11 @@ package cn.iocoder.yudao.module.promotion.controller.admin.bargain; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; | 5 | import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; |
| 6 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityCreateReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO; | ||
| 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; | 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO; |
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityRespVO; | ||
| 9 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO; | ||
| 10 | import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert; | 10 | import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert; |
| 11 | -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; | ||
| 12 | -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainProductDO; | ||
| 13 | import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; | 11 | import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; |
| 14 | import io.swagger.v3.oas.annotations.Operation; | 12 | import io.swagger.v3.oas.annotations.Operation; |
| 15 | import io.swagger.v3.oas.annotations.Parameter; | 13 | import io.swagger.v3.oas.annotations.Parameter; |
| @@ -20,12 +18,8 @@ import org.springframework.web.bind.annotation.*; | @@ -20,12 +18,8 @@ import org.springframework.web.bind.annotation.*; | ||
| 20 | 18 | ||
| 21 | import javax.annotation.Resource; | 19 | import javax.annotation.Resource; |
| 22 | import javax.validation.Valid; | 20 | import javax.validation.Valid; |
| 23 | -import java.util.List; | ||
| 24 | -import java.util.Set; | ||
| 25 | 21 | ||
| 26 | -import static cn.hutool.core.collection.CollectionUtil.newArrayList; | ||
| 27 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 22 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 28 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | ||
| 29 | 23 | ||
| 30 | @Tag(name = "管理后台 - 砍价活动") | 24 | @Tag(name = "管理后台 - 砍价活动") |
| 31 | @RestController | 25 | @RestController |
| @@ -68,9 +62,7 @@ public class BargainActivityController { | @@ -68,9 +62,7 @@ public class BargainActivityController { | ||
| 68 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | 62 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| 69 | @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:query')") | 63 | @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:query')") |
| 70 | public CommonResult<BargainActivityRespVO> getBargainActivity(@RequestParam("id") Long id) { | 64 | public CommonResult<BargainActivityRespVO> getBargainActivity(@RequestParam("id") Long id) { |
| 71 | - BargainActivityDO activity = activityService.getBargainActivity(id); | ||
| 72 | - List<BargainProductDO> products = activityService.getBargainProductsByActivityIds(newArrayList(id)); | ||
| 73 | - return success(BargainActivityConvert.INSTANCE.convert(activity, products)); | 65 | + return success(BargainActivityConvert.INSTANCE.convert(activityService.getBargainActivity(id))); |
| 74 | } | 66 | } |
| 75 | 67 | ||
| 76 | @GetMapping("/page") | 68 | @GetMapping("/page") |
| @@ -78,14 +70,7 @@ public class BargainActivityController { | @@ -78,14 +70,7 @@ public class BargainActivityController { | ||
| 78 | @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:query')") | 70 | @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:query')") |
| 79 | public CommonResult<PageResult<BargainActivityRespVO>> getBargainActivityPage( | 71 | public CommonResult<PageResult<BargainActivityRespVO>> getBargainActivityPage( |
| 80 | @Valid BargainActivityPageReqVO pageVO) { | 72 | @Valid BargainActivityPageReqVO pageVO) { |
| 81 | - // 查询砍价活动 | ||
| 82 | - PageResult<BargainActivityDO> pageResult = activityService.getBargainActivityPage(pageVO); | ||
| 83 | - // 拼接数据 | ||
| 84 | - Set<Long> activityIds = convertSet(pageResult.getList(), BargainActivityDO::getId); | ||
| 85 | - Set<Long> spuIds = convertSet(pageResult.getList(), BargainActivityDO::getSpuId); | ||
| 86 | - return success(BargainActivityConvert.INSTANCE.convertPage(pageResult, | ||
| 87 | - activityService.getBargainProductsByActivityIds(activityIds), | ||
| 88 | - spuApi.getSpuList(spuIds))); | 73 | + return success(BargainActivityConvert.INSTANCE.convertPage(activityService.getBargainActivityPage(pageVO))); |
| 89 | } | 74 | } |
| 90 | 75 | ||
| 91 | } | 76 | } |
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/product/BargainProductUpdateReqVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/BargainActivityCreateReqVO.java
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product; | 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; |
| 5 | import lombok.EqualsAndHashCode; | 5 | import lombok.EqualsAndHashCode; |
| 6 | import lombok.ToString; | 6 | import lombok.ToString; |
| 7 | 7 | ||
| 8 | -@Schema(description = "管理后台 - 砍价商品更新 Request VO") | 8 | +@Schema(description = "管理后台 - 砍价活动创建 Request VO") |
| 9 | @Data | 9 | @Data |
| 10 | @EqualsAndHashCode(callSuper = true) | 10 | @EqualsAndHashCode(callSuper = true) |
| 11 | @ToString(callSuper = true) | 11 | @ToString(callSuper = true) |
| 12 | -public class BargainProductUpdateReqVO extends BargainProductBaseVO { | 12 | +public class BargainActivityCreateReqVO extends BargainActivityBaseVO { |
| 13 | 13 | ||
| 14 | } | 14 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/product/BargainProductCreateReqVO.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.product; | 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import lombok.Data; | 5 | import lombok.Data; |
| 5 | import lombok.EqualsAndHashCode; | 6 | import lombok.EqualsAndHashCode; |
| 6 | import lombok.ToString; | 7 | import lombok.ToString; |
| 7 | 8 | ||
| 8 | -// TODO @puhui999:是不是应该把 BargainProductCreateReqVO 和 BargainProductUpdateReqVO 合并在一起哈。就是一个 SaveReqVO | ||
| 9 | -@Schema(description = "管理后台 - 砍价商品创建 Request VO") | 9 | +@Schema(description = "管理后台 - 砍价活动分页 Request VO") |
| 10 | @Data | 10 | @Data |
| 11 | @EqualsAndHashCode(callSuper = true) | 11 | @EqualsAndHashCode(callSuper = true) |
| 12 | @ToString(callSuper = true) | 12 | @ToString(callSuper = true) |
| 13 | -public class BargainProductCreateReqVO extends BargainProductBaseVO { | 13 | +public class BargainActivityPageReqVO extends PageParam { |
| 14 | + | ||
| 15 | + @Schema(description = "砍价名称", example = "赵六") | ||
| 16 | + private String name; | ||
| 17 | + | ||
| 18 | + @Schema(description = "活动状态:0开启 1关闭", example = "0") | ||
| 19 | + private Integer status; | ||
| 14 | 20 | ||
| 15 | } | 21 | } |
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; |
| 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.time.LocalDateTime; | 9 | import java.time.LocalDateTime; |
| 12 | -import java.util.List; | ||
| 13 | - | ||
| 14 | @Schema(description = "管理后台 - 砍价活动 Response VO") | 10 | @Schema(description = "管理后台 - 砍价活动 Response VO") |
| 15 | @Data | 11 | @Data |
| 16 | @EqualsAndHashCode(callSuper = true) | 12 | @EqualsAndHashCode(callSuper = true) |
| 17 | @ToString(callSuper = true) | 13 | @ToString(callSuper = true) |
| 18 | public class BargainActivityRespVO extends BargainActivityBaseVO { | 14 | public class BargainActivityRespVO extends BargainActivityBaseVO { |
| 19 | 15 | ||
| 20 | - // TODO @puhui999:example 补全 | ||
| 21 | - | ||
| 22 | @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618大促") | 16 | @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618大促") |
| 23 | private String spuName; | 17 | private String spuName; |
| 24 | 18 | ||
| @@ -28,18 +22,14 @@ public class BargainActivityRespVO extends BargainActivityBaseVO { | @@ -28,18 +22,14 @@ public class BargainActivityRespVO extends BargainActivityBaseVO { | ||
| 28 | @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") | 22 | @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") |
| 29 | private Long id; | 23 | private Long id; |
| 30 | 24 | ||
| 31 | - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | 25 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-07-01 23:59:59") |
| 32 | private LocalDateTime createTime; | 26 | private LocalDateTime createTime; |
| 33 | 27 | ||
| 34 | - @Schema(description = "砍价成功数量", requiredMode = Schema.RequiredMode.REQUIRED) | 28 | + @Schema(description = "砍价成功数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "999") |
| 35 | private Integer successCount; | 29 | private Integer successCount; |
| 36 | 30 | ||
| 37 | @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | 31 | @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") |
| 38 | @NotNull(message = "活动状态不能为空") | 32 | @NotNull(message = "活动状态不能为空") |
| 39 | private Integer status; | 33 | private Integer status; |
| 40 | 34 | ||
| 41 | - @Schema(description = "砍价商品", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 42 | - @Valid | ||
| 43 | - private List<BargainProductRespVO> products; | ||
| 44 | - | ||
| 45 | } | 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.BargainProductUpdateReqVO; | ||
| 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<BargainProductUpdateReqVO> 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.BargainProductCreateReqVO; | ||
| 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<BargainProductCreateReqVO> products; | ||
| 21 | - | ||
| 22 | -} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | -import lombok.Data; | ||
| 6 | -import lombok.EqualsAndHashCode; | ||
| 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 | - | ||
| 14 | -@Schema(description = "管理后台 - 砍价活动分页 Request VO") | ||
| 15 | -@Data | ||
| 16 | -@EqualsAndHashCode(callSuper = true) | ||
| 17 | -@ToString(callSuper = true) | ||
| 18 | -public class BargainActivityPageReqVO extends PageParam { | ||
| 19 | - | ||
| 20 | - @Schema(description = "砍价名称", example = "赵六") | ||
| 21 | - private String name; | ||
| 22 | - | ||
| 23 | - @Schema(description = "商品 SPU 编号关联 ProductSpuDO 的 id", example = "14016") | ||
| 24 | - private Long spuId; | ||
| 25 | - | ||
| 26 | - @Schema(description = "总限购数量", example = "16218") | ||
| 27 | - private Integer totalLimitCount; | ||
| 28 | - | ||
| 29 | - @Schema(description = "单次限购数量", example = "28265") | ||
| 30 | - private Integer singleLimitCount; | ||
| 31 | - | ||
| 32 | - @Schema(description = "开始时间") | ||
| 33 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 34 | - private LocalDateTime[] startTime; | ||
| 35 | - | ||
| 36 | - @Schema(description = "结束时间") | ||
| 37 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 38 | - private LocalDateTime[] endTime; | ||
| 39 | - | ||
| 40 | - @Schema(description = "开团人数") | ||
| 41 | - private Integer userSize; | ||
| 42 | - | ||
| 43 | - @Schema(description = "开团组数") | ||
| 44 | - private Integer totalNum; | ||
| 45 | - | ||
| 46 | - @Schema(description = "成团组数") | ||
| 47 | - private Integer successNum; | ||
| 48 | - | ||
| 49 | - @Schema(description = "参与人数", example = "25222") | ||
| 50 | - private Integer orderUserCount; | ||
| 51 | - | ||
| 52 | - @Schema(description = "虚拟成团") | ||
| 53 | - private Integer virtualGroup; | ||
| 54 | - | ||
| 55 | - @Schema(description = "活动状态:0开启 1关闭", example = "0") | ||
| 56 | - private Integer status; | ||
| 57 | - | ||
| 58 | - @Schema(description = "限制时长(小时)") | ||
| 59 | - private Integer limitDuration; | ||
| 60 | - | ||
| 61 | - @Schema(description = "创建时间") | ||
| 62 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 63 | - private LocalDateTime[] createTime; | ||
| 64 | - | ||
| 65 | -} |
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 = "23") | ||
| 20 | - @NotNull(message = "商品 skuId 不能为空") | ||
| 21 | - private Long skuId; | ||
| 22 | - | ||
| 23 | - @Schema(description = "砍价起始价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") | ||
| 24 | - @NotNull(message = "砍价起始价格不能为空") | ||
| 25 | - private Integer bargainFirstPrice; | ||
| 26 | - | ||
| 27 | - @Schema(description = "砍价底价", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") | ||
| 28 | - @NotNull(message = "砍价底价不能为空") | ||
| 29 | - private Integer bargainPrice; | ||
| 30 | - | ||
| 31 | - @Schema(description = "活动库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") | ||
| 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,46 +15,8 @@ public class CombinationActivityPageReqVO extends PageParam { | @@ -20,46 +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 = "商品 SPU 编号关联 ProductSpuDO 的 id", example = "14016") | ||
| 24 | - private Long spuId; | ||
| 25 | - | ||
| 26 | - @Schema(description = "总限购数量", example = "16218") | ||
| 27 | - private Integer totalLimitCount; | ||
| 28 | - | ||
| 29 | - @Schema(description = "单次限购数量", example = "28265") | ||
| 30 | - private Integer singleLimitCount; | ||
| 31 | - | ||
| 32 | - @Schema(description = "开始时间") | ||
| 33 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 34 | - private LocalDateTime[] startTime; | ||
| 35 | - | ||
| 36 | - @Schema(description = "结束时间") | ||
| 37 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 38 | - private LocalDateTime[] endTime; | ||
| 39 | - | ||
| 40 | - @Schema(description = "开团人数") | ||
| 41 | - private Integer userSize; | ||
| 42 | - | ||
| 43 | - @Schema(description = "开团组数") | ||
| 44 | - private Integer totalNum; | ||
| 45 | - | ||
| 46 | - @Schema(description = "成团组数") | ||
| 47 | - private Integer successNum; | ||
| 48 | - | ||
| 49 | - @Schema(description = "参与人数", example = "25222") | ||
| 50 | - private Integer orderUserCount; | ||
| 51 | - | ||
| 52 | - @Schema(description = "虚拟成团") | ||
| 53 | - private Integer virtualGroup; | ||
| 54 | - | ||
| 55 | @Schema(description = "活动状态:0开启 1关闭", example = "0") | 18 | @Schema(description = "活动状态:0开启 1关闭", example = "0") |
| 56 | private Integer status; | 19 | private Integer status; |
| 57 | 20 | ||
| 58 | - @Schema(description = "限制时长(小时)") | ||
| 59 | - private Integer limitDuration; | ||
| 60 | - | ||
| 61 | - @Schema(description = "创建时间") | ||
| 62 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 63 | - private LocalDateTime[] createTime; | ||
| 64 | 21 | ||
| 65 | } | 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; | ||
| 12 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product.BargainProductUpdateReqVO; | 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO; |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityRespVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO; | ||
| 13 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; |
| 14 | -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainProductDO; | ||
| 15 | import org.mapstruct.Mapper; | 8 | import org.mapstruct.Mapper; |
| 16 | -import org.mapstruct.Mapping; | ||
| 17 | -import org.mapstruct.Mappings; | ||
| 18 | import org.mapstruct.factory.Mappers; | 9 | import org.mapstruct.factory.Mappers; |
| 19 | 10 | ||
| 20 | import java.util.List; | 11 | import java.util.List; |
| 21 | -import java.util.Map; | ||
| 22 | - | ||
| 23 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | ||
| 24 | 12 | ||
| 25 | /** | 13 | /** |
| 26 | * 拼团活动 Convert | 14 | * 拼团活动 Convert |
| @@ -38,57 +26,8 @@ public interface BargainActivityConvert { | @@ -38,57 +26,8 @@ public interface BargainActivityConvert { | ||
| 38 | 26 | ||
| 39 | BargainActivityRespVO convert(BargainActivityDO bean); | 27 | BargainActivityRespVO convert(BargainActivityDO bean); |
| 40 | 28 | ||
| 41 | - BargainProductRespVO convert(BargainProductDO bean); | ||
| 42 | - | ||
| 43 | - default BargainActivityRespVO convert(BargainActivityDO bean, List<BargainProductDO> productDOs) { | ||
| 44 | - return convert(bean).setProducts(convertList2(productDOs)); | ||
| 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 | - Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId); | ||
| 55 | - PageResult<BargainActivityRespVO> pageResult = convertPage(page); | ||
| 56 | - pageResult.getList().forEach(item -> { | ||
| 57 | - MapUtils.findAndThen(spuMap, item.getSpuId(), spu -> { | ||
| 58 | - item.setSpuName(spu.getName()); | ||
| 59 | - item.setPicUrl(spu.getPicUrl()); | ||
| 60 | - }); | ||
| 61 | - item.setProducts(convertList2(productList)); | ||
| 62 | - }); | ||
| 63 | - return pageResult; | ||
| 64 | - } | ||
| 65 | - | ||
| 66 | - List<BargainProductRespVO> convertList2(List<BargainProductDO> productDOs); | ||
| 67 | - | ||
| 68 | - // TODO @puhui999:参数改成 activity、product 会不会干净一点哈 | ||
| 69 | - @Mappings({ | ||
| 70 | - @Mapping(target = "id", ignore = true), | ||
| 71 | - @Mapping(target = "activityId", source = "activityDO.id"), | ||
| 72 | - @Mapping(target = "spuId", source = "activityDO.spuId"), | ||
| 73 | - @Mapping(target = "skuId", source = "vo.skuId"), | ||
| 74 | - @Mapping(target = "bargainFirstPrice", source = "vo.bargainFirstPrice"), | ||
| 75 | - @Mapping(target = "bargainPrice", source = "vo.bargainPrice"), | ||
| 76 | - @Mapping(target = "stock", source = "vo.stock"), | ||
| 77 | - @Mapping(target = "activityStartTime", source = "activityDO.startTime"), | ||
| 78 | - @Mapping(target = "activityEndTime", source = "activityDO.endTime") | ||
| 79 | - }) | ||
| 80 | - BargainProductDO convert(BargainActivityDO activityDO, BargainProductBaseVO vo); | ||
| 81 | - | ||
| 82 | - default List<BargainProductDO> convertList(List<? extends BargainProductBaseVO> products, BargainActivityDO activityDO) { | ||
| 83 | - return CollectionUtils.convertList(products, item -> convert(activityDO, item).setActivityStatus(activityDO.getStatus())); | ||
| 84 | - } | ||
| 85 | - | ||
| 86 | - default List<BargainProductDO> convertList(List<BargainProductUpdateReqVO> updateProductVOs, | ||
| 87 | - List<BargainProductDO> products, BargainActivityDO activity) { | ||
| 88 | - Map<Long, Long> productMap = convertMap(products, BargainProductDO::getSkuId, BargainProductDO::getId); | ||
| 89 | - return CollectionUtils.convertList(updateProductVOs, updateProductVO -> convert(activity, updateProductVO) | ||
| 90 | - .setId(productMap.get(updateProductVO.getSkuId())) | ||
| 91 | - .setActivityStatus(activity.getStatus())); | ||
| 92 | - } | ||
| 93 | - | ||
| 94 | } | 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; |
| @@ -93,4 +94,6 @@ public interface CombinationActivityConvert { | @@ -93,4 +94,6 @@ public interface CombinationActivityConvert { | ||
| 93 | 94 | ||
| 94 | CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO); | 95 | CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO); |
| 95 | 96 | ||
| 97 | + List<CombinationRecordRespDTO> convert(List<CombinationRecordDO> bean); | ||
| 98 | + | ||
| 96 | } | 99 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainActivityDO.java
| @@ -53,7 +53,18 @@ public class BargainActivityDO extends BaseDO { | @@ -53,7 +53,18 @@ public class BargainActivityDO extends BaseDO { | ||
| 53 | * 商品 SPU 编号 | 53 | * 商品 SPU 编号 |
| 54 | */ | 54 | */ |
| 55 | private Long spuId; | 55 | private Long spuId; |
| 56 | - | 56 | + /** |
| 57 | + * 商品 SKU 编号 | ||
| 58 | + */ | ||
| 59 | + private Long skuId; | ||
| 60 | + /** | ||
| 61 | + * 砍价起始价格,单位分 | ||
| 62 | + */ | ||
| 63 | + private Integer bargainFirstPrice; | ||
| 64 | + /** | ||
| 65 | + * 砍价底价,单位:分 | ||
| 66 | + */ | ||
| 67 | + private Integer bargainPrice; | ||
| 57 | /** | 68 | /** |
| 58 | * 达到该人数,才能砍到低价 | 69 | * 达到该人数,才能砍到低价 |
| 59 | */ | 70 | */ |
| @@ -70,7 +81,7 @@ public class BargainActivityDO extends BaseDO { | @@ -70,7 +81,7 @@ public class BargainActivityDO extends BaseDO { | ||
| 70 | private Integer totalLimitCount; | 81 | private Integer totalLimitCount; |
| 71 | 82 | ||
| 72 | /** | 83 | /** |
| 73 | - * 砍价库存 | 84 | + * 砍价活动库存 |
| 74 | */ | 85 | */ |
| 75 | private Integer stock; | 86 | private Integer stock; |
| 76 | 87 |
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 | -@TableName("promotion_bargain_product") | ||
| 17 | -@KeySequence("promotion_bargain_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 18 | -@Data | ||
| 19 | -@EqualsAndHashCode(callSuper = true) | ||
| 20 | -@ToString(callSuper = true) | ||
| 21 | -@Builder | ||
| 22 | -@NoArgsConstructor | ||
| 23 | -@AllArgsConstructor | ||
| 24 | -public class BargainProductDO extends BaseDO { | ||
| 25 | - | ||
| 26 | - /** | ||
| 27 | - * 编号 | ||
| 28 | - */ | ||
| 29 | - @TableId | ||
| 30 | - private Long id; | ||
| 31 | - /** | ||
| 32 | - * 砍价活动编号 | ||
| 33 | - */ | ||
| 34 | - private Long activityId; | ||
| 35 | - /** | ||
| 36 | - * 商品 SPU 编号 | ||
| 37 | - */ | ||
| 38 | - private Long spuId; | ||
| 39 | - /** | ||
| 40 | - * 商品 SKU 编号 | ||
| 41 | - */ | ||
| 42 | - private Long skuId; | ||
| 43 | - /** | ||
| 44 | - * 砍价商品状态 | ||
| 45 | - * | ||
| 46 | - * 关联 {@link BargainActivityDO#getStatus()} | ||
| 47 | - */ | ||
| 48 | - private Integer activityStatus; | ||
| 49 | - /** | ||
| 50 | - * 活动开始时间点 | ||
| 51 | - */ | ||
| 52 | - private LocalDateTime activityStartTime; | ||
| 53 | - /** | ||
| 54 | - * 活动结束时间点 | ||
| 55 | - */ | ||
| 56 | - private LocalDateTime activityEndTime; | ||
| 57 | - /** | ||
| 58 | - * 砍价起始价格,单位分 | ||
| 59 | - */ | ||
| 60 | - private Integer bargainFirstPrice; | ||
| 61 | - /** | ||
| 62 | - * 砍价底价,单位:分 | ||
| 63 | - */ | ||
| 64 | - private Integer bargainPrice; | ||
| 65 | - /** | ||
| 66 | - * 活动库存 | ||
| 67 | - */ | ||
| 68 | - private Integer stock; | ||
| 69 | - | ||
| 70 | -} |
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,6 +20,7 @@ public interface CombinationActivityMapper extends BaseMapperX<CombinationActivi | @@ -20,6 +20,7 @@ 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 | + .eqIfPresent(CombinationActivityDO::getStatus, reqVO.getStatus()) | ||
| 23 | .orderByDesc(CombinationActivityDO::getId)); | 24 | .orderByDesc(CombinationActivityDO::getId)); |
| 24 | } | 25 | } |
| 25 | 26 |
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.BargainActivityCreateReqVO; |
| 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 接口 |
| @@ -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 ids 砍价活动 ids | ||
| 63 | - * @return 砍价活动的商品列表 | ||
| 64 | - */ | ||
| 65 | - List<BargainProductDO> getBargainProductsByActivityIds(Collection<Long> ids); | ||
| 66 | 56 | ||
| 67 | } | 57 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainServiceImpl.java
| @@ -10,31 +10,25 @@ import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; | @@ -10,31 +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.BargainProductCreateReqVO; | ||
| 17 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product.BargainProductUpdateReqVO; | 13 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO; |
| 14 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO; | ||
| 15 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO; | ||
| 18 | import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert; | 16 | import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert; |
| 19 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; | 17 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; |
| 20 | -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainProductDO; | ||
| 21 | import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainActivityMapper; | 18 | import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainActivityMapper; |
| 22 | -import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainProductMapper; | ||
| 23 | import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainRecordMapper; | 19 | import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainRecordMapper; |
| 24 | import org.springframework.stereotype.Service; | 20 | import org.springframework.stereotype.Service; |
| 25 | import org.springframework.transaction.annotation.Transactional; | 21 | import org.springframework.transaction.annotation.Transactional; |
| 26 | import org.springframework.validation.annotation.Validated; | 22 | import org.springframework.validation.annotation.Validated; |
| 27 | 23 | ||
| 28 | import javax.annotation.Resource; | 24 | import javax.annotation.Resource; |
| 29 | -import java.util.Collection; | ||
| 30 | import java.util.List; | 25 | import java.util.List; |
| 31 | 26 | ||
| 32 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 27 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 33 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.anyMatch; | 28 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.anyMatch; |
| 34 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue; | 29 | +import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; |
| 35 | 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; |
| 36 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; | 31 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; |
| 37 | -import static cn.iocoder.yudao.module.promotion.util.PromotionUtils.validateProductSkuAllExists; | ||
| 38 | 32 | ||
| 39 | /** | 33 | /** |
| 40 | * 砍价活动 Service 实现类 | 34 | * 砍价活动 Service 实现类 |
| @@ -50,38 +44,37 @@ public class BargainServiceImpl implements BargainActivityService, BargainRecord | @@ -50,38 +44,37 @@ public class BargainServiceImpl implements BargainActivityService, BargainRecord | ||
| 50 | @Resource | 44 | @Resource |
| 51 | private BargainRecordMapper recordMapper; | 45 | private BargainRecordMapper recordMapper; |
| 52 | @Resource | 46 | @Resource |
| 53 | - private BargainProductMapper bargainProductMapper; | ||
| 54 | - @Resource | ||
| 55 | private ProductSpuApi productSpuApi; | 47 | private ProductSpuApi productSpuApi; |
| 56 | @Resource | 48 | @Resource |
| 57 | private ProductSkuApi productSkuApi; | 49 | private ProductSkuApi productSkuApi; |
| 58 | 50 | ||
| 51 | + private static void validateSku(Long skuId, List<ProductSkuRespDTO> skus) { | ||
| 52 | + // 校验商品 sku 是否存在 | ||
| 53 | + if (!CollectionUtils.convertSet(skus, ProductSkuRespDTO::getId).contains(skuId)) { | ||
| 54 | + throw exception(SKU_NOT_EXISTS); | ||
| 55 | + } | ||
| 56 | + } | ||
| 57 | + | ||
| 59 | @Override | 58 | @Override |
| 60 | @Transactional(rollbackFor = Exception.class) | 59 | @Transactional(rollbackFor = Exception.class) |
| 61 | public Long createBargainActivity(BargainActivityCreateReqVO createReqVO) { | 60 | public Long createBargainActivity(BargainActivityCreateReqVO createReqVO) { |
| 62 | // 校验商品 SPU 是否存在是否参加的别的活动 | 61 | // 校验商品 SPU 是否存在是否参加的别的活动 |
| 63 | - validateProductBargainConflict(createReqVO.getSpuId(), null); | 62 | + validateBargainConflict(createReqVO.getSpuId(), null); |
| 64 | // 获取所选 spu下的所有 sku | 63 | // 获取所选 spu下的所有 sku |
| 65 | List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(CollectionUtil.newArrayList(createReqVO.getSpuId())); | 64 | List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(CollectionUtil.newArrayList(createReqVO.getSpuId())); |
| 66 | - // 校验商品 sku 是否存在 | ||
| 67 | - validateProductSkuAllExists(skus, createReqVO.getProducts(), BargainProductCreateReqVO::getSkuId); | 65 | + validateSku(createReqVO.getSkuId(), skus); |
| 68 | 66 | ||
| 69 | // 插入砍价活动 | 67 | // 插入砍价活动 |
| 70 | BargainActivityDO activityDO = BargainActivityConvert.INSTANCE.convert(createReqVO); | 68 | BargainActivityDO activityDO = BargainActivityConvert.INSTANCE.convert(createReqVO); |
| 71 | // TODO 营销相关属性初始化 砍价成功更新相关属性 | 69 | // TODO 营销相关属性初始化 砍价成功更新相关属性 |
| 72 | activityDO.setSuccessCount(0); | 70 | activityDO.setSuccessCount(0); |
| 73 | - // 活动总库存 | ||
| 74 | - activityDO.setStock(getSumValue(createReqVO.getProducts(), BargainProductCreateReqVO::getStock, Integer::sum)); | ||
| 75 | activityDO.setStatus(CommonStatusEnum.ENABLE.getStatus()); | 71 | activityDO.setStatus(CommonStatusEnum.ENABLE.getStatus()); |
| 76 | bargainActivityMapper.insert(activityDO); | 72 | bargainActivityMapper.insert(activityDO); |
| 77 | - // 插入商品 | ||
| 78 | - List<BargainProductDO> productDOs = BargainActivityConvert.INSTANCE.convertList(createReqVO.getProducts(), activityDO); | ||
| 79 | - bargainProductMapper.insertBatch(productDOs); | ||
| 80 | // 返回 | 73 | // 返回 |
| 81 | return activityDO.getId(); | 74 | return activityDO.getId(); |
| 82 | } | 75 | } |
| 83 | 76 | ||
| 84 | - private void validateProductBargainConflict(Long spuId, Long activityId) { | 77 | + private void validateBargainConflict(Long spuId, Long activityId) { |
| 85 | // 校验商品 spu 是否存在 | 78 | // 校验商品 spu 是否存在 |
| 86 | List<ProductSpuRespDTO> spuList = productSpuApi.getSpuList(CollUtil.newArrayList(spuId)); | 79 | List<ProductSpuRespDTO> spuList = productSpuApi.getSpuList(CollUtil.newArrayList(spuId)); |
| 87 | if (CollUtil.isEmpty(spuList)) { | 80 | if (CollUtil.isEmpty(spuList)) { |
| @@ -109,52 +102,16 @@ public class BargainServiceImpl implements BargainActivityService, BargainRecord | @@ -109,52 +102,16 @@ public class BargainServiceImpl implements BargainActivityService, BargainRecord | ||
| 109 | throw exception(BARGAIN_ACTIVITY_STATUS_DISABLE); | 102 | throw exception(BARGAIN_ACTIVITY_STATUS_DISABLE); |
| 110 | } | 103 | } |
| 111 | // 校验商品冲突 | 104 | // 校验商品冲突 |
| 112 | - validateProductBargainConflict(updateReqVO.getSpuId(), updateReqVO.getId()); | 105 | + validateBargainConflict(updateReqVO.getSpuId(), updateReqVO.getId()); |
| 113 | // 获取所选 spu下的所有 sku | 106 | // 获取所选 spu下的所有 sku |
| 114 | List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(CollectionUtil.newArrayList(updateReqVO.getSpuId())); | 107 | List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(CollectionUtil.newArrayList(updateReqVO.getSpuId())); |
| 115 | // 校验商品 sku 是否存在 | 108 | // 校验商品 sku 是否存在 |
| 116 | - validateProductSkuAllExists(skus, updateReqVO.getProducts(), BargainProductUpdateReqVO::getSkuId); | 109 | + validateSku(updateReqVO.getSkuId(), skus); |
| 117 | 110 | ||
| 118 | // 更新 | 111 | // 更新 |
| 119 | BargainActivityDO updateObj = BargainActivityConvert.INSTANCE.convert(updateReqVO); | 112 | BargainActivityDO updateObj = BargainActivityConvert.INSTANCE.convert(updateReqVO); |
| 120 | - // 更新活动库存 | ||
| 121 | - updateObj.setStock(getSumValue(updateReqVO.getProducts(), BargainProductUpdateReqVO::getStock, Integer::sum)); | ||
| 122 | bargainActivityMapper.updateById(updateObj); | 113 | bargainActivityMapper.updateById(updateObj); |
| 123 | - // 更新商品 | ||
| 124 | - updateBargainProduct(updateObj, updateReqVO.getProducts()); | ||
| 125 | - } | ||
| 126 | 114 | ||
| 127 | - /** | ||
| 128 | - * 更新砍价商品 | ||
| 129 | - * | ||
| 130 | - * @param updateObj 更新的活动 | ||
| 131 | - * @param products 商品配置 | ||
| 132 | - */ | ||
| 133 | - private void updateBargainProduct(BargainActivityDO updateObj, List<BargainProductUpdateReqVO> products) { | ||
| 134 | - // 默认全部新增 | ||
| 135 | - List<BargainProductDO> defaultNewList = BargainActivityConvert.INSTANCE.convertList(products, updateObj); | ||
| 136 | - // 数据库中的老数据 | ||
| 137 | - List<BargainProductDO> oldList = bargainProductMapper.selectListByActivityIds(CollUtil.newArrayList(updateObj.getId())); | ||
| 138 | - List<List<BargainProductDO>> lists = CollectionUtils.diffList(oldList, defaultNewList, (oldVal, newVal) -> { | ||
| 139 | - boolean same = ObjectUtil.equal(oldVal.getSkuId(), newVal.getSkuId()); | ||
| 140 | - if (same) { | ||
| 141 | - newVal.setId(oldVal.getId()); | ||
| 142 | - } | ||
| 143 | - return same; | ||
| 144 | - }); | ||
| 145 | - | ||
| 146 | - // create | ||
| 147 | - if (CollUtil.isNotEmpty(lists.get(0))) { | ||
| 148 | - bargainProductMapper.insertBatch(lists.get(0)); | ||
| 149 | - } | ||
| 150 | - // update | ||
| 151 | - if (CollUtil.isNotEmpty(lists.get(1))) { | ||
| 152 | - bargainProductMapper.updateBatch(lists.get(1)); | ||
| 153 | - } | ||
| 154 | - // delete | ||
| 155 | - if (CollUtil.isNotEmpty(lists.get(2))) { | ||
| 156 | - bargainProductMapper.deleteBatchIds(CollectionUtils.convertList(lists.get(2), BargainProductDO::getId)); | ||
| 157 | - } | ||
| 158 | } | 115 | } |
| 159 | 116 | ||
| 160 | @Override | 117 | @Override |
| @@ -189,9 +146,4 @@ public class BargainServiceImpl implements BargainActivityService, BargainRecord | @@ -189,9 +146,4 @@ public class BargainServiceImpl implements BargainActivityService, BargainRecord | ||
| 189 | return bargainActivityMapper.selectPage(pageReqVO); | 146 | return bargainActivityMapper.selectPage(pageReqVO); |
| 190 | } | 147 | } |
| 191 | 148 | ||
| 192 | - @Override | ||
| 193 | - public List<BargainProductDO> getBargainProductsByActivityIds(Collection<Long> ids) { | ||
| 194 | - return bargainProductMapper.selectListByActivityIds(ids); | ||
| 195 | - } | ||
| 196 | - | ||
| 197 | } | 149 | } |
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/CombinationServiceImpl.java
| @@ -30,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional; | @@ -30,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional; | ||
| 30 | import org.springframework.validation.annotation.Validated; | 30 | import org.springframework.validation.annotation.Validated; |
| 31 | 31 | ||
| 32 | import javax.annotation.Resource; | 32 | import javax.annotation.Resource; |
| 33 | +import java.time.LocalDateTime; | ||
| 33 | import java.util.Collection; | 34 | import java.util.Collection; |
| 34 | import java.util.List; | 35 | import java.util.List; |
| 35 | 36 | ||
| @@ -68,8 +69,6 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi | @@ -68,8 +69,6 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi | ||
| 68 | // 校验商品 sku 是否存在 | 69 | // 校验商品 sku 是否存在 |
| 69 | validateProductSkuAllExists(skus, createReqVO.getProducts(), CombinationProductCreateReqVO::getSkuId); | 70 | validateProductSkuAllExists(skus, createReqVO.getProducts(), CombinationProductCreateReqVO::getSkuId); |
| 70 | 71 | ||
| 71 | - // TODO 艿艿 有个小问题:现在有活动时间和限制时长,活动时间的结束时间早于设置的限制时间怎么算状态比如: | ||
| 72 | - // 活动时间 2023-08-05 15:00:00 - 2023-08-05 15:20:00 限制时长 2小时,那么活动时间结束就结束还是加时到满两小时 | ||
| 73 | // 插入拼团活动 | 72 | // 插入拼团活动 |
| 74 | CombinationActivityDO activityDO = CombinationActivityConvert.INSTANCE.convert(createReqVO); | 73 | CombinationActivityDO activityDO = CombinationActivityConvert.INSTANCE.convert(createReqVO); |
| 75 | // TODO 营销相关属性初始化 拼团成功更新相关属性 | 74 | // TODO 营销相关属性初始化 拼团成功更新相关属性 |
| @@ -132,7 +131,7 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi | @@ -132,7 +131,7 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi | ||
| 132 | * 更新拼团商品 | 131 | * 更新拼团商品 |
| 133 | * | 132 | * |
| 134 | * @param activity 拼团活动 | 133 | * @param activity 拼团活动 |
| 135 | - * @param products 该活动的最新商品配置 | 134 | + * @param products 该活动的最新商品配置 |
| 136 | */ | 135 | */ |
| 137 | private void updateCombinationProduct(CombinationActivityDO activity, List<CombinationProductUpdateReqVO> products) { | 136 | private void updateCombinationProduct(CombinationActivityDO activity, List<CombinationProductUpdateReqVO> products) { |
| 138 | // 第一步,对比新老数据,获得添加、修改、删除的列表 | 137 | // 第一步,对比新老数据,获得添加、修改、删除的列表 |
| @@ -201,6 +200,7 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi | @@ -201,6 +200,7 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi | ||
| 201 | } | 200 | } |
| 202 | 201 | ||
| 203 | @Override | 202 | @Override |
| 203 | + @Transactional(rollbackFor = Exception.class) | ||
| 204 | public void updateCombinationRecordStatusByUserIdAndOrderId(CombinationRecordUpdateStatusReqDTO reqDTO) { | 204 | public void updateCombinationRecordStatusByUserIdAndOrderId(CombinationRecordUpdateStatusReqDTO reqDTO) { |
| 205 | // 校验拼团是否存在 | 205 | // 校验拼团是否存在 |
| 206 | CombinationRecordDO recordDO = validateCombinationRecord(reqDTO.getUserId(), reqDTO.getOrderId()); | 206 | CombinationRecordDO recordDO = validateCombinationRecord(reqDTO.getUserId(), reqDTO.getOrderId()); |
| @@ -244,6 +244,7 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi | @@ -244,6 +244,7 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi | ||
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | @Override | 246 | @Override |
| 247 | + @Transactional(rollbackFor = Exception.class) | ||
| 247 | public void createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { | 248 | public void createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { |
| 248 | // 1.1 校验拼团活动 | 249 | // 1.1 校验拼团活动 |
| 249 | CombinationActivityDO activity = validateCombinationActivityExists(reqDTO.getActivityId()); | 250 | CombinationActivityDO activity = validateCombinationActivityExists(reqDTO.getActivityId()); |
| @@ -252,9 +253,19 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi | @@ -252,9 +253,19 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi | ||
| 252 | if (recordDO != null) { | 253 | if (recordDO != null) { |
| 253 | throw exception(COMBINATION_RECORD_EXISTS); | 254 | throw exception(COMBINATION_RECORD_EXISTS); |
| 254 | } | 255 | } |
| 255 | - // 1.3 父拼团是否存在,是否已经满了 | 256 | + // 1.3 校验用户是否参加了其它拼团 |
| 257 | + List<CombinationRecordDO> recordDOList = recordMapper.selectListByUserIdAndStatus(reqDTO.getUserId(), CombinationRecordStatusEnum.IN_PROGRESS.getStatus()); | ||
| 258 | + if (CollUtil.isNotEmpty(recordDOList)) { | ||
| 259 | + throw exception(COMBINATION_RECORD_FAILED_HAVE_JOINED); | ||
| 260 | + } | ||
| 261 | + // 1.4 校验当前活动是否过期 | ||
| 262 | + if (LocalDateTime.now().isAfter(activity.getEndTime())) { | ||
| 263 | + throw exception(COMBINATION_RECORD_FAILED_TIME_END); | ||
| 264 | + } | ||
| 265 | + // 1.5 父拼团是否存在,是否已经满了 | ||
| 256 | if (reqDTO.getHeadId() != null) { | 266 | if (reqDTO.getHeadId() != null) { |
| 257 | - CombinationRecordDO recordDO1 = recordMapper.selectRecordByHeadId(reqDTO.getHeadId(), reqDTO.getActivityId(), CombinationRecordStatusEnum.IN_PROGRESS.getStatus()); | 267 | + // 查询进行中的父拼团 |
| 268 | + CombinationRecordDO recordDO1 = recordMapper.selectOneByHeadId(reqDTO.getHeadId(), CombinationRecordStatusEnum.IN_PROGRESS.getStatus()); | ||
| 258 | if (recordDO1 == null) { | 269 | if (recordDO1 == null) { |
| 259 | throw exception(COMBINATION_RECORD_HEAD_NOT_EXISTS); | 270 | throw exception(COMBINATION_RECORD_HEAD_NOT_EXISTS); |
| 260 | } | 271 | } |
| @@ -263,7 +274,6 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi | @@ -263,7 +274,6 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi | ||
| 263 | throw exception(COMBINATION_RECORD_USER_FULL); | 274 | throw exception(COMBINATION_RECORD_USER_FULL); |
| 264 | } | 275 | } |
| 265 | } | 276 | } |
| 266 | - // TODO @puhui999:应该还有一些校验,后续补噶;例如说,一个团,自己已经参与进去了,不能再参与进去; | ||
| 267 | 277 | ||
| 268 | // 2. 创建拼团记录 | 278 | // 2. 创建拼团记录 |
| 269 | CombinationRecordDO record = CombinationActivityConvert.INSTANCE.convert(reqDTO); | 279 | CombinationRecordDO record = CombinationActivityConvert.INSTANCE.convert(reqDTO); |
| @@ -288,4 +298,22 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi | @@ -288,4 +298,22 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi | ||
| 288 | return recordMapper.selectListByStatus(status); | 298 | return recordMapper.selectListByStatus(status); |
| 289 | } | 299 | } |
| 290 | 300 | ||
| 301 | + public List<CombinationRecordDO> getRecordListByUserIdAndActivityId(Long userId, Long activityId) { | ||
| 302 | + return recordMapper.selectListByUserIdAndActivityId(userId, activityId); | ||
| 303 | + } | ||
| 304 | + | ||
| 305 | + @Override | ||
| 306 | + public void validateCombinationLimitCount(Long activityId, Integer count, Integer sumCount) { | ||
| 307 | + // 1.1 校验拼团活动 | ||
| 308 | + CombinationActivityDO activity = validateCombinationActivityExists(activityId); | ||
| 309 | + // 校验是否达到限购总限购标准 | ||
| 310 | + if ((sumCount + count) > activity.getTotalLimitCount()) { | ||
| 311 | + throw exception(COMBINATION_RECORD_FAILED_TOTAL_LIMIT_COUNT_EXCEED); | ||
| 312 | + } | ||
| 313 | + // 单次购买是否达到限购标准 | ||
| 314 | + if (count > activity.getSingleLimitCount()) { | ||
| 315 | + throw exception(COMBINATION_RECORD_FAILED_SINGLE_LIMIT_COUNT_EXCEED); | ||
| 316 | + } | ||
| 317 | + } | ||
| 318 | + | ||
| 291 | } | 319 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillconfig/SeckillConfigServiceImpl.java
| @@ -62,7 +62,6 @@ public class SeckillConfigServiceImpl implements SeckillConfigService { | @@ -62,7 +62,6 @@ public class SeckillConfigServiceImpl implements SeckillConfigService { | ||
| 62 | seckillConfigMapper.updateById(updateObj); | 62 | seckillConfigMapper.updateById(updateObj); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | - // TODO @puhui999: 这个要不合并到更新操作里? 不单独有个操作咧; fix: 更新状态不用那么多必须的参数,更新的时候需要校验时间段 | ||
| 66 | @Override | 65 | @Override |
| 67 | public void updateSeckillConfigStatus(Long id, Integer status) { | 66 | public void updateSeckillConfigStatus(Long id, Integer status) { |
| 68 | // 校验秒杀时段是否存在 | 67 | // 校验秒杀时段是否存在 |
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,19 +151,7 @@ public class CombinationActivityServiceImplTest extends BaseDbUnitTest { | @@ -152,19 +151,7 @@ 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.setSpuId(null); | ||
| 156 | - reqVO.setTotalLimitCount(null); | ||
| 157 | - reqVO.setSingleLimitCount(null); | ||
| 158 | - reqVO.setStartTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | ||
| 159 | - reqVO.setEndTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | ||
| 160 | - reqVO.setUserSize(null); | ||
| 161 | - reqVO.setTotalNum(null); | ||
| 162 | - reqVO.setSuccessNum(null); | ||
| 163 | - reqVO.setOrderUserCount(null); | ||
| 164 | - reqVO.setVirtualGroup(null); | ||
| 165 | reqVO.setStatus(null); | 154 | reqVO.setStatus(null); |
| 166 | - reqVO.setLimitDuration(null); | ||
| 167 | - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | ||
| 168 | 155 | ||
| 169 | // 调用 | 156 | // 调用 |
| 170 | PageResult<CombinationActivityDO> pageResult = combinationActivityService.getCombinationActivityPage(reqVO); | 157 | PageResult<CombinationActivityDO> pageResult = combinationActivityService.getCombinationActivityPage(reqVO); |
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
| @@ -126,8 +126,7 @@ public class AppTradeOrderController { | @@ -126,8 +126,7 @@ public class AppTradeOrderController { | ||
| 126 | @Operation(summary = "确认交易订单收货") | 126 | @Operation(summary = "确认交易订单收货") |
| 127 | @Parameter(name = "id", description = "交易订单编号") | 127 | @Parameter(name = "id", description = "交易订单编号") |
| 128 | public CommonResult<Boolean> takeOrder(@RequestParam("id") Long id) { | 128 | public CommonResult<Boolean> takeOrder(@RequestParam("id") Long id) { |
| 129 | - // TODO @芋艿:未实现,mock 用 | ||
| 130 | - return success(true); | 129 | + return success(tradeOrderService.receiveOrder(getLoginUserId(), id)); |
| 131 | } | 130 | } |
| 132 | 131 | ||
| 133 | @DeleteMapping("/cancel") | 132 | @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 状态为已发货,等待收货 |
| @@ -428,16 +434,6 @@ public class TradeOrderServiceImpl implements TradeOrderService { | @@ -428,16 +434,6 @@ public class TradeOrderServiceImpl implements TradeOrderService { | ||
| 428 | // TODO 设计:lili:是不是发货后,才支持售后? | 434 | // TODO 设计:lili:是不是发货后,才支持售后? |
| 429 | } | 435 | } |
| 430 | 436 | ||
| 431 | - private void validateDeliveryExpress(TradeOrderDeliveryReqVO deliveryReqVO) { | ||
| 432 | - DeliveryExpressDO deliveryExpress = deliveryExpressService.getDeliveryExpress(deliveryReqVO.getLogisticsId()); | ||
| 433 | - if (deliveryExpress == null) { | ||
| 434 | - throw exception(EXPRESS_NOT_EXISTS); | ||
| 435 | - } | ||
| 436 | - if (deliveryExpress.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { | ||
| 437 | - throw exception(EXPRESS_STATUS_NOT_ENABLE); | ||
| 438 | - } | ||
| 439 | - } | ||
| 440 | - | ||
| 441 | /** | 437 | /** |
| 442 | * 校验交易订单满足被发货的条件 | 438 | * 校验交易订单满足被发货的条件 |
| 443 | * | 439 | * |
| @@ -464,17 +460,23 @@ public class TradeOrderServiceImpl implements TradeOrderService { | @@ -464,17 +460,23 @@ public class TradeOrderServiceImpl implements TradeOrderService { | ||
| 464 | // 订单类型:拼团 | 460 | // 订单类型:拼团 |
| 465 | if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) { | 461 | if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) { |
| 466 | // 校验订单拼团是否成功 | 462 | // 校验订单拼团是否成功 |
| 467 | - if (combinationRecordApi.isCombinationRecordSuccess(order.getUserId(), order.getId())) { | 463 | + if (combinationRecordApi.validateRecordSuccess(order.getUserId(), order.getId())) { |
| 468 | throw exception(ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS); | 464 | throw exception(ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS); |
| 469 | } | 465 | } |
| 470 | } | 466 | } |
| 471 | - // TODO puhui999: 校验订单砍价是否成功 | 467 | + // 订单类类型:砍价 |
| 468 | + if (Objects.equals(TradeOrderTypeEnum.BARGAIN.getType(), order.getType())) { | ||
| 469 | + // 校验订单砍价是否成功 | ||
| 470 | + if (bargainRecordApi.validateRecordSuccess(order.getUserId(), order.getId())) { | ||
| 471 | + throw exception(ORDER_DELIVERY_FAIL_BARGAIN_RECORD_STATUS_NOT_SUCCESS); | ||
| 472 | + } | ||
| 473 | + } | ||
| 472 | return order; | 474 | return order; |
| 473 | } | 475 | } |
| 474 | 476 | ||
| 475 | @Override | 477 | @Override |
| 476 | @Transactional(rollbackFor = Exception.class) | 478 | @Transactional(rollbackFor = Exception.class) |
| 477 | - public void receiveOrder(Long userId, Long id) { | 479 | + public Boolean receiveOrder(Long userId, Long id) { |
| 478 | // 校验并获得交易订单(可收货) | 480 | // 校验并获得交易订单(可收货) |
| 479 | TradeOrderDO order = validateOrderReceivable(userId, id); | 481 | TradeOrderDO order = validateOrderReceivable(userId, id); |
| 480 | 482 | ||
| @@ -490,6 +492,7 @@ public class TradeOrderServiceImpl implements TradeOrderService { | @@ -490,6 +492,7 @@ public class TradeOrderServiceImpl implements TradeOrderService { | ||
| 490 | // TODO 芋艿:lili 发送订单变化的消息 | 492 | // TODO 芋艿:lili 发送订单变化的消息 |
| 491 | 493 | ||
| 492 | // TODO 芋艿:lili 发送商品被购买完成的数据 | 494 | // TODO 芋艿:lili 发送商品被购买完成的数据 |
| 495 | + return Boolean.TRUE; | ||
| 493 | } | 496 | } |
| 494 | 497 | ||
| 495 | @Override | 498 | @Override |