Commit 384359c9d4f30e17084ddd83346de7748fd7b331
1 parent
5f918490
fix: 完善拼团、秒杀、砍价活动管理
Showing
26 changed files
with
238 additions
and
293 deletions
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java
| ... | ... | @@ -82,14 +82,20 @@ public class LocalDateTimeUtils { |
| 82 | 82 | || startTime1.isBefore(endTime2) && endTime1.isAfter(endTime2); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | + /** | |
| 86 | + * 判断时间段是否重叠 | |
| 87 | + * | |
| 88 | + * @param startTime1 开始 time1 | |
| 89 | + * @param endTime1 结束 time1 | |
| 90 | + * @param startTime2 开始 time2 | |
| 91 | + * @param endTime2 结束 time2 | |
| 92 | + * @return 重叠:true 不重叠:false | |
| 93 | + */ | |
| 85 | 94 | public static boolean isOverlap(LocalTime startTime1, LocalTime endTime1, LocalTime startTime2, LocalTime endTime2) { |
| 86 | 95 | // 日期部分使用了当前日期LocalDate.now() |
| 87 | - // TODO @puhui999:LocalDate.now() 抽一个变量,啊哈;然后注释写下;之后 4 个变量不用,直接调方法的时候,直接计算作为入参; | |
| 88 | - LocalDateTime startDateTime1 = LocalDateTime.of(LocalDate.now(), startTime1); | |
| 89 | - LocalDateTime endDateTime1 = LocalDateTime.of(LocalDate.now(), endTime1); | |
| 90 | - LocalDateTime startDateTime2 = LocalDateTime.of(LocalDate.now(), startTime2); | |
| 91 | - LocalDateTime endDateTime2 = LocalDateTime.of(LocalDate.now(), endTime2); | |
| 92 | - return LocalDateTimeUtil.isOverlap(startDateTime1, endDateTime1, startDateTime2, endDateTime2); | |
| 96 | + LocalDate nowDate = LocalDate.now(); | |
| 97 | + return LocalDateTimeUtil.isOverlap(LocalDateTime.of(nowDate, startTime1), LocalDateTime.of(nowDate, endTime1), | |
| 98 | + LocalDateTime.of(nowDate, startTime2), LocalDateTime.of(nowDate, endTime2)); | |
| 93 | 99 | } |
| 94 | 100 | |
| 95 | 101 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApi.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.api.bargain; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainRecordCreateReqDTO; | |
| 4 | + | |
| 5 | +import javax.validation.Valid; | |
| 6 | + | |
| 7 | +// TODO @芋艿:后面也再撸撸这几个接口 | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 砍价记录 API 接口 | |
| 11 | + * | |
| 12 | + * @author HUIHUI | |
| 13 | + */ | |
| 14 | +public interface BargainRecordApi { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 创建开团记录 | |
| 18 | + * | |
| 19 | + * @param reqDTO 请求 DTO | |
| 20 | + */ | |
| 21 | + void createRecord(@Valid BargainRecordCreateReqDTO reqDTO); | |
| 22 | + | |
| 23 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/dto/BargainRecordCreateReqDTO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.api.bargain.dto; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | + | |
| 5 | +import javax.validation.constraints.NotEmpty; | |
| 6 | +import javax.validation.constraints.NotNull; | |
| 7 | + | |
| 8 | +// TODO @芋艿:这块要在看看 | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 砍价记录的创建 Request DTO | |
| 12 | + * | |
| 13 | + * @author HUIHUI | |
| 14 | + */ | |
| 15 | +@Data | |
| 16 | +public class BargainRecordCreateReqDTO { | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 砍价活动编号 | |
| 20 | + */ | |
| 21 | + @NotNull(message = "砍价活动编号不能为空") | |
| 22 | + private Long activityId; | |
| 23 | + /** | |
| 24 | + * spu 编号 | |
| 25 | + */ | |
| 26 | + @NotNull(message = "spu 编号不能为空") | |
| 27 | + private Long spuId; | |
| 28 | + /** | |
| 29 | + * sku 编号 | |
| 30 | + */ | |
| 31 | + @NotNull(message = "sku 编号不能为空") | |
| 32 | + private Long skuId; | |
| 33 | + /** | |
| 34 | + * 用户编号 | |
| 35 | + */ | |
| 36 | + @NotNull(message = "用户编号不能为空") | |
| 37 | + private Long userId; | |
| 38 | + /** | |
| 39 | + * 订单编号 | |
| 40 | + */ | |
| 41 | + @NotNull(message = "订单编号不能为空") | |
| 42 | + private Long orderId; | |
| 43 | + /** | |
| 44 | + * 商品名字 | |
| 45 | + */ | |
| 46 | + @NotEmpty(message = "商品名字不能为空") | |
| 47 | + private String spuName; | |
| 48 | + /** | |
| 49 | + * 商品图片 | |
| 50 | + */ | |
| 51 | + @NotEmpty(message = "商品图片不能为空") | |
| 52 | + private String picUrl; | |
| 53 | + /** | |
| 54 | + * 砍价商品单价 | |
| 55 | + */ | |
| 56 | + @NotNull(message = "砍价底价不能为空") | |
| 57 | + private Integer bargainPrice; | |
| 58 | + /** | |
| 59 | + * 商品原价,单位分 | |
| 60 | + */ | |
| 61 | + @NotNull(message = "商品原价不能为空") | |
| 62 | + private Integer price; | |
| 63 | + /** | |
| 64 | + * 用户昵称 | |
| 65 | + */ | |
| 66 | + @NotEmpty(message = "用户昵称不能为空") | |
| 67 | + private String nickname; | |
| 68 | + /** | |
| 69 | + * 用户头像 | |
| 70 | + */ | |
| 71 | + @NotEmpty(message = "用户头像不能为空") | |
| 72 | + private String avatar; | |
| 73 | + /** | |
| 74 | + * 开团状态:进行中 砍价成功 砍价失败 | |
| 75 | + */ | |
| 76 | + @NotNull(message = "开团状态不能为空") | |
| 77 | + private Integer status; | |
| 78 | + | |
| 79 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.api.combination; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 4 | +import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateReqDTO; | |
| 4 | 5 | |
| 5 | 6 | import javax.validation.Valid; |
| 6 | 7 | |
| ... | ... | @@ -17,7 +18,7 @@ public interface CombinationRecordApi { |
| 17 | 18 | * |
| 18 | 19 | * @param reqDTO 请求 DTO |
| 19 | 20 | */ |
| 20 | - void createCombinationRecord(@Valid CombinationRecordCreateReqDTO reqDTO); | |
| 21 | + void createRecord(@Valid CombinationRecordCreateReqDTO reqDTO); | |
| 21 | 22 | |
| 22 | 23 | /** |
| 23 | 24 | * 查询拼团记录是否成功 |
| ... | ... | @@ -26,25 +27,13 @@ public interface CombinationRecordApi { |
| 26 | 27 | * @param orderId 订单编号 |
| 27 | 28 | * @return 拼团是否成功 |
| 28 | 29 | */ |
| 29 | - boolean isCombinationRecordSuccess(Long userId, Long orderId); | |
| 30 | + boolean isRecordSuccess(Long userId, Long orderId); | |
| 30 | 31 | |
| 31 | - // TODO @puhui999:updateRecordStatus 和 updateRecordStatusAndStartTime 看看后续是不是可以统一掉; | |
| 32 | 32 | /** |
| 33 | 33 | * 更新开团记录状态 |
| 34 | 34 | * |
| 35 | - * @param userId 用户编号 | |
| 36 | - * @param orderId 订单编号 | |
| 37 | - * @param status 状态值 | |
| 38 | - */ | |
| 39 | - void updateCombinationRecordStatus(Long userId, Long orderId, Integer status); | |
| 40 | - | |
| 41 | - /** | |
| 42 | - * 更新开团记录状态和开始时间 | |
| 43 | - * | |
| 44 | - * @param userId 用户编号 | |
| 45 | - * @param orderId 订单编号 | |
| 46 | - * @param status 状态值 | |
| 35 | + * @param reqDTO 请求 DTO | |
| 47 | 36 | */ |
| 48 | - void updateCombinationRecordStatusAndStartTime(Long userId, Long orderId, Integer status); | |
| 37 | + void updateRecordStatus(CombinationRecordUpdateReqDTO reqDTO); | |
| 49 | 38 | |
| 50 | 39 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateReqDTO.java
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordUpdateReqDTO.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 | +import java.time.LocalDateTime; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 拼团记录的更新 Request DTO | |
| 10 | + * | |
| 11 | + * @author HUIHUI | |
| 12 | + */ | |
| 13 | +@Data | |
| 14 | +public class CombinationRecordUpdateReqDTO { | |
| 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/combination/CombinationRecordStatusEnum.java
| ... | ... | @@ -16,10 +16,9 @@ import java.util.Arrays; |
| 16 | 16 | @Getter |
| 17 | 17 | public enum CombinationRecordStatusEnum implements IntArrayValuable { |
| 18 | 18 | |
| 19 | - WAITING(0, "未付款"), | |
| 20 | - IN_PROGRESS(1, "进行中"), | |
| 21 | - SUCCESS(2, "拼团成功"), | |
| 22 | - FAILED(3, "拼团失败"); | |
| 19 | + IN_PROGRESS(0, "进行中"), | |
| 20 | + SUCCESS(1, "拼团成功"), | |
| 21 | + FAILED(2, "拼团失败"); | |
| 23 | 22 | |
| 24 | 23 | public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CombinationRecordStatusEnum::getStatus).toArray(); |
| 25 | 24 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.api.combination; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 4 | +import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateReqDTO; | |
| 4 | 5 | import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; |
| 5 | 6 | import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; |
| 6 | 7 | import org.springframework.stereotype.Service; |
| 7 | 8 | |
| 8 | 9 | import javax.annotation.Resource; |
| 9 | -import java.time.LocalDateTime; | |
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * 拼团活动 API 实现类 |
| ... | ... | @@ -20,23 +20,22 @@ public class CombinationRecordApiImpl implements CombinationRecordApi { |
| 20 | 20 | private CombinationRecordService recordService; |
| 21 | 21 | |
| 22 | 22 | @Override |
| 23 | - public void createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { | |
| 23 | + public void createRecord(CombinationRecordCreateReqDTO reqDTO) { | |
| 24 | 24 | recordService.createCombinationRecord(reqDTO); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | @Override |
| 28 | - public boolean isCombinationRecordSuccess(Long userId, Long orderId) { | |
| 28 | + public boolean isRecordSuccess(Long userId, Long orderId) { | |
| 29 | 29 | return CombinationRecordStatusEnum.isSuccess(recordService.getCombinationRecord(userId, orderId).getStatus()); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | @Override |
| 33 | - public void updateCombinationRecordStatus(Long userId, Long orderId, Integer status) { | |
| 34 | - recordService.updateCombinationRecordStatusByUserIdAndOrderId(userId, orderId, status); | |
| 35 | - } | |
| 36 | - | |
| 37 | - @Override | |
| 38 | - public void updateCombinationRecordStatusAndStartTime(Long userId, Long orderId, Integer status) { | |
| 39 | - recordService.updateCombinationRecordStatusAndStartTimeByUserIdAndOrderId(userId, orderId, status, LocalDateTime.now()); | |
| 33 | + public void updateRecordStatus(CombinationRecordUpdateReqDTO reqDTO) { | |
| 34 | + if (null == reqDTO.getStartTime()) { | |
| 35 | + recordService.updateCombinationRecordStatusByUserIdAndOrderId(reqDTO); | |
| 36 | + } else { | |
| 37 | + recordService.updateCombinationRecordStatusAndStartTimeByUserIdAndOrderId(reqDTO); | |
| 38 | + } | |
| 40 | 39 | } |
| 41 | 40 | |
| 42 | 41 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityRespVO.java
| ... | ... | @@ -29,21 +29,8 @@ public class BargainActivityRespVO extends BargainActivityBaseVO { |
| 29 | 29 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 30 | 30 | private LocalDateTime createTime; |
| 31 | 31 | |
| 32 | - @Schema(description = "开团人数", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 33 | - @NotNull(message = "开团人数不能为空") | |
| 34 | - private Integer userSize; | |
| 35 | - | |
| 36 | - @Schema(description = "开团组数", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 37 | - @NotNull(message = "开团组数不能为空") | |
| 38 | - private Integer totalNum; | |
| 39 | - | |
| 40 | - @Schema(description = "成团组数", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 41 | - @NotNull(message = "成团组数不能为空") | |
| 42 | - private Integer successNum; | |
| 43 | - | |
| 44 | - @Schema(description = "虚拟成团", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 45 | - @NotNull(message = "虚拟成团不能为空") | |
| 46 | - private Integer virtualGroup; | |
| 32 | + @Schema(description = "砍价成功数量", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 33 | + private Integer successCount; | |
| 47 | 34 | |
| 48 | 35 | @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") |
| 49 | 36 | @NotNull(message = "活动状态不能为空") | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainAssistDO.java
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainRecordDO.java
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationRecordDO.java
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainRecordMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.dal.mysql.bargain; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 5 | 4 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; |
| 6 | 5 | import org.apache.ibatis.annotations.Mapper; |
| 7 | 6 | |
| 8 | -import java.util.List; | |
| 9 | - | |
| 10 | 7 | /** |
| 11 | 8 | * 砍价记录 Mapper |
| 12 | 9 | * |
| ... | ... | @@ -15,34 +12,4 @@ import java.util.List; |
| 15 | 12 | @Mapper |
| 16 | 13 | public interface BargainRecordMapper extends BaseMapperX<BargainRecordDO> { |
| 17 | 14 | |
| 18 | - // TODO @puhui999:selectByUserIdAndOrderId | |
| 19 | - default BargainRecordDO selectRecord(Long userId, Long orderId) { | |
| 20 | - return selectOne(BargainRecordDO::getUserId, userId, | |
| 21 | - BargainRecordDO::getOrderId, orderId); | |
| 22 | - } | |
| 23 | - | |
| 24 | - /** | |
| 25 | - * 查询砍价记录 | |
| 26 | - * | |
| 27 | - * @param headId 团长编号 | |
| 28 | - * @param activityId 活动编号 | |
| 29 | - * @return 砍价记录 | |
| 30 | - */ | |
| 31 | - default BargainRecordDO selectRecordByHeadId(Long headId, Long activityId, Integer status) { | |
| 32 | - return selectOne(new LambdaQueryWrapperX<BargainRecordDO>() | |
| 33 | - .eq(BargainRecordDO::getUserId, headId) | |
| 34 | - .eq(BargainRecordDO::getActivityId, activityId) | |
| 35 | - .eq(BargainRecordDO::getStatus, status)); | |
| 36 | - } | |
| 37 | - | |
| 38 | - default List<BargainRecordDO> selectListByHeadIdAndStatus(Long headId, Integer status) { | |
| 39 | - return selectList(new LambdaQueryWrapperX<BargainRecordDO>() | |
| 40 | - //.eq(BargainRecordDO::getHeadId, headId) | |
| 41 | - .eq(BargainRecordDO::getStatus, status)); | |
| 42 | - } | |
| 43 | - | |
| 44 | - default List<BargainRecordDO> selectListByStatus(Integer status) { | |
| 45 | - return selectList(BargainRecordDO::getStatus, status); | |
| 46 | - } | |
| 47 | - | |
| 48 | 15 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java
| ... | ... | @@ -15,8 +15,7 @@ import java.util.List; |
| 15 | 15 | @Mapper |
| 16 | 16 | public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO> { |
| 17 | 17 | |
| 18 | - // TODO @puhui999:selectByUserIdAndOrderId | |
| 19 | - default CombinationRecordDO selectRecord(Long userId, Long orderId) { | |
| 18 | + default CombinationRecordDO selectByUserIdAndOrderId(Long userId, Long orderId) { | |
| 20 | 19 | return selectOne(CombinationRecordDO::getUserId, userId, |
| 21 | 20 | CombinationRecordDO::getOrderId, orderId); |
| 22 | 21 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java
| ... | ... | @@ -49,14 +49,6 @@ public interface BargainActivityService { |
| 49 | 49 | BargainActivityDO getBargainActivity(Long id); |
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | - * 获得砍价活动列表 | |
| 53 | - * | |
| 54 | - * @param ids 编号 | |
| 55 | - * @return 砍价活动列表 | |
| 56 | - */ | |
| 57 | - List<BargainActivityDO> getBargainActivityList(Collection<Long> ids); | |
| 58 | - | |
| 59 | - /** | |
| 60 | 52 | * 获得砍价活动分页 |
| 61 | 53 | * |
| 62 | 54 | * @param pageReqVO 分页查询 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordService.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.service.bargain; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; | |
| 5 | - | |
| 6 | -import java.time.LocalDateTime; | |
| 7 | - | |
| 8 | 4 | /** |
| 9 | 5 | * 商品活动记录 service |
| 10 | 6 | * |
| ... | ... | @@ -12,40 +8,6 @@ import java.time.LocalDateTime; |
| 12 | 8 | */ |
| 13 | 9 | public interface BargainRecordService { |
| 14 | 10 | |
| 15 | - /** | |
| 16 | - * 更新砍价状态 | |
| 17 | - * | |
| 18 | - * @param userId 用户编号 | |
| 19 | - * @param orderId 订单编号 | |
| 20 | - * @param status 状态 | |
| 21 | - */ | |
| 22 | - void updateBargainRecordStatusByUserIdAndOrderId(Long userId, Long orderId, Integer status); | |
| 23 | - | |
| 24 | - ///** | |
| 25 | - // * 创建砍价记录 | |
| 26 | - // * | |
| 27 | - // * @param reqDTO 创建信息 | |
| 28 | - // */ | |
| 29 | - //void createBargainRecord(BargainRecordCreateReqDTO reqDTO); | |
| 30 | - | |
| 31 | - /** | |
| 32 | - * 更新砍价状态和开始时间 | |
| 33 | - * | |
| 34 | - * @param userId 用户编号 | |
| 35 | - * @param orderId 订单编号 | |
| 36 | - * @param status 状态 | |
| 37 | - * @param startTime 开始时间 | |
| 38 | - */ | |
| 39 | - void updateBargainRecordStatusAndStartTimeByUserIdAndOrderId(Long userId, Long orderId, | |
| 40 | - Integer status, LocalDateTime startTime); | |
| 41 | - | |
| 42 | - /** | |
| 43 | - * 获得砍价状态 | |
| 44 | - * | |
| 45 | - * @param userId 用户编号 | |
| 46 | - * @param orderId 订单编号 | |
| 47 | - * @return 砍价状态 | |
| 48 | - */ | |
| 49 | - BargainRecordDO getBargainRecord(Long userId, Long orderId); | |
| 11 | +// TODO | |
| 50 | 12 | |
| 51 | 13 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainServiceImpl.java
| ... | ... | @@ -18,7 +18,6 @@ import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product.Bar |
| 18 | 18 | import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert; |
| 19 | 19 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; |
| 20 | 20 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainProductDO; |
| 21 | -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; | |
| 22 | 21 | import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainActivityMapper; |
| 23 | 22 | import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainProductMapper; |
| 24 | 23 | import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainRecordMapper; |
| ... | ... | @@ -27,7 +26,6 @@ import org.springframework.transaction.annotation.Transactional; |
| 27 | 26 | import org.springframework.validation.annotation.Validated; |
| 28 | 27 | |
| 29 | 28 | import javax.annotation.Resource; |
| 30 | -import java.time.LocalDateTime; | |
| 31 | 29 | import java.util.Collection; |
| 32 | 30 | import java.util.List; |
| 33 | 31 | |
| ... | ... | @@ -187,11 +185,6 @@ public class BargainServiceImpl implements BargainActivityService, BargainRecord |
| 187 | 185 | } |
| 188 | 186 | |
| 189 | 187 | @Override |
| 190 | - public List<BargainActivityDO> getBargainActivityList(Collection<Long> ids) { | |
| 191 | - return bargainActivityMapper.selectBatchIds(ids); | |
| 192 | - } | |
| 193 | - | |
| 194 | - @Override | |
| 195 | 188 | public PageResult<BargainActivityDO> getBargainActivityPage(BargainActivityPageReqVO pageReqVO) { |
| 196 | 189 | return bargainActivityMapper.selectPage(pageReqVO); |
| 197 | 190 | } |
| ... | ... | @@ -201,93 +194,4 @@ public class BargainServiceImpl implements BargainActivityService, BargainRecord |
| 201 | 194 | return bargainProductMapper.selectListByActivityIds(ids); |
| 202 | 195 | } |
| 203 | 196 | |
| 204 | - @Override | |
| 205 | - public void updateBargainRecordStatusByUserIdAndOrderId(Long userId, Long orderId, Integer status) { | |
| 206 | - // 校验砍价是否存在 | |
| 207 | - // 更新状态 | |
| 208 | - recordMapper.updateById(validateBargainRecord(userId, orderId).setStatus(status)); | |
| 209 | - } | |
| 210 | - | |
| 211 | - @Override | |
| 212 | - @Transactional(rollbackFor = Exception.class) | |
| 213 | - public void updateBargainRecordStatusAndStartTimeByUserIdAndOrderId(Long userId, Long orderId, Integer status, LocalDateTime startTime) { | |
| 214 | - BargainRecordDO recordDO = validateBargainRecord(userId, orderId); | |
| 215 | - // 更新状态 | |
| 216 | - recordDO.setStatus(status); | |
| 217 | - // 更新开始时间 | |
| 218 | - //recordDO.setStartTime(startTime); | |
| 219 | - //recordMapper.updateById(recordDO); | |
| 220 | - // | |
| 221 | - //// 更新砍价参入人数 | |
| 222 | - //List<BargainRecordDO> recordDOs = recordMapper.selectListByHeadIdAndStatus(recordDO.getHeadId(), status); | |
| 223 | - //if (CollUtil.isNotEmpty(recordDOs)) { | |
| 224 | - // recordDOs.forEach(item -> { | |
| 225 | - // item.setUserCount(recordDOs.size()); | |
| 226 | - // // 校验砍价是否满足要求 | |
| 227 | - // if (ObjectUtil.equal(recordDOs.size(), recordDO.getUserSize())) { | |
| 228 | - // item.setStatus(BargainRecordStatusEnum.SUCCESS.getStatus()); | |
| 229 | - // } | |
| 230 | - // }); | |
| 231 | - //} | |
| 232 | - //recordMapper.updateBatch(recordDOs); | |
| 233 | - } | |
| 234 | - | |
| 235 | - private BargainRecordDO validateBargainRecord(Long userId, Long orderId) { | |
| 236 | - // 校验砍价是否存在 | |
| 237 | - BargainRecordDO recordDO = recordMapper.selectRecord(userId, orderId); | |
| 238 | - if (recordDO == null) { | |
| 239 | - throw exception(BARGAIN_RECORD_NOT_EXISTS); | |
| 240 | - } | |
| 241 | - return recordDO; | |
| 242 | - } | |
| 243 | - | |
| 244 | - //@Override | |
| 245 | - //public void createBargainRecord(BargainRecordCreateReqDTO reqDTO) { | |
| 246 | - // // 1.1 校验砍价活动 | |
| 247 | - // BargainActivityDO activity = validateBargainActivityExists(reqDTO.getActivityId()); | |
| 248 | - // // 1.2 需要校验下,他当前是不是已经参加了该砍价; | |
| 249 | - // BargainRecordDO recordDO = recordMapper.selectRecord(reqDTO.getUserId(), reqDTO.getOrderId()); | |
| 250 | - // if (recordDO != null) { | |
| 251 | - // throw exception(BARGAIN_RECORD_EXISTS); | |
| 252 | - // } | |
| 253 | - // // 1.3 父砍价是否存在,是否已经满了 | |
| 254 | - // if (reqDTO.getHeadId() != null) { | |
| 255 | - // BargainRecordDO recordDO1 = recordMapper.selectRecordByHeadId(reqDTO.getHeadId(), reqDTO.getActivityId(), BargainRecordStatusEnum.IN_PROGRESS.getStatus()); | |
| 256 | - // if (recordDO1 == null) { | |
| 257 | - // throw exception(BARGAIN_RECORD_HEAD_NOT_EXISTS); | |
| 258 | - // } | |
| 259 | - // // 校验砍价是否满足要求 | |
| 260 | - // if (ObjectUtil.equal(recordDO1.getUserCount(), recordDO1.getUserSize())) { | |
| 261 | - // throw exception(BARGAIN_RECORD_USER_FULL); | |
| 262 | - // } | |
| 263 | - // } | |
| 264 | - // // TODO @puhui999:应该还有一些校验,后续补噶;例如说,一个团,自己已经参与进去了,不能再参与进去; | |
| 265 | - // | |
| 266 | - // // 2. 创建砍价记录 | |
| 267 | - // BargainRecordDO record = BargainActivityConvert.INSTANCE.convert(reqDTO); | |
| 268 | - // if (reqDTO.getHeadId() == null) { | |
| 269 | - // // TODO @puhui999:不是自己呀;headId 是父团长的 BargainRecordDO.id 哈 | |
| 270 | - // record.setHeadId(reqDTO.getUserId()); | |
| 271 | - // } | |
| 272 | - // record.setVirtualGroup(false); | |
| 273 | - // // TODO @puhui999:过期时间,应该是 Date 哈; | |
| 274 | - // record.setExpireTime(activity.getLimitDuration()); | |
| 275 | - // record.setUserSize(activity.getUserSize()); | |
| 276 | - // recordMapper.insert(record); | |
| 277 | - //} | |
| 278 | - | |
| 279 | - @Override | |
| 280 | - public BargainRecordDO getBargainRecord(Long userId, Long orderId) { | |
| 281 | - return validateBargainRecord(userId, orderId); | |
| 282 | - } | |
| 283 | - | |
| 284 | - /** | |
| 285 | - * APP 端获取开团记录 | |
| 286 | - * | |
| 287 | - * @return 开团记录 | |
| 288 | - */ | |
| 289 | - public List<BargainRecordDO> getRecordListByStatus(Integer status) { | |
| 290 | - return recordMapper.selectListByStatus(status); | |
| 291 | - } | |
| 292 | - | |
| 293 | 197 | } | ... | ... |
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.CombinationRecordUpdateReqDTO; | |
| 4 | 5 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; |
| 5 | 6 | |
| 6 | -import java.time.LocalDateTime; | |
| 7 | - | |
| 8 | 7 | /** |
| 9 | 8 | * 商品活动记录 service |
| 10 | 9 | * |
| ... | ... | @@ -15,11 +14,9 @@ public interface CombinationRecordService { |
| 15 | 14 | /** |
| 16 | 15 | * 更新拼团状态 |
| 17 | 16 | * |
| 18 | - * @param userId 用户编号 | |
| 19 | - * @param orderId 订单编号 | |
| 20 | - * @param status 状态 | |
| 17 | + * @param reqDTO 请求 DTO | |
| 21 | 18 | */ |
| 22 | - void updateCombinationRecordStatusByUserIdAndOrderId(Long userId, Long orderId, Integer status); | |
| 19 | + void updateCombinationRecordStatusByUserIdAndOrderId(CombinationRecordUpdateReqDTO reqDTO); | |
| 23 | 20 | |
| 24 | 21 | /** |
| 25 | 22 | * 创建拼团记录 |
| ... | ... | @@ -31,13 +28,9 @@ public interface CombinationRecordService { |
| 31 | 28 | /** |
| 32 | 29 | * 更新拼团状态和开始时间 |
| 33 | 30 | * |
| 34 | - * @param userId 用户编号 | |
| 35 | - * @param orderId 订单编号 | |
| 36 | - * @param status 状态 | |
| 37 | - * @param startTime 开始时间 | |
| 31 | + * @param reqDTO 请求 DTO | |
| 38 | 32 | */ |
| 39 | - void updateCombinationRecordStatusAndStartTimeByUserIdAndOrderId(Long userId, Long orderId, | |
| 40 | - Integer status, LocalDateTime startTime); | |
| 33 | + void updateCombinationRecordStatusAndStartTimeByUserIdAndOrderId(CombinationRecordUpdateReqDTO reqDTO); | |
| 41 | 34 | |
| 42 | 35 | /** |
| 43 | 36 | * 获得拼团状态 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationServiceImpl.java
| ... | ... | @@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; |
| 11 | 11 | import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; |
| 12 | 12 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; |
| 13 | 13 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 14 | +import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateReqDTO; | |
| 14 | 15 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO; |
| 15 | 16 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageReqVO; |
| 16 | 17 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO; |
| ... | ... | @@ -29,7 +30,6 @@ import org.springframework.transaction.annotation.Transactional; |
| 29 | 30 | import org.springframework.validation.annotation.Validated; |
| 30 | 31 | |
| 31 | 32 | import javax.annotation.Resource; |
| 32 | -import java.time.LocalDateTime; | |
| 33 | 33 | import java.util.Collection; |
| 34 | 34 | import java.util.List; |
| 35 | 35 | |
| ... | ... | @@ -204,27 +204,27 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | @Override |
| 207 | - public void updateCombinationRecordStatusByUserIdAndOrderId(Long userId, Long orderId, Integer status) { | |
| 207 | + public void updateCombinationRecordStatusByUserIdAndOrderId(CombinationRecordUpdateReqDTO reqDTO) { | |
| 208 | 208 | // 校验拼团是否存在 |
| 209 | - CombinationRecordDO recordDO = validateCombinationRecord(userId, orderId); | |
| 209 | + CombinationRecordDO recordDO = validateCombinationRecord(reqDTO.getUserId(), reqDTO.getOrderId()); | |
| 210 | 210 | |
| 211 | 211 | // 更新状态 |
| 212 | - recordDO.setStatus(status); | |
| 212 | + recordDO.setStatus(reqDTO.getStatus()); | |
| 213 | 213 | recordMapper.updateById(recordDO); |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | @Override |
| 217 | 217 | @Transactional(rollbackFor = Exception.class) |
| 218 | - public void updateCombinationRecordStatusAndStartTimeByUserIdAndOrderId(Long userId, Long orderId, Integer status, LocalDateTime startTime) { | |
| 219 | - CombinationRecordDO recordDO = validateCombinationRecord(userId, orderId); | |
| 218 | + public void updateCombinationRecordStatusAndStartTimeByUserIdAndOrderId(CombinationRecordUpdateReqDTO reqDTO) { | |
| 219 | + CombinationRecordDO recordDO = validateCombinationRecord(reqDTO.getUserId(), reqDTO.getOrderId()); | |
| 220 | 220 | // 更新状态 |
| 221 | - recordDO.setStatus(status); | |
| 221 | + recordDO.setStatus(reqDTO.getStatus()); | |
| 222 | 222 | // 更新开始时间 |
| 223 | - recordDO.setStartTime(startTime); | |
| 223 | + recordDO.setStartTime(reqDTO.getStartTime()); | |
| 224 | 224 | recordMapper.updateById(recordDO); |
| 225 | 225 | |
| 226 | 226 | // 更新拼团参入人数 |
| 227 | - List<CombinationRecordDO> recordDOs = recordMapper.selectListByHeadIdAndStatus(recordDO.getHeadId(), status); | |
| 227 | + List<CombinationRecordDO> recordDOs = recordMapper.selectListByHeadIdAndStatus(recordDO.getHeadId(), reqDTO.getStatus()); | |
| 228 | 228 | if (CollUtil.isNotEmpty(recordDOs)) { |
| 229 | 229 | recordDOs.forEach(item -> { |
| 230 | 230 | item.setUserCount(recordDOs.size()); |
| ... | ... | @@ -239,7 +239,7 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi |
| 239 | 239 | |
| 240 | 240 | private CombinationRecordDO validateCombinationRecord(Long userId, Long orderId) { |
| 241 | 241 | // 校验拼团是否存在 |
| 242 | - CombinationRecordDO recordDO = recordMapper.selectRecord(userId, orderId); | |
| 242 | + CombinationRecordDO recordDO = recordMapper.selectByUserIdAndOrderId(userId, orderId); | |
| 243 | 243 | if (recordDO == null) { |
| 244 | 244 | throw exception(COMBINATION_RECORD_NOT_EXISTS); |
| 245 | 245 | } |
| ... | ... | @@ -251,7 +251,7 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi |
| 251 | 251 | // 1.1 校验拼团活动 |
| 252 | 252 | CombinationActivityDO activity = validateCombinationActivityExists(reqDTO.getActivityId()); |
| 253 | 253 | // 1.2 需要校验下,他当前是不是已经参加了该拼团; |
| 254 | - CombinationRecordDO recordDO = recordMapper.selectRecord(reqDTO.getUserId(), reqDTO.getOrderId()); | |
| 254 | + CombinationRecordDO recordDO = recordMapper.selectByUserIdAndOrderId(reqDTO.getUserId(), reqDTO.getOrderId()); | |
| 255 | 255 | if (recordDO != null) { |
| 256 | 256 | throw exception(COMBINATION_RECORD_EXISTS); |
| 257 | 257 | } |
| ... | ... | @@ -270,10 +270,6 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi |
| 270 | 270 | |
| 271 | 271 | // 2. 创建拼团记录 |
| 272 | 272 | CombinationRecordDO record = CombinationActivityConvert.INSTANCE.convert(reqDTO); |
| 273 | - if (reqDTO.getHeadId() == null) { | |
| 274 | - // TODO @puhui999:不是自己呀;headId 是父团长的 CombinationRecordDO.id 哈 | |
| 275 | - record.setHeadId(reqDTO.getUserId()); | |
| 276 | - } | |
| 277 | 273 | record.setVirtualGroup(false); |
| 278 | 274 | // TODO @puhui999:过期时间,应该是 Date 哈; |
| 279 | 275 | record.setExpireTime(activity.getLimitDuration()); | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java
| ... | ... | @@ -62,6 +62,7 @@ public interface ErrorCodeConstants { |
| 62 | 62 | ErrorCode EXPRESS_NOT_EXISTS = new ErrorCode(1011004000, "快递公司不存在"); |
| 63 | 63 | ErrorCode EXPRESS_CODE_DUPLICATE = new ErrorCode(1011004001, "已经存在该编码的快递公司"); |
| 64 | 64 | ErrorCode EXPRESS_CLIENT_NOT_PROVIDE = new ErrorCode(1011004002, "需要接入快递服务商,比如【快递100】"); |
| 65 | + ErrorCode EXPRESS_STATUS_NOT_ENABLE = new ErrorCode(1011004003, "快递公司未启用"); | |
| 65 | 66 | |
| 66 | 67 | ErrorCode EXPRESS_API_QUERY_ERROR = new ErrorCode(1011004101, "快递查询接口异常"); |
| 67 | 68 | ErrorCode EXPRESS_API_QUERY_FAILED = new ErrorCode(1011004102, "快递查询返回失败,原因:{}"); | ... | ... |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationActivityApi.java renamed to yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java
| 1 | -package cn.iocoder.yudao.module.promotion.api.combination; | |
| 1 | +package cn.iocoder.yudao.module.trade.enums; | |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * 拼团活动 API 接口 | |
| 4 | + * 通知模板枚举类 | |
| 5 | 5 | * |
| 6 | 6 | * @author HUIHUI |
| 7 | 7 | */ |
| 8 | -public interface CombinationActivityApi { | |
| 8 | +public interface MessageTemplateConstants { | |
| 9 | + | |
| 10 | + String ORDER_DELIVERY = "order_delivery"; // 短信模版编号 | |
| 9 | 11 | |
| 10 | 12 | } | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/notify/TradeNotifyEnums.java
0 → 100644
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageService.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.service.message; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.trade.service.message.dto.TradeOrderMessageWhenDeliveryOrderReqDTO; | |
| 3 | +import cn.iocoder.yudao.module.trade.service.message.bo.TradeOrderMessageWhenDeliveryOrderReqBO; | |
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Trade 消息 service 接口 |
| ... | ... | @@ -10,10 +10,10 @@ import cn.iocoder.yudao.module.trade.service.message.dto.TradeOrderMessageWhenDe |
| 10 | 10 | public interface TradeMessageService { |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * 订单发货时发送消息 | |
| 13 | + * 订单发货时发送通知 | |
| 14 | 14 | * |
| 15 | - * @param reqDTO 发送消息 | |
| 15 | + * @param reqBO 发送消息 | |
| 16 | 16 | */ |
| 17 | - void sendMessageWhenDeliveryOrder(TradeOrderMessageWhenDeliveryOrderReqDTO reqDTO); | |
| 17 | + void sendMessageWhenDeliveryOrder(TradeOrderMessageWhenDeliveryOrderReqBO reqBO); | |
| 18 | 18 | |
| 19 | 19 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageServiceImpl.java
| ... | ... | @@ -2,7 +2,8 @@ package cn.iocoder.yudao.module.trade.service.message; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; |
| 4 | 4 | import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; |
| 5 | -import cn.iocoder.yudao.module.trade.service.message.dto.TradeOrderMessageWhenDeliveryOrderReqDTO; | |
| 5 | +import cn.iocoder.yudao.module.trade.enums.MessageTemplateConstants; | |
| 6 | +import cn.iocoder.yudao.module.trade.service.message.bo.TradeOrderMessageWhenDeliveryOrderReqBO; | |
| 6 | 7 | import org.springframework.stereotype.Service; |
| 7 | 8 | import org.springframework.validation.annotation.Validated; |
| 8 | 9 | |
| ... | ... | @@ -23,18 +24,16 @@ public class TradeMessageServiceImpl implements TradeMessageService { |
| 23 | 24 | private NotifyMessageSendApi notifyMessageSendApi; |
| 24 | 25 | |
| 25 | 26 | @Override |
| 26 | - public void sendMessageWhenDeliveryOrder(TradeOrderMessageWhenDeliveryOrderReqDTO reqDTO) { | |
| 27 | + public void sendMessageWhenDeliveryOrder(TradeOrderMessageWhenDeliveryOrderReqBO reqBO) { | |
| 27 | 28 | // 1、构造消息 |
| 28 | - Map<String, Object> msgMap = new HashMap<>(); | |
| 29 | - msgMap.put("orderId", reqDTO.getOrderId()); | |
| 30 | - // TODO puhui999:应该不是 msg 哇,应该是涉及到的模版参数哈;msg 太大了 | |
| 31 | - msgMap.put("msg", reqDTO.getMessage()); | |
| 29 | + Map<String, Object> msgMap = new HashMap<>(2); | |
| 30 | + msgMap.put("orderId", reqBO.getOrderId()); | |
| 31 | + msgMap.put("deliveryMessage", reqBO.getMessage()); | |
| 32 | 32 | // 2、发送站内信 |
| 33 | 33 | notifyMessageSendApi.sendSingleMessageToMember( |
| 34 | 34 | new NotifySendSingleToUserReqDTO() |
| 35 | - .setUserId(reqDTO.getUserId()) | |
| 36 | - // TODO puhui999:短信模版编号,枚举起来; | |
| 37 | - .setTemplateCode("order_delivery") | |
| 35 | + .setUserId(reqBO.getUserId()) | |
| 36 | + .setTemplateCode(MessageTemplateConstants.ORDER_DELIVERY) | |
| 38 | 37 | .setTemplateParams(msgMap)); |
| 39 | 38 | } |
| 40 | 39 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/dto/TradeOrderMessageWhenDeliveryOrderReqDTO.java renamed to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/bo/TradeOrderMessageWhenDeliveryOrderReqBO.java
| 1 | -package cn.iocoder.yudao.module.trade.service.message.dto; | |
| 1 | +package cn.iocoder.yudao.module.trade.service.message.bo; | |
| 2 | 2 | |
| 3 | 3 | import lombok.Data; |
| 4 | 4 | |
| 5 | 5 | import javax.validation.constraints.NotEmpty; |
| 6 | 6 | import javax.validation.constraints.NotNull; |
| 7 | 7 | |
| 8 | -// TODO @puhui999:改成 ReqBO 哈;包名也换了;service 我们还是同一用 bo 对象 | |
| 9 | 8 | /** |
| 10 | - * 订单发货时 Req DTO | |
| 9 | + * 订单发货时通知创建 Req BO | |
| 11 | 10 | * |
| 12 | 11 | * @author HUIHUI |
| 13 | 12 | */ |
| 14 | 13 | @Data |
| 15 | -public class TradeOrderMessageWhenDeliveryOrderReqDTO { | |
| 14 | +public class TradeOrderMessageWhenDeliveryOrderReqBO { | |
| 16 | 15 | |
| 17 | 16 | /** |
| 18 | 17 | * 订单编号 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java
| ... | ... | @@ -5,6 +5,7 @@ import cn.hutool.core.lang.Assert; |
| 5 | 5 | import cn.hutool.core.util.IdUtil; |
| 6 | 6 | import cn.hutool.core.util.StrUtil; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.core.KeyValue; |
| 8 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 8 | 9 | import cn.iocoder.yudao.framework.common.enums.TerminalEnum; |
| 9 | 10 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 10 | 11 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| ... | ... | @@ -21,6 +22,7 @@ import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDT |
| 21 | 22 | import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; |
| 22 | 23 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; |
| 23 | 24 | import cn.iocoder.yudao.module.promotion.api.combination.CombinationRecordApi; |
| 25 | +import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateReqDTO; | |
| 24 | 26 | import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi; |
| 25 | 27 | import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; |
| 26 | 28 | import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; |
| ... | ... | @@ -45,7 +47,7 @@ import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties |
| 45 | 47 | import cn.iocoder.yudao.module.trade.service.cart.TradeCartService; |
| 46 | 48 | import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; |
| 47 | 49 | import cn.iocoder.yudao.module.trade.service.message.TradeMessageService; |
| 48 | -import cn.iocoder.yudao.module.trade.service.message.dto.TradeOrderMessageWhenDeliveryOrderReqDTO; | |
| 50 | +import cn.iocoder.yudao.module.trade.service.message.bo.TradeOrderMessageWhenDeliveryOrderReqBO; | |
| 49 | 51 | import cn.iocoder.yudao.module.trade.service.price.TradePriceService; |
| 50 | 52 | import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; |
| 51 | 53 | import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; |
| ... | ... | @@ -173,9 +175,7 @@ public class TradeOrderServiceImpl implements TradeOrderService { |
| 173 | 175 | if (equal(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) { |
| 174 | 176 | MemberUserRespDTO user = memberUserApi.getUser(userId); |
| 175 | 177 | // TODO 拼团一次应该只能选择一种规格的商品 |
| 176 | - // TODO @puhui999:应该是前置校验哈;然后不应该设置状态,而是交给拼团记录那处理; | |
| 177 | - combinationRecordApi.createCombinationRecord(TradeOrderConvert.INSTANCE.convert(order, orderItems.get(0), createReqVO, user) | |
| 178 | - .setStatus(CombinationRecordStatusEnum.WAITING.getStatus())); | |
| 178 | + combinationRecordApi.createRecord(TradeOrderConvert.INSTANCE.convert(order, orderItems.get(0), createReqVO, user)); | |
| 179 | 179 | } |
| 180 | 180 | // TODO 秒杀扣减库存是下单就扣除还是等待订单支付成功再扣除 |
| 181 | 181 | if (equal(TradeOrderTypeEnum.SECKILL.getType(), order.getType())) { |
| ... | ... | @@ -311,7 +311,8 @@ public class TradeOrderServiceImpl implements TradeOrderService { |
| 311 | 311 | // 1、拼团活动 |
| 312 | 312 | if (equal(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) { |
| 313 | 313 | // 更新拼团状态 TODO puhui999:订单支付失败或订单支付过期删除这条拼团记录 |
| 314 | - combinationRecordApi.updateCombinationRecordStatusAndStartTime(order.getUserId(), order.getId(), CombinationRecordStatusEnum.IN_PROGRESS.getStatus()); | |
| 314 | + combinationRecordApi.updateRecordStatus(new CombinationRecordUpdateReqDTO().setUserId(order.getUserId()) | |
| 315 | + .setOrderId(order.getId()).setStatus(CombinationRecordStatusEnum.IN_PROGRESS.getStatus()).setStartTime(LocalDateTime.now())); | |
| 315 | 316 | } |
| 316 | 317 | // TODO 芋艿:发送订单变化的消息 |
| 317 | 318 | |
| ... | ... | @@ -394,11 +395,7 @@ public class TradeOrderServiceImpl implements TradeOrderService { |
| 394 | 395 | // 2.1 快递发货 |
| 395 | 396 | if (equal(deliveryReqVO.getType(), DeliveryTypeEnum.EXPRESS.getMode())) { |
| 396 | 397 | // 校验快递公司 |
| 397 | - // TODO @puhui999:getDeliveryExpress 直接封装一个校验的,会不会好点;因为还有开启关闭啥的; | |
| 398 | - DeliveryExpressDO deliveryExpress = deliveryExpressService.getDeliveryExpress(deliveryReqVO.getLogisticsId()); | |
| 399 | - if (deliveryExpress == null) { | |
| 400 | - throw exception(EXPRESS_NOT_EXISTS); | |
| 401 | - } | |
| 398 | + validateDeliveryExpress(deliveryReqVO); | |
| 402 | 399 | updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()); |
| 403 | 400 | } |
| 404 | 401 | // 2.2 用户自提 |
| ... | ... | @@ -425,13 +422,23 @@ public class TradeOrderServiceImpl implements TradeOrderService { |
| 425 | 422 | // TODO 芋艿:发送订单变化的消息 |
| 426 | 423 | |
| 427 | 424 | // 发送站内信 |
| 428 | - tradeMessageService.sendMessageWhenDeliveryOrder(new TradeOrderMessageWhenDeliveryOrderReqDTO().setOrderId(order.getId()) | |
| 425 | + tradeMessageService.sendMessageWhenDeliveryOrder(new TradeOrderMessageWhenDeliveryOrderReqBO().setOrderId(order.getId()) | |
| 429 | 426 | .setUserId(userId).setMessage(TradeOrderDeliveryStatusEnum.DELIVERED.getName())); |
| 430 | 427 | |
| 431 | 428 | // TODO 芋艿:OrderLog |
| 432 | 429 | // TODO 设计:lili:是不是发货后,才支持售后? |
| 433 | 430 | } |
| 434 | 431 | |
| 432 | + private void validateDeliveryExpress(TradeOrderDeliveryReqVO deliveryReqVO) { | |
| 433 | + DeliveryExpressDO deliveryExpress = deliveryExpressService.getDeliveryExpress(deliveryReqVO.getLogisticsId()); | |
| 434 | + if (deliveryExpress == null) { | |
| 435 | + throw exception(EXPRESS_NOT_EXISTS); | |
| 436 | + } | |
| 437 | + if (deliveryExpress.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { | |
| 438 | + throw exception(EXPRESS_STATUS_NOT_ENABLE); | |
| 439 | + } | |
| 440 | + } | |
| 441 | + | |
| 435 | 442 | /** |
| 436 | 443 | * 校验交易订单满足被发货的条件 |
| 437 | 444 | * |
| ... | ... | @@ -458,8 +465,7 @@ public class TradeOrderServiceImpl implements TradeOrderService { |
| 458 | 465 | // 订单类型:拼团 |
| 459 | 466 | if (equal(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) { |
| 460 | 467 | // 校验订单拼团是否成功 |
| 461 | - // TODO 用户 ID 使用当前登录用户的还是订单保存的? | |
| 462 | - if (combinationRecordApi.isCombinationRecordSuccess(order.getUserId(), order.getId())) { | |
| 468 | + if (combinationRecordApi.isRecordSuccess(order.getUserId(), order.getId())) { | |
| 463 | 469 | throw exception(ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS); |
| 464 | 470 | } |
| 465 | 471 | } | ... | ... |