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 | 52 | @Operation(summary = "获得多个商品,近期参与的每个活动") // 每种活动,只返回一个;key 为 SPU 编号 |
| 53 | 53 | @Parameter(name = "spuIds", description = "商品编号数组", required = true) |
| 54 | 54 | public CommonResult<Map<Long, List<AppActivityRespVO>>> getActivityListBySpuIds(@RequestParam("spuIds") List<Long> spuIds) { |
| 55 | - | |
| 56 | 55 | if (CollUtil.isEmpty(spuIds)) { |
| 57 | 56 | return success(MapUtil.empty()); |
| 58 | 57 | } |
| 59 | 58 | |
| 59 | + // TODO @puhui999:要避免这种 1+n 的查询 | |
| 60 | 60 | Map<Long, List<AppActivityRespVO>> map = new HashMap<>(spuIds.size()); |
| 61 | 61 | spuIds.forEach(spuId -> { |
| 62 | 62 | map.put(spuId, getAppActivityRespVOList(spuId)); |
| ... | ... | @@ -65,35 +65,38 @@ public class AppActivityController { |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | private List<AppActivityRespVO> getAppActivityRespVOList(Long spuId) { |
| 68 | - List<AppActivityRespVO> respList = new ArrayList<>(); | |
| 68 | + List<AppActivityRespVO> activityList = new ArrayList<>(); | |
| 69 | + // 拼团活动 | |
| 69 | 70 | CombinationActivityDO combination = combinationActivityService.getCombinationActivityBySpuId(spuId); |
| 70 | 71 | if (combination != null) { |
| 71 | - respList.add(new AppActivityRespVO() | |
| 72 | + activityList.add(new AppActivityRespVO() | |
| 72 | 73 | .setId(combination.getId()) |
| 73 | 74 | .setType(PromotionTypeEnum.COMBINATION_ACTIVITY.getType()) |
| 74 | 75 | .setName(combination.getName()) |
| 75 | 76 | .setStartTime(combination.getStartTime()) |
| 76 | 77 | .setEndTime(combination.getEndTime())); |
| 77 | 78 | } |
| 79 | + // 秒杀活动 | |
| 78 | 80 | SeckillActivityDO seckill = seckillActivityService.getSeckillActivityBySpuId(spuId); |
| 79 | 81 | if (seckill != null) { |
| 80 | - respList.add(new AppActivityRespVO() | |
| 82 | + activityList.add(new AppActivityRespVO() | |
| 81 | 83 | .setId(seckill.getId()) |
| 82 | 84 | .setType(PromotionTypeEnum.SECKILL_ACTIVITY.getType()) |
| 83 | 85 | .setName(seckill.getName()) |
| 84 | 86 | .setStartTime(seckill.getStartTime()) |
| 85 | 87 | .setEndTime(seckill.getEndTime())); |
| 86 | 88 | } |
| 89 | + // 秒杀活动 | |
| 87 | 90 | BargainActivityDO bargain = bargainActivityService.getBargainActivityBySpuId(spuId); |
| 88 | 91 | if (bargain != null) { |
| 89 | - respList.add(new AppActivityRespVO() | |
| 92 | + activityList.add(new AppActivityRespVO() | |
| 90 | 93 | .setId(bargain.getId()) |
| 91 | 94 | .setType(PromotionTypeEnum.BARGAIN_ACTIVITY.getType()) |
| 92 | 95 | .setName(bargain.getName()) |
| 93 | 96 | .setStartTime(bargain.getStartTime()) |
| 94 | 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
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 | 83 | .last("LIMIT " + count)); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | + // TODO @puhui999:需要开启状态;另外,是不是可以 limit1,不用 throwEx = false 处理呀?另外,时间要满足噢 | |
| 86 | 87 | default BargainActivityDO selectOne(Long spuId) { |
| 87 | 88 | return selectOne(new LambdaQueryWrapperX<BargainActivityDO>() |
| 88 | 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 | 40 | .last("LIMIT " + count)); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | + // TODO @puhui999:需要开启状态;另外,是不是可以 limit1,不用 throwEx = false 处理呀?另外,时间要满足噢 | |
| 43 | 44 | default CombinationActivityDO selectOne(Long spuId) { |
| 44 | 45 | return selectOne(new LambdaQueryWrapperX<CombinationActivityDO>() |
| 45 | 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 | 84 | default List<CombinationRecordDO> selectListByActivityIdAndStatusAndHeadId(Long activityId, Integer status, |
| 85 | 85 | Long headId, Integer count) { |
| 86 | 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 | 89 | .eq(CombinationRecordDO::getHeadId, headId) |
| 90 | 90 | .orderByDesc(CombinationRecordDO::getId) |
| 91 | 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 | 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 | 60 | default SeckillActivityDO selectOne(Long spuId) { |
| 60 | 61 | return selectOne(new LambdaQueryWrapperX<SeckillActivityDO>() |
| 61 | 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 | 67 | @Resource |
| 68 | 68 | private TradeOrderApi tradeOrderApi; |
| 69 | 69 | |
| 70 | + // TODO @芋艿:在详细预览下; | |
| 70 | 71 | @Override |
| 71 | 72 | @Transactional(rollbackFor = Exception.class) |
| 72 | 73 | public void updateCombinationRecordStatusByUserIdAndOrderId(Integer status, Long userId, Long orderId) { |
| ... | ... | @@ -78,6 +79,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 78 | 79 | recordMapper.updateById(record); |
| 79 | 80 | } |
| 80 | 81 | |
| 82 | + // TODO @芋艿:在详细预览下; | |
| 81 | 83 | @Override |
| 82 | 84 | @Transactional(rollbackFor = Exception.class) |
| 83 | 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 | 16 | MEMBER_CREATE(1, "用户下单"), |
| 17 | 17 | ADMIN_UPDATE_PRICE(2, "订单价格 {oldPayPrice} 修改,实际支付金额为 {newPayPrice} 元"), |
| 18 | 18 | MEMBER_PAY(10, "用户付款成功"), |
| 19 | - SYSTEM_UP_ADDRESS(11, "订单 {orderId} 收货地址修改"), | |
| 19 | + ADMIN_UPDATE_ADDRESS(11, "收货地址修改"), | |
| 20 | 20 | ADMIN_DELIVERY(20, "已发货,快递公司:{deliveryName},快递单号:{logisticsNo}"), |
| 21 | 21 | MEMBER_RECEIVE(30, "用户已收货"), |
| 22 | 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 | 738 | } |
| 739 | 739 | |
| 740 | 740 | @Override |
| 741 | - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.SYSTEM_UP_ADDRESS) | |
| 741 | + @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_UPDATE_ADDRESS) | |
| 742 | 742 | public void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO) { |
| 743 | 743 | // 校验交易订单 |
| 744 | 744 | TradeOrderDO order = validateOrderExists(reqVO.getId()); |
| 745 | 745 | // TODO @puhui999:是否需要校验订单是否发货 |
| 746 | - // TODO 发货后是否支持修改收货地址 | |
| 746 | + // TODO 发货后是否支持修改收货地址;回答:发货后,不允许修改; | |
| 747 | 747 | |
| 748 | 748 | // 更新 |
| 749 | 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 | 755 | @Override | ... | ... |