|
@@ -1,5 +1,6 @@
|
|
package com.caimei365.user.service.impl;
|
|
package com.caimei365.user.service.impl;
|
|
|
|
|
|
|
|
+import com.caimei365.user.components.CommonService;
|
|
import com.caimei365.user.mapper.BaseMapper;
|
|
import com.caimei365.user.mapper.BaseMapper;
|
|
import com.caimei365.user.mapper.LoginMapper;
|
|
import com.caimei365.user.mapper.LoginMapper;
|
|
import com.caimei365.user.mapper.RegisterMapper;
|
|
import com.caimei365.user.mapper.RegisterMapper;
|
|
@@ -10,7 +11,6 @@ import com.caimei365.user.model.po.OperationPo;
|
|
import com.caimei365.user.model.po.ShopPo;
|
|
import com.caimei365.user.model.po.ShopPo;
|
|
import com.caimei365.user.model.po.UserPo;
|
|
import com.caimei365.user.model.po.UserPo;
|
|
import com.caimei365.user.model.vo.ServiceProviderVo;
|
|
import com.caimei365.user.model.vo.ServiceProviderVo;
|
|
-import com.caimei365.user.model.vo.UserLoginVo;
|
|
|
|
import com.caimei365.user.service.RegisterService;
|
|
import com.caimei365.user.service.RegisterService;
|
|
import com.caimei365.user.components.RedisService;
|
|
import com.caimei365.user.components.RedisService;
|
|
import com.caimei365.user.utils.AliyunSmsUtil;
|
|
import com.caimei365.user.utils.AliyunSmsUtil;
|
|
@@ -35,11 +35,13 @@ import java.util.Map;
|
|
*/
|
|
*/
|
|
@Slf4j
|
|
@Slf4j
|
|
@Service
|
|
@Service
|
|
-public class RegisterServiceImpl implements RegisterService {
|
|
|
|
|
|
+public class RegisterServiceImpl implements RegisterService{
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private RedisService redisService;
|
|
private RedisService redisService;
|
|
@Resource
|
|
@Resource
|
|
|
|
+ private CommonService commonService;
|
|
|
|
+ @Resource
|
|
private BaseMapper baseMapper;
|
|
private BaseMapper baseMapper;
|
|
@Resource
|
|
@Resource
|
|
private LoginMapper loginMapper;
|
|
private LoginMapper loginMapper;
|
|
@@ -55,10 +57,10 @@ public class RegisterServiceImpl implements RegisterService {
|
|
@Override
|
|
@Override
|
|
public ResponseJson registerCheck(String mobileOrEmail) {
|
|
public ResponseJson registerCheck(String mobileOrEmail) {
|
|
// 手机号验证
|
|
// 手机号验证
|
|
- String mobileResult = mobileAndCodeValidate(mobileOrEmail, null);
|
|
|
|
|
|
+ String mobileResult = commonService.mobileAndCodeValidate(mobileOrEmail, null);
|
|
if (mobileResult != null) {return ResponseJson.error(mobileResult);}
|
|
if (mobileResult != null) {return ResponseJson.error(mobileResult);}
|
|
// 邮箱验证
|
|
// 邮箱验证
|
|
- String emailResult = emailValidate(mobileOrEmail);
|
|
|
|
|
|
+ String emailResult = commonService.emailValidate(mobileOrEmail);
|
|
if (emailResult != null) {return ResponseJson.error(emailResult);}
|
|
if (emailResult != null) {return ResponseJson.error(emailResult);}
|
|
return ResponseJson.success("该账号可以注册");
|
|
return ResponseJson.success("该账号可以注册");
|
|
}
|
|
}
|
|
@@ -100,7 +102,7 @@ public class RegisterServiceImpl implements RegisterService {
|
|
return ResponseJson.error("输入的密码不一致");
|
|
return ResponseJson.error("输入的密码不一致");
|
|
}
|
|
}
|
|
// 手机号与验证码校验
|
|
// 手机号与验证码校验
|
|
- String result = mobileAndCodeValidate(clubRegisterDto.getBindMobile(), clubRegisterDto.getSmsCode());
|
|
|
|
|
|
+ String result = commonService.mobileAndCodeValidate(clubRegisterDto.getBindMobile(), clubRegisterDto.getSmsCode());
|
|
if (result != null) {return ResponseJson.error(result);}
|
|
if (result != null) {return ResponseJson.error(result);}
|
|
/*
|
|
/*
|
|
组装用户数据 user
|
|
组装用户数据 user
|
|
@@ -405,7 +407,7 @@ public class RegisterServiceImpl implements RegisterService {
|
|
String email = onlineDto.getContractEmail();
|
|
String email = onlineDto.getContractEmail();
|
|
if (StringUtils.isNotBlank(email)) {
|
|
if (StringUtils.isNotBlank(email)) {
|
|
// 邮箱验证
|
|
// 邮箱验证
|
|
- String emailCheck = emailValidate(email);
|
|
|
|
|
|
+ String emailCheck = commonService.emailValidate(email);
|
|
if (emailCheck != null) {return ResponseJson.error(emailCheck);}
|
|
if (emailCheck != null) {return ResponseJson.error(emailCheck);}
|
|
// 机构名称检查
|
|
// 机构名称检查
|
|
ResponseJson responseJson = ValidateUtil.validateClubName(onlineDto.getName());
|
|
ResponseJson responseJson = ValidateUtil.validateClubName(onlineDto.getName());
|
|
@@ -423,7 +425,7 @@ public class RegisterServiceImpl implements RegisterService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 手机号验证
|
|
// 手机号验证
|
|
- String result = mobileAndCodeValidate(mobile, null);
|
|
|
|
|
|
+ String result = commonService.mobileAndCodeValidate(mobile, null);
|
|
if (result != null) {return ResponseJson.error(result);}
|
|
if (result != null) {return ResponseJson.error(result);}
|
|
// 获取协销信息
|
|
// 获取协销信息
|
|
Integer userId = onlineDto.getUserId();
|
|
Integer userId = onlineDto.getUserId();
|
|
@@ -623,7 +625,7 @@ public class RegisterServiceImpl implements RegisterService {
|
|
return ResponseJson.error("两次输入的密码不一致");
|
|
return ResponseJson.error("两次输入的密码不一致");
|
|
}
|
|
}
|
|
// 手机号与验证码校验
|
|
// 手机号与验证码校验
|
|
- String result = mobileAndCodeValidate(shopRegisterDto.getBindMobile(), smsCode);
|
|
|
|
|
|
+ String result = commonService.mobileAndCodeValidate(shopRegisterDto.getBindMobile(), smsCode);
|
|
if (result != null) {return ResponseJson.error(result, null);}
|
|
if (result != null) {return ResponseJson.error(result, null);}
|
|
// 小程序第一步校验完成
|
|
// 小程序第一步校验完成
|
|
if (1 == whichStep) {
|
|
if (1 == whichStep) {
|
|
@@ -771,67 +773,5 @@ public class RegisterServiceImpl implements RegisterService {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 校验邮箱
|
|
|
|
- * @param email 邮箱
|
|
|
|
- * @return errorMsg
|
|
|
|
- */
|
|
|
|
- private String emailValidate(String email) {
|
|
|
|
- if (!ValidateUtil.validateEmail(email)) {
|
|
|
|
- return "邮箱格式不正确";
|
|
|
|
- }
|
|
|
|
- Integer userIdByEmail = baseMapper.getUserIdByEmail(email);
|
|
|
|
- if (null != userIdByEmail && userIdByEmail > 0 ) {
|
|
|
|
- return "该邮箱已被使用";
|
|
|
|
- }
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- /**
|
|
|
|
- * 校验手机号与验证码
|
|
|
|
- * @param mobile 手机号
|
|
|
|
- * @param smsCode 验证码
|
|
|
|
- * @return errorMsg
|
|
|
|
- */
|
|
|
|
- private String mobileAndCodeValidate(String mobile, String smsCode) {
|
|
|
|
- ResponseJson model = ValidateUtil.validateMobile(mobile);
|
|
|
|
- if (model.getCode() == -1) {
|
|
|
|
- return model.getMsg();
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isNotBlank(smsCode)){
|
|
|
|
- String redisSmsCode = (String) redisService.get("code:" + mobile);
|
|
|
|
- if (!redisSmsCode.equals(smsCode)) {
|
|
|
|
- return "手机验证码错误";
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- boolean flag = false;
|
|
|
|
- // 查找用户表是否存在
|
|
|
|
- Integer dbUserId = baseMapper.getUserIdByMobile(mobile);
|
|
|
|
- if (null != dbUserId && dbUserId > 0) {
|
|
|
|
- UserLoginVo user = loginMapper.getLoginUserByUserId(dbUserId);
|
|
|
|
- String showName = ValidateUtil.nameConversion(user.getUserName());
|
|
|
|
- if (2 == user.getUserIdentity() || 4 == user.getUserIdentity()) {
|
|
|
|
- return "该手机号已绑定机构(" + showName + ")联系人,请重新填写手机号";
|
|
|
|
- } else if (3 == user.getUserIdentity()) {
|
|
|
|
- return "该手机号已绑定供应商(" + showName + ")联系人,请重新填写手机号";
|
|
|
|
- }
|
|
|
|
- flag = true;
|
|
|
|
- }
|
|
|
|
- // 查找运营人员表是否存在
|
|
|
|
- Integer dbOperationId = baseMapper.getOperationIdByMobile(mobile);
|
|
|
|
- if (null != dbOperationId && dbOperationId > 0) {
|
|
|
|
- UserLoginVo operation = loginMapper.getOperationUserByOperationId(dbOperationId);
|
|
|
|
- String showName = ValidateUtil.nameConversion(operation.getUserName());
|
|
|
|
- if (2 == operation.getUserIdentity() || 4 == operation.getUserIdentity()) {
|
|
|
|
- return "该手机号已绑定机构(" + showName + ")运营人员,请重新填写手机号";
|
|
|
|
- } else if (3 == operation.getUserIdentity()) {
|
|
|
|
- return "该手机号已绑定供应商(" + showName + ")运营人员,请重新填写手机号";
|
|
|
|
- }
|
|
|
|
- flag = true;
|
|
|
|
- }
|
|
|
|
- if (flag) {
|
|
|
|
- return "该手机号已被使用";
|
|
|
|
- }
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|