From 57f6c50625718b6c3564787eea822e798b89f782 Mon Sep 17 00:00:00 2001 From: caiyuchao Date: Mon, 23 Jun 2025 15:56:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B4=A6=E5=8D=95=E5=88=97=E8=A1=A8;?= =?UTF-8?q?=E5=85=85=E5=80=BC=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/wfc/job/task/OmadaTask.java | 1 + .../src/main/java/org/wfc/job/task/ReminderTask.java | 2 +- .../wfc/user/service/impl/UAccountServiceImpl.java | 6 ++++-- .../org/wfc/user/service/impl/UOrderServiceImpl.java | 11 ++++++----- .../src/main/resources/mapper/user/UBillMapper.xml | 2 +- .../src/main/resources/mapper/user/UClientMapper.xml | 1 + 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/wfc-modules/wfc-job/src/main/java/org/wfc/job/task/OmadaTask.java b/wfc-modules/wfc-job/src/main/java/org/wfc/job/task/OmadaTask.java index de2bb2e..5082335 100644 --- a/wfc-modules/wfc-job/src/main/java/org/wfc/job/task/OmadaTask.java +++ b/wfc-modules/wfc-job/src/main/java/org/wfc/job/task/OmadaTask.java @@ -27,6 +27,7 @@ public class OmadaTask { long startTime = System.currentTimeMillis(); remoteUserService.deviceJob(); remoteUUserService.addCdrInfoByOmadaApi(); + remoteUUserService.sendReminderEMail(); long endTime = System.currentTimeMillis(); log.info(MessageUtils.message("job.execute.success", endTime - startTime)); } diff --git a/wfc-modules/wfc-job/src/main/java/org/wfc/job/task/ReminderTask.java b/wfc-modules/wfc-job/src/main/java/org/wfc/job/task/ReminderTask.java index 1165b4b..958eabc 100644 --- a/wfc-modules/wfc-job/src/main/java/org/wfc/job/task/ReminderTask.java +++ b/wfc-modules/wfc-job/src/main/java/org/wfc/job/task/ReminderTask.java @@ -19,7 +19,7 @@ public class ReminderTask { private RemoteUUserService remoteUUserService; public R reminderJob() { - return remoteUUserService.sendReminderEMail(); + return R.ok(true); } } diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UAccountServiceImpl.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UAccountServiceImpl.java index 9b3c9db..a502bb8 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UAccountServiceImpl.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UAccountServiceImpl.java @@ -36,9 +36,9 @@ import org.wfc.user.domain.UAccount; import org.wfc.user.domain.UBill; import org.wfc.user.domain.UBillRule; import org.wfc.user.domain.UClient; -import org.wfc.user.domain.constant.ReminderStatusEnum; import org.wfc.user.domain.constant.OrderStatusEnum; import org.wfc.user.domain.constant.OrderTypeEnum; +import org.wfc.user.domain.constant.ReminderStatusEnum; import org.wfc.user.domain.properties.ReminderProperties; import org.wfc.user.domain.vo.UAccountDashboardVo; import org.wfc.user.domain.vo.UCdrUserVo; @@ -336,7 +336,9 @@ public class UAccountServiceImpl extends ServiceImpl i for (UAccount packageAccount : packageAccounts) { if (packageAccount.getTrafficEnable()) { try { - if ((packageAccount.getTraffic() - packageAccount.getTrafficUsed()) / packageAccount.getTraffic() <= reminderProperties.getTrafficThreshold() / 100) { + BigDecimal value = BigDecimal.valueOf(packageAccount.getTraffic()).subtract(BigDecimal.valueOf(packageAccount.getTrafficUsed())).divide(BigDecimal.valueOf(packageAccount.getTraffic()), 2, RoundingMode.HALF_UP); + BigDecimal threshold = BigDecimal.valueOf(reminderProperties.getTrafficThreshold()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP); + if (value.compareTo(threshold) <= 0) { Context context = new Context(); context.setVariable("threshold", reminderProperties.getTrafficThreshold()); context.setVariable("totalTraffic", TrafficConverter.formatBytes(packageAccount.getTraffic())); diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UOrderServiceImpl.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UOrderServiceImpl.java index ae23639..e71b193 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UOrderServiceImpl.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/service/impl/UOrderServiceImpl.java @@ -136,12 +136,13 @@ public class UOrderServiceImpl extends ServiceImpl impleme callbackPackage(order, account, false); } else if (OrderTypeEnum.RECHARGE.getCode().equals(order.getType())) { // 充值 - // 更新账户余额 - account.setBalance(order.getOrderAmount().add(Optional.ofNullable(account.getBalance()).orElse(BigDecimal.ZERO))); // 如果已欠费,充值时补充欠费部分以抵消 - if (ObjectUtil.isNull(account.getBalanceUsed()) && account.getBalanceUsed().compareTo(BigDecimal.ZERO) > 0 - && ObjectUtil.isNull(account.getBalance()) && account.getBalance().subtract(account.getBalanceUsed()).compareTo(BigDecimal.ZERO) < 0) { - account.setBalance(account.getBalance().add(account.getBalanceUsed().subtract(account.getBalance()))); + if (ObjectUtil.isNotNull(account.getBalanceUsed()) && account.getBalanceUsed().compareTo(BigDecimal.ZERO) > 0 + && ObjectUtil.isNotNull(account.getBalance()) && account.getBalance().subtract(account.getBalanceUsed()).compareTo(BigDecimal.ZERO) < 0) { + account.setBalance(account.getBalanceUsed().add(order.getOrderAmount())); + } else { + // 更新账户余额 + account.setBalance(order.getOrderAmount().add(Optional.ofNullable(account.getBalance()).orElse(BigDecimal.ZERO))); } account.setBalanceReminder(ReminderStatusEnum.NO.getCode()); diff --git a/wfc-modules/wfc-user/src/main/resources/mapper/user/UBillMapper.xml b/wfc-modules/wfc-user/src/main/resources/mapper/user/UBillMapper.xml index 18ffa97..2ac1ce4 100644 --- a/wfc-modules/wfc-user/src/main/resources/mapper/user/UBillMapper.xml +++ b/wfc-modules/wfc-user/src/main/resources/mapper/user/UBillMapper.xml @@ -30,7 +30,7 @@ FROM u_bill b WHERE b.del_flag = 0 - AND b.type in (1, 2) + AND b.type in (0, 1) AND b.invoice_number is not null AND b.user_id = #{userId} order by b.create_time desc diff --git a/wfc-modules/wfc-user/src/main/resources/mapper/user/UClientMapper.xml b/wfc-modules/wfc-user/src/main/resources/mapper/user/UClientMapper.xml index 4304bee..88ff6bb 100644 --- a/wfc-modules/wfc-user/src/main/resources/mapper/user/UClientMapper.xml +++ b/wfc-modules/wfc-user/src/main/resources/mapper/user/UClientMapper.xml @@ -48,6 +48,7 @@ WHERE cdr.del_flag = 0 AND ch.id is not null + AND c.client_id is not null AND cdr.user_id = #{userId}