fix: buy package
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
package org.wfc.user.domain.vo;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @description: 账户仪表盘Vo
|
||||
* @author: cyc
|
||||
* @since: 2024-12-25
|
||||
*/
|
||||
@Data
|
||||
public class UAccountDashboardVo {
|
||||
|
||||
private Long id;
|
||||
|
||||
private BigDecimal balance;
|
||||
|
||||
private Long packageId;
|
||||
|
||||
private Date startTime;
|
||||
|
||||
private Date endTime;
|
||||
|
||||
private Long trafficUsed;
|
||||
|
||||
private Long durationUsed;
|
||||
|
||||
private Integer clientNumUsed;
|
||||
|
||||
private String packageName;
|
||||
|
||||
private Integer periodNum;
|
||||
|
||||
private Integer periodType;
|
||||
|
||||
private BigDecimal price;
|
||||
|
||||
private Long traffic;
|
||||
|
||||
private Long duration;
|
||||
|
||||
private Integer clientNum;
|
||||
|
||||
private String remark;
|
||||
|
||||
private Boolean rateLimitEnable;
|
||||
|
||||
private Boolean trafficEnable;
|
||||
|
||||
private Boolean durationEnable;
|
||||
|
||||
private Boolean clientNumEnable;
|
||||
|
||||
private String rateLimitName;
|
||||
|
||||
private Long downLimit;
|
||||
|
||||
private Boolean downLimitEnable;
|
||||
|
||||
private Long upLimit;
|
||||
|
||||
private Boolean upLimitEnable;
|
||||
|
||||
private Long activity;
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package org.wfc.user.service;
|
||||
import org.wfc.user.api.domain.bo.UClientBo;
|
||||
import org.wfc.user.domain.UAccount;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.wfc.user.domain.vo.UAccountDashboardVo;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -25,4 +26,10 @@ public interface IUAccountService extends IService<UAccount> {
|
||||
*/
|
||||
void authClientAndRateLimit(UClientBo client);
|
||||
|
||||
/**
|
||||
* 首页仪表盘查询
|
||||
* @return
|
||||
*/
|
||||
UAccountDashboardVo getByUser();
|
||||
|
||||
}
|
||||
|
||||
@@ -6,9 +6,12 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.wfc.common.core.domain.LoginUser;
|
||||
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;
|
||||
@@ -16,12 +19,14 @@ import org.wfc.omada.api.hotspot.OmadaAuthorizedClientApi;
|
||||
import org.wfc.user.api.domain.bo.UClientBo;
|
||||
import org.wfc.user.domain.UAccount;
|
||||
import org.wfc.user.domain.UClient;
|
||||
import org.wfc.user.domain.vo.UAccountDashboardVo;
|
||||
import org.wfc.user.domain.vo.UCdrUserVo;
|
||||
import org.wfc.user.mapper.UAccountMapper;
|
||||
import org.wfc.user.mapper.UCdrMapper;
|
||||
import org.wfc.user.mapper.UClientMapper;
|
||||
import org.wfc.user.service.IUAccountService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -113,4 +118,27 @@ public class UAccountServiceImpl extends ServiceImpl<UAccountMapper, UAccount> i
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UAccountDashboardVo getByUser() {
|
||||
LoginUser<Object> loginUser = SecurityUtils.getLoginUser();
|
||||
UAccount account = this.getOne(Wrappers.<UAccount>lambdaQuery().eq(UAccount::getUserId, loginUser.getUserid()), false);
|
||||
UAccountDashboardVo dashboardVo = new UAccountDashboardVo();
|
||||
if (ObjectUtil.isNull(account)) {
|
||||
dashboardVo.setId(loginUser.getUserid());
|
||||
dashboardVo.setBalance(BigDecimal.ZERO);
|
||||
dashboardVo.setTraffic(0L);
|
||||
dashboardVo.setDuration(0L);
|
||||
dashboardVo.setTrafficUsed(0L);
|
||||
dashboardVo.setDurationUsed(0L);
|
||||
dashboardVo.setClientNum(0);
|
||||
dashboardVo.setClientNumUsed(0);
|
||||
dashboardVo.setActivity(0L);
|
||||
} else {
|
||||
BeanUtils.copyProperties(account, dashboardVo);
|
||||
dashboardVo.setId(loginUser.getUserid());
|
||||
dashboardVo.setActivity(0L);
|
||||
}
|
||||
return dashboardVo;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -28,6 +29,7 @@ import org.wfc.user.service.IURateLimitService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
@@ -64,18 +66,24 @@ public class UOrderServiceImpl extends ServiceImpl<UOrderMapper, UOrder> impleme
|
||||
order.setStatus(OrderStatusEnum.PAID.getCode());
|
||||
this.updateById(order);
|
||||
|
||||
// 授权当前设备访问wifi
|
||||
UClient client = clientService.getOne(Wrappers.<UClient>lambdaQuery().eq(UClient::getUserId, order.getUserId()), false);
|
||||
if (ObjectUtil.isNull(client)) {
|
||||
omadaAuthorizedClientApi.authClient(client.getSiteId(), client.getClientMac());
|
||||
// 授权当前用户的所有设备访问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);
|
||||
Long accountId = null;
|
||||
if (ObjectUtil.isNull(account)) {
|
||||
account = new UAccount();
|
||||
account.setUserId(order.getUserId());
|
||||
account.setBalance(BigDecimal.ZERO);
|
||||
} else {
|
||||
accountId = account.getId();
|
||||
}
|
||||
Long accountId = account.getId();
|
||||
if (OrderTypeEnum.PACKAGE.getCode().equals(order.getType())) {
|
||||
// 套餐
|
||||
callbackPackage(order, account);
|
||||
@@ -100,6 +108,7 @@ public class UOrderServiceImpl extends ServiceImpl<UOrderMapper, UOrder> impleme
|
||||
BeanUtils.copyProperties(rateLimit, account);
|
||||
}
|
||||
BeanUtils.copyProperties(uPackage, account);
|
||||
account.setPackageId(order.getPackageId());
|
||||
account.setTrafficUsed(0L);
|
||||
account.setDurationUsed(0L);
|
||||
account.setClientNumUsed(0);
|
||||
|
||||
Reference in New Issue
Block a user