添加注册功能、登录添加订阅信息验证

master
hshansha 7 months ago
parent 97205d72f8
commit 6da164ea39

@ -8,8 +8,10 @@ import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginBody;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.domain.model.SmsLoginBody;
import com.ruoyi.common.core.service.DictService;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.pay.domain.bo.PaySubInfoBo;
import com.ruoyi.pay.domain.vo.PaySubInfoVo;
import com.ruoyi.pay.service.IPaySubInfoService;
import com.ruoyi.system.domain.vo.RouterVo;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.ISysMenuService;
@ -40,8 +42,7 @@ public class SysLoginController {
private final ISysMenuService menuService;
private final ISysUserService userService;
private final SysUserMapper userMapper;
private final DictService dictService;
// private final IAsSubscriptionInfoService iAsSubscriptionInfoService;
private final IPaySubInfoService iPaySubInfoService;
/**
*
*
@ -82,13 +83,13 @@ public class SysLoginController {
//除管理员用户外,所有用户根据用户公司拿到到期时间 未到期允许登录 否则不允许登录
String companyName = LoginHelper.getCompanyName();
Long tenantId = LoginHelper.getTenantId();
/*if(companyName!=null&&companyName!=""){
if(companyName!=null&&companyName!=""){
//查询订阅信息中的结束时间
AsSubscriptionInfoBo bo = new AsSubscriptionInfoBo();
PaySubInfoBo bo = new PaySubInfoBo();
bo.setTenantId(tenantId);
List<AsSubscriptionInfoVo> asSubscriptionInfoVos = iAsSubscriptionInfoService.queryList(bo);
if(asSubscriptionInfoVos!=null&&asSubscriptionInfoVos.size()>0){
AsSubscriptionInfoVo subscriptionInfo = asSubscriptionInfoVos.get(0);
List<PaySubInfoVo> subscriptionInfoVos = iPaySubInfoService.queryList(bo);
if(subscriptionInfoVos!=null&&subscriptionInfoVos.size()>0){
PaySubInfoVo subscriptionInfo = subscriptionInfoVos.get(0);
//截止日期不为空并且激活状态为已激活默认0已激活
if(subscriptionInfo.getEndTime()!=null&&subscriptionInfo.getActive().equals("0")){
Date endTime= subscriptionInfo.getEndTime();
@ -108,7 +109,7 @@ public class SysLoginController {
}else{
return R.fail("公司没有订阅信息,请联系管理员或开发人员!");
}
}*/
}
ajax.put(Constants.TOKEN, token);
return R.ok(ajax);
}

@ -5,11 +5,21 @@ import cn.dev33.satoken.secure.BCrypt;
import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.RegisterBody;
import com.ruoyi.common.core.service.DictService;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.pay.domain.bo.PaySubInfoBo;
import com.ruoyi.pay.domain.bo.PaySubPlanBo;
import com.ruoyi.pay.domain.bo.PayTenantBo;
import com.ruoyi.pay.domain.vo.PaySubPlanVo;
import com.ruoyi.pay.domain.vo.PayTenantVo;
import com.ruoyi.pay.service.IPaySubInfoService;
import com.ruoyi.pay.service.IPaySubPlanService;
import com.ruoyi.pay.service.IPayTenantService;
import com.ruoyi.system.service.*;
import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;
@ -18,6 +28,11 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
*
*
@ -33,6 +48,9 @@ public class SysRegisterController extends BaseController {
private final ISysRoleService roleService;
private final ISysUserService userService;
private final SysLoginService loginService;
private final IPaySubInfoService iPaySubInfoService;
private final IPaySubPlanService iPaySubPlanService;
private final IPayTenantService iPayTenantService;
private final DictService dictService;
/**
@ -51,27 +69,25 @@ public class SysRegisterController extends BaseController {
/**
*
*/
/* @SaIgnore
@SaIgnore
@PostMapping("/registerGs")
public R<Map<String ,Object>> register1(@Validated(AddGroup.class) @RequestBody AsCompanyBo bo) {
public R<SysRole> register1(@Validated(AddGroup.class) @RequestBody PayTenantBo bo) {
//添加验证 手机号相同或者公司名相同不允许注册
AsCompanyBo queryBo = new AsCompanyBo();
PayTenantBo queryBo = new PayTenantBo();
queryBo.setPhone(bo.getPhone());
List<AsCompanyVo> asCompanyVos = iAsCompanyService.queryList(queryBo);
List<PayTenantVo> asCompanyVos = iPayTenantService.queryList(queryBo);
if(asCompanyVos!=null&&asCompanyVos.size()>0){
return new R().fail("手机号已注册");
}
queryBo.setName(bo.getName());
queryBo.setPhone(null);
List<AsCompanyVo> asCompanyVos2 = iAsCompanyService.queryList(queryBo);
List<PayTenantVo> asCompanyVos2 = iPayTenantService.queryList(queryBo);
if(asCompanyVos2!=null&&asCompanyVos2.size()>0){
return new R().fail("公司名已注册");
}
if(iAsCompanyService.insertByBo(bo)){
//公司注册成功后自动添加3个角色管理员、客户、运维
Long[] adids={1655371202140614657L, 1642699828651147266L, 1642699828651147267L, 1642699828651147268L, 1642699828651147269L, 1642699828651147270L, 1642699828651147271L, 1702576150650126337L, 1642699829787803649L, 1642699829787803650L, 1642699829787803651L, 1642699829787803652L, 1642699829787803653L, 1642699829787803654L, 1702576351469207553L, 1642699830664413186L, 1642699830664413187L, 1642699830664413188L, 1642699830664413189L, 1642699830664413190L, 1655482882922754049L, 1655840316736458753L, 1655448497192230913L, 1654661619136454657L, 1655842888306184194L, 1654661698882756610L, 1654661489897365506L, 1642699830664413191L, 1666004221847199746L, 1702576545644511234L, 1645595648910704641L, 1645314322216816642L, 1645314322216816643L, 1645314322216816644L, 1645314322216816645L, 1645314322216816646L, 1645314322216816647L, 1702576946385092610L, 1658662667209936897L, 1658662667209936898L, 1658662667209936899L, 1658662667209936900L, 1658662667209936901L, 1658662667209936902L, 1701529461713534977L, 1645688918156320769L, 1645688918156320770L, 1645688918156320771L, 1645688918156320772L, 1645688918156320773L, 1645688918156320774L, 1702577106473287681L, 1658662668782800897L, 1658662668782800898L, 1658662668782800899L, 1658662668782800900L, 1658662668782800901L, 1658662668782800902L, 1702577252363763714L, 1647137024584462337L, 1647137024584462338L, 1647137024584462339L, 1647137024584462340L, 1647137024584462341L, 1647137024584462342L, 1661650957882208257L, 1702578000103309314L, 1645688916713480193L, 1645688916713480194L, 1645688916713480195L, 1645688916713480196L, 1645688916713480197L, 1645688916713480198L, 1702578372427481090L, 1642699829523562497L, 1642699829523562498L, 1642699829523562499L, 1642699829523562500L, 1642699829523562501L, 1642699829523562502L, 1702581675269914626L, 1642699828978302977L, 1642699828978302978L, 1642699828978302979L, 1642699828978302980L, 1642699828978302981L, 1642699828978302982L, 1701527993971376129L, 1661257205264498690L, 1661257343563284481L, 1662289656452018177L, 1662289815781044225L, 1662289897637081089L, 1662289992025698306L, 1669951329203130370L, 1645314323366055938L, 1702567199455936513L, 1645314323366055939L, 1645314323366055940L, 1645314323366055941L, 1645314323366055942L, 1645314323366055943L, 1642699830974791687L, 1642699830320480257L, 1642699830320480258L, 1642699830320480259L, 1642699830320480260L, 1642699830320480261L, 1642699830320480262L, 1702582089298051073L, 1642699830031073281L, 1642699830031073282L, 1642699830031073283L, 1642699830031073284L, 1642699830031073285L, 1642699830031073286L, 1644533653729988609L, 1702582246030802945L, 1645597336069488641L, 1645688917699141633L, 1645688917699141634L, 1645688917699141635L, 1645688917699141636L, 1645688917699141637L, 1645688917699141638L, 1702582588248260610L, 1642699829242544129L, 1642699829242544130L, 1642699829242544131L, 1642699829242544132L, 1642699829242544133L, 1642699829242544134L, 1702582422652944386L, 1645688917497815042L, 1645688917497815043L, 1645688917497815044L, 1645688917497815045L, 1645688917497815046L, 1645688917497815047L, 1702582710013100034L, 1645329015545835521L, 1645329015545835522L, 1645329015545835523L, 1645329015545835524L, 1645329015545835525L, 1645329015545835526L, 1702582843756871681L, 1645688917900468225L, 1645688917900468226L, 1645688917900468227L, 1645688917900468228L, 1645688917900468229L, 1645688917900468230L, 1702582979249668098L, 1L, 100L, 1001L, 1002L, 1003L, 1004L, 1005L, 1006L, 1007L, 1702585719430414338L, 101L, 1010L, 1011L, 1012L, 1013L, 1702585850393362434L};
Long[] khids={1655371202140614657L, 1642699828651147266L, 1642699828651147268L, 1642699830664413186L, 1642699830664413187L, 1642699830664413188L, 1642699830664413189L, 1642699830664413190L, 1655482882922754049L, 1655840316736458753L, 1655842888306184194L, 1654661489897365506L, 1702576545644511234L, 1661257205264498690L, 1661257343563284481L, 1662289656452018177L, 1662289815781044225L, 1662289897637081089L, 1662289992025698306L, 1669951329203130370L};
Long[] wxids = {1702576150650126337L, 1642699829787803649L, 1642699829787803650L, 1642699829787803651L, 1642699829787803652L, 1642699829787803653L, 1642699829787803654L, 1642699830664413186L, 1642699830664413187L, 1642699830664413188L, 1642699830664413189L, 1642699830664413190L, 1655482882922754049L, 1655840316736458753L, 1655448497192230913L, 1654661619136454657L, 1655842888306184194L, 1654661698882756610L, 1654661489897365506L, 1642699830664413191L, 1702576545644511234L, 1702576946385092610L, 1701529461713534977L, 1702577106473287681L, 1702577252363763714L, 1702578372427481090L, 1702581675269914626L, 1701527993971376129L, 1661257205264498690L, 1661257343563284481L, 1662289656452018177L, 1662289815781044225L, 1662289897637081089L, 1662289992025698306L, 1669951329203130370L};
if(iPayTenantService.insertByBo(bo)){
//公司注册成功后自动添加角色:管理员 todo
Long[] adids={};
SysRole role1 = new SysRole();
role1.setRoleKey("companyAdmin");
role1.setRoleName("公司管理员");
@ -83,42 +99,18 @@ public class SysRegisterController extends BaseController {
role1.setFlag(false);
role1.setMenuIds(adids);
SysRole role2 = new SysRole();
role2.setRoleKey("client");
role2.setRoleName("客户");
role2.setTenantId(bo.getId());
role2.setStatus("0");
role2.setRoleSort(0);
role2.setMenuCheckStrictly(false);
role2.setDeptCheckStrictly(true);
role2.setFlag(false);
role2.setMenuIds(khids);
SysRole role3 = new SysRole();
role3.setRoleKey("maintainer");
role3.setRoleName("维修");
role3.setTenantId(bo.getId());
role3.setStatus("0");
role3.setRoleSort(0);
role3.setMenuCheckStrictly(false);
role3.setDeptCheckStrictly(true);
role3.setFlag(false);
role3.setMenuIds(wxids);
roleService.insertRole(role1);
roleService.insertRole(role2);
roleService.insertRole(role3);
Map<String ,Object> data = new HashMap<>();
/*Map<String ,Object> data = new HashMap<>();
List<SysRole> roles = new ArrayList<>();
roles.add(role1);
roles.add(role2);
roles.add(role3);
// data.put("id",bo.getId());
data.put("roles",roles);
return new R().ok(data);
data.put("roles",roles);*/
return new R().ok(role1);
}else{
return new R().fail("注册失败,请重试");
}
}*/
}
/**
*
*/
@ -136,12 +128,12 @@ public class SysRegisterController extends BaseController {
return R.fail("新增用户'" + user.getUserName() + "'失败,用户已存在");
}
user.setPassword(BCrypt.hashpw(user.getPassword()));
/* //1.查询试用的订阅计划信息 2.注册管理员用户同时添加公司的订阅计划——免费试用3月
AsSubscriptionInfoBo bo = new AsSubscriptionInfoBo();
AsSubscriptionPlanBo planBo= new AsSubscriptionPlanBo();
planBo.setName(dictService.getDictValue("trial_plan","sub_name")); //对应字典的使用计划名称查询试用计划
List<AsSubscriptionPlanVo> asSubscriptionPlanVos = iAsSubscriptionPlanService.queryList(planBo);
if(asSubscriptionPlanVos!=null&&asSubscriptionPlanVos.size()>0){
//1.查询试用的订阅计划信息 2.注册管理员用户同时添加公司的订阅计划——免费试用3月
PaySubInfoBo bo = new PaySubInfoBo();
PaySubPlanBo planBo= new PaySubPlanBo();
planBo.setName(dictService.getDictValue("trial_plan","trial_name")); //试用 对应字典的试用名称查询试用计划
List<PaySubPlanVo> planVos = iPaySubPlanService.queryList(planBo);
if(planVos!=null&&planVos.size()>0){
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date); // 设置当前日期
@ -150,8 +142,8 @@ public class SysRegisterController extends BaseController {
bo.setActive("0");
bo.setTenantId(user.getTenantId());
bo.setCompanyName(user.getTenantName());
bo.setSubplanId(asSubscriptionPlanVos.get(0).getId());
bo.setSubplanName(asSubscriptionPlanVos.get(0).getName());
bo.setSubplanId(planVos.get(0).getId());
bo.setSubplanName(planVos.get(0).getName());
bo.setStartTime(date);
bo.setEndTime(endDate);
bo.setRemark("用户注册默认试用");
@ -163,7 +155,7 @@ public class SysRegisterController extends BaseController {
bo.setStartTime(null);
bo.setRemark("用户注册时未找到试用计划");
}
iAsSubscriptionInfoService.insertByBo(bo);*/
iPaySubInfoService.insertByBo(bo);
user.setTenantName(null);
return toAjax(userService.insertUser(user));
}

@ -49,8 +49,8 @@ spring:
driverClassName: com.mysql.cj.jdbc.Driver
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
url: jdbc:mysql://localhost:3307/pay?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&nullCatalogMeansCurrent=true
username: root
url: jdbc:mysql://localhost:3306/pay?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&nullCatalogMeansCurrent=true
username: pay
password: hs123456
# 从库数据源
# slave:

@ -0,0 +1,171 @@
--- # 监控中心配置
spring.boot.admin.client:
# 增加客户端开关
enabled: true
url: http://localhost:9090/admin
instance:
service-host-type: IP
username: ruoyi
password: 123456
--- # xxl-job 配置
xxl.job:
# 执行器开关
enabled: false
# 调度中心地址:如调度中心集群部署存在多个地址则用逗号分隔。
admin-addresses: http://localhost:9100/xxl-job-admin
# 执行器通讯TOKEN非空时启用
access-token: xxl-job
executor:
# 执行器AppName执行器心跳注册分组依据为空则关闭自动注册
appname: xxl-job-executor
# 执行器端口号 执行器从9101开始往后写
port: 9101
# 执行器注册默认IP:PORT
address:
# 执行器IP默认自动获取IP
ip:
# 执行器运行日志文件存储磁盘路径
logpath: ./logs/xxl-job
# 执行器日志文件保存天数大于3生效
logretentiondays: 30
--- # 数据源配置
spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
# 动态数据源文档 https://www.kancloud.cn/tracy5546/dynamic-datasource/content
dynamic:
# 性能分析插件(有性能损耗 不建议生产环境使用)
p6spy: true
# 设置默认的数据源或者数据源组,默认值即为 master
primary: master
# 严格模式 匹配不到数据源则报错
strict: true
datasource:
# 主库数据源
master:
type: ${spring.datasource.type}
driverClassName: com.mysql.cj.jdbc.Driver
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
url: jdbc:mysql://localhost:3307/pay?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&nullCatalogMeansCurrent=true
username: root
password: hs123456
# 从库数据源
# slave:
# lazy: true
# type: ${spring.datasource.type}
# driverClassName: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://localhost:3306/ry-flowable-plus?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&nullCatalogMeansCurrent=true
# username:
# password:
# oracle:
# type: ${spring.datasource.type}
# driverClassName: oracle.jdbc.OracleDriver
# url: jdbc:oracle:thin:@//localhost:1521/XE
# username: ROOT
# password: root
# hikari:
# connectionTestQuery: SELECT 1 FROM DUAL
# postgres:
# type: ${spring.datasource.type}
# driverClassName: org.postgresql.Driver
# url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
# username: root
# password: root
# sqlserver:
# type: ${spring.datasource.type}
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
# url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true
# username: SA
# password: root
hikari:
# 最大连接池数量
maxPoolSize: 20
# 最小空闲线程数量
minIdle: 10
# 配置获取连接等待超时的时间
connectionTimeout: 30000
# 校验超时时间
validationTimeout: 5000
# 空闲连接存活最大时间默认10分钟
idleTimeout: 600000
# 此属性控制池中连接的最长生命周期值0表示无限生命周期默认30分钟
maxLifetime: 1800000
# 连接测试query配置检测连接是否有效
connectionTestQuery: SELECT 1
# 多久检查一次连接的活性
keepaliveTime: 30000
--- # redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
spring:
redis:
# 地址
host: localhost
# 端口默认为6379
port: 6379
# 数据库索引
database: 0
# 密码(如没有密码请注释掉)
# password:
# 连接超时时间
timeout: 10s
# 是否开启ssl
ssl: false
redisson:
# redis key前缀
keyPrefix: pay
# 线程池数量
threads: 4
# Netty线程池数量
nettyThreads: 8
# 单节点配置
singleServerConfig:
# 客户端名称
clientName: ${ruoyi.name}
# 最小空闲连接数
connectionMinimumIdleSize: 8
# 连接池大小
connectionPoolSize: 32
# 连接空闲超时,单位:毫秒
idleConnectionTimeout: 10000
# 命令等待超时,单位:毫秒
timeout: 3000
# 发布和订阅连接池大小
subscriptionConnectionPoolSize: 50
--- # mail 邮件发送
mail:
enabled: false
host: smtp.163.com
port: 465
# 是否需要用户名密码验证
auth: true
# 发送方遵循RFC-822标准
from: xxx@163.com
# 用户名注意如果使用foxmail邮箱此处user为qq号
user: xxx@163.com
# 密码注意某些邮箱需要为SMTP服务单独设置密码详情查看相关帮助
pass: xxxxxxxxxx
# 使用 STARTTLS安全连接STARTTLS是对纯文本通信协议的扩展。
starttlsEnable: true
# 使用SSL安全连接
sslEnable: true
# SMTP超时时长单位毫秒缺省值不超时
timeout: 0
# Socket连接超时值单位毫秒缺省值不超时
connectionTimeout: 0
--- # sms 短信
sms:
enabled: false
# 阿里云 dysmsapi.aliyuncs.com
# 腾讯云 sms.tencentcloudapi.com
endpoint: "dysmsapi.aliyuncs.com"
accessKeyId: xxxxxxx
accessKeySecret: xxxxxx
signName: 测试
# 腾讯专用
sdkAppId:

@ -12,6 +12,12 @@
<artifactId>ruoyi-pay</artifactId>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.5.1</version> <!-- 或者您希望使用的 TestNG 版本 -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>

@ -79,6 +79,13 @@ public class PaySubInfoController extends BaseController {
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody PaySubInfoBo bo) {
//判断该公司是否已经有订阅信息
PaySubInfoBo queryBo = new PaySubInfoBo();
queryBo.setTenantId(bo.getTenantId());
List<PaySubInfoVo> infoVos = iPaySubInfoService.queryList(queryBo);
if(infoVos!=null&&infoVos.size()>0){
return R.fail("公司已有订阅信息,不能新增");
}
return toAjax(iPaySubInfoService.insertByBo(bo));
}

@ -79,6 +79,19 @@ public class PayTenantController extends BaseController {
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody PayTenantBo bo) {
//添加验证 手机号相同或者公司名相同不允许注册
PayTenantBo queryBo = new PayTenantBo();
queryBo.setPhone(bo.getPhone());
List<PayTenantVo> asCompanyVos = iPayTenantService.queryList(queryBo);
if(asCompanyVos!=null&&asCompanyVos.size()>0){
return new R().fail("手机号已注册");
}
queryBo.setName(bo.getName());
queryBo.setPhone(null);
List<PayTenantVo> asCompanyVos2 = iPayTenantService.queryList(queryBo);
if(asCompanyVos2!=null&&asCompanyVos2.size()>0){
return new R().fail("公司名已注册");
}
return toAjax(iPayTenantService.insertByBo(bo));
}

Loading…
Cancel
Save