再调整一下子单退款

This commit is contained in:
HH 2023-04-18 10:39:22 +08:00
parent 4d2dd4be6f
commit 109a7a2520
4 changed files with 38 additions and 10 deletions

View File

@ -2,6 +2,9 @@ package com.ghy.order.domain;
import com.ghy.common.annotation.Excel;
import com.ghy.common.core.domain.BaseEntity;
import com.ghy.common.enums.OrderStatus;
import com.ghy.common.enums.PayStatus;
import com.ghy.common.enums.PayTypeEnum;
import com.ghy.goods.domain.Goods;
import com.ghy.worker.domain.Worker;
import lombok.Data;
@ -46,6 +49,9 @@ public class OrderDetail extends BaseEntity {
@Excel(name = "订单类型", cellType = Excel.ColumnType.NUMERIC)
private Integer orderType;
/**
* @see OrderStatus
*/
@Excel(name = "订单状态", cellType = Excel.ColumnType.NUMERIC)
private Integer orderStatus;
@ -118,9 +124,15 @@ public class OrderDetail extends BaseEntity {
*/
private Date arrivalTime;
/**
* @see PayTypeEnum
*/
@Excel(name = "付款类型", cellType = Excel.ColumnType.NUMERIC)
private Integer payType;
/**
* @see PayStatus
*/
@Excel(name = "付款状态", cellType = Excel.ColumnType.NUMERIC)
private Integer payStatus;

View File

@ -3,6 +3,9 @@ package com.ghy.order.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ghy.common.annotation.Excel;
import com.ghy.common.core.domain.BaseEntity;
import com.ghy.common.enums.OrderStatus;
import com.ghy.common.enums.PayStatus;
import com.ghy.common.enums.PayTypeEnum;
import com.ghy.payment.domain.FinancialMaster;
import com.ghy.worker.domain.Worker;
import lombok.Data;
@ -39,12 +42,21 @@ public class OrderMaster extends BaseEntity {
@Excel(name = "订单类型", cellType = Excel.ColumnType.NUMERIC)
private Integer orderType;
/**
* @see OrderStatus
*/
@Excel(name = "订单状态", cellType = Excel.ColumnType.NUMERIC)
private Integer orderStatus;
/**
* @see PayTypeEnum
*/
@Excel(name = "付款类型", cellType = Excel.ColumnType.NUMERIC)
private Integer payType;
/**
* @see PayStatus
*/
@Excel(name = "付款状态", cellType = Excel.ColumnType.NUMERIC)
private Integer payStatus;

View File

@ -260,29 +260,32 @@ public class OrderDetailServiceImpl implements OrderDetailService {
public void cancel(long orderDetailId) throws BaseAdaPayException {
OrderDetail orderDetail = selectById(orderDetailId);
Assert.notNull(orderDetail, "找不到对应的子订单");
if (OrderStatus.CANCEL.code() == orderDetail.getOrderStatus()) {
logger.info("子订单[id={}]已经是取消状态了", orderDetailId);
return;
}
// 更新子订单状态
orderDetailMapper.updateStatus(orderDetailId, OrderStatus.CANCEL.code());
// 查询出所有的子订单 就走主订单取消流程
List<OrderDetail> orderDetails = orderDetailMapper.selectByOrderMasterId(orderDetail.getOrderMasterId());
// 发起退款
refund(orderDetail);
// 如果除了这个子订单以外 没有其它未取消的订单
boolean allCancel = true;
for (OrderDetail od : orderDetails) {
if (!od.getId().equals(orderDetailId)) {
if (!od.getOrderStatus().equals(OrderStatus.CANCEL.code())) {
allCancel = false;
}
break;
}
}
// 判断主单是否全部派单
boolean allAssign = orderMasterService.isAllAssign(orderDetail.getOrderMasterId());
// 如果主单已经全部派单 并且 其它订单都已经取消
// 如果主单已经全部派单 并且 所有单都已经取消
if (allAssign && allCancel) {
logger.info("主订单[id={}]下所有的子订单都被取消 直接进入主订单取消流程", orderDetail.getOrderMasterId());
orderMasterService.cancelAgree(orderDetail.getOrderMasterId(), 1);
return;
}
orderDetailMapper.updateStatus(orderDetailId, OrderStatus.CANCEL.code());
// 发起退款
refund(orderDetail);
}
/**

View File

@ -127,6 +127,7 @@
<if test="payTime != null">pay_time = #{payTime},</if>
<if test="payMoney != null">pay_money = #{payMoney},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="reverseId != null and reverseId != ''">reverse_id = #{reverseId},</if>
update_time = SYSDATE()
</set>
WHERE id = #{id}