|
@@ -16,15 +16,11 @@ import com.caimei365.user.components.RedisService;
|
|
|
import com.caimei365.user.utils.AliyunSmsUtil;
|
|
|
import com.caimei365.user.utils.Md5Util;
|
|
|
import com.caimei365.user.utils.ValidateUtil;
|
|
|
-import io.swagger.annotations.ApiImplicitParam;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestHeader;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.text.SimpleDateFormat;
|
|
@@ -80,26 +76,15 @@ public class RegisterServiceImpl implements RegisterService {
|
|
|
StringUtils.isBlank(smsCode)) {
|
|
|
return ResponseJson.error("参数异常", null);
|
|
|
}
|
|
|
- if (!clubRegisterDto.getPassword().equals(passWordConfirm)) {
|
|
|
- return ResponseJson.error("输入的密码不一致", null);
|
|
|
- }
|
|
|
- String redisSmsCode = (String) redisService.get("code:" + clubRegisterDto.getBindMobile());
|
|
|
- if (!redisSmsCode.equals(smsCode)) {
|
|
|
- return ResponseJson.error("手机验证码错误", null);
|
|
|
- }
|
|
|
if (1 != isAgreed) {
|
|
|
return ResponseJson.error("请勾选同意协议", null);
|
|
|
}
|
|
|
- // 查找用户表是否存在
|
|
|
- Integer dbUserId = baseMapper.getUserIdByMobile(clubRegisterDto.getBindMobile());
|
|
|
- if (null != dbUserId && dbUserId > 0) {
|
|
|
- return ResponseJson.error("该手机号已被使用", null);
|
|
|
- }
|
|
|
- // 查找运营人员表是否存在
|
|
|
- Integer dbOperationId = baseMapper.getOperationIdByMobile(clubRegisterDto.getBindMobile());
|
|
|
- if (null != dbOperationId && dbOperationId > 0) {
|
|
|
- return ResponseJson.error("您已是机构运营人员,无需再注册机构", null);
|
|
|
+ if (!clubRegisterDto.getPassword().equals(passWordConfirm)) {
|
|
|
+ return ResponseJson.error("输入的密码不一致", null);
|
|
|
}
|
|
|
+ // 手机号与验证码校验
|
|
|
+ String result = mobileAndCodeValidate(clubRegisterDto.getBindMobile(), smsCode);
|
|
|
+ if (result != null) {return ResponseJson.error(result, null);}
|
|
|
/*
|
|
|
组装用户数据 user
|
|
|
*/
|
|
@@ -346,9 +331,8 @@ public class RegisterServiceImpl implements RegisterService {
|
|
|
return ResponseJson.success(club);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
- * PC端供应商注册
|
|
|
+ * 供应商注册
|
|
|
*
|
|
|
* @param shopRegisterDto ShopRegisterDto{
|
|
|
* source 注册来源: 0网站 1小程序
|
|
@@ -367,55 +351,52 @@ public class RegisterServiceImpl implements RegisterService {
|
|
|
* firstShopType 医疗=1和非医疗=2
|
|
|
* secondShopType 医疗的二级分类 一类器械=1、二类器械 =2、三类器械=3、其他=4 /// 1和非医疗没有二级分类
|
|
|
* mainPro 主打项目(mainpro)
|
|
|
- * }
|
|
|
+ * }
|
|
|
* @param passWordConfirm 用户确认密码
|
|
|
* @param smsCode 短信验证码(旧:activationCode)
|
|
|
* @param isAgreed 是否同意勾选同意协议,1是,其他否
|
|
|
+ * @param whichStep 注册步数: PC(0),小程序(1,2,3)
|
|
|
* @param headers HttpHeaders
|
|
|
* @return ShopPo
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public ResponseJson<ShopPo> shopRegister(ShopRegisterDto shopRegisterDto, String passWordConfirm, String smsCode, Integer isAgreed, HttpHeaders headers) {
|
|
|
+ public ResponseJson<ShopPo> shopRegister(ShopRegisterDto shopRegisterDto, String passWordConfirm, String smsCode, Integer isAgreed, Integer whichStep, HttpHeaders headers) {
|
|
|
// 打印IP
|
|
|
String ip = headers.getFirst("X-CLIENT-IP");
|
|
|
- log.info("X-Forwarded-For:" + ip);
|
|
|
+ log.info("机构注册 X-CLIENT-IP : " + ip);
|
|
|
// 参数校验
|
|
|
- if (StringUtils.isBlank(shopRegisterDto.getName()) || StringUtils.isBlank(shopRegisterDto.getBindMobile())
|
|
|
- || StringUtils.isBlank(shopRegisterDto.getPassword()) || StringUtils.isBlank(passWordConfirm)
|
|
|
- || StringUtils.isBlank(smsCode) || StringUtils.isBlank(shopRegisterDto.getLinkMan())) {
|
|
|
+ if (StringUtils.isBlank(shopRegisterDto.getBindMobile()) || StringUtils.isBlank(smsCode)
|
|
|
+ || StringUtils.isBlank(shopRegisterDto.getPassword()) || StringUtils.isBlank(passWordConfirm)) {
|
|
|
return ResponseJson.error("参数异常", null);
|
|
|
}
|
|
|
- ResponseJson model = ValidateUtil.validateMobile(shopRegisterDto.getBindMobile());
|
|
|
- if (model.getCode() == -1) {
|
|
|
- return ResponseJson.error(model.getMsg(), null);
|
|
|
- }
|
|
|
- if (!shopRegisterDto.getPassword().equals(passWordConfirm)) {
|
|
|
- return ResponseJson.error("输入的密码不一致", null);
|
|
|
- }
|
|
|
- if (1 != isAgreed) {
|
|
|
- return ResponseJson.error("请勾选同意协议", null);
|
|
|
- }
|
|
|
- // 查找用户表是否存在
|
|
|
- Integer dbUserId = baseMapper.getUserIdByMobile(shopRegisterDto.getBindMobile());
|
|
|
- if (null != dbUserId && dbUserId > 0) {
|
|
|
- return ResponseJson.error("该手机号已被使用", null);
|
|
|
+ if (!shopRegisterDto.getPassword() .equals(passWordConfirm)) {
|
|
|
+ return ResponseJson.error("两次输入的密码不一致", null);
|
|
|
}
|
|
|
- // 查找运营人员表是否存在
|
|
|
- Integer dbOperationId = baseMapper.getOperationIdByMobile(shopRegisterDto.getBindMobile());
|
|
|
- if (null != dbOperationId && dbOperationId > 0) {
|
|
|
- return ResponseJson.error("您已是机构运营人员,无需再注册机构", null);
|
|
|
+ // 手机号与验证码校验
|
|
|
+ String result = mobileAndCodeValidate(shopRegisterDto.getBindMobile(), smsCode);
|
|
|
+ if (result != null) {return ResponseJson.error(result, null);}
|
|
|
+ // 小程序第一步校验完成
|
|
|
+ if (1 == whichStep) {
|
|
|
+ return ResponseJson.success(null);
|
|
|
}
|
|
|
- String redisSmsCode = (String) redisService.get("code:" + shopRegisterDto.getBindMobile());
|
|
|
- if (!redisSmsCode.equals(smsCode)) {
|
|
|
- return ResponseJson.error("手机验证码错误", null);
|
|
|
+ if (StringUtils.isBlank(shopRegisterDto.getName()) || StringUtils.isBlank(shopRegisterDto.getLinkMan())) {
|
|
|
+ return ResponseJson.error("参数异常", null);
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(shopRegisterDto.getEmail())) {
|
|
|
- dbUserId = baseMapper.getUserIdByEmail(shopRegisterDto.getEmail());
|
|
|
- if (null != dbUserId && dbUserId > 0) {
|
|
|
+ // 查找用户表是否存在相同邮箱
|
|
|
+ Integer userIdByEmail = baseMapper.getUserIdByEmail(shopRegisterDto.getEmail());
|
|
|
+ if (null != userIdByEmail && userIdByEmail > 0) {
|
|
|
return ResponseJson.error("该邮箱已被使用", null);
|
|
|
}
|
|
|
}
|
|
|
+ // 小程序第二步校验完成
|
|
|
+ if (2 == whichStep) {
|
|
|
+ return ResponseJson.success(null);
|
|
|
+ }
|
|
|
+ if (1 != isAgreed) {
|
|
|
+ return ResponseJson.error("请勾选同意协议", null);
|
|
|
+ }
|
|
|
/*
|
|
|
组装用户数据 user
|
|
|
*/
|
|
@@ -508,79 +489,32 @@ public class RegisterServiceImpl implements RegisterService {
|
|
|
return ResponseJson.success(shop);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
- * 小程序端分步供应商注册
|
|
|
- *
|
|
|
- * @param shopRegisterDto ShopRegisterDto{
|
|
|
- * source 注册来源: 0网站 1小程序
|
|
|
- * name 组织名称
|
|
|
- * sName 供应商公司简称(sname)
|
|
|
- * bindMobile 企业绑定手机号
|
|
|
- * email 邮箱
|
|
|
- * password 密码
|
|
|
- * linkMan 联系人
|
|
|
- * provinceId 省(provinceID)
|
|
|
- * cityId 市(cityID)
|
|
|
- * townId 所在县区Id(townID)
|
|
|
- * address 地址
|
|
|
- * socialCreditCode 统一社会信用代码
|
|
|
- * businessLicenseImage 营业执照
|
|
|
- * firstShopType 医疗=1和非医疗=2
|
|
|
- * secondShopType 医疗的二级分类 一类器械=1、二类器械 =2、三类器械=3、其他=4 /// 1和非医疗没有二级分类
|
|
|
- * mainPro 主打项目(mainpro)
|
|
|
- * }
|
|
|
- * @param passWordConfirm 用户确认密码
|
|
|
- * @param smsCode 短信验证码(旧:activationCode)
|
|
|
- * @param isAgreed 是否同意勾选同意协议,1是,其他否
|
|
|
- * @param whichStep 注册步数
|
|
|
- * @param headers HttpHeaders
|
|
|
- * @return ShopPo
|
|
|
+ * 校验手机号与验证码
|
|
|
+ * @param mobile 手机号
|
|
|
+ * @param smsCode 验证码
|
|
|
+ * @return errorMsg
|
|
|
*/
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public ResponseJson<ShopPo> shopAppletsRegister(ShopRegisterDto shopRegisterDto, String passWordConfirm, String smsCode, Integer isAgreed, Integer whichStep, HttpHeaders headers) {
|
|
|
- // 参数校验
|
|
|
- if (1 == whichStep) {
|
|
|
- if (StringUtils.isBlank(shopRegisterDto.getBindMobile()) || StringUtils.isBlank(shopRegisterDto.getPassword())
|
|
|
- || StringUtils.isBlank(smsCode) || StringUtils.isBlank(shopRegisterDto.getPassword())
|
|
|
- || StringUtils.isBlank(passWordConfirm)) {
|
|
|
- return ResponseJson.error("参数异常", null);
|
|
|
- }
|
|
|
- if (!shopRegisterDto.getPassword() .equals(passWordConfirm)) {
|
|
|
- return ResponseJson.error("两次输入的密码不一致", null);
|
|
|
- }
|
|
|
- // 查找用户表是否存在
|
|
|
- Integer dbUserId = baseMapper.getUserIdByMobile(shopRegisterDto.getBindMobile());
|
|
|
- if (null != dbUserId && dbUserId > 0) {
|
|
|
- return ResponseJson.error("该手机号已被使用", null);
|
|
|
- }
|
|
|
- // 查找运营人员表是否存在
|
|
|
- Integer dbOperationId = baseMapper.getOperationIdByMobile(shopRegisterDto.getBindMobile());
|
|
|
- if (null != dbOperationId && dbOperationId > 0) {
|
|
|
- return ResponseJson.error("您已是机构运营人员,无需再注册机构", null);
|
|
|
- }
|
|
|
- String redisSmsCode = (String) redisService.get("code:" + shopRegisterDto.getBindMobile());
|
|
|
- if (!redisSmsCode.equals(smsCode)) {
|
|
|
- return ResponseJson.error("手机验证码错误", null);
|
|
|
- }
|
|
|
- return ResponseJson.success(null);
|
|
|
- } else if (2 == whichStep) {
|
|
|
- if (StringUtils.isBlank(shopRegisterDto.getName()) || StringUtils.isBlank(shopRegisterDto.getLinkMan())) {
|
|
|
- return ResponseJson.error("参数异常", null);
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(shopRegisterDto.getEmail())) {
|
|
|
- // 查找用户表是否存在相同邮箱
|
|
|
- Integer dbUserId = baseMapper.getUserIdByEmail(shopRegisterDto.getEmail());
|
|
|
- if (null != dbUserId && dbUserId > 0) {
|
|
|
- return ResponseJson.error("该邮箱已被使用", null);
|
|
|
- }
|
|
|
- }
|
|
|
- return ResponseJson.success(null);
|
|
|
- } else if (1 != isAgreed) {
|
|
|
- return ResponseJson.error("请勾选同意协议", null);
|
|
|
+ private String mobileAndCodeValidate(String mobile, String smsCode) {
|
|
|
+ ResponseJson model = ValidateUtil.validateMobile(mobile);
|
|
|
+ if (model.getCode() == -1) {
|
|
|
+ return model.getMsg();
|
|
|
+ }
|
|
|
+ String redisSmsCode = (String) redisService.get("code:" + mobile);
|
|
|
+ if (!redisSmsCode.equals(smsCode)) {
|
|
|
+ return "手机验证码错误";
|
|
|
+ }
|
|
|
+ // 查找用户表是否存在
|
|
|
+ Integer dbUserId = baseMapper.getUserIdByMobile(mobile);
|
|
|
+ if (null != dbUserId && dbUserId > 0) {
|
|
|
+ return "该手机号已被使用";
|
|
|
+ }
|
|
|
+ // 查找运营人员表是否存在
|
|
|
+ Integer dbOperationId = baseMapper.getOperationIdByMobile(mobile);
|
|
|
+ if (null != dbOperationId && dbOperationId > 0) {
|
|
|
+ return "您已是运营人员,无需再注册机构";
|
|
|
}
|
|
|
- return shopRegister(shopRegisterDto, passWordConfirm, smsCode, isAgreed, headers);
|
|
|
+ return null;
|
|
|
}
|
|
|
}
|
|
|
|