|
|
@@ -293,6 +293,7 @@ public class UserLogic {
|
|
|
List<UserWait> list = userWaitService.lambdaQuery()
|
|
|
.eq(UserWait::getMobile, mobile)
|
|
|
.eq(UserWait::getIsAdd, false)
|
|
|
+ .eq(UserWait::getExamineStatus, ExamineStatusEnum.OK.getKey())
|
|
|
.list();
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
return;
|
|
|
@@ -314,6 +315,7 @@ public class UserLogic {
|
|
|
userWaitService.lambdaUpdate()
|
|
|
.set(UserWait::getIsAdd, true)
|
|
|
.in(UserWait::getId, list.stream().map(UserWait::getId).collect(Collectors.toList()))
|
|
|
+ .eq(UserWait::getExamineStatus, ExamineStatusEnum.OK.getKey())
|
|
|
.update();
|
|
|
}
|
|
|
|
|
|
@@ -739,7 +741,7 @@ public class UserLogic {
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
|
- public UserWxBean workerMobileLogin(String mobile, String messageCode, String locate) throws Exception {
|
|
|
+ public UserWxBean workerMobileLogin(String mobile, String messageCode, String locate, HttpServletRequest request) throws Exception {
|
|
|
Object validMessageCode = redisUtil.get(Constant.RedisPrefix.SMS + ":" + mobile);
|
|
|
if (Objects.isNull(validMessageCode)) {
|
|
|
throw new RemoteServiceException("短信验证码过期");
|
|
|
@@ -749,12 +751,12 @@ public class UserLogic {
|
|
|
throw new RemoteServiceException("短信验证码错误");
|
|
|
}
|
|
|
|
|
|
- User user = this.initAppUser(mobile, locate);
|
|
|
+ User user = this.initAppUser(mobile, locate, request);
|
|
|
|
|
|
return this.appUser(user);
|
|
|
}
|
|
|
|
|
|
- private User initAppUser(String mobile, String locate) throws Exception {
|
|
|
+ private User initAppUser(String mobile, String locate, HttpServletRequest request) throws Exception {
|
|
|
String key = Constant.RedisPrefix.LOCK_AUTH + ":" + mobile;
|
|
|
Lock obtain = redisLockRegistry.obtain(key);
|
|
|
if (!obtain.tryLock(2, TimeUnit.SECONDS)) {
|
|
|
@@ -773,10 +775,15 @@ public class UserLogic {
|
|
|
userWait = userWaitService.lambdaQuery()
|
|
|
.eq(UserWait::getMobile, mobile)
|
|
|
.eq(UserWait::getUserType, UserTypeEnum.WORKER.getKey())
|
|
|
+ .eq(UserWait::getExamineStatus, ExamineStatusEnum.OK.getKey())
|
|
|
.last("limit 1")
|
|
|
.one();
|
|
|
|
|
|
if (Objects.isNull(userWait)) {
|
|
|
+ final String source = CommonUtils.getSource(request);
|
|
|
+ if (StringUtils.isBlank(source) || source.equals("PC")) {
|
|
|
+ throw new RemoteServiceException("账号密码错误!");
|
|
|
+ }
|
|
|
// 如果初始化师傅信息表没有,就注册一个
|
|
|
user = new User();
|
|
|
user.setUserId(IdWorker.getIdStr())
|
|
|
@@ -791,6 +798,9 @@ public class UserLogic {
|
|
|
// 否则按初始化信息新注册
|
|
|
user = new User();
|
|
|
user.setUserId(userWait.getWorkerNumber())
|
|
|
+ .setFirstName(userWait.getFirstName())
|
|
|
+ .setLastName(userWait.getLastName())
|
|
|
+ .setExamineStatus(userWait.getExamineStatus())
|
|
|
.setCreateTime(new Date())
|
|
|
.setMobile(mobile);
|
|
|
}
|
|
|
@@ -847,4 +857,33 @@ public class UserLogic {
|
|
|
.setCreateTime(DateUtil.date())
|
|
|
.insert();
|
|
|
}
|
|
|
+
|
|
|
+ public void registerUser(String companyWechatId, String firstName, String lastName, String mobile, String email) {
|
|
|
+ final AdminCompanyWechat adminCompanyWechat = adminCompanyWechatService.getById(companyWechatId);
|
|
|
+ if (Objects.isNull(adminCompanyWechat)) {
|
|
|
+ throw new RemoteServiceException("商户异常");
|
|
|
+ }
|
|
|
+
|
|
|
+ final Integer count = userService.lambdaQuery()
|
|
|
+ .eq(User::getMobile, StringUtils.trim(mobile))
|
|
|
+ .count();
|
|
|
+
|
|
|
+ if (count > 0) {
|
|
|
+ throw new RemoteServiceException("信息已存在");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ UserWait userWait = new UserWait();
|
|
|
+ userWait.setId(IdWorker.getIdStr())
|
|
|
+ .setUserType(UserTypeEnum.WORKER.getKey())
|
|
|
+ .setWorkerNumber(userWait.getId())
|
|
|
+ .setCompanyWechatId(companyWechatId)
|
|
|
+ .setCompanyWechatName(adminCompanyWechat.getCompanyName())
|
|
|
+ .setFirstName(firstName)
|
|
|
+ .setLastName(lastName)
|
|
|
+ .setMobile(StringUtils.trim(mobile))
|
|
|
+ .setEMail(StringUtils.trim(email))
|
|
|
+ .setExamineStatus(ExamineStatusEnum.WAIT.getKey())
|
|
|
+ .insert();
|
|
|
+ }
|
|
|
}
|