Compare commits

..

66 Commits

Author SHA1 Message Date
d5c51a80c6 fix(system): 修正WebAI过期账号禁用逻辑中的字段引用错误 2025-12-15 21:09:33 +08:00
aa905d47ac refactor(system): 修正类名大小写规范 2025-12-11 21:03:11 +08:00
40c0f96518 feat(system): 新增定时任务禁用过期WebAI账号 2025-12-11 20:58:23 +08:00
8ae9dda7e6 fix(system): 修正租户余额与套餐价格比较逻辑 2025-12-05 21:16:45 +08:00
dbaba2532c Merge branch 'agency' 2025-12-05 20:39:42 +08:00
4dffbb4e11 fix(system): 为租户套餐响应VO添加字段Swagger注解并补充days属性 2025-12-05 20:37:22 +08:00
aa3171d1ab feat(system): 新增 Web AI 客户端权限控制字段 2025-12-05 15:11:36 +08:00
08243e390e fix(mapper): 修复删除状态过滤条件并新增主播类型筛选 2025-12-03 15:19:03 +08:00
9a991e527a feat(tkdata): 新增按删除状态筛选主播/大哥 2025-12-02 16:31:43 +08:00
cece05fd1f refactor(tenant-package): 精简代理套餐VO并调整枚举值
- 去除AgencyTenantPackageSimpleRespVO的冗余校验注解
- 调整PackageTypeEnum代理类型数值199→999
- 精简列表接口返回TenantAgencyPackageDO并补充packageType、price字段
- 同步更新Service与Controller类型与调用链
2025-11-28 14:27:39 +08:00
7cda6e8781 feat(test): 新增测试环境专用配置 2025-11-27 14:18:44 +08:00
cdaf7ce631 feat(system): 新增Ai自动回复权限字段 2025-11-27 13:26:32 +08:00
aebeaaeabe feat(system): 新增AI自动回复权限字段并补充字段备注
在代理套餐及积分相关VO/DO中:
- 新增 aiReplay 字段(0关闭 1开启)
- 为租户积分记录补充 remark 字段及描述
- 同步更新相关查询、保存、响应VO与Service实现
2025-11-26 20:20:20 +08:00
646bc77c7b fix(system): 支持代理套餐的租户更新逻辑 2025-11-26 16:13:17 +08:00
42ec325815 feat(system): 新增代理租户续费功能及多级代理支持 2025-11-26 13:38:53 +08:00
d99bb17419 fix(system): 移除BalanceEnum中BONUS值的多余空格 2025-11-25 18:40:36 +08:00
a4ce439f7c refactor(system): 为租户测试账号操作增加备注参数 2025-11-25 16:20:23 +08:00
bfc2b21872 feat(system): 新增租户测试账户增减及奖励类型支持
- BalanceEnum 增加 BONUS 奖励类型
- ErrorCodeConstants 补充测试账户不足/操作错误码
- TenantBalanceMapper 添加乐观锁更新测试账户数方法
- TenantBalanceService 新增 reduceTestAccountNum/addTestAccountNum
- TenantBalanceServiceImpl 实现测试账户扣减与奖励发放逻辑
- TenantPointsDO/VO 增加 testAccountNum 字段
- TenantServiceImpl 创建租户时根据套餐类型自动增减测试账户
- 新增 PackageTypeEnum 枚举区分测试/代理/普通套餐
2025-11-25 16:16:28 +08:00
e366af0493 feat(system): 增加测试账号数字段支持代理场景 2025-11-25 15:18:13 +08:00
95f2e88296 feat(tenant-agency): 新增代理套餐精简列表接口 2025-11-25 14:58:15 +08:00
d05ce7336c fix(tenant): 修正代理租户套餐MyBatis映射及VO类型错误 2025-11-24 21:18:15 +08:00
43dd7cf768 fix(config): 添加代理租户类型过滤条件 2025-11-24 20:11:56 +08:00
d879ff7dc9 feat(system): 增加代理租户创建失败错误码并重构套餐逻辑 2025-11-24 19:43:19 +08:00
0d57c0a5f8 feat(system): 新增套餐消费与余额校验逻辑
- 为 TenantAgencyPackage 增加 validTenantPackage 校验方法
- 在 TenantBalanceService 中实现基于套餐的消费接口
- 新增租户余额消费失败错误码 TENANT_BALANCE_CONSUMPTION_OPERATION_ERROR
- 将积分记录 orderId 类型由 Long 改为 String 以兼容业务流水号
- 消费时自动生成 CONSUMPTION/ORDER 业务编号并记录积分变动
2025-11-24 16:46:15 +08:00
016b4df3e8 feat(system): 新增代理租户套餐管理模块
- 新增 TenantAgencyPackage 实体、Mapper、Service 及 Controller 全套后端
- 新增租户余额消费接口及 VO(预留实现)
- 移除废弃的社交登录相关错误码,补充代理套餐错误码 TENANT_AGENCY_PACKAGE_NOT_EXISTS
- 配置文件增加 system_tenant_agency_package 缓存忽略

共 15 个文件,+578 −7 行,复杂度:非常复杂
2025-11-24 15:59:04 +08:00
f03877c1d5 fix(system): 修复租户积分查询时间条件判断逻辑 2025-11-24 15:15:43 +08:00
023a01b7a2 refactor(system): 租户积分分页查询改为XML连表并返回VO 2025-11-24 15:10:06 +08:00
30bbbfb729 fix(system): 增加租户转账下级校验并补充错误码
校验目标租户必须为当前租户下级,新增 TENANT_BALANCE_TRANSFER_ERROR_TARGET_NOT_SUBORDINATE 错误码,防止越权转账。
2025-11-24 14:28:23 +08:00
500feb74cb fix(system): 限制租户只能查看自己的积分记录 2025-11-24 14:08:46 +08:00
cf6290d3b4 refactor(system): 拆分转账枚举为转入与转出类型 2025-11-24 13:58:48 +08:00
a65400b3e8 refactor(tenant-balance): 将变动描述字段改为备注并自动生成描述 2025-11-21 21:23:57 +08:00
90039ad7ae feat(system): 新增租户积分交易历史分页接口 2025-11-21 21:20:25 +08:00
431c943019 feat(system): 增加租户代理层级控制与级别校验 2025-11-21 19:50:04 +08:00
5a15f2208b fix(system): 修正租户转账记录中目标租户ID设置错误 2025-11-21 18:04:24 +08:00
fdbd90c6de refactor(system): 重构业务流水号生成器并优化租户转账描述
- 将 BizNoGenerator 改为基于 Hutool Snowflake 的全局唯一 ID,移除每日自增序列逻辑
- TenantBalanceTransferReqVO 用 password/remark 替换原 description 字段
- TenantPointsDO 新增 remark 字段
- 转账记录自动生成“转账给租户 X,金额:Y”与“转账来自租户 X,金额:Y”描述,并写入 remark
2025-11-21 16:10:41 +08:00
dfdedbb92d feat(tenant-balance): 新增查询自身及下级余额接口
- Controller 增加 /get-self-amount 与 /get-self-subordinate-amount-page 端点
- Service 与 Mapper 实现当前租户余额查询及下级分页查询
- RespVO 移除乐观锁字段,改用 updatedAt 并补充 tenantName 展示
2025-11-21 15:51:17 +08:00
1c40343c6d feat(system): 新增租户余额转账功能 2025-11-20 22:08:54 +08:00
36a5b3bd0d feat(system): 新增租户类型字段并支持代理钱包初始化 2025-11-20 20:30:52 +08:00
78b6f5624b feat(system): 租户余额列表新增租户名称字段并支持变动描述
- 在分页查询中联表返回租户名称,提升列表可读性
- 新增变动描述字段,支持充值等操作记录具体原因
- 优化 Mapper 与 Service 返回类型,统一使用 TenantBalanceRespVO
2025-11-20 19:15:31 +08:00
3466996f07 feat(system): 新增租户余额版本号校验与充值错误码
补充乐观锁场景下的版本号、余额异常及充值失败专用错误码,为后续余额并发更新提供精确异常定位。
2025-11-20 18:26:35 +08:00
ebf071b225 feat(tenant-balance): 新增后台给租户充值余额接口 2025-11-19 22:10:39 +08:00
f00e250be9 feat(tenant-balance): 新增租户余额管理功能
新增租户余额实体、Mapper、Service、Controller 及对应 VO,支持余额分页查询、保存与错误码定义。
2025-11-19 21:04:06 +08:00
c75df4743d feat(system): 新增租户积分管理功能
新增租户积分实体、Mapper、Service及Controller全套代码,并补充对应错误码TENANT_POINTS_NOT_EXISTS。
2025-11-19 20:39:29 +08:00
6e0f41e661 feat(system): 新增代理租户查询下属租户分页接口 2025-11-18 19:21:44 +08:00
5f84fd31b6 feat(system): 新增爬虫过期账号禁用任务并重构AI过期逻辑 2025-11-18 14:56:04 +08:00
3ade777ac2 fix(system): 修复过期账号任务仅处理有效用户
补充 AI 与大哥账号查询条件,避免全表扫描
2025-11-17 21:26:19 +08:00
4c42809d3b feat(employee-big-brother): 新增建联率统计与柱状图接口
- Controller 增加 /self_complete、/employeeCompleteBarChart 两个端点
- Mapper 新增 selectEmployeeBrotherCompleteBarChart、selectEmployeeBrotherWithOperationStatus 查询
- Service 层实现个人及多用户建联率统计逻辑
- XML 补充对应 SQL,支持按天数与用户列表过滤
2025-11-12 19:15:42 +08:00
10c5b04c32 feat(system): 新增用户AI回复开关字段 2025-11-07 13:56:56 +08:00
9519000a75 feat(tenant): 新增租户多维度到期时间查询条件 2025-10-31 14:33:00 +08:00
d9e2d188c1 1.添加主播直播类型模糊搜索 2025-10-27 19:49:22 +08:00
2145c51814 1.首页统计数量添加过去 7 天建联统计 2025-10-17 15:13:08 +08:00
a7582cb558 1.修复首页统计数量错误问题 2025-10-15 18:26:16 +08:00
145034b908 1.添加主播信息,员工主播信息英文国家名字段 2025-10-13 17:55:49 +08:00
35be251a00 1.大哥添加粉丝团等级 2025-09-23 16:21:47 +08:00
20a5e249aa 1.取消ai过期时间不能空限制
2.取消大哥过期时间不能为空的限制
2025-09-16 19:40:11 +08:00
b29431de5b 1.修改定时任务逻辑 2025-09-16 18:02:45 +08:00
3cc79b6c46 1.ai账号过期时间,大哥过期时间控制
2.定时任务处理过期账户的登录权限
2025-09-16 16:44:08 +08:00
b677fd0b0f 1.员工查询 xml 添加 deleted = 0 判断 2025-09-15 18:54:39 +08:00
a223f33ed0 1.员工查询排序问题修复 2025-09-10 16:33:08 +08:00
2d1528b392 1.修复管理查询员工数据分页查询重复的问题 2025-09-10 15:57:08 +08:00
e53998446b 1.管理首页柱状图统计数据去重 2025-09-10 14:34:52 +08:00
2650aadcbd 1.租户添加备注和备注模糊搜索功能 2025-09-10 14:11:52 +08:00
7b88322ffa 1.修复管理查看到员工今日建联数量空指针的问题 2025-09-09 20:55:46 +08:00
18822ef3e1 1.管理能查看到员工今日建联数量 2025-09-09 20:31:28 +08:00
4411d38b39 1.添加员工主播数据更新字段查询 2025-09-05 22:17:18 +08:00
e3c820271d 1.修复添加员工导出主播功能 2025-09-04 20:51:59 +08:00
99 changed files with 4120 additions and 72 deletions

View File

@@ -139,4 +139,13 @@ public class BigBrotherPageReqVO extends PageParam {
@Schema(description = "国家名称")
private String countryName;
@Schema(description = "粉丝团等级", example = "0")
private Integer fansLevel;
@Schema(description = "粉丝团等级最大值", example = "0")
private Integer fansLevelMax;
@Schema(description = "粉丝团等级最小值", example = "0")
private Integer fansLevelMin;
}

View File

@@ -71,4 +71,8 @@ public class BigBrotherRespVO {
@Schema(description = "是否分配")
@ExcelProperty("是否分配")
private Byte isAssigned;
@Schema(description = "粉丝团等级", example = "0")
@ExcelProperty("粉丝团等级")
private Integer fansLevel;
}

View File

@@ -55,4 +55,8 @@ public class BigBrotherSaveReqVO {
@Schema(description = "是否分配", example = "0")
private Byte isAssigned;
@Schema(description = "粉丝团等级", example = "0")
private Integer fansLevel;
}

View File

@@ -6,9 +6,12 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.tkdata.controller.admin.employeebigbrother.vo.EmployeeBigBrotherPageReqVO;
import cn.iocoder.yudao.module.tkdata.controller.admin.employeebigbrother.vo.EmployeeBigBrotherRespVO;
import cn.iocoder.yudao.module.tkdata.controller.admin.employeebigbrother.vo.EmployeeBigBrotherSaveReqVO;
import cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo.CompletedRateVO;
import cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo.EmployeeCompleteBarChartReqVO;
import cn.iocoder.yudao.module.tkdata.dal.dataobject.employeebigbrother.EmployeeBigBrotherDO;
import cn.iocoder.yudao.module.tkdata.service.employeebigbrother.EmployeeBigBrotherService;
import io.swagger.v3.oas.annotations.Operation;
@@ -125,4 +128,20 @@ public class EmployeeBigBrotherController {
employeeBigBrotherService.batchUpdateEmployeeBigBrother(updateReqVO);
return success(true);
}
@GetMapping("/self_complete")
@Operation(summary = "获得自己的建联率")
@PreAuthorize("@ss.hasPermission('server:employee-hosts:selfquery')")
public CommonResult<CompletedRateVO> getEmployeeHostsCompleteWithSelf() {
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
return success(employeeBigBrotherService.getEmployeeHostsCompleteWithSelf(loginUserId));
}
@PostMapping("/employeeCompleteBarChart")
@Operation(summary = "获得员工的建联柱状图数据")
@PreAuthorize("@ss.hasPermission('server:employee-big-brother:selfquery')")
public CommonResult<List<CompletedRateVO>> getEmployeeCompleteBarChart(@RequestBody EmployeeCompleteBarChartReqVO reqVO) {
return success(employeeBigBrotherService.getEmployeeBrotherCompleteBarChart(reqVO.getUserId(),reqVO.getDays()));
}
}

View File

@@ -138,4 +138,16 @@ public class EmployeeBigBrotherPageReqVO extends PageParam {
@Schema(description = "国家名称")
private String countryName;
@Schema(description = "粉丝团等级", example = "0")
private Integer fansLevel;
@Schema(description = "粉丝团等级最大值", example = "0")
private Integer fansLevelMax;
@Schema(description = "粉丝团等级最小值", example = "0")
private Integer fansLevelMin;
@Schema(description = "是否删除", example = "0")
private Integer isDelete;
}

View File

@@ -72,4 +72,7 @@ public class EmployeeBigBrotherRespVO {
@ExcelProperty("是否洽谈")
private Integer operationStatus;
@Schema(description = "粉丝团等级", example = "0")
@ExcelProperty("粉丝团等级")
private Integer fansLevel;
}

View File

@@ -49,4 +49,6 @@ public class EmployeeBigBrotherSaveReqVO {
@Schema(description = "是否洽谈", example = "2")
private Integer operationStatus;
@Schema(description = "粉丝团等级", example = "0")
private Integer fansLevel;
}

View File

@@ -112,6 +112,21 @@ public class EmployeeHostsController {
BeanUtils.toBean(list, EmployeeHostsRespVO.class));
}
@GetMapping("/export-employee-excel")
@Operation(summary = "导出员工分配主播Excel")
@PreAuthorize("@ss.hasPermission('server:employee-self-hosts:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportEmployeeSelfHostsExcel(@Valid EmployeeHostsPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
PageResult<EmployeeHostsDO> employeeHostsPageWithSelf = employeeHostsService.getEmployeeHostsPageWithSelf(pageReqVO);
List<EmployeeHostsDO> list = employeeHostsPageWithSelf.getList();
// 导出 Excel
ExcelUtils.write(response, "员工分配主播.xls", "数据", EmployeeHostsRespVO.class,
BeanUtils.toBean(list, EmployeeHostsRespVO.class));
}
@PostMapping("/allocation")
@Operation(summary = "批量分配主播给员工")
@PreAuthorize("@ss.hasPermission('server:employee-hosts:allocation')")
@@ -134,8 +149,6 @@ public class EmployeeHostsController {
return success(employeeHostsService.getEmployeeHostsCompleteWithSelf(userId));
}
@GetMapping("/self_complete")
@Operation(summary = "获得自己的建联率")
@PreAuthorize("@ss.hasPermission('server:employee-hosts:selfquery')")
@@ -143,4 +156,12 @@ public class EmployeeHostsController {
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
return success(employeeHostsService.getEmployeeHostsCompleteWithSelf(loginUserId));
}
@PostMapping("/employeeCompleteBarChart")
@Operation(summary = "获得员工的建联柱状图数据")
@PreAuthorize("@ss.hasPermission('server:employee-hosts:selfquery')")
public CommonResult<List<CompletedRateVO>> getEmployeeCompleteBarChart(@RequestBody EmployeeCompleteBarChartReqVO reqVO) {
return success(employeeHostsService.getEmployeeHostsCompleteBarChart(reqVO.getUserId(),reqVO.getDays()));
}
}

View File

@@ -1,17 +1,26 @@
package cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/*
* @author: ziin
* @date: 2025/8/6 15:13
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "管理后台 - 员工建联完成率")
public class CompletedRateVO {
private Long userId;
private Integer finishedNum;
private Integer UnfinishedNum;
private Integer totalNum;
public CompletedRateVO(Long userId, int i) {
this.userId = userId;
this.finishedNum = i;
}
}

View File

@@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo;
import lombok.Data;
import java.util.List;
/*
* @author: ziin
* @date: 2025/10/17 14:55
*/
@Data
public class EmployeeCompleteBarChartReqVO {
private List<Long> userId;
private Integer days;
}

View File

@@ -56,6 +56,10 @@ public class EmployeeHostsPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime createTime;
@Schema(description = "数据更新时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime updateTime;
/**
* 昨日金币最大值
*/
@@ -129,4 +133,10 @@ public class EmployeeHostsPageReqVO extends PageParam {
@Schema(description = "旗帜")
private String flag;
@Schema(description = "国家英文名", example = "United States")
private String countryEng;
@Schema(description = "是否删除", example = "0")
private Integer isDelete;
}

View File

@@ -79,4 +79,7 @@ public class EmployeeHostsRespVO {
@Schema(description = "旗帜")
private String flag;
@Schema(description = "国家英文名", example = "United States")
private String countryEng;
}

View File

@@ -53,4 +53,7 @@ public class EmployeeHostsSaveReqVO {
@Schema(description = "旗帜")
private String flag;
@Schema(description = "国家英文名", example = "United States")
private String countryEng;
}

View File

@@ -54,6 +54,10 @@ public class NewHostsPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime createTime;
@Schema(description = "数据插入时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime updateTime;
@Schema(description = "用户 Id", example = "10967")
private Long userId;
@@ -141,4 +145,7 @@ public class NewHostsPageReqVO extends PageParam {
@Schema(description = "旗帜")
private String flag;
@Schema(description = "国家英文名", example = "United States")
private String countryEng;
}

View File

@@ -90,4 +90,8 @@ public class NewHostsRespVO {
@Schema(description = "旗帜")
@ExcelProperty("旗帜")
private String flag;
@Schema(description = "国家英文名", example = "United States")
@ExcelProperty("国家英文名")
private String countryEng;
}

View File

@@ -82,4 +82,6 @@ public class BigBrotherDO extends BaseDO {
private Long tenantId;
private Integer isAssigned;
private Integer fansLevel;
}

View File

@@ -82,4 +82,5 @@ public class EmployeeBigBrotherDO extends BaseDO {
private Long tenantId;
private Integer fansLevel;
}

View File

@@ -85,4 +85,6 @@ public class EmployeeHostsDO extends BaseDO {
private Long tenantId;
private String flag;
private String countryEng;
}

View File

@@ -85,4 +85,6 @@ public class NewHostsDO extends TenantBaseDO {
* 是否建联
*/
private Byte operationStatus;
private String countryEng;
}

View File

@@ -3,11 +3,14 @@ package cn.iocoder.yudao.module.tkdata.dal.mysql.employeebigbrother;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.tkdata.controller.admin.employeebigbrother.vo.EmployeeBigBrotherPageReqVO;
import cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo.CompletedRateVO;
import cn.iocoder.yudao.module.tkdata.dal.dataobject.employeebigbrother.EmployeeBigBrotherDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 大哥数据员工业务 Mapper
*
@@ -20,4 +23,9 @@ public interface EmployeeBigBrotherMapper extends BaseMapperX<EmployeeBigBrother
IPage<EmployeeBigBrotherDO> selectPagewithSelf(@Param("page") IPage<EmployeeBigBrotherDO> iPage,@Param("dto") EmployeeBigBrotherPageReqVO pageReqVO);
List<CompletedRateVO> selectEmployeeBrotherCompleteBarChart(@Param("list") List<Long> list, @Param("days") Integer days);
CompletedRateVO selectEmployeeBrotherWithOperationStatus(@Param("userId") Long userId);
}

View File

@@ -33,4 +33,6 @@ public interface EmployeeHostsMapper extends BaseMapperX<EmployeeHostsDO> {
void batchUpdate(ArrayList<EmployeeHostsDO> employeeHostsDOS);
CompletedRateVO selectEmployeeHostsWithOperationStatus(@Param("userId") Long userId);
List<CompletedRateVO> selectEmployeeHostsCompleteBarChart(@Param("list") List<Long> list, @Param("days") Integer days);
}

View File

@@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.tkdata.job;
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

View File

@@ -5,7 +5,9 @@ import javax.validation.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.tkdata.controller.admin.employeebigbrother.vo.EmployeeBigBrotherPageReqVO;
import cn.iocoder.yudao.module.tkdata.controller.admin.employeebigbrother.vo.EmployeeBigBrotherSaveReqVO;
import cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo.CompletedRateVO;
import cn.iocoder.yudao.module.tkdata.dal.dataobject.employeebigbrother.EmployeeBigBrotherDO;
import org.apache.ibatis.annotations.Param;
/**
@@ -65,4 +67,8 @@ public interface EmployeeBigBrotherService {
PageResult<EmployeeBigBrotherDO> getEmployeeBigBrotherPageWithSelf(@Valid EmployeeBigBrotherPageReqVO pageReqVO);
void batchUpdateEmployeeBigBrother(@Valid List<EmployeeBigBrotherSaveReqVO> updateReqVO);
List<CompletedRateVO> getEmployeeBrotherCompleteBarChart(@Param("list") List<Long> list, @Param("days") Integer days);
CompletedRateVO getEmployeeHostsCompleteWithSelf(Long loginUserId);
}

View File

@@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.tkdata.controller.admin.employeebigbrother.vo.EmployeeBigBrotherPageReqVO;
import cn.iocoder.yudao.module.tkdata.controller.admin.employeebigbrother.vo.EmployeeBigBrotherSaveReqVO;
import cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo.CompletedRateVO;
import cn.iocoder.yudao.module.tkdata.dal.dataobject.bigbrother.BigBrotherDO;
import cn.iocoder.yudao.module.tkdata.dal.dataobject.employeebigbrother.EmployeeBigBrotherDO;
import cn.iocoder.yudao.module.tkdata.dal.dataobject.employeehosts.EmployeeHostsDO;
@@ -21,6 +22,8 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
@@ -157,4 +160,36 @@ public class EmployeeBigBrotherServiceImpl implements EmployeeBigBrotherService
employeeBigBrotherMapper.updateBatch(employeeBigBrotherDOS);
}
@Override
public List<CompletedRateVO> getEmployeeBrotherCompleteBarChart(List<Long> userIdList, Integer days) {
List<CompletedRateVO> dbList = employeeBigBrotherMapper.selectEmployeeBrotherCompleteBarChart(userIdList,days);
try {
// 2. 转 Mapkey 是 userId
Map<Long, CompletedRateVO> dbMap = dbList.stream()
.collect(Collectors.toMap(
CompletedRateVO::getUserId,
Function.identity(),
(oldVal, newVal) -> newVal)); // 重复时保留新的
// 3. 组装结果
return userIdList.stream()
.map(userId -> dbMap.getOrDefault(userId, new CompletedRateVO(userId, 0))) // 缺数据补0
.collect(Collectors.toList());
} catch (Exception e) {
ArrayList<CompletedRateVO> nullData = new ArrayList<>();
for (Long userId : userIdList) {
nullData.add(new CompletedRateVO(userId, 0));
}
return nullData;
}
}
@Override
public CompletedRateVO getEmployeeHostsCompleteWithSelf(Long loginUserId) {
return employeeBigBrotherMapper.selectEmployeeBrotherWithOperationStatus(loginUserId);
}
}

View File

@@ -66,4 +66,6 @@ public interface EmployeeHostsService {
void batchUpdateEmployeeHosts(List<EmployeeHostsSaveReqVO> updateReqVOList);
CompletedRateVO getEmployeeHostsCompleteWithSelf(@Valid Long userId);
List<CompletedRateVO> getEmployeeHostsCompleteBarChart(@Valid List<Long> userId,Integer days);
}

View File

@@ -25,6 +25,8 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@@ -110,15 +112,10 @@ public class EmployeeHostsServiceImpl implements EmployeeHostsService {
@Override
public PageResult<EmployeeHostsDO> getEmployeeHostsPage(EmployeeHostsPageReqVO pageReqVO) {
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
pageReqVO.setTenantId(TenantContextHolder.getTenantId());
if (loginUser != null) {
pageReqVO.setUserId(loginUser.getId());
IPage<EmployeeHostsDO> iPage = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
IPage<EmployeeHostsDO> newHostsDOIPage = employeeHostsMapper.selectPageWithXMLWithSelf(iPage, pageReqVO);
return new PageResult<>(newHostsDOIPage.getRecords(), newHostsDOIPage.getTotal());
}
return null;
IPage<EmployeeHostsDO> iPage = new Page<>(pageReqVO.getPageNo(),pageReqVO.getPageSize());
IPage<EmployeeHostsDO> newHostsDOIPage = employeeHostsMapper.selectPageWithXML(iPage, pageReqVO);
return new PageResult<>(newHostsDOIPage.getRecords(),newHostsDOIPage.getTotal());
}
@Override
@@ -183,5 +180,36 @@ public class EmployeeHostsServiceImpl implements EmployeeHostsService {
return employeeHostsMapper.selectEmployeeHostsWithOperationStatus(userId);
}
@Override
public List<CompletedRateVO> getEmployeeHostsCompleteBarChart(List<Long> userIdList, Integer days) {
List<CompletedRateVO> dbList = employeeHostsMapper.selectEmployeeHostsCompleteBarChart(userIdList,days);
try {
// 2. 转 Mapkey 是 userId
Map<Long, CompletedRateVO> dbMap = dbList.stream()
.collect(Collectors.toMap(
CompletedRateVO::getUserId,
Function.identity(),
(oldVal, newVal) -> newVal)); // 重复时保留新的
// 3. 组装结果
return userIdList.stream()
.map(userId -> dbMap.getOrDefault(userId, new CompletedRateVO(userId, 0))) // 缺数据补0
.collect(Collectors.toList());
} catch (Exception e) {
ArrayList<CompletedRateVO> nullData = new ArrayList<>();
for (Long userId : userIdList) {
nullData.add(new CompletedRateVO(userId, 0));
}
return nullData;
}
}
}

View File

@@ -31,6 +31,7 @@
<result column="updater" jdbcType="VARCHAR" property="updater" />
<result column="deleted" jdbcType="BOOLEAN" property="deleted" />
<result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
<result column="fans_level" jdbcType="INTEGER" property="fansLevel" />
</resultMap>
@@ -38,7 +39,7 @@
<select id="selectPageWithXML" resultType="cn.iocoder.yudao.module.tkdata.dal.dataobject.bigbrother.BigBrotherDO">
select sbr.id, sbr.display_id, sbr.user_id_str,sbr.nickname,sbr.level,sbr.hostcoins,
sbr.follower_count, sbr.following_count, sbr.region, sbr.historic_high_coins, sbr.total_gift_coins,
sbr.host_display_id,sbr.create_time, sbr.is_assigned from
sbr.host_display_id,sbr.create_time, sbr.is_assigned,sbr.fans_level from
server_big_brother sbr left join server_country_info ci ON sbr.region = ci.country_name
where sbr.tenant_id=#{dto.tenantId}
and sbr.deleted = 0
@@ -87,6 +88,17 @@
<if test="dto.levelMin != null and dto.levelMax != null " >
and sbr.level between #{dto.levelMin,jdbcType=INTEGER} and #{dto.levelMax,jdbcType=INTEGER}
</if>
<!-- 粉丝团等级筛选 -->
<if test="dto.fansLevelMin != null and dto.fansLevelMax == null ">
and sbr.fans_level >=#{dto.fansLevelMin,jdbcType=INTEGER}
</if>
<if test="dto.fansLevelMax != null and dto.fansLevelMin == null ">
and sbr.fans_level &lt;=#{dto.fansLevelMax,jdbcType=INTEGER}
</if>
<if test="dto.fansLevelMin != null and dto.fansLevelMax != null " >
and sbr.fans_level between #{dto.fansLevelMin,jdbcType=INTEGER} and #{dto.fansLevelMax,jdbcType=INTEGER}
</if>
<if test="dto.isAssigned != null">
and sbr.is_assigned =#{dto.isAssigned}
</if>

View File

@@ -31,6 +31,7 @@
<result column="updater" jdbcType="VARCHAR" property="updater" />
<result column="deleted" jdbcType="BOOLEAN" property="deleted" />
<result column="operation_status" jdbcType="BOOLEAN" property="operationStatus"/>
<result column="fans_level" jdbcType="INTEGER" property="fansLevel"/>
</resultMap>
@@ -38,7 +39,7 @@
resultType="cn.iocoder.yudao.module.tkdata.dal.dataobject.employeebigbrother.EmployeeBigBrotherDO">
select sbr.id, sbr.display_id, sbr.user_id_str,sbr.nickname,sbr.level,sbr.hostcoins,
sbr.follower_count, sbr.following_count, sbr.region, sbr.historic_high_coins, sbr.total_gift_coins,
sbr.host_display_id,sbr.create_time, sbr.user_id, sbr.operation_status from
sbr.host_display_id,sbr.create_time, sbr.user_id, sbr.operation_status,sbr.fans_level from
server_employee_big_brother sbr left join server_country_info ci ON sbr.region = ci.country_name
where sbr.tenant_id=#{dto.tenantId}
and sbr.deleted = 0
@@ -88,6 +89,16 @@
<if test="dto.levelMin != null and dto.levelMax != null " >
and sbr.level between #{dto.levelMin,jdbcType=INTEGER} and #{dto.levelMax,jdbcType=INTEGER}
</if>
<!-- 粉丝团等级筛选 -->
<if test="dto.fansLevelMin != null and dto.fansLevelMax == null ">
and sbr.fans_level >=#{dto.fansLevelMin,jdbcType=INTEGER}
</if>
<if test="dto.fansLevelMax != null and dto.fansLevelMin == null ">
and sbr.fans_level &lt;=#{dto.fansLevelMax,jdbcType=INTEGER}
</if>
<if test="dto.fansLevelMin != null and dto.fansLevelMax != null " >
and sbr.fans_level between #{dto.fansLevelMin,jdbcType=INTEGER} and #{dto.fansLevelMax,jdbcType=INTEGER}
</if>
<if test="dto.operationStatus != null">
and sbr.operation_status =#{dto.operationStatus}
</if>
@@ -124,10 +135,19 @@
resultType="cn.iocoder.yudao.module.tkdata.dal.dataobject.employeebigbrother.EmployeeBigBrotherDO">
select sbr.id, sbr.display_id, sbr.user_id_str,sbr.nickname,sbr.level,sbr.hostcoins,
sbr.follower_count, sbr.following_count, sbr.region, sbr.historic_high_coins, sbr.total_gift_coins,
sbr.host_display_id,sbr.create_time, sbr.user_id, sbr.operation_status from
sbr.host_display_id,sbr.create_time, sbr.user_id, sbr.operation_status,sbr.fans_level from
server_employee_big_brother sbr left join server_country_info ci ON sbr.region = ci.country_name
where sbr.tenant_id=#{dto.tenantId}
and sbr.deleted = 0
<if test="dto.isDelete == 1">
and deleted = 1
</if>
<if test="dto.isDelete == 0">
and deleted = 0
</if>
<if test="dto.isDelete == 3">
and (deleted = 0
or deleted = 1)
</if>
<if test="dto.userId != null" >
and sbr.user_id = #{dto.userId,jdbcType=VARCHAR}
</if>
@@ -176,6 +196,16 @@
<if test="dto.levelMin != null and dto.levelMax != null " >
and sbr.level between #{dto.levelMin,jdbcType=INTEGER} and #{dto.levelMax,jdbcType=INTEGER}
</if>
<!-- 粉丝团等级筛选 -->
<if test="dto.fansLevelMin != null and dto.fansLevelMax == null ">
and sbr.fans_level >=#{dto.fansLevelMin,jdbcType=INTEGER}
</if>
<if test="dto.fansLevelMax != null and dto.fansLevelMin == null ">
and sbr.fans_level &lt;=#{dto.fansLevelMax,jdbcType=INTEGER}
</if>
<if test="dto.fansLevelMin != null and dto.fansLevelMax != null " >
and sbr.fans_level between #{dto.fansLevelMin,jdbcType=INTEGER} and #{dto.fansLevelMax,jdbcType=INTEGER}
</if>
<if test="dto.operationStatus != null">
and sbr.operation_status =#{dto.operationStatus}
</if>
@@ -207,4 +237,39 @@
</when>
</choose>
</select>
<select id="selectEmployeeBrotherCompleteBarChart"
resultType="cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo.CompletedRateVO">
SELECT
user_id AS userId,
COUNT(DISTINCT
CASE WHEN operation_status = 1 THEN display_id END) AS finishedNum
FROM server_employee_big_brother
WHERE deleted = 0
AND operation_status = 1
<!-- 日期范围:今天或过去 7 天(含今天) -->
AND update_time >= DATE_SUB(CURDATE(), INTERVAL #{days,jdbcType=INTEGER} - 1 DAY)
<if test="list != null and list.size() > 0">
AND user_id IN
<foreach collection="list" item="user_id" open="(" separator="," close=")">
#{user_id}
</foreach>
</if>
GROUP BY user_id
</select>
<select id="selectEmployeeBrotherWithOperationStatus"
resultType="cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo.CompletedRateVO">
SELECT
user_id AS userId,
SUM(CASE WHEN operation_status = 1 THEN 1 ELSE 0 END) AS finishedNum,
SUM(CASE WHEN operation_status = 0 THEN 1 ELSE 0 END) AS unfinishedNum,
COUNT(*) AS totalNum
FROM server_employee_big_brother
WHERE deleted = 0
<if test="userId != null">
AND user_id = #{userId}
</if>
GROUP BY user_id
</select>
</mapper>

View File

@@ -12,6 +12,54 @@
<!-- 使用 IGNORE 关键字忽略重复插入 -->
<sql id="Base_Column_List">
id,
hosts_id,
user_id,
hosts_level,
hosts_coins,
invitation_type,
online_fans,
fans,
fllowernum,
yesterday_coins,
country,
hosts_kind,
operation_status,
remake,
`uid`,
tenant_id,
flag,
create_time,
update_time,
creator,
updater,
deleted
</sql>
<resultMap id="BaseResultMap" type="cn.iocoder.yudao.module.tkdata.dal.dataobject.employeehosts.EmployeeHostsDO">
<result column="id" property="id"/>
<result column="hosts_id" property="hostsId"/>
<result column="user_id" property="userId"/>
<result column="hosts_level" property="hostsLevel"/>
<result column="hosts_coins" property="hostsCoins"/>
<result column="invitation_type" property="invitationType"/>
<result column="online_fans" property="onlineFans"/>
<result column="fans" property="fans"/>
<result column="fllowernum" property="fllowernum"/>
<result column="yesterday_coins" property="yesterdayCoins"/>
<result column="country" property="country"/>
<result column="hosts_kind" property="hostsKind"/>
<result column="operation_status" property="operationStatus"/>
<result column="remake" property="remake"/>
<result column="uid" property="uid"/>
<result column="tenant_id" property="tenantId"/>
<result column="flag" property="flag"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="creator" property="creator"/>
<result column="updater" property="updater"/>
<result column="deleted" property="deleted"/>
</resultMap>
<insert id="insertIgnore" parameterType="cn.iocoder.yudao.module.tkdata.dal.dataobject.employeehosts.EmployeeHostsDO">
INSERT IGNORE INTO server_employee_hosts
<trim prefix="(" suffix=")" suffixOverrides=",">
@@ -63,7 +111,8 @@
<select id="selectPageWithXMLWithSelf" resultType="cn.iocoder.yudao.module.tkdata.dal.dataobject.employeehosts.EmployeeHostsDO">
select ns.id,hosts_id, hosts_level, hosts_coins, Invitation_type, fans, fllowernum,
yesterday_coins,ns.create_time, country, online_fans,hosts_kind,remake ,
operation_status,ns.user_id ,ns.update_time,ns.flag from server_employee_hosts ns left join server_country_info ci ON ns.country = ci.country_name
operation_status,ns.user_id ,ns.update_time,ns.flag,ns.deleted,ns.country_eng
from server_employee_hosts ns left join server_country_info ci ON ns.country = ci.country_name
WHERE tenant_id =#{req.tenantId,jdbcType=BIGINT}
and ns.user_id =#{req.userId,jdbcType=BIGINT}
<!-- 主播国家筛选 -->
@@ -73,10 +122,17 @@
<if test="req.country != '' and req.country !=null ">
and ns.country = #{req.country}
</if>
<if test="req.hostsKind != null">
and ns.hosts_kind = #{req.hostsKind,jdbcType=INTEGER}
</if>
<!-- 按照入库时间筛选主播 -->
<if test="req.createTime != null">
and DATE(ns.create_time) =#{req.createTime}
</if>
<!-- 按照更新时间筛选主播 -->
<if test="req.updateTime != null">
and DATE(ns.update_time) =#{req.updateTime}
</if>
<if test="req.operationStatus != null">
and operation_status =#{req.operationStatus,jdbcType=INTEGER}
</if>
@@ -95,6 +151,7 @@
#{level, jdbcType=VARCHAR}
</foreach>
</if>
and deleted = 0
<!-- 今日主播金币筛选 -->
<if test="req.hostsCoinsMin != null and req.hostsCoinsMax == null and req.hostsCoinsMax != '' ">
and ns.hosts_coins >=#{req.hostsCoinsMin,jdbcType=INTEGER}
@@ -161,30 +218,30 @@
<!-- sortNmae 有值的情况下排序 -->
<when test="req.sortName != null and req.sort != null ">
<if test="req.sortName == 'createTime' and req.sort != null">
ns.create_time ${req.sort}
ns.create_time ${req.sort},ns.id ${req.sort}
</if>
<!-- 昨日主播金币条件排序 -->
<if test="req.sortName == 'yesterdayCoins' and req.sort != null">
ns.yesterday_coins ${req.sort}
ns.yesterday_coins ${req.sort},ns.id ${req.sort}
</if>
<!-- 主播金币条件排序 -->
<if test="req.sortName == 'hostsCoins' and req.sort != null">
ns.hosts_coins ${req.sort}
ns.hosts_coins ${req.sort},ns.id ${req.sort}
</if>
<!-- 主播粉丝条件排序 -->
<if test="req.sortName == 'fans' and req.sort != null">
ns.fans ${req.sort}
ns.fans ${req.sort},ns.id ${req.sort}
</if>
<!-- 主播关注数量排序 -->
<if test="req.sortName == 'fllowernum' and req.sort != null">
ns.fllowernum ${req.sort}
ns.fllowernum ${req.sort},ns.id ${req.sort}
</if>
<!-- 主播直播间在线数量排序 -->
<if test="req.sortName == 'onlineFans' and req.sort != null">
ns.online_fans ${req.sort}
ns.online_fans ${req.sort},ns.id ${req.sort}
</if>
<if test="req.sortName == 'updateTime' and req.sort != null">
ns.update_time ${req.sort}
ns.update_time ${req.sort},ns.id ${req.sort}
</if>
</when>
<otherwise>
@@ -195,10 +252,19 @@
<select id="selectPageWithXML" resultType="cn.iocoder.yudao.module.tkdata.dal.dataobject.employeehosts.EmployeeHostsDO">
select ns.id,hosts_id, hosts_level, hosts_coins, Invitation_type, fans, fllowernum,
yesterday_coins,ns.create_time, country, online_fans,hosts_kind,remake ,operation_status,user_id,uid,ns.update_time,ns.flag
yesterday_coins,ns.create_time, country, online_fans,hosts_kind,remake ,operation_status,user_id,uid,ns.update_time,ns.flag,ns.country_eng
from server_employee_hosts ns left join server_country_info ci ON ns.country = ci.country_name
WHERE tenant_id = #{req.tenantId,jdbcType=BIGINT}
and deleted = 0
<if test="req.isDelete == 1">
and deleted = 1
</if>
<if test="req.isDelete == 0">
and deleted = 0
</if>
<if test="req.isDelete == 3">
and (deleted = 0
or deleted = 1)
</if>
<!-- 筛选员工名下主播 -->
<if test="req.userId != null ">
and user_id = #{req.userId,jdbcType=BIGINT}
@@ -207,6 +273,10 @@
<if test="req.region!= '' and req.region != null">
and ci.country_group_name =#{req.region,jdbcType=VARCHAR}
</if>
<!-- 主播类型筛选 -->
<if test="req.hostsKind != null">
and ns.hosts_kind = #{req.hostsKind,jdbcType=INTEGER}
</if>
<if test="req.country != '' and req.country !=null ">
and ns.country = #{req.country}
</if>
@@ -214,8 +284,13 @@
<if test="req.createTime != null">
and DATE(ns.create_time) =#{req.createTime}
</if>
<!-- 按照更新时间筛选主播 -->
<if test="req.updateTime != null">
and DATE(ns.update_time) =#{req.updateTime}
</if>
<if test="req.operationStatus != null">
and operation_status =#{req.operationStatus,jdbcType=INTEGER}
and operation_status = #{req.operationStatus,jdbcType=INTEGER}
</if>
<!-- 主播 Id 模糊搜索 -->
<if test="req.hostsId != '' and req.hostsId != null ">
@@ -298,30 +373,30 @@
<!-- sortNmae 有值的情况下排序 -->
<when test="req.sortName != null and req.sort != null ">
<if test="req.sortName == 'createTime' and req.sort != null">
ns.create_time ${req.sort}
ns.create_time ${req.sort},ns.id ${req.sort}
</if>
<!-- 昨日主播金币条件排序 -->
<if test="req.sortName == 'yesterdayCoins' and req.sort != null">
ns.yesterday_coins ${req.sort}
ns.yesterday_coins ${req.sort},ns.id ${req.sort}
</if>
<!-- 主播金币条件排序 -->
<if test="req.sortName == 'hostsCoins' and req.sort != null">
ns.hosts_coins ${req.sort}
ns.hosts_coins ${req.sort},ns.id ${req.sort}
</if>
<!-- 主播粉丝条件排序 -->
<if test="req.sortName == 'fans' and req.sort != null">
ns.fans ${req.sort}
ns.fans ${req.sort},ns.id ${req.sort}
</if>
<!-- 主播关注数量排序 -->
<if test="req.sortName == 'fllowernum' and req.sort != null">
ns.fllowernum ${req.sort}
ns.fllowernum ${req.sort},ns.id ${req.sort}
</if>
<!-- 主播直播间在线数量排序 -->
<if test="req.sortName == 'onlineFans' and req.sort != null">
ns.online_fans ${req.sort}
ns.online_fans ${req.sort},ns.id ${req.sort}
</if>
<if test="req.sortName == 'updateTime' and req.sort != null">
ns.update_time ${req.sort}
ns.update_time ${req.sort},ns.id ${req.sort}
</if>
</when>
<otherwise>
@@ -355,4 +430,24 @@
</if>
GROUP BY user_id
</select>
<select id="selectEmployeeHostsCompleteBarChart"
resultType="cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo.CompletedRateVO">
SELECT
user_id AS userId,
COUNT(DISTINCT
CASE WHEN operation_status = 1 THEN hosts_id END) AS finishedNum
FROM server_employee_hosts
WHERE deleted = 0
AND operation_status = 1
<!-- 日期范围:今天或过去 7 天(含今天) -->
AND update_time >= DATE_SUB(CURDATE(), INTERVAL #{days,jdbcType=INTEGER} - 1 DAY)
<if test="list != null and list.size() > 0">
AND user_id IN
<foreach collection="list" item="user_id" open="(" separator="," close=")">
#{user_id}
</foreach>
</if>
GROUP BY user_id
</select>
</mapper>

View File

@@ -12,7 +12,7 @@
<select id="selectPageWithXML" resultType="cn.iocoder.yudao.module.tkdata.dal.dataobject.newhosts.NewHostsDO">
select ns.id,hosts_id, hosts_level, hosts_coins, Invitation_type, fans, fllowernum,
yesterday_coins,ns.create_time, country, online_fans,hosts_kind ,is_assigned,uid ,ns.update_time,ns.operation_status,ns.ai_operation
yesterday_coins,ns.create_time, country, online_fans,hosts_kind ,is_assigned,uid ,ns.update_time,ns.operation_status,ns.ai_operation,ns.country_eng
from server_new_hosts ns left join
server_country_info ci ON ns.country = ci.country_name
WHERE tenant_id =#{req.tenantId,jdbcType=BIGINT}
@@ -35,6 +35,10 @@
<if test="req.hostsId != '' and req.hostsId != null ">
and ns.hosts_id like concat(#{req.hostsId,jdbcType=VARCHAR},'%')
</if>
<!-- 直播类型模糊搜索 -->
<if test="req.hostsKind != null and req.hostsKind != ''">
and ns.hosts_kind like concat("%",#{req.hostsKind,jdbcType=VARCHAR},"%")
</if>
<!-- 是否分配筛选 -->
<if test="req.isAssigned != null ">
and ns.is_assigned =#{req.isAssigned,jdbcType=INTEGER}
@@ -103,7 +107,6 @@
<if test="req.invitationType != null">
and ns.Invitation_type =#{req.invitationType,jdbcType=INTEGER}
</if>
<!-- 排序类型 -->
<!-- 排序类型 -->
group by
ns.hosts_id

View File

@@ -29,7 +29,7 @@ public class PageParam implements Serializable {
@Schema(description = "每页条数,最大值为 1000", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
@NotNull(message = "每页条数不能为空")
@Min(value = 1, message = "每页条数最小值为 1")
// @Min(value = 1, message = "每页条数最小值为 1")
@Max(value = 1000, message = "每页条数最大值为 1000")
private Integer pageSize = PAGE_SIZE;

View File

@@ -45,6 +45,7 @@ public class JobLogServiceImpl implements JobLogService {
.result(result).build();
jobLogMapper.updateById(updateObj);
} catch (Exception ex) {
log.error("更新 Job 日志失败", ex);
log.error("[updateJobLogResultAsync][logId({}) endTime({}) duration({}) success({}) result({})]",
logId, endTime, duration, success, result);
}

View File

@@ -8,9 +8,8 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantRespVO;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.*;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO;
import cn.iocoder.yudao.module.system.service.tenant.TenantService;
import io.swagger.v3.oas.annotations.Operation;
@@ -109,7 +108,11 @@ public class TenantController {
@PreAuthorize("@ss.hasPermission('system:tenant:query')")
public CommonResult<PageResult<TenantRespVO>> getTenantPage(@Valid TenantPageReqVO pageVO) {
PageResult<TenantDO> pageResult = tenantService.getTenantPage(pageVO);
return success(BeanUtils.toBean(pageResult, TenantRespVO.class));
PageResult<TenantRespVO> bean = BeanUtils.toBean(pageResult, TenantRespVO.class);
for (TenantRespVO tenantRespVO : bean.getList()) {
tenantRespVO.setHasChildren(tenantRespVO.getTenantType().equals("代理"));
}
return success(bean);
}
@GetMapping("/export-excel")
@@ -124,4 +127,53 @@ public class TenantController {
BeanUtils.toBean(list, TenantRespVO.class));
}
// 以下是控制代理租户的租户查询
// ----------------------------------------------------------------------------------
@GetMapping("/page_self")
@Operation(summary = "代理获得自己下属租户分页")
@PreAuthorize("@ss.hasPermission('system:tenant:query-self')")
public CommonResult<PageResult<TenantRespVO>> getSelfTenantPage(@Valid TenantPageReqVO pageVO) {
PageResult<TenantDO> pageResult = tenantService.getSelfTenantPage(pageVO);
PageResult<TenantRespVO> bean = BeanUtils.toBean(pageResult, TenantRespVO.class);
for (TenantRespVO tenantRespVO : bean.getList()) {
tenantRespVO.setHasChildren(tenantRespVO.getTenantType().equals("代理"));
}
return success(bean);
}
@GetMapping("/getSelfTenantLevel")
@Operation(summary = "获取自身代理级别")
@PreAuthorize("@ss.hasPermission('system:tenant:query-self-Level')")
public CommonResult<TenantLevelRespVO> getSelfTenantPage() {
Long tenantId = TenantContextHolder.getTenantId();
TenantDO tenant = tenantService.getTenant(tenantId);
return success(BeanUtils.toBean(tenant, TenantLevelRespVO.class));
}
@GetMapping("/get-children")
@Operation(summary = "获得代理租户下级")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:tenant:query-children')")
public CommonResult<List<TenantRespVO>> getChildrenTenant(@RequestParam("id") Long id) {
List<TenantDO> tenantList = tenantService.getChildrenTenant(id);
List<TenantRespVO> bean = BeanUtils.toBean(tenantList, TenantRespVO.class);
for (TenantRespVO tenantRespVO : bean) {
tenantRespVO.setHasChildren(tenantRespVO.getTenantType().equals("代理"));
}
return success(bean);
}
@PutMapping("/renewal")
@Operation(summary = "租户续费")
@PreAuthorize("@ss.hasPermission('system:tenant:renewal')")
public CommonResult<Boolean> renewalTenant(@Valid @RequestBody TenantRenewalReqVO renewalReqVO) {
tenantService.renewalTenant(renewalReqVO);
return success(true);
}
}

View File

@@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.*;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantagencypackage.TenantAgencyPackageDO;
import cn.iocoder.yudao.module.system.service.tenant.TenantPackageService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
@@ -73,7 +74,7 @@ public class TenantPackageController {
@GetMapping({"/get-simple-list", "simple-list"})
@Operation(summary = "获取租户套餐精简信息列表", description = "只包含被开启的租户套餐,主要用于前端的下拉选项")
public CommonResult<List<TenantPackageSimpleRespVO>> getTenantPackageList() {
List<TenantPackageDO> list = tenantPackageService.getTenantPackageListByStatus(CommonStatusEnum.ENABLE.getStatus());
List<TenantAgencyPackageDO> list = tenantPackageService.getTenantPackageListByStatus(CommonStatusEnum.ENABLE.getStatus());
return success(BeanUtils.toBean(list, TenantPackageSimpleRespVO.class));
}

View File

@@ -17,4 +17,12 @@ public class TenantPackageSimpleRespVO {
@NotNull(message = "套餐名不能为空")
private String name;
@Schema(description = "套餐类型", example = "1")
private Integer packageType;
@Schema(description = "套餐价格", example = "30")
private Integer price;
@Schema(description = "套餐有效期天数", example = "30")
private Integer days;
}

View File

@@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 租户 Response VO")
@Data
@ExcelIgnoreUnannotated
public class TenantLevelRespVO {
@Schema(description = "租户等级",example = "1")
private String tenantLevel;
}

View File

@@ -33,4 +33,24 @@ public class TenantPageReqVO extends PageParam {
@Schema(description = "创建时间")
private LocalDateTime[] createTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@Schema(description = "AI到期时间")
private LocalDateTime[] aiExpireTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@Schema(description = "爬虫到期时间")
private LocalDateTime[] expireTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@Schema(description = "爬大哥到期时间")
private LocalDateTime[] brotherExpireTime;
@Schema
private String remark;
@Schema(description = "父租户Id")
private Long parentId;
@Schema(description = "租户类型", example = "代理/客户")
private String tenantType;
}

View File

@@ -0,0 +1,31 @@
package cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
/*
* @author: ziin
* @date: 2025/11/25 20:54
*/
@Schema(description = "管理后台 - 租户续费 Request VO")
@Data
public class TenantRenewalReqVO {
@Schema(description = "租户编号", example = "1024")
private Long id;
@Schema(description = "租户套餐编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotNull(message = "租户套餐编号不能为空")
private Long packageId;
@Schema(description = "备注", example = "备注")
private String remark;
}

View File

@@ -8,6 +8,7 @@ import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 租户 Response VO")
@@ -45,6 +46,14 @@ public class TenantRespVO {
@Schema(description = "过期时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime expireTime;
@Schema(description = "ai过期时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime aiExpireTime;
@Schema(description = "大哥过期时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime brotherExpireTime;
@Schema(description = "账号数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer accountCount;
@@ -52,4 +61,18 @@ public class TenantRespVO {
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "备注", example = "备注")
private String remark;
@Schema(description = "上级租户 Id", example = "1024")
private Long parentId;
@Schema(description = "租户类型", example = "代理/客户")
private String tenantType;
@Schema(description = "租户等级",example = "1")
private String tenantLevel;
@Schema(description = "是否存在下级",example = "true")
private Boolean hasChildren;
}

View File

@@ -45,6 +45,13 @@ public class TenantSaveReqVO {
@NotNull(message = "过期时间不能为空")
private LocalDateTime expireTime;
@Schema(description = "ai过期时间")
private LocalDateTime aiExpireTime;
@Schema(description = "大哥过期时间")
private LocalDateTime brotherExpireTime;
@Schema(description = "账号数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotNull(message = "账号数量不能为空")
private Integer accountCount;
@@ -76,4 +83,11 @@ public class TenantSaveReqVO {
@Schema(description = "能否登录 AI 聊天工具", example = "0不允许1允许")
private Byte aiChat;
@Schema(description = "备注", example = "备注")
private String remark;
@Schema(description = "租户类型", example = "代理/客户")
@NotNull(message = "租户类型不能为空")
private String tenantType;
}

View File

@@ -0,0 +1,114 @@
package cn.iocoder.yudao.module.system.controller.admin.tenantagencypackage;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageSimpleRespVO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantagencypackage.TenantAgencyPackageDO;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.system.controller.admin.tenantagencypackage.vo.*;
import cn.iocoder.yudao.module.system.service.tenantagencypackage.TenantAgencyPackageService;
@Tag(name = "管理后台 - 代理租户套餐")
@RestController
@RequestMapping("/system/tenant-agency-package")
@Validated
public class TenantAgencyPackageController {
@Resource
private TenantAgencyPackageService tenantAgencyPackageService;
@PostMapping("/create")
@Operation(summary = "创建代理租户套餐")
@PreAuthorize("@ss.hasPermission('system:tenant-agency-package:create')")
public CommonResult<Long> createTenantAgencyPackage(@Valid @RequestBody TenantAgencyPackageSaveReqVO createReqVO) {
return success(tenantAgencyPackageService.createTenantAgencyPackage(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新代理租户套餐")
@PreAuthorize("@ss.hasPermission('system:tenant-agency-package:update')")
public CommonResult<Boolean> updateTenantAgencyPackage(@Valid @RequestBody TenantAgencyPackageSaveReqVO updateReqVO) {
tenantAgencyPackageService.updateTenantAgencyPackage(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除代理租户套餐")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('system:tenant-agency-package:delete')")
public CommonResult<Boolean> deleteTenantAgencyPackage(@RequestParam("id") Long id) {
tenantAgencyPackageService.deleteTenantAgencyPackage(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除代理租户套餐")
@PreAuthorize("@ss.hasPermission('system:tenant-agency-package:delete')")
public CommonResult<Boolean> deleteTenantAgencyPackageList(@RequestParam("ids") List<Long> ids) {
tenantAgencyPackageService.deleteTenantAgencyPackageListByIds(ids);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得代理租户套餐")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:tenant-agency-package:query')")
public CommonResult<TenantAgencyPackageRespVO> getTenantAgencyPackage(@RequestParam("id") Long id) {
TenantAgencyPackageDO tenantAgencyPackage = tenantAgencyPackageService.getTenantAgencyPackage(id);
return success(BeanUtils.toBean(tenantAgencyPackage, TenantAgencyPackageRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得代理租户套餐分页")
@PreAuthorize("@ss.hasPermission('system:tenant-agency-package:query')")
public CommonResult<PageResult<TenantAgencyPackageRespVO>> getTenantAgencyPackagePage(@Valid TenantAgencyPackagePageReqVO pageReqVO) {
PageResult<TenantAgencyPackageDO> pageResult = tenantAgencyPackageService.getTenantAgencyPackagePage(pageReqVO);
return success(BeanUtils.toBean(pageResult, TenantAgencyPackageRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出代理租户套餐 Excel")
@PreAuthorize("@ss.hasPermission('system:tenant-agency-package:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportTenantAgencyPackageExcel(@Valid TenantAgencyPackagePageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<TenantAgencyPackageDO> list = tenantAgencyPackageService.getTenantAgencyPackagePage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "代理租户套餐.xls", "数据", TenantAgencyPackageRespVO.class,
BeanUtils.toBean(list, TenantAgencyPackageRespVO.class));
}
@GetMapping({"/get-simple-list", "代理套餐精简列表"})
@Operation(summary = "获取代理租户套餐精简信息列表", description = "只包含被开启的租户套餐,主要用于前端的下拉选项")
@PreAuthorize("@ss.hasPermission('system:tenant-agency-package:simple-list')")
public CommonResult<List<AgencyTenantPackageSimpleRespVO>> getTenantPackageList() {
List<TenantAgencyPackageDO> list = tenantAgencyPackageService.getTenantPackageListByStatus(CommonStatusEnum.ENABLE.getStatus());
return success(BeanUtils.toBean(list, AgencyTenantPackageSimpleRespVO.class));
}
}

View File

@@ -0,0 +1,23 @@
package cn.iocoder.yudao.module.system.controller.admin.tenantagencypackage.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 租户套餐精简 Response VO")
@Data
public class AgencyTenantPackageSimpleRespVO {
@Schema(description = "套餐编号", example = "1024")
private Long id;
@Schema(description = "套餐名", example = "VIP")
private String name;
@Schema(description = "Ai自动回复权限 0关闭 1 开启", example = "1")
private Integer packageType;
@Schema(description = "套餐价格", example = "1000")
private Integer price;
}

View File

@@ -0,0 +1,57 @@
package cn.iocoder.yudao.module.system.controller.admin.tenantagencypackage.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 代理租户套餐分页 Request VO")
@Data
public class TenantAgencyPackagePageReqVO extends PageParam {
@Schema(description = "套餐名", example = "芋艿")
private String name;
@Schema(description = "租户状态0正常 1停用", example = "2")
private Integer status;
@Schema(description = "备注", example = "你猜")
private String remark;
@Schema(description = "关联的菜单编号")
private Set<Long> menuIds;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "套餐天数")
private Integer days;
@Schema(description = "套餐价格", example = "22890")
private Integer price;
@Schema(description = "爬主播客户端 0 关闭 1 开启")
private Integer hostslClient;
@Schema(description = "爬大哥客户端 0 关闭 1 开启")
private Integer brotherClient;
@Schema(description = "AI 客户端 0 关闭 1 开启")
private Integer aiClient;
@Schema(description = "Ai自动回复权限 0关闭 1 开启")
private Integer aiReplay;
@Schema(description = "套餐类型", example = "2")
private Integer packageType;
@Schema(description = "WebAi权限 0关闭 1开启")
private Integer webAi;
}

View File

@@ -0,0 +1,70 @@
package cn.iocoder.yudao.module.system.controller.admin.tenantagencypackage.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 代理租户套餐 Response VO")
@Data
@ExcelIgnoreUnannotated
public class TenantAgencyPackageRespVO {
@Schema(description = "套餐编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20125")
@ExcelProperty("套餐编号")
private Long id;
@Schema(description = "套餐名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@ExcelProperty("套餐名")
private String name;
@Schema(description = "租户状态0正常 1停用", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty("租户状态0正常 1停用")
private Integer status;
@Schema(description = "备注", example = "你猜")
@ExcelProperty("备注")
private String remark;
@Schema(description = "关联的菜单编号", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("关联的菜单编号")
private Set<Long> menuIds;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "套餐天数", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("套餐天数")
private Integer days;
@Schema(description = "套餐价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "22890")
@ExcelProperty("套餐价格")
private Integer price;
@Schema(description = "爬主播客户端 0 关闭 1 开启")
@ExcelProperty("爬主播客户端 0 关闭 1 开启")
private Integer hostslClient;
@Schema(description = "爬大哥客户端 0 关闭 1 开启")
@ExcelProperty("爬大哥客户端 0 关闭 1 开启")
private Integer brotherClient;
@Schema(description = "AI 客户端 0 关闭 1 开启")
@ExcelProperty("AI 客户端 0 关闭 1 开启")
private Integer aiClient;
@Schema(description = "套餐类型", example = "2")
@ExcelProperty("套餐类型")
private Integer packageType;
@Schema(description = "Ai自动回复权限 0关闭 1 开启")
@ExcelProperty("Ai 自动回复权限 0关闭 1开启")
private Integer aiReplay;
@Schema(description = "WebAi权限 0关闭 1开启")
@ExcelProperty("WebAi权限 0关闭 1开启")
private Integer webAi;
}

View File

@@ -0,0 +1,55 @@
package cn.iocoder.yudao.module.system.controller.admin.tenantagencypackage.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 代理租户套餐新增/修改 Request VO")
@Data
public class TenantAgencyPackageSaveReqVO {
@Schema(description = "套餐编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20125")
private Long id;
@Schema(description = "套餐名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@NotEmpty(message = "套餐名不能为空")
private String name;
@Schema(description = "租户状态0正常 1停用", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "租户状态0正常 1停用不能为空")
private Integer status;
@Schema(description = "备注", example = "你猜")
private String remark;
@Schema(description = "关联的菜单编号", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "关联的菜单编号不能为空")
private Set<Long> menuIds;
@Schema(description = "套餐天数", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "套餐天数不能为空")
private Integer days;
@Schema(description = "套餐价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "22890")
@NotNull(message = "套餐价格不能为空")
private Integer price;
@Schema(description = "爬主播客户端 0 关闭 1 开启")
private Integer hostslClient;
@Schema(description = "爬大哥客户端 0 关闭 1 开启")
private Integer brotherClient;
@Schema(description = "AI 客户端 0 关闭 1 开启")
private Integer aiClient;
@Schema(description = "套餐类型", example = "2")
private Integer packageType;
@Schema(description = "Ai自动回复权限 0关闭 1 开启")
private Integer aiReplay;
@Schema(description = "WebAi权限 0关闭 1开启")
private Integer webAi;
}

View File

@@ -0,0 +1,138 @@
package cn.iocoder.yudao.module.system.controller.admin.tenantbalance;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.system.controller.admin.tenantbalance.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantbalance.TenantBalanceDO;
import cn.iocoder.yudao.module.system.service.tenantbalance.TenantBalanceService;
@Tag(name = "管理后台 - 租户余额")
@RestController
@RequestMapping("/system/tenant-balance")
@Validated
public class TenantBalanceController {
@Resource
private TenantBalanceService tenantBalanceService;
@PostMapping("/create")
@Operation(summary = "创建租户余额")
@PreAuthorize("@ss.hasPermission('system:tenant-balance:create')")
public CommonResult<Long> createTenantBalance(@Valid @RequestBody TenantBalanceSaveReqVO createReqVO) {
return success(tenantBalanceService.createTenantBalance(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新租户余额")
@PreAuthorize("@ss.hasPermission('system:tenant-balance:update')")
public CommonResult<Boolean> updateTenantBalance(@Valid @RequestBody TenantBalanceSaveReqVO updateReqVO) {
tenantBalanceService.updateTenantBalance(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除租户余额")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('system:tenant-balance:delete')")
public CommonResult<Boolean> deleteTenantBalance(@RequestParam("id") Long id) {
tenantBalanceService.deleteTenantBalance(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除租户余额")
@PreAuthorize("@ss.hasPermission('system:tenant-balance:delete')")
public CommonResult<Boolean> deleteTenantBalanceList(@RequestParam("ids") List<Long> ids) {
tenantBalanceService.deleteTenantBalanceListByIds(ids);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得租户余额")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:tenant-balance:query')")
public CommonResult<TenantBalanceRespVO> getTenantBalance(@RequestParam("id") Long id) {
TenantBalanceDO tenantBalance = tenantBalanceService.getTenantBalance(id);
return success(BeanUtils.toBean(tenantBalance, TenantBalanceRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得租户余额分页")
@PreAuthorize("@ss.hasPermission('system:tenant-balance:query')")
public CommonResult<PageResult<TenantBalanceRespVO>> getTenantBalancePage(@Valid TenantBalancePageReqVO pageReqVO) {
PageResult<TenantBalanceRespVO> tenantBalancePage = tenantBalanceService.getTenantBalancePage(pageReqVO);
return success(BeanUtils.toBean(tenantBalancePage, TenantBalanceRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出租户余额 Excel")
@PreAuthorize("@ss.hasPermission('system:tenant-balance:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportTenantBalanceExcel(@Valid TenantBalancePageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<TenantBalanceRespVO> list = tenantBalanceService.getTenantBalancePage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "租户余额.xls", "数据", TenantBalanceRespVO.class,
BeanUtils.toBean(list, TenantBalanceRespVO.class));
}
@PostMapping("/addAmount")
@Operation(summary = "添加租户余额")
@PreAuthorize("@ss.hasPermission('system:tenant-balance:add')")
public CommonResult<Boolean> addTenantBalance(@Valid @RequestBody TenantBalanceAddReqVO addReqVO) {
tenantBalanceService.addTenantBalance(addReqVO);
return success(true);
}
@PostMapping("/transfer")
@Operation(summary = "租户余额转账")
@PreAuthorize("@ss.hasPermission('system:tenant-balance:transfer')")
public CommonResult<Boolean> transferToTenant(@Valid @RequestBody TenantBalanceTransferReqVO transferReqVO) {
tenantBalanceService.transferToTenant(transferReqVO);
return success(true);
}
@GetMapping("/get-self-amount")
@Operation(summary = "获得自己的余额")
@PreAuthorize("@ss.hasPermission('system:tenant-balance:self-amount')")
public CommonResult<TenantBalanceRespVO> getTenantBalance() {
TenantBalanceDO tenantBalance = tenantBalanceService.getSelfBalance();
return success(BeanUtils.toBean(tenantBalance, TenantBalanceRespVO.class));
}
@GetMapping("/get-self-subordinate-amount-page")
@Operation(summary = "获得自己下级余额的分页")
@PreAuthorize("@ss.hasPermission('system:tenant-balance:self-subordinate')")
public CommonResult<PageResult<TenantBalanceRespVO>> getSelfSubordinate(@Valid TenantBalancePageReqVO pageReqVO) {
PageResult<TenantBalanceRespVO> tenantBalancePage = tenantBalanceService.getSelfSubordinateTenantBalancePage(pageReqVO);
return success(BeanUtils.toBean(tenantBalancePage, TenantBalanceRespVO.class));
}
}

View File

@@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.system.controller.admin.tenantbalance.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
/*
* @author: ziin
* @date: 2025/11/19 21:05
*/
@Schema(description = "管理后台 - 租户余额添加VO")
@Data
public class TenantBalanceAddReqVO {
@Schema(description = "租户 Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "19954")
@NotNull(message = "租户 Id 不能为空")
private Long id;
@Schema(description = "增加的余额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000000")
@NotNull(message = "增加的余额不能为空")
private Integer amount;
@Schema(description = "备注", example = "备注")
private String remark;
}

View File

@@ -0,0 +1,17 @@
package cn.iocoder.yudao.module.system.controller.admin.tenantbalance.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/*
* @author: ziin
* @date: 2025/11/24 15:32
*/
@Schema(description = "管理后台 - 租户余额消费")
@Data
public class TenantBalanceConsumptionReqVO {
@Schema( description = "套餐编号")
private Long id;
}

View File

@@ -0,0 +1,32 @@
package cn.iocoder.yudao.module.system.controller.admin.tenantbalance.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 租户余额分页 Request VO")
@Data
public class TenantBalancePageReqVO extends PageParam {
@Schema(description = "租户编号", example = "1024")
private Long id;
@Schema(description = "当前积分余额")
private Integer balance;
@Schema(description = "乐观锁版本号")
private Integer version;
@Schema(description = "更新时间")
private LocalDateTime updatedAt;
@Schema(description = "测试账号数")
@ExcelProperty("测试账号数")
private Integer testAccountNum;
}

View File

@@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.system.controller.admin.tenantbalance.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 租户余额 Response VO")
@Data
@ExcelIgnoreUnannotated
public class TenantBalanceRespVO {
@Schema(description = "租户 Id", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("租户 Id")
private Long id;
@Schema(description = "当前积分余额", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("当前积分余额")
private Integer balance;
@Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("更新时间")
private LocalDateTime updatedAt;
@Schema(description = "代理名称")
@ExcelProperty("代理名称")
private String tenantName;
@Schema(description = "测试账号数")
@ExcelProperty("测试账号数")
private Integer testAccountNum;
}

View File

@@ -0,0 +1,33 @@
package cn.iocoder.yudao.module.system.controller.admin.tenantbalance.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 租户余额新增/修改 Request VO")
@Data
public class TenantBalanceSaveReqVO {
@Schema(description = "租户 Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "19954")
private Long id;
@Schema(description = "当前积分余额", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "当前积分余额不能为空")
private Integer balance;
@Schema(description = "乐观锁版本号", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "乐观锁版本号不能为空")
private Integer version;
@Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "更新时间不能为空")
private LocalDateTime updatedAt;
@Schema(description = "测试账号数")
@ExcelProperty("测试账号数")
private Integer testAccountNum;
}

View File

@@ -0,0 +1,31 @@
package cn.iocoder.yudao.module.system.controller.admin.tenantbalance.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
/*
* @author: ziin
* @date: 2025/11/19 21:05
*/
@Schema(description = "管理后台 - 租户余额添加VO")
@Data
public class TenantBalanceTransferReqVO {
@Schema(description = "租户 Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "租户 Id 不能为空")
private Long targetTenantId;
@Schema(description = "转账的金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
@NotNull(message = "增加的余额不能为空")
private Integer transferAmount;
@Schema(description = "登录密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
@NotNull(message = "登录密码不能为空")
private String password;
@Schema(description = "备注", example = "转账")
private String remark;
}

View File

@@ -0,0 +1,114 @@
package cn.iocoder.yudao.module.system.controller.admin.tenantpoints;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantpoints.TenantPointsDO;
import cn.iocoder.yudao.module.system.service.tenantpoints.TenantPointsService;
@Tag(name = "管理后台 - 租户积分记录")
@RestController
@RequestMapping("/system/tenant-points")
@Validated
public class TenantPointsController {
@Resource
private TenantPointsService tenantPointsService;
@PostMapping("/create")
@Operation(summary = "创建租户积分记录")
@PreAuthorize("@ss.hasPermission('system:tenant-points:create')")
public CommonResult<Long> createTenantPoints(@Valid @RequestBody TenantPointsSaveReqVO createReqVO) {
return success(tenantPointsService.createTenantPoints(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新租户积分记录")
@PreAuthorize("@ss.hasPermission('system:tenant-points:update')")
public CommonResult<Boolean> updateTenantPoints(@Valid @RequestBody TenantPointsSaveReqVO updateReqVO) {
tenantPointsService.updateTenantPoints(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除租户积分记录")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('system:tenant-points:delete')")
public CommonResult<Boolean> deleteTenantPoints(@RequestParam("id") Long id) {
tenantPointsService.deleteTenantPoints(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除租户积分记录")
@PreAuthorize("@ss.hasPermission('system:tenant-points:delete')")
public CommonResult<Boolean> deleteTenantPointsList(@RequestParam("ids") List<Long> ids) {
tenantPointsService.deleteTenantPointsListByIds(ids);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得租户积分记录")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:tenant-points:query')")
public CommonResult<TenantPointsRespVO> getTenantPoints(@RequestParam("id") Long id) {
TenantPointsDO tenantPoints = tenantPointsService.getTenantPoints(id);
return success(BeanUtils.toBean(tenantPoints, TenantPointsRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得租户积分记录分页")
@PreAuthorize("@ss.hasPermission('system:tenant-points:query')")
public CommonResult<PageResult<TenantPointsPageRespVO>> getTenantPointsPage(@Valid TenantPointsPageReqVO pageReqVO) {
PageResult<TenantPointsPageRespVO> tenantPointsPage = tenantPointsService.getTenantPointsPage(pageReqVO);
return success(tenantPointsPage);
}
@GetMapping("/export-excel")
@Operation(summary = "导出租户积分记录 Excel")
@PreAuthorize("@ss.hasPermission('system:tenant-points:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportTenantPointsExcel(@Valid TenantPointsPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<TenantPointsPageRespVO> list = tenantPointsService.getTenantPointsPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "租户积分记录.xls", "数据", TenantPointsPageRespVO.class,
BeanUtils.toBean(list, TenantPointsPageRespVO.class));
}
@GetMapping("/transaction-history/page")
@Operation(summary = "获得租户积分记录分页")
@Parameter(name = "tenantId", description = "租户 Id")
@PreAuthorize("@ss.hasPermission('system:tenant-balance:query')")
public CommonResult<PageResult<TenantPointsDO>> getTenantTransactionHistoryPointsPage(PageParam pageReqVO,
@RequestParam("tenantId") Long tenantId) {
return success(tenantPointsService.getTenantTransactionHistoryPointsPage(pageReqVO, tenantId));
}
}

View File

@@ -0,0 +1,47 @@
package cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 租户积分记录分页 Request VO")
@Data
public class TenantPointsPageReqVO extends PageParam {
@Schema(description = "本次变动点数,正加负减")
private Integer points;
@Schema(description = "变动后余额快照(冗余)")
private Integer balance;
@Schema(description = "变动类型,如 RECHARGE, CONSUME, TRANSFER_OUT, TRANSFER_IN", example = "1")
private String type;
@Schema(description = "变动描述", example = "随便")
private String description;
@Schema(description = "订单 Id/业务单号", example = "84")
private String orderId;
@Schema(description = "业务流水号(转账、订单等唯一标识)")
private String bizNo;
@Schema(description = "操作人 Id", example = "8171")
private Long operatorId;
@Schema(description = "目标租户 Id转账使用", example = "18731")
private Long targetTenantId;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createdAt;
@Schema(description = "备注")
private String remark;
}

View File

@@ -0,0 +1,66 @@
package cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 租户积分记录 Response VO")
@Data
@ExcelIgnoreUnannotated
public class TenantPointsPageRespVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "16587")
@ExcelProperty("主键")
private Long id;
@Schema(description = "本次变动点数,正加负减", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("本次变动点数,正加负减")
private Integer points;
@Schema(description = "变动后余额快照(冗余)")
@ExcelProperty("变动后余额快照(冗余)")
private Integer balance;
@Schema(description = "变动类型,", example = "转账")
@ExcelProperty("变动类型,")
private String type;
@Schema(description = "变动描述", example = "转账金额 100")
@ExcelProperty("变动描述")
private String description;
@Schema(description = "订单 Id/业务单号", example = "84")
@ExcelProperty("订单 Id/业务单号")
private String orderId;
@Schema(description = "业务流水号(转账、订单等唯一标识)")
@ExcelProperty("业务流水号(转账、订单等唯一标识)")
private String bizNo;
@Schema(description = "操作人 Id", example = "8171")
@ExcelProperty("操作人 Id")
private Long operatorId;
@Schema(description = "目标租户 Id转账使用", example = "18731")
@ExcelProperty("目标租户 Id转账使用")
private Long targetTenantId;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createdAt;
@Schema(description = "租户名称", example = "租户 A")
@ExcelProperty("租户名称")
private String tenantName;
@Schema(description = "测试账号数", example = "1")
@ExcelProperty("测试账号数")
private Integer testAccountNum;
@Schema(description = "备注", example = "转账金额1000")
@ExcelProperty("备注")
private String remark;
}

View File

@@ -0,0 +1,58 @@
package cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 租户积分记录 Response VO")
@Data
@ExcelIgnoreUnannotated
public class TenantPointsRespVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "16587")
@ExcelProperty("主键")
private Long id;
@Schema(description = "本次变动点数,正加负减", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("本次变动点数,正加负减")
private Integer points;
@Schema(description = "变动后余额快照(冗余)")
@ExcelProperty("变动后余额快照(冗余)")
private Integer balance;
@Schema(description = "变动类型,如 RECHARGE, CONSUME, TRANSFER_OUT, TRANSFER_IN", example = "1")
@ExcelProperty("变动类型,如 RECHARGE, CONSUME, TRANSFER_OUT, TRANSFER_IN")
private String type;
@Schema(description = "变动描述", example = "随便")
@ExcelProperty("变动描述")
private String description;
@Schema(description = "订单 Id/业务单号", example = "84")
@ExcelProperty("订单 Id/业务单号")
private String orderId;
@Schema(description = "业务流水号(转账、订单等唯一标识)")
@ExcelProperty("业务流水号(转账、订单等唯一标识)")
private String bizNo;
@Schema(description = "操作人 Id", example = "8171")
@ExcelProperty("操作人 Id")
private Long operatorId;
@Schema(description = "目标租户 Id转账使用", example = "18731")
@ExcelProperty("目标租户 Id转账使用")
private Long targetTenantId;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createdAt;
@Schema(description = "测试账号数", example = "1")
@ExcelProperty("测试账号数")
private Integer testAccountNum;
}

View File

@@ -0,0 +1,46 @@
package cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 租户积分记录新增/修改 Request VO")
@Data
public class TenantPointsSaveReqVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "16587")
private Long id;
@Schema(description = "本次变动点数,正加负减", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "本次变动点数,正加负减不能为空")
private Integer points;
@Schema(description = "变动后余额快照(冗余)")
private Integer balance;
@Schema(description = "变动类型,如 RECHARGE, CONSUME, TRANSFER_OUT, TRANSFER_IN", example = "1")
private String type;
@Schema(description = "变动描述", example = "随便")
private String description;
@Schema(description = "订单 Id/业务单号", example = "84")
private String orderId;
@Schema(description = "业务流水号(转账、订单等唯一标识)")
private String bizNo;
@Schema(description = "操作人 Id", example = "8171")
private Long operatorId;
@Schema(description = "目标租户 Id转账使用", example = "18731")
private Long targetTenantId;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "创建时间不能为空")
private LocalDateTime createdAt;
}

View File

@@ -33,4 +33,10 @@ public class UserClientSaveReqVO {
@Schema(description = "能否登录 AI 聊天工具", example = "0不允许1允许")
private Byte aiChat;
@Schema(description = "是否允许使用 AI 回复", example = "0不允许1允许")
private Byte aiReplay;
@Schema(description = "是否允许登录 Web AI 客户端", example = "0不允许1允许")
private Byte webAi;
}

View File

@@ -80,4 +80,10 @@ public class UserRespVO{
@Schema(description = "爬取大哥")
private Byte aiChat;
@Schema(description = "是否允许使用 AI 回复", example = "0不允许1允许")
private Byte aiReplay;
@Schema(description = "是否允许登录 Web AI 客户端", example = "0不允许1允许")
private Byte webAi;
}

View File

@@ -88,4 +88,10 @@ public class UserSaveReqVO {
@Schema(description = "能否登录 AI 聊天工具", example = "0不允许1允许")
private Byte aiChat;
@Schema(description = "是否允许使用 AI 回复", example = "0不允许1允许")
private Byte aiReplay;
@Schema(description = "是否允许登录 Web AI 客户端", example = "0不允许1允许")
private Byte webAi;
}

View File

@@ -74,9 +74,43 @@ public class TenantDO extends BaseDO {
* 过期时间
*/
private LocalDateTime expireTime;
/**
* ai过期时间
*/
private LocalDateTime aiExpireTime;
/**
* 大哥过期时间
*/
private LocalDateTime brotherExpireTime;
/**
* 账号数量
*/
private Integer accountCount;
/**
* 上级租户 Id
*/
private Long parentId;
/**
* 备注
*/
private String remark;
/**
* 租户类型
*/
private String tenantType;
/**
* 代理级别
*/
private Integer tenantLevel;
private String initialUser;
}

View File

@@ -0,0 +1,86 @@
package cn.iocoder.yudao.module.system.dal.dataobject.tenantagencypackage;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 代理租户套餐 DO
*
* @author 总后台
*/
@TableName(value = "system_tenant_agency_package",autoResultMap = true)
@KeySequence("system_tenant_agency_package_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TenantIgnore
public class TenantAgencyPackageDO extends BaseDO {
/**
* 套餐编号
*/
@TableId
private Long id;
/**
* 套餐名
*/
private String name;
/**
* 租户状态0正常 1停用
*/
private Integer status;
/**
* 备注
*/
private String remark;
/**
* 关联的菜单编号
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private Set<Long> menuIds;
/**
* 套餐天数
*/
private Integer days;
/**
* 套餐价格
*/
private Integer price;
/**
* 爬主播客户端 0 关闭 1 开启
*/
private Integer hostslClient;
/**
* 爬大哥客户端 0 关闭 1 开启
*/
private Integer brotherClient;
/**
* AI 客户端 0 关闭 1 开启
*/
private Integer aiClient;
/**
* 套餐类型
*/
private Integer packageType;
/**
* Ai自动回复权限 0关闭 1开启
*/
private Integer aiReplay;
/**
* WebAi权限 0关闭 1开启
*/
private Integer webAi;
}

View File

@@ -0,0 +1,40 @@
package cn.iocoder.yudao.module.system.dal.dataobject.tenantbalance;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 租户余额 DO
*
* @author 总后台
*/
@TableName("system_tenant_balance")
@KeySequence("system_tenant_balance_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TenantBalanceDO{
private Long id;
/**
* 当前积分余额
*/
private Integer balance;
/**
* 乐观锁版本号
*/
private Integer version;
/**
* 更新时间
*/
private LocalDateTime updatedAt;
private Integer testAccountNum;
}

View File

@@ -0,0 +1,70 @@
package cn.iocoder.yudao.module.system.dal.dataobject.tenantpoints;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 租户积分记录 DO
*
* @author 总后台
*/
@TableName("system_tenant_points")
@KeySequence("system_tenant_points_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TenantPointsDO {
/**
* 主键
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 本次变动点数,正加负减
*/
private Integer points;
/**
* 变动后余额快照(冗余)
*/
private Integer balance;
/**
* 变动类型,如 RECHARGE, CONSUME, TRANSFER_OUT, TRANSFER_IN
*/
private String type;
/**
* 变动描述
*/
private String description;
/**
* 订单 Id/业务单号
*/
private String orderId;
/**
* 业务流水号(转账、订单等唯一标识)
*/
private String bizNo;
/**
* 操作人 Id
*/
private Long operatorId;
/**
* 目标租户 Id转账使用
*/
private Long targetTenantId;
/**
* 创建时间
*/
private LocalDateTime createdAt;
private Long tenantId;
private String remark;
private Integer testAccountNum;
}

View File

@@ -105,4 +105,10 @@ public class AdminUserDO extends TenantBaseDO {
@Schema(description = "是否允许登录AI客户端", example = "0不允许1允许")
private Byte aiChat;
@Schema(description = "是否允许使用AI回复", example = "0不允许1允许")
private Byte aiReplay;
@Schema(description = "是否允许登录Web AI客户端", example = "0不允许1允许")
private Byte webAi;
}

View File

@@ -1,4 +1,9 @@
package cn.iocoder.yudao.module.system.dal.mysql.tenant;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import org.apache.ibatis.annotations.Param;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
@@ -23,7 +28,12 @@ public interface TenantMapper extends BaseMapperX<TenantDO> {
.likeIfPresent(TenantDO::getContactName, reqVO.getContactName())
.likeIfPresent(TenantDO::getContactMobile, reqVO.getContactMobile())
.eqIfPresent(TenantDO::getStatus, reqVO.getStatus())
.eqIfPresent(TenantDO::getTenantType, reqVO.getTenantType())
.betweenIfPresent(TenantDO::getCreateTime, reqVO.getCreateTime())
.betweenIfPresent(TenantDO::getAiExpireTime, reqVO.getAiExpireTime())
.betweenIfPresent(TenantDO::getExpireTime, reqVO.getExpireTime())
.betweenIfPresent(TenantDO::getBrotherExpireTime, reqVO.getBrotherExpireTime())
.likeIfPresent(TenantDO::getRemark, reqVO.getRemark())
.orderByDesc(TenantDO::getId));
}
@@ -47,4 +57,29 @@ public interface TenantMapper extends BaseMapperX<TenantDO> {
return selectList(TenantDO::getStatus, status);
}
default List<TenantDO> selectByAiExpireTime() {
LambdaQueryWrapper<TenantDO> myQuery = Wrappers.lambdaQuery(TenantDO.class);
myQuery.isNull(TenantDO::getAiExpireTime);
return selectList(myQuery);
}
default PageResult<TenantDO> selectSelfPage(TenantPageReqVO reqVO){
return selectPage(reqVO, new LambdaQueryWrapperX<TenantDO>()
.eq(TenantDO::getParentId, reqVO.getParentId())
.likeIfPresent(TenantDO::getName, reqVO.getName())
.likeIfPresent(TenantDO::getContactName, reqVO.getContactName())
.likeIfPresent(TenantDO::getContactMobile, reqVO.getContactMobile())
.eqIfPresent(TenantDO::getStatus, reqVO.getStatus())
.betweenIfPresent(TenantDO::getCreateTime, reqVO.getCreateTime())
.betweenIfPresent(TenantDO::getAiExpireTime, reqVO.getAiExpireTime())
.betweenIfPresent(TenantDO::getExpireTime, reqVO.getExpireTime())
.betweenIfPresent(TenantDO::getBrotherExpireTime, reqVO.getBrotherExpireTime())
.likeIfPresent(TenantDO::getRemark, reqVO.getRemark())
.orderByDesc(TenantDO::getId));
}
default List<TenantDO> selectTenantByParentId(Long id){
return selectList(TenantDO::getParentId, id);
}
}

View File

@@ -0,0 +1,42 @@
package cn.iocoder.yudao.module.system.dal.mysql.tenantagencypackage;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantagencypackage.TenantAgencyPackageDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.tenantagencypackage.vo.*;
/**
* 代理租户套餐 Mapper
*
* @author 总后台
*/
@Mapper
public interface TenantAgencyPackageMapper extends BaseMapperX<TenantAgencyPackageDO> {
default PageResult<TenantAgencyPackageDO> selectPage(TenantAgencyPackagePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<TenantAgencyPackageDO>()
.likeIfPresent(TenantAgencyPackageDO::getName, reqVO.getName())
.eqIfPresent(TenantAgencyPackageDO::getStatus, reqVO.getStatus())
.eqIfPresent(TenantAgencyPackageDO::getRemark, reqVO.getRemark())
.eqIfPresent(TenantAgencyPackageDO::getMenuIds, reqVO.getMenuIds())
.betweenIfPresent(TenantAgencyPackageDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(TenantAgencyPackageDO::getDays, reqVO.getDays())
.eqIfPresent(TenantAgencyPackageDO::getPrice, reqVO.getPrice())
.eqIfPresent(TenantAgencyPackageDO::getHostslClient, reqVO.getHostslClient())
.eqIfPresent(TenantAgencyPackageDO::getBrotherClient, reqVO.getBrotherClient())
.eqIfPresent(TenantAgencyPackageDO::getAiClient, reqVO.getAiClient())
.eqIfPresent(TenantAgencyPackageDO::getPackageType, reqVO.getPackageType())
.orderByDesc(TenantAgencyPackageDO::getId));
}
default List<TenantAgencyPackageDO> selectListByStatus(Integer status) {
return selectList(TenantAgencyPackageDO::getStatus, status);
}
TenantAgencyPackageDO selectWithXml(Long packageId);
}

View File

@@ -0,0 +1,65 @@
package cn.iocoder.yudao.module.system.dal.mysql.tenantbalance;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantbalance.TenantBalanceDO;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.tenantbalance.vo.*;
import org.apache.ibatis.annotations.Param;
/**
* 租户余额 Mapper
*
* @author 总后台
*/
@Mapper
public interface TenantBalanceMapper extends BaseMapperX<TenantBalanceDO> {
default PageResult<TenantBalanceDO> selectPage(TenantBalancePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<TenantBalanceDO>()
.eqIfPresent(TenantBalanceDO::getBalance, reqVO.getBalance())
.eqIfPresent(TenantBalanceDO::getVersion, reqVO.getVersion())
.eqIfPresent(TenantBalanceDO::getUpdatedAt, reqVO.getUpdatedAt())
.orderByDesc(TenantBalanceDO::getId));
}
default Integer updateBalanceWithVersion(Long id, int amount, Integer oldVersion) {
LambdaUpdateWrapper<TenantBalanceDO> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(TenantBalanceDO::getId, id);
wrapper.eq(TenantBalanceDO::getVersion, oldVersion);
// balance = balance + amount
wrapper.setSql("balance = balance + " + amount);
// version = version + 1
wrapper.setSql("version = version + 1");
return this.update(null, wrapper);
}
IPage<TenantBalanceRespVO> selectPageWithTenantName(IPage<TenantBalanceRespVO> iPage,@Param("req") TenantBalancePageReqVO pageReqVO);
IPage<TenantBalanceRespVO> selectPageWithSelfSubordinateTenant(@Param("iPage") IPage<TenantBalanceRespVO> iPage, @Param("pageReqVO") TenantBalancePageReqVO pageReqVO, @Param("tenantId") Long tenantId);
default Integer updateTestAccountNumWithVersion(Long currentTenantId, Integer newTestAccountNum, Integer oldVersion){
LambdaUpdateWrapper<TenantBalanceDO> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(TenantBalanceDO::getId, currentTenantId);
wrapper.eq(TenantBalanceDO::getVersion, oldVersion);
// testAccount = testAccount + -1
wrapper.setSql("test_account_num = test_account_num + " + newTestAccountNum);
// version = version + 1
wrapper.setSql("version = version + 1");
return this.update(null, wrapper);
}
}

View File

@@ -0,0 +1,61 @@
package cn.iocoder.yudao.module.system.dal.mysql.tenantpoints;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantpoints.TenantPointsDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo.*;
import org.apache.ibatis.annotations.Param;
/**
* 租户积分记录 Mapper
*
* @author 总后台
*/
@Mapper
public interface TenantPointsMapper extends BaseMapperX<TenantPointsDO> {
default PageResult<TenantPointsDO> selectPage(TenantPointsPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<TenantPointsDO>()
.eqIfPresent(TenantPointsDO::getPoints, reqVO.getPoints())
.eqIfPresent(TenantPointsDO::getBalance, reqVO.getBalance())
.eqIfPresent(TenantPointsDO::getType, reqVO.getType())
.eqIfPresent(TenantPointsDO::getDescription, reqVO.getDescription())
.eqIfPresent(TenantPointsDO::getOrderId, reqVO.getOrderId())
.eqIfPresent(TenantPointsDO::getBizNo, reqVO.getBizNo())
.eqIfPresent(TenantPointsDO::getOperatorId, reqVO.getOperatorId())
.eqIfPresent(TenantPointsDO::getTargetTenantId, reqVO.getTargetTenantId())
.eqIfPresent(TenantPointsDO::getCreatedAt, reqVO.getCreatedAt())
.orderByDesc(TenantPointsDO::getId));
}
default PageResult<TenantPointsDO> TenantTransactionHistoryPointsPage(PageParam pageReqVO, Long tenantId){
return selectPage(pageReqVO, new LambdaQueryWrapperX<TenantPointsDO>()
.eq(TenantPointsDO::getTenantId, tenantId)
.orderByDesc(TenantPointsDO::getCreatedAt));
}
default PageResult<TenantPointsDO> selectPageWithTenantId(TenantPointsPageReqVO reqVO, Long tenantId) {
return selectPage(reqVO, new LambdaQueryWrapperX<TenantPointsDO>()
.eq(TenantPointsDO::getTenantId, tenantId)
.eqIfPresent(TenantPointsDO::getPoints, reqVO.getPoints())
.eqIfPresent(TenantPointsDO::getBalance, reqVO.getBalance())
.eqIfPresent(TenantPointsDO::getType, reqVO.getType())
.eqIfPresent(TenantPointsDO::getDescription, reqVO.getDescription())
.eqIfPresent(TenantPointsDO::getOrderId, reqVO.getOrderId())
.eqIfPresent(TenantPointsDO::getBizNo, reqVO.getBizNo())
.eqIfPresent(TenantPointsDO::getOperatorId, reqVO.getOperatorId())
.eqIfPresent(TenantPointsDO::getTargetTenantId, reqVO.getTargetTenantId())
.eqIfPresent(TenantPointsDO::getCreatedAt, reqVO.getCreatedAt())
.orderByDesc(TenantPointsDO::getId));
}
IPage<TenantPointsPageRespVO> selectPageWithXML(@Param("iPage") IPage<TenantPointsPageRespVO> iPage, @Param("pageReqVO") TenantPointsPageReqVO pageReqVO);
IPage<TenantPointsPageRespVO> selectPageWithTenantIdXML(@Param("iPage")IPage<TenantPointsPageRespVO> iPage,@Param("pageReqVO") TenantPointsPageReqVO pageReqVO,@Param("tenantId") Long tenantId);
}

View File

@@ -3,10 +3,12 @@ package cn.iocoder.yudao.module.system.dal.mysql.user;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserRespVO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
@@ -18,6 +20,7 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
return selectOne(AdminUserDO::getUsername, username);
}
default AdminUserDO selectByUsernameAndTenantId(String username,Long tenantId) {
return selectOne(AdminUserDO::getUsername, username
,AdminUserDO::getTenantId, tenantId);
@@ -62,4 +65,10 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
}
List<UserRespVO> selectTenantUserById(Long tenantId);
@TenantIgnore
AdminUserDO selectByUsernameAndTenantIdWithAgencyRenewal(@Param("initialUser") String initialUser,@Param("targetTenantId") Long targetTenantId);
@TenantIgnore
int updateByIdWithRenwal(AdminUserDO targetTenantUser);
}

View File

@@ -109,25 +109,47 @@ public interface ErrorCodeConstants {
ErrorCode TENANT_CAN_NOT_UPDATE_SYSTEM = new ErrorCode(1_002_015_003, "系统租户不能进行修改、删除等操作!");
ErrorCode TENANT_NAME_DUPLICATE = new ErrorCode(1_002_015_004, "名字为【{}】的租户已存在");
ErrorCode TENANT_WEBSITE_DUPLICATE = new ErrorCode(1_002_015_005, "域名为【{}】的租户已存在");
ErrorCode TENANT_LEVEL_CANT_CREATE_AGENCY = new ErrorCode(1_002_015_006, "租户级别不能创建代理租户");
// ========== 租户套餐 1-002-016-000 ==========
ErrorCode TENANT_PACKAGE_NOT_EXISTS = new ErrorCode(1_002_016_000, "租户套餐不存在");
ErrorCode TENANT_PACKAGE_USED = new ErrorCode(1_002_016_001, "租户正在使用该套餐,请给租户重新设置套餐后再尝试删除");
ErrorCode TENANT_PACKAGE_DISABLE = new ErrorCode(1_002_016_002, "名字为【{}】的租户套餐已被禁用");
ErrorCode TENANT_PACKAGE_NAME_DUPLICATE = new ErrorCode(1_002_016_003, "已经存在该名字的租户套餐");
ErrorCode TENANT_USER_NOT_EXISTS = new ErrorCode(1_002_016_004, "租户初始用户不存在");
// ========== 租户套餐 1-002-017-000 ==========
ErrorCode TENANT_POINTS_NOT_EXISTS = new ErrorCode(1_002_017_000, "租户积分不存在");
// ========== 租户余额 1-003-017-000 ==========
ErrorCode TENANT_BALANCE_NOT_EXISTS = new ErrorCode(1_003_017_000, "租户余额不存在");
ErrorCode TENANT_BALANCE_VERSION_ERROR = new ErrorCode(1_003_017_001, "租户余额版本号错误");
ErrorCode TENANT_BALANCE_BALANCE_ERROR = new ErrorCode(1_003_017_002, "租户余额余额错误");
ErrorCode TENANT_BALANCE_BALANCE_NOT_ENOUGH = new ErrorCode(1_003_017_003, "租户余额余额不足");
ErrorCode TENANT_BALANCE_RECHARGE_ERROR = new ErrorCode(1_003_017_004, "租户余额充值错误");
ErrorCode TENANT_WALLET_NOT_EXISTS = new ErrorCode(1_003_017_005, "租户钱包不存在");
ErrorCode TENANT_BALANCE_NOT_ENOUGH = new ErrorCode(1_003_017_006, "当前余额余额不足");
ErrorCode TENANT_BALANCE_TRANSFER_ERROR = new ErrorCode(1_003_017_007, "转账余额不能小于等与 0");
ErrorCode TENANT_BALANCE_TRANSFER_TARGET_NOT_EXISTS = new ErrorCode(1_003_017_008, "转账目标租户钱包不存在");
ErrorCode TENANT_BALANCE_TRANSFER_OPERATION_ERROR = new ErrorCode(1_003_017_009, "转账操作失败");
ErrorCode TENANT_BALANCE_TRANSFER_PASSWORD_ERROR = new ErrorCode(1_003_017_010, "转账密码错误");
ErrorCode TENANT_BALANCE_TRANSFER_PASSWORD_ERROR_IS_NULL = new ErrorCode(1_003_017_011, "转账密码不能为空");
ErrorCode TENANT_BALANCE_TRANSFER_ERROR_TARGET_NOT_SUBORDINATE = new ErrorCode(1_003_017_012, "转账目标租户不是当前租户的下级");
ErrorCode TENANT_BALANCE_CONSUMPTION_OPERATION_ERROR = new ErrorCode(1_003_017_013, "租户余额消费操作失败");
ErrorCode TENANT_CREATE_FAIL = new ErrorCode(1_003_017_014, "租户创建失败");
ErrorCode TENANT_BALANCE_TEST_ACCOUNT_NUM_NOT_ENOUGH = new ErrorCode(1_003_017_015, "当前账户测试账户数量不足");
ErrorCode TENANT_BALANCE_TEST_ACCOUNT_NUM_OPERATION_ERROR = new ErrorCode(1_003_017_016, "租户测试账户数量操作错误");
ErrorCode TENANT_IS_AGENCY = new ErrorCode(1_003_017_017, "代理租户,不能进行续费操作");
ErrorCode TENANT_UPDATE_INITIAL_USER_INFO_FAIL = new ErrorCode(1_003_017_018, "更新租户初始用户信息失败");
ErrorCode TENANT_RENEWAL_FAIL = new ErrorCode(1_003_017_019, "租户续费失败");
// ================= 租户套餐 1-003-018-000 ==================
ErrorCode TENANT_AGENCY_PACKAGE_NOT_EXISTS = new ErrorCode(1_003_018_000, "代理租户套餐不存在");
// ========== 社交用户 1-002-018-000 ==========
ErrorCode SOCIAL_USER_AUTH_FAILURE = new ErrorCode(1_002_018_000, "社交授权失败,原因是:{}");
ErrorCode SOCIAL_USER_NOT_FOUND = new ErrorCode(1_002_018_001, "社交授权失败,找不到对应的用户");
ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_PHONE_CODE_ERROR = new ErrorCode(1_002_018_200, "获得手机号失败");
ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_QRCODE_ERROR = new ErrorCode(1_002_018_201, "获得小程序码失败");
ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_TEMPLATE_ERROR = new ErrorCode(1_002_018_202, "获得小程序订阅消息模版失败");
ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_MESSAGE_ERROR = new ErrorCode(1_002_018_203, "发送小程序订阅消息失败");
ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_ORDER_UPLOAD_SHIPPING_INFO_ERROR = new ErrorCode(1_002_018_204, "上传微信小程序发货信息失败");
ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_ORDER_NOTIFY_CONFIRM_RECEIVE_ERROR = new ErrorCode(1_002_018_205, "上传微信小程序订单收货信息失败");
ErrorCode SOCIAL_CLIENT_NOT_EXISTS = new ErrorCode(1_002_018_210, "社交客户端不存在");
ErrorCode SOCIAL_CLIENT_UNIQUE = new ErrorCode(1_002_018_211, "社交客户端已存在配置");
// ========== OAuth2 客户端 1-002-020-000 =========
ErrorCode OAUTH2_CLIENT_NOT_EXISTS = new ErrorCode(1_002_020_000, "OAuth2 客户端不存在");

View File

@@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.system.enums.agencyTenantPackage;
import lombok.Getter;
/*
* @author: ziin
* @date: 2025/11/25 15:22
*/
@Getter
public enum PackageTypeEnum {
AI(0, "AI"),
CRAWL(1, "爬虫"),
BROTHER_CRAWL(2, "兄弟爬虫"),
TEST(99, "测试账户"),
AGENCY(999, "代理");
private final Integer value;
private final String name;
PackageTypeEnum(Integer value, String name) {
this.value = value;
this.name = name;
}
}

View File

@@ -0,0 +1,29 @@
package cn.iocoder.yudao.module.system.enums.balance;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
/*
* @author: ziin
* @date: 2025/11/19 21:30
*/
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum BalanceEnum {
RECHARGE("充值"),
TRANSFER_OUT("转出"),
TRANSFER_IN("转入"),
CONSUMPTION("消费"),
BONUS("奖励");
private String desc;
}

View File

@@ -0,0 +1,23 @@
package cn.iocoder.yudao.module.system.enums.tenant;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
/*
* @author: ziin
* @date: 2025/11/21 18:55
*/
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum TenantEnum {
AGENCY("代理"),
USER("用户");
private String tenantType;
}

View File

@@ -0,0 +1,93 @@
package cn.iocoder.yudao.module.system.job;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.dal.mysql.tenant.TenantMapper;
import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
/**
* 禁用过期账号定时任务处理器
* <p>
* 该类用于定时检查并禁用已过期的AI账号和大哥账号。
* 通过查询租户表中已过期的账号,然后将对应用户的权限状态更新为禁用。
* </p>
*
* @author ziin
* @date 2025/9/16 14:35
*/
@Slf4j
@Component
public class DisableAIExpiredAccount implements JobHandler{
/**
* 租户数据访问对象
* 用于查询租户信息和过期时间
*/
@Resource
TenantMapper tenantMapper;
/**
* 管理员用户数据访问对象
* 用于查询和更新用户权限状态
*/
@Resource
private AdminUserMapper userMapper;
/**
* 执行禁用过期账号的定时任务
* <p>
* 该方法会执行以下操作:
* 1. 查询所有AI账号已过期的租户
* 2. 查询所有大哥账号已过期的租户
* 3. 分别禁用这些租户下的用户对应权限
* 4. 返回操作结果统计信息
* </p>
*
* @param param 任务参数(当前未使用)
* @return 操作结果字符串包含禁用的AI账号和大哥账号数量
* @throws Exception 执行过程中可能抛出的异常
*/
@Override
@TenantJob
public String execute(String param) throws Exception {
Long tenantId = TenantContextHolder.getTenantId();
TenantDO tenant = tenantMapper.selectById(tenantId);
if (tenant.getAiExpireTime()!=null) {
Duration brotherDuration = LocalDateTimeUtil.between(tenant.getAiExpireTime(), LocalDateTime.now());
long minutes = brotherDuration.toMinutes();
LambdaQueryWrapper<AdminUserDO> aiUserQueryWrapper = new LambdaQueryWrapper<>();
aiUserQueryWrapper.eq(AdminUserDO::getTenantId, tenantId);
aiUserQueryWrapper.eq(AdminUserDO::getAiChat, 1);
List<AdminUserDO> aiUserList = userMapper.selectList(aiUserQueryWrapper);
int aiAccountNum = 0 ;
if (minutes >= 0) {
for (AdminUserDO adminUserDO : aiUserList) {
adminUserDO.setAiChat((byte) 0);
userMapper.updateById(adminUserDO);
aiAccountNum++;
log.info("禁用过期AI账号账号ID{}", adminUserDO.getId());
}
}
// 返回操作结果包含禁用的AI账号和大哥账号数量统计
return "禁用过期账号成功,禁用了 " + aiAccountNum + " 个 AI 账号。";
}
return "租户未配置过期时间";
}
}

View File

@@ -0,0 +1,119 @@
package cn.iocoder.yudao.module.system.job;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.dal.mysql.tenant.TenantMapper;
import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
/**
* 禁用过期账号定时任务处理器
* <p>
* 该类用于定时检查并禁用已过期的AI账号和大哥账号。
* 通过查询租户表中已过期的账号,然后将对应用户的权限状态更新为禁用。
* </p>
*
* @author ziin
* @date 2025/9/16 14:35
*/
@Slf4j
@Component
public class DisableBrotherExpiredAccount implements JobHandler {
/**
* 租户数据访问对象
* 用于查询租户信息和过期时间
*/
@Resource
TenantMapper tenantMapper;
/**
* 管理员用户数据访问对象
* 用于查询和更新用户权限状态
*/
@Resource
private AdminUserMapper userMapper;
/**
* 执行禁用过期账号的定时任务
* <p>
* 该方法会执行以下操作:
* 1. 查询所有AI账号已过期的租户
* 2. 查询所有大哥账号已过期的租户
* 3. 分别禁用这些租户下的用户对应权限
* 4. 返回操作结果统计信息
* </p>
*
* @param param 任务参数(当前未使用)
* @return 操作结果字符串包含禁用的AI账号和大哥账号数量
* @throws Exception 执行过程中可能抛出的异常
*/
@Override
@TenantJob
/**
* 执行禁用过期大哥账号的定时任务
* @param param 任务参数(未使用)
* @return 执行结果信息
* @throws Exception 执行过程中可能抛出的异常
*/
public String execute(String param) throws Exception {
// 获取当前租户ID
Long tenantId = TenantContextHolder.getTenantId();
// 查询当前租户信息
TenantDO tenant = tenantMapper.selectById(tenantId);
// 检查租户是否配置了大哥账号过期时间,如未配置则直接返回提示
if (tenant.getBrotherExpireTime() == null) {
return "租户未配置大哥过期时间";
}
// 计算从租户设置的过期时间到当前时间的时间差
Duration brotherDuration = LocalDateTimeUtil.between(tenant.getBrotherExpireTime(), LocalDateTime.now());
// 转换为分钟数
long minutes = brotherDuration.toMinutes();
// 创建查询条件,查找当前租户下的所有大哥账号
LambdaQueryWrapper<AdminUserDO> brotherUserQueryWrapper = new LambdaQueryWrapper<>();
brotherUserQueryWrapper.eq(AdminUserDO::getTenantId, tenantId);
brotherUserQueryWrapper.eq(AdminUserDO::getBigBrother, 1);
// 查询符合条件的大哥账号列表
List<AdminUserDO> aiUserList = userMapper.selectList(brotherUserQueryWrapper);
// 统计被禁用的大哥账号数量
int brotherAccountNum = 0;
// 如果已过过期时间minutes >= 0表示当前时间已超过过期时间
if (minutes >= 0) {
// 遍历所有大哥账号进行禁用操作
for (AdminUserDO adminUserDO : aiUserList) {
// 将BigBrother标志设置为0表示禁用大哥权限
adminUserDO.setBigBrother((byte) 0);
// 更新用户信息到数据库
userMapper.updateById(adminUserDO);
// 更新统计计数
brotherAccountNum++;
// 记录禁用操作日志
log.info("禁用过期大哥账号账号ID{}", adminUserDO.getId());
}
}
// 返回操作结果:包含禁用的大哥账号数量统计
return "禁用过期账号成功,禁用了 " + brotherAccountNum + " 个 大哥账号。";
}
}

View File

@@ -0,0 +1,88 @@
package cn.iocoder.yudao.module.system.job;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.dal.mysql.tenant.TenantMapper;
import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.List;
/**
* 禁用过期账号定时任务处理器
* <p>
* 该类用于定时检查并禁用已过期的AI账号和大哥账号。
* 通过查询租户表中已过期的账号,然后将对应用户的权限状态更新为禁用。
* </p>
*
* @author ziin
* @date 2025/9/16 14:35
*/
@Slf4j
@Component
public class DisableCrawlExpiredAccount implements JobHandler{
/**
* 租户数据访问对象
* 用于查询租户信息和过期时间
*/
@Resource
TenantMapper tenantMapper;
/**
* 管理员用户数据访问对象
* 用于查询和更新用户权限状态
*/
@Resource
private AdminUserMapper userMapper;
/**
* 执行禁用过期账号的定时任务
* <p>
* 该方法会执行以下操作:
* 1. 查询所有AI账号已过期的租户
* 2. 查询所有大哥账号已过期的租户
* 3. 分别禁用这些租户下的用户对应权限
* 4. 返回操作结果统计信息
* </p>
*
* @param param 任务参数(当前未使用)
* @return 操作结果字符串包含禁用的AI账号和大哥账号数量
* @throws Exception 执行过程中可能抛出的异常
*/
@Override
@TenantJob
public String execute(String param) throws Exception {
Long tenantId = TenantContextHolder.getTenantId();
TenantDO tenant = tenantMapper.selectById(tenantId);
if (tenant.getExpireTime()!=null) {
Duration brotherDuration = LocalDateTimeUtil.between(tenant.getExpireTime(), LocalDateTime.now());
long minutes = brotherDuration.toMinutes();
LambdaQueryWrapper<AdminUserDO> aiUserQueryWrapper = new LambdaQueryWrapper<>();
aiUserQueryWrapper.eq(AdminUserDO::getTenantId, tenantId);
aiUserQueryWrapper.eq(AdminUserDO::getCrawl, 1);
List<AdminUserDO> aiUserList = userMapper.selectList(aiUserQueryWrapper);
int aiAccountNum = 0 ;
if (minutes >= 0) {
for (AdminUserDO adminUserDO : aiUserList) {
adminUserDO.setCrawl((byte) 0);
userMapper.updateById(adminUserDO);
aiAccountNum++;
log.info("禁用过期爬虫账号账号ID{}", adminUserDO.getId());
}
}
// 返回操作结果包含禁用的AI账号和大哥账号数量统计
return "禁用过期账号成功,禁用了 " + aiAccountNum + " 个 爬虫 账号。";
}
return "租户未配置过期时间";
}
}

View File

@@ -0,0 +1,68 @@
package cn.iocoder.yudao.module.system.job;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.dal.mysql.tenant.TenantMapper;
import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.List;/*
* @author: ziin
* @date: 2025/12/11 20:55
*/
@Slf4j
@Component
public class DisableWebAIExpiredAccount implements JobHandler{
/**
* 租户数据访问对象
* 用于查询租户信息和过期时间
*/
@Resource
TenantMapper tenantMapper;
/**
* 管理员用户数据访问对象
* 用于查询和更新用户权限状态
*/
@Resource
private AdminUserMapper userMapper;
@Override
@TenantJob
public String execute(String param) throws Exception {
Long tenantId = TenantContextHolder.getTenantId();
TenantDO tenant = tenantMapper.selectById(tenantId);
if (tenant.getExpireTime()!=null) {
Duration brotherDuration = LocalDateTimeUtil.between(tenant.getAiExpireTime(), LocalDateTime.now());
long minutes = brotherDuration.toMinutes();
LambdaQueryWrapper<AdminUserDO> aiUserQueryWrapper = new LambdaQueryWrapper<>();
aiUserQueryWrapper.eq(AdminUserDO::getTenantId, tenantId);
aiUserQueryWrapper.eq(AdminUserDO::getWebAi, 1);
List<AdminUserDO> aiUserList = userMapper.selectList(aiUserQueryWrapper);
int aiAccountNum = 0 ;
if (minutes >= 0) {
for (AdminUserDO adminUserDO : aiUserList) {
adminUserDO.setWebAi((byte) 0);
userMapper.updateById(adminUserDO);
aiAccountNum++;
log.info("禁用过期WebAI账号账号ID{}", adminUserDO.getId());
}
}
// 返回操作结果包含禁用的AI账号和大哥账号数量统计
return "禁用过期账号成功,禁用了 " + aiAccountNum + " 个 WebAI 账号。";
}
return "租户未配置过期时间";
}
}

View File

@@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackagePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantagencypackage.TenantAgencyPackageDO;
import javax.validation.Valid;
import java.util.List;
@@ -67,6 +68,6 @@ public interface TenantPackageService {
* @param status 状态
* @return 租户套餐
*/
List<TenantPackageDO> getTenantPackageListByStatus(Integer status);
List<TenantAgencyPackageDO> getTenantPackageListByStatus(Integer status);
}

View File

@@ -1,15 +1,20 @@
package cn.iocoder.yudao.module.system.service.tenant;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackagePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageSimpleRespVO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantagencypackage.TenantAgencyPackageDO;
import cn.iocoder.yudao.module.system.dal.mysql.tenant.TenantPackageMapper;
import cn.iocoder.yudao.module.system.dal.mysql.tenantagencypackage.TenantAgencyPackageMapper;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.google.common.annotations.VisibleForTesting;
import org.springframework.context.annotation.Lazy;
@@ -38,6 +43,9 @@ public class TenantPackageServiceImpl implements TenantPackageService {
@Lazy // 避免循环依赖的报错
private TenantService tenantService;
@Resource
private TenantAgencyPackageMapper tenantAgencyPackageMapper;
@Override
public Long createTenantPackage(TenantPackageSaveReqVO createReqVO) {
// 校验套餐名是否重复
@@ -113,8 +121,14 @@ public class TenantPackageServiceImpl implements TenantPackageService {
}
@Override
public List<TenantPackageDO> getTenantPackageListByStatus(Integer status) {
return tenantPackageMapper.selectListByStatus(status);
public List<TenantAgencyPackageDO> getTenantPackageListByStatus(Integer status) {
Long tenantId = TenantContextHolder.getTenantId();
if (tenantId != 1) {
return tenantAgencyPackageMapper.selectListByStatus(status);
}
List<TenantPackageDO> tenantPackageDOS = tenantPackageMapper.selectListByStatus(status);
return BeanUtils.toBean(tenantPackageDOS, TenantAgencyPackageDO.class);
}

View File

@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.service.tenant;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantRenewalReqVO;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO;
import cn.iocoder.yudao.module.system.service.tenant.handler.TenantInfoHandler;
@@ -135,4 +136,9 @@ public interface TenantService {
*/
void validTenant(Long id);
PageResult<TenantDO> getSelfTenantPage(@Valid TenantPageReqVO pageVO);
List<TenantDO> getChildrenTenant(Long id);
void renewalTenant( TenantRenewalReqVO updateReqVO);
}

View File

@@ -1,6 +1,9 @@
package cn.iocoder.yudao.module.system.service.tenant;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
@@ -11,33 +14,48 @@ import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
import cn.iocoder.yudao.framework.tenant.config.TenantProperties;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantRenewalReqVO;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO;
import cn.iocoder.yudao.module.system.convert.tenant.TenantConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantagencypackage.TenantAgencyPackageDO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantbalance.TenantBalanceDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.dal.mysql.dept.UserPostMapper;
import cn.iocoder.yudao.module.system.dal.mysql.tenant.TenantMapper;
import cn.iocoder.yudao.module.system.dal.mysql.tenantbalance.TenantBalanceMapper;
import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper;
import cn.iocoder.yudao.module.system.enums.agencyTenantPackage.PackageTypeEnum;
import cn.iocoder.yudao.module.system.enums.permission.RoleCodeEnum;
import cn.iocoder.yudao.module.system.enums.permission.RoleTypeEnum;
import cn.iocoder.yudao.module.system.enums.tenant.TenantEnum;
import cn.iocoder.yudao.module.system.service.permission.MenuService;
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
import cn.iocoder.yudao.module.system.service.permission.RoleService;
import cn.iocoder.yudao.module.system.service.tenant.handler.TenantInfoHandler;
import cn.iocoder.yudao.module.system.service.tenant.handler.TenantMenuHandler;
import cn.iocoder.yudao.module.system.service.tenantagencypackage.TenantAgencyPackageService;
import cn.iocoder.yudao.module.system.service.tenantbalance.TenantBalanceService;
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.Objects;
import java.util.Set;
@@ -74,6 +92,16 @@ public class TenantServiceImpl implements TenantService {
private MenuService menuService;
@Resource
private PermissionService permissionService;
@Resource
private TenantBalanceMapper tenantBalanceMapper;
@Resource
private TenantAgencyPackageService tenantAgencyPackageService;
@Resource
private AdminUserMapper userMapper;
@Resource
private TenantBalanceService balanceService;
@Autowired
private TenantBalanceService tenantBalanceService;
@Override
public List<Long> getTenantIdList() {
@@ -95,29 +123,262 @@ public class TenantServiceImpl implements TenantService {
}
}
@Override
public PageResult<TenantDO> getSelfTenantPage(TenantPageReqVO pageVO) {
Long tenantId = TenantContextHolder.getTenantId();
pageVO.setParentId(tenantId);
return tenantMapper.selectSelfPage(pageVO);
}
@Override
public List<TenantDO> getChildrenTenant(Long id) {
return tenantMapper.selectTenantByParentId(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
@TenantIgnore
public void renewalTenant(TenantRenewalReqVO updateReqVO) {
// 校验租户是否存在
TenantDO targetTenant = getTenant(updateReqVO.getId());
Long currentTenantId = TenantContextHolder.getTenantId();
if (targetTenant == null) {
throw exception(TENANT_NOT_EXISTS);
}
// 校验租户是否为代理类型
if (targetTenant.getTenantType().equals(TenantEnum.AGENCY.getTenantType())) {
throw exception(TENANT_IS_AGENCY);
}
TenantAgencyPackageDO tenantAgencyPackage = tenantAgencyPackageService.getTenantAgencyPackage(updateReqVO.getPackageId());
TenantBalanceDO tenantBalance = tenantBalanceService.getTenantBalance(currentTenantId);
AdminUserDO targetTenantUser = userService.getUserByTenantIdAndUserName(updateReqVO.getId(), targetTenant.getInitialUser());
if (targetTenantUser == null) {
throw exception(TENANT_USER_NOT_EXISTS);
}
if (tenantBalance.getBalance() < tenantAgencyPackage.getPrice()){
throw exception(TENANT_BALANCE_NOT_ENOUGH);
}
if (balanceService.consumption(tenantAgencyPackage.getId(), targetTenant.getId(), updateReqVO.getRemark())) {
log.info("代理: {} 续费租户:{} 成功,套餐 Id:{}", currentTenantId,targetTenant.getId(),updateReqVO.getPackageId());
}
if (targetTenant.getExpireTime().isBefore(LocalDateTime.now())){
targetTenant.setExpireTime(LocalDateTime.now().plusDays(tenantAgencyPackage.getDays()));
targetTenant.setStatus(CommonStatusEnum.ENABLE.getStatus());
targetTenantUser.setCrawl((byte) 1);
}else {
targetTenant.setExpireTime(targetTenant.getExpireTime().plusDays(tenantAgencyPackage.getDays()));
}
if (tenantAgencyPackage.getAiClient()==1){
if (targetTenant.getAiExpireTime().isBefore(LocalDateTime.now())){
targetTenant.setAiExpireTime(LocalDateTime.now().plusDays(tenantAgencyPackage.getDays()));
targetTenantUser.setAiReplay((byte) 1);
targetTenantUser.setAiChat((byte) 1);
}else {
targetTenant.setAiExpireTime(targetTenant.getAiExpireTime().plusDays(tenantAgencyPackage.getDays()));
}
}
if (tenantAgencyPackage.getBrotherClient() ==1 ){
if (targetTenant.getBrotherExpireTime().isBefore(LocalDateTime.now())){
targetTenant.setBrotherExpireTime(LocalDateTime.now().plusDays(tenantAgencyPackage.getDays()));
targetTenantUser.setBigBrother((byte) 1);
}else {
targetTenant.setBrotherExpireTime(targetTenant.getBrotherExpireTime().plusDays(tenantAgencyPackage.getDays()));
}
}
int updateInitialUserCount = userMapper.updateByIdWithRenwal(targetTenantUser);
if (updateInitialUserCount <= 0) {
throw exception(TENANT_UPDATE_INITIAL_USER_INFO_FAIL);
}
int updateTenantCount = tenantMapper.updateById(targetTenant);
if (updateTenantCount <= 0) {
throw exception(TENANT_RENEWAL_FAIL);
}
}
@Override
@DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换
@DataPermission(enable = false) // 参见 https://gitee.com/zhijiantianya/ruoyi-vue-pro/pulls/1154 说明
public Long createTenant(TenantSaveReqVO createReqVO) {
// 校验租户名称是否重复
// 获取当前操作租户的ID即创建者的租户ID
Long currentTenantId = TenantContextHolder.getTenantId();
if (currentTenantId != 1){
// 校验租户名称是否重复null表示新增场景无需排除当前ID
validTenantNameDuplicate(createReqVO.getName(), null);
// 校验租户域名是否重复null表示新增场景无需排除当前ID
validTenantWebsiteDuplicate(createReqVO.getWebsite(), null);
// 校验并获取租户套餐信息(确保套餐存在且未被禁用)
TenantAgencyPackageDO tenantAgencyPackageDO = tenantAgencyPackageService.validTenantPackage(createReqVO.getPackageId());
// 查询当前租户的详细信息
TenantDO currentTenant = tenantMapper.selectById(currentTenantId);
// 校验租户类型和层级权限不允许创建代理类型租户或当前租户级别为2的租户不允许创建
if (createReqVO.getTenantType().equals(TenantEnum.AGENCY.getTenantType()) && currentTenant.getTenantLevel() == 2) {
throw exception(TENANT_LEVEL_CANT_CREATE_AGENCY);
}
// 将请求参数转换为租户数据对象
TenantDO tenant = BeanUtils.toBean(createReqVO, TenantDO.class);
// 获取当前时间并计算租户过期时间
String now = DateUtil.now(); // 获取当前时间字符串
DateTime dt = DateUtil.parse(now); // 将时间字符串解析为DateTime对象
LocalDateTime localDateTime = LocalDateTimeUtil.of(dt); // 转换为LocalDateTime对象
// 根据套餐天数计算过期时间:当前时间 + 套餐天数
LocalDateTime offset = LocalDateTimeUtil.offset(localDateTime, tenantAgencyPackageDO.getDays(), ChronoUnit.DAYS);
// 设置租户的基本过期时间
tenant.setExpireTime(offset);
// 设置租户的初始用户名(创建者)
tenant.setInitialUser(createReqVO.getUsername());
// 根据套餐配置设置特定功能的过期时间
// 如果套餐包含"大哥客户端"功能,则设置大哥客户端的过期时间
if (tenantAgencyPackageDO.getBrotherClient() == 1){
tenant.setBrotherExpireTime(offset);
}
// 如果套餐包含"AI客户端"功能则设置AI客户端的过期时间
if (tenantAgencyPackageDO.getAiClient() == 1){
tenant.setAiExpireTime(offset);
}
if(tenantAgencyPackageDO.getBrotherClient() == 2){}
// 设置新租户的级别为当前租户级别+1层级关系
if (createReqVO.getTenantType().equals(TenantEnum.AGENCY.getTenantType())){
tenant.setTenantLevel(currentTenant.getTenantLevel() + 1);
}
// 设置新租户的父租户ID为当前租户ID建立层级关系
tenant.setParentId(currentTenantId);
if (tenant.getTenantType().equals(TenantEnum.AGENCY.getTenantType())) {
tenant.setStatus(CommonStatusEnum.DISABLE.getStatus());
}
tenantMapper.insert(tenant);
// 扣除开通费用,
if (balanceService.consumption(createReqVO.getPackageId(), tenant.getId(), createReqVO.getRemark())) {
log.info("代理: {} 开通租户:{} 成功,套餐 Id:{}", currentTenantId,tenant.getId(),createReqVO.getPackageId());
}
// 开通测试套餐扣除测试账号数
if (tenantAgencyPackageDO.getPackageType().equals(PackageTypeEnum.TEST.getValue())){
balanceService.reduceTestAccountNum(currentTenantId, createReqVO.getRemark());
}
if (!tenantAgencyPackageDO.getPackageType().equals(PackageTypeEnum.AGENCY.getValue())
&& !tenantAgencyPackageDO.getPackageType().equals(PackageTypeEnum.TEST.getValue())) {
balanceService.addTestAccountNum(currentTenantId, createReqVO.getRemark());
}
// 在新创建的租户上下文中执行管理员初始化操作
TenantUtils.execute(tenant.getId(), () -> {
// 创建租户的默认角色
Long roleId = AgencyCreateRole(tenantAgencyPackageDO);
// 创建租户的管理员用户,并分配角色
Long userId = createUser(roleId, createReqVO);
AdminUserDO user = userService.getUser(userId);
if (tenantAgencyPackageDO.getHostslClient() == 1){
user.setCrawl((byte) 1);
}
if (tenantAgencyPackageDO.getBrotherClient() == 1){
user.setBigBrother((byte) 1);
}
if (tenantAgencyPackageDO.getAiClient() == 1){
user.setAiChat((byte) 1);
}
if (tenantAgencyPackageDO.getAiReplay() == 1){
user.setAiReplay((byte) 1);
}
if (tenantAgencyPackageDO.getWebAi() == 1){
user.setWebAi((byte) 1);
}
userMapper.updateById(user);
// 将创建的用户设置为租户的联系人(管理员)
tenantMapper.updateById(new TenantDO().setId(tenant.getId()).setContactUserId(userId));
});
// 如果创建的是代理类型租户,则初始化其钱包
if (tenant.getTenantType().equals("代理")) {
// 创建租户钱包对象
TenantBalanceDO tenantBalance = new TenantBalanceDO();
tenantBalance.setId(tenant.getId()); // 钱包ID与租户ID一致
tenantBalance.setBalance(0); // 初始余额设为0
tenantBalance.setVersion(0); // 初始版本号设为0
tenantBalance.setTestAccountNum(15);
tenantBalanceMapper.insert(tenantBalance); // 插入钱包记录
}
// 返回新创建的租户ID
return tenant.getId();
}
// 校验租户名称是否重复null表示新增场景无需排除当前ID
validTenantNameDuplicate(createReqVO.getName(), null);
// 校验租户域名是否重复
// 校验租户域名是否重复null表示新增场景无需排除当前ID
validTenantWebsiteDuplicate(createReqVO.getWebsite(), null);
// 校验套餐被禁用
// 校验并获取租户套餐信息(确保套餐存在且未被禁用)
TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(createReqVO.getPackageId());
// 创建租户
// 查询当前租户的详细信息
TenantDO currentTenant = tenantMapper.selectById(currentTenantId);
// 校验租户类型和层级权限不允许创建代理类型租户或当前租户级别为2的租户不允许创建
if (createReqVO.getTenantType().equals(TenantEnum.AGENCY.getTenantType()) && currentTenant.getTenantLevel() == 2) {
throw exception(TENANT_LEVEL_CANT_CREATE_AGENCY);
}
// 将请求参数转换为租户数据对象
TenantDO tenant = BeanUtils.toBean(createReqVO, TenantDO.class);
// 设置新租户的级别为当前租户级别+1层级关系
if (createReqVO.getTenantType().equals(TenantEnum.AGENCY.getTenantType())){
tenant.setTenantLevel(currentTenant.getTenantLevel() + 1);
}
// 设置新租户的父租户ID为当前租户ID建立层级关系
tenant.setParentId(currentTenantId);
// 将新租户信息插入数据库
tenantMapper.insert(tenant);
// 创建租户的管理员
// 在新创建的租户上下文中执行管理员初始化操作
TenantUtils.execute(tenant.getId(), () -> {
// 创建角色
// 创建租户的默认角色
Long roleId = createRole(tenantPackage);
// 创建用户,并分配角色
// 创建租户的管理员用户,并分配角色
Long userId = createUser(roleId, createReqVO);
// 修改租户的管理员
// 将创建的用户设置为租户的联系人(管理员)
tenantMapper.updateById(new TenantDO().setId(tenant.getId()).setContactUserId(userId));
});
// 如果创建的是代理类型租户,则初始化其钱包
if (tenant.getTenantType().equals("代理")) {
// 创建租户钱包对象
TenantBalanceDO tenantBalance = new TenantBalanceDO();
tenantBalance.setId(tenant.getId()); // 钱包ID与租户ID一致
tenantBalance.setBalance(0); // 初始余额设为0
tenantBalance.setVersion(0); // 初始版本号设为0
tenantBalance.setTestAccountNum(15);
tenantBalanceMapper.insert(tenantBalance); // 插入钱包记录
}
// 返回新创建的租户ID
return tenant.getId();
}
@@ -140,6 +401,17 @@ public class TenantServiceImpl implements TenantService {
return roleId;
}
private Long AgencyCreateRole(TenantAgencyPackageDO agencyPackageDO) {
// 创建角色
RoleSaveReqVO reqVO = new RoleSaveReqVO();
reqVO.setName(RoleCodeEnum.TENANT_ADMIN.getName()).setCode(RoleCodeEnum.TENANT_ADMIN.getCode())
.setSort(0).setRemark("系统自动生成");
Long roleId = roleService.createRole(reqVO, RoleTypeEnum.SYSTEM.getType());
// 分配权限
permissionService.assignRoleMenu(roleId, agencyPackageDO.getMenuIds());
return roleId;
}
@Override
@DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换
public void updateTenant(TenantSaveReqVO updateReqVO) {
@@ -150,15 +422,27 @@ public class TenantServiceImpl implements TenantService {
// 校验租户域名是否重复
validTenantWebsiteDuplicate(updateReqVO.getWebsite(), updateReqVO.getId());
// 校验套餐被禁用
TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(updateReqVO.getPackageId());
// 更新租户
TenantDO updateObj = BeanUtils.toBean(updateReqVO, TenantDO.class);
tenantMapper.updateById(updateObj);
// 如果套餐发生变化,则修改其角色的权限
if (ObjectUtil.notEqual(tenant.getPackageId(), updateReqVO.getPackageId())) {
updateTenantRoleMenu(tenant.getId(), tenantPackage.getMenuIds());
if (updateReqVO.getTenantType().equals(TenantEnum.AGENCY.getTenantType()) || tenant.getParentId() != 1) {
TenantAgencyPackageDO tenantAgencyPackageDO = tenantAgencyPackageService.validTenantPackage(updateReqVO.getPackageId());
// 更新租户
TenantDO updateObj = BeanUtils.toBean(updateReqVO, TenantDO.class);
tenantMapper.updateById(updateObj);
// 如果套餐发生变化,则修改其角色的权限
if (ObjectUtil.notEqual(tenant.getPackageId(), updateReqVO.getPackageId())) {
updateTenantRoleMenu(tenant.getId(), tenantAgencyPackageDO.getMenuIds());
}
}else {
TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(updateReqVO.getPackageId());
// 更新租户
TenantDO updateObj = BeanUtils.toBean(updateReqVO, TenantDO.class);
tenantMapper.updateById(updateObj);
// 如果套餐发生变化,则修改其角色的权限
if (ObjectUtil.notEqual(tenant.getPackageId(), updateReqVO.getPackageId())) {
updateTenantRoleMenu(tenant.getId(), tenantPackage.getMenuIds());
}
}
}
private void validTenantNameDuplicate(String name, Long id) {
@@ -310,4 +594,4 @@ public class TenantServiceImpl implements TenantService {
return tenantProperties == null || Boolean.FALSE.equals(tenantProperties.getEnable());
}
}
}

View File

@@ -0,0 +1,66 @@
package cn.iocoder.yudao.module.system.service.tenantagencypackage;
import java.util.*;
import javax.validation.*;
import javax.validation.constraints.NotNull;
import cn.iocoder.yudao.module.system.controller.admin.tenantagencypackage.vo.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantagencypackage.TenantAgencyPackageDO;
/**
* 代理租户套餐 Service 接口
*
* @author 总后台
*/
public interface TenantAgencyPackageService {
/**
* 创建代理租户套餐
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createTenantAgencyPackage(@Valid TenantAgencyPackageSaveReqVO createReqVO);
/**
* 更新代理租户套餐
*
* @param updateReqVO 更新信息
*/
void updateTenantAgencyPackage(@Valid TenantAgencyPackageSaveReqVO updateReqVO);
/**
* 删除代理租户套餐
*
* @param id 编号
*/
void deleteTenantAgencyPackage(Long id);
/**
* 批量删除代理租户套餐
*
* @param ids 编号
*/
void deleteTenantAgencyPackageListByIds(List<Long> ids);
/**
* 获得代理租户套餐
*
* @param id 编号
* @return 代理租户套餐
*/
TenantAgencyPackageDO getTenantAgencyPackage(Long id);
/**
* 获得代理租户套餐分页
*
* @param pageReqVO 分页查询
* @return 代理租户套餐分页
*/
PageResult<TenantAgencyPackageDO> getTenantAgencyPackagePage(TenantAgencyPackagePageReqVO pageReqVO);
TenantAgencyPackageDO validTenantPackage(@NotNull(message = "租户套餐编号不能为空") Long packageId);
List<TenantAgencyPackageDO> getTenantPackageListByStatus(Integer status);
}

View File

@@ -0,0 +1,108 @@
package cn.iocoder.yudao.module.system.service.tenantagencypackage;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantagencypackage.TenantAgencyPackageDO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import cn.iocoder.yudao.module.system.controller.admin.tenantagencypackage.vo.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.dal.mysql.tenantagencypackage.TenantAgencyPackageMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
/**
* 代理租户套餐 Service 实现类
*
* @author 总后台
*/
@Service
@Validated
public class TenantAgencyPackageServiceImpl implements TenantAgencyPackageService {
@Resource
private TenantAgencyPackageMapper tenantAgencyPackageMapper;
@Override
public Long createTenantAgencyPackage(TenantAgencyPackageSaveReqVO createReqVO) {
// 插入
TenantAgencyPackageDO tenantAgencyPackage = BeanUtils.toBean(createReqVO, TenantAgencyPackageDO.class);
tenantAgencyPackageMapper.insert(tenantAgencyPackage);
// 返回
return tenantAgencyPackage.getId();
}
@Override
public void updateTenantAgencyPackage(TenantAgencyPackageSaveReqVO updateReqVO) {
// 校验存在
validateTenantAgencyPackageExists(updateReqVO.getId());
// 更新
TenantAgencyPackageDO updateObj = BeanUtils.toBean(updateReqVO, TenantAgencyPackageDO.class);
tenantAgencyPackageMapper.updateById(updateObj);
}
@Override
public void deleteTenantAgencyPackage(Long id) {
// 校验存在
validateTenantAgencyPackageExists(id);
// 删除
tenantAgencyPackageMapper.deleteById(id);
}
@Override
public void deleteTenantAgencyPackageListByIds(List<Long> ids) {
// 校验存在
validateTenantAgencyPackageExists(ids);
// 删除
tenantAgencyPackageMapper.deleteByIds(ids);
}
private void validateTenantAgencyPackageExists(List<Long> ids) {
List<TenantAgencyPackageDO> list = tenantAgencyPackageMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
throw exception(TENANT_AGENCY_PACKAGE_NOT_EXISTS);
}
}
private void validateTenantAgencyPackageExists(Long id) {
if (tenantAgencyPackageMapper.selectById(id) == null) {
throw exception(TENANT_AGENCY_PACKAGE_NOT_EXISTS);
}
}
@Override
public TenantAgencyPackageDO getTenantAgencyPackage(Long id) {
return tenantAgencyPackageMapper.selectById(id);
}
@Override
public PageResult<TenantAgencyPackageDO> getTenantAgencyPackagePage(TenantAgencyPackagePageReqVO pageReqVO) {
return tenantAgencyPackageMapper.selectPage(pageReqVO);
}
@Override
public TenantAgencyPackageDO validTenantPackage(Long packageId) {
TenantAgencyPackageDO tenantAgencyPackageDO = tenantAgencyPackageMapper.selectById(packageId);
if (tenantAgencyPackageDO == null) {
throw exception(TENANT_PACKAGE_NOT_EXISTS);
}
if (tenantAgencyPackageDO.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) {
throw exception(TENANT_PACKAGE_DISABLE, tenantAgencyPackageDO.getName());
}
return tenantAgencyPackageDO;
}
@Override
public List<TenantAgencyPackageDO> getTenantPackageListByStatus(Integer status) {
return tenantAgencyPackageMapper.selectListByStatus(status);
}
}

View File

@@ -0,0 +1,75 @@
package cn.iocoder.yudao.module.system.service.tenantbalance;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.system.controller.admin.tenantbalance.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantbalance.TenantBalanceDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
/**
* 租户余额 Service 接口
*
* @author 总后台
*/
public interface TenantBalanceService {
/**
* 创建租户余额
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createTenantBalance(@Valid TenantBalanceSaveReqVO createReqVO);
/**
* 更新租户余额
*
* @param updateReqVO 更新信息
*/
void updateTenantBalance(@Valid TenantBalanceSaveReqVO updateReqVO);
/**
* 删除租户余额
*
* @param id 编号
*/
void deleteTenantBalance(Long id);
/**
* 批量删除租户余额
*
* @param ids 编号
*/
void deleteTenantBalanceListByIds(List<Long> ids);
/**
* 获得租户余额
*
* @param id 编号
* @return 租户余额
*/
TenantBalanceDO getTenantBalance(Long id);
/**
* 获得租户余额分页
*
* @param pageReqVO 分页查询
* @return 租户余额分页
*/
PageResult<TenantBalanceRespVO> getTenantBalancePage(TenantBalancePageReqVO pageReqVO);
void addTenantBalance(@Valid TenantBalanceAddReqVO updateReqVO);
void transferToTenant(@Valid TenantBalanceTransferReqVO transferReqVO);
TenantBalanceDO getSelfBalance();
PageResult<TenantBalanceRespVO> getSelfSubordinateTenantBalancePage(@Valid TenantBalancePageReqVO pageReqVO);
Boolean consumption(Long PackageId, Long targetTenantId,String remark);
Boolean reduceTestAccountNum(Long currentTenantId, String remark);
Boolean addTestAccountNum(Long currentTenantId, String remark);
}

View File

@@ -0,0 +1,430 @@
package cn.iocoder.yudao.module.system.service.tenantbalance;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.system.controller.admin.tenantbalance.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantagencypackage.TenantAgencyPackageDO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantbalance.TenantBalanceDO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantpoints.TenantPointsDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.dal.mysql.tenant.TenantMapper;
import cn.iocoder.yudao.module.system.dal.mysql.tenantagencypackage.TenantAgencyPackageMapper;
import cn.iocoder.yudao.module.system.dal.mysql.tenantbalance.TenantBalanceMapper;
import cn.iocoder.yudao.module.system.dal.mysql.tenantpoints.TenantPointsMapper;
import cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum;
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import cn.iocoder.yudao.module.system.util.BizNoGenerator;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mzt.logapi.starter.annotation.LogRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.system.enums.balance.BalanceEnum.*;
/**
* 租户余额 Service 实现类
*
* @author 总后台
*/
@Service
@Validated
public class TenantBalanceServiceImpl implements TenantBalanceService {
@Resource
private TenantBalanceMapper tenantBalanceMapper;
@Resource
private TenantPointsMapper tenantPointsMapper;
@Resource
private AdminUserService userService;
@Resource
private TenantMapper tenantMapper;
@Resource
private TenantAgencyPackageMapper tenantAgencyPackageMapper;
@Override
public Long createTenantBalance(TenantBalanceSaveReqVO createReqVO) {
// 插入
TenantBalanceDO tenantBalance = BeanUtils.toBean(createReqVO, TenantBalanceDO.class);
tenantBalanceMapper.insert(tenantBalance);
// 返回
return tenantBalance.getId();
}
@Override
public void updateTenantBalance(TenantBalanceSaveReqVO updateReqVO) {
// 校验存在
validateTenantBalanceExists(updateReqVO.getId());
// 更新
TenantBalanceDO updateObj = BeanUtils.toBean(updateReqVO, TenantBalanceDO.class);
tenantBalanceMapper.updateById(updateObj);
}
@Override
public void deleteTenantBalance(Long id) {
// 校验存在
validateTenantBalanceExists(id);
// 删除
tenantBalanceMapper.deleteById(id);
}
@Override
public void deleteTenantBalanceListByIds(List<Long> ids) {
// 校验存在
validateTenantBalanceExists(ids);
// 删除
tenantBalanceMapper.deleteByIds(ids);
}
private void validateTenantBalanceExists(List<Long> ids) {
List<TenantBalanceDO> list = tenantBalanceMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
throw exception(TENANT_BALANCE_NOT_EXISTS);
}
}
private void validateTenantBalanceExists(Long id) {
if (tenantBalanceMapper.selectById(id) == null) {
throw exception(TENANT_BALANCE_NOT_EXISTS);
}
}
@Override
public TenantBalanceDO getTenantBalance(Long id) {
return tenantBalanceMapper.selectById(id);
}
@Override
public PageResult<TenantBalanceRespVO> getTenantBalancePage(TenantBalancePageReqVO pageReqVO) {
IPage<TenantBalanceRespVO> iPage = new Page<>(pageReqVO.getPageNo(),pageReqVO.getPageSize());
IPage<TenantBalanceRespVO> tenantBalanceRespVOIPage = tenantBalanceMapper.selectPageWithTenantName(iPage, pageReqVO);
return new PageResult<>(tenantBalanceRespVOIPage.getRecords(),tenantBalanceRespVOIPage.getTotal());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void addTenantBalance(TenantBalanceAddReqVO addReqVO) {
// 校验存在
if (tenantBalanceMapper.selectById(addReqVO.getId()) == null) {
// 初始化余额为 0
TenantBalanceDO tenantBalance = new TenantBalanceDO();
tenantBalance.setId(addReqVO.getId());
tenantBalance.setBalance(0);
tenantBalance.setVersion(0);
tenantBalanceMapper.insert(tenantBalance);
}
String recharge = BizNoGenerator.generate("RECHARGE");
// 获取初始化查询结果
TenantBalanceDO tenantBalance = tenantBalanceMapper.selectById(addReqVO.getId());
Integer newBalance = tenantBalance.getBalance()+addReqVO.getAmount();
Integer oldVersion = tenantBalance.getVersion();
Integer updateCount = tenantBalanceMapper.updateBalanceWithVersion(addReqVO.getId(), addReqVO.getAmount(), oldVersion);
if (updateCount == 0) {
throw exception(TENANT_BALANCE_RECHARGE_ERROR);
}
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
if (loginUser == null) {
throw exception(USER_NOT_EXISTS);
}
TenantPointsDO tenantPointsDO = new TenantPointsDO();
tenantPointsDO.setTenantId(addReqVO.getId());
tenantPointsDO.setPoints(addReqVO.getAmount());
tenantPointsDO.setBalance(newBalance);
tenantPointsDO.setOperatorId(loginUser.getId());
tenantPointsDO.setType(RECHARGE.getDesc()); // RECHARGE / BONUS / ...
tenantPointsDO.setDescription("总后台充值,金额:"+addReqVO.getAmount());
tenantPointsDO.setRemark(addReqVO.getRemark());
tenantPointsDO.setBizNo(recharge);
tenantPointsMapper.insert(tenantPointsDO);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void transferToTenant(TenantBalanceTransferReqVO transferReqVO) {
/**
* 执行租户余额转账操作
* 注:这部分代码应该位于某个转账相关的方法中
*/
// 获取当前登录用户ID用于操作记录和权限验证
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
// 生成转账业务流水号,用于唯一标识这笔转账交易
String transfer = BizNoGenerator.generate("TRANSFER");
// 验证转账密码是否为空
if (transferReqVO.getPassword().isEmpty()) {
throw exception(TENANT_BALANCE_TRANSFER_PASSWORD_ERROR_IS_NULL);
}
TenantDO targetTenantInfo = tenantMapper.selectById(transferReqVO.getTargetTenantId());
// 获取当前登录用户信息
AdminUserDO user = userService.getUser(loginUserId);
// 验证转账密码是否正确
if (!userService.isPasswordMatch(transferReqVO.getPassword(), user.getPassword())) {
throw exception(TENANT_BALANCE_TRANSFER_PASSWORD_ERROR);
}
// 获取当前租户ID转出方
Long tenantId = TenantContextHolder.getTenantId();
if (!Objects.equals(targetTenantInfo.getParentId(), tenantId)) {
throw exception(TENANT_BALANCE_TRANSFER_ERROR_TARGET_NOT_SUBORDINATE);
}
// 校验当前租户钱包是否存在
TenantBalanceDO tenantBalanceDO = tenantBalanceMapper.selectById(tenantId);
if (tenantBalanceDO == null) {
throw exception(TENANT_WALLET_NOT_EXISTS);
}
// 获取目标租户(转入方)的余额信息
TenantBalanceDO targetTenantBalance = tenantBalanceMapper.selectById(transferReqVO.getTargetTenantId());
// 校验目标租户钱包是否存在
if (targetTenantBalance == null) {
throw exception(TENANT_BALANCE_TRANSFER_TARGET_NOT_EXISTS);
}
// 校验当前租户余额是否足够支付转账金额
if (tenantBalanceDO.getBalance() < transferReqVO.getTransferAmount()) {
throw exception(TENANT_BALANCE_NOT_ENOUGH);
}
// 校验转账金额是否有效必须大于0
if (transferReqVO.getTransferAmount() <= 0) {
throw exception(TENANT_BALANCE_TRANSFER_ERROR);
}
// 计算转账后转出方的新余额
Integer tenantNewBalance = tenantBalanceDO.getBalance() - transferReqVO.getTransferAmount();
// 计算转账后转入方的新余额
Integer targetTenantNewBalance = targetTenantBalance.getBalance() + transferReqVO.getTransferAmount();
// 获取转出方当前的版本号(用于乐观锁控制)
Integer tenantBalanceDOVersion = tenantBalanceDO.getVersion();
// 获取转入方当前的版本号(用于乐观锁控制)
Integer targetTenantBalanceVersion = targetTenantBalance.getVersion();
// 先更新转入方的余额(使用乐观锁)
Integer updateTargetBalanceCount = tenantBalanceMapper
.updateBalanceWithVersion(transferReqVO.getTargetTenantId(), transferReqVO.getTransferAmount(), targetTenantBalanceVersion);
// 如果更新转入方失败,抛出异常
if (updateTargetBalanceCount == 0) {
throw exception(TENANT_BALANCE_TRANSFER_OPERATION_ERROR);
}
// 再更新转出方的余额(使用乐观锁,金额为负数表示减少)
Integer updateCount = tenantBalanceMapper
.updateBalanceWithVersion(tenantId, -transferReqVO.getTransferAmount(), tenantBalanceDOVersion);
// 如果更新转出方失败,抛出异常
if (updateCount == 0) {
throw exception(TENANT_BALANCE_TRANSFER_OPERATION_ERROR);
}
// 创建转出方的积分变动记录
TenantPointsDO tenantPointsDO = new TenantPointsDO();
tenantPointsDO.setTenantId(tenantId); // 设置租户ID
tenantPointsDO.setPoints(-transferReqVO.getTransferAmount()); // 设置变动积分(负数表示减少)
tenantPointsDO.setBalance(tenantNewBalance); // 设置变动后的余额
tenantPointsDO.setOperatorId(loginUserId); // 设置操作人ID
tenantPointsDO.setType(TRANSFER_OUT.getDesc()); // 设置交易类型为转账
tenantPointsDO.setDescription("转账给租户" + transferReqVO.getTargetTenantId() + ",金额:" + transferReqVO.getTransferAmount()); // 设置交易描述
tenantPointsDO.setTargetTenantId(transferReqVO.getTargetTenantId()); // 设置目标租户ID
tenantPointsDO.setBizNo(transfer); // 设置业务流水号
tenantPointsDO.setRemark(transferReqVO.getRemark());
int tenantInsert = tenantPointsMapper.insert(tenantPointsDO); // 插入记录
// 创建转入方的积分变动记录
TenantPointsDO targetPointsDO = new TenantPointsDO();
targetPointsDO.setTenantId(transferReqVO.getTargetTenantId()); // 设置目标租户ID
targetPointsDO.setPoints(transferReqVO.getTransferAmount()); // 设置变动积分(正数表示增加)
targetPointsDO.setBalance(targetTenantNewBalance); // 设置变动后的余额
targetPointsDO.setOperatorId(loginUserId); // 设置操作人ID
targetPointsDO.setType(TRANSFER_IN.getDesc()); // 设置交易类型为转账
targetPointsDO.setTargetTenantId(tenantId);// 设置目标租户ID
targetPointsDO.setDescription("转账来自租户" + tenantId + ",金额:" + transferReqVO.getTransferAmount()); // 设置交易描述
targetPointsDO.setBizNo(transfer); // 设置业务流水号(与转出方使用同一个流水号)
int targetInsert = tenantPointsMapper.insert(targetPointsDO); // 插入记录
// 验证交易记录是否都插入成功
if (tenantInsert == 0 || targetInsert == 0) {
throw exception(TENANT_BALANCE_TRANSFER_OPERATION_ERROR);
}
}
@Override
public TenantBalanceDO getSelfBalance() {
Long tenantId = TenantContextHolder.getTenantId();
TenantBalanceDO tenantBalance = tenantBalanceMapper.selectById(tenantId);
if (tenantBalance == null) {
throw exception(TENANT_WALLET_NOT_EXISTS);
}
return tenantBalance;
}
@Override
public PageResult<TenantBalanceRespVO> getSelfSubordinateTenantBalancePage(TenantBalancePageReqVO pageReqVO) {
Long tenantId = TenantContextHolder.getTenantId();
IPage<TenantBalanceRespVO> iPage = new Page<>(pageReqVO.getPageNo(),pageReqVO.getPageSize());
IPage<TenantBalanceRespVO> tenantBalanceRespVOIPage = tenantBalanceMapper.selectPageWithSelfSubordinateTenant(iPage, pageReqVO,tenantId);
return new PageResult<>(tenantBalanceRespVOIPage.getRecords(),tenantBalanceRespVOIPage.getTotal());
}
@Override
public Boolean consumption(Long PackageId, Long targetTenantId,String remark) {
Long tenantId = TenantContextHolder.getTenantId();
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
String consumption = BizNoGenerator.generate("CONSUMPTION");
String order = BizNoGenerator.generate("ORDER");
// 从数据库中查询租户余额
TenantBalanceDO tenantBalance = tenantBalanceMapper.selectById(tenantId);
if (tenantBalance == null) {
throw exception(TENANT_WALLET_NOT_EXISTS);
}
// 从数据库中查询套餐信息
TenantAgencyPackageDO tenantAgencyPackageDO = tenantAgencyPackageMapper.selectById(PackageId);
if (tenantAgencyPackageDO == null) {
throw exception(TENANT_AGENCY_PACKAGE_NOT_EXISTS);
}
// 检查租户余额是否足够
if (tenantBalance.getBalance() < tenantAgencyPackageDO.getPrice()) {
throw exception(TENANT_BALANCE_BALANCE_NOT_ENOUGH);
}
Integer tenantBalanceDOVersion = tenantBalance.getVersion();
Integer oldBalance = tenantBalance.getBalance();
Integer newBalance = oldBalance - tenantAgencyPackageDO.getPrice();
// 更新租户余额
Integer updateCount = tenantBalanceMapper.updateBalanceWithVersion(tenantId, -tenantAgencyPackageDO.getPrice(), tenantBalanceDOVersion);
if (updateCount == 0) {
throw exception(TENANT_BALANCE_CONSUMPTION_OPERATION_ERROR);
}
// 消费积分变动记录
TenantPointsDO tenantPointsDO = new TenantPointsDO();
tenantPointsDO.setTenantId(tenantId); // 设置租户ID
tenantPointsDO.setPoints(-tenantAgencyPackageDO.getPrice()); // 设置变动积分(负数表示减少)
tenantPointsDO.setBalance(newBalance); // 设置变动后的余额
tenantPointsDO.setOperatorId(loginUserId); // 设置操作人ID
tenantPointsDO.setType(CONSUMPTION.getDesc()); // 设置交易类型为转账
tenantPointsDO.setDescription("给租户" + targetTenantId + "开通套餐" + tenantAgencyPackageDO.getName() + ",金额:" + tenantAgencyPackageDO.getPrice()); // 设置交易描述
tenantPointsDO.setTargetTenantId(targetTenantId); // 设置目标租户ID
tenantPointsDO.setBizNo(consumption); // 设置业务流水号
tenantPointsDO.setRemark(remark);
tenantPointsDO.setOrderId(order);
int tenantInsert = tenantPointsMapper.insert(tenantPointsDO); // 插入记录
if (tenantInsert == 0) {
throw exception(TENANT_BALANCE_CONSUMPTION_OPERATION_ERROR);
}
return true;
}
@Override
public Boolean reduceTestAccountNum(Long currentTenantId,String remark) {
TenantBalanceDO tenantBalanceDO = tenantBalanceMapper.selectById(currentTenantId);
if (tenantBalanceDO.getTestAccountNum()<=0) {
throw exception(TENANT_BALANCE_TEST_ACCOUNT_NUM_NOT_ENOUGH);
}
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
Integer oldVersion = tenantBalanceDO.getVersion();
Integer newTestAccountNum = tenantBalanceDO.getTestAccountNum() - 1;
Integer i = tenantBalanceMapper.updateTestAccountNumWithVersion(currentTenantId, -1, oldVersion);
if (i == 0) {
throw exception(TENANT_BALANCE_TEST_ACCOUNT_NUM_OPERATION_ERROR);
}
String consumption = BizNoGenerator.generate("CONSUMPTION");
// 消费积分变动记录
TenantPointsDO tenantPointsDO = new TenantPointsDO();
tenantPointsDO.setTenantId(currentTenantId); // 设置租户ID
tenantPointsDO.setPoints(-1); // 设置变动积分(负数表示减少)
tenantPointsDO.setBalance(tenantPointsDO.getBalance());
tenantPointsDO.setTestAccountNum(newTestAccountNum); // 设置变动后的余额
tenantPointsDO.setOperatorId(loginUserId); // 设置操作人ID
tenantPointsDO.setType(CONSUMPTION.getDesc()); // 设置交易类型为转账
tenantPointsDO.setDescription("开通测试账户"); // 设置交易描述
tenantPointsDO.setRemark(remark);
tenantPointsDO.setBizNo(consumption); // 设置业务流水号
int tenantInsert = tenantPointsMapper.insert(tenantPointsDO); // 插入记录
if (tenantInsert == 0) {
throw exception(TENANT_BALANCE_CONSUMPTION_OPERATION_ERROR);
}
return true;
}
@Override
public Boolean addTestAccountNum(Long currentTenantId,String remark) {
TenantBalanceDO tenantBalanceDO = tenantBalanceMapper.selectById(currentTenantId);
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
Integer oldVersion = tenantBalanceDO.getVersion();
Integer newTestAccountNum = tenantBalanceDO.getTestAccountNum() + 5;
Integer i = tenantBalanceMapper.updateTestAccountNumWithVersion(currentTenantId, 5, oldVersion);
if (i == 0) {
throw exception(TENANT_BALANCE_TEST_ACCOUNT_NUM_OPERATION_ERROR);
}
String bonus = BizNoGenerator.generate("BONUS");
// 消费积分变动记录
TenantPointsDO tenantPointsDO = new TenantPointsDO();
tenantPointsDO.setTenantId(currentTenantId); // 设置租户ID
tenantPointsDO.setPoints(5); // 设置变动积分(负数表示减少)
tenantPointsDO.setTestAccountNum(newTestAccountNum); // 设置变动后的余额
tenantPointsDO.setBalance(tenantPointsDO.getBalance());
tenantPointsDO.setOperatorId(loginUserId); // 设置操作人ID
tenantPointsDO.setType(BONUS.getDesc()); // 设置交易类型为转账
tenantPointsDO.setDescription("开通测试账户,增加测试账号数量"); // 设置交易描述
tenantPointsDO.setBizNo(bonus); // 设置业务流水号
tenantPointsDO.setRemark(remark);
int tenantInsert = tenantPointsMapper.insert(tenantPointsDO); // 插入记录
if (tenantInsert == 0) {
throw exception(TENANT_BALANCE_CONSUMPTION_OPERATION_ERROR);
}
return true;
}
}

View File

@@ -0,0 +1,63 @@
package cn.iocoder.yudao.module.system.service.tenantpoints;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantpoints.TenantPointsDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
/**
* 租户积分记录 Service 接口
*
* @author 总后台
*/
public interface TenantPointsService {
/**
* 创建租户积分记录
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createTenantPoints(@Valid TenantPointsSaveReqVO createReqVO);
/**
* 更新租户积分记录
*
* @param updateReqVO 更新信息
*/
void updateTenantPoints(@Valid TenantPointsSaveReqVO updateReqVO);
/**
* 删除租户积分记录
*
* @param id 编号
*/
void deleteTenantPoints(Long id);
/**
* 批量删除租户积分记录
*
* @param ids 编号
*/
void deleteTenantPointsListByIds(List<Long> ids);
/**
* 获得租户积分记录
*
* @param id 编号
* @return 租户积分记录
*/
TenantPointsDO getTenantPoints(Long id);
/**
* 获得租户积分记录分页
*
* @param pageReqVO 分页查询
* @return 租户积分记录分页
*/
PageResult<TenantPointsPageRespVO> getTenantPointsPage(TenantPointsPageReqVO pageReqVO);
PageResult<TenantPointsDO> getTenantTransactionHistoryPointsPage(PageParam pageReqVO, Long tenantId);
}

View File

@@ -0,0 +1,109 @@
package cn.iocoder.yudao.module.system.service.tenantpoints;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantpoints.TenantPointsDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.dal.mysql.tenantpoints.TenantPointsMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
/**
* 租户积分记录 Service 实现类
*
* @author 总后台
*/
@Service
@Validated
public class TenantPointsServiceImpl implements TenantPointsService {
@Resource
private TenantPointsMapper tenantPointsMapper;
@Override
public Long createTenantPoints(TenantPointsSaveReqVO createReqVO) {
// 插入
TenantPointsDO tenantPoints = BeanUtils.toBean(createReqVO, TenantPointsDO.class);
tenantPointsMapper.insert(tenantPoints);
// 返回
return tenantPoints.getId();
}
@Override
public void updateTenantPoints(TenantPointsSaveReqVO updateReqVO) {
// 校验存在
validateTenantPointsExists(updateReqVO.getId());
// 更新
TenantPointsDO updateObj = BeanUtils.toBean(updateReqVO, TenantPointsDO.class);
tenantPointsMapper.updateById(updateObj);
}
@Override
public void deleteTenantPoints(Long id) {
// 校验存在
validateTenantPointsExists(id);
// 删除
tenantPointsMapper.deleteById(id);
}
@Override
public void deleteTenantPointsListByIds(List<Long> ids) {
// 校验存在
validateTenantPointsExists(ids);
// 删除
tenantPointsMapper.deleteByIds(ids);
}
private void validateTenantPointsExists(List<Long> ids) {
List<TenantPointsDO> list = tenantPointsMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
throw exception(TENANT_POINTS_NOT_EXISTS);
}
}
private void validateTenantPointsExists(Long id) {
if (tenantPointsMapper.selectById(id) == null) {
throw exception(TENANT_POINTS_NOT_EXISTS);
}
}
@Override
public TenantPointsDO getTenantPoints(Long id) {
return tenantPointsMapper.selectById(id);
}
@Override
public PageResult<TenantPointsPageRespVO> getTenantPointsPage(TenantPointsPageReqVO pageReqVO) {
Long tenantId = TenantContextHolder.getTenantId();
if (tenantId == 1) {
IPage<TenantPointsPageRespVO> iPage = new Page<>(pageReqVO.getPageNo(),pageReqVO.getPageSize());
IPage<TenantPointsPageRespVO> tenantPointsPageRespVOIPage = tenantPointsMapper.selectPageWithXML(iPage, pageReqVO);
return new PageResult<>(tenantPointsPageRespVOIPage.getRecords(),tenantPointsPageRespVOIPage.getTotal());
}
IPage<TenantPointsPageRespVO> iPage = new Page<>(pageReqVO.getPageNo(),pageReqVO.getPageSize());
IPage<TenantPointsPageRespVO> tenantPointsPageRespVOIPage = tenantPointsMapper.selectPageWithTenantIdXML(iPage,pageReqVO,tenantId);
return new PageResult<>(tenantPointsPageRespVOIPage.getRecords(),tenantPointsPageRespVOIPage.getTotal());
}
@Override
public PageResult<TenantPointsDO> getTenantTransactionHistoryPointsPage(PageParam pageReqVO, Long tenantId) {
return tenantPointsMapper.TenantTransactionHistoryPointsPage(pageReqVO,tenantId);
}
}

View File

@@ -209,4 +209,6 @@ public interface AdminUserService {
List<UserRespVO> getTenantUserById(Long tenantId);
void updateUserWithClientRole(@Valid UserClientSaveReqVO reqVO);
AdminUserDO getUserByTenantIdAndUserName(Long targetTenantId, String initialUser);
}

View File

@@ -13,6 +13,7 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
import cn.iocoder.yudao.framework.datapermission.core.util.DataPermissionUtils;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.infra.api.config.ConfigApi;
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthRegisterReqVO;
import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO;
@@ -552,6 +553,11 @@ public class AdminUserServiceImpl implements AdminUserService {
userMapper.updateById(updateObj);
}
@Override
public AdminUserDO getUserByTenantIdAndUserName(Long targetTenantId, String initialUser) {
return userMapper.selectByUsernameAndTenantIdWithAgencyRenewal(initialUser,targetTenantId);
}
private AdminUserDO validateUserForCreateOrUpdate(Long id, String username,Long tenantId) {
return DataPermissionUtils.executeIgnore(() -> {

View File

@@ -0,0 +1,9 @@
package cn.iocoder.yudao.module.system.util;
import cn.hutool.core.util.IdUtil;
public class BizNoGenerator {
public static String generate(String prefix) {
return prefix + "-" + IdUtil.getSnowflakeNextIdStr();
}
}

View File

@@ -16,4 +16,67 @@
select * from system_users where tenant_id=#{tenantId,jdbcType=BIGINT}
</select>
<select id="selectByUsernameAndTenantIdWithAgencyRenewal"
resultType="cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO">
select * from system_users
where username=#{initialUser,jdbcType=VARCHAR} and tenant_id=#{targetTenantId,jdbcType=BIGINT}
</select>
<update id="updateByIdWithRenwal">
update system_users set
<if test="username != null">
username = #{username,jdbcType=VARCHAR},
</if>
<if test="password != null">
password = #{password,jdbcType=VARCHAR},
</if>
<if test="nickname != null">
nickname = #{nickname,jdbcType=VARCHAR},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="deptId != null">
dept_id = #{deptId,jdbcType=BIGINT},
</if>
<if test="postIds != null">
post_ids = #{postIds,jdbcType=VARCHAR,typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler},
</if>
<if test="email != null">
email = #{email,jdbcType=VARCHAR},
</if>
<if test="mobile != null">
mobile = #{mobile,jdbcType=VARCHAR},
</if>
<if test="sex != null">
sex = #{sex,jdbcType=INTEGER},
</if>
<if test="avatar != null">
avatar = #{avatar,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="loginIp != null">
login_ip = #{loginIp,jdbcType=VARCHAR},
</if>
<if test="loginDate != null">
login_date = #{loginDate,jdbcType=TIMESTAMP},
</if>
<if test="crawl != null">
crawl = #{crawl,jdbcType=TINYINT},
</if>
<if test="bigBrother != null">
big_brother = #{bigBrother,jdbcType=TINYINT},
</if>
<if test="aiChat != null">
ai_chat = #{aiChat,jdbcType=TINYINT},
</if>
<if test="aiReplay != null">
ai_replay = #{aiReplay,jdbcType=TINYINT},
</if>
update_time = NOW()
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.tenantagencypackage.TenantAgencyPackageMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<resultMap id="TenantAgencyPackageResultMap" type="cn.iocoder.yudao.module.system.dal.dataobject.tenantagencypackage.TenantAgencyPackageDO">
<id property="id" column="id" />
<result property="name" column="name" />
<result property="price" column="price" />
<result property="status" column="status" />
<result property="remark" column="remark" />
<result property="menuIds" column="menu_ids" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" />
<result property="createTime" column="create_time" />
</resultMap>
<select id="selectWithXml"
resultMap="TenantAgencyPackageResultMap">
select * from system_tenant_agency_package where id = #{id}
</select>
</mapper>

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.tenantbalance.TenantBalanceMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="selectPageWithTenantName"
resultType="cn.iocoder.yudao.module.system.controller.admin.tenantbalance.vo.TenantBalanceRespVO">
select stb.*, st.name as tenantName from system_tenant_balance as stb
left join system_tenant as st on stb.id = st.id
<where>
<if test="req.id != null">
and stb.id = #{req.id,jdbcType=BIGINT}
</if>
</where>
order by stb.id desc
</select>
<select id="selectPageWithSelfSubordinateTenant"
resultType="cn.iocoder.yudao.module.system.controller.admin.tenantbalance.vo.TenantBalanceRespVO">
select stb.*, st.name as tenantName from system_tenant_balance as stb
left join system_tenant as st on stb.id = st.id
<where>
and st.parent_Id = #{tenantId,jdbcType=BIGINT}
and st.tenant_type = '代理'
<if test="pageReqVO.id != null">
and stb.id = #{pageReqVO.id,jdbcType=BIGINT}
</if>
</where>
order by stb.id desc
</select>
</mapper>

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.tenantpoints.TenantPointsMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="selectPageWithXML"
resultType="cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo.TenantPointsPageRespVO">
select stp.*,st.name as tenantName
from system_tenant_points stp
left join system_tenant st
on st.id = stp.tenant_id
<where>
<if test="pageReqVO.bizNo != null">
and stp.biz_no = #{pageReqVO.bizNo}
</if>
<if test="pageReqVO.remark != null">
and stp.remark like concat('%', #{pageReqVO.remark}, '%')
</if>
<if test="pageReqVO.orderId != null">
and stp.operator_id = #{pageReqVO.orderId}
</if>
<if test="pageReqVO.targetTenantId != null">
and stp.target_tenant_id = #{pageReqVO.targetTenantId}
</if>
<if test="pageReqVO.operatorId != null">
and stp.operator_id = #{pageReqVO.operatorId}
</if>
<if test="pageReqVO.type != null">
and stp.type = #{pageReqVO.type}
</if>
<if test="pageReqVO.createdAt != null and pageReqVO.createdAt.length == 2">
and stp.created_at between #{pageReqVO.createdAt[0]} and #{pageReqVO.createdAt[1]}
</if>
</where>
order by stp.created_at desc
</select>
<select id="selectPageWithTenantIdXML"
resultType="cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo.TenantPointsPageRespVO">
select stp.*,st.name as tenantName
from system_tenant_points stp
left join system_tenant st
on st.id = stp.tenant_id
<where>
stp.tenant_id = #{tenantId}
<if test="pageReqVO.bizNo != null">
and stp.biz_no = #{pageReqVO.bizNo}
</if>
<if test="pageReqVO.remark != null">
and stp.remark like concat('%', #{pageReqVO.remark}, '%')
</if>
<if test="pageReqVO.orderId != null">
and stp.operator_id = #{pageReqVO.orderId}
</if>
<if test="pageReqVO.targetTenantId != null">
and stp.target_tenant_id = #{pageReqVO.targetTenantId}
</if>
<if test="pageReqVO.operatorId != null">
and stp.operator_id = #{pageReqVO.operatorId}
</if>
<if test="pageReqVO.type != null">
and stp.type = #{pageReqVO.type}
</if>
<if test="pageReqVO.createdAt != null">
and stp.created_at between #{pageReqVO.createdAt[0]} and #{pageReqVO.createdAt[1]}
</if>
</where>
order by stp.created_at desc
</select>
</mapper>

View File

@@ -7,6 +7,9 @@ spring:
autoconfigure:
exclude:
- com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 禁用 AI 模块的 Milvus手动创建
- de.codecentric.boot.admin.server.config.AdminServerAutoConfiguration # 禁用 Spring Boot Admin 的 Server 的自动配置
- de.codecentric.boot.admin.server.ui.config.AdminServerUiAutoConfiguration # 禁用 Spring Boot Admin 的 Server UI 的自动配置
- de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置
# 数据源配置项
datasource:

View File

@@ -12,7 +12,7 @@ spring:
- de.codecentric.boot.admin.server.ui.config.AdminServerUiAutoConfiguration # 禁用 Spring Boot Admin 的 Server UI 的自动配置
- de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置
- org.springframework.ai.autoconfigure.vectorstore.qdrant.QdrantVectorStoreAutoConfiguration # 禁用 AI 模块的 Qdrant手动创建
- org.springframework.ai.autoconfigure.vectorstore.milvus.MilvusVectorStoreAutoConfiguration # 禁用 AI 模块的 Milvus手动创建
- org.springframework.ai.autoconfigure.vectorstore.milvus.MilvusVectorStoreAutoConfiguration # 禁用 AI 模tenant-agency-package/get-simple-list块的 Milvus手动创建
# 数据源配置项
datasource:
druid: # Druid 【监控】相关的全局配置
@@ -181,6 +181,7 @@ logging:
cn.iocoder.yudao.module.iot.dal.mysql: debug
cn.iocoder.yudao.module.iot.dal.tdengine: DEBUG
cn.iocoder.yudao.module.ai.dal.mysql: debug
cn.iocoder.yudao.module.tkdata.dal.mysql: debug
org.springframework.context.support.PostProcessorRegistrationDelegate: ERROR # TODO 芋艿先禁用Spring Boot 3.X 存在部分错误的 WARN 提示
debug: false

View File

@@ -0,0 +1,216 @@
server:
port: 48080
--- #################### 数据库相关配置 ####################
spring:
autoconfigure:
# noinspection SpringBootApplicationYaml
exclude:
- com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源
# - org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration # 默认 local 环境,不开启 Quartz 的自动配置
- de.codecentric.boot.admin.server.config.AdminServerAutoConfiguration # 禁用 Spring Boot Admin 的 Server 的自动配置
- de.codecentric.boot.admin.server.ui.config.AdminServerUiAutoConfiguration # 禁用 Spring Boot Admin 的 Server UI 的自动配置
- de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置
- org.springframework.ai.autoconfigure.vectorstore.qdrant.QdrantVectorStoreAutoConfiguration # 禁用 AI 模块的 Qdrant手动创建
- org.springframework.ai.autoconfigure.vectorstore.milvus.MilvusVectorStoreAutoConfiguration # 禁用 AI 模块的 Milvus手动创建
# 数据源配置项
datasource:
druid: # Druid 【监控】相关的全局配置
web-stat-filter:
enabled: true
stat-view-servlet:
enabled: true
allow: # 设置白名单,不填则允许所有访问
url-pattern: /druid/*
login-username: # 控制台管理用户名和密码
login-password:
filter:
stat:
enabled: true
log-slow-sql: true # 慢 SQL 记录
slow-sql-millis: 100
merge-sql: true
wall:
config:
multi-statement-allow: true
dynamic: # 多数据源配置
druid: # Druid 【连接池】相关的全局配置
initial-size: 1 # 初始连接数
min-idle: 1 # 最小连接池数量
max-active: 20 # 最大连接池数量
max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒
time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒
min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒
max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒
validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效
test-while-idle: true
test-on-borrow: false
test-on-return: false
primary: master
datasource:
master:
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true&allowMultiQueries=true # MySQL Connector/J 8.X 连接的示例
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true # MySQL Connector/J 5.X 连接的示例
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true;useUnicode=true;characterEncoding=utf-8 # SQLServer 连接的示例
# url: jdbc:dm://127.0.0.1:5236?schema=RUOYI_VUE_PRO # DM 连接的示例
# url: jdbc:kingbase8://127.0.0.1:54321/test # 人大金仓 KingbaseES 连接的示例
# url: jdbc:postgresql://127.0.0.1:5432/postgres # OpenGauss 连接的示例
username: ruoyi-vue-pro
password: ki7kbrP3TXADPddS
# username: sa # SQL Server 连接的示例
# password: Yudao@2024 # SQL Server 连接的示例
# username: SYSDBA # DM 连接的示例
# password: SYSDBA001 # DM 连接的示例
# username: root # OpenGauss 连接的示例
# password: Yudao@2024 # OpenGauss 连接的示例
# slave: # 模拟从库,可根据自己需要修改
# lazy: true # 开启懒加载,保证启动速度
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&nullCatalogMeansCurrent=true
# username: root
# password: 123456
# tdengine: # IoT 数据库(需要 IoT 物联网再开启噢!)
# url: jdbc:TAOS-RS://127.0.0.1:6041/ruoyi_vue_pro
# driver-class-name: com.taosdata.jdbc.rs.RestfulDriver
# username: root
# password: taosdata
# druid:
# validation-query: SELECT SERVER_STATUS() # TDengine 数据源的有效性检查 SQL
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
redis:
host: 127.0.0.1 # 地址
port: 6379 # 端口
database: 0 # 数据库索引
# password: dev # 密码,建议生产环境开启
--- #################### 定时任务相关配置 ####################
# Quartz 配置项,对应 QuartzProperties 配置类
spring:
quartz:
auto-startup: true # 本地开发环境,尽量不要开启 Job
scheduler-name: schedulerName # Scheduler 名字。默认为 schedulerName
job-store-type: jdbc # Job 存储器类型。默认为 memory 表示内存,可选 jdbc 使用数据库。
wait-for-jobs-to-complete-on-shutdown: true # 应用关闭时,是否等待定时任务执行完成。默认为 false ,建议设置为 true
properties: # 添加 Quartz Scheduler 附加属性,更多可以看 http://www.quartz-scheduler.org/documentation/2.4.0-SNAPSHOT/configuration.html 文档
org:
quartz:
# Scheduler 相关配置
scheduler:
instanceName: schedulerName
instanceId: AUTO # 自动生成 instance ID
# JobStore 相关配置
jobStore:
# JobStore 实现类。可见博客https://blog.csdn.net/weixin_42458219/article/details/122247162
class: org.springframework.scheduling.quartz.LocalDataSourceJobStore
isClustered: true # 是集群模式
clusterCheckinInterval: 15000 # 集群检查频率,单位:毫秒。默认为 15000即 15 秒
misfireThreshold: 60000 # misfire 阀值,单位:毫秒。
# 线程池相关配置
threadPool:
threadCount: 25 # 线程池大小。默认为 10 。
threadPriority: 5 # 线程优先级
class: org.quartz.simpl.SimpleThreadPool # 线程池类型
jdbc: # 使用 JDBC 的 JobStore 的时候JDBC 的配置
initialize-schema: NEVER # 是否自动使用 SQL 初始化 Quartz 表结构。这里设置成 never ,我们手动创建表结构。
--- #################### 消息队列相关 ####################
spring:
# RabbitMQ 配置项,对应 RabbitProperties 配置类
rabbitmq:
host: 127.0.0.1 # RabbitMQ 服务的地址
port: 5672 # RabbitMQ 服务的端口
username: guest # RabbitMQ 服务的账号
password: guest # RabbitMQ 服务的密码
--- #################### 服务保障相关配置 ####################
# Lock4j 配置项
lock4j:
acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒
expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒
--- #################### 监控相关配置 ####################
# Actuator 监控端点的配置项
management:
endpoints:
web:
base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator
exposure:
include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
# Spring Boot Admin 配置项
spring:
boot:
admin:
# Spring Boot Admin Client 客户端的相关配置
client:
url: http://127.0.0.1:${server.port}/${spring.boot.admin.context-path} # 设置 Spring Boot Admin Server 地址
instance:
service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME]
# Spring Boot Admin Server 服务端的相关配置
context-path: /admin # 配置 Spring
# 日志文件配置
logging:
file:
name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径
level:
# 配置自己写的 MyBatis Mapper 打印日志
cn.iocoder.yudao.module.bpm.dal.mysql: debug
cn.iocoder.yudao.module.infra.dal.mysql: debug
cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiErrorLogMapper: INFO # 配置 ApiErrorLogMapper 的日志级别为 info避免和 GlobalExceptionHandler 重复打印
cn.iocoder.yudao.module.infra.dal.mysql.job.JobLogMapper: INFO # 配置 JobLogMapper 的日志级别为 info
cn.iocoder.yudao.module.infra.dal.mysql.file.FileConfigMapper: INFO # 配置 FileConfigMapper 的日志级别为 info
cn.iocoder.yudao.module.pay.dal.mysql: debug
cn.iocoder.yudao.module.pay.dal.mysql.notify.PayNotifyTaskMapper: INFO # 配置 PayNotifyTaskMapper 的日志级别为 info
cn.iocoder.yudao.module.system.dal.mysql: debug
cn.iocoder.yudao.module.system.dal.mysql.sms.SmsChannelMapper: INFO # 配置 SmsChannelMapper 的日志级别为 info
cn.iocoder.yudao.module.tool.dal.mysql: debug
cn.iocoder.yudao.module.member.dal.mysql: debug
cn.iocoder.yudao.module.trade.dal.mysql: debug
cn.iocoder.yudao.module.promotion.dal.mysql: debug
cn.iocoder.yudao.module.statistics.dal.mysql: debug
cn.iocoder.yudao.module.crm.dal.mysql: debug
cn.iocoder.yudao.module.erp.dal.mysql: debug
cn.iocoder.yudao.module.iot.dal.mysql: debug
cn.iocoder.yudao.module.iot.dal.tdengine: DEBUG
cn.iocoder.yudao.module.ai.dal.mysql: debug
cn.iocoder.yudao.module.tkdata.dal.mysql: debug
org.springframework.context.support.PostProcessorRegistrationDelegate: ERROR # TODO 芋艿先禁用Spring Boot 3.X 存在部分错误的 WARN 提示
debug: false
--- #################### 芋道相关配置 ####################
# 芋道配置项,设置当前项目所有自定义的配置
yudao:
captcha:
enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试;
security:
mock-enable: true
pay:
order-notify-url: https://yutou.mynatapp.cc/admin-api/pay/notify/order # 支付渠道的【支付】回调地址
refund-notify-url: https://yutou.mynatapp.cc/admin-api/pay/notify/refund # 支付渠道的【退款】回调地址
transfer-notify-url: https://yutou.mynatapp.cc/admin-api/pay/notify/transfer # 支付渠道的【转账】回调地址
access-log: # 访问日志的配置项
enable: false
demo: false # 关闭演示模式
wxa-code:
env-version: develop # 小程序版本: 正式版为 "release";体验版为 "trial";开发版为 "develop"
wxa-subscribe-message:
miniprogram-state: developer # 跳转小程序类型:开发版为 “developer”体验版为 “trial”为正式版为 “formal”
tencent-lbs-key: TVDBZ-TDILD-4ON4B-PFDZA-RNLKH-VVF6E # QQ 地图的密钥 https://lbs.qq.com/service/staticV2/staticGuide/staticDoc
--- #################### iot相关配置 TODO 芋艿【IOT】再瞅瞅 ####################
pf4j:
# pluginsDir: /tmp/
pluginsDir: ../plugins

View File

@@ -193,6 +193,9 @@ yudao:
- server_country_info
- ai_comment
- ai_language
- system_tenant_balance
- system_tenant_points
- system_tenant_agency_package
ignore-caches:
- user_role_ids
- permission_menu_ids