|
|
@@ -14,6 +14,8 @@ import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.common.exception.ServiceException;
|
|
|
import com.fs.common.service.ISmsService;
|
|
|
import com.fs.common.utils.sign.Md5Utils;
|
|
|
+import com.fs.company.domain.CompanyUser;
|
|
|
+import com.fs.company.service.ICompanyUserService;
|
|
|
import com.fs.core.config.WxOpenProperties;
|
|
|
import com.fs.course.domain.FsCoursePlaySourceConfig;
|
|
|
import com.fs.course.service.IFsCoursePlaySourceConfigService;
|
|
|
@@ -24,6 +26,7 @@ import com.fs.his.service.IFsUserCouponService;
|
|
|
import com.fs.his.service.IFsUserNewTaskService;
|
|
|
import com.fs.his.service.IFsUserService;
|
|
|
import com.fs.his.vo.FsUserRegisterParam;
|
|
|
+import com.fs.im.service.OpenIMService;
|
|
|
import com.fs.watch.domain.WatchDeviceSetup;
|
|
|
import com.fs.watch.domain.WatchUser;
|
|
|
import com.fs.watch.service.WatchUserService;
|
|
|
@@ -43,6 +46,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
import static com.fs.his.utils.PhoneUtil.encryptPhone;
|
|
|
import static com.fs.his.utils.PhoneUtil.encryptPhoneOldKey;
|
|
|
@@ -54,6 +58,7 @@ import static com.fs.his.utils.PhoneUtil.encryptPhoneOldKey;
|
|
|
public class AppLoginController extends AppBaseController{
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
private static final String INTERNAL_LOGIN_CODE = "EdisonX!@#.+-123";
|
|
|
+ private static final Pattern PHONE_PATTERN = Pattern.compile("^1\\d{10}$");
|
|
|
@Autowired
|
|
|
private IFsUserService userService;
|
|
|
@Autowired
|
|
|
@@ -73,6 +78,10 @@ public class AppLoginController extends AppBaseController{
|
|
|
private ISmsService smsService;
|
|
|
@Autowired
|
|
|
private IFsCoursePlaySourceConfigService fsCoursePlaySourceConfigService;
|
|
|
+ @Autowired
|
|
|
+ private OpenIMService openIMService;
|
|
|
+ @Autowired
|
|
|
+ private ICompanyUserService companyUserService;
|
|
|
|
|
|
@ApiOperation("注册app用户")
|
|
|
@PostMapping("/register")
|
|
|
@@ -98,6 +107,7 @@ public class AppLoginController extends AppBaseController{
|
|
|
userService.updateFsUser(user);
|
|
|
// 注册也视为首次使用 app:补写首次登录时间并发放奖励(如符合条件)
|
|
|
userNewTaskService.performFirstLoginApp(fsUser.getUserId());
|
|
|
+ bindCompanyUserInfoByPhone(fsUser);
|
|
|
return R.ok("注册成功");
|
|
|
} else {
|
|
|
// 创建新用户
|
|
|
@@ -111,6 +121,7 @@ public class AppLoginController extends AppBaseController{
|
|
|
if (userService.insertFsUser(user) > 0) {
|
|
|
// 注册也视为首次使用 app:补写首次登录时间并发放奖励(如符合条件)
|
|
|
userNewTaskService.performFirstLoginApp(user.getUserId());
|
|
|
+ bindCompanyUserInfoByPhone(user);
|
|
|
return R.ok("注册成功");
|
|
|
} else {
|
|
|
return R.error("注册失败");
|
|
|
@@ -304,18 +315,16 @@ public class AppLoginController extends AppBaseController{
|
|
|
userService.insertFsUser(user);
|
|
|
// 新用户第一次使用 app:补写首次登录时间并发放积分(如符合条件)
|
|
|
userNewTaskService.performFirstLoginApp(user.getUserId());
|
|
|
- map.put("isNew", true);
|
|
|
+// map.put("isNew", true);
|
|
|
map.put("unionid",unionid);
|
|
|
- return R.ok(map);
|
|
|
} else {
|
|
|
if (StringUtils.isNotEmpty(param.getJpushId())) {
|
|
|
user.setAppOpenId(openid);
|
|
|
updateExistingUserJpushId(user, param.getJpushId());
|
|
|
}
|
|
|
if (StringUtils.isEmpty(user.getPhone())) {
|
|
|
- map.put("isNew", true);
|
|
|
+// map.put("isNew", true);
|
|
|
map.put("unionid",user.getUnionId());
|
|
|
- return R.ok(map);
|
|
|
}
|
|
|
}
|
|
|
int isFirstLogin = userNewTaskService.performTaskOne(user.getUserId());
|
|
|
@@ -331,6 +340,7 @@ public class AppLoginController extends AppBaseController{
|
|
|
map.put("isFirstLoginApp", isFirstLoginApp);
|
|
|
map.put("needFillFirstLoginRewardAddress",
|
|
|
user.getFirstLoginAppTime() != null && StringUtils.isBlank(user.getFirstLoginRewardAddress()));
|
|
|
+ bindCompanyUserInfoByPhone(user);
|
|
|
return R.ok(map);
|
|
|
}catch (Exception e){
|
|
|
logger.error("zyp 登录失败:{}", e.getMessage());
|
|
|
@@ -378,6 +388,7 @@ public class AppLoginController extends AppBaseController{
|
|
|
map.put("isFirstLoginApp", isFirstLoginApp);
|
|
|
map.put("needFillFirstLoginRewardAddress",
|
|
|
user.getFirstLoginAppTime() != null && StringUtils.isBlank(user.getFirstLoginRewardAddress()));
|
|
|
+ bindCompanyUserInfoByPhone(user);
|
|
|
return R.ok(map);
|
|
|
}catch (Exception e){
|
|
|
logger.error("zyp 苹果登录失败:{}", e.getMessage());
|
|
|
@@ -651,9 +662,49 @@ public class AppLoginController extends AppBaseController{
|
|
|
map.put("isFirstLoginApp", isFirstLoginApp);
|
|
|
map.put("needFillFirstLoginRewardAddress",
|
|
|
user.getFirstLoginAppTime() != null && StringUtils.isBlank(user.getFirstLoginRewardAddress()));
|
|
|
+ bindCompanyUserInfoByPhone(user);
|
|
|
return R.ok(map);
|
|
|
}
|
|
|
|
|
|
+ private void bindCompanyUserInfoByPhone(FsUser user) {
|
|
|
+ if (user == null || StringUtils.isBlank(user.getPhone())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String phone = normalizePhone(user.getPhone());
|
|
|
+ if (StringUtils.isBlank(phone)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ CompanyUser companyUser = companyUserService.selectCompanyUserByPhone(phone);
|
|
|
+ if (companyUser == null || !"0".equals(companyUser.getStatus()) || "1".equals(companyUser.getDelFlag())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ user.setCompanyUserId(companyUser.getUserId());
|
|
|
+ user.setCompanyUserName(companyUser.getUserName());
|
|
|
+ user.setCompanyAvatar(companyUser.getAvatar());
|
|
|
+ }
|
|
|
+
|
|
|
+ private String normalizePhone(String phone) {
|
|
|
+ if (StringUtils.isBlank(phone)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (isPhoneNumber(phone)) {
|
|
|
+ return phone;
|
|
|
+ }
|
|
|
+ String decryptPhone = com.fs.his.utils.PhoneUtil.decryptPhone(phone);
|
|
|
+ if (isPhoneNumber(decryptPhone)) {
|
|
|
+ return decryptPhone;
|
|
|
+ }
|
|
|
+ String oldDecryptPhone = com.fs.his.utils.PhoneUtil.decryptPhoneOldKey(phone);
|
|
|
+ if (isPhoneNumber(oldDecryptPhone)) {
|
|
|
+ return oldDecryptPhone;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isPhoneNumber(String phone) {
|
|
|
+ return StringUtils.isNotBlank(phone) && PHONE_PATTERN.matcher(phone).matches();
|
|
|
+ }
|
|
|
+
|
|
|
// private R handleLoginType1(FsUserLoginParam param) {
|
|
|
// if (StringUtils.isEmpty(param.getPhone()) || StringUtils.isEmpty(param.getPassword())) {
|
|
|
// return R.error("账号或密码不能为空");
|
|
|
@@ -910,6 +961,7 @@ public class AppLoginController extends AppBaseController{
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("token", token);
|
|
|
map.put("user", user);
|
|
|
+ bindCompanyUserInfoByPhone(user);
|
|
|
return R.ok(map);
|
|
|
}
|
|
|
return R.error("用户不存在!");
|
|
|
@@ -949,4 +1001,17 @@ public class AppLoginController extends AppBaseController{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取好友申请列表
|
|
|
+ *
|
|
|
+ * @param userRequestParam
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/getFriendList")
|
|
|
+ public R getFriendList(@RequestBody UserRequestParam userRequestParam)
|
|
|
+ {
|
|
|
+ return R.ok().put("data",openIMService.getFriendList(userRequestParam.getUserID(),userRequestParam.getPagination().getPageNumber(),userRequestParam.getPagination().getShowNumber(),userRequestParam.getApplyType()));
|
|
|
+ }
|
|
|
+
|
|
|
}
|