|
|
@@ -602,6 +602,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 校验订单是否符合退款操作
|
|
|
*/
|
|
|
@@ -624,18 +625,29 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
|
|
|
BigDecimal refundMoney = refundReq.getRefundMoney();
|
|
|
BigDecimal money = orderDon.getMoney();
|
|
|
+ BigDecimal balance = orderDon.getBalance();
|
|
|
+ BigDecimal refundBalance = refundReq.getRefundBalance();
|
|
|
//余额退款
|
|
|
if (UpgradeOrderDon.Type.BALANCE.getType().equals(refundType)) {
|
|
|
- BigDecimal balance = orderDon.getBalance();
|
|
|
refundMoney = orderDonRefundBalance.add(refundMoney);
|
|
|
- if (UpgradeOrderDon.Type.BALANCE == orderDon.getType() && refundMoney.compareTo(balance) > 0) {
|
|
|
- throw BusinessRuntimeException.getInstance("退款余额大于订单支付余额");
|
|
|
- }
|
|
|
if (UpgradeOrderDon.Type.BALANCE != orderDon.getType() && refundMoney.compareTo(money) > 0) {
|
|
|
throw BusinessRuntimeException.getInstance("退款余额大于订单支付金额");
|
|
|
}
|
|
|
orderDon.setRefundBalance(refundMoney);
|
|
|
orderDon.setRefundMoney(BigDecimal.ZERO);
|
|
|
+ } else if (OrderRefundReq.RefundType.bxj.name().equals(refundType)) {
|
|
|
+ balance = balance.add(money);
|
|
|
+ if (refundBalance.compareTo(balance) > 0) {
|
|
|
+ throw BusinessRuntimeException.getInstance("退款余额大于订单支付余额");
|
|
|
+ }
|
|
|
+ refundBalance = refundBalance.add(orderDonRefundBalance);
|
|
|
+ orderDon.setRefundBalance(refundBalance);
|
|
|
+
|
|
|
+ refundMoney = orderDonRefundMoney.add(refundMoney);
|
|
|
+ if (refundMoney.compareTo(money) > 0) {
|
|
|
+ throw BusinessRuntimeException.getInstance("退款金额大于订单支付金额");
|
|
|
+ }
|
|
|
+ orderDon.setRefundMoney(refundMoney);
|
|
|
} else {
|
|
|
//退金额
|
|
|
refundMoney = orderDonRefundMoney.add(refundMoney);
|
|
|
@@ -992,19 +1004,29 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
}
|
|
|
}
|
|
|
BigDecimal refundMoney = refundReq.getRefundMoney();
|
|
|
+ BigDecimal refundBalance = refundReq.getRefundBalance();
|
|
|
BigDecimal money = orderDon.getMoney();
|
|
|
+ BigDecimal balance = orderDon.getBalance();
|
|
|
//余额退款
|
|
|
if (OrderDon.Type.BALANCE.getType().equals(refundType)) {
|
|
|
- BigDecimal balance = orderDon.getBalance();
|
|
|
refundMoney = orderDonRefundBalance.add(refundMoney);
|
|
|
- if (OrderDon.Type.BALANCE == orderDon.getType() && refundMoney.compareTo(balance) > 0) {
|
|
|
- throw BusinessRuntimeException.getInstance("退款余额大于订单支付余额");
|
|
|
- }
|
|
|
if (OrderDon.Type.BALANCE != orderDon.getType() && refundMoney.compareTo(money) > 0) {
|
|
|
throw BusinessRuntimeException.getInstance("退款余额大于订单支付金额");
|
|
|
}
|
|
|
orderDon.setRefundBalance(refundMoney);
|
|
|
- orderDon.setRefundMoney(BigDecimal.ZERO);
|
|
|
+ } else if (OrderRefundReq.RefundType.bxj.name().equals(refundType)) {
|
|
|
+ balance = balance.add(money);
|
|
|
+ if (refundBalance.compareTo(balance) > 0) {
|
|
|
+ throw BusinessRuntimeException.getInstance("退款余额大于订单总金额");
|
|
|
+ }
|
|
|
+ refundBalance = refundBalance.add(orderDonRefundBalance);
|
|
|
+ orderDon.setRefundBalance(refundBalance);
|
|
|
+
|
|
|
+ refundMoney = orderDonRefundMoney.add(refundMoney);
|
|
|
+ if (refundMoney.compareTo(money) > 0) {
|
|
|
+ throw BusinessRuntimeException.getInstance("退款金额大于订单支付金额");
|
|
|
+ }
|
|
|
+ orderDon.setRefundMoney(refundMoney);
|
|
|
} else {
|
|
|
//退金额
|
|
|
refundMoney = orderDonRefundMoney.add(refundMoney);
|