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 2274d45fd..05dfb8b6e 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 @@ -28,7 +28,7 @@ public interface CombinationRecordApi { * 创建开团记录 * * @param reqDTO 请求 DTO - * @return 团信息 + * @return 拼团信息 */ CombinationRecordCreateRespDTO createCombinationRecord(@Valid CombinationRecordCreateReqDTO reqDTO); diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java index dfb8ec889..8f6962d00 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java @@ -40,8 +40,6 @@ public class CombinationRecordController { @Lazy private CombinationRecordService combinationRecordService; - // 然后如果 headId 非空,并且第一页,单独多查询一条 head ;放到第 0 个位置;相当于说,第一页特殊一点; - @GetMapping("/page") @Operation(summary = "获得拼团记录分页") @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java index e242569ac..0da03e050 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java @@ -47,13 +47,13 @@ public class AppCombinationRecordController { public CommonResult getCombinationRecordSummary() { AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO(); // 1. 获得拼团参与用户数量 - Long count = combinationRecordService.getCombinationUserCount(); - if (count == 0) { + Long userCount = combinationRecordService.getCombinationUserCount(); + if (userCount == 0) { summary.setAvatars(Collections.emptyList()); - summary.setUserCount(count); + summary.setUserCount(userCount); return success(summary); } - summary.setUserCount(count); + summary.setUserCount(userCount); // 2. 获得拼团记录头像 List records = combinationRecordService.getLatestCombinationRecordList( 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 aad8281d6..84f7e5d46 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 @@ -192,7 +192,6 @@ public interface CombinationActivityConvert { return result; } - default AppCombinationRecordDetailRespVO convert(Long userId, CombinationRecordDO headRecord, List memberRecords) { AppCombinationRecordDetailRespVO respVO = new AppCombinationRecordDetailRespVO() .setHeadRecord(convert(headRecord)).setMemberRecords(convertList3(memberRecords)); 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 56ec0361a..f633edc90 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 @@ -99,10 +99,10 @@ public interface CombinationRecordMapper extends BaseMapperX queryWrapper = new LambdaQueryWrapperX() .eqIfPresent(CombinationRecordDO::getStatus, pageVO.getStatus()) .betweenIfPresent(CombinationRecordDO::getCreateTime, pageVO.getCreateTime()); + // 如果 headId 非空,说明查询指定团的团长 + 团员的拼团记录 if (pageVO.getHeadId() != null) { - queryWrapper.eq(CombinationRecordDO::getId, pageVO.getHeadId()) - .or() - .eq(CombinationRecordDO::getHeadId, pageVO.getHeadId()); + queryWrapper.eq(CombinationRecordDO::getId, pageVO.getHeadId()) // 团长 + .or().eq(CombinationRecordDO::getHeadId, pageVO.getHeadId()); // 团员 } return selectPage(pageVO, queryWrapper); } @@ -127,6 +127,7 @@ public interface CombinationRecordMapper extends BaseMapperX() .select("DISTINCT (user_id)") diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java index 82baf1931..2d10d1e70 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java @@ -339,19 +339,20 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { @Override public KeyValue expireCombinationRecord() { - // 1.获取所有正在进行中的过期的父拼团 + // 1. 获取所有正在进行中的过期的父拼团 List headExpireRecords = combinationRecordMapper.selectListByHeadIdAndStatusAndExpireTimeLt( CombinationRecordDO.HEAD_ID_GROUP, CombinationRecordStatusEnum.IN_PROGRESS.getStatus(), LocalDateTime.now()); if (CollUtil.isEmpty(headExpireRecords)) { return new KeyValue<>(0, 0); } - // 2.获取拼团活动 + // 2. 获取拼团活动 List activities = combinationActivityService.getCombinationActivityListByIds( convertSet(headExpireRecords, CombinationRecordDO::getActivityId)); Map activityMap = convertMap(activities, CombinationActivityDO::getId); - // 3.校验是否虚拟成团 + // TODO @puhui999:这里可以改成“每个团”,处理一次哈;这样 handleExpireRecord、handleVirtualGroupRecord 都改成按团处理,每个是一个小事务; + // 3. 校验是否虚拟成团 List virtualGroupHeadRecords = new ArrayList<>(); // 虚拟成团 for (Iterator iterator = headExpireRecords.iterator(); iterator.hasNext(); ) { CombinationRecordDO record = iterator.next(); diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java index d942fd853..8719730b9 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java @@ -93,6 +93,7 @@ public interface TradeOrderMapper extends BaseMapperX { return selectOne(TradeOrderDO::getPickUpVerifyCode, pickUpVerifyCode); } + // TODO @puhui999:selectByUserIdAndCombinationActivityIdAndStatus,这样更容易理解哈。 /** * 只针对 combinationActivityId 的查询 * diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationOrderHandler.java index 7efdc1650..6a530dc89 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationOrderHandler.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationOrderHandler.java @@ -70,8 +70,8 @@ public class TradeCombinationOrderHandler implements TradeOrderHandler { TradeOrderConvert.INSTANCE.convert(order, item)); // 3. 更新拼团相关信息到订单 - // TODO 芋艿,只需要更新 record。 如果创建订单时自己是团长的情况下 combinationHeadId 是为 null 的, - // 设置团长编号这个操作时在订单是否后创建拼团记录时才设置的,所以支付完创建拼团记录后需要设置一下记录编号和团长编号 + // 为什么几个字段都要更新?原因是: + // 如果创建订单时自己是团长的情况下 combinationHeadId 是为 null 的,设置团长编号这个操作时在订单是否后创建拼团记录时才设置的。 orderUpdateService.updateOrderCombinationInfo(order.getId(), order.getCombinationActivityId(), combinationRecord.getCombinationRecordId(), combinationRecord.getCombinationHeadId()); }