2
0

fix: 账单列表;充值类型

This commit is contained in:
caiyuchao
2025-06-23 15:56:12 +08:00
parent 35cf811689
commit 57f6c50625
6 changed files with 14 additions and 9 deletions

View File

@@ -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<UAccountMapper, UAccount> 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()));

View File

@@ -136,12 +136,13 @@ public class UOrderServiceImpl extends ServiceImpl<UOrderMapper, UOrder> 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());

View File

@@ -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

View File

@@ -48,6 +48,7 @@
WHERE
cdr.del_flag = 0
AND ch.id is not null
AND c.client_id is not null
<if test="userId != null and userId != ''">
AND cdr.user_id = #{userId}
</if>