trade:售后增加发货

This commit is contained in:
YunaiV 2022-11-16 23:02:10 +08:00
parent 92dbf093ea
commit 40f0117130
6 changed files with 87 additions and 15 deletions

View File

@ -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_STATUS_NO_DELIVERED = new ErrorCode(1011000104, "订单未发货,无法申请【退货退款】售后");
ErrorCode AFTER_SALE_CREATE_FAIL_ORDER_ITEM_APPLIED = new ErrorCode(1011000105, "订单项已申请售后,无法重复申请"); 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_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 ========== // ========== Cart 模块 1-011-001-000 ==========
ErrorCode CARD_ITEM_NOT_FOUND = new ErrorCode(1011002000, "购物车项不存在"); ErrorCode CARD_ITEM_NOT_FOUND = new ErrorCode(1011002000, "购物车项不存在");

View File

@ -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.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.AppTradeAfterSaleCreateReqVO;
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleDeliveryReqVO;
import cn.iocoder.yudao.module.trade.service.aftersale.TradeAfterSaleService; import cn.iocoder.yudao.module.trade.service.aftersale.TradeAfterSaleService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -29,8 +30,15 @@ public class AppTradeAfterSaleController {
@PostMapping(value = "/create") @PostMapping(value = "/create")
@ApiOperation(value = "申请售后") @ApiOperation(value = "申请售后")
private CommonResult<Long> createAfterSale(@RequestBody AppTradeAfterSaleCreateReqVO createReqVO) { public CommonResult<Long> createAfterSale(@RequestBody AppTradeAfterSaleCreateReqVO createReqVO) {
return success(afterSaleService.createAfterSale(getLoginUserId(), createReqVO)); return success(afterSaleService.createAfterSale(getLoginUserId(), createReqVO));
} }
@PostMapping(value = "/delivery")
@ApiOperation(value = "退回货物")
public CommonResult<Boolean> deliveryAfterSale(@RequestBody AppTradeAfterSaleDeliveryReqVO deliveryReqVO) {
afterSaleService.deliveryAfterSale(getLoginUserId(), deliveryReqVO);
return success(true);
}
} }

View File

@ -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;
}

View File

@ -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;
} }

View File

@ -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.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.AppTradeAfterSaleCreateReqVO;
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleDeliveryReqVO;
/** /**
* 交易售后 Service 接口 * 交易售后 Service 接口
@ -29,4 +30,13 @@ public interface TradeAfterSaleService {
* @param auditReqVO 审批 Request 信息 * @param auditReqVO 审批 Request 信息
*/ */
void auditAfterSale(Long userId, String userIp, TradeAfterSaleAuditReqVO auditReqVO); void auditAfterSale(Long userId, String userIp, TradeAfterSaleAuditReqVO auditReqVO);
/**
* 退回货物
*
* @param userId 会员用户编号
* @param deliveryReqVO 退货 Request 信息
*/
void deliveryAfterSale(Long userId, AppTradeAfterSaleDeliveryReqVO deliveryReqVO);
} }

View File

@ -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.pay.api.refund.dto.PayRefundCreateReqDTO;
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleAuditReqVO; 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.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.convert.aftersale.TradeAfterSaleConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO; import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; 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()) ? Integer newStatus = afterSale.getType().equals(TradeAfterSaleTypeEnum.REFUND.getType()) ?
TradeAfterSaleStatusEnum.WAIT_REFUND.getStatus() : TradeAfterSaleStatusEnum.SELLER_PASS.getStatus(); 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) .setStatus(newStatus).setAuditUserId(userId)
.setAuditReason(auditReqVO.getAuditReason()).setAuditTime(LocalDateTime.now())); .setAuditReason(auditReqVO.getAuditReason()).setAuditTime(LocalDateTime.now()));
@ -165,7 +166,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService {
TradeAfterSaleAuditReqVO auditReqVO, TradeAfterSaleDO afterSale) { TradeAfterSaleAuditReqVO auditReqVO, TradeAfterSaleDO afterSale) {
// 更新售后单的状态 // 更新售后单的状态
Integer newStatus = TradeAfterSaleStatusEnum.SELLER_REFUSE.getStatus(); 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) .setStatus(newStatus).setAuditUserId(userId)
.setAuditReason(auditReqVO.getAuditReason()).setAuditTime(LocalDateTime.now())); .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 发送售后消息
}
} }