fix: billRule不启用情况
This commit is contained in:
@@ -205,7 +205,7 @@ public class UAccountServiceImpl extends ServiceImpl<UAccountMapper, UAccount> i
|
||||
wifiApi.cancelAuthClient(site.getSiteId(), client.getMac());
|
||||
continue;
|
||||
}
|
||||
if (!AccountUtil.isValid(account, current)) {
|
||||
if (!AccountUtil.isValid(account, current, enabledBalance)) {
|
||||
wifiApi.cancelAuthClient(site.getSiteId(), client.getMac());
|
||||
continue;
|
||||
}
|
||||
@@ -233,7 +233,9 @@ public class UAccountServiceImpl extends ServiceImpl<UAccountMapper, UAccount> i
|
||||
return;
|
||||
}
|
||||
Date current = new Date();
|
||||
if (AccountUtil.isValid(account, current)) {
|
||||
List<UBillRule> billRules = billRuleMapper.selectList(Wrappers.<UBillRule>lambdaQuery().eq(UBillRule::getEnable, true));
|
||||
Optional<UBillRule> billRuleOptional = billRules.stream().findFirst();
|
||||
if (AccountUtil.isValid(account, current, billRuleOptional.isPresent())) {
|
||||
|
||||
if (account.getClientNumEnable()) {
|
||||
int onlineClientNum = uClientService.getCurrentClients(client.getUserId()).size();
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.wfc.omada.api.organization.model.OperationResponseGridVoSiteSummaryIn
|
||||
import org.wfc.omada.api.organization.model.SiteSummaryInfo;
|
||||
import org.wfc.user.api.IWifiApi;
|
||||
import org.wfc.user.domain.UAccount;
|
||||
import org.wfc.user.domain.UBillRule;
|
||||
import org.wfc.user.domain.UCdr;
|
||||
import org.wfc.user.domain.UCdrHistory;
|
||||
import org.wfc.user.domain.UClient;
|
||||
@@ -36,6 +37,7 @@ import org.wfc.user.domain.constant.UserTypeEnum;
|
||||
import org.wfc.user.domain.vo.UCdrClientVo;
|
||||
import org.wfc.user.domain.vo.UCdrHistoryUserVo;
|
||||
import org.wfc.user.domain.vo.UCdrUserVo;
|
||||
import org.wfc.user.mapper.UBillRuleMapper;
|
||||
import org.wfc.user.mapper.UCdrMapper;
|
||||
import org.wfc.user.service.IUAccountService;
|
||||
import org.wfc.user.service.IUCdrHistoryService;
|
||||
@@ -48,6 +50,7 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -91,6 +94,9 @@ public class UCdrServiceImpl extends ServiceImpl<UCdrMapper, UCdr> implements IU
|
||||
@Autowired
|
||||
private IUClientService uClientService;
|
||||
|
||||
@Autowired
|
||||
private UBillRuleMapper billRuleMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public UCdrUserVo getByUser() {
|
||||
@@ -184,11 +190,13 @@ public class UCdrServiceImpl extends ServiceImpl<UCdrMapper, UCdr> implements IU
|
||||
if (CollUtil.isEmpty(userIds)) {
|
||||
return macs;
|
||||
}
|
||||
List<UBillRule> billRules = billRuleMapper.selectList(Wrappers.<UBillRule>lambdaQuery().eq(UBillRule::getEnable, true));
|
||||
Optional<UBillRule> billRuleOptional = billRules.stream().findFirst();
|
||||
List<UAccount> accounts = accountService.list(Wrappers.<UAccount>lambdaQuery().in(UAccount::getUserId, userIds));
|
||||
for (UClient unAuthClient : unAuthClients) {
|
||||
for (UAccount account : accounts) {
|
||||
if (Objects.equals(unAuthClient.getUserId(), account.getUserId())) {
|
||||
if (AccountUtil.isValid(account, new Date())) {
|
||||
if (AccountUtil.isValid(account, new Date(), billRuleOptional.isPresent())) {
|
||||
if (account.getClientNumEnable()) {
|
||||
int onlineClientNum = uClientService.getCurrentClients(account.getUserId()).size();
|
||||
if (onlineClientNum >= account.getClientNum()) {
|
||||
|
||||
@@ -129,7 +129,9 @@ public class UOrderServiceImpl extends ServiceImpl<UOrderMapper, UOrder> impleme
|
||||
} else {
|
||||
accountId = account.getId();
|
||||
oldBalance = account.getBalance();
|
||||
isValid = AccountUtil.isValid(account, new Date());
|
||||
List<UBillRule> billRules = billRuleMapper.selectList(Wrappers.<UBillRule>lambdaQuery().eq(UBillRule::getEnable, true));
|
||||
Optional<UBillRule> billRuleOptional = billRules.stream().findFirst();
|
||||
isValid = AccountUtil.isValid(account, new Date(), billRuleOptional.isPresent());
|
||||
}
|
||||
if (OrderTypeEnum.PACKAGE.getCode().equals(order.getType())) {
|
||||
// 套餐
|
||||
|
||||
@@ -21,12 +21,12 @@ public class AccountUtil {
|
||||
* @param current 当前时间
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isValid(UAccount account, Date current) {
|
||||
public static boolean isValid(UAccount account, Date current, boolean enableBalance) {
|
||||
// 过期/流量已用完/时长已用完应取消授权
|
||||
return ((DateUtil.compare(account.getStartTime(), current) <= 0 && DateUtil.compare(account.getEndTime(), current) > 0)
|
||||
&& (!account.getTrafficEnable() || account.getTrafficUsed() <= account.getTraffic())
|
||||
&& (!account.getDurationEnable() || account.getDurationUsed() <= account.getDuration()))
|
||||
|| (ObjectUtil.isNotNull(account.getBalance()) && account.getBalance().compareTo(BigDecimal.ZERO) > 0
|
||||
|| (enableBalance && ObjectUtil.isNotNull(account.getBalance()) && account.getBalance().compareTo(BigDecimal.ZERO) > 0
|
||||
&& (ObjectUtil.isNull(account.getBalanceUsed()) || account.getBalanceUsed().compareTo(BigDecimal.ZERO) == 0
|
||||
|| (ObjectUtil.isNotNull(account.getBalanceUsed()) && account.getBalance().compareTo(BigDecimal.ZERO) > 0
|
||||
&& account.getBalance().subtract(account.getBalanceUsed()).compareTo(BigDecimal.ZERO) > 0)));
|
||||
|
||||
Reference in New Issue
Block a user