|
@@ -217,7 +217,8 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
String smsCode = RedisUtil.get(PREFIX + registerDto.getPhone());
|
|
String smsCode = RedisUtil.get(PREFIX + registerDto.getPhone());
|
|
if (smsCode == null) throw new RuntimeException("验证码已过期,请重新发送!");
|
|
if (smsCode == null) throw new RuntimeException("验证码已过期,请重新发送!");
|
|
//比对验证码
|
|
//比对验证码
|
|
- if (registerDto.getSmsCode()!=Integer.parseInt(smsCode)) throw new SecurityException("验证码输入错误,请检查!");
|
|
|
|
|
|
+ if (registerDto.getSmsCode() != Integer.parseInt(smsCode))
|
|
|
|
+ throw new SecurityException("验证码输入错误,请检查!");
|
|
//4.开始新增
|
|
//4.开始新增
|
|
AppUser appUser = new AppUser();
|
|
AppUser appUser = new AppUser();
|
|
//手机号
|
|
//手机号
|
|
@@ -411,25 +412,25 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
* 获取验证码
|
|
* 获取验证码
|
|
*/
|
|
*/
|
|
boolean getPhoneSmsCode(String phone) {
|
|
boolean getPhoneSmsCode(String phone) {
|
|
- AppUser appUser= this.findByPhone(phone);
|
|
|
|
- if (appUser!=null){
|
|
|
|
- throw new AjaxError("该手机号已注册");
|
|
|
|
- }
|
|
|
|
|
|
+ AppUser appUser = this.findByPhone(phone);
|
|
|
|
+ if (appUser != null) {
|
|
|
|
+ throw new AjaxError("该手机号已注册");
|
|
|
|
+ }
|
|
//生成4位随机数
|
|
//生成4位随机数
|
|
- String code=RandomUtil.randomNumbers(4);
|
|
|
|
|
|
+ String code = RandomUtil.randomNumbers(4);
|
|
//保存到缓存,默认1分钟 todo:届时放开手机验证码 randomNumber
|
|
//保存到缓存,默认1分钟 todo:届时放开手机验证码 randomNumber
|
|
RedisUtil.setByMINUTES(PREFIX + phone, code, 5);
|
|
RedisUtil.setByMINUTES(PREFIX + phone, code, 5);
|
|
- SystemObject.smsFactory.handler().sendSMS(phone,"您的验证码是"+code+"。如非本人操作,请忽略本短信");
|
|
|
|
|
|
+ SystemObject.smsFactory.handler().sendSMS(phone, "您的验证码是" + code + "。如非本人操作,请忽略本短信");
|
|
//发送验证码短信
|
|
//发送验证码短信
|
|
return true;
|
|
return true;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private AppUser findByPhone(String phone) {
|
|
private AppUser findByPhone(String phone) {
|
|
- QueryWrapper<AppUser>ew=new QueryWrapper<>();
|
|
|
|
- ew.lambda().eq(AppUser::getPhone,phone);
|
|
|
|
- List<AppUser>list=list(ew);
|
|
|
|
- return list.isEmpty()?null:list.get(0);
|
|
|
|
|
|
+ QueryWrapper<AppUser> ew = new QueryWrapper<>();
|
|
|
|
+ ew.lambda().eq(AppUser::getPhone, phone);
|
|
|
|
+ List<AppUser> list = list(ew);
|
|
|
|
+ return list.isEmpty() ? null : list.get(0);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -492,37 +493,38 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
return 1 == appUserMapper.updateById(appUser);
|
|
return 1 == appUserMapper.updateById(appUser);
|
|
}
|
|
}
|
|
|
|
|
|
- /** 获取银行卡信息 */
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取银行卡信息
|
|
|
|
+ */
|
|
public SoMap getBankInfo() {
|
|
public SoMap getBankInfo() {
|
|
SoMap so = new SoMap();
|
|
SoMap so = new SoMap();
|
|
Integer userType = StpAPPUserUtil.getAPPLoginInfo().getUserType();
|
|
Integer userType = StpAPPUserUtil.getAPPLoginInfo().getUserType();
|
|
Long fk = StpAPPUserUtil.getAPPLoginInfo().getFk();
|
|
Long fk = StpAPPUserUtil.getAPPLoginInfo().getFk();
|
|
|
|
|
|
//1=普通边民,2=边民组长,3=收购商,4=司机,5=外籍商户,6=合作社
|
|
//1=普通边民,2=边民组长,3=收购商,4=司机,5=外籍商户,6=合作社
|
|
- if(1 == userType || 2 == userType) {
|
|
|
|
|
|
+ if (1 == userType || 2 == userType) {
|
|
PeopleDto peopleDto = levelOneServerInterface.getRpcById(fk);
|
|
PeopleDto peopleDto = levelOneServerInterface.getRpcById(fk);
|
|
- so.put("bankName",peopleDto.getBankName());
|
|
|
|
- so.put("bankAccount",peopleDto.getBankCode());
|
|
|
|
- }
|
|
|
|
- else if(3 == userType) {
|
|
|
|
|
|
+ so.put("bankName", peopleDto.getBankName());
|
|
|
|
+ so.put("bankAccount", peopleDto.getBankCode());
|
|
|
|
+ } else if (3 == userType) {
|
|
PurchaserDto purchaserDto = levelTwoServerInterface.getByPurchaserId(fk);
|
|
PurchaserDto purchaserDto = levelTwoServerInterface.getByPurchaserId(fk);
|
|
- so.put("bankName",purchaserDto.getBankName());
|
|
|
|
- so.put("bankAccount",purchaserDto.getBankAccount());
|
|
|
|
- }
|
|
|
|
- else if(5 == userType) {
|
|
|
|
|
|
+ so.put("bankName", purchaserDto.getBankName());
|
|
|
|
+ so.put("bankAccount", purchaserDto.getBankAccount());
|
|
|
|
+ } else if (5 == userType) {
|
|
EnterpriseDto enterpriseDto = levelOneServerInterface.getEnterpriseById(fk);
|
|
EnterpriseDto enterpriseDto = levelOneServerInterface.getEnterpriseById(fk);
|
|
- so.put("bankName",enterpriseDto.getBank());
|
|
|
|
- so.put("bankAccount",enterpriseDto.getBankAccount());
|
|
|
|
- }
|
|
|
|
- else if(6 == userType) {
|
|
|
|
|
|
+ so.put("bankName", enterpriseDto.getBank());
|
|
|
|
+ so.put("bankAccount", enterpriseDto.getBankAccount());
|
|
|
|
+ } else if (6 == userType) {
|
|
CooperativeDto cooperativeDto = levelOneServerInterface.getCooperativeById(fk);
|
|
CooperativeDto cooperativeDto = levelOneServerInterface.getCooperativeById(fk);
|
|
- so.put("bankName",cooperativeDto.getBankName());
|
|
|
|
- so.put("bankAccount",cooperativeDto.getBankAccount());
|
|
|
|
|
|
+ so.put("bankName", cooperativeDto.getBankName());
|
|
|
|
+ so.put("bankAccount", cooperativeDto.getBankAccount());
|
|
}
|
|
}
|
|
return so;
|
|
return so;
|
|
}
|
|
}
|
|
|
|
|
|
- /** 保存银行卡信息 */
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 保存银行卡信息
|
|
|
|
+ */
|
|
public boolean saveBankInfo(SoMap so) {
|
|
public boolean saveBankInfo(SoMap so) {
|
|
Integer userType = StpAPPUserUtil.getAPPLoginInfo().getUserType();
|
|
Integer userType = StpAPPUserUtil.getAPPLoginInfo().getUserType();
|
|
Long fk = StpAPPUserUtil.getAPPLoginInfo().getFk();
|
|
Long fk = StpAPPUserUtil.getAPPLoginInfo().getFk();
|
|
@@ -530,19 +532,16 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
String bankAccount = so.getString("bankAccount");
|
|
String bankAccount = so.getString("bankAccount");
|
|
|
|
|
|
//1=普通边民,2=边民组长,3=收购商,4=司机,5=外籍商户,6=合作社
|
|
//1=普通边民,2=边民组长,3=收购商,4=司机,5=外籍商户,6=合作社
|
|
- if(1 == userType || 2 == userType) {
|
|
|
|
|
|
+ if (1 == userType || 2 == userType) {
|
|
boolean result = levelOneServerInterface.saveBankByPeople(fk, bankName, bankAccount);
|
|
boolean result = levelOneServerInterface.saveBankByPeople(fk, bankName, bankAccount);
|
|
return result;
|
|
return result;
|
|
- }
|
|
|
|
- else if(3 == userType) {
|
|
|
|
|
|
+ } else if (3 == userType) {
|
|
boolean result = levelTwoServerInterface.saveBankByPurchaser(fk, bankName, bankAccount);
|
|
boolean result = levelTwoServerInterface.saveBankByPurchaser(fk, bankName, bankAccount);
|
|
return result;
|
|
return result;
|
|
- }
|
|
|
|
- else if(5 == userType) {
|
|
|
|
|
|
+ } else if (5 == userType) {
|
|
boolean result = levelOneServerInterface.saveBankByEnterprise(fk, bankName, bankAccount);
|
|
boolean result = levelOneServerInterface.saveBankByEnterprise(fk, bankName, bankAccount);
|
|
return result;
|
|
return result;
|
|
- }
|
|
|
|
- else if(6 == userType) {
|
|
|
|
|
|
+ } else if (6 == userType) {
|
|
boolean result = levelOneServerInterface.saveBankByCooperative(fk, bankName, bankAccount);
|
|
boolean result = levelOneServerInterface.saveBankByCooperative(fk, bankName, bankAccount);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@@ -570,109 +569,45 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
return update == 1;
|
|
return update == 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * 远程调用: 当从航通导入数据时,自动给边民生成账号
|
|
|
|
|
|
+ * 用户数量统计
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
*/
|
|
*/
|
|
- public boolean generatePeopleAccount(HtPeopleDto peopleDto) throws Exception {
|
|
|
|
- //检查是否重复注册
|
|
|
|
- AppUser appUser=this.findByPhone(peopleDto.getBorderTel());
|
|
|
|
- if (appUser!=null) {
|
|
|
|
- log.error("\n该用户已注册! phone = " + peopleDto.getBorderTel() + "\n");
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- //创建保存对象
|
|
|
|
- appUser = new AppUser();
|
|
|
|
- //设置基本属性
|
|
|
|
- appUser.setAuth(1 + ""); // 默认已认证
|
|
|
|
- appUser.setUserType(1); // 用户类型 1
|
|
|
|
- appUser.setCreateTime(new Date()); // 创建时间
|
|
|
|
- appUser.setPhone(peopleDto.getBorderTel()); // 电话
|
|
|
|
- appUser.setStatus("1"); // 可用状态
|
|
|
|
- appUser.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 默认可用
|
|
|
|
- appUser.setAuthTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); // 认证时间
|
|
|
|
- appUser.setName(peopleDto.getBorderName()); // 昵称
|
|
|
|
- appUser.setFkId(peopleDto.getId()); // 外键
|
|
|
|
- appUser.setCreateUnit("航通");
|
|
|
|
- //随机生成6位数密码
|
|
|
|
- String password = RandomUtil.randomNumbers(6);
|
|
|
|
- log.info("生成账号:{},{}",peopleDto.getBorderTel(),password);
|
|
|
|
-// String password=appUser.getPhone();
|
|
|
|
- //密码加密
|
|
|
|
- String encodePassword = passwordEncoder.encode(password + "");
|
|
|
|
- //设置密码
|
|
|
|
- appUser.setPassword(encodePassword);
|
|
|
|
- //保存
|
|
|
|
- int insert = appUserMapper.insert(appUser);
|
|
|
|
- //发送短信
|
|
|
|
- if (insert == 1) {
|
|
|
|
- //todo: 届时放开注释
|
|
|
|
- String content="您好,您的[边民互市]app账号已生成。账号:" + peopleDto.getBorderTel() + ", 初始密码:" + password + "。可前往app进行修改";
|
|
|
|
-// boolean msg = smsRetryService.sendSmsRegisteMsg(null, "您好,您已成功注册[边民互市]app账号。账号:" + peopleDto.getBorderTel() + ", 初始密码:" + password + "。可前往app进行修改");
|
|
|
|
-// return msg;
|
|
|
|
- System.out.println("注册成功! 账户 = " + peopleDto.getBorderTel() + " password = " + password);
|
|
|
|
- SystemObject.smsFactory.handler().sendSMS(peopleDto.getBorderTel(),content);
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- throw new RuntimeException("同步航通信息时,边民注册app信息失败,边民手机号为: " + peopleDto.getBorderTel() + "。 时间: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
|
|
|
+ public Map<String, Object> selectUsers() {
|
|
|
|
+ return appUserMapper.selectUsers();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ ;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * 远程调用: 当从航通导入数据时,自动给外籍商户生成账号
|
|
|
|
|
|
+ * 创建账号
|
|
|
|
+ *
|
|
|
|
+ * @param createDTO
|
|
*/
|
|
*/
|
|
- public int generateEnterpriseAccount(EnterpriseDto enterpriseDto) throws Exception {
|
|
|
|
- //判断是否已被注册
|
|
|
|
- List<AppUser> appUsers = appUserMapper.selectList(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, enterpriseDto.getOwnerTel()));
|
|
|
|
- if (appUsers.size() != 0) {
|
|
|
|
- StaticLog.error("用户手机号已被注册:{},{}", enterpriseDto.getOwnerTel(), JSONUtil.toJsonStr(enterpriseDto));
|
|
|
|
- return 0;
|
|
|
|
|
|
+ public void createUser(AppUserCreateDTO createDTO) {
|
|
|
|
+ log.info("创建账号:{}",JSONUtil.toJsonStr(createDTO));
|
|
|
|
+ String phone = createDTO.getPhone();
|
|
|
|
+ AppUser appUser = this.findByPhone(phone);
|
|
|
|
+ if (appUser != null) {
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
- //创建保存对象
|
|
|
|
- AppUser appUser = new AppUser();
|
|
|
|
- //设置基本属性
|
|
|
|
- appUser.setAuth(1 + ""); // 默认已认证
|
|
|
|
- appUser.setUserType(5); // 用户类型 1
|
|
|
|
- appUser.setCreateTime(new Date()); // 创建时间
|
|
|
|
- appUser.setPhone(enterpriseDto.getOwnerTel()); // 电话
|
|
|
|
- appUser.setStatus(Status.STATUS_ONE.getCode() + ""); // 可用状态
|
|
|
|
- appUser.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 默认可用
|
|
|
|
- appUser.setAuthTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); // 认证时间
|
|
|
|
- appUser.setName(enterpriseDto.getOwnerName()); // 昵称
|
|
|
|
- appUser.setFkId(enterpriseDto.getId()); // 外键
|
|
|
|
- appUser.setCreateUnit("航通"); // 创建单位
|
|
|
|
- //随机生成6位数密码
|
|
|
|
- //int password = (int) (Math.random() * (999999 - 100000 + 1) + 100000);
|
|
|
|
- String password = appUser.getPhone();
|
|
|
|
|
|
+ appUser = new AppUser();
|
|
|
|
+ BeanUtils.copyProperties(createDTO, appUser);
|
|
//密码加密
|
|
//密码加密
|
|
- String encodePassword = passwordEncoder.encode(password + "");
|
|
|
|
- //设置密码
|
|
|
|
- appUser.setPassword(encodePassword);
|
|
|
|
- //保存
|
|
|
|
- int insert = appUserMapper.insert(appUser);
|
|
|
|
- //发送短信
|
|
|
|
- if (insert == 1) {
|
|
|
|
- //查询外籍商户和商铺是否存在,不存在则删除app user信息 ownTel
|
|
|
|
-// List<ShopDto> shopDtoListByPhone = levelOneServerInterface.getShopDtoListByPhone(appUser.getPhone());
|
|
|
|
-// List<EnterpriseDto> enterpriseDtoListByPhone = levelOneServerInterface.getEnterpriseDtoListByPhone(appUser.getPhone());
|
|
|
|
-// if(shopDtoListByPhone.size() != 1 && enterpriseDtoListByPhone.size() != 1)
|
|
|
|
-// throw new ServiceException("当航通同步商铺信息时,商铺或者外籍商户信息入库发生异常,故在自动创建appUser时抛出异常回滚数据。");
|
|
|
|
- //todo: 届时放开注释
|
|
|
|
-// boolean msg = smsRetryService.sendSmsRegisteMsg(null, "您好,您已成功注册[边民互市]app账号。账号:" + peopleDto.getBorderTel() + ", 初始密码:" + password + "。可前往app进行修改");
|
|
|
|
-// return msg;
|
|
|
|
- System.out.println("\n注册成功! 账户 = " + enterpriseDto.getOwnerTel() + " password = " + password + "\n");
|
|
|
|
- return 1;
|
|
|
|
- }
|
|
|
|
- StaticLog.error("同步航通信息时,边民注册app信息失败,边民手机号为: " + enterpriseDto.getOwnerTel() + "。 时间: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
|
- return 1;
|
|
|
|
|
|
+ String encodePassword = passwordEncoder.encode(phone);
|
|
|
|
+ appUser.setPassword(encodePassword)
|
|
|
|
+ .setFkId(Long.parseLong(createDTO.getFkId()))
|
|
|
|
+ .setUserType(Integer.parseInt(createDTO.getUserType()))
|
|
|
|
+ .setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode())
|
|
|
|
+ .setCreateTime(new Date()).setUpdateTime(new Date());
|
|
|
|
+ this.save(appUser);
|
|
|
|
+ String content = "您好,您的app账号已生成。账号:" + phone + ", 初始密码:" + phone + "。可前往app进行修改";
|
|
|
|
+ // todo 发送短信
|
|
|
|
+ //SystemObject.smsFactory.handler().sendSMS(phone, content);
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 用户数量统计
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public Map<String, Object> selectUsers(){
|
|
|
|
- return appUserMapper.selectUsers();
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
|
|
}
|
|
}
|