Browse Source

更新手机号BUG修改

chenw 6 years ago
parent
commit
2c2a327919

+ 17 - 8
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/StudentServiceImpl.java

@@ -15,10 +15,7 @@ import com.usoftchina.smartschool.school.dto.BatchDealBaseDTO;
 import com.usoftchina.smartschool.school.dto.DocBaseDTO;
 import com.usoftchina.smartschool.school.dto.ListReqDTO;
 import com.usoftchina.smartschool.school.exception.BizExceptionCode;
-import com.usoftchina.smartschool.school.mapper.DataImportMapper;
-import com.usoftchina.smartschool.school.mapper.SysClazzMapper;
-import com.usoftchina.smartschool.school.mapper.SysGradeMapper;
-import com.usoftchina.smartschool.school.mapper.SysStudentMapper;
+import com.usoftchina.smartschool.school.mapper.*;
 import com.usoftchina.smartschool.school.po.*;
 import com.usoftchina.smartschool.school.wxschool.mapper.WxUserMapper;
 import com.usoftchina.smartschool.utils.CollectionUtils;
@@ -48,6 +45,8 @@ public class StudentServiceImpl implements StudentService{
     @Autowired
     private SysGradeMapper sysGradeMapper;
     @Autowired
+    private SysTeacherMapper sysTeacherMapper;
+    @Autowired
     private SysClazzMapper sysClazzMapper;
     @Autowired
     private MessageLogService messageLogService;
@@ -174,12 +173,22 @@ public class StudentServiceImpl implements StudentService{
             //更新账户信息表的手机号
             for (SysParents item : updateDetails) {
                 SysParents sysParents = sysStudentMapper.selectParentById(item.getParent_id());
-                if (ObjectUtils.isEmpty(sysParents)) {
+                if (!ObjectUtils.isEmpty(sysParents)) {
                     if (item.getPa_phone().equals(sysParents.getPa_phone())) {
                         UserDO userDO = new UserDO();
-                        userDO.setUserId(item.getUser_id());
-                        userDO.setUserPhone(item.getPa_phone());
-                        userMapper.update(userDO);
+                        UserDO oldUserDO = userMapper.selectUserByPhone(sysParents.getPa_phone());
+                        if (!ObjectUtils.isEmpty(oldUserDO)) {
+                            userDO.setUserId(oldUserDO.getUserId());
+                            userDO.setUserPhone(item.getPa_phone());
+                            userMapper.update(userDO);
+                            SysTeacher oldSysTeacher = sysTeacherMapper.selectByPhone(sysParents.getPa_phone(), schoolid);
+                            if (!ObjectUtils.isEmpty(oldSysTeacher)){
+                                SysTeacher sysTeacher = new SysTeacher();
+                                sysTeacher.setTeacher_phone(item.getPa_phone());
+                                sysTeacher.setTeacher_id(oldSysTeacher.getTeacher_id());
+                                sysTeacherMapper.updateByPrimaryKeySelective(sysTeacher);
+                            }
+                        }
                     }
                 }
             }