|
@@ -316,20 +316,8 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
}
|
|
}
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- OrderDon.Type type = orderDon.getType();
|
|
|
|
|
- String outNo = StrUtil.EMPTY;
|
|
|
|
|
- if (type == OrderDon.Type.WeChat && !refundType.equals(OrderDon.Type.BALANCE.getType())) {
|
|
|
|
|
- outNo = wxRefund(refundReq, orderDon);
|
|
|
|
|
- }
|
|
|
|
|
- if (type == OrderDon.Type.ALI_PAY && !refundType.equals(OrderDon.Type.BALANCE.getType())) {
|
|
|
|
|
- outNo = zfbRefund(refundReq, orderDon);
|
|
|
|
|
- }
|
|
|
|
|
- if (type == OrderDon.Type.PAYPAL && !refundType.equals(OrderDon.Type.BALANCE.getType())) {
|
|
|
|
|
- payPalService.refund(refundReq, orderDon);
|
|
|
|
|
- }
|
|
|
|
|
- if (type == OrderDon.Type.STRIPE && !refundType.equals(OrderDon.Type.BALANCE.getType())) {
|
|
|
|
|
- stripeService.refund(refundReq, orderDon);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //调用第三方接口退款
|
|
|
|
|
+ String outNo = centerRefund(refundReq, orderDon);
|
|
|
orderDon.setRefundDesc(refundReq.getRefundDesc());
|
|
orderDon.setRefundDesc(refundReq.getRefundDesc());
|
|
|
//记录退款信息
|
|
//记录退款信息
|
|
|
commonRefund(orderDon, goodsDon, sku, outNo, refundType);
|
|
commonRefund(orderDon, goodsDon, sku, outNo, refundType);
|
|
@@ -602,6 +590,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
if (orderDon == null) {
|
|
if (orderDon == null) {
|
|
|
throw BusinessRuntimeException.getInstance("订单不存在");
|
|
throw BusinessRuntimeException.getInstance("订单不存在");
|
|
|
}
|
|
}
|
|
|
|
|
+ BigDecimal orderDonRefundMoney = Optional.ofNullable(orderDon.getRefundMoney()).orElse(BigDecimal.ZERO);
|
|
|
String refundType = refundReq.getRefundType();
|
|
String refundType = refundReq.getRefundType();
|
|
|
if (orderDon.getType() == OrderDon.Type.BALANCE && !OrderDon.Type.BALANCE.getType().equals(refundType)) {
|
|
if (orderDon.getType() == OrderDon.Type.BALANCE && !OrderDon.Type.BALANCE.getType().equals(refundType)) {
|
|
|
throw BusinessRuntimeException.getInstance("余额支付的订单不支持金额退款");
|
|
throw BusinessRuntimeException.getInstance("余额支付的订单不支持金额退款");
|
|
@@ -660,6 +649,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
if (refundMoney.compareTo(money) > 0) {
|
|
if (refundMoney.compareTo(money) > 0) {
|
|
|
throw BusinessRuntimeException.getInstance("退款金额大于订单支付金额");
|
|
throw BusinessRuntimeException.getInstance("退款金额大于订单支付金额");
|
|
|
}
|
|
}
|
|
|
|
|
+ refundMoney = refundMoney.add(orderDonRefundMoney);
|
|
|
orderDon.setRefundMoney(refundMoney);
|
|
orderDon.setRefundMoney(refundMoney);
|
|
|
}
|
|
}
|
|
|
//礼品卡是否已使用
|
|
//礼品卡是否已使用
|
|
@@ -917,7 +907,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void refundPriceDiffer(OrderRefundReq orderRefundReq) {
|
|
|
|
|
|
|
+ public void refundPriceDiffer(OrderRefundReq orderRefundReq) throws Exception {
|
|
|
Long orderId = orderRefundReq.getOrderId();
|
|
Long orderId = orderRefundReq.getOrderId();
|
|
|
OrderDon orderDon = orderDonMapper.selectById(orderId);
|
|
OrderDon orderDon = orderDonMapper.selectById(orderId);
|
|
|
if (orderDon == null) {
|
|
if (orderDon == null) {
|
|
@@ -929,6 +919,31 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
if (Constant.noOrderAllStatus.contains(orderDon.getStatus().name())) {
|
|
if (Constant.noOrderAllStatus.contains(orderDon.getStatus().name())) {
|
|
|
throw BusinessRuntimeException.getInstance("订单不是已支付状态");
|
|
throw BusinessRuntimeException.getInstance("订单不是已支付状态");
|
|
|
}
|
|
}
|
|
|
|
|
+ //默认补差价余额
|
|
|
|
|
+ String refundType = Optional.ofNullable(orderRefundReq.getRefundType()).orElse("balance");
|
|
|
|
|
+ if ("money".equals(refundType)) {
|
|
|
|
|
+ BigDecimal refundMoney = orderRefundReq.getRefundMoney();
|
|
|
|
|
+ if (refundMoney == null || refundMoney.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("请输入正确的差价金额");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (refundMoney.compareTo(orderDon.getMoney()) >= 0) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("补差价金额应不大于订单金额");
|
|
|
|
|
+ }
|
|
|
|
|
+ //退款
|
|
|
|
|
+ String outNo = centerRefund(orderRefundReq, orderDon);
|
|
|
|
|
+ BigDecimal orderRefundMoney = Optional.ofNullable(orderDon.getRefundMoney()).orElse(BigDecimal.ZERO);
|
|
|
|
|
+ orderDon.setRefundMoney(orderRefundMoney.add(refundMoney));
|
|
|
|
|
+ orderDonMapper.updateById(orderDon);
|
|
|
|
|
+
|
|
|
|
|
+ GoodsDon goodsDon = goodsDonMapper.selectById(orderDon.getGoodsId());
|
|
|
|
|
+ GoodsDonSku sku = null;
|
|
|
|
|
+ if (orderDon.getSkuId() != null) {
|
|
|
|
|
+ sku = skuMapper.selectById(orderDon.getSkuId());
|
|
|
|
|
+ }
|
|
|
|
|
+ orderDon.setRefundDesc("补差价");
|
|
|
|
|
+ refundRecord(orderDon, goodsDon, sku, outNo, refundType);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
BigDecimal refundBalance = orderRefundReq.getRefundBalance();
|
|
BigDecimal refundBalance = orderRefundReq.getRefundBalance();
|
|
|
if (refundBalance == null || refundBalance.compareTo(BigDecimal.ZERO) <= 0 || refundBalance.compareTo(orderDon.getMoney()) > 0) {
|
|
if (refundBalance == null || refundBalance.compareTo(BigDecimal.ZERO) <= 0 || refundBalance.compareTo(orderDon.getMoney()) > 0) {
|
|
|
throw BusinessRuntimeException.getInstance("请输入正确的差价金额");
|
|
throw BusinessRuntimeException.getInstance("请输入正确的差价金额");
|
|
@@ -981,4 +996,22 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
}
|
|
}
|
|
|
return relation;
|
|
return relation;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public String centerRefund(OrderRefundReq refundReq, OrderDon orderDon) throws Exception {
|
|
|
|
|
+ OrderDon.Type type = orderDon.getType();
|
|
|
|
|
+ String refundType = refundReq.getRefundType();
|
|
|
|
|
+ if (type == OrderDon.Type.WeChat && !refundType.equals(OrderDon.Type.BALANCE.getType())) {
|
|
|
|
|
+ return wxRefund(refundReq, orderDon);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (type == OrderDon.Type.ALI_PAY && !refundType.equals(OrderDon.Type.BALANCE.getType())) {
|
|
|
|
|
+ return zfbRefund(refundReq, orderDon);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (type == OrderDon.Type.PAYPAL && !refundType.equals(OrderDon.Type.BALANCE.getType())) {
|
|
|
|
|
+ payPalService.refund(refundReq, orderDon);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (type == OrderDon.Type.STRIPE && !refundType.equals(OrderDon.Type.BALANCE.getType())) {
|
|
|
|
|
+ stripeService.refund(refundReq, orderDon);
|
|
|
|
|
+ }
|
|
|
|
|
+ return StrUtil.EMPTY;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|