From 655eefc340bd9225f490c81ce52a242efb6482db Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 28 Aug 2023 09:23:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=AE=A1=E7=90=86=EF=BC=9A?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=AE=A2=E5=8D=95=E7=AE=A1=E7=90=86=E6=8F=90?= =?UTF-8?q?=E5=88=B0=E7=9A=84=E4=B8=80=E4=BA=9B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../trade/enums/ErrorCodeConstants.java | 1 + .../DeliveryPickUpStoreController.java | 9 +++++++-- .../DeliveryPickUpStoreSimpleRespVO.java | 3 ++- .../admin/order/TradeOrderController.java | 12 ++++-------- .../order/TradeOrderUpdateServiceImpl.java | 19 ++++++++++--------- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java index dc757b05e..3aa0e5dd3 100644 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java +++ b/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 { ErrorCode ORDER_DELIVERY_FAIL_REFUND_STATUS_NOT_NONE = new ErrorCode(1011000021, "交易订单发货失败,订单已退款或部分退款"); ErrorCode ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS = new ErrorCode(1011000022, "交易订单发货失败,拼团未成功"); ErrorCode ORDER_DELIVERY_FAIL_BARGAIN_RECORD_STATUS_NOT_SUCCESS = new ErrorCode(1011000023, "交易订单发货失败,砍价未成功"); + ErrorCode ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS = new ErrorCode(1011000024, "交易订单发货失败,发货类型不是快递"); // ========== After Sale 模块 1011000100 ========== ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1011000100, "售后单不存在"); diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java index a8ddec24c..7687ebc64 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java +++ b/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; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.*; import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; @@ -64,10 +66,13 @@ public class DeliveryPickUpStoreController { } @GetMapping("/list-all-simple") - @Operation(summary = "获取快递公司精简信息列表") + @Operation(summary = "获得自提门店精简信息列表") public CommonResult> getSimpleDeliveryPickUpStoreList() { List list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list)); + return success(CollectionUtils.convertList(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list), item -> { + item.setAreaName(AreaUtils.format(item.getAreaId())); + return item; + })); } @GetMapping("/list") diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java index 34c66df4c..c12fc9fc3 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java +++ b/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 { @Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18733") private Integer areaId; - // TODO @puhui999:要把 areaName 也返回哈 + @Schema(description = "区域名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "xx市") + private String areaName; @Schema(description = "门店详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "复旦大学路 188 号") private String detailAddress; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java index 8a28e5ddb..57b21bee0 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java +++ b/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 { tradeOrderQueryService.getExpressTrackList(id, getLoginUserId()))); } - // TODO @puhui999:put 请求哈 - @PostMapping("/delivery") + @PutMapping("/delivery") @Operation(summary = "订单发货") @PreAuthorize("@ss.hasPermission('trade:order:update')") public CommonResult deliveryOrder(@RequestBody TradeOrderDeliveryReqVO deliveryReqVO) { @@ -94,8 +93,7 @@ public class TradeOrderController { return success(true); } - // TODO @puhui999:put 请求哈,update-remark; - @PostMapping("/remark") + @PutMapping("/update-remark") @Operation(summary = "订单备注") @PreAuthorize("@ss.hasPermission('trade:order:update')") public CommonResult updateOrderRemark(@RequestBody TradeOrderRemarkReqVO reqVO) { @@ -103,8 +101,7 @@ public class TradeOrderController { return success(true); } - // TODO @puhui999:put 请求哈,update-price; - @PostMapping("/adjust-price") + @PutMapping("/update-price") @Operation(summary = "订单调价") @PreAuthorize("@ss.hasPermission('trade:order:update')") public CommonResult updateOrderPrice(@RequestBody TradeOrderUpdatePriceReqVO reqVO) { @@ -112,8 +109,7 @@ public class TradeOrderController { return success(true); } - // TODO @puhui999:put 请求哈,update-address; - @PostMapping("/adjust-address") + @PutMapping("/update-address") @Operation(summary = "修改订单收货地址") @PreAuthorize("@ss.hasPermission('trade:order:update')") public CommonResult updateOrderAddress(@RequestBody TradeOrderUpdateAddressReqVO reqVO) { diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java index dd119a64e..989b8c1d8 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java +++ b/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 import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi; import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdateAddressReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdatePriceReqVO; import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderRemarkReqVO; +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdateAddressReqVO; +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdatePriceReqVO; import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO; import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementReqVO; import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementRespVO; @@ -397,7 +397,10 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { // TODO @puhui999:只有选择快递的,才可以发货 // 1.1 校验并获得交易订单(可发货) TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId()); - + // 校验 deliveryType 是否为快递,是快递才可以发货 + if (ObjectUtil.notEqual(order.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getMode())) { + throw exception(ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS); + } // TODO @puhui999:下面不修改 deliveryType,直接校验 deliveryType 是否为快递,是快递才可以发货;先做严格的方式哈。 // 判断发货类型 TradeOrderDO updateOrderObj = new TradeOrderDO(); @@ -411,10 +414,10 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { if (deliveryExpress.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { throw exception(EXPRESS_STATUS_NOT_ENABLE); } - updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()).setDeliveryType(DeliveryTypeEnum.EXPRESS.getMode()); + updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()); } else { // 2.2 无需发货 - updateOrderObj.setLogisticsId(0L).setLogisticsNo("").setDeliveryType(DeliveryTypeEnum.NULL.getMode()); + updateOrderObj.setLogisticsId(0L).setLogisticsNo(""); } // 更新 TradeOrderDO 状态为已发货,等待收货 updateOrderObj.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now()); @@ -454,16 +457,14 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { // 订单类型:拼团 if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) { // 校验订单拼团是否成功 - // TODO @puhui999:是不是取反? - if (combinationRecordApi.isCombinationRecordSuccess(order.getUserId(), order.getId())) { + if (!combinationRecordApi.isCombinationRecordSuccess(order.getUserId(), order.getId())) { throw exception(ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS); } } // 订单类类型:砍价 if (Objects.equals(TradeOrderTypeEnum.BARGAIN.getType(), order.getType())) { // 校验订单砍价是否成功 - // TODO @puhui999:是不是取反? - if (bargainRecordApi.isBargainRecordSuccess(order.getUserId(), order.getId())) { + if (!bargainRecordApi.isBargainRecordSuccess(order.getUserId(), order.getId())) { throw exception(ORDER_DELIVERY_FAIL_BARGAIN_RECORD_STATUS_NOT_SUCCESS); } }