Commit 387ef6f396d4d182a5755f74ca2a7cbfd8b86814
1 parent
50711945
【功能简化】商城:1)拼团活动,移除用户主动取消,不常用;2)review 拼团相关的逻辑
Showing
4 changed files
with
3 additions
and
103 deletions
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java
| ... | ... | @@ -10,9 +10,7 @@ import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.Ap |
| 10 | 10 | import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordSummaryRespVO; |
| 11 | 11 | import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; |
| 12 | 12 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; |
| 13 | -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; | |
| 14 | 13 | import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; |
| 15 | -import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; | |
| 16 | 14 | import io.swagger.v3.oas.annotations.Operation; |
| 17 | 15 | import io.swagger.v3.oas.annotations.Parameter; |
| 18 | 16 | import io.swagger.v3.oas.annotations.Parameters; |
| ... | ... | @@ -20,7 +18,6 @@ import io.swagger.v3.oas.annotations.tags.Tag; |
| 20 | 18 | import jakarta.annotation.Resource; |
| 21 | 19 | import jakarta.validation.Valid; |
| 22 | 20 | import jakarta.validation.constraints.Max; |
| 23 | -import org.springframework.context.annotation.Lazy; | |
| 24 | 21 | import org.springframework.validation.annotation.Validated; |
| 25 | 22 | import org.springframework.web.bind.annotation.GetMapping; |
| 26 | 23 | import org.springframework.web.bind.annotation.RequestMapping; |
| ... | ... | @@ -43,9 +40,6 @@ public class AppCombinationRecordController { |
| 43 | 40 | |
| 44 | 41 | @Resource |
| 45 | 42 | private CombinationRecordService combinationRecordService; |
| 46 | - @Resource | |
| 47 | - @Lazy | |
| 48 | - private TradeOrderApi tradeOrderApi; | |
| 49 | 43 | |
| 50 | 44 | @GetMapping("/get-summary") |
| 51 | 45 | @Operation(summary = "获得拼团记录的概要信息", description = "用于小程序首页") |
| ... | ... | @@ -117,26 +111,4 @@ public class AppCombinationRecordController { |
| 117 | 111 | return success(CombinationActivityConvert.INSTANCE.convert(getLoginUserId(), headRecord, memberRecords)); |
| 118 | 112 | } |
| 119 | 113 | |
| 120 | - @GetMapping("/cancel") | |
| 121 | - @Operation(summary = "取消拼团") | |
| 122 | - @Parameter(name = "id", description = "拼团记录编号", required = true, example = "1024") | |
| 123 | - public CommonResult<Boolean> cancelCombinationRecord(@RequestParam("id") Long id) { | |
| 124 | - Long userId = getLoginUserId(); | |
| 125 | - // 1、查找这条拼团记录 | |
| 126 | - CombinationRecordDO record = combinationRecordService.getCombinationRecordByIdAndUser(userId, id); | |
| 127 | - if (record == null) { | |
| 128 | - return success(Boolean.FALSE); | |
| 129 | - } | |
| 130 | - // 1.1、需要先校验拼团记录未完成; | |
| 131 | - if (!CombinationRecordStatusEnum.isInProgress(record.getStatus())) { | |
| 132 | - return success(Boolean.FALSE); | |
| 133 | - } | |
| 134 | - | |
| 135 | - // 2. 取消已支付的订单 | |
| 136 | - tradeOrderApi.cancelPaidOrder(userId, record.getOrderId()); | |
| 137 | - // 3. 取消拼团记录 | |
| 138 | - combinationRecordService.cancelCombinationRecord(userId, record.getId(), record.getHeadId()); | |
| 139 | - return success(Boolean.TRUE); | |
| 140 | - } | |
| 141 | - | |
| 142 | 114 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java
| ... | ... | @@ -140,24 +140,6 @@ public interface CombinationRecordService { |
| 140 | 140 | @Nullable Long headId); |
| 141 | 141 | |
| 142 | 142 | /** |
| 143 | - * 获取拼团记录 | |
| 144 | - * | |
| 145 | - * @param userId 用户编号 | |
| 146 | - * @param id 拼团记录编号 | |
| 147 | - * @return 拼团记录 | |
| 148 | - */ | |
| 149 | - CombinationRecordDO getCombinationRecordByIdAndUser(Long userId, Long id); | |
| 150 | - | |
| 151 | - /** | |
| 152 | - * 取消拼团 | |
| 153 | - * | |
| 154 | - * @param userId 用户编号 | |
| 155 | - * @param id 拼团记录编号 | |
| 156 | - * @param headId 团长编号 | |
| 157 | - */ | |
| 158 | - void cancelCombinationRecord(Long userId, Long id, Long headId); | |
| 159 | - | |
| 160 | - /** | |
| 161 | 143 | * 处理过期拼团 |
| 162 | 144 | * |
| 163 | 145 | * @return key 过期拼团数量, value 虚拟成团数量 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
| ... | ... | @@ -69,7 +69,6 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 69 | 69 | private ProductSpuApi productSpuApi; |
| 70 | 70 | @Resource |
| 71 | 71 | private ProductSkuApi productSkuApi; |
| 72 | - | |
| 73 | 72 | @Resource |
| 74 | 73 | @Lazy // 延迟加载,避免循环依赖 |
| 75 | 74 | private TradeOrderApi tradeOrderApi; |
| ... | ... | @@ -290,61 +289,6 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 290 | 289 | } |
| 291 | 290 | |
| 292 | 291 | @Override |
| 293 | - public CombinationRecordDO getCombinationRecordByIdAndUser(Long userId, Long id) { | |
| 294 | - return combinationRecordMapper.selectOne(CombinationRecordDO::getUserId, userId, CombinationRecordDO::getId, id); | |
| 295 | - } | |
| 296 | - | |
| 297 | - @Override | |
| 298 | - @Transactional(rollbackFor = Exception.class) | |
| 299 | - public void cancelCombinationRecord(Long userId, Long id, Long headId) { | |
| 300 | - // 删除记录 | |
| 301 | - combinationRecordMapper.deleteById(id); | |
| 302 | - | |
| 303 | - // 需要更新的记录 | |
| 304 | - List<CombinationRecordDO> updateRecords = new ArrayList<>(); | |
| 305 | - // 如果它是团长,则顺序(下单时间)继承 | |
| 306 | - if (Objects.equals(headId, CombinationRecordDO.HEAD_ID_GROUP)) { // 情况一:团长 | |
| 307 | - // 团员 | |
| 308 | - List<CombinationRecordDO> list = getCombinationRecordListByHeadId(id); | |
| 309 | - if (CollUtil.isEmpty(list)) { | |
| 310 | - return; | |
| 311 | - } | |
| 312 | - // 按照创建时间升序排序 | |
| 313 | - list.sort(Comparator.comparing(CombinationRecordDO::getCreateTime)); // 影响原 list | |
| 314 | - CombinationRecordDO newHead = list.get(0); // 新团长继位 | |
| 315 | - list.forEach(item -> { | |
| 316 | - CombinationRecordDO recordDO = new CombinationRecordDO(); | |
| 317 | - recordDO.setId(item.getId()); | |
| 318 | - if (ObjUtil.equal(item.getId(), newHead.getId())) { // 新团长 | |
| 319 | - recordDO.setHeadId(CombinationRecordDO.HEAD_ID_GROUP); | |
| 320 | - } else { | |
| 321 | - recordDO.setHeadId(newHead.getId()); | |
| 322 | - } | |
| 323 | - recordDO.setUserCount(list.size()); | |
| 324 | - updateRecords.add(recordDO); | |
| 325 | - }); | |
| 326 | - } else { // 情况二:团员 | |
| 327 | - // 团长 | |
| 328 | - CombinationRecordDO recordHead = combinationRecordMapper.selectById(headId); | |
| 329 | - // 团员 | |
| 330 | - List<CombinationRecordDO> records = getCombinationRecordListByHeadId(headId); | |
| 331 | - if (CollUtil.isEmpty(records)) { | |
| 332 | - return; | |
| 333 | - } | |
| 334 | - records.add(recordHead); // 加入团长,团长数据也需要更新 | |
| 335 | - records.forEach(item -> { | |
| 336 | - CombinationRecordDO recordDO = new CombinationRecordDO(); | |
| 337 | - recordDO.setId(item.getId()); | |
| 338 | - recordDO.setUserCount(records.size()); | |
| 339 | - updateRecords.add(recordDO); | |
| 340 | - }); | |
| 341 | - } | |
| 342 | - | |
| 343 | - // 更新拼团记录 | |
| 344 | - combinationRecordMapper.updateBatch(updateRecords); | |
| 345 | - } | |
| 346 | - | |
| 347 | - @Override | |
| 348 | 292 | public KeyValue<Integer, Integer> expireCombinationRecord() { |
| 349 | 293 | // 1. 获取所有正在进行中的过期的父拼团 |
| 350 | 294 | List<CombinationRecordDO> headExpireRecords = combinationRecordMapper.selectListByHeadIdAndStatusAndExpireTimeLt( | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java
| ... | ... | @@ -855,12 +855,14 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 855 | 855 | @Override |
| 856 | 856 | @Transactional(rollbackFor = Exception.class) |
| 857 | 857 | public void cancelPaidOrder(Long userId, Long orderId) { |
| 858 | - // TODO 芋艿:这里实现要优化下; | |
| 858 | + // TODO @puhui999:需要校验状态;已支付的情况下,才可以。 | |
| 859 | 859 | TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderId, userId); |
| 860 | 860 | if (order == null) { |
| 861 | 861 | throw exception(ORDER_NOT_FOUND); |
| 862 | 862 | } |
| 863 | 863 | cancelOrder0(order, TradeOrderCancelTypeEnum.MEMBER_CANCEL); |
| 864 | + | |
| 865 | + // TODO @puhui999:需要退款 | |
| 864 | 866 | } |
| 865 | 867 | |
| 866 | 868 | /** | ... | ... |