fix: reconnectClient
This commit is contained in:
@@ -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());
|
||||
|
||||
List<UBillRule> billRules = billRuleMapper.selectList(Wrappers.<UBillRule>lambdaQuery().eq(UBillRule::getEnable, true));
|
||||
Optional<UBillRule> billRuleOptional = billRules.stream().findFirst();
|
||||
// 统计已使用余额
|
||||
if (CollUtil.isNotEmpty(balanceAccounts)) {
|
||||
List<UBillRule> billRules = billRuleMapper.selectList(Wrappers.<UBillRule>lambdaQuery().eq(UBillRule::getEnable, true));
|
||||
Optional<UBillRule> billRuleOptional = billRules.stream().findFirst();
|
||||
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());
|
||||
}
|
||||
// 套餐有效,有已使用余额且余额扣去已使用余额大于0,reconnect
|
||||
|
||||
Reference in New Issue
Block a user