Browse Source

fix 补差价余额记录

zoujiajian 2 năm trước cách đây
mục cha
commit
c2d86b4630

+ 19 - 17
netflix-service/src/main/java/com/cyksj/service/mange/impl/CmsOrderDonServiceImpl.java

@@ -951,6 +951,13 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
         if (refundMoney.add(orderRefundMoney).add(orderDonRefundBalance).compareTo(orderDon.getRealMoney()) >= 0) {
             throw BusinessRuntimeException.getInstance("补差价已达到该订单付款金额");
         }
+        GoodsDon goodsDon = goodsDonMapper.selectById(orderDon.getGoodsId());
+        GoodsDonSku sku = null;
+        if (orderDon.getSkuId() != null) {
+            sku = skuMapper.selectById(orderDon.getSkuId());
+        }
+        orderDon.setRefundDesc("补差价");
+        String outNo = StrUtil.EMPTY;
         if ("money".equals(refundType)) {
             if (refundMoney == null || refundMoney.compareTo(BigDecimal.ZERO) <= 0) {
                 throw BusinessRuntimeException.getInstance("请输入正确的差价金额");
@@ -959,32 +966,27 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
                 throw BusinessRuntimeException.getInstance("补差价金额应不大于订单金额");
             }
             //退款
-            String outNo = centerRefund(orderRefundReq, orderDon);
+            outNo = centerRefund(orderRefundReq, orderDon);
             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, refundMoney, goodsDon, sku, outNo, refundType);
-
             //补差价金额 扣除对应分销提成金额
             orderDon.setRefundMoney(refundMoney);
             deductDsPoints(orderDon);
             //店铺分销提成金额扣除
             yhShopDistributeService.deductDsMoney(orderDon);
-            return;
-        }
-        BigDecimal refundBalance = refundMoney;
-        if (refundBalance == null || refundBalance.compareTo(BigDecimal.ZERO) <= 0 || refundBalance.compareTo(orderDon.getMoney()) > 0) {
-            throw BusinessRuntimeException.getInstance("请输入正确的差价金额");
+
+        } else {
+            BigDecimal refundBalance = refundMoney;
+            if (refundBalance == null || refundBalance.compareTo(BigDecimal.ZERO) <= 0 || refundBalance.compareTo(orderDon.getMoney()) > 0) {
+                throw BusinessRuntimeException.getInstance("请输入正确的差价金额");
+            }
+            userBenefitsService.addUserBalance(orderDon.getUserId(), refundBalance, UserBalanceSourceRecord.Source.price_differ, orderDon.getYhsId());
+            orderDon.setRefundBalance(orderDonRefundBalance.add(refundBalance));
+            orderDonMapper.updateById(orderDon);
         }
-        userBenefitsService.addUserBalance(orderDon.getUserId(), refundBalance, UserBalanceSourceRecord.Source.price_differ, orderDon.getYhsId());
-        orderDon.setRefundBalance(orderDonRefundBalance.add(refundBalance));
-        orderDonMapper.updateById(orderDon);
+
+        refundRecord(orderDon, refundMoney, goodsDon, sku, outNo, refundType);
     }
 
     @Override