|
@@ -2,6 +2,7 @@ package com.gree.mall.miniapp.logic.user;
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
@@ -739,53 +740,58 @@ public class UserLogic {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private User initAppUser(AdminCompanyWechat wechat, String mobile) throws Exception {
|
|
private User initAppUser(AdminCompanyWechat wechat, String mobile) throws Exception {
|
|
|
- User user = userService.lambdaQuery()
|
|
|
|
|
- .eq(User::getMobile, mobile)
|
|
|
|
|
- .eq(User::getType, UserTypeEnum.WORKER.getKey())
|
|
|
|
|
- .last("limit 1")
|
|
|
|
|
- .one();
|
|
|
|
|
- UserWait userWait = null;
|
|
|
|
|
- if (Objects.isNull(user)) {
|
|
|
|
|
- // 师傅信息没有就查找初始化师傅表
|
|
|
|
|
- userWait = userWaitService.lambdaQuery()
|
|
|
|
|
- .eq(UserWait::getMobile, mobile)
|
|
|
|
|
- .eq(UserWait::getUserType, UserTypeEnum.WORKER.getKey())
|
|
|
|
|
- .last("limit 1")
|
|
|
|
|
- .one();
|
|
|
|
|
-
|
|
|
|
|
- // 没有师傅信息抛出错误
|
|
|
|
|
- if (Objects.isNull(userWait)) {
|
|
|
|
|
- throw new RemoteServiceException("无师傅信息");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
String key = Constant.RedisPrefix.LOCK_AUTH + ":" + mobile;
|
|
String key = Constant.RedisPrefix.LOCK_AUTH + ":" + mobile;
|
|
|
Lock obtain = redisLockRegistry.obtain(key);
|
|
Lock obtain = redisLockRegistry.obtain(key);
|
|
|
if (!obtain.tryLock(2, TimeUnit.SECONDS)) {
|
|
if (!obtain.tryLock(2, TimeUnit.SECONDS)) {
|
|
|
log.error("请勿重复登录");
|
|
log.error("请勿重复登录");
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
try {
|
|
try {
|
|
|
- //如果用户不存在则新注册
|
|
|
|
|
|
|
+ User user = userService.lambdaQuery()
|
|
|
|
|
+ .eq(User::getMobile, mobile)
|
|
|
|
|
+ .eq(User::getType, UserTypeEnum.WORKER.getKey())
|
|
|
|
|
+ .last("limit 1")
|
|
|
|
|
+ .one();
|
|
|
|
|
+ UserWait userWait;
|
|
|
if (Objects.isNull(user)) {
|
|
if (Objects.isNull(user)) {
|
|
|
- user = new User();
|
|
|
|
|
- user.setUserId(userWait.getWorkerNumber());
|
|
|
|
|
- user.setLastLoginTime(new Date());
|
|
|
|
|
- user.setCreateTime(new Date());
|
|
|
|
|
- user.setMobile(mobile);
|
|
|
|
|
|
|
+ // 师傅信息没有就查找初始化师傅表
|
|
|
|
|
+ userWait = userWaitService.lambdaQuery()
|
|
|
|
|
+ .eq(UserWait::getMobile, mobile)
|
|
|
|
|
+ .eq(UserWait::getUserType, UserTypeEnum.WORKER.getKey())
|
|
|
|
|
+ .last("limit 1")
|
|
|
|
|
+ .one();
|
|
|
|
|
+
|
|
|
|
|
+ if (Objects.isNull(userWait)) {
|
|
|
|
|
+ // 如果初始化师傅信息表没有,就注册一个
|
|
|
|
|
+ user = new User();
|
|
|
|
|
+ user.setUserId(IdWorker.getIdStr())
|
|
|
|
|
+ .setCreateTime(new Date())
|
|
|
|
|
+ .setOpenId(user.getUserId())
|
|
|
|
|
+ .setWorkerNumber(user.getUserId())
|
|
|
|
|
+ .setMobile(mobile)
|
|
|
|
|
+ .setNickName("user_" + IdUtil.simpleUUID());
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 否则按初始化信息新注册
|
|
|
|
|
+ user = new User();
|
|
|
|
|
+ user.setUserId(userWait.getWorkerNumber())
|
|
|
|
|
+ .setCreateTime(new Date())
|
|
|
|
|
+ .setMobile(mobile);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
userService.save(user);
|
|
userService.save(user);
|
|
|
- } else {
|
|
|
|
|
- //如果用户存在,并更新相关信息
|
|
|
|
|
- if (!user.getStatus()) {
|
|
|
|
|
- throw new RemoteServiceException("用户已被冻结");
|
|
|
|
|
|
|
+ if (Objects.nonNull(userWait)) {
|
|
|
|
|
+ this.userTypeInit2(user);
|
|
|
}
|
|
}
|
|
|
- user.setLastLoginTime(new Date());
|
|
|
|
|
- //授权手机号
|
|
|
|
|
- user.updateById();
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- this.userTypeInit2(user);
|
|
|
|
|
|
|
+ //如果用户存在,并更新相关信息
|
|
|
|
|
+ if (!user.getStatus()) {
|
|
|
|
|
+ throw new RemoteServiceException("用户已被冻结");
|
|
|
|
|
+ }
|
|
|
|
|
+ user.setLastLoginTime(new Date());
|
|
|
|
|
+ //授权手机号
|
|
|
|
|
+ user.updateById();
|
|
|
|
|
|
|
|
return user;
|
|
return user;
|
|
|
} finally {
|
|
} finally {
|