|
@@ -368,6 +368,43 @@ public class AppLoginController extends AppBaseController{
|
|
|
@PostMapping("/loginByApple")
|
|
@PostMapping("/loginByApple")
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public R loginByApple(@Validated @RequestBody FsUserLoginByAppleParam param) {
|
|
public R loginByApple(@Validated @RequestBody FsUserLoginByAppleParam param) {
|
|
|
|
|
+// try {
|
|
|
|
|
+// if (StringUtils.isEmpty(param.getAppleKey())) {
|
|
|
|
|
+// return R.error("获取苹果key失败");
|
|
|
|
|
+// }
|
|
|
|
|
+// // 根据苹果key查询用户
|
|
|
|
|
+// FsUser user = userMapper.findUserByAppleKey(param.getAppleKey());
|
|
|
|
|
+// Map<String, Object> map = new HashMap<>();
|
|
|
|
|
+// if (user == null) {
|
|
|
|
|
+// map.put("isNew", true);
|
|
|
|
|
+// return R.ok(map);
|
|
|
|
|
+// } else {
|
|
|
|
|
+// if (StringUtils.isNotEmpty(param.getJpushId())) {
|
|
|
|
|
+// updateExistingUserJpushId(user, param.getJpushId());
|
|
|
|
|
+// }
|
|
|
|
|
+// if (StringUtils.isEmpty(user.getPhone())) {
|
|
|
|
|
+// map.put("isNew", true);
|
|
|
|
|
+// return R.ok(map);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// // 更新登录设备信息
|
|
|
|
|
+// updateLoginDevice(user.getUserId(), param.getLoginDevice(), param.getSource());
|
|
|
|
|
+//
|
|
|
|
|
+// /*if (user.getStatus()==0){
|
|
|
|
|
+// return R.error("登录失败,账户被禁用");
|
|
|
|
|
+// }*/
|
|
|
|
|
+// int isFirstLogin = userNewTaskService.performTaskOne(user.getUserId());
|
|
|
|
|
+// String token = jwtUtils.generateToken(user.getUserId());
|
|
|
|
|
+// redisCache.setCacheObject("userToken:" + user.getUserId(), token, 604800, TimeUnit.SECONDS);
|
|
|
|
|
+// map.put("token", token);
|
|
|
|
|
+// map.put("user", user);
|
|
|
|
|
+// map.put("isFirst",isFirstLogin);
|
|
|
|
|
+// return R.ok(map);
|
|
|
|
|
+// }catch (Exception e){
|
|
|
|
|
+// logger.error("zyp 苹果登录失败:{}", e.getMessage());
|
|
|
|
|
+// return R.error("登录失败");
|
|
|
|
|
+// }
|
|
|
try {
|
|
try {
|
|
|
if (StringUtils.isEmpty(param.getAppleKey())) {
|
|
if (StringUtils.isEmpty(param.getAppleKey())) {
|
|
|
return R.error("获取苹果key失败");
|
|
return R.error("获取苹果key失败");
|
|
@@ -375,22 +412,54 @@ public class AppLoginController extends AppBaseController{
|
|
|
// 根据苹果key查询用户
|
|
// 根据苹果key查询用户
|
|
|
FsUser user = userMapper.findUserByAppleKey(param.getAppleKey());
|
|
FsUser user = userMapper.findUserByAppleKey(param.getAppleKey());
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
+ // 因苹果审核问题, 如果开关打开 则创建新用户 ,若开关关闭需要校验 unionId
|
|
|
|
|
+ String key="appleCheckFlag";
|
|
|
|
|
+ Boolean flag =redisCache.getCacheObject(key);
|
|
|
|
|
+ if(flag==null){
|
|
|
|
|
+ flag =false; // 默认关闭
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (user == null) {
|
|
if (user == null) {
|
|
|
- map.put("isNew", true);
|
|
|
|
|
- return R.ok(map);
|
|
|
|
|
|
|
+ if( flag){
|
|
|
|
|
+ user = new FsUser();
|
|
|
|
|
+ user.setLoginDevice(param.getLoginDevice()!=null ? param.getLoginDevice() : null);
|
|
|
|
|
+ user.setSource(param.getSource()!=null ? param.getSource() : null);
|
|
|
|
|
+ user.setAppleKey(param.getAppleKey());
|
|
|
|
|
+ user.setNickName("苹果用户");
|
|
|
|
|
+ user.setCreateTime(new Date());
|
|
|
|
|
+ user.setAppCreateTime(new Date());
|
|
|
|
|
+ user.setStatus(1);
|
|
|
|
|
+ user.setAvatar("https://cos.his.cdwjyyh.com/fs/20240926/420728ee06e54575ba82665dedb4756b.png");
|
|
|
|
|
+ if (StringUtils.isNotEmpty(param.getJpushId())) {
|
|
|
|
|
+ user.setJpushId(param.getJpushId());
|
|
|
|
|
+ }
|
|
|
|
|
+ userService.insertFsUser(user);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ map.put("isNew", true); // 新账户,使用微信登录绑定appleKey
|
|
|
|
|
+ return R.ok(map);
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
if (StringUtils.isNotEmpty(param.getJpushId())) {
|
|
if (StringUtils.isNotEmpty(param.getJpushId())) {
|
|
|
updateExistingUserJpushId(user, param.getJpushId());
|
|
updateExistingUserJpushId(user, param.getJpushId());
|
|
|
|
|
+ try {
|
|
|
|
|
+ //发送注册优惠券
|
|
|
|
|
+ fsUserCouponService.sendRegisterCoupon(user);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ logger.error("发送注册优惠券失败:{}",e.getMessage());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- if (StringUtils.isEmpty(user.getPhone())) {
|
|
|
|
|
|
|
+ // 审核通过后才校验
|
|
|
|
|
+ if (!flag && StringUtils.isEmpty(user.getUnionId())) {
|
|
|
map.put("isNew", true);
|
|
map.put("isNew", true);
|
|
|
return R.ok(map);
|
|
return R.ok(map);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // 更新登录设备信息
|
|
|
|
|
- updateLoginDevice(user.getUserId(), param.getLoginDevice(), param.getSource());
|
|
|
|
|
-
|
|
|
|
|
|
|
+ if(user.getAppCreateTime()== null){
|
|
|
|
|
+ FsUser update = new FsUser();
|
|
|
|
|
+ update.setAppCreateTime(new Date());
|
|
|
|
|
+ update.setUserId(user.getUserId());
|
|
|
|
|
+ userService.updateFsUser(update);
|
|
|
|
|
+ }
|
|
|
/*if (user.getStatus()==0){
|
|
/*if (user.getStatus()==0){
|
|
|
return R.error("登录失败,账户被禁用");
|
|
return R.error("登录失败,账户被禁用");
|
|
|
}*/
|
|
}*/
|
|
@@ -405,6 +474,7 @@ public class AppLoginController extends AppBaseController{
|
|
|
logger.error("zyp 苹果登录失败:{}", e.getMessage());
|
|
logger.error("zyp 苹果登录失败:{}", e.getMessage());
|
|
|
return R.error("登录失败");
|
|
return R.error("登录失败");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private FsUser createNewAppleUser(FsUserEditPhoneParam param, String phoneNumber) {
|
|
private FsUser createNewAppleUser(FsUserEditPhoneParam param, String phoneNumber) {
|