From 898bd5b4e610a75c4d589ab6915f56758a1e0c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A3=B7=E5=8F=B6?= <14103883+leaf-phos@user.noreply.gitee.com> Date: Thu, 28 Nov 2024 08:57:33 +0800 Subject: [PATCH] =?UTF-8?q?debug:=E9=80=80=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/TransactionBillServiceImpl.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) 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 45444c7b..83fe39f7 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 @@ -1090,7 +1090,8 @@ public class TransactionBillServiceImpl implements TransactionBillService, After TransactionBillVO order = bo.getOrder(); DeviceVO device = bo.getDevice(); ServiceUtil.assertion(order == null, "订单不存在"); - ServiceUtil.assertion(!TransactionBillStatus.SUCCESS_DEPOSIT.getStatus().equals(order.getStatus()), "当前订单状态不允许结束"); +// ServiceUtil.assertion(!TransactionBillStatus.SUCCESS_DEPOSIT.getStatus().equals(order.getStatus()), "当前订单状态不允许结束"); + ServiceUtil.assertion(order.getIsFinished() != null && order.getIsFinished(), "当前订单已结束,无法操作"); ServiceUtil.assertion(device == null, "设备不存在"); LocalDateTime endTime = LocalDateTime.now(); // 结束使用的时间 @@ -1111,6 +1112,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After TransactionBillQuery query = new TransactionBillQuery(); query.setStatus(TransactionBillStatus.SUCCESS_DEPOSIT.getStatus()); query.setBillId(order.getBillId()); + query.setIsFinished(false); int update = this.updateByQuery(data, query); ServiceUtil.assertion(update != 1, "修改订单状态失败,请刷新后重试"); @@ -1181,7 +1183,6 @@ public class TransactionBillServiceImpl implements TransactionBillService, After TransactionBillVO order = bo.getOrder(); DeviceVO device = bo.getDevice(); ServiceUtil.assertion(order == null, "订单不存在"); - ServiceUtil.assertion(!TransactionBillStatus.SUCCESS.getStatus().equals(order.getStatus()), "当前订单状态不允许结束"); ServiceUtil.assertion(!SuitFeeMode.SMART.getMode().equals(order.getSuitFeeMode()), "当前订单非智能收费订单,无法提前结束"); ServiceUtil.assertion(order.getIsFinished() != null && order.getIsFinished(), "当前订单已结束,无法操作"); ServiceUtil.assertion(device == null, "设备不存在"); @@ -1215,13 +1216,15 @@ public class TransactionBillServiceImpl implements TransactionBillService, After // 计算需要退款的金额,若金额 > 0.01 则申请退款 BigDecimal refundAmount = this.calcRefundAmount(order, endTime, totalEle); if (BigDecimal.valueOf(0.01).compareTo(refundAmount) < 0) { - // 申请退款 - BillRefundDTO refundDto = new BillRefundDTO(); - refundDto.setBillId(order.getBillId()); - refundDto.setRefundAmount(refundAmount); - refundDto.setRefundReason(String.format("充值订单%s智能退款%s元", order.getBillNo(), refundAmount)); - int refund = this.refund(refundDto); - ServiceUtil.assertion(refund != 1, "申请退款失败"); + scheduledExecutorService.schedule(() -> { + // 申请退款 + BillRefundDTO refundDto = new BillRefundDTO(); + refundDto.setBillId(order.getBillId()); + refundDto.setRefundAmount(refundAmount); + refundDto.setRefundReason(String.format("充值订单%s智能退款%s元", order.getBillNo(), refundAmount)); + int refund = this.refund(refundDto); + ServiceUtil.assertion(refund != 1, "申请退款失败"); + }, 0, TimeUnit.SECONDS); } // 清零设备 @@ -1303,7 +1306,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After DeviceVO device = bo.getDevice(); ServiceUtil.assertion(order == null, "订单不存在"); ServiceUtil.assertion(order.getIsFinished() != null && order.getIsFinished(), "当前订单已结束,无法操作"); - ServiceUtil.assertion(!TransactionBillStatus.SUCCESS.getStatus().equals(order.getStatus()), "当前订单状态不允许结束"); +// ServiceUtil.assertion(!TransactionBillStatus.SUCCESS.getStatus().equals(order.getStatus()), "当前订单状态不允许结束"); ServiceUtil.assertion(device == null, "设备不存在"); LocalDateTime endTime = LocalDateTime.now(); // 结束使用的时间 @@ -1745,8 +1748,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After TransactionBillVO bill = this.selectSmTransactionBillByBillId(dto.getBillId()); ServiceUtil.assertion(bill == null, "待退款的订单不存在"); ServiceUtil.assertion(dto.getRefundAmount().compareTo(bill.getMoney()) > 0, "退款金额不允许大于订单金额"); - ServiceUtil.assertion(bill.getIsFinished() == null || !bill.getIsFinished(), "当前订单还未结束使用,无法退款"); - ServiceUtil.assertion(!TransactionBillStatus.SUCCESS.getStatus().equals(bill.getStatus()), "当前订单未支付成功,不允许退款"); + ServiceUtil.assertion(!TransactionBillStatus.SUCCESS.getStatus().equals(bill.getStatus()), "当前订单状态不允许退款"); // 拼接分成列表 transactionAssembler.assembleBonusList(bill); @@ -1760,7 +1762,6 @@ public class TransactionBillServiceImpl implements TransactionBillService, After TransactionBillQuery billQuery = new TransactionBillQuery(); billQuery.setBillId(dto.getBillId()); billQuery.setStatus(TransactionBillStatus.SUCCESS.getStatus()); - billQuery.setIsFinished(true); int updateBill = this.updateByQuery(data, billQuery); ServiceUtil.assertion(updateBill != 1, "退款时修改订单状态失败,订单状态已发生改变,请刷新后重试");