Ver Fonte

退款逻辑修改

skyline há 2 anos atrás
pai
commit
1fd8e0db86

+ 4 - 4
service/src/main/java/com/kym/service/wechat/impl/WxPayServiceImpl.java

@@ -376,7 +376,7 @@ public class WxPayServiceImpl implements WxPayService {
         }
 
         // 将余额转移至冻结余额
-        accountService.lambdaUpdate().setSql(" frozen_amount = (frozen_amount + (balance - discount_amount)) ,balance = 0").eq(Account::getUserId, userId).update();
+        accountService.lambdaUpdate().setSql(" frozen_amount = (frozen_amount + balance ,balance = 0").eq(Account::getUserId, userId).update();
 
         // 余减去优惠金额作为退款金额
         AtomicInteger refundAmount = new AtomicInteger(account.getBalance() - account.getDiscountAmount());
@@ -546,9 +546,9 @@ public class WxPayServiceImpl implements WxPayService {
             refundLogService.updateById(refundLog);
 
             if (RefundLog.STATUS_退款成功.equals(refundNotification.getRefundStatus().name())) {
-                // 冻结金额扣减此次退款金额,优惠金额字段减去申请退款时的优惠金额
-                accountService.lambdaUpdate().setSql("frozen_amount = (frozen_amount - %d) , discount_amount = (discount_amount - %d)"
-                                .formatted(refundNotification.getAmount().getRefund().intValue()), refundLog.getDiscountAmount())
+                // 冻结金额扣减此次退款金额+优惠金额),优惠金额字段减去申请退款时的优惠金额
+                accountService.lambdaUpdate().setSql("frozen_amount = (frozen_amount - (%d + %d) , discount_amount = (discount_amount - %d)"
+                                .formatted(refundNotification.getAmount().getRefund().intValue()), refundLog.getDiscountAmount(), refundLog.getDiscountAmount())
                         .eq(Account::getUserId, refundLog.getUserId()).update();
 
                 // 更新资金流水