From 995a89b0dc3b189e8ffdf3fcba9eba21a07661e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A2=A8=E5=A4=A7=E5=8F=94?= <494979559@qq.com> Date: Tue, 6 Aug 2024 10:38:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=A7=9F=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/ss/device/mapper/DeviceMapper.xml | 2 +- .../receiveBill/service/impl/ReceiveBillServiceImpl.java | 4 ++-- .../service/impl/TransactionBillServiceImpl.java | 9 +++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/DeviceMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/DeviceMapper.xml index eb21db6d..a4fa6fcc 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/DeviceMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/DeviceMapper.xml @@ -464,7 +464,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update sm_device set rent_time = if( - now() > rent_time, + rent_time is null or now() > rent_time, date_add(now(), interval #{seconds} second), date_add(rent_time, interval #{seconds} second) ) diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/receiveBill/service/impl/ReceiveBillServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/receiveBill/service/impl/ReceiveBillServiceImpl.java index 69613030..411ace41 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/receiveBill/service/impl/ReceiveBillServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/receiveBill/service/impl/ReceiveBillServiceImpl.java @@ -128,7 +128,7 @@ public class ReceiveBillServiceImpl implements ReceiveBillService ServiceUtil.assertion(device == null || device.getDeviceId() == null, "设备不存在"); // 设备未过期,则不生成账单 - if (device.getRentTime() != null && device.getRentTime().isAfter(LocalDateTime.now())) { + if (device.getRentTime() != null && device.getRentTime().isAfter(billTime)) { return 1; } @@ -159,7 +159,7 @@ public class ReceiveBillServiceImpl implements ReceiveBillService bill.setReceivedAmount(amount); Integer result = transactionTemplate.execute(status -> { // 用户余额扣减 - int subtract = userService.subtractBalance(mch.getUserId(), amount, true, bill.getDescription()); + int subtract = userService.subtractBalance(mch.getUserId(), amount, false, bill.getDescription()); ServiceUtil.assertion(subtract != 1, "扣减商户余额失败"); // 插入账单 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 e56a601d..9772230a 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 @@ -258,12 +258,12 @@ public class TransactionBillServiceImpl implements TransactionBillService { // 根据服务费类型进行对应操作 // 月费 if (ServiceType.MONTH.getType().equals(serviceType)) { - int count = receiveBillService.genBillByMonthAndPay(bo, serviceRate); - ServiceUtil.assertion(count == 0, "商户出账失败,请刷新后重试"); // 服务费 = 0 order.setServiceCharge(BigDecimal.ZERO); // 商户到账金额 = 交易金额 order.setArrivalAmount(order.getMoney()); + int count = receiveBillService.genBillByMonthAndPay(bo, serviceRate); + ServiceUtil.assertion(count == 0, "商户出账失败,请刷新后重试"); } // 设备订单比例 else if(ServiceType.PERCENT.getType().equals(serviceType)){ @@ -309,6 +309,7 @@ public class TransactionBillServiceImpl implements TransactionBillService { ChannelVO channel = bo.getChannel(); TransactionBill order = new TransactionBill(); + bo.setOrder(order); // 基础信息 order.setUserId(data.getUserId()); order.setSuitTime(data.getSuitTime()); @@ -322,7 +323,7 @@ public class TransactionBillServiceImpl implements TransactionBillService { order.setDeviceRechargeStatus(TransactionBillDeviceRechargeStatus.UN_RECHARGE.getStatus()); // 设备状态:未充值 // 设备信息 order.setDeviceId(device.getDeviceId()); - order.setMchId(device.getUserId()); // 到账人ID + order.setMchId(mch.getUserId()); // 到账人ID order.setDeviceName(device.getDeviceName()); order.setDeviceMac(device.getMac()); // 店铺信息 @@ -333,7 +334,7 @@ public class TransactionBillServiceImpl implements TransactionBillService { } // 套餐信息 order.setSuitName(suit.getName()); - // 用户信息 + // 支付用户信息 order.setAccountNo(user.getWxOpenId()); // 渠道费用计算 order.setChannelCost(channel.getCostRate().multiply(order.getMoney()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP));