feat: 多套餐查看
This commit is contained in:
@@ -24,10 +24,10 @@ import java.util.List;
|
|||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author sys
|
* @author sys
|
||||||
* @since 2025-02-10
|
* @since 2025-03-13
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/user/uAccountPackage")
|
@RequestMapping("/accountPackage")
|
||||||
public class UAccountPackageController extends BaseController {
|
public class UAccountPackageController extends BaseController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -36,13 +36,13 @@ public class UAccountPackageController extends BaseController {
|
|||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
public TableDataInfo page(UAccountPackage uAccountPackage) {
|
public TableDataInfo page(UAccountPackage uAccountPackage) {
|
||||||
startPage();
|
startPage();
|
||||||
List<UAccountPackage> list = uAccountPackageService.list();
|
List<UAccountPackage> list = uAccountPackageService.queryList(uAccountPackage);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult list(UAccountPackage uAccountPackage) {
|
public AjaxResult list(UAccountPackage uAccountPackage) {
|
||||||
List<UAccountPackage> list = uAccountPackageService.list();
|
List<UAccountPackage> list = uAccountPackageService.queryList(uAccountPackage);
|
||||||
return success(list);
|
return success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,14 +3,17 @@ package org.wfc.user.service;
|
|||||||
import org.wfc.user.domain.UAccountPackage;
|
import org.wfc.user.domain.UAccountPackage;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 用户平台-账户套餐表 服务类
|
* 用户平台-账户套餐表 服务类
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author sys
|
* @author sys
|
||||||
* @since 2025-02-10
|
* @since 2025-03-13
|
||||||
*/
|
*/
|
||||||
public interface IUAccountPackageService extends IService<UAccountPackage> {
|
public interface IUAccountPackageService extends IService<UAccountPackage> {
|
||||||
|
|
||||||
|
List<UAccountPackage> queryList(UAccountPackage uAccountPackage);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,21 @@
|
|||||||
package org.wfc.user.service.impl;
|
package org.wfc.user.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.wfc.common.security.utils.SecurityUtils;
|
||||||
|
import org.wfc.user.domain.UAccount;
|
||||||
import org.wfc.user.domain.UAccountPackage;
|
import org.wfc.user.domain.UAccountPackage;
|
||||||
|
import org.wfc.user.mapper.UAccountMapper;
|
||||||
import org.wfc.user.mapper.UAccountPackageMapper;
|
import org.wfc.user.mapper.UAccountPackageMapper;
|
||||||
import org.wfc.user.service.IUAccountPackageService;
|
import org.wfc.user.service.IUAccountPackageService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.springframework.stereotype.Service;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -12,9 +23,46 @@ import org.springframework.stereotype.Service;
|
|||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author sys
|
* @author sys
|
||||||
* @since 2025-02-10
|
* @since 2025-03-13
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class UAccountPackageServiceImpl extends ServiceImpl<UAccountPackageMapper, UAccountPackage> implements IUAccountPackageService {
|
public class UAccountPackageServiceImpl extends ServiceImpl<UAccountPackageMapper, UAccountPackage> implements IUAccountPackageService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UAccountMapper accountMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UAccountPackage> queryList(UAccountPackage uAccountPackage) {
|
||||||
|
UAccount account = accountMapper.selectOne(Wrappers.<UAccount>lambdaQuery().eq(UAccount::getUserId, SecurityUtils.getLoginUser().getUserid()), false);
|
||||||
|
if (ObjectUtil.isNotNull(account)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
uAccountPackage.setAccountId(account.getId());
|
||||||
|
return this.list(buildQueryWrapper(uAccountPackage));
|
||||||
|
}
|
||||||
|
|
||||||
|
private LambdaQueryWrapper<UAccountPackage> buildQueryWrapper(UAccountPackage bo) {
|
||||||
|
LambdaQueryWrapper<UAccountPackage> lqw = Wrappers.lambdaQuery();
|
||||||
|
lqw.eq(bo.getAccountId() != null, UAccountPackage::getAccountId, bo.getAccountId());
|
||||||
|
lqw.eq(bo.getPackageId() != null, UAccountPackage::getPackageId, bo.getPackageId());
|
||||||
|
lqw.eq(bo.getTraffic() != null, UAccountPackage::getTraffic, bo.getTraffic());
|
||||||
|
lqw.eq(bo.getDuration() != null, UAccountPackage::getDuration, bo.getDuration());
|
||||||
|
lqw.eq(bo.getClientNum() != null, UAccountPackage::getClientNum, bo.getClientNum());
|
||||||
|
lqw.eq(bo.getExpiredTime() != null, UAccountPackage::getExpiredTime, bo.getExpiredTime());
|
||||||
|
lqw.like(StrUtil.isNotBlank(bo.getPackageName()), UAccountPackage::getPackageName, bo.getPackageName());
|
||||||
|
lqw.eq(bo.getPeriodNum() != null, UAccountPackage::getPeriodNum, bo.getPeriodNum());
|
||||||
|
lqw.eq(bo.getPeriodType() != null, UAccountPackage::getPeriodType, bo.getPeriodType());
|
||||||
|
lqw.eq(bo.getPrice() != null, UAccountPackage::getPrice, bo.getPrice());
|
||||||
|
lqw.like(StrUtil.isNotBlank(bo.getRemark()), UAccountPackage::getRemark, bo.getRemark());
|
||||||
|
lqw.eq(bo.getRateLimitEnable() != null, UAccountPackage::getRateLimitEnable, bo.getRateLimitEnable());
|
||||||
|
lqw.eq(bo.getTrafficEnable() != null, UAccountPackage::getTrafficEnable, bo.getTrafficEnable());
|
||||||
|
lqw.eq(bo.getDurationEnable() != null, UAccountPackage::getDurationEnable, bo.getDurationEnable());
|
||||||
|
lqw.eq(bo.getClientNumEnable() != null, UAccountPackage::getClientNumEnable, bo.getClientNumEnable());
|
||||||
|
lqw.like(StrUtil.isNotBlank(bo.getRateLimitName()), UAccountPackage::getRateLimitName, bo.getRateLimitName());
|
||||||
|
lqw.eq(bo.getDownLimit() != null, UAccountPackage::getDownLimit, bo.getDownLimit());
|
||||||
|
lqw.eq(bo.getDownLimitEnable() != null, UAccountPackage::getDownLimitEnable, bo.getDownLimitEnable());
|
||||||
|
lqw.eq(bo.getUpLimit() != null, UAccountPackage::getUpLimit, bo.getUpLimit());
|
||||||
|
lqw.eq(bo.getUpLimitEnable() != null, UAccountPackage::getUpLimitEnable, bo.getUpLimitEnable());
|
||||||
|
return lqw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,7 +177,9 @@ public class UAccountServiceImpl extends ServiceImpl<UAccountMapper, UAccount> i
|
|||||||
if (accountPackageOptional.isPresent()) {
|
if (accountPackageOptional.isPresent()) {
|
||||||
wifiApi.reconnectClient(site.getSiteId(), client.getMac());
|
wifiApi.reconnectClient(site.getSiteId(), client.getMac());
|
||||||
UAccountPackage accountPackage = accountPackageOptional.get();
|
UAccountPackage accountPackage = accountPackageOptional.get();
|
||||||
|
Long accountId = account.getId();
|
||||||
BeanUtils.copyProperties(accountPackage, account);
|
BeanUtils.copyProperties(accountPackage, account);
|
||||||
|
account.setId(accountId);
|
||||||
account.setTrafficUsed(0L);
|
account.setTrafficUsed(0L);
|
||||||
account.setDurationUsed(0L);
|
account.setDurationUsed(0L);
|
||||||
account.setClientNumUsed(0);
|
account.setClientNumUsed(0);
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ public class UOrderServiceImpl extends ServiceImpl<UOrderMapper, UOrder> impleme
|
|||||||
} else {
|
} else {
|
||||||
accountId = account.getId();
|
accountId = account.getId();
|
||||||
oldBalance = account.getBalance();
|
oldBalance = account.getBalance();
|
||||||
isValid = AccountUtil.isValid(account, new Date());
|
isValid = AccountUtil.isPackageValid(account, new Date());
|
||||||
}
|
}
|
||||||
if (OrderTypeEnum.PACKAGE.getCode().equals(order.getType())) {
|
if (OrderTypeEnum.PACKAGE.getCode().equals(order.getType())) {
|
||||||
// 套餐
|
// 套餐
|
||||||
@@ -195,6 +195,7 @@ public class UOrderServiceImpl extends ServiceImpl<UOrderMapper, UOrder> impleme
|
|||||||
if (isValid) {
|
if (isValid) {
|
||||||
BeanUtils.copyProperties(uPackage, accountPackage);
|
BeanUtils.copyProperties(uPackage, accountPackage);
|
||||||
accountPackage.setId(null);
|
accountPackage.setId(null);
|
||||||
|
accountPackage.setAccountId(account.getId());
|
||||||
accountPackage.setPackageId(order.getPackageId());
|
accountPackage.setPackageId(order.getPackageId());
|
||||||
accountPackageMapper.insert(accountPackage);
|
accountPackageMapper.insert(accountPackage);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user