From 40f0117130ee238615e8f3d0acaa01c460ef2869 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 16 Nov 2022 23:02:10 +0800 Subject: [PATCH] =?UTF-8?q?trade=EF=BC=9A=E5=94=AE=E5=90=8E=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=8F=91=E8=B4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../trade/enums/ErrorCodeConstants.java | 3 +- .../AppTradeAfterSaleController.java | 10 ++++++- .../vo/AppTradeAfterSaleDeliveryReqVO.java | 30 +++++++++++++++++++ .../aftersale/TradeAfterSaleDO.java | 22 +++++++------- .../aftersale/TradeAfterSaleService.java | 10 +++++++ .../aftersale/TradeAfterSaleServiceImpl.java | 27 +++++++++++++++-- 6 files changed, 87 insertions(+), 15 deletions(-) create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppTradeAfterSaleDeliveryReqVO.java 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 1dfe17472..cea7ceb4e 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 @@ -31,7 +31,8 @@ public interface ErrorCodeConstants { ErrorCode AFTER_SALE_CREATE_FAIL_ORDER_STATUS_NO_DELIVERED = new ErrorCode(1011000104, "订单未发货,无法申请【退货退款】售后"); ErrorCode AFTER_SALE_CREATE_FAIL_ORDER_ITEM_APPLIED = new ErrorCode(1011000105, "订单项已申请售后,无法重复申请"); ErrorCode AFTER_SALE_AUDIT_FAIL_STATUS_NOT_APPLY = new ErrorCode(1011000106, "审批失败,售后状态不处于审批中"); - ErrorCode AFTER_SALE_UPDATE_STATUS_FAIL = new ErrorCode(1011000106, "操作售后单失败,请刷新后重试"); + ErrorCode AFTER_SALE_UPDATE_STATUS_FAIL = new ErrorCode(1011000107, "操作售后单失败,请刷新后重试"); + ErrorCode AFTER_SALE_DELIVERY_FAIL_STATUS_NOT_BUYER_RETURN = new ErrorCode(1011000108, "退货失败,售后单状态不处于【买家退货】"); // ========== Cart 模块 1-011-001-000 ========== ErrorCode CARD_ITEM_NOT_FOUND = new ErrorCode(1011002000, "购物车项不存在"); diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppTradeAfterSaleController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppTradeAfterSaleController.java index 23fd8fcf8..494085b3f 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppTradeAfterSaleController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppTradeAfterSaleController.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.trade.controller.app.aftersale; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleCreateReqVO; +import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleDeliveryReqVO; import cn.iocoder.yudao.module.trade.service.aftersale.TradeAfterSaleService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -29,8 +30,15 @@ public class AppTradeAfterSaleController { @PostMapping(value = "/create") @ApiOperation(value = "申请售后") - private CommonResult createAfterSale(@RequestBody AppTradeAfterSaleCreateReqVO createReqVO) { + public CommonResult createAfterSale(@RequestBody AppTradeAfterSaleCreateReqVO createReqVO) { return success(afterSaleService.createAfterSale(getLoginUserId(), createReqVO)); } + @PostMapping(value = "/delivery") + @ApiOperation(value = "退回货物") + public CommonResult deliveryAfterSale(@RequestBody AppTradeAfterSaleDeliveryReqVO deliveryReqVO) { + afterSaleService.deliveryAfterSale(getLoginUserId(), deliveryReqVO); + return success(true); + } + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppTradeAfterSaleDeliveryReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppTradeAfterSaleDeliveryReqVO.java new file mode 100644 index 000000000..0727361d7 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppTradeAfterSaleDeliveryReqVO.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.trade.controller.app.aftersale.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; + +@ApiModel("用户 App - 交易售后退回货物 Request VO") +@Data +public class AppTradeAfterSaleDeliveryReqVO { + + @ApiModelProperty(name = "售后编号", required = true, example = "1024") + @NotNull(message = "售后编号不能为空") + private Long id; + + @ApiModelProperty(name = "退货物流公司编号", required = true, example = "1") + @NotNull(message = "退货物流公司编号不能为空") + private Long logisticsId; + + @ApiModelProperty(name = "退货物流单号", required = true, example = "SF123456789") + @NotNull(message = "退货物流单号不能为空") + private String logisticsNo; + + @ApiModelProperty(name = "退货时间", required = true) + @NotNull(message = "退货时间不能为空") + private LocalDateTime deliveryTime; + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/TradeAfterSaleDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/TradeAfterSaleDO.java index 327dc8aeb..0fdb43dc0 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/TradeAfterSaleDO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/TradeAfterSaleDO.java @@ -134,26 +134,26 @@ public class TradeAfterSaleDO extends BaseDO { // ========== 退货相关 ========== /** - * 退货物流公司编号 TODO + * 退货物流公司编号 * - * 关联 ExpressDO 的 id 编号 + * 关联 LogisticsDO 的 id 编号 */ - private Long returnExpressId; // express_name + private Long logisticsId; /** - * 退货物流单号 TODO + * 退货物流单号 */ - private String returnExpressNo; // express_no + private String logisticsNo; /** - * 退货时间 TODO + * 退货时间 */ - private LocalDateTime deliveryTime; // ship_time + private LocalDateTime deliveryTime; /** - * 收获备注 TODO + * 收货时间 */ - private String receiveMemo; // receive_message + private LocalDateTime receiptTime; /** - * 收货时间 TODO + * 收货备注 */ - private LocalDateTime receiveDate; // receive_time + private String receiptMemo; } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleService.java index ec9e579bf..d0ef09342 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleService.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.trade.service.aftersale; import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleAuditReqVO; import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleCreateReqVO; +import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleDeliveryReqVO; /** * 交易售后 Service 接口 @@ -29,4 +30,13 @@ public interface TradeAfterSaleService { * @param auditReqVO 审批 Request 信息 */ void auditAfterSale(Long userId, String userIp, TradeAfterSaleAuditReqVO auditReqVO); + + /** + * 退回货物 + * + * @param userId 会员用户编号 + * @param deliveryReqVO 退货 Request 信息 + */ + void deliveryAfterSale(Long userId, AppTradeAfterSaleDeliveryReqVO deliveryReqVO); + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceImpl.java index 7e7ee6a80..11b439940 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceImpl.java @@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi; import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleAuditReqVO; import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleCreateReqVO; +import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleDeliveryReqVO; import cn.iocoder.yudao.module.trade.convert.aftersale.TradeAfterSaleConvert; import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; @@ -147,7 +148,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService { // 情况二:退货退款:需要等用户退货后,才能发起退款 Integer newStatus = afterSale.getType().equals(TradeAfterSaleTypeEnum.REFUND.getType()) ? TradeAfterSaleStatusEnum.WAIT_REFUND.getStatus() : TradeAfterSaleStatusEnum.SELLER_PASS.getStatus(); - updateAfterSaleStatus(afterSale.getId(), TradeAfterSaleStatusEnum.APPLY.getStatus(), new TradeAfterSaleDO() + updateAfterSaleStatus(afterSale.getId(), TradeAfterSaleStatusEnum.APPLY.getStatus(), new TradeAfterSaleDO() .setStatus(newStatus).setAuditUserId(userId) .setAuditReason(auditReqVO.getAuditReason()).setAuditTime(LocalDateTime.now())); @@ -165,7 +166,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService { TradeAfterSaleAuditReqVO auditReqVO, TradeAfterSaleDO afterSale) { // 更新售后单的状态 Integer newStatus = TradeAfterSaleStatusEnum.SELLER_REFUSE.getStatus(); - updateAfterSaleStatus(afterSale.getId(), TradeAfterSaleStatusEnum.APPLY.getStatus(), new TradeAfterSaleDO() + updateAfterSaleStatus(afterSale.getId(), TradeAfterSaleStatusEnum.APPLY.getStatus(), new TradeAfterSaleDO() .setStatus(newStatus).setAuditUserId(userId) .setAuditReason(auditReqVO.getAuditReason()).setAuditTime(LocalDateTime.now())); @@ -199,4 +200,26 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService { } } + @Override + public void deliveryAfterSale(Long userId, AppTradeAfterSaleDeliveryReqVO deliveryReqVO) { + // 校验售后单存在,并状态未退货 + TradeAfterSaleDO afterSale = tradeAfterSaleMapper.selectById(deliveryReqVO.getId()); + if (afterSale == null) { + throw exception(AFTER_SALE_NOT_FOUND); + } + if (afterSale.getStatus().equals(TradeAfterSaleStatusEnum.SELLER_PASS.getStatus())) { + throw exception(AFTER_SALE_DELIVERY_FAIL_STATUS_NOT_BUYER_RETURN); + } + + // 更新售后单的物流信息 + updateAfterSaleStatus(afterSale.getId(), TradeAfterSaleStatusEnum.SELLER_PASS.getStatus(), new TradeAfterSaleDO() + .setStatus(TradeAfterSaleStatusEnum.BUYER_RETURN.getStatus()) + .setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()) + .setDeliveryTime(deliveryReqVO.getDeliveryTime())); + + // TODO 记录售后日志 + + // TODO 发送售后消息 + } + }