mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 09:11:52 +08:00
trade:【交易售后】确认收货
This commit is contained in:
parent
40f0117130
commit
67050eeaa8
@ -32,7 +32,8 @@ public interface ErrorCodeConstants {
|
||||
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(1011000107, "操作售后单失败,请刷新后重试");
|
||||
ErrorCode AFTER_SALE_DELIVERY_FAIL_STATUS_NOT_BUYER_RETURN = new ErrorCode(1011000108, "退货失败,售后单状态不处于【买家退货】");
|
||||
ErrorCode AFTER_SALE_DELIVERY_FAIL_STATUS_NOT_SELLER_PASS = new ErrorCode(1011000108, "退货失败,售后单状态不处于【待买家退货】");
|
||||
ErrorCode AFTER_SALE_CONFIRM_FAIL_STATUS_NOT_BUYER_RETURN = new ErrorCode(1011000109, "确认收货失败,售后单状态不处于【待确认收货】");
|
||||
|
||||
// ========== Cart 模块 1-011-001-000 ==========
|
||||
ErrorCode CARD_ITEM_NOT_FOUND = new ErrorCode(1011002000, "购物车项不存在");
|
||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.trade.controller.admin.aftersale;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleAuditReqVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleConfirmReqVO;
|
||||
import cn.iocoder.yudao.module.trade.service.aftersale.TradeAfterSaleService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -37,4 +38,12 @@ public class TradeAfterSaleController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/confirm")
|
||||
@ApiOperation("确认收货")
|
||||
@PreAuthorize("@ss.hasPermission('trade:after-sale:audit')")
|
||||
public CommonResult<Boolean> confirmAfterSale(@RequestBody TradeAfterSaleConfirmReqVO confirmReqVO) {
|
||||
afterSaleService.confirmAfterSale(getLoginUserId(), getClientIP(), confirmReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public class TradeAfterSaleAuditReqVO {
|
||||
@ApiModelProperty(value = "审批结果", required = true, example = "true",
|
||||
notes = "true - 通过;false - 不通过")
|
||||
@NotNull(message = "审批结果不能为空")
|
||||
private Boolean audit;
|
||||
private Boolean pass;
|
||||
|
||||
@ApiModelProperty(value = "审批备注", example = "你猜")
|
||||
private String auditReason;
|
||||
|
@ -0,0 +1,25 @@
|
||||
package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("管理后台 - 交易售后确认收货 Request VO")
|
||||
@Data
|
||||
public class TradeAfterSaleConfirmReqVO {
|
||||
|
||||
@ApiModelProperty(value = "售后编号", required = true, example = "1024")
|
||||
@NotNull(message = "售后编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "收货结果", required = true, example = "true",
|
||||
notes = "true - 确认收货;false - 拒绝收货")
|
||||
@NotNull(message = "审批结果不能为空")
|
||||
private Boolean pass;
|
||||
|
||||
@ApiModelProperty(value = "收货备注", example = "你猜")
|
||||
private String receiptMemo;
|
||||
|
||||
}
|
@ -1,6 +1,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.TradeAfterSaleConfirmReqVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleCreateReqVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleDeliveryReqVO;
|
||||
|
||||
@ -39,4 +40,13 @@ public interface TradeAfterSaleService {
|
||||
*/
|
||||
void deliveryAfterSale(Long userId, AppTradeAfterSaleDeliveryReqVO deliveryReqVO);
|
||||
|
||||
/**
|
||||
* 确认收货
|
||||
*
|
||||
* @param userId 管理员用户编号
|
||||
* @param userIp 操作 IP
|
||||
* @param confirmReqVO 收货 Request 信息
|
||||
*/
|
||||
void confirmAfterSale(Long userId, String userIp, TradeAfterSaleConfirmReqVO confirmReqVO);
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package cn.iocoder.yudao.module.trade.service.aftersale;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
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.admin.aftersale.vo.TradeAfterSaleConfirmReqVO;
|
||||
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;
|
||||
@ -129,12 +131,12 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService {
|
||||
if (afterSale == null) {
|
||||
throw exception(AFTER_SALE_NOT_FOUND);
|
||||
}
|
||||
if (afterSale.getStatus().equals(TradeAfterSaleStatusEnum.APPLY.getStatus())) {
|
||||
if (ObjectUtil.notEqual(afterSale.getStatus(), TradeAfterSaleStatusEnum.APPLY.getStatus())) {
|
||||
throw exception(AFTER_SALE_AUDIT_FAIL_STATUS_NOT_APPLY);
|
||||
}
|
||||
|
||||
// 进行审批
|
||||
if (auditReqVO.getAudit()) {
|
||||
if (auditReqVO.getPass()) {
|
||||
auditAfterSalePass(userId, userIp, auditReqVO, afterSale);
|
||||
} else {
|
||||
auditAfterSaleReject(userId, auditReqVO, afterSale);
|
||||
@ -207,8 +209,8 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService {
|
||||
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);
|
||||
if (ObjectUtil.notEqual(afterSale.getStatus(), TradeAfterSaleStatusEnum.SELLER_PASS.getStatus())) {
|
||||
throw exception(AFTER_SALE_DELIVERY_FAIL_STATUS_NOT_SELLER_PASS);
|
||||
}
|
||||
|
||||
// 更新售后单的物流信息
|
||||
@ -222,4 +224,56 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService {
|
||||
// TODO 发送售后消息
|
||||
}
|
||||
|
||||
@Override
|
||||
public void confirmAfterSale(Long userId, String userIp,
|
||||
TradeAfterSaleConfirmReqVO confirmReqVO) {
|
||||
// 校验售后单存在,并状态未审批
|
||||
TradeAfterSaleDO afterSale = tradeAfterSaleMapper.selectById(confirmReqVO.getId());
|
||||
if (afterSale == null) {
|
||||
throw exception(AFTER_SALE_NOT_FOUND);
|
||||
}
|
||||
if (ObjectUtil.notEqual(afterSale.getStatus(), TradeAfterSaleStatusEnum.BUYER_RETURN.getStatus())) {
|
||||
throw exception(AFTER_SALE_CONFIRM_FAIL_STATUS_NOT_BUYER_RETURN);
|
||||
}
|
||||
|
||||
// 进行审批
|
||||
if (confirmReqVO.getPass()) {
|
||||
confirmAfterSalePass(userId, userIp, confirmReqVO, afterSale);
|
||||
} else {
|
||||
confirmAfterSaleReject(userId, confirmReqVO, afterSale);
|
||||
}
|
||||
}
|
||||
|
||||
private void confirmAfterSalePass(Long userId, String userIp,
|
||||
TradeAfterSaleConfirmReqVO confirmReqVO, TradeAfterSaleDO afterSale) {
|
||||
// 更新售后单的状态
|
||||
Integer newStatus = TradeAfterSaleStatusEnum.WAIT_REFUND.getStatus();
|
||||
updateAfterSaleStatus(afterSale.getId(), TradeAfterSaleStatusEnum.BUYER_RETURN.getStatus(), new TradeAfterSaleDO()
|
||||
.setStatus(newStatus).setReceiptTime(LocalDateTime.now()).setReceiptMemo(confirmReqVO.getReceiptMemo()));
|
||||
|
||||
// 如果直接退款,则发起售后退款
|
||||
if (afterSale.getType().equals(TradeAfterSaleTypeEnum.REFUND.getType())) {
|
||||
createPayRefund(userIp, afterSale);
|
||||
}
|
||||
|
||||
// TODO 记录售后日志
|
||||
|
||||
// TODO 发送售后消息
|
||||
}
|
||||
|
||||
private void confirmAfterSaleReject(Long userId, TradeAfterSaleConfirmReqVO confirmReqVO, TradeAfterSaleDO afterSale) {
|
||||
// 更新售后单的状态
|
||||
Integer newStatus = TradeAfterSaleStatusEnum.SELLER_TERMINATION.getStatus();
|
||||
updateAfterSaleStatus(afterSale.getId(), TradeAfterSaleStatusEnum.BUYER_RETURN.getStatus(), new TradeAfterSaleDO()
|
||||
.setStatus(newStatus).setReceiptTime(LocalDateTime.now()).setReceiptMemo(confirmReqVO.getReceiptMemo()));
|
||||
|
||||
// 更新交易订单项的售后状态为【未申请】
|
||||
tradeOrderService.updateOrderItemAfterSaleStatus(afterSale.getOrderItemId(),
|
||||
TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), TradeOrderItemAfterSaleStatusEnum.NONE.getStatus());
|
||||
|
||||
// TODO 记录售后日志
|
||||
|
||||
// TODO 发送售后消息
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user