From c2b6c0d72a0520ff7b8b14920796db10c1539034 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Tue, 22 Aug 2023 00:42:20 +0800 Subject: [PATCH 1/5] =?UTF-8?q?fix:=20=E8=AE=A2=E5=8D=95=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E9=87=8D=E6=9E=84=20=E2=91=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bargain/vo/BargainActivityBaseVO.java | 2 +- .../delivery/DeliveryExpressController.java | 11 ++++++++- .../express/DeliveryExpressSimpleRespVO.java | 24 +++++++++++++++++++ .../admin/order/TradeOrderController.java | 20 ++++++++++++---- .../order/vo/TradeOrderDeliveryReqVO.java | 8 ------- .../admin/order/vo/TradeOrderRemarkReqVO.java | 21 ++++++++++++++++ .../delivery/DeliveryExpressConvert.java | 11 ++++----- .../mysql/delivery/DeliveryExpressMapper.java | 5 ++++ .../delivery/DeliveryExpressService.java | 14 ++++++++--- .../delivery/DeliveryExpressServiceImpl.java | 14 +++++++---- .../order/TradeOrderUpdateService.java | 9 +++++++ .../order/TradeOrderUpdateServiceImpl.java | 22 ++++++++++++----- .../aftersale/TradeAfterSaleServiceTest.java | 7 ++++-- 13 files changed, 132 insertions(+), 36 deletions(-) create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressSimpleRespVO.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderRemarkReqVO.java diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/BargainActivityBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/BargainActivityBaseVO.java index 7387ae4cf..a4865bc5c 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/BargainActivityBaseVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/BargainActivityBaseVO.java @@ -18,7 +18,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data public class BargainActivityBaseVO { - @Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "越拼越省钱") + @Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "砍得越多省得越多,是兄弟就来砍我") @NotNull(message = "砍价名称不能为空") private String name; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java index cff98a558..4fecd5ab1 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java @@ -1,11 +1,11 @@ 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.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.*; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressUpdateReqVO; import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressConvert; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; @@ -67,6 +67,15 @@ public class DeliveryExpressController { return success(DeliveryExpressConvert.INSTANCE.convert(deliveryExpress)); } + @GetMapping("/list-all-simple") + @Operation(summary = "获取快递公司精简信息列表", description = "主要用于前端的下拉选项") + public CommonResult> getSimpleBrandList() { + // 获取品牌列表,只要开启状态的 + List list = deliveryExpressService.getDeliveryExpressListByStatus(CommonStatusEnum.ENABLE.getStatus()); + // 排序后,返回给前端 + return success(DeliveryExpressConvert.INSTANCE.convertList1(list)); + } + @GetMapping("/page") @Operation(summary = "获得快递公司分页") @PreAuthorize("@ss.hasPermission('trade:delivery:express:query')") diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressSimpleRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressSimpleRespVO.java new file mode 100644 index 000000000..b97cc2317 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressSimpleRespVO.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 快递公司精简信息 Response VO") +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DeliveryExpressSimpleRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6592") + @NotNull(message = "编号不能为空") + private Long id; + + @Schema(description = "快递公司名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "顺丰速运") + @NotNull(message = "快递公司名称不能为空") + private String name; + +} 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 786be10d7..bff002d1b 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 @@ -7,10 +7,7 @@ import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; import cn.iocoder.yudao.module.product.api.property.ProductPropertyValueApi; import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageItemRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.*; import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; @@ -97,4 +94,19 @@ public class TradeOrderController { return success(true); } + @PostMapping("/remark") + @Operation(summary = "发货订单") + @PreAuthorize("@ss.hasPermission('trade:order:remark')") + public CommonResult remarkOrder(@RequestBody TradeOrderRemarkReqVO remarkReqVO) { + tradeOrderUpdateService.remarkOrder(getLoginUserId(), remarkReqVO); + return success(true); + } + + // TODO @puhui999 订单物流详情 + // TODO @puhui999 【前台】订单取消 + // TODO @puhui999 【后台】订单取消 + // TODO @puhui999 【前台】订单核销 + // TODO @puhui999 【前台】订单删除 + // TODO @puhui999 【后台】订单统计 + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java index a14c91390..e19747a79 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java @@ -1,7 +1,5 @@ package cn.iocoder.yudao.module.trade.controller.admin.order.vo; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -16,12 +14,6 @@ public class TradeOrderDeliveryReqVO { @NotNull(message = "订单编号不能为空") private Long id; - // TODO @puhui999:可以去掉 type;如果无需发货,则 logisticsId 传递 0;logisticsNo 传递空串 - @Schema(description = "发货类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @InEnum(DeliveryTypeEnum.class) - @NotNull(message = "发货类型不能为空") - private Integer type; - @Schema(description = "发货物流公司编号", example = "1") @NotNull(message = "发货物流公司不能为空") private Long logisticsId; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderRemarkReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderRemarkReqVO.java new file mode 100644 index 000000000..4ef8da40e --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderRemarkReqVO.java @@ -0,0 +1,21 @@ +package cn.iocoder.yudao.module.trade.controller.admin.order.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 订单备注 Request VO") +@Data +public class TradeOrderRemarkReqVO { + + @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @NotNull(message = "订单编号不能为空") + private Long id; + + @Schema(description = "商家备注", example = "你猜一下") + @NotEmpty(message = "订单备注不能为空") + private String remark; + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressConvert.java index c4529ba89..3cf2c6f05 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressConvert.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressConvert.java @@ -1,17 +1,13 @@ package cn.iocoder.yudao.module.trade.convert.delivery; -import java.util.*; - import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExcelVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressUpdateReqVO; +import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.*; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; +import java.util.List; + @Mapper public interface DeliveryExpressConvert { @@ -29,4 +25,5 @@ public interface DeliveryExpressConvert { List convertList02(List list); + List convertList1(List list); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressMapper.java index f74318e56..59e7cf02e 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressMapper.java @@ -36,6 +36,11 @@ public interface DeliveryExpressMapper extends BaseMapperX { return selectOne(new LambdaQueryWrapper() .eq(DeliveryExpressDO::getCode, code)); } + + default List selectListByStatus(Integer status) { + return selectList(DeliveryExpressDO::getStatus, status); + } + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressService.java index b6fffa87a..a8167e460 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressService.java @@ -1,8 +1,5 @@ package cn.iocoder.yudao.module.trade.service.delivery; -import java.util.*; -import javax.validation.*; - import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressCreateReqVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExportReqVO; @@ -10,6 +7,10 @@ import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.Delive import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressUpdateReqVO; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; +import javax.validation.Valid; +import java.util.Collection; +import java.util.List; + /** * 快递公司 Service 接口 * @@ -71,4 +72,11 @@ public interface DeliveryExpressService { */ List getDeliveryExpressList(DeliveryExpressExportReqVO exportReqVO); + /** + * 获取指定状态的快递公司列表 + * + * @param status 状态 + * @return 返回快递公司列表 + */ + List getDeliveryExpressListByStatus(Integer status); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressServiceImpl.java index 2f08b0b3f..9236728d0 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressServiceImpl.java @@ -9,14 +9,15 @@ import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressConvert; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryExpressMapper; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; -import java.util.*; - +import javax.annotation.Resource; +import java.util.Collection; +import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_CODE_DUPLICATE; +import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_NOT_EXISTS; /** * 快递公司 Service 实现类 @@ -99,4 +100,9 @@ public class DeliveryExpressServiceImpl implements DeliveryExpressService { return deliveryExpressMapper.selectList(exportReqVO); } + @Override + public List getDeliveryExpressListByStatus(Integer status) { + return deliveryExpressMapper.selectListByStatus(status); + } + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java index 92183efb3..0e5e69734 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.trade.service.order; 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.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; @@ -60,6 +61,14 @@ public interface TradeOrderUpdateService { */ void receiveOrder(Long userId, Long id); + /** + * 【管理员】交易订单备注 + * + * @param loginUserId 管理员编号 + * @param remarkReqVO 备注请求 + */ + void remarkOrder(Long loginUserId, TradeOrderRemarkReqVO remarkReqVO); + // =================== Order Item =================== /** 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 5137c3ce4..2e0f9dfdc 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 @@ -30,6 +30,7 @@ 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.TradeOrderDeliveryReqVO; +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderRemarkReqVO; 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; @@ -398,7 +399,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { TradeOrderDO updateOrderObj = new TradeOrderDO(); // 判断发货类型 // 2.1 快递发货 - if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.EXPRESS.getMode())) { + if (ObjectUtil.notEqual(deliveryReqVO.getLogisticsId(), 0L)) { // 校验快递公司 DeliveryExpressDO deliveryExpress = deliveryExpressService.getDeliveryExpress(deliveryReqVO.getLogisticsId()); if (deliveryExpress == null) { @@ -408,11 +409,9 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { throw exception(EXPRESS_STATUS_NOT_ENABLE); } updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()).setDeliveryType(DeliveryTypeEnum.EXPRESS.getMode()); - } - // TODO @puhui999:无需发货时,更新 logisticsId 为 0; - // 2.2 无需发货 - if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.NULL.getMode())) { - updateOrderObj.setLogisticsId(null).setLogisticsNo("").setDeliveryType(DeliveryTypeEnum.NULL.getMode()); + } else { + // 2.2 无需发货 + updateOrderObj.setLogisticsId(0L).setLogisticsNo("").setDeliveryType(DeliveryTypeEnum.NULL.getMode()); } // 更新 TradeOrderDO 状态为已发货,等待收货 @@ -489,6 +488,17 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { // TODO 芋艿:lili 发送商品被购买完成的数据 } + @Override + public void remarkOrder(Long loginUserId, TradeOrderRemarkReqVO remarkReqVO) { + // 校验并获得交易订单 + validateOrderDeliverable(remarkReqVO.getId()); + + TradeOrderDO updateOrderObj = new TradeOrderDO(); + updateOrderObj.setId(remarkReqVO.getId()); + updateOrderObj.setRemark(remarkReqVO.getRemark()); + tradeOrderMapper.updateById(updateOrderObj); + } + /** * 校验交易订单满足可售货的条件 * diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceTest.java index c1224d228..b7b1e00ba 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceTest.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceTest.java @@ -18,6 +18,7 @@ import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleWayEnum; import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; +import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; import org.junit.jupiter.api.Test; import org.springframework.boot.test.mock.mockito.MockBean; @@ -54,6 +55,8 @@ public class TradeAfterSaleServiceTest extends BaseDbUnitTest { @MockBean private TradeOrderUpdateService tradeOrderService; @MockBean + private TradeOrderQueryService tradeOrderQueryService; + @MockBean private PayRefundApi payRefundApi; @MockBean @@ -72,12 +75,12 @@ public class TradeAfterSaleServiceTest extends BaseDbUnitTest { o.setOrderId(111L).setUserId(userId).setPayPrice(200); o.setAfterSaleStatus(TradeOrderItemAfterSaleStatusEnum.NONE.getStatus()); }); - when(tradeOrderService.getOrderItem(eq(1024L), eq(1L))) + when(tradeOrderQueryService.getOrderItem(eq(1024L), eq(1L))) .thenReturn(orderItem); // mock 方法(交易订单) TradeOrderDO order = randomPojo(TradeOrderDO.class, o -> o.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()) .setNo("202211301234")); - when(tradeOrderService.getOrder(eq(1024L), eq(111L))).thenReturn(order); + when(tradeOrderQueryService.getOrder(eq(1024L), eq(111L))).thenReturn(order); // 调用 Long afterSaleId = tradeAfterSaleService.createAfterSale(userId, createReqVO); From 716f11e80ba544c83e7018b77aab9cae4d907c68 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Tue, 22 Aug 2023 00:57:36 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20=E5=90=88=E5=B9=B6=E5=B7=AE=E5=BC=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../trade/controller/admin/order/TradeOrderController.java | 5 +---- .../controller/app/delivery/AppDeliverExpressController.java | 2 +- .../trade/service/aftersale/TradeAfterSaleServiceTest.java | 3 +-- 3 files changed, 3 insertions(+), 7 deletions(-) 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 bc1d766a3..31b3fd79d 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 @@ -5,10 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageItemRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.*; import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverExpressController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverExpressController.java index e1ad1b705..20cdef588 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverExpressController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverExpressController.java @@ -31,7 +31,7 @@ public class AppDeliverExpressController { @GetMapping("/list") @Operation(summary = "获得快递公司列表") public CommonResult> getDeliveryExpressList() { - List list = deliveryExpressService.getDeliveryExpressList(CommonStatusEnum.ENABLE.getStatus()); + List list = deliveryExpressService.getDeliveryExpressListByStatus(CommonStatusEnum.ENABLE.getStatus()); list.sort(Comparator.comparing(DeliveryExpressDO::getSort)); return success(DeliveryExpressConvert.INSTANCE.convertList03(list)); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceTest.java index 736371ba0..7c3c6055c 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceTest.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceTest.java @@ -56,8 +56,7 @@ public class TradeAfterSaleServiceTest extends BaseDbUnitTest { private TradeOrderUpdateService tradeOrderUpdateService; @Resource private TradeOrderQueryService tradeOrderQueryService; - @MockBean - private TradeOrderQueryService tradeOrderQueryService; + @MockBean private PayRefundApi payRefundApi; From d29c5a556ca59c137ba0cded9ddb931313d92a92 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Tue, 22 Aug 2023 12:19:25 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=AE=A1=E7=90=86?= =?UTF-8?q?=EF=BC=9A=E6=B7=BB=E5=8A=A0=E4=BF=AE=E6=94=B9=E5=A4=87=E6=B3=A8?= =?UTF-8?q?=E3=80=81=E8=AE=A2=E5=8D=95=E8=B0=83=E4=BB=B7=E3=80=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=9C=B0=E5=9D=80=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/order/TradeOrderController.java | 27 ++++++-- .../vo/TradeOrderAdjustAddressReqVO.java | 33 ++++++++++ .../order/vo/TradeOrderAdjustPriceReqVO.java | 20 ++++++ .../convert/order/TradeOrderConvert.java | 9 ++- .../order/TradeOrderUpdateService.java | 40 +++++++---- .../order/TradeOrderUpdateServiceImpl.java | 66 ++++++++++++++----- .../order/TradeOrderUpdateServiceTest.java | 8 ++- .../module/pay/enums/ErrorCodeConstants.java | 1 + 8 files changed, 163 insertions(+), 41 deletions(-) create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderAdjustAddressReqVO.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderAdjustPriceReqVO.java 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 31b3fd79d..35f2226a2 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 @@ -25,7 +25,6 @@ import java.util.Map; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; @Tag(name = "管理后台 - 交易订单") @RestController @@ -78,17 +77,33 @@ public class TradeOrderController { @PostMapping("/delivery") @Operation(summary = "发货订单") - @PreAuthorize("@ss.hasPermission('trade:order:delivery')") + @PreAuthorize("@ss.hasPermission('trade:order:update')") public CommonResult deliveryOrder(@RequestBody TradeOrderDeliveryReqVO deliveryReqVO) { - tradeOrderUpdateService.deliveryOrder(getLoginUserId(), deliveryReqVO); + tradeOrderUpdateService.deliveryOrder(deliveryReqVO); return success(true); } @PostMapping("/remark") @Operation(summary = "发货订单") - @PreAuthorize("@ss.hasPermission('trade:order:remark')") - public CommonResult remarkOrder(@RequestBody TradeOrderRemarkReqVO remarkReqVO) { - tradeOrderUpdateService.remarkOrder(getLoginUserId(), remarkReqVO); + @PreAuthorize("@ss.hasPermission('trade:order:update')") + public CommonResult remarkOrder(@RequestBody TradeOrderRemarkReqVO reqVO) { + tradeOrderUpdateService.remarkOrder(reqVO); + return success(true); + } + + @PostMapping("/adjust-price") + @Operation(summary = "发货订单") + @PreAuthorize("@ss.hasPermission('trade:order:update')") + public CommonResult adjustPrice(@RequestBody TradeOrderAdjustPriceReqVO reqVO) { + tradeOrderUpdateService.adjustPrice(reqVO); + return success(true); + } + + @PostMapping("/adjust-address") + @Operation(summary = "发货订单") + @PreAuthorize("@ss.hasPermission('trade:order:update')") + public CommonResult adjustAddress(@RequestBody TradeOrderAdjustAddressReqVO reqVO) { + tradeOrderUpdateService.adjustAddress(reqVO); return success(true); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderAdjustAddressReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderAdjustAddressReqVO.java new file mode 100644 index 000000000..5ea530b29 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderAdjustAddressReqVO.java @@ -0,0 +1,33 @@ +package cn.iocoder.yudao.module.trade.controller.admin.order.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 订单修改地址 Request VO") +@Data +public class TradeOrderAdjustAddressReqVO { + + @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "订单编号不能为空") + private Long id; + + @Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "z张三") + @NotEmpty(message = "收件人名称不能为空") + private String receiverName; + + @Schema(description = "收件人手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "19988188888") + @NotEmpty(message = "收件人手机不能为空") + private String receiverMobile; + + @Schema(description = "收件人地区编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7310") + @NotNull(message = "收件人地区编号不能为空") + private Integer receiverAreaId; + + @Schema(description = "收件人详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "昆明市五华区xxx小区xxx") + @NotEmpty(message = "收件人详细地址不能为空") + private String receiverDetailAddress; + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderAdjustPriceReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderAdjustPriceReqVO.java new file mode 100644 index 000000000..bed7ac0e9 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderAdjustPriceReqVO.java @@ -0,0 +1,20 @@ +package cn.iocoder.yudao.module.trade.controller.admin.order.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 订单改价 Request VO") +@Data +public class TradeOrderAdjustPriceReqVO { + + @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @NotNull(message = "订单编号不能为空") + private Long id; + + @Schema(description = "订单调价,单位:分 正数,加价;负数,减价", requiredMode = Schema.RequiredMode.REQUIRED, example = "-100") + @NotNull(message = "订单调价价格不能为空") + private Integer adjustPrice; + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java index 3728ea58b..4d83a46f7 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java @@ -17,8 +17,7 @@ import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCr import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageItemRespVO; +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.*; import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; import cn.iocoder.yudao.module.trade.controller.app.order.vo.*; import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; @@ -278,4 +277,10 @@ public interface TradeOrderConvert { List convertList02(List list); + TradeOrderDO convert(TradeOrderAdjustAddressReqVO reqVO); + + TradeOrderDO convert(TradeOrderAdjustPriceReqVO reqVO); + + TradeOrderDO convert(TradeOrderRemarkReqVO reqVO); + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java index 853579a84..217ba154c 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java @@ -1,5 +1,7 @@ package cn.iocoder.yudao.module.trade.service.order; +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderAdjustAddressReqVO; +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderAdjustPriceReqVO; 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.app.order.vo.AppTradeOrderCreateReqVO; @@ -21,7 +23,7 @@ public interface TradeOrderUpdateService { /** * 获得订单结算信息 * - * @param userId 登录用户 + * @param userId 登录用户 * @param settlementReqVO 订单结算请求 * @return 订单结算结果 */ @@ -30,8 +32,8 @@ public interface TradeOrderUpdateService { /** * 【会员】创建交易订单 * - * @param userId 登录用户 - * @param userIp 用户 IP 地址 + * @param userId 登录用户 + * @param userIp 用户 IP 地址 * @param createReqVO 创建交易订单请求模型 * @return 交易订单的 */ @@ -40,7 +42,7 @@ public interface TradeOrderUpdateService { /** * 更新交易订单已支付 * - * @param id 交易订单编号 + * @param id 交易订单编号 * @param payOrderId 支付订单编号 */ void updateOrderPaid(Long id, Long payOrderId); @@ -48,10 +50,9 @@ public interface TradeOrderUpdateService { /** * 【管理员】发货交易订单 * - * @param userId 管理员编号 * @param deliveryReqVO 发货请求 */ - void deliveryOrder(Long userId, TradeOrderDeliveryReqVO deliveryReqVO); + void deliveryOrder(TradeOrderDeliveryReqVO deliveryReqVO); /** * 【会员】收货交易订单 @@ -64,17 +65,30 @@ public interface TradeOrderUpdateService { /** * 【管理员】交易订单备注 * - * @param loginUserId 管理员编号 - * @param remarkReqVO 备注请求 + * @param reqVO 请求 */ - void remarkOrder(Long loginUserId, TradeOrderRemarkReqVO remarkReqVO); + void remarkOrder(TradeOrderRemarkReqVO reqVO); + + /** + * 调整价格 + * + * @param reqVO 请求 + */ + void adjustPrice(TradeOrderAdjustPriceReqVO reqVO); + + /** + * 调整地址 + * + * @param reqVO 请求 + */ + void adjustAddress(TradeOrderAdjustAddressReqVO reqVO); // =================== Order Item =================== /** * 更新交易订单项的售后状态 * - * @param id 交易订单项编号 + * @param id 交易订单项编号 * @param oldAfterSaleStatus 当前售后状态;如果不符,更新后会抛出异常 * @param newAfterSaleStatus 目标售后状态 */ @@ -85,11 +99,11 @@ public interface TradeOrderUpdateService { /** * 更新交易订单项的售后状态 * - * @param id 交易订单项编号 + * @param id 交易订单项编号 * @param oldAfterSaleStatus 当前售后状态;如果不符,更新后会抛出异常 * @param newAfterSaleStatus 目标售后状态 - * @param afterSaleId 售后单编号;当订单项发起售后时,必须传递该字段 - * @param refundPrice 退款金额;当订单项退款成功时,必须传递该值 + * @param afterSaleId 售后单编号;当订单项发起售后时,必须传递该字段 + * @param refundPrice 退款金额;当订单项退款成功时,必须传递该值 */ void updateOrderItemAfterSaleStatus(Long id, Integer oldAfterSaleStatus, Integer newAfterSaleStatus, Long afterSaleId, Integer refundPrice); 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 6b92ef993..934a46fdf 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,6 +29,8 @@ 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.TradeOrderAdjustAddressReqVO; +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderAdjustPriceReqVO; 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.app.order.vo.AppTradeOrderCreateReqVO; @@ -54,6 +56,7 @@ import cn.iocoder.yudao.module.trade.service.price.TradePriceService; import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NotNull; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -65,6 +68,7 @@ import java.util.Objects; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.ORDER_NOT_FOUND; +import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.ORDER_PAID_NO_ADJUST_PRICE; import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; /** @@ -346,10 +350,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { */ private KeyValue validateOrderPayable(Long id, Long payOrderId) { // 校验订单是否存在 - TradeOrderDO order = tradeOrderMapper.selectById(id); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } + TradeOrderDO order = validateOrder(id); // 校验订单未支付 if (!TradeOrderStatusEnum.isUnpaid(order.getStatus()) || order.getPayStatus()) { log.error("[validateOrderPaid][order({}) 不处于待支付状态,请进行处理!order 数据是:{}]", @@ -392,7 +393,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { @Override @Transactional(rollbackFor = Exception.class) - public void deliveryOrder(Long userId, TradeOrderDeliveryReqVO deliveryReqVO) { + public void deliveryOrder(TradeOrderDeliveryReqVO deliveryReqVO) { // TODO @puhui999:只有选择快递的,才可以发货 // 1.1 校验并获得交易订单(可发货) TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId()); @@ -424,7 +425,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { // 发送站内信 tradeMessageService.sendMessageWhenDeliveryOrder(new TradeOrderMessageWhenDeliveryOrderReqBO().setOrderId(order.getId()) - .setUserId(userId).setMessage(null)); + .setUserId(order.getUserId()).setMessage(null)); // TODO 芋艿:OrderLog // TODO 设计:lili:是不是发货后,才支持售后? @@ -439,11 +440,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { * @return 交易订单 */ private TradeOrderDO validateOrderDeliverable(Long id) { - // 校验订单是否存在 - TradeOrderDO order = tradeOrderMapper.selectById(id); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } + TradeOrderDO order = validateOrder(id); // 校验订单是否是待发货状态 if (!TradeOrderStatusEnum.isUndelivered(order.getStatus())) { throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED); @@ -469,6 +466,16 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { return order; } + @NotNull + private TradeOrderDO validateOrder(Long id) { + // 校验订单是否存在 + TradeOrderDO order = tradeOrderMapper.selectById(id); + if (order == null) { + throw exception(ORDER_NOT_FOUND); + } + return order; + } + @Override @Transactional(rollbackFor = Exception.class) public void receiveOrder(Long userId, Long id) { @@ -489,14 +496,39 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { } @Override - public void remarkOrder(Long loginUserId, TradeOrderRemarkReqVO remarkReqVO) { + public void remarkOrder(TradeOrderRemarkReqVO reqVO) { // 校验并获得交易订单 - validateOrderDeliverable(remarkReqVO.getId()); + validateOrder(reqVO.getId()); - TradeOrderDO updateOrderObj = new TradeOrderDO(); - updateOrderObj.setId(remarkReqVO.getId()); - updateOrderObj.setRemark(remarkReqVO.getRemark()); - tradeOrderMapper.updateById(updateOrderObj); + // 更新 + TradeOrderDO order = TradeOrderConvert.INSTANCE.convert(reqVO); + tradeOrderMapper.updateById(order); + } + + @Override + public void adjustPrice(TradeOrderAdjustPriceReqVO reqVO) { + // 校验交易订单 + TradeOrderDO order = validateOrder(reqVO.getId()); + if (order.getPayStatus()) { + throw exception(ORDER_PAID_NO_ADJUST_PRICE); + } + + // 更新 + TradeOrderDO update = TradeOrderConvert.INSTANCE.convert(reqVO); + update.setPayPrice(update.getPayPrice() + update.getAdjustPrice()); + tradeOrderMapper.updateById(update); + } + + @Override + public void adjustAddress(TradeOrderAdjustAddressReqVO reqVO) { + // 校验交易订单 + validateOrder(reqVO.getId()); + // TODO 是否需要校验订单是否发货 + // TODO 发货后是否支持修改收货地址 + + // 更新 + TradeOrderDO update = TradeOrderConvert.INSTANCE.convert(reqVO); + tradeOrderMapper.updateById(update); } /** diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceTest.java index 313d1874e..284ab7ccf 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceTest.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceTest.java @@ -23,7 +23,10 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper; import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderMapper; -import cn.iocoder.yudao.module.trade.enums.order.*; +import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; +import cn.iocoder.yudao.module.trade.enums.order.TradeOrderRefundStatusEnum; +import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; +import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderConfig; import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; import org.junit.jupiter.api.BeforeEach; @@ -38,7 +41,6 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.*; @@ -282,7 +284,7 @@ public class TradeOrderUpdateServiceTest extends BaseDbUnitTest { // mock 方法(支付单) // 调用 - tradeOrderUpdateService.deliveryOrder(randomLongId(), deliveryReqVO); + tradeOrderUpdateService.deliveryOrder(deliveryReqVO); // 断言 TradeOrderDO dbOrder = tradeOrderMapper.selectById(1L); assertEquals(dbOrder.getStatus(), TradeOrderStatusEnum.DELIVERED.getStatus()); diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java index 8e2f935fc..e1c933fd1 100644 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java +++ b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java @@ -27,6 +27,7 @@ public interface ErrorCodeConstants { ErrorCode ORDER_IS_EXPIRED = new ErrorCode(1007002003, "支付订单已经过期"); ErrorCode ORDER_SUBMIT_CHANNEL_ERROR = new ErrorCode(1007002004, "发起支付报错,错误码:{},错误提示:{}"); ErrorCode ORDER_REFUND_FAIL_STATUS_ERROR = new ErrorCode(1007002005, "支付订单退款失败,原因:状态不是已支付或已退款"); + ErrorCode ORDER_PAID_NO_ADJUST_PRICE = new ErrorCode(1007002006, "支付订单调价失败,原因:支付订单已付款,不能调价"); // ========== ORDER 模块(拓展单) 1007003000 ========== ErrorCode ORDER_EXTENSION_NOT_FOUND = new ErrorCode(1007003000, "支付交易拓展单不存在"); From d2c135eda94c9cbbdb1c1393cb073a6b74bcdc65 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Tue, 22 Aug 2023 16:31:28 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=AE=A1=E7=90=86?= =?UTF-8?q?=EF=BC=9A=E6=B7=BB=E5=8A=A0=E4=BF=AE=E6=94=B9=E5=A4=87=E6=B3=A8?= =?UTF-8?q?=E3=80=81=E8=AE=A2=E5=8D=95=E8=B0=83=E4=BB=B7=E3=80=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=9C=B0=E5=9D=80=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/order/TradeOrderController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 35f2226a2..61d361c0b 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 @@ -76,7 +76,7 @@ public class TradeOrderController { } @PostMapping("/delivery") - @Operation(summary = "发货订单") + @Operation(summary = "订单发货") @PreAuthorize("@ss.hasPermission('trade:order:update')") public CommonResult deliveryOrder(@RequestBody TradeOrderDeliveryReqVO deliveryReqVO) { tradeOrderUpdateService.deliveryOrder(deliveryReqVO); @@ -84,7 +84,7 @@ public class TradeOrderController { } @PostMapping("/remark") - @Operation(summary = "发货订单") + @Operation(summary = "订单备注") @PreAuthorize("@ss.hasPermission('trade:order:update')") public CommonResult remarkOrder(@RequestBody TradeOrderRemarkReqVO reqVO) { tradeOrderUpdateService.remarkOrder(reqVO); @@ -92,7 +92,7 @@ public class TradeOrderController { } @PostMapping("/adjust-price") - @Operation(summary = "发货订单") + @Operation(summary = "订单调价") @PreAuthorize("@ss.hasPermission('trade:order:update')") public CommonResult adjustPrice(@RequestBody TradeOrderAdjustPriceReqVO reqVO) { tradeOrderUpdateService.adjustPrice(reqVO); @@ -100,7 +100,7 @@ public class TradeOrderController { } @PostMapping("/adjust-address") - @Operation(summary = "发货订单") + @Operation(summary = "修改订单收货地址") @PreAuthorize("@ss.hasPermission('trade:order:update')") public CommonResult adjustAddress(@RequestBody TradeOrderAdjustAddressReqVO reqVO) { tradeOrderUpdateService.adjustAddress(reqVO); From 002475f33afc797e9286700c8c6f52d22ae752b7 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Tue, 22 Aug 2023 18:55:00 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=AE=A1=E7=90=86?= =?UTF-8?q?=EF=BC=9A=E5=AE=8C=E5=96=84=E8=AE=A2=E5=8D=95=E7=AE=A1=E7=90=86?= =?UTF-8?q?=20=E8=A1=A5=E5=85=A8=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../delivery/DeliveryExpressController.java | 2 +- .../DeliveryPickUpStoreController.java | 27 ++++----- .../vo/pickup/DeliveryPickUpStoreExcelVO.java | 58 ------------------- .../DeliveryPickUpStoreExportReqVO.java | 34 ----------- .../DeliveryPickUpStoreSimpleRespVO.java | 51 ++++++++++++++++ .../admin/order/TradeOrderController.java | 10 ++++ .../admin/order/vo/TradeOrderBaseVO.java | 12 +++- .../order/vo/TradeOrderDeliveryReqVO.java | 2 - .../admin/order/vo/TradeOrderPageReqVO.java | 7 +++ .../delivery/DeliveryPickUpStoreConvert.java | 14 ++--- .../delivery/DeliveryPickUpStoreMapper.java | 12 +--- .../dal/mysql/order/TradeOrderMapper.java | 2 + .../delivery/DeliveryPickUpStoreService.java | 13 +++-- .../DeliveryPickUpStoreServiceImpl.java | 14 ++--- 14 files changed, 111 insertions(+), 147 deletions(-) delete mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreExcelVO.java delete mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreExportReqVO.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java index 4fecd5ab1..699530f3d 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java @@ -69,7 +69,7 @@ public class DeliveryExpressController { @GetMapping("/list-all-simple") @Operation(summary = "获取快递公司精简信息列表", description = "主要用于前端的下拉选项") - public CommonResult> getSimpleBrandList() { + public CommonResult> getSimpleDeliveryExpressList() { // 获取品牌列表,只要开启状态的 List list = deliveryExpressService.getDeliveryExpressListByStatus(CommonStatusEnum.ENABLE.getStatus()); // 排序后,返回给前端 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 3b7421aa4..6bbbda381 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 @@ -1,9 +1,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.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; 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; @@ -16,14 +15,11 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; -import java.io.IOException; import java.util.Collection; import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; @Tag(name = "管理后台 - 自提门店") @RestController @@ -67,6 +63,15 @@ public class DeliveryPickUpStoreController { return success(DeliveryPickUpStoreConvert.INSTANCE.convert(deliveryPickUpStore)); } + @GetMapping("/list-all-simple") + @Operation(summary = "获取快递公司精简信息列表") + public CommonResult> getSimpleDeliveryPickUpStoreList() { + // 获取品牌列表,只要开启状态的 + List list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus(CommonStatusEnum.ENABLE.getStatus()); + // 排序后,返回给前端 + return success(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list)); + } + @GetMapping("/list") @Operation(summary = "获得自提门店列表") @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") @@ -84,16 +89,4 @@ public class DeliveryPickUpStoreController { return success(DeliveryPickUpStoreConvert.INSTANCE.convertPage(pageResult)); } - // TODO @jason:导出去掉好列;简化下,一般用不到哈。 - @GetMapping("/export-excel") - @Operation(summary = "导出自提门店 Excel") - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:export')") - @OperateLog(type = EXPORT) - public void exportDeliveryPickUpStoreExcel(@Valid DeliveryPickUpStoreExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = deliveryPickUpStoreService.getDeliveryPickUpStoreList(exportReqVO); - // 导出 Excel - List datas = DeliveryPickUpStoreConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "自提门店.xls", "数据", DeliveryPickUpStoreExcelVO.class, datas); - } } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreExcelVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreExcelVO.java deleted file mode 100644 index a50b0ce75..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreExcelVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - -import java.time.LocalDateTime; - -@Data -public class DeliveryPickUpStoreExcelVO { - - @ExcelProperty("编号") - private Long id; - - @ExcelProperty("门店名称") - private String name; - - @ExcelProperty("门店简介") - private String introduction; - - @ExcelProperty("门店手机") - private String phone; - - @ExcelProperty("门店所在区域") - private String areaName; - - @ExcelProperty("门店详细地址") - private String detailAddress; - - @ExcelProperty("门店logo") - private String logo; - - // TODO @jason:是不是可以加个 convert? - /** - * easy-excel 好像暂时不支持 LocalTime. 转成string - */ - @ExcelProperty("营业开始时间") - private String openingTime; - - @ExcelProperty("营业结束时间") - private String closingTime; - - @ExcelProperty("纬度") - private String latitude; - - @ExcelProperty("经度") - private String longitude; - - @ExcelProperty(value = "状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.COMMON_STATUS) - private Integer status; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreExportReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreExportReqVO.java deleted file mode 100644 index 05546de77..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreExportReqVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 自提门店 Excel 导出 Request VO,参数和 DeliveryPickUpStorePageReqVO 是一致的") -@Data -public class DeliveryPickUpStoreExportReqVO { - - @Schema(description = "门店名称", example = "李四") - private String name; - - @Schema(description = "门店手机") - private String phone; - - @Schema(description = "区域id", example = "18733") - private Integer areaId; - - @Schema(description = "门店状态", example = "1") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} 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 new file mode 100644 index 000000000..05497dac7 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java @@ -0,0 +1,51 @@ +package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; + +import cn.iocoder.yudao.framework.common.validation.Mobile; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.time.LocalTime; + +@Schema(description = "管理后台 - 自提门店精简信息 Response VO") +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DeliveryPickUpStoreSimpleRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") + @NotNull(message = "编号不能为空") + private Long id; + + @Schema(description = "门店名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") + @NotBlank(message = "门店名称不能为空") + private String name; + + @Schema(description = "门店手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601892312") + @NotBlank(message = "门店手机不能为空") + @Mobile + private String phone; + + @Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18733") + @NotNull(message = "区域编号不能为空") + private Integer areaId; + + @Schema(description = "门店详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "复旦大学路 188 号") + @NotBlank(message = "门店详细地址不能为空") + private String detailAddress; + + @Schema(description = "营业开始时间", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "营业开始时间不能为空") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm") + private LocalTime openingTime; + + @Schema(description = "营业结束时间", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "营业结束时间不能为空") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm") + private LocalTime closingTime; + +} 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 61d361c0b..ac3cb90b6 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 @@ -25,6 +25,7 @@ import java.util.Map; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; @Tag(name = "管理后台 - 交易订单") @RestController @@ -75,6 +76,15 @@ public class TradeOrderController { return success(TradeOrderConvert.INSTANCE.convert(order, orderItems, user)); } + @GetMapping("/get-express-track-list") + @Operation(summary = "获得交易订单的物流轨迹") + @Parameter(name = "id", description = "交易订单编号") + @PreAuthorize("@ss.hasPermission('trade:order:query')") + public CommonResult> getOrderExpressTrackList(@RequestParam("id") Long id) { + return success(TradeOrderConvert.INSTANCE.convertList02( + tradeOrderQueryService.getExpressTrackList(id, getLoginUserId()))); + } + @PostMapping("/delivery") @Operation(summary = "订单发货") @PreAuthorize("@ss.hasPermission('trade:order:update')") diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java index 3fa6ca8ab..7d05a0cfe 100755 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java @@ -6,9 +6,9 @@ import lombok.Data; import java.time.LocalDateTime; /** -* 交易订单 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ + * 交易订单 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ @Data public class TradeOrderBaseVO { @@ -87,6 +87,12 @@ public class TradeOrderBaseVO { // ========== 收件 + 物流基本信息 ========== + @Schema(description = "配送方式", example = "10") + private Integer deliveryType; + + @Schema(description = "自提门店", example = "10") + private Long pickUpStoreId; + @Schema(description = "配送模板编号", example = "1024") private Long deliveryTemplateId; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java index e19747a79..791c4088e 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.trade.controller.admin.order.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; @Schema(description = "管理后台 - 订单发货 Request VO") @@ -19,7 +18,6 @@ public class TradeOrderDeliveryReqVO { private Long logisticsId; @Schema(description = "发货物流单号", example = "SF123456789") - @NotEmpty(message = "发货物流单号不能为空") private String logisticsNo; } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java index 9b0b577cf..33c4cc400 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java @@ -10,6 +10,7 @@ import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; +import java.util.List; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @@ -30,6 +31,12 @@ public class TradeOrderPageReqVO extends PageParam { @Mobile private String userMobile; + @Schema(description = "发货物流公司编号", example = "1") + private Long logisticsId; + + @Schema(description = "自提门店编号", example = "[1,2]") + private List pickUpStoreIds; + @Schema(description = "收件人名称", example = "小红") private String receiverName; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java index 03f219567..9e114242b 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java @@ -1,20 +1,18 @@ package cn.iocoder.yudao.module.trade.convert.delivery; -import java.util.*; - import cn.iocoder.yudao.framework.common.pojo.PageResult; - import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreExcelVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreRespVO; +import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreSimpleRespVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; import org.mapstruct.Mapper; -import org.mapstruct.Mapping; import org.mapstruct.Named; import org.mapstruct.factory.Mappers; +import java.util.List; + @Mapper public interface DeliveryPickUpStoreConvert { @@ -30,14 +28,10 @@ public interface DeliveryPickUpStoreConvert { PageResult convertPage(PageResult page); - List convertList02(List list); - - @Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToName") - DeliveryPickUpStoreExcelVO convert2(DeliveryPickUpStoreDO bean); - @Named("convertAreaIdToName") default String convertAreaIdToName(Integer areaId) { return AreaUtils.format(areaId); } + List convertList1(List list); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreMapper.java index 7ccf6ad98..b26b1c015 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreMapper.java @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.trade.dal.mysql.delivery; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreExportReqVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; import org.apache.ibatis.annotations.Mapper; @@ -23,15 +22,10 @@ public interface DeliveryPickUpStoreMapper extends BaseMapperX selectList(DeliveryPickUpStoreExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(DeliveryPickUpStoreDO::getName, reqVO.getName()) - .eqIfPresent(DeliveryPickUpStoreDO::getPhone, reqVO.getPhone()) - .eqIfPresent(DeliveryPickUpStoreDO::getAreaId, reqVO.getAreaId()) - .eqIfPresent(DeliveryPickUpStoreDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(DeliveryPickUpStoreDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(DeliveryPickUpStoreDO::getId)); + default List selectListByStatus(Integer status) { + return selectList(DeliveryPickUpStoreDO::getStatus, status); } + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java index dadb762f9..9555c0592 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java @@ -34,6 +34,8 @@ public interface TradeOrderMapper extends BaseMapperX { .eqIfPresent(TradeOrderDO::getStatus, reqVO.getStatus()) .eqIfPresent(TradeOrderDO::getPayChannelCode, reqVO.getPayChannelCode()) .eqIfPresent(TradeOrderDO::getTerminal,reqVO.getTerminal()) + .eqIfPresent(TradeOrderDO::getLogisticsId, reqVO.getLogisticsId()) + .inIfPresent(TradeOrderDO::getPickUpStoreId, reqVO.getPickUpStoreIds()) .betweenIfPresent(TradeOrderDO::getCreateTime, reqVO.getCreateTime())); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java index 82d7548e1..8cfdb2220 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java @@ -1,14 +1,15 @@ package cn.iocoder.yudao.module.trade.service.delivery; -import java.util.*; -import javax.validation.*; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreExportReqVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; +import javax.validation.Valid; +import java.util.Collection; +import java.util.List; + /** * 自提门店 Service 接口 * @@ -63,10 +64,10 @@ public interface DeliveryPickUpStoreService { PageResult getDeliveryPickUpStorePage(DeliveryPickUpStorePageReqVO pageReqVO); /** - * 获得自提门店列表, 用于 Excel 导出 + * 获得指定状态的自提门店列表 * - * @param exportReqVO 查询条件 + * @param status 状态 * @return 自提门店列表 */ - List getDeliveryPickUpStoreList(DeliveryPickUpStoreExportReqVO exportReqVO); + List getDeliveryPickUpStoreListByStatus(Integer status); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java index ac5eaa3a5..4e31839b8 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java @@ -2,21 +2,20 @@ package cn.iocoder.yudao.module.trade.service.delivery; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreExportReqVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryPickUpStoreMapper; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; -import java.util.*; - +import javax.annotation.Resource; +import java.util.Collection; +import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PICK_UP_STORE_NOT_EXISTS; /** * 自提门店 Service 实现类 @@ -78,7 +77,8 @@ public class DeliveryPickUpStoreServiceImpl implements DeliveryPickUpStoreServic } @Override - public List getDeliveryPickUpStoreList(DeliveryPickUpStoreExportReqVO exportReqVO) { - return deliveryPickUpStoreMapper.selectList(exportReqVO); + public List getDeliveryPickUpStoreListByStatus(Integer status) { + return deliveryPickUpStoreMapper.selectListByStatus(status); } + }