Pārlūkot izejas kodu

fix: 退款回调 frozen_amount 多扣 discountAmount 导致负值

申请退款时 frozen_amount 仅增加了 rechargeBalance,但退款回调时却减去了
(refund + discountAmount),导致 frozen_amount 被多扣产生负值。
多次充值退款场景下负值会持续累积,修正为 frozen_amount 仅核减 refund。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
skyline 20 stundas atpakaļ
vecāks
revīzija
d4133c2d4e

+ 2 - 2
car-wash-service/src/main/java/com/kym/service/wechat/impl/WxPayServiceImpl.java

@@ -715,8 +715,8 @@ public class WxPayServiceImpl implements WxPayService {
             if (RefundLog.STATUS_退款成功.equals(refundNotification.getRefundStatus().name())) {
                 // 冻结金额扣减此次(退款金额+优惠金额),优惠金额字段减去申请退款时的优惠金额
                 var account = accountService.getAccountByUserId(refundLog.getUserId());
-                accountService.lambdaUpdate().setSql("frozen_amount = (frozen_amount - (%d + %d)) , discount_amount = (discount_amount - %d)"
-                                .formatted(refundNotification.getAmount().getRefund().intValue(), refundLog.getDiscountAmount(), refundLog.getDiscountAmount()))
+                accountService.lambdaUpdate().setSql("frozen_amount = (frozen_amount - %d) , discount_amount = (discount_amount - %d)"
+                                .formatted(refundNotification.getAmount().getRefund().intValue(), refundLog.getDiscountAmount()))
                         .eq(Account::getUserId, refundLog.getUserId()).update();
 
                 // 更新资金流水