|
@@ -86,11 +86,7 @@ private FamilyInvitationService familyInvitationService;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (user == null) {
|
|
if (user == null) {
|
|
|
- // 5. 没有phoneCode也无法通过手机号找到用户 → 不能自动创建(避免mock→真实openid迁移时产生重复用户)
|
|
|
|
|
- if (phone == null) {
|
|
|
|
|
- throw new RuntimeException("用户不存在,请先授权手机号后登录");
|
|
|
|
|
- }
|
|
|
|
|
- // 6. 有phoneCode且查不到 → 全新用户,创建新家庭和用户
|
|
|
|
|
|
|
+ // 5. 完全查不到 → 全新用户,自动创建
|
|
|
isNewUser = true;
|
|
isNewUser = true;
|
|
|
|
|
|
|
|
Family family = new Family();
|
|
Family family = new Family();
|
|
@@ -105,7 +101,7 @@ private FamilyInvitationService familyInvitationService;
|
|
|
user.setUnionid(unionid != null ? unionid : "");
|
|
user.setUnionid(unionid != null ? unionid : "");
|
|
|
user.setFamilyId(family.getId());
|
|
user.setFamilyId(family.getId());
|
|
|
user.setRole("parent");
|
|
user.setRole("parent");
|
|
|
- user.setNickname(dto.getNickname() != null ? dto.getNickname() : "用户" + phone.substring(7));
|
|
|
|
|
|
|
+ user.setNickname(dto.getNickname() != null ? dto.getNickname() : (phone != null ? "用户" + phone.substring(7) : "微信用户"));
|
|
|
user.setAvatar(dto.getAvatar());
|
|
user.setAvatar(dto.getAvatar());
|
|
|
user.setPhone(phone);
|
|
user.setPhone(phone);
|
|
|
user.setPassword("");
|
|
user.setPassword("");
|
|
@@ -114,7 +110,7 @@ private FamilyInvitationService familyInvitationService;
|
|
|
userMapper.insert(user);
|
|
userMapper.insert(user);
|
|
|
try { onboardingService.initForUser(user.getId()); onboardingService.completeTask(user.getId(), "REGISTER"); } catch (Exception e) { /* onboarding init failure should not block login */ }
|
|
try { onboardingService.initForUser(user.getId()); onboardingService.completeTask(user.getId(), "REGISTER"); } catch (Exception e) { /* onboarding init failure should not block login */ }
|
|
|
} else {
|
|
} else {
|
|
|
- // 7. 手机号已存在但openid不同,绑定openid
|
|
|
|
|
|
|
+ // 6. 手机号已存在但openid不同,绑定openid
|
|
|
user.setOpenid(openid);
|
|
user.setOpenid(openid);
|
|
|
user.setUnionid(unionid != null ? unionid : "");
|
|
user.setUnionid(unionid != null ? unionid : "");
|
|
|
user.setUpdatedAt(new Date());
|
|
user.setUpdatedAt(new Date());
|