Browse Source

1.同账号问题修改

yuanliang 1 year ago
parent
commit
632e3dd093

+ 15 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/StudentServiceImpl.java

@@ -699,7 +699,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
         if (!student.getPhone().equals(studentInfo.getPhone())) {
             updatePhone = true;
             SysUser oldSysUser = sysUserMapper.getByUserId(studentInfo.getId());
-            com.yonge.cooleshow.biz.dal.entity.SysUser sysUser = getOrCreateAccount(studentInfo, oldSysUser.getPassword());
+            com.yonge.cooleshow.biz.dal.entity.SysUser sysUser = updateAccount(studentInfo, oldSysUser);
             this.lambdaUpdate().set(Student::getSubjectId, studentInfo.getSubjectId())
                     .set(Student::getTenantId, studentInfo.getTenantId())
                     .set(Student::getUserId, sysUser.getId())
@@ -924,6 +924,20 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
         return sysUser;
     }
 
+    private com.yonge.cooleshow.biz.dal.entity.SysUser updateAccount(StudentWrapper.Student studentInfo,SysUser oldSysUser) {
+        QueryWrapper<com.yonge.cooleshow.biz.dal.entity.SysUser> sysUserQueryWrapper = new QueryWrapper<>();
+        sysUserQueryWrapper.lambda().eq(com.yonge.cooleshow.biz.dal.entity.SysUser::getPhone, studentInfo.getPhone());
+        List<com.yonge.cooleshow.biz.dal.entity.SysUser> sysUsers = sysUserMapper.selectList(sysUserQueryWrapper);
+        if (!sysUsers.isEmpty()) {
+            throw new BizException("手机号已经注册账号");
+        } else {
+            oldSysUser.setPhone(studentInfo.getPhone());
+            com.yonge.cooleshow.biz.dal.entity.SysUser sysUser = JSON.parseObject(JSON.toJSONString(oldSysUser), com.yonge.cooleshow.biz.dal.entity.SysUser.class);
+            sysUserMapper.updateById(sysUser);
+            return sysUser;
+        }
+    }
+
     /**
      * 更新学生关联帐号
      *