|
@@ -80,7 +80,7 @@ public class CmsVipOrderServiceImpl implements CmsVipOrderService {
|
|
|
|
|
|
|
|
private void commonRefund(VipOrderDon orderDon, BigDecimal refundMoney, String operator, String outNo, String refundType, Boolean isOnly, BigDecimal refundBalance, String chatImg, BigDecimal deductBalance) {
|
|
private void commonRefund(VipOrderDon orderDon, BigDecimal refundMoney, String operator, String outNo, String refundType, Boolean isOnly, BigDecimal refundBalance, String chatImg, BigDecimal deductBalance) {
|
|
|
//记录退款
|
|
//记录退款
|
|
|
- recordRefundOrder(orderDon, outNo, refundMoney, operator, chatImg, refundType);
|
|
|
|
|
|
|
+ recordRefundOrder(orderDon, outNo, refundMoney, refundBalance, operator, chatImg, refundType);
|
|
|
//退等比例
|
|
//退等比例
|
|
|
if (isOnly != null && isOnly) {
|
|
if (isOnly != null && isOnly) {
|
|
|
userBenefitsService.addUserBalance(orderDon.getUserId(), refundBalance, UserBalanceSourceRecord.Source.vip_refund, null, orderDon.getId(), orderDon.getPayTitle() + UserBalanceSourceRecord.Source.vip_refund.getDesc(), true);
|
|
userBenefitsService.addUserBalance(orderDon.getUserId(), refundBalance, UserBalanceSourceRecord.Source.vip_refund, null, orderDon.getId(), orderDon.getPayTitle() + UserBalanceSourceRecord.Source.vip_refund.getDesc(), true);
|
|
@@ -88,14 +88,14 @@ public class CmsVipOrderServiceImpl implements CmsVipOrderService {
|
|
|
orderDon.setRefundBalance(orderDonRefundBalance.add(refundBalance));
|
|
orderDon.setRefundBalance(orderDonRefundBalance.add(refundBalance));
|
|
|
}
|
|
}
|
|
|
//若存在余额支付,退还余额
|
|
//若存在余额支付,退还余额
|
|
|
- if (isOnly == null && orderDon.getBalance().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
- BigDecimal addBalance = orderDon.getBalance();
|
|
|
|
|
- //需额外扣除余额
|
|
|
|
|
- if (deductBalance != null && deductBalance.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
- addBalance = addBalance.subtract(deductBalance);
|
|
|
|
|
- }
|
|
|
|
|
- userBenefitsService.addUserBalance(orderDon.getUserId(), addBalance, UserBalanceSourceRecord.Source.vip_refund, null, orderDon.getId(), orderDon.getPayTitle() + UserBalanceSourceRecord.Source.vip_refund.getDesc(), true);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// if (isOnly == null && orderDon.getBalance().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+// BigDecimal addBalance = orderDon.getBalance();
|
|
|
|
|
+// //需额外扣除余额
|
|
|
|
|
+// if (deductBalance != null && deductBalance.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+// addBalance = addBalance.subtract(deductBalance);
|
|
|
|
|
+// }
|
|
|
|
|
+// userBenefitsService.addUserBalance(orderDon.getUserId(), addBalance, UserBalanceSourceRecord.Source.vip_refund, null, orderDon.getId(), orderDon.getPayTitle() + UserBalanceSourceRecord.Source.vip_refund.getDesc(), true);
|
|
|
|
|
+// }
|
|
|
//扣除会员时长
|
|
//扣除会员时长
|
|
|
List<Long> userIdList = userBindRelationService.getRelationUserIdList(orderDon.getUserId(), null);
|
|
List<Long> userIdList = userBindRelationService.getRelationUserIdList(orderDon.getUserId(), null);
|
|
|
VipUser vipUser = vipUserMapper.selectOne(Wrappers.lambdaQuery(VipUser.class)
|
|
VipUser vipUser = vipUserMapper.selectOne(Wrappers.lambdaQuery(VipUser.class)
|
|
@@ -194,7 +194,7 @@ public class CmsVipOrderServiceImpl implements CmsVipOrderService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void recordRefundOrder(VipOrderDon orderDon, String outRefundNo, BigDecimal refundMoney, String operator, String chatImg, String refundType) {
|
|
|
|
|
|
|
+ private void recordRefundOrder(VipOrderDon orderDon, String outRefundNo, BigDecimal refundMoney, BigDecimal refundBalance, String operator, String chatImg, String refundType) {
|
|
|
RefundVipOrderDon refund = new RefundVipOrderDon();
|
|
RefundVipOrderDon refund = new RefundVipOrderDon();
|
|
|
refund.setOrderId(orderDon.getId());
|
|
refund.setOrderId(orderDon.getId());
|
|
|
refund.setOutRefundNo(outRefundNo);
|
|
refund.setOutRefundNo(outRefundNo);
|
|
@@ -212,6 +212,11 @@ public class CmsVipOrderServiceImpl implements CmsVipOrderService {
|
|
|
refund.setRefundMethod(refundType);
|
|
refund.setRefundMethod(refundType);
|
|
|
refund.setRefundFee(orderDon.getRefundBalance());
|
|
refund.setRefundFee(orderDon.getRefundBalance());
|
|
|
}
|
|
}
|
|
|
|
|
+ //余额现金退款
|
|
|
|
|
+ if (OrderRefundReq.RefundType.bxj.name().equals(refundType)) {
|
|
|
|
|
+ refund.setRefundMethod(OrderRefundReq.RefundType.bxj.name());
|
|
|
|
|
+ refund.setRefundBalance(refundBalance);
|
|
|
|
|
+ }
|
|
|
refundVipOrderDonMapper.insert(refund);
|
|
refundVipOrderDonMapper.insert(refund);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -231,12 +236,13 @@ public class CmsVipOrderServiceImpl implements CmsVipOrderService {
|
|
|
}
|
|
}
|
|
|
String refundType = refundReq.getRefundType();
|
|
String refundType = refundReq.getRefundType();
|
|
|
BigDecimal refundMoney = refundReq.getRefundMoney();
|
|
BigDecimal refundMoney = refundReq.getRefundMoney();
|
|
|
|
|
+ BigDecimal refundBalance = refundReq.getRefundBalance();
|
|
|
BigDecimal money = orderDon.getMoney();
|
|
BigDecimal money = orderDon.getMoney();
|
|
|
|
|
+ BigDecimal balance = orderDon.getBalance();
|
|
|
BigDecimal orderDonRefundMoney = Optional.ofNullable(orderDon.getRefundMoney()).orElse(BigDecimal.ZERO);
|
|
BigDecimal orderDonRefundMoney = Optional.ofNullable(orderDon.getRefundMoney()).orElse(BigDecimal.ZERO);
|
|
|
BigDecimal orderDonRefundBalance = Optional.ofNullable(orderDon.getRefundBalance()).orElse(BigDecimal.ZERO);
|
|
BigDecimal orderDonRefundBalance = Optional.ofNullable(orderDon.getRefundBalance()).orElse(BigDecimal.ZERO);
|
|
|
//余额退款
|
|
//余额退款
|
|
|
if (OrderDon.Type.BALANCE.getType().equals(refundType)) {
|
|
if (OrderDon.Type.BALANCE.getType().equals(refundType)) {
|
|
|
- BigDecimal balance = orderDon.getBalance();
|
|
|
|
|
refundMoney = orderDonRefundBalance.add(refundMoney);
|
|
refundMoney = orderDonRefundBalance.add(refundMoney);
|
|
|
if (VipOrderDon.Type.BALANCE == orderDon.getType() && refundMoney.compareTo(balance) > 0) {
|
|
if (VipOrderDon.Type.BALANCE == orderDon.getType() && refundMoney.compareTo(balance) > 0) {
|
|
|
throw BusinessRuntimeException.getInstance("退款余额大于订单支付余额");
|
|
throw BusinessRuntimeException.getInstance("退款余额大于订单支付余额");
|
|
@@ -246,7 +252,19 @@ public class CmsVipOrderServiceImpl implements CmsVipOrderService {
|
|
|
}
|
|
}
|
|
|
orderDon.setRefundBalance(refundMoney);
|
|
orderDon.setRefundBalance(refundMoney);
|
|
|
orderDon.setRefundMoney(BigDecimal.ZERO);
|
|
orderDon.setRefundMoney(BigDecimal.ZERO);
|
|
|
- } else {
|
|
|
|
|
|
|
+ } else if (OrderRefundReq.RefundType.bxj.name().equals(refundType)) {
|
|
|
|
|
+ refundBalance = refundBalance.add(orderDonRefundBalance);
|
|
|
|
|
+ if (refundBalance.compareTo(balance) > 0) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("退款余额大于订单支付余额");
|
|
|
|
|
+ }
|
|
|
|
|
+ orderDon.setRefundBalance(refundBalance);
|
|
|
|
|
+
|
|
|
|
|
+ refundMoney = orderDonRefundMoney.add(refundMoney);
|
|
|
|
|
+ if (refundMoney.compareTo(money) > 0) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("退款金额大于订单支付金额");
|
|
|
|
|
+ }
|
|
|
|
|
+ orderDon.setRefundMoney(refundMoney);
|
|
|
|
|
+ }else {
|
|
|
//退金额
|
|
//退金额
|
|
|
refundMoney = orderDonRefundMoney.add(refundMoney);
|
|
refundMoney = orderDonRefundMoney.add(refundMoney);
|
|
|
if (refundMoney.compareTo(money) > 0) {
|
|
if (refundMoney.compareTo(money) > 0) {
|