2
0

fix: reconnectClient

This commit is contained in:
caiyuchao
2025-06-25 11:24:34 +08:00
parent 2e85639d1e
commit cf57e7b0e3

View File

@@ -133,10 +133,10 @@ public class UAccountServiceImpl extends ServiceImpl<UAccountMapper, UAccount> i
List<UAccount> balanceAccounts = accounts.stream().filter(account -> !AccountUtil.isPackageValid(account, current))
.collect(Collectors.toList());
// 统计已使用余额
if (CollUtil.isNotEmpty(balanceAccounts)) {
List<UBillRule> billRules = billRuleMapper.selectList(Wrappers.<UBillRule>lambdaQuery().eq(UBillRule::getEnable, true));
Optional<UBillRule> billRuleOptional = billRules.stream().findFirst();
// 统计已使用余额
if (CollUtil.isNotEmpty(balanceAccounts)) {
if (billRuleOptional.isPresent()) {
UBillRule billRule = billRuleOptional.get();
for (UAccount balanceAccount : balanceAccounts) {
@@ -165,10 +165,10 @@ public class UAccountServiceImpl extends ServiceImpl<UAccountMapper, UAccount> i
this.updateBatchById(packageAccounts);
// 取消授权
cancelAuthClient();
cancelAuthClient(billRuleOptional.isPresent());
}
private void cancelAuthClient() {
private void cancelAuthClient(boolean enabledBalance) {
// 查出所有已授权client, 根据client的site和mac去查当前user, 再查user的account是否有可用套餐和余额没有则取消授权
ResponseEntity<OperationResponseGridVoSiteSummaryInfo> siteRes = omadaSiteApi.getSiteList(WifiConstants.PAGE, WifiConstants.PAGE_SIZE);
Date current = new Date();
@@ -193,7 +193,7 @@ public class UAccountServiceImpl extends ServiceImpl<UAccountMapper, UAccount> i
}
UAccount account = this.getOne(Wrappers.<UAccount>lambdaQuery().eq(UAccount::getUserId, loginClient.getUserId()), false);
// 套餐失效但是有余额且没有已使用余额reconnect
if (AccountUtil.isPackageUnValidBalanceValid(account, current)) {
if (enabledBalance && AccountUtil.isPackageUnValidBalanceValid(account, current)) {
wifiApi.reconnectClient(site.getSiteId(), client.getMac());
}
// 套餐有效有已使用余额且余额扣去已使用余额大于0reconnect