From 93181b4f218808a2d708159331fd3d81c5733f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A2=A8=E5=A4=A7=E5=8F=94?= <494979559@qq.com> Date: Wed, 11 Sep 2024 14:05:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ruoyi/common/pay/syb/util/SybUtil.java | 2 +- .../com/ruoyi/ss/payBill/domain/enums/PayBillStatus.java | 5 +++++ .../ruoyi/ss/payBill/service/impl/PayBillServiceImpl.java | 6 +++++- .../service/impl/TransactionBillServiceImpl.java | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/pay/syb/util/SybUtil.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/pay/syb/util/SybUtil.java index 8fcfa9a7..c3cb1ed0 100644 --- a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/pay/syb/util/SybUtil.java +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/pay/syb/util/SybUtil.java @@ -222,7 +222,7 @@ public class SybUtil { Map reqMap = request.getParameterMap(); for(Object key:reqMap.keySet()){ String value = ((String[])reqMap.get(key))[0]; - System.out.println(key+";"+value); +// System.out.println(key+";"+value); map.put(key.toString(),value); } return map; diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/domain/enums/PayBillStatus.java b/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/domain/enums/PayBillStatus.java index 275e53e4..ad08a51a 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/domain/enums/PayBillStatus.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/domain/enums/PayBillStatus.java @@ -33,4 +33,9 @@ public enum PayBillStatus { public static List getCanCancelList() { return asList(WAIT_PAY, PAYING); } + + // 已经支付过的状态 + public static List payedList() { + return asList(PAY_SUCCESS, REFUNDING, REFUNDED); + } } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/service/impl/PayBillServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/service/impl/PayBillServiceImpl.java index 98373fca..d9bd8ce9 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/service/impl/PayBillServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/service/impl/PayBillServiceImpl.java @@ -257,8 +257,12 @@ public class PayBillServiceImpl implements PayBillService } private void handleSuccess(PayBillVO payBill, LocalDateTime payTime) { - log.info("获取支付订单:{}", payBill); ServiceUtil.assertion(payBill == null, "支付订单不存在"); + log.info("获取支付订单:{}", payBill.getPayNo()); + // 若已经支付成功,则跳过 + if (PayBillStatus.payedList().contains(payBill.getStatus())) { + return; + } ServiceUtil.assertion(!PayBillStatus.PAYING.getStatus().equals(payBill.getStatus()), "该支付订单不是正在支付的支付订单"); transactionTemplate.execute(status -> { diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java index 6810a5e5..3f9c97e9 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java @@ -1440,7 +1440,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After // 按比例计算退款金额 BigDecimal refundAmount = dto.getRefundAmount(); BigDecimal refundRate = refundAmount.divide(bill.getMoney(), 2, RoundingMode.HALF_UP); // 退款金额比例 - BigDecimal refundServiceAmount = bill.getServiceCharge().multiply(refundRate); // 退款的手续费 + BigDecimal refundServiceAmount = bill.getServiceCharge().multiply(refundRate).setScale(2, RoundingMode.HALF_UP); // 退款的手续费 BigDecimal refundMchAmount = refundAmount.subtract(refundServiceAmount); // 退款的商户余额 userService.subtractBalance(bill.getMchId(), refundMchAmount, dto.getRefundReason(), RecordBalanceBstType.RECHARGE, bill.getBillId());