From ba59ec85e045e37af1b6ab4044d30634f8535901 Mon Sep 17 00:00:00 2001 From: "zhijiantianya@gmail.com" Date: Mon, 7 Aug 2023 19:30:26 +0800 Subject: [PATCH] =?UTF-8?q?code=20review=20=E5=90=84=E7=A7=8D=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/util/date/LocalDateTimeUtils.java | 21 -------- .../dto/BargainRecordCreateReqDTO.java | 2 + .../api/combination/CombinationRecordApi.java | 10 ++-- ... CombinationRecordUpdateStatusReqDTO.java} | 4 +- .../promotion/enums/ErrorCodeConstants.java | 3 ++ .../combination/CombinationRecordApiImpl.java | 8 +-- .../vo/activity/BargainActivityRespVO.java | 2 + .../vo/product/BargainProductCreateReqVO.java | 1 + .../vo/product/BargainProductPageReqVO.java | 47 ------------------ .../bargain/BargainActivityConvert.java | 3 +- .../CombinationActivityConvert.java | 1 + .../SeckillActivityConvert.java | 1 + .../dataobject/bargain/BargainAssistDO.java | 2 +- .../mysql/bargain/BargainProductMapper.java | 15 ------ .../combination/CombinationRecordMapper.java | 1 + .../combination/CombinationRecordService.java | 6 +-- .../combination/CombinationServiceImpl.java | 37 +++++++------- .../SeckillActivityServiceImpl.java | 31 ++++++------ .../trade/enums/MessageTemplateConstants.java | 1 + .../trade/enums/notify/TradeNotifyEnums.java | 1 + .../message/TradeMessageServiceImpl.java | 1 + .../service/order/TradeOrderServiceImpl.java | 49 +++++++++---------- .../service/notify/PayNotifyServiceImpl.java | 1 + 23 files changed, 87 insertions(+), 161 deletions(-) rename yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/{CombinationRecordUpdateReqDTO.java => CombinationRecordUpdateStatusReqDTO.java} (87%) delete mode 100644 yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/product/BargainProductPageReqVO.java diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java index 1497f217d..feca25411 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java @@ -62,26 +62,6 @@ public class LocalDateTimeUtils { return LocalDateTimeUtil.isIn(LocalDateTime.now(), startTime, endTime); } - /** - * 检查时间重叠 不包含日期 - * - * @param startTime1 需要校验的开始时间 - * @param endTime1 需要校验的结束时间 - * @param startTime2 校验所需的开始时间 - * @param endTime2 校验所需的结束时间 - * @return 是否重叠 - */ - @Deprecated - public static boolean checkTimeOverlap(LocalTime startTime1, LocalTime endTime1, LocalTime startTime2, LocalTime endTime2) { - // 判断时间是否重叠 - // 开始时间在已配置时段的结束时间之前 且 结束时间在已配置时段的开始时间之后 [] - return startTime1.isBefore(endTime2) && endTime1.isAfter(startTime2) - // 开始时间在已配置时段的开始时间之前 且 结束时间在已配置时段的开始时间之后 (] 或 () - || startTime1.isBefore(startTime2) && endTime1.isAfter(startTime2) - // 开始时间在已配置时段的结束时间之前 且 结束时间在已配值时段的结束时间之后 [) 或 () - || startTime1.isBefore(endTime2) && endTime1.isAfter(endTime2); - } - /** * 判断时间段是否重叠 * @@ -92,7 +72,6 @@ public class LocalDateTimeUtils { * @return 重叠:true 不重叠:false */ public static boolean isOverlap(LocalTime startTime1, LocalTime endTime1, LocalTime startTime2, LocalTime endTime2) { - // 日期部分使用了当前日期LocalDate.now() LocalDate nowDate = LocalDate.now(); return LocalDateTimeUtil.isOverlap(LocalDateTime.of(nowDate, startTime1), LocalDateTime.of(nowDate, endTime1), LocalDateTime.of(nowDate, startTime2), LocalDateTime.of(nowDate, endTime2)); diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/dto/BargainRecordCreateReqDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/dto/BargainRecordCreateReqDTO.java index 1778f5d08..22ef80a1e 100644 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/dto/BargainRecordCreateReqDTO.java +++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/dto/BargainRecordCreateReqDTO.java @@ -40,6 +40,7 @@ public class BargainRecordCreateReqDTO { */ @NotNull(message = "订单编号不能为空") private Long orderId; + // TODO @puhui999:spuName、picUrl、 之类字段不用传递; /** * 商品名字 */ @@ -60,6 +61,7 @@ public class BargainRecordCreateReqDTO { */ @NotNull(message = "商品原价不能为空") private Integer price; + // TODO @puhui999:nickname、avatar 不用传递,去查询; /** * 用户昵称 */ diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java index 619fde6ef..2a83ed984 100644 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java +++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.promotion.api.combination; import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateReqDTO; +import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO; import javax.validation.Valid; @@ -18,7 +18,7 @@ public interface CombinationRecordApi { * * @param reqDTO 请求 DTO */ - void createRecord(@Valid CombinationRecordCreateReqDTO reqDTO); + void createCombinationRecord(@Valid CombinationRecordCreateReqDTO reqDTO); /** * 查询拼团记录是否成功 @@ -27,13 +27,15 @@ public interface CombinationRecordApi { * @param orderId 订单编号 * @return 拼团是否成功 */ - boolean isRecordSuccess(Long userId, Long orderId); + boolean isCombinationRecordSuccess(Long userId, Long orderId); + + // TODO @puhui999:是不是搞成具体的方法,拼团成功,拼团失败,这种方法; /** * 更新开团记录状态 * * @param reqDTO 请求 DTO */ - void updateRecordStatus(CombinationRecordUpdateReqDTO reqDTO); + void updateCombinationRecordStatus(CombinationRecordUpdateStatusReqDTO reqDTO); } diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordUpdateReqDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordUpdateStatusReqDTO.java similarity index 87% rename from yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordUpdateReqDTO.java rename to yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordUpdateStatusReqDTO.java index 7abfd7aa9..3ba49ff36 100644 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordUpdateReqDTO.java +++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordUpdateStatusReqDTO.java @@ -6,12 +6,12 @@ import javax.validation.constraints.NotNull; import java.time.LocalDateTime; /** - * 拼团记录的更新 Request DTO + * 拼团记录的更新状态 Request DTO * * @author HUIHUI */ @Data -public class CombinationRecordUpdateReqDTO { +public class CombinationRecordUpdateStatusReqDTO { /** * 用户编号 diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java index 0e8a0e752..e2f2bb98c 100644 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java +++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java @@ -74,6 +74,9 @@ public interface ErrorCodeConstants { ErrorCode BARGAIN_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1013011001, "存在商品参加了其它砍价活动"); ErrorCode BARGAIN_ACTIVITY_STATUS_DISABLE = new ErrorCode(1013011002, "砍价活动已关闭不能修改"); ErrorCode BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1013011003, "砍价活动未关闭或未结束,不能删除"); + + // TODO @puhui999:拆分成砍价记录 + ErrorCode BARGAIN_RECORD_NOT_EXISTS = new ErrorCode(1013011004, "砍价不存在"); ErrorCode BARGAIN_RECORD_EXISTS = new ErrorCode(1013011005, "砍价失败,已参与过该砍价"); ErrorCode BARGAIN_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1013011006, "砍价失败,父砍价不存在"); diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java index a31abf8c3..b21f7bee9 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.promotion.api.combination; import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateReqDTO; +import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO; import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; import org.springframework.stereotype.Service; @@ -20,17 +20,17 @@ public class CombinationRecordApiImpl implements CombinationRecordApi { private CombinationRecordService recordService; @Override - public void createRecord(CombinationRecordCreateReqDTO reqDTO) { + public void createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { recordService.createCombinationRecord(reqDTO); } @Override - public boolean isRecordSuccess(Long userId, Long orderId) { + public boolean isCombinationRecordSuccess(Long userId, Long orderId) { return CombinationRecordStatusEnum.isSuccess(recordService.getCombinationRecord(userId, orderId).getStatus()); } @Override - public void updateRecordStatus(CombinationRecordUpdateReqDTO reqDTO) { + public void updateCombinationRecordStatus(CombinationRecordUpdateStatusReqDTO reqDTO) { if (null == reqDTO.getStartTime()) { recordService.updateCombinationRecordStatusByUserIdAndOrderId(reqDTO); } else { diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityRespVO.java index 2253e05a8..064e4e8ac 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityRespVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityRespVO.java @@ -17,6 +17,8 @@ import java.util.List; @ToString(callSuper = true) public class BargainActivityRespVO extends BargainActivityBaseVO { + // TODO @puhui999:example 补全 + @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618大促") private String spuName; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/product/BargainProductCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/product/BargainProductCreateReqVO.java index da3575bea..9b14b1765 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/product/BargainProductCreateReqVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/product/BargainProductCreateReqVO.java @@ -5,6 +5,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; +// TODO @puhui999:是不是应该把 BargainProductCreateReqVO 和 BargainProductUpdateReqVO 合并在一起哈。就是一个 SaveReqVO @Schema(description = "管理后台 - 砍价商品创建 Request VO") @Data @EqualsAndHashCode(callSuper = true) diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/product/BargainProductPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/product/BargainProductPageReqVO.java deleted file mode 100644 index 7053ea230..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/product/BargainProductPageReqVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 砍价商品分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainProductPageReqVO extends PageParam { - - @Schema(description = "砍价活动编号", example = "6829") - private Long activityId; - - @Schema(description = "商品 SPU 编号", example = "18731") - private Long spuId; - - @Schema(description = "商品 SKU 编号", example = "31675") - private Long skuId; - - @Schema(description = "砍价商品状态", example = "2") - private Integer activityStatus; - - @Schema(description = "活动开始时间点") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] activityStartTime; - - @Schema(description = "活动结束时间点") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] activityEndTime; - - @Schema(description = "砍价价格,单位分", example = "27682") - private Integer activePrice; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java index 25d073136..ebd1f303a 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java @@ -65,6 +65,7 @@ public interface BargainActivityConvert { List convertList2(List productDOs); + // TODO @puhui999:参数改成 activity、product 会不会干净一点哈 @Mappings({ @Mapping(target = "id", ignore = true), @Mapping(target = "activityId", source = "activityDO.id"), @@ -90,6 +91,4 @@ public interface BargainActivityConvert { .setActivityStatus(activity.getStatus())); } - //BargainRecordDO convert(BargainRecordCreateReqDTO reqDTO); - } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java index 0ea3dd23e..436067ed8 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java @@ -67,6 +67,7 @@ public interface CombinationActivityConvert { List convertList2(List productDOs); + // TODO @puhui999:参数改成 activity、product 会不会干净一点哈 @Mappings({ @Mapping(target = "id", ignore = true), @Mapping(target = "activityId", source = "activityDO.id"), diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java index 6051ae09e..65f3b9b0c 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java @@ -56,6 +56,7 @@ public interface SeckillActivityConvert { return convert1(seckillActivity).setProducts(convertList2(seckillProducts)); } + // TODO @puhui999:参数改成 activity、product 会不会干净一点哈 @Mappings({ @Mapping(target = "id", ignore = true), @Mapping(target = "activityId", source = "activityDO.id"), diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainAssistDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainAssistDO.java index a80be2ccd..691f5a6e2 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainAssistDO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainAssistDO.java @@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; /** - * 砍价助力 DO TODO + * 砍价助力 DO TODO 芋艿:表结构 * * @author HUIHUI */ diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainProductMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainProductMapper.java index 5366c668b..f35999e8e 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainProductMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainProductMapper.java @@ -1,9 +1,6 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.bargain; -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product.BargainProductPageReqVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainProductDO; import org.apache.ibatis.annotations.Mapper; @@ -18,18 +15,6 @@ import java.util.List; @Mapper public interface BargainProductMapper extends BaseMapperX { - default PageResult selectPage(BargainProductPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(BargainProductDO::getActivityId, reqVO.getActivityId()) - .eqIfPresent(BargainProductDO::getSpuId, reqVO.getSpuId()) - .eqIfPresent(BargainProductDO::getSkuId, reqVO.getSkuId()) - .eqIfPresent(BargainProductDO::getActivityStatus, reqVO.getActivityStatus()) - .betweenIfPresent(BargainProductDO::getActivityStartTime, reqVO.getActivityStartTime()) - .betweenIfPresent(BargainProductDO::getActivityEndTime, reqVO.getActivityEndTime()) - .betweenIfPresent(BargainProductDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BargainProductDO::getId)); - } - default List selectListByActivityIds(Collection ids) { return selectList(BargainProductDO::getActivityId, ids); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java index a64cefd0e..8c05b3024 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java @@ -20,6 +20,7 @@ public interface CombinationRecordMapper extends BaseMapperX products) { - // 默认全部新增 - List defaultNewList = CombinationActivityConvert.INSTANCE.convertList(products, updateObj); - // 数据库中的老数据 - List oldList = combinationProductMapper.selectListByActivityIds(CollUtil.newArrayList(updateObj.getId())); - List> lists = CollectionUtils.diffList(oldList, defaultNewList, (oldVal, newVal) -> { + private void updateCombinationProduct(CombinationActivityDO activity, List products) { + // 第一步,对比新老数据,获得添加、修改、删除的列表 + List newList = CombinationActivityConvert.INSTANCE.convertList(products, activity); + List oldList = combinationProductMapper.selectListByActivityIds(CollUtil.newArrayList(activity.getId())); + List> diffList = CollectionUtils.diffList(oldList, newList, (oldVal, newVal) -> { boolean same = ObjectUtil.equal(oldVal.getSkuId(), newVal.getSkuId()); if (same) { newVal.setId(oldVal.getId()); @@ -147,17 +146,15 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi return same; }); - // create - if (CollUtil.isNotEmpty(lists.get(0))) { - combinationProductMapper.insertBatch(lists.get(0)); + // 第二步,批量添加、修改、删除 + if (CollUtil.isNotEmpty(diffList.get(0))) { + combinationProductMapper.insertBatch(diffList.get(0)); } - // update - if (CollUtil.isNotEmpty(lists.get(1))) { - combinationProductMapper.updateBatch(lists.get(1)); + if (CollUtil.isNotEmpty(diffList.get(1))) { + combinationProductMapper.updateBatch(diffList.get(1)); } - // delete - if (CollUtil.isNotEmpty(lists.get(2))) { - combinationProductMapper.deleteBatchIds(CollectionUtils.convertList(lists.get(2), CombinationProductDO::getId)); + if (CollUtil.isNotEmpty(diffList.get(2))) { + combinationProductMapper.deleteBatchIds(CollectionUtils.convertList(diffList.get(2), CombinationProductDO::getId)); } } @@ -204,7 +201,7 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi } @Override - public void updateCombinationRecordStatusByUserIdAndOrderId(CombinationRecordUpdateReqDTO reqDTO) { + public void updateCombinationRecordStatusByUserIdAndOrderId(CombinationRecordUpdateStatusReqDTO reqDTO) { // 校验拼团是否存在 CombinationRecordDO recordDO = validateCombinationRecord(reqDTO.getUserId(), reqDTO.getOrderId()); @@ -215,7 +212,7 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi @Override @Transactional(rollbackFor = Exception.class) - public void updateCombinationRecordStatusAndStartTimeByUserIdAndOrderId(CombinationRecordUpdateReqDTO reqDTO) { + public void updateCombinationRecordStatusAndStartTimeByUserIdAndOrderId(CombinationRecordUpdateStatusReqDTO reqDTO) { CombinationRecordDO recordDO = validateCombinationRecord(reqDTO.getUserId(), reqDTO.getOrderId()); // 更新状态 recordDO.setStatus(reqDTO.getStatus()); diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityServiceImpl.java index 500089bb0..72f985656 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityServiceImpl.java @@ -137,16 +137,14 @@ public class SeckillActivityServiceImpl implements SeckillActivityService { /** * 更新秒杀商品 * - * @param updateObj 更新的活动 - * @param products 商品配置 + * @param activity 秒杀活动 + * @param products 该活动的最新商品配置 */ - private void updateSeckillProduct(SeckillActivityDO updateObj, List products) { - // 默认全部新增 - List defaultNewList = SeckillActivityConvert.INSTANCE.convertList(products, updateObj); - // 数据库中的活动商品 - List oldList = seckillProductMapper.selectListByActivityId(updateObj.getId()); - // 对比老、新两个列表,找出新增、修改、删除的数据 - List> lists = diffList(oldList, defaultNewList, (oldVal, newVal) -> { + private void updateSeckillProduct(SeckillActivityDO activity, List products) { + // 第一步,对比新老数据,获得添加、修改、删除的列表 + List newList = SeckillActivityConvert.INSTANCE.convertList(products, activity); + List oldList = seckillProductMapper.selectListByActivityId(activity.getId()); + List> diffList = diffList(oldList, newList, (oldVal, newVal) -> { boolean same = ObjectUtil.equal(oldVal.getSkuId(), newVal.getSkuId()); if (same) { newVal.setId(oldVal.getId()); @@ -154,17 +152,16 @@ public class SeckillActivityServiceImpl implements SeckillActivityService { return same; }); - // create - if (isNotEmpty(lists.get(0))) { - seckillProductMapper.insertBatch(lists.get(0)); + // 第二步,批量添加、修改、删除 + if (isNotEmpty(diffList.get(0))) { + seckillProductMapper.insertBatch(diffList.get(0)); } - // update - if (isNotEmpty(lists.get(1))) { - seckillProductMapper.updateBatch(lists.get(1)); + if (isNotEmpty(diffList.get(1))) { + seckillProductMapper.updateBatch(diffList.get(1)); } // delete - if (isNotEmpty(lists.get(2))) { - seckillProductMapper.deleteBatchIds(convertList(lists.get(2), SeckillProductDO::getId)); + if (isNotEmpty(diffList.get(2))) { + seckillProductMapper.deleteBatchIds(convertList(diffList.get(2), SeckillProductDO::getId)); } } diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java index 327e13dc0..09ed72012 100644 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.trade.enums; +// TODO @芋艿:枚举 /** * 通知模板枚举类 * diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/notify/TradeNotifyEnums.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/notify/TradeNotifyEnums.java index 3aa0de0cd..74c6b23fe 100644 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/notify/TradeNotifyEnums.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/notify/TradeNotifyEnums.java @@ -1,4 +1,5 @@ package cn.iocoder.yudao.module.trade.enums.notify; +// TODO @芋艿:这个枚举的作用? public interface TradeNotifyEnums { } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageServiceImpl.java index 5c110005a..4bf56e014 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageServiceImpl.java @@ -29,6 +29,7 @@ public class TradeMessageServiceImpl implements TradeMessageService { Map msgMap = new HashMap<>(2); msgMap.put("orderId", reqBO.getOrderId()); msgMap.put("deliveryMessage", reqBO.getMessage()); + // TODO 芋艿:看下模版 // 2、发送站内信 notifyMessageSendApi.sendSingleMessageToMember( new NotifySendSingleToUserReqDTO() diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java index a846b92b0..64e90eb52 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.trade.service.order; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.lang.Assert; import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.core.KeyValue; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; @@ -22,7 +23,7 @@ import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDT import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; import cn.iocoder.yudao.module.promotion.api.combination.CombinationRecordApi; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateReqDTO; +import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO; import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi; import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; @@ -59,8 +60,6 @@ import javax.annotation.Resource; import java.time.LocalDateTime; import java.util.*; -import static cn.hutool.core.util.ObjectUtil.equal; -import static cn.hutool.core.util.ObjectUtil.notEqual; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; @@ -172,13 +171,13 @@ public class TradeOrderServiceImpl implements TradeOrderService { afterCreateTradeOrder(userId, createReqVO, order, orderItems, calculateRespBO); // 3.3 校验订单类型 // 拼团 - if (equal(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) { + if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) { MemberUserRespDTO user = memberUserApi.getUser(userId); // TODO 拼团一次应该只能选择一种规格的商品 - combinationRecordApi.createRecord(TradeOrderConvert.INSTANCE.convert(order, orderItems.get(0), createReqVO, user)); + combinationRecordApi.createCombinationRecord(TradeOrderConvert.INSTANCE.convert(order, orderItems.get(0), createReqVO, user)); } // TODO 秒杀扣减库存是下单就扣除还是等待订单支付成功再扣除 - if (equal(TradeOrderTypeEnum.SECKILL.getType(), order.getType())) { + if (Objects.equals(TradeOrderTypeEnum.SECKILL.getType(), order.getType())) { } @@ -205,7 +204,7 @@ public class TradeOrderServiceImpl implements TradeOrderService { TradePriceCalculateRespBO calculateRespBO) { // 用户选择物流配送的时候才需要填写收货地址 AddressRespDTO address = new AddressRespDTO(); - if (equal(createReqVO.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getMode())) { + if (Objects.equals(createReqVO.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getMode())) { // 用户收件地址的校验 address = validateAddress(userId, createReqVO.getAddressId()); } @@ -309,9 +308,9 @@ public class TradeOrderServiceImpl implements TradeOrderService { } // 校验活动 // 1、拼团活动 - if (equal(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) { + if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) { // 更新拼团状态 TODO puhui999:订单支付失败或订单支付过期删除这条拼团记录 - combinationRecordApi.updateRecordStatus(new CombinationRecordUpdateReqDTO().setUserId(order.getUserId()) + combinationRecordApi.updateCombinationRecordStatus(new CombinationRecordUpdateStatusReqDTO().setUserId(order.getUserId()) .setOrderId(order.getId()).setStatus(CombinationRecordStatusEnum.IN_PROGRESS.getStatus()).setStartTime(LocalDateTime.now())); } // TODO 芋艿:发送订单变化的消息 @@ -344,7 +343,7 @@ public class TradeOrderServiceImpl implements TradeOrderService { throw exception(ORDER_UPDATE_PAID_STATUS_NOT_UNPAID); } // 校验支付订单匹配 - if (notEqual(order.getPayOrderId(), payOrderId)) { // 支付单号 + if (ObjectUtil.notEqual(order.getPayOrderId(), payOrderId)) { // 支付单号 log.error("[validateOrderPaid][order({}) 支付单不匹配({}),请进行处理!order 数据是:{}]", id, payOrderId, JsonUtils.toJsonString(order)); throw exception(ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR); @@ -363,13 +362,13 @@ public class TradeOrderServiceImpl implements TradeOrderService { throw exception(ORDER_UPDATE_PAID_FAIL_PAY_ORDER_STATUS_NOT_SUCCESS); } // 校验支付金额一致 - if (notEqual(payOrder.getPrice(), order.getPayPrice())) { + if (ObjectUtil.notEqual(payOrder.getPrice(), order.getPayPrice())) { log.error("[validateOrderPaid][order({}) payOrder({}) 支付金额不匹配,请进行处理!order 数据是:{},payOrder 数据是:{}]", id, payOrderId, JsonUtils.toJsonString(order), JsonUtils.toJsonString(payOrder)); throw exception(ORDER_UPDATE_PAID_FAIL_PAY_PRICE_NOT_MATCH); } // 校验支付订单匹配(二次) - if (notEqual(payOrder.getMerchantOrderId(), id.toString())) { + if (ObjectUtil.notEqual(payOrder.getMerchantOrderId(), id.toString())) { log.error("[validateOrderPaid][order({}) 支付单不匹配({}),请进行处理!payOrder 数据是:{}]", id, payOrderId, JsonUtils.toJsonString(payOrder)); throw exception(ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR); @@ -393,19 +392,19 @@ public class TradeOrderServiceImpl implements TradeOrderService { TradeOrderDO updateOrderObj = new TradeOrderDO(); // 判断发货类型 // 2.1 快递发货 - if (equal(deliveryReqVO.getType(), DeliveryTypeEnum.EXPRESS.getMode())) { + if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.EXPRESS.getMode())) { // 校验快递公司 validateDeliveryExpress(deliveryReqVO); updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()); } // 2.2 用户自提 - if (equal(deliveryReqVO.getType(), DeliveryTypeEnum.PICK_UP.getMode())) { + if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.PICK_UP.getMode())) { // TODO 校验自提门店是否存在 // 重置一下确保快递公司和快递单号为空 updateOrderObj.setLogisticsId(null).setLogisticsNo(""); } // 2.3 TODO 芋艿:如果无需发货,需要怎么存储?回复:需要把 deliverType 设置为 DeliveryTypeEnum.NULL - if (equal(deliveryReqVO.getType(), DeliveryTypeEnum.NULL.getMode())) { + if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.NULL.getMode())) { // TODO 情况一:正常走发货逻辑和用户自提有点像 不同点:不需要自提门店只需要用户确认收货 // TODO 情况二:用户下单付款后直接确认收货或等待用户确认收货 // 重置一下确保快递公司和快递单号为空 @@ -455,17 +454,17 @@ public class TradeOrderServiceImpl implements TradeOrderService { } // 校验订单是否是待发货状态 if (!TradeOrderStatusEnum.isUndelivered(order.getStatus()) - || notEqual(order.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.UNDELIVERED.getStatus())) { + || ObjectUtil.notEqual(order.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.UNDELIVERED.getStatus())) { throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED); } // 校验订单是否退款 - if (notEqual(TradeOrderRefundStatusEnum.NONE.getStatus(), order.getRefundStatus())) { + if (ObjectUtil.notEqual(TradeOrderRefundStatusEnum.NONE.getStatus(), order.getRefundStatus())) { throw exception(ORDER_DELIVERY_FAIL_REFUND_STATUS_NOT_NONE); } // 订单类型:拼团 - if (equal(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) { + if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) { // 校验订单拼团是否成功 - if (combinationRecordApi.isRecordSuccess(order.getUserId(), order.getId())) { + if (combinationRecordApi.isCombinationRecordSuccess(order.getUserId(), order.getId())) { throw exception(ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS); } } @@ -515,7 +514,7 @@ public class TradeOrderServiceImpl implements TradeOrderService { } // 校验订单是否是待收货状态 if (!TradeOrderStatusEnum.isDelivered(order.getStatus()) - || notEqual(order.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.DELIVERED.getStatus())) { + || ObjectUtil.notEqual(order.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.DELIVERED.getStatus())) { throw exception(ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED); } return order; @@ -525,7 +524,7 @@ public class TradeOrderServiceImpl implements TradeOrderService { public TradeOrderDO getOrder(Long userId, Long id) { TradeOrderDO order = tradeOrderMapper.selectById(id); if (order != null - && notEqual(order.getUserId(), userId)) { + && ObjectUtil.notEqual(order.getUserId(), userId)) { return null; } return order; @@ -569,7 +568,7 @@ public class TradeOrderServiceImpl implements TradeOrderService { public TradeOrderItemDO getOrderItem(Long userId, Long itemId) { TradeOrderItemDO orderItem = tradeOrderItemMapper.selectById(itemId); if (orderItem != null - && notEqual(orderItem.getUserId(), userId)) { + && ObjectUtil.notEqual(orderItem.getUserId(), userId)) { return null; } return orderItem; @@ -649,10 +648,10 @@ public class TradeOrderServiceImpl implements TradeOrderService { if (order == null) { throw exception(ORDER_NOT_FOUND); } - if (notEqual(order.getStatus(), TradeOrderStatusEnum.COMPLETED.getStatus())) { + if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.COMPLETED.getStatus())) { throw exception(ORDER_COMMENT_FAIL_STATUS_NOT_COMPLETED); } - if (notEqual(order.getCommentStatus(), Boolean.FALSE)) { + if (ObjectUtil.notEqual(order.getCommentStatus(), Boolean.FALSE)) { throw exception(ORDER_COMMENT_STATUS_NOT_FALSE); } @@ -662,7 +661,7 @@ public class TradeOrderServiceImpl implements TradeOrderService { // 更新订单项评价状态 tradeOrderItemMapper.updateById(new TradeOrderItemDO().setId(orderItem.getId()).setCommentStatus(Boolean.TRUE)); List orderItems = getOrderItemListByOrderId(CollUtil.newArrayList(order.getId())); - if (!anyMatch(orderItems, item -> equal(item.getCommentStatus(), Boolean.FALSE))) { + if (!anyMatch(orderItems, item -> Objects.equals(item.getCommentStatus(), Boolean.FALSE))) { // 对于 order 来说,就是评论完,把 order 更新完合理的 status 等字段。 tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()).setCommentStatus(Boolean.TRUE)); } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceImpl.java index c85876ee7..f6b17c565 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceImpl.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceImpl.java @@ -252,6 +252,7 @@ public class PayNotifyServiceImpl implements PayNotifyService { notifyTaskMapper.updateById(updateTask); return updateTask.getStatus(); } + // 情况二:调用失败、调用异常 // 2.1 超过最大回调次数 if (updateTask.getNotifyTimes() >= PayNotifyTaskDO.NOTIFY_FREQUENCY.length) {