feat: 购买套餐带宽限速和套餐失效取消带宽限速
This commit is contained in:
@@ -88,6 +88,15 @@ public class UAccountServiceImpl extends ServiceImpl<UAccountMapper, UAccount> i
|
|||||||
for (UClient client : clients) {
|
for (UClient client : clients) {
|
||||||
try {
|
try {
|
||||||
omadaAuthorizedClientApi.cancelAuthClient(client.getSiteId(), client.getClientMac());
|
omadaAuthorizedClientApi.cancelAuthClient(client.getSiteId(), client.getClientMac());
|
||||||
|
|
||||||
|
// 取消带宽限速
|
||||||
|
ClientRateLimitSetting clientRateLimitSetting = new ClientRateLimitSetting();
|
||||||
|
clientRateLimitSetting.setMode(0);
|
||||||
|
CustomRateLimitEntity customRateLimitEntity = new CustomRateLimitEntity();
|
||||||
|
customRateLimitEntity.setDownEnable(false);
|
||||||
|
customRateLimitEntity.setUpEnable(false);
|
||||||
|
clientRateLimitSetting.setCustomRateLimit(customRateLimitEntity);
|
||||||
|
omadaClientApi.updateClientRateLimitSetting(client.getSiteId(), client.getClientMac(), clientRateLimitSetting);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.info("unAuth error: {}", e.getMessage());
|
log.info("unAuth error: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ import org.springframework.beans.BeanUtils;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.wfc.common.security.utils.SecurityUtils;
|
import org.wfc.common.security.utils.SecurityUtils;
|
||||||
|
import org.wfc.omada.api.client.OmadaClientApi;
|
||||||
|
import org.wfc.omada.api.client.model.ClientRateLimitSetting;
|
||||||
|
import org.wfc.omada.api.client.model.CustomRateLimitEntity;
|
||||||
import org.wfc.omada.api.hotspot.OmadaAuthorizedClientApi;
|
import org.wfc.omada.api.hotspot.OmadaAuthorizedClientApi;
|
||||||
import org.wfc.user.domain.UAccount;
|
import org.wfc.user.domain.UAccount;
|
||||||
import org.wfc.user.domain.UClient;
|
import org.wfc.user.domain.UClient;
|
||||||
@@ -58,6 +61,9 @@ public class UOrderServiceImpl extends ServiceImpl<UOrderMapper, UOrder> impleme
|
|||||||
@Autowired
|
@Autowired
|
||||||
private OmadaAuthorizedClientApi omadaAuthorizedClientApi;
|
private OmadaAuthorizedClientApi omadaAuthorizedClientApi;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OmadaClientApi omadaClientApi;
|
||||||
|
|
||||||
public void paySuccess(Long orderId) {
|
public void paySuccess(Long orderId) {
|
||||||
// 支付成功回调(预留)
|
// 支付成功回调(预留)
|
||||||
|
|
||||||
@@ -66,14 +72,6 @@ public class UOrderServiceImpl extends ServiceImpl<UOrderMapper, UOrder> impleme
|
|||||||
order.setStatus(OrderStatusEnum.PAID.getCode());
|
order.setStatus(OrderStatusEnum.PAID.getCode());
|
||||||
this.updateById(order);
|
this.updateById(order);
|
||||||
|
|
||||||
// 授权当前用户的所有设备访问wifi
|
|
||||||
List<UClient> clients = clientService.list(Wrappers.<UClient>lambdaQuery().eq(UClient::getUserId, order.getUserId()));
|
|
||||||
for (UClient client : clients) {
|
|
||||||
if (StrUtil.isNotBlank(client.getSiteId())) {
|
|
||||||
omadaAuthorizedClientApi.authClient(client.getSiteId(), client.getClientMac());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 保存或更新账户信息
|
// 保存或更新账户信息
|
||||||
UAccount account = accountService.getOne(Wrappers.<UAccount>lambdaQuery().eq(UAccount::getUserId, order.getUserId()), false);
|
UAccount account = accountService.getOne(Wrappers.<UAccount>lambdaQuery().eq(UAccount::getUserId, order.getUserId()), false);
|
||||||
Long accountId = null;
|
Long accountId = null;
|
||||||
@@ -97,6 +95,30 @@ public class UOrderServiceImpl extends ServiceImpl<UOrderMapper, UOrder> impleme
|
|||||||
}
|
}
|
||||||
account.setId(accountId);
|
account.setId(accountId);
|
||||||
accountService.saveOrUpdate(account);
|
accountService.saveOrUpdate(account);
|
||||||
|
|
||||||
|
// 授权当前用户的所有设备访问wifi
|
||||||
|
List<UClient> clients = clientService.list(Wrappers.<UClient>lambdaQuery().eq(UClient::getUserId, order.getUserId()));
|
||||||
|
for (UClient client : clients) {
|
||||||
|
if (StrUtil.isNotBlank(client.getSiteId())) {
|
||||||
|
omadaAuthorizedClientApi.authClient(client.getSiteId(), client.getClientMac());
|
||||||
|
|
||||||
|
// 带宽限速
|
||||||
|
if (account.getRateLimitEnable()) {
|
||||||
|
ClientRateLimitSetting clientRateLimitSetting = new ClientRateLimitSetting();
|
||||||
|
clientRateLimitSetting.setMode(0);
|
||||||
|
CustomRateLimitEntity customRateLimitEntity = new CustomRateLimitEntity();
|
||||||
|
customRateLimitEntity.setDownEnable(account.getDownLimitEnable());
|
||||||
|
customRateLimitEntity.setDownLimit(account.getDownLimit() == null ? 0 : account.getDownLimit().intValue());
|
||||||
|
customRateLimitEntity.setDownUnit(1);
|
||||||
|
customRateLimitEntity.setUpEnable(account.getUpLimitEnable());
|
||||||
|
customRateLimitEntity.setUpLimit(account.getUpLimit() == null ? 0 : account.getUpLimit().intValue());
|
||||||
|
customRateLimitEntity.setUpUnit(1);
|
||||||
|
clientRateLimitSetting.setCustomRateLimit(customRateLimitEntity);
|
||||||
|
omadaClientApi.updateClientRateLimitSetting(client.getSiteId(), client.getClientMac(), clientRateLimitSetting);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void callbackPackage(UOrder order, UAccount account) {
|
private void callbackPackage(UOrder order, UAccount account) {
|
||||||
|
|||||||
Reference in New Issue
Block a user