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());