Commit 655eefc340bd9225f490c81ce52a242efb6482db

Authored by puhui999
1 parent 60875a04

订单管理:完善订单管理提到的一些问题

yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java
... ... @@ -32,6 +32,7 @@ public interface ErrorCodeConstants {
32 32 ErrorCode ORDER_DELIVERY_FAIL_REFUND_STATUS_NOT_NONE = new ErrorCode(1011000021, "交易订单发货失败,订单已退款或部分退款");
33 33 ErrorCode ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS = new ErrorCode(1011000022, "交易订单发货失败,拼团未成功");
34 34 ErrorCode ORDER_DELIVERY_FAIL_BARGAIN_RECORD_STATUS_NOT_SUCCESS = new ErrorCode(1011000023, "交易订单发货失败,砍价未成功");
  35 + ErrorCode ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS = new ErrorCode(1011000024, "交易订单发货失败,发货类型不是快递");
35 36  
36 37 // ========== After Sale 模块 1011000100 ==========
37 38 ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1011000100, "售后单不存在");
... ...
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java
... ... @@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery;
3 3 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
4 4 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
5 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
  7 +import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
6 8 import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.*;
7 9 import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert;
8 10 import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO;
... ... @@ -64,10 +66,13 @@ public class DeliveryPickUpStoreController {
64 66 }
65 67  
66 68 @GetMapping("/list-all-simple")
67   - @Operation(summary = "获取快递公司精简信息列表")
  69 + @Operation(summary = "获得自提门店精简信息列表")
68 70 public CommonResult<List<DeliveryPickUpStoreSimpleRespVO>> getSimpleDeliveryPickUpStoreList() {
69 71 List<DeliveryPickUpStoreDO> list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus(CommonStatusEnum.ENABLE.getStatus());
70   - return success(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list));
  72 + return success(CollectionUtils.convertList(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list), item -> {
  73 + item.setAreaName(AreaUtils.format(item.getAreaId()));
  74 + return item;
  75 + }));
71 76 }
72 77  
73 78 @GetMapping("/list")
... ...
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java
... ... @@ -23,7 +23,8 @@ public class DeliveryPickUpStoreSimpleRespVO {
23 23 @Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18733")
24 24 private Integer areaId;
25 25  
26   - // TODO @puhui999:要把 areaName 也返回哈
  26 + @Schema(description = "区域名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "xx市")
  27 + private String areaName;
27 28  
28 29 @Schema(description = "门店详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "复旦大学路 188 号")
29 30 private String detailAddress;
... ...
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java
... ... @@ -85,8 +85,7 @@ public class TradeOrderController {
85 85 tradeOrderQueryService.getExpressTrackList(id, getLoginUserId())));
86 86 }
87 87  
88   - // TODO @puhui999:put 请求哈
89   - @PostMapping("/delivery")
  88 + @PutMapping("/delivery")
90 89 @Operation(summary = "订单发货")
91 90 @PreAuthorize("@ss.hasPermission('trade:order:update')")
92 91 public CommonResult<Boolean> deliveryOrder(@RequestBody TradeOrderDeliveryReqVO deliveryReqVO) {
... ... @@ -94,8 +93,7 @@ public class TradeOrderController {
94 93 return success(true);
95 94 }
96 95  
97   - // TODO @puhui999:put 请求哈,update-remark;
98   - @PostMapping("/remark")
  96 + @PutMapping("/update-remark")
99 97 @Operation(summary = "订单备注")
100 98 @PreAuthorize("@ss.hasPermission('trade:order:update')")
101 99 public CommonResult<Boolean> updateOrderRemark(@RequestBody TradeOrderRemarkReqVO reqVO) {
... ... @@ -103,8 +101,7 @@ public class TradeOrderController {
103 101 return success(true);
104 102 }
105 103  
106   - // TODO @puhui999:put 请求哈,update-price;
107   - @PostMapping("/adjust-price")
  104 + @PutMapping("/update-price")
108 105 @Operation(summary = "订单调价")
109 106 @PreAuthorize("@ss.hasPermission('trade:order:update')")
110 107 public CommonResult<Boolean> updateOrderPrice(@RequestBody TradeOrderUpdatePriceReqVO reqVO) {
... ... @@ -112,8 +109,7 @@ public class TradeOrderController {
112 109 return success(true);
113 110 }
114 111  
115   - // TODO @puhui999:put 请求哈,update-address;
116   - @PostMapping("/adjust-address")
  112 + @PutMapping("/update-address")
117 113 @Operation(summary = "修改订单收货地址")
118 114 @PreAuthorize("@ss.hasPermission('trade:order:update')")
119 115 public CommonResult<Boolean> updateOrderAddress(@RequestBody TradeOrderUpdateAddressReqVO reqVO) {
... ...
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java
... ... @@ -29,10 +29,10 @@ import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUp
29 29 import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi;
30 30 import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO;
31 31 import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
32   -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdateAddressReqVO;
33   -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdatePriceReqVO;
34 32 import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO;
35 33 import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderRemarkReqVO;
  34 +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdateAddressReqVO;
  35 +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdatePriceReqVO;
36 36 import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO;
37 37 import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementReqVO;
38 38 import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementRespVO;
... ... @@ -397,7 +397,10 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
397 397 // TODO @puhui999:只有选择快递的,才可以发货
398 398 // 1.1 校验并获得交易订单(可发货)
399 399 TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId());
400   -
  400 + // 校验 deliveryType 是否为快递,是快递才可以发货
  401 + if (ObjectUtil.notEqual(order.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getMode())) {
  402 + throw exception(ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS);
  403 + }
401 404 // TODO @puhui999:下面不修改 deliveryType,直接校验 deliveryType 是否为快递,是快递才可以发货;先做严格的方式哈。
402 405 // 判断发货类型
403 406 TradeOrderDO updateOrderObj = new TradeOrderDO();
... ... @@ -411,10 +414,10 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
411 414 if (deliveryExpress.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) {
412 415 throw exception(EXPRESS_STATUS_NOT_ENABLE);
413 416 }
414   - updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()).setDeliveryType(DeliveryTypeEnum.EXPRESS.getMode());
  417 + updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo());
415 418 } else {
416 419 // 2.2 无需发货
417   - updateOrderObj.setLogisticsId(0L).setLogisticsNo("").setDeliveryType(DeliveryTypeEnum.NULL.getMode());
  420 + updateOrderObj.setLogisticsId(0L).setLogisticsNo("");
418 421 }
419 422 // 更新 TradeOrderDO 状态为已发货,等待收货
420 423 updateOrderObj.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now());
... ... @@ -454,16 +457,14 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
454 457 // 订单类型:拼团
455 458 if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) {
456 459 // 校验订单拼团是否成功
457   - // TODO @puhui999:是不是取反?
458   - if (combinationRecordApi.isCombinationRecordSuccess(order.getUserId(), order.getId())) {
  460 + if (!combinationRecordApi.isCombinationRecordSuccess(order.getUserId(), order.getId())) {
459 461 throw exception(ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS);
460 462 }
461 463 }
462 464 // 订单类类型:砍价
463 465 if (Objects.equals(TradeOrderTypeEnum.BARGAIN.getType(), order.getType())) {
464 466 // 校验订单砍价是否成功
465   - // TODO @puhui999:是不是取反?
466   - if (bargainRecordApi.isBargainRecordSuccess(order.getUserId(), order.getId())) {
  467 + if (!bargainRecordApi.isBargainRecordSuccess(order.getUserId(), order.getId())) {
467 468 throw exception(ORDER_DELIVERY_FAIL_BARGAIN_RECORD_STATUS_NOT_SUCCESS);
468 469 }
469 470 }
... ...