Commit c917f01d83969ed0f1e3da7dec0b8a308b69d1a0
1 parent
ec2c3e50
promotion:code review 拼团相关的部分代码
Showing
9 changed files
with
22 additions
and
13 deletions
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.java
| @@ -52,11 +52,11 @@ public class AppActivityController { | @@ -52,11 +52,11 @@ public class AppActivityController { | ||
| 52 | @Operation(summary = "获得多个商品,近期参与的每个活动") // 每种活动,只返回一个;key 为 SPU 编号 | 52 | @Operation(summary = "获得多个商品,近期参与的每个活动") // 每种活动,只返回一个;key 为 SPU 编号 |
| 53 | @Parameter(name = "spuIds", description = "商品编号数组", required = true) | 53 | @Parameter(name = "spuIds", description = "商品编号数组", required = true) |
| 54 | public CommonResult<Map<Long, List<AppActivityRespVO>>> getActivityListBySpuIds(@RequestParam("spuIds") List<Long> spuIds) { | 54 | public CommonResult<Map<Long, List<AppActivityRespVO>>> getActivityListBySpuIds(@RequestParam("spuIds") List<Long> spuIds) { |
| 55 | - | ||
| 56 | if (CollUtil.isEmpty(spuIds)) { | 55 | if (CollUtil.isEmpty(spuIds)) { |
| 57 | return success(MapUtil.empty()); | 56 | return success(MapUtil.empty()); |
| 58 | } | 57 | } |
| 59 | 58 | ||
| 59 | + // TODO @puhui999:要避免这种 1+n 的查询 | ||
| 60 | Map<Long, List<AppActivityRespVO>> map = new HashMap<>(spuIds.size()); | 60 | Map<Long, List<AppActivityRespVO>> map = new HashMap<>(spuIds.size()); |
| 61 | spuIds.forEach(spuId -> { | 61 | spuIds.forEach(spuId -> { |
| 62 | map.put(spuId, getAppActivityRespVOList(spuId)); | 62 | map.put(spuId, getAppActivityRespVOList(spuId)); |
| @@ -65,35 +65,38 @@ public class AppActivityController { | @@ -65,35 +65,38 @@ public class AppActivityController { | ||
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | private List<AppActivityRespVO> getAppActivityRespVOList(Long spuId) { | 67 | private List<AppActivityRespVO> getAppActivityRespVOList(Long spuId) { |
| 68 | - List<AppActivityRespVO> respList = new ArrayList<>(); | 68 | + List<AppActivityRespVO> activityList = new ArrayList<>(); |
| 69 | + // 拼团活动 | ||
| 69 | CombinationActivityDO combination = combinationActivityService.getCombinationActivityBySpuId(spuId); | 70 | CombinationActivityDO combination = combinationActivityService.getCombinationActivityBySpuId(spuId); |
| 70 | if (combination != null) { | 71 | if (combination != null) { |
| 71 | - respList.add(new AppActivityRespVO() | 72 | + activityList.add(new AppActivityRespVO() |
| 72 | .setId(combination.getId()) | 73 | .setId(combination.getId()) |
| 73 | .setType(PromotionTypeEnum.COMBINATION_ACTIVITY.getType()) | 74 | .setType(PromotionTypeEnum.COMBINATION_ACTIVITY.getType()) |
| 74 | .setName(combination.getName()) | 75 | .setName(combination.getName()) |
| 75 | .setStartTime(combination.getStartTime()) | 76 | .setStartTime(combination.getStartTime()) |
| 76 | .setEndTime(combination.getEndTime())); | 77 | .setEndTime(combination.getEndTime())); |
| 77 | } | 78 | } |
| 79 | + // 秒杀活动 | ||
| 78 | SeckillActivityDO seckill = seckillActivityService.getSeckillActivityBySpuId(spuId); | 80 | SeckillActivityDO seckill = seckillActivityService.getSeckillActivityBySpuId(spuId); |
| 79 | if (seckill != null) { | 81 | if (seckill != null) { |
| 80 | - respList.add(new AppActivityRespVO() | 82 | + activityList.add(new AppActivityRespVO() |
| 81 | .setId(seckill.getId()) | 83 | .setId(seckill.getId()) |
| 82 | .setType(PromotionTypeEnum.SECKILL_ACTIVITY.getType()) | 84 | .setType(PromotionTypeEnum.SECKILL_ACTIVITY.getType()) |
| 83 | .setName(seckill.getName()) | 85 | .setName(seckill.getName()) |
| 84 | .setStartTime(seckill.getStartTime()) | 86 | .setStartTime(seckill.getStartTime()) |
| 85 | .setEndTime(seckill.getEndTime())); | 87 | .setEndTime(seckill.getEndTime())); |
| 86 | } | 88 | } |
| 89 | + // 秒杀活动 | ||
| 87 | BargainActivityDO bargain = bargainActivityService.getBargainActivityBySpuId(spuId); | 90 | BargainActivityDO bargain = bargainActivityService.getBargainActivityBySpuId(spuId); |
| 88 | if (bargain != null) { | 91 | if (bargain != null) { |
| 89 | - respList.add(new AppActivityRespVO() | 92 | + activityList.add(new AppActivityRespVO() |
| 90 | .setId(bargain.getId()) | 93 | .setId(bargain.getId()) |
| 91 | .setType(PromotionTypeEnum.BARGAIN_ACTIVITY.getType()) | 94 | .setType(PromotionTypeEnum.BARGAIN_ACTIVITY.getType()) |
| 92 | .setName(bargain.getName()) | 95 | .setName(bargain.getName()) |
| 93 | .setStartTime(bargain.getStartTime()) | 96 | .setStartTime(bargain.getStartTime()) |
| 94 | .setEndTime(bargain.getEndTime())); | 97 | .setEndTime(bargain.getEndTime())); |
| 95 | } | 98 | } |
| 96 | - return respList; | 99 | + return activityList; |
| 97 | } | 100 | } |
| 98 | 101 | ||
| 99 | } | 102 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationRecordDO.java
| @@ -76,6 +76,8 @@ public class CombinationRecordDO extends BaseDO { | @@ -76,6 +76,8 @@ public class CombinationRecordDO extends BaseDO { | ||
| 76 | * 用户编号 | 76 | * 用户编号 |
| 77 | */ | 77 | */ |
| 78 | private Long userId; | 78 | private Long userId; |
| 79 | + | ||
| 80 | + // TODO @puhui999:要不去掉这 2 个字段,通过读取解决?如果去掉,相关接口都要处理下哈; | ||
| 79 | /** | 81 | /** |
| 80 | * 用户昵称 | 82 | * 用户昵称 |
| 81 | */ | 83 | */ |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java
| @@ -83,6 +83,7 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> { | @@ -83,6 +83,7 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> { | ||
| 83 | .last("LIMIT " + count)); | 83 | .last("LIMIT " + count)); |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | + // TODO @puhui999:需要开启状态;另外,是不是可以 limit1,不用 throwEx = false 处理呀?另外,时间要满足噢 | ||
| 86 | default BargainActivityDO selectOne(Long spuId) { | 87 | default BargainActivityDO selectOne(Long spuId) { |
| 87 | return selectOne(new LambdaQueryWrapperX<BargainActivityDO>() | 88 | return selectOne(new LambdaQueryWrapperX<BargainActivityDO>() |
| 88 | .eq(BargainActivityDO::getSpuId, spuId) | 89 | .eq(BargainActivityDO::getSpuId, spuId) |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationActivityMapper.java
| @@ -40,6 +40,7 @@ public interface CombinationActivityMapper extends BaseMapperX<CombinationActivi | @@ -40,6 +40,7 @@ public interface CombinationActivityMapper extends BaseMapperX<CombinationActivi | ||
| 40 | .last("LIMIT " + count)); | 40 | .last("LIMIT " + count)); |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | + // TODO @puhui999:需要开启状态;另外,是不是可以 limit1,不用 throwEx = false 处理呀?另外,时间要满足噢 | ||
| 43 | default CombinationActivityDO selectOne(Long spuId) { | 44 | default CombinationActivityDO selectOne(Long spuId) { |
| 44 | return selectOne(new LambdaQueryWrapperX<CombinationActivityDO>() | 45 | return selectOne(new LambdaQueryWrapperX<CombinationActivityDO>() |
| 45 | .eq(CombinationActivityDO::getSpuId, spuId) | 46 | .eq(CombinationActivityDO::getSpuId, spuId) |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java
| @@ -84,8 +84,8 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO | @@ -84,8 +84,8 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO | ||
| 84 | default List<CombinationRecordDO> selectListByActivityIdAndStatusAndHeadId(Long activityId, Integer status, | 84 | default List<CombinationRecordDO> selectListByActivityIdAndStatusAndHeadId(Long activityId, Integer status, |
| 85 | Long headId, Integer count) { | 85 | Long headId, Integer count) { |
| 86 | return selectList(new LambdaQueryWrapperX<CombinationRecordDO>() | 86 | return selectList(new LambdaQueryWrapperX<CombinationRecordDO>() |
| 87 | - .eq(CombinationRecordDO::getActivityId, activityId) | ||
| 88 | - .eq(CombinationRecordDO::getStatus, status) | 87 | + .eqIfPresent(CombinationRecordDO::getActivityId, activityId) |
| 88 | + .eqIfPresent(CombinationRecordDO::getStatus, status) | ||
| 89 | .eq(CombinationRecordDO::getHeadId, headId) | 89 | .eq(CombinationRecordDO::getHeadId, headId) |
| 90 | .orderByDesc(CombinationRecordDO::getId) | 90 | .orderByDesc(CombinationRecordDO::getId) |
| 91 | .last("LIMIT " + count)); | 91 | .last("LIMIT " + count)); |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java
| @@ -56,6 +56,7 @@ public interface SeckillActivityMapper extends BaseMapperX<SeckillActivityDO> { | @@ -56,6 +56,7 @@ public interface SeckillActivityMapper extends BaseMapperX<SeckillActivityDO> { | ||
| 56 | .apply(ObjectUtil.isNotNull(pageReqVO.getConfigId()), "FIND_IN_SET(" + pageReqVO.getConfigId() + ",config_ids) > 0")); | 56 | .apply(ObjectUtil.isNotNull(pageReqVO.getConfigId()), "FIND_IN_SET(" + pageReqVO.getConfigId() + ",config_ids) > 0")); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | + // TODO @puhui999:需要开启状态;另外,是不是可以 limit1,不用 throwEx = false 处理呀?另外,时间要满足噢; | ||
| 59 | default SeckillActivityDO selectOne(Long spuId) { | 60 | default SeckillActivityDO selectOne(Long spuId) { |
| 60 | return selectOne(new LambdaQueryWrapperX<SeckillActivityDO>() | 61 | return selectOne(new LambdaQueryWrapperX<SeckillActivityDO>() |
| 61 | .eq(SeckillActivityDO::getSpuId, spuId) | 62 | .eq(SeckillActivityDO::getSpuId, spuId) |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
| @@ -67,6 +67,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -67,6 +67,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 67 | @Resource | 67 | @Resource |
| 68 | private TradeOrderApi tradeOrderApi; | 68 | private TradeOrderApi tradeOrderApi; |
| 69 | 69 | ||
| 70 | + // TODO @芋艿:在详细预览下; | ||
| 70 | @Override | 71 | @Override |
| 71 | @Transactional(rollbackFor = Exception.class) | 72 | @Transactional(rollbackFor = Exception.class) |
| 72 | public void updateCombinationRecordStatusByUserIdAndOrderId(Integer status, Long userId, Long orderId) { | 73 | public void updateCombinationRecordStatusByUserIdAndOrderId(Integer status, Long userId, Long orderId) { |
| @@ -78,6 +79,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | @@ -78,6 +79,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 78 | recordMapper.updateById(record); | 79 | recordMapper.updateById(record); |
| 79 | } | 80 | } |
| 80 | 81 | ||
| 82 | + // TODO @芋艿:在详细预览下; | ||
| 81 | @Override | 83 | @Override |
| 82 | @Transactional(rollbackFor = Exception.class) | 84 | @Transactional(rollbackFor = Exception.class) |
| 83 | public void updateRecordStatusAndStartTimeByUserIdAndOrderId(Integer status, Long userId, Long orderId, LocalDateTime startTime) { | 85 | public void updateRecordStatusAndStartTimeByUserIdAndOrderId(Integer status, Long userId, Long orderId, LocalDateTime startTime) { |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderOperateTypeEnum.java
| @@ -16,7 +16,7 @@ public enum TradeOrderOperateTypeEnum { | @@ -16,7 +16,7 @@ public enum TradeOrderOperateTypeEnum { | ||
| 16 | MEMBER_CREATE(1, "用户下单"), | 16 | MEMBER_CREATE(1, "用户下单"), |
| 17 | ADMIN_UPDATE_PRICE(2, "订单价格 {oldPayPrice} 修改,实际支付金额为 {newPayPrice} 元"), | 17 | ADMIN_UPDATE_PRICE(2, "订单价格 {oldPayPrice} 修改,实际支付金额为 {newPayPrice} 元"), |
| 18 | MEMBER_PAY(10, "用户付款成功"), | 18 | MEMBER_PAY(10, "用户付款成功"), |
| 19 | - SYSTEM_UP_ADDRESS(11, "订单 {orderId} 收货地址修改"), | 19 | + ADMIN_UPDATE_ADDRESS(11, "收货地址修改"), |
| 20 | ADMIN_DELIVERY(20, "已发货,快递公司:{deliveryName},快递单号:{logisticsNo}"), | 20 | ADMIN_DELIVERY(20, "已发货,快递公司:{deliveryName},快递单号:{logisticsNo}"), |
| 21 | MEMBER_RECEIVE(30, "用户已收货"), | 21 | MEMBER_RECEIVE(30, "用户已收货"), |
| 22 | SYSTEM_RECEIVE(31, "到期未收货,系统自动确认收货"), | 22 | SYSTEM_RECEIVE(31, "到期未收货,系统自动确认收货"), |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java
| @@ -738,19 +738,18 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { | @@ -738,19 +738,18 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { | ||
| 738 | } | 738 | } |
| 739 | 739 | ||
| 740 | @Override | 740 | @Override |
| 741 | - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.SYSTEM_UP_ADDRESS) | 741 | + @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_UPDATE_ADDRESS) |
| 742 | public void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO) { | 742 | public void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO) { |
| 743 | // 校验交易订单 | 743 | // 校验交易订单 |
| 744 | TradeOrderDO order = validateOrderExists(reqVO.getId()); | 744 | TradeOrderDO order = validateOrderExists(reqVO.getId()); |
| 745 | // TODO @puhui999:是否需要校验订单是否发货 | 745 | // TODO @puhui999:是否需要校验订单是否发货 |
| 746 | - // TODO 发货后是否支持修改收货地址 | 746 | + // TODO 发货后是否支持修改收货地址;回答:发货后,不允许修改; |
| 747 | 747 | ||
| 748 | // 更新 | 748 | // 更新 |
| 749 | tradeOrderMapper.updateById(TradeOrderConvert.INSTANCE.convert(reqVO)); | 749 | tradeOrderMapper.updateById(TradeOrderConvert.INSTANCE.convert(reqVO)); |
| 750 | 750 | ||
| 751 | // 记录订单日志 | 751 | // 记录订单日志 |
| 752 | - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus(), | ||
| 753 | - MapUtil.<String, Object>builder().put("orderId", order.getId()).build()); | 752 | + TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus()); |
| 754 | } | 753 | } |
| 755 | 754 | ||
| 756 | @Override | 755 | @Override |