Commit 2591ab5d36a19ece7b3acff1574410af80c4e3cd
1 parent
c25bf38f
订单中心+营销活动:完善部分 TODO 提到的问题
Showing
18 changed files
with
97 additions
and
152 deletions
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/CommonResult.java
| ... | ... | @@ -41,7 +41,7 @@ public class CommonResult<T> implements Serializable { |
| 41 | 41 | * 因为 A 方法返回的 CommonResult 对象,不满足调用其的 B 方法的返回,所以需要进行转换。 |
| 42 | 42 | * |
| 43 | 43 | * @param result 传入的 result 对象 |
| 44 | - * @param <T> 返回的泛型 | |
| 44 | + * @param <T> 返回的泛型 | |
| 45 | 45 | * @return 新的 CommonResult 对象 |
| 46 | 46 | */ |
| 47 | 47 | public static <T> CommonResult<T> error(CommonResult<?> result) { |
| ... | ... | @@ -68,6 +68,14 @@ public class CommonResult<T> implements Serializable { |
| 68 | 68 | return result; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | + public static <T> CommonResult<T> success(T data, String msg) { | |
| 72 | + CommonResult<T> result = new CommonResult<>(); | |
| 73 | + result.code = GlobalErrorCodeConstants.SUCCESS.getCode(); | |
| 74 | + result.data = data; | |
| 75 | + result.msg = msg; | |
| 76 | + return result; | |
| 77 | + } | |
| 78 | + | |
| 71 | 79 | public static boolean isSuccess(Integer code) { |
| 72 | 80 | return Objects.equals(code, GlobalErrorCodeConstants.SUCCESS.getCode()); |
| 73 | 81 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/dto/BargainRecordCreateReqDTO.java
| ... | ... | @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.promotion.api.bargain.dto; |
| 2 | 2 | |
| 3 | 3 | import lombok.Data; |
| 4 | 4 | |
| 5 | -import javax.validation.constraints.NotEmpty; | |
| 6 | 5 | import javax.validation.constraints.NotNull; |
| 7 | 6 | |
| 8 | 7 | // TODO @芋艿:这块要在看看 |
| ... | ... | @@ -40,17 +39,7 @@ public class BargainRecordCreateReqDTO { |
| 40 | 39 | */ |
| 41 | 40 | @NotNull(message = "订单编号不能为空") |
| 42 | 41 | private Long orderId; |
| 43 | - // TODO @puhui999:spuName、picUrl、 之类字段不用传递; | |
| 44 | - /** | |
| 45 | - * 商品名字 | |
| 46 | - */ | |
| 47 | - @NotEmpty(message = "商品名字不能为空") | |
| 48 | - private String spuName; | |
| 49 | - /** | |
| 50 | - * 商品图片 | |
| 51 | - */ | |
| 52 | - @NotEmpty(message = "商品图片不能为空") | |
| 53 | - private String picUrl; | |
| 42 | + | |
| 54 | 43 | /** |
| 55 | 44 | * 砍价商品单价 |
| 56 | 45 | */ |
| ... | ... | @@ -61,17 +50,7 @@ public class BargainRecordCreateReqDTO { |
| 61 | 50 | */ |
| 62 | 51 | @NotNull(message = "商品原价不能为空") |
| 63 | 52 | private Integer price; |
| 64 | - // TODO @puhui999:nickname、avatar 不用传递,去查询; | |
| 65 | - /** | |
| 66 | - * 用户昵称 | |
| 67 | - */ | |
| 68 | - @NotEmpty(message = "用户昵称不能为空") | |
| 69 | - private String nickname; | |
| 70 | - /** | |
| 71 | - * 用户头像 | |
| 72 | - */ | |
| 73 | - @NotEmpty(message = "用户头像不能为空") | |
| 74 | - private String avatar; | |
| 53 | + | |
| 75 | 54 | /** |
| 76 | 55 | * 开团状态:进行中 砍价成功 砍价失败 |
| 77 | 56 | */ | ... | ... |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java
| ... | ... | @@ -2,9 +2,9 @@ package cn.iocoder.yudao.module.promotion.api.combination; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 4 | 4 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordRespDTO; |
| 5 | -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO; | |
| 6 | 5 | |
| 7 | 6 | import javax.validation.Valid; |
| 7 | +import java.time.LocalDateTime; | |
| 8 | 8 | import java.util.List; |
| 9 | 9 | |
| 10 | 10 | // TODO @芋艿:后面也再撸撸这几个接口 |
| ... | ... | @@ -51,13 +51,29 @@ public interface CombinationRecordApi { |
| 51 | 51 | */ |
| 52 | 52 | void validateCombinationLimitCount(Long activityId, Integer count, Integer sumCount); |
| 53 | 53 | |
| 54 | - // TODO @puhui999:是不是搞成具体的方法,拼团成功,拼团失败,这种方法; | |
| 54 | + /** | |
| 55 | + * 更新拼团状态为 成功 | |
| 56 | + * | |
| 57 | + * @param userId 用户编号 | |
| 58 | + * @param orderId 订单编号 | |
| 59 | + */ | |
| 60 | + void updateRecordStatusToSuccess(Long userId, Long orderId); | |
| 55 | 61 | |
| 56 | 62 | /** |
| 57 | - * 更新开团记录状态 | |
| 63 | + * 更新拼团状态为 失败 | |
| 58 | 64 | * |
| 59 | - * @param reqDTO 请求 DTO | |
| 65 | + * @param userId 用户编号 | |
| 66 | + * @param orderId 订单编号 | |
| 67 | + */ | |
| 68 | + void updateRecordStatusToFailed(Long userId, Long orderId); | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * 更新拼团状态为 进行中 | |
| 72 | + * | |
| 73 | + * @param userId 用户编号 | |
| 74 | + * @param orderId 订单编号 | |
| 75 | + * @param startTime 开始时间 | |
| 60 | 76 | */ |
| 61 | - void updateCombinationRecordStatus(CombinationRecordUpdateStatusReqDTO reqDTO); | |
| 77 | + void updateRecordStatusToInProgress(Long userId, Long orderId, LocalDateTime startTime); | |
| 62 | 78 | |
| 63 | 79 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordUpdateStatusReqDTO.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.api.combination.dto; | |
| 2 | - | |
| 3 | -import lombok.Data; | |
| 4 | - | |
| 5 | -import javax.validation.constraints.NotNull; | |
| 6 | -import java.time.LocalDateTime; | |
| 7 | - | |
| 8 | -/** | |
| 9 | - * 拼团记录的更新状态 Request DTO | |
| 10 | - * | |
| 11 | - * @author HUIHUI | |
| 12 | - */ | |
| 13 | -@Data | |
| 14 | -public class CombinationRecordUpdateStatusReqDTO { | |
| 15 | - | |
| 16 | - /** | |
| 17 | - * 用户编号 | |
| 18 | - */ | |
| 19 | - @NotNull(message = "用户编号不能为空") | |
| 20 | - private Long userId; | |
| 21 | - | |
| 22 | - /** | |
| 23 | - * 订单编号 | |
| 24 | - */ | |
| 25 | - @NotNull(message = "订单编号不能为空") | |
| 26 | - private Long orderId; | |
| 27 | - | |
| 28 | - /** | |
| 29 | - * 开团状态:正在开团 拼团成功 拼团失败 | |
| 30 | - */ | |
| 31 | - @NotNull(message = "开团状态不能为空") | |
| 32 | - private Integer status; | |
| 33 | - | |
| 34 | - /** | |
| 35 | - * 团开始时间 | |
| 36 | - */ | |
| 37 | - private LocalDateTime startTime; | |
| 38 | - | |
| 39 | -} |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java
| ... | ... | @@ -51,7 +51,7 @@ public interface ErrorCodeConstants { |
| 51 | 51 | |
| 52 | 52 | // ========== 秒杀活动 1013008000 ========== |
| 53 | 53 | ErrorCode SECKILL_ACTIVITY_NOT_EXISTS = new ErrorCode(1013008000, "秒杀活动不存在"); |
| 54 | - ErrorCode SECKILL_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1013008002, "存在商品参加了其它秒杀活动"); | |
| 54 | + ErrorCode SECKILL_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1013008002, "存在商品参加了其它秒杀活动,秒杀时段冲突"); | |
| 55 | 55 | ErrorCode SECKILL_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1013008003, "秒杀活动已关闭,不能修改"); |
| 56 | 56 | ErrorCode SECKILL_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1013008004, "秒杀活动未关闭或未结束,不能删除"); |
| 57 | 57 | ErrorCode SECKILL_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1013008005, "秒杀活动已关闭,不能重复关闭"); | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java
| ... | ... | @@ -2,13 +2,13 @@ package cn.iocoder.yudao.module.promotion.api.combination; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 4 | 4 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordRespDTO; |
| 5 | -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO; | |
| 6 | 5 | import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; |
| 7 | 6 | import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; |
| 8 | 7 | import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; |
| 9 | 8 | import org.springframework.stereotype.Service; |
| 10 | 9 | |
| 11 | 10 | import javax.annotation.Resource; |
| 11 | +import java.time.LocalDateTime; | |
| 12 | 12 | import java.util.List; |
| 13 | 13 | |
| 14 | 14 | /** |
| ... | ... | @@ -43,12 +43,19 @@ public class CombinationRecordApiImpl implements CombinationRecordApi { |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | @Override |
| 46 | - public void updateCombinationRecordStatus(CombinationRecordUpdateStatusReqDTO reqDTO) { | |
| 47 | - if (null == reqDTO.getStartTime()) { | |
| 48 | - recordService.updateCombinationRecordStatusByUserIdAndOrderId(reqDTO); | |
| 49 | - } else { | |
| 50 | - recordService.updateCombinationRecordStatusAndStartTimeByUserIdAndOrderId(reqDTO); | |
| 51 | - } | |
| 46 | + public void updateRecordStatusToSuccess(Long userId, Long orderId) { | |
| 47 | + recordService.updateCombinationRecordStatusByUserIdAndOrderId(CombinationRecordStatusEnum.SUCCESS.getStatus(), userId, orderId); | |
| 48 | + } | |
| 49 | + | |
| 50 | + @Override | |
| 51 | + public void updateRecordStatusToFailed(Long userId, Long orderId) { | |
| 52 | + recordService.updateCombinationRecordStatusByUserIdAndOrderId(CombinationRecordStatusEnum.FAILED.getStatus(), userId, orderId); | |
| 53 | + } | |
| 54 | + | |
| 55 | + @Override | |
| 56 | + public void updateRecordStatusToInProgress(Long userId, Long orderId, LocalDateTime startTime) { | |
| 57 | + recordService.updateRecordStatusAndStartTimeByUserIdAndOrderId(CombinationRecordStatusEnum.IN_PROGRESS.getStatus(), | |
| 58 | + userId, orderId, startTime); | |
| 52 | 59 | } |
| 53 | 60 | |
| 54 | 61 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationRecordDO.java
| ... | ... | @@ -86,11 +86,11 @@ public class CombinationRecordDO extends BaseDO { |
| 86 | 86 | */ |
| 87 | 87 | private Boolean virtualGroup; |
| 88 | 88 | /** |
| 89 | - * 过期时间,单位:小时 | |
| 89 | + * 过期时间 | |
| 90 | 90 | * |
| 91 | - * 关联 {@link CombinationActivityDO#getLimitDuration()} | |
| 91 | + * {@link CombinationRecordDO#getStartTime()} + {@link CombinationActivityDO#getLimitDuration()} 计算 | |
| 92 | 92 | */ |
| 93 | - private Integer expireTime; | |
| 93 | + private LocalDateTime expireTime; | |
| 94 | 94 | /** |
| 95 | 95 | * 开始时间 (订单付款后开始的时间) |
| 96 | 96 | */ | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.service.combination; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 4 | -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO; | |
| 5 | 4 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; |
| 6 | 5 | |
| 6 | +import java.time.LocalDateTime; | |
| 7 | 7 | import java.util.List; |
| 8 | 8 | |
| 9 | 9 | /** |
| ... | ... | @@ -16,9 +16,11 @@ public interface CombinationRecordService { |
| 16 | 16 | /** |
| 17 | 17 | * 更新拼团状态 |
| 18 | 18 | * |
| 19 | - * @param reqDTO 请求 DTO | |
| 19 | + * @param status 状态 | |
| 20 | + * @param userId 用户编号 | |
| 21 | + * @param orderId 订单编号 | |
| 20 | 22 | */ |
| 21 | - void updateCombinationRecordStatusByUserIdAndOrderId(CombinationRecordUpdateStatusReqDTO reqDTO); | |
| 23 | + void updateCombinationRecordStatusByUserIdAndOrderId(Integer status, Long userId, Long orderId); | |
| 22 | 24 | |
| 23 | 25 | /** |
| 24 | 26 | * 创建拼团记录 |
| ... | ... | @@ -30,9 +32,12 @@ public interface CombinationRecordService { |
| 30 | 32 | /** |
| 31 | 33 | * 更新拼团状态和开始时间 |
| 32 | 34 | * |
| 33 | - * @param reqDTO 请求 DTO | |
| 35 | + * @param status 状态 | |
| 36 | + * @param userId 用户编号 | |
| 37 | + * @param orderId 订单编号 | |
| 38 | + * @param startTime 开始时间 | |
| 34 | 39 | */ |
| 35 | - void updateCombinationRecordStatusAndStartTimeByUserIdAndOrderId(CombinationRecordUpdateStatusReqDTO reqDTO); | |
| 40 | + void updateRecordStatusAndStartTimeByUserIdAndOrderId(Integer status, Long userId, Long orderId, LocalDateTime startTime); | |
| 36 | 41 | |
| 37 | 42 | /** |
| 38 | 43 | * 获得拼团状态 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
| ... | ... | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.promotion.service.combination; |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.util.ObjectUtil; |
| 5 | 5 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 6 | -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO; | |
| 7 | 6 | import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; |
| 8 | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; |
| 9 | 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; |
| ... | ... | @@ -21,6 +20,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU |
| 21 | 20 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; |
| 22 | 21 | |
| 23 | 22 | // TODO 芋艿:等拼团记录做完,完整 review 下 |
| 23 | + | |
| 24 | 24 | /** |
| 25 | 25 | * 拼团记录 Service 实现类 |
| 26 | 26 | * |
| ... | ... | @@ -38,27 +38,27 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 38 | 38 | |
| 39 | 39 | @Override |
| 40 | 40 | @Transactional(rollbackFor = Exception.class) |
| 41 | - public void updateCombinationRecordStatusByUserIdAndOrderId(CombinationRecordUpdateStatusReqDTO reqDTO) { | |
| 41 | + public void updateCombinationRecordStatusByUserIdAndOrderId(Integer status, Long userId, Long orderId) { | |
| 42 | 42 | // 校验拼团是否存在 |
| 43 | - CombinationRecordDO recordDO = validateCombinationRecord(reqDTO.getUserId(), reqDTO.getOrderId()); | |
| 43 | + CombinationRecordDO recordDO = validateCombinationRecord(userId, orderId); | |
| 44 | 44 | |
| 45 | 45 | // 更新状态 |
| 46 | - recordDO.setStatus(reqDTO.getStatus()); | |
| 46 | + recordDO.setStatus(status); | |
| 47 | 47 | recordMapper.updateById(recordDO); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | @Override |
| 51 | 51 | @Transactional(rollbackFor = Exception.class) |
| 52 | - public void updateCombinationRecordStatusAndStartTimeByUserIdAndOrderId(CombinationRecordUpdateStatusReqDTO reqDTO) { | |
| 53 | - CombinationRecordDO recordDO = validateCombinationRecord(reqDTO.getUserId(), reqDTO.getOrderId()); | |
| 52 | + public void updateRecordStatusAndStartTimeByUserIdAndOrderId(Integer status, Long userId, Long orderId, LocalDateTime startTime) { | |
| 53 | + CombinationRecordDO recordDO = validateCombinationRecord(userId, orderId); | |
| 54 | 54 | // 更新状态 |
| 55 | - recordDO.setStatus(reqDTO.getStatus()); | |
| 55 | + recordDO.setStatus(status); | |
| 56 | 56 | // 更新开始时间 |
| 57 | - recordDO.setStartTime(reqDTO.getStartTime()); | |
| 57 | + recordDO.setStartTime(startTime); | |
| 58 | 58 | recordMapper.updateById(recordDO); |
| 59 | 59 | |
| 60 | 60 | // 更新拼团参入人数 |
| 61 | - List<CombinationRecordDO> recordDOs = recordMapper.selectListByHeadIdAndStatus(recordDO.getHeadId(), reqDTO.getStatus()); | |
| 61 | + List<CombinationRecordDO> recordDOs = recordMapper.selectListByHeadIdAndStatus(recordDO.getHeadId(), status); | |
| 62 | 62 | if (CollUtil.isNotEmpty(recordDOs)) { |
| 63 | 63 | recordDOs.forEach(item -> { |
| 64 | 64 | item.setUserCount(recordDOs.size()); |
| ... | ... | @@ -115,8 +115,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 115 | 115 | // 2. 创建拼团记录 |
| 116 | 116 | CombinationRecordDO record = CombinationActivityConvert.INSTANCE.convert(reqDTO); |
| 117 | 117 | record.setVirtualGroup(false); |
| 118 | - // TODO @puhui999:过期时间,应该是 Date 哈; | |
| 119 | - record.setExpireTime(activity.getLimitDuration()); | |
| 118 | + record.setExpireTime(record.getStartTime().plusHours(activity.getLimitDuration())); | |
| 120 | 119 | record.setUserSize(activity.getUserSize()); |
| 121 | 120 | recordMapper.insert(record); |
| 122 | 121 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java
| ... | ... | @@ -92,15 +92,9 @@ public class SeckillActivityServiceImpl implements SeckillActivityService { |
| 92 | 92 | if (activityId != null) { // 排除自己 |
| 93 | 93 | activityList.removeIf(item -> ObjectUtil.equal(item.getId(), activityId)); |
| 94 | 94 | } |
| 95 | - // TODO @puhui999:一个 spu,参与两个活动应该没关系,关键是活动时间不充能重叠; | |
| 96 | - // 2.2 过滤出所有 spuId 有交集的活动,判断是否存在重叠 | |
| 97 | - List<SeckillActivityDO> activityDOs1 = filterList(activityList, s -> ObjectUtil.equal(s.getSpuId(), spuId)); | |
| 98 | - if (isNotEmpty(activityDOs1)) { | |
| 99 | - throw exception(SECKILL_ACTIVITY_SPU_CONFLICTS); | |
| 100 | - } | |
| 101 | - // 2.3 过滤出所有 configIds 有交集的活动,判断是否存在重叠 | |
| 102 | - List<SeckillActivityDO> activityDOs2 = filterList(activityList, s -> containsAny(s.getConfigIds(), configIds)); | |
| 103 | - if (isNotEmpty(activityDOs2)) { | |
| 95 | + // 2.2 过滤出所有 configIds 有交集的活动,判断是否存在重叠 | |
| 96 | + List<SeckillActivityDO> activityDOs = filterList(activityList, s -> containsAny(s.getConfigIds(), configIds)); | |
| 97 | + if (isNotEmpty(activityDOs)) { | |
| 104 | 98 | throw exception(SECKILL_ACTIVITY_SPU_CONFLICTS); |
| 105 | 99 | } |
| 106 | 100 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/util/PromotionUtils.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.util; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | |
| 5 | 4 | import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; |
| 6 | -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; | |
| 7 | 5 | |
| 8 | 6 | import java.time.LocalDateTime; |
| 9 | -import java.util.List; | |
| 10 | -import java.util.Set; | |
| 11 | -import java.util.function.Function; | |
| 12 | - | |
| 13 | -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 14 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.anyMatch; | |
| 15 | -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; | |
| 16 | 7 | |
| 17 | 8 | /** |
| 18 | 9 | * 活动工具类 |
| ... | ... | @@ -31,21 +22,4 @@ public class PromotionUtils { |
| 31 | 22 | return LocalDateTimeUtils.beforeNow(endTime) ? CommonStatusEnum.DISABLE.getStatus() : CommonStatusEnum.ENABLE.getStatus(); |
| 32 | 23 | } |
| 33 | 24 | |
| 34 | - /** | |
| 35 | - * 校验商品 sku 是否都存在 | |
| 36 | - * | |
| 37 | - * @param skus 数据库中的商品 skus | |
| 38 | - * @param products 需要校验的商品 | |
| 39 | - * @param func 获取需要校验的商品的 skuId | |
| 40 | - */ | |
| 41 | - public static <T> void validateProductSkuAllExists(List<ProductSkuRespDTO> skus, List<T> products, Function<T, Long> func) { | |
| 42 | - // 校验 sku 个数是否一致 | |
| 43 | - Set<Long> skuIdsSet = CollectionUtils.convertSet(products, func); | |
| 44 | - Set<Long> skuIdsSet1 = CollectionUtils.convertSet(skus, ProductSkuRespDTO::getId); | |
| 45 | - // 校验 skuId 是否存在 | |
| 46 | - if (anyMatch(skuIdsSet, s -> !skuIdsSet1.contains(s))) { | |
| 47 | - throw exception(SKU_NOT_EXISTS); | |
| 48 | - } | |
| 49 | - } | |
| 50 | - | |
| 51 | 25 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.java
| ... | ... | @@ -36,6 +36,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 36 | 36 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 37 | 37 | import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; |
| 38 | 38 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 39 | +import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.AFTER_SALE_NOT_FOUND; | |
| 39 | 40 | |
| 40 | 41 | @Tag(name = "管理后台 - 售后订单") |
| 41 | 42 | @RestController |
| ... | ... | @@ -76,6 +77,9 @@ public class TradeAfterSaleController { |
| 76 | 77 | public CommonResult<TradeAfterSaleDetailRespVO> getOrderDetail(@RequestParam("id") Long id) { |
| 77 | 78 | // 查询订单 |
| 78 | 79 | TradeAfterSaleDO afterSale = afterSaleService.getAfterSale(id); |
| 80 | + if (afterSale == null) { | |
| 81 | + return success(null, AFTER_SALE_NOT_FOUND.getMsg()); | |
| 82 | + } | |
| 79 | 83 | // 查询订单 |
| 80 | 84 | TradeOrderDO order = tradeOrderQueryService.getOrder(afterSale.getOrderId()); |
| 81 | 85 | // 查询订单项 |
| ... | ... | @@ -92,7 +96,11 @@ public class TradeAfterSaleController { |
| 92 | 96 | TradeAfterSaleLogRespDTO respVO = new TradeAfterSaleLogRespDTO(); |
| 93 | 97 | respVO.setId((long) i); |
| 94 | 98 | respVO.setUserId((long) i); |
| 95 | - respVO.setUserType(1); | |
| 99 | + respVO.setUserType(i % 2 == 0 ? 2 : 1); | |
| 100 | + // 模拟系统操作 | |
| 101 | + if (i == 2) { | |
| 102 | + respVO.setUserType(3); | |
| 103 | + } | |
| 96 | 104 | respVO.setAfterSaleId(id); |
| 97 | 105 | respVO.setOrderId((long) i); |
| 98 | 106 | respVO.setOrderItemId((long) i); | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/TradeAfterSaleDetailRespVO.java
| ... | ... | @@ -35,7 +35,7 @@ public class TradeAfterSaleDetailRespVO extends TradeAfterSaleBaseVO { |
| 35 | 35 | /** |
| 36 | 36 | * 售后日志 |
| 37 | 37 | */ |
| 38 | - private List<TradeAfterSaleLogRespVO> afterSaleLog; | |
| 38 | + private List<TradeAfterSaleLogRespVO> logs; | |
| 39 | 39 | |
| 40 | 40 | @Schema(description = "管理后台 - 交易订单的详情的订单项目") |
| 41 | 41 | @Data | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDetailRespVO.java
| ... | ... | @@ -26,24 +26,23 @@ public class TradeOrderDetailRespVO extends TradeOrderBaseVO { |
| 26 | 26 | private MemberUserRespVO user; |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | - * TODO 订单操作日志, 先模拟一波;返回 logs,简洁,然后复数哈 | |
| 29 | + * TODO 订单操作日志, 先模拟一波 | |
| 30 | 30 | */ |
| 31 | - private List<OrderLog> orderLog; | |
| 31 | + private List<OrderLog> logs; | |
| 32 | 32 | |
| 33 | - // TODO @puhui999:swagger 注解 | |
| 33 | + @Schema(description = "管理后台 - 交易订单的操作日志") | |
| 34 | 34 | @Data |
| 35 | 35 | public static class OrderLog { |
| 36 | 36 | |
| 37 | - /** | |
| 38 | - * 内容 | |
| 39 | - */ | |
| 37 | + @Schema(description = "操作详情", requiredMode = Schema.RequiredMode.REQUIRED, example = "订单发货") | |
| 40 | 38 | private String content; |
| 41 | 39 | |
| 42 | - /** | |
| 43 | - * 创建时间 | |
| 44 | - */ | |
| 40 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-06-01 10:50:20") | |
| 45 | 41 | private LocalDateTime createTime; |
| 46 | 42 | |
| 43 | + @Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 44 | + private Integer userType; | |
| 45 | + | |
| 47 | 46 | } |
| 48 | 47 | |
| 49 | 48 | @Schema(description = "管理后台 - 交易订单的详情的订单项目") | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/TradeAfterSaleConvert.java
| ... | ... | @@ -78,7 +78,7 @@ public interface TradeAfterSaleConvert { |
| 78 | 78 | // 处理订单信息 |
| 79 | 79 | respVO.setOrder(convert(order)); |
| 80 | 80 | // 处理售后日志 |
| 81 | - respVO.setAfterSaleLog(convertList1(logs)); | |
| 81 | + respVO.setLogs(convertList1(logs)); | |
| 82 | 82 | return respVO; |
| 83 | 83 | } |
| 84 | 84 | List<TradeAfterSaleLogRespVO> convertList1(List<TradeAfterSaleLogRespDTO> list); | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java
| ... | ... | @@ -93,6 +93,7 @@ public interface TradeOrderConvert { |
| 93 | 93 | items.forEach(item -> item.setIncrCount(-item.getIncrCount())); |
| 94 | 94 | return new ProductSkuUpdateStockReqDTO(items); |
| 95 | 95 | } |
| 96 | + | |
| 96 | 97 | List<ProductSkuUpdateStockReqDTO.Item> convertList(List<TradeOrderItemDO> list); |
| 97 | 98 | |
| 98 | 99 | @Mappings({ |
| ... | ... | @@ -151,9 +152,10 @@ public interface TradeOrderConvert { |
| 151 | 152 | TradeOrderDetailRespVO.OrderLog orderLog = new TradeOrderDetailRespVO.OrderLog(); |
| 152 | 153 | orderLog.setContent("订单操作" + i); |
| 153 | 154 | orderLog.setCreateTime(LocalDateTime.now()); |
| 155 | + orderLog.setUserType(i % 2 == 0 ? 2 : 1); | |
| 154 | 156 | orderLogs.add(orderLog); |
| 155 | 157 | } |
| 156 | - orderVO.setOrderLog(orderLogs); | |
| 158 | + orderVO.setLogs(orderLogs); | |
| 157 | 159 | return orderVO; |
| 158 | 160 | } |
| 159 | 161 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceImpl.java
| ... | ... | @@ -90,12 +90,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa |
| 90 | 90 | |
| 91 | 91 | @Override |
| 92 | 92 | public TradeAfterSaleDO getAfterSale(Long id) { |
| 93 | - TradeAfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id); | |
| 94 | - // TODO @puhui999;读不到,不要这里报错哈;交给前端报错;一般是读取信息不到,message 提示,然后 close tab; | |
| 95 | - if (afterSale == null) { | |
| 96 | - throw exception(AFTER_SALE_NOT_FOUND); | |
| 97 | - } | |
| 98 | - return afterSale; | |
| 93 | + return tradeAfterSaleMapper.selectById(id); | |
| 99 | 94 | } |
| 100 | 95 | |
| 101 | 96 | // TODO 芋艿:拼团失败,要不要发起售后的方式退款?还是走取消逻辑? | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java
| ... | ... | @@ -28,7 +28,6 @@ import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; |
| 28 | 28 | import cn.iocoder.yudao.module.promotion.api.bargain.BargainRecordApi; |
| 29 | 29 | import cn.iocoder.yudao.module.promotion.api.combination.CombinationRecordApi; |
| 30 | 30 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordRespDTO; |
| 31 | -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO; | |
| 32 | 31 | import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi; |
| 33 | 32 | import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; |
| 34 | 33 | import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; |
| ... | ... | @@ -352,8 +351,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 352 | 351 | // 1、拼团活动 |
| 353 | 352 | if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) { |
| 354 | 353 | // 更新拼团状态 TODO puhui999:订单支付失败或订单支付过期删除这条拼团记录 |
| 355 | - combinationRecordApi.updateCombinationRecordStatus(new CombinationRecordUpdateStatusReqDTO().setUserId(order.getUserId()) | |
| 356 | - .setOrderId(order.getId()).setStatus(CombinationRecordStatusEnum.IN_PROGRESS.getStatus()).setStartTime(LocalDateTime.now())); | |
| 354 | + combinationRecordApi.updateRecordStatusToInProgress(order.getUserId(), order.getId(), LocalDateTime.now()); | |
| 357 | 355 | } |
| 358 | 356 | // TODO 芋艿:发送订单变化的消息 |
| 359 | 357 | ... | ... |