|  | @@ -24,7 +24,6 @@ import com.ym.mec.common.entity.HttpResponseResult;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.entity.ImGroupMember;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.exception.BizException;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.page.PageInfo;
 | 
	
		
			
				|  |  | -import com.ym.mec.common.page.WrapperUtil;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.service.IdGeneratorService;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.service.impl.BaseServiceImpl;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.tenant.TenantContextHolder;
 | 
	
	
		
			
				|  | @@ -46,7 +45,6 @@ import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.io.IOException;
 | 
	
		
			
				|  |  |  import java.math.BigDecimal;
 | 
	
		
			
				|  |  | -import java.math.RoundingMode;
 | 
	
		
			
				|  |  |  import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  |  import java.util.*;
 | 
	
		
			
				|  |  |  import java.util.concurrent.atomic.AtomicInteger;
 | 
	
	
		
			
				|  | @@ -69,7 +67,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private TeacherDao teacherDao;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  | -    private StudentDao studentDao;
 | 
	
		
			
				|  |  | +    private StudentService studentService;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private IdGeneratorService idGeneratorService;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
	
		
			
				|  | @@ -173,8 +171,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private GoodsDao goodsDao;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  | -    private SysUserCashAccountDao sysUserCashAccountDao;
 | 
	
		
			
				|  |  | -    @Autowired
 | 
	
		
			
				|  |  |      private ContractService contractService;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private StudentPreRegistrationDao studentPreRegistrationDao;
 | 
	
	
		
			
				|  | @@ -324,9 +320,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |      public boolean preRegister(StudentPreRegistration studentPreRegistration) {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          String musicGroupId = studentPreRegistration.getMusicGroupId();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          // 查询乐团状态
 | 
	
		
			
				|  |  |          MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
 | 
	
		
			
				|  |  |          if (musicGroup == null) {
 | 
	
	
		
			
				|  | @@ -335,69 +329,24 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          if (musicGroup.getStatus() != MusicGroupStatusEnum.PRE_APPLY) {
 | 
	
		
			
				|  |  |              throw new BizException("乐团当前状态不能预报名");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          StudentPreRegistration originRegistration = studentPreRegistrationDao.queryByMusicGroupIdAndPhone(studentPreRegistration.getPhone(), musicGroupId);
 | 
	
		
			
				|  |  |          if (originRegistration != null) {
 | 
	
		
			
				|  |  |              throw new BizException("您已预报名成功,请勿重复提交资料");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        Date date = new Date();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        // 判断用户是否存在
 | 
	
		
			
				|  |  | -        SysUser user = sysUserFeignService.queryUserByMobile(studentPreRegistration.getPhone());
 | 
	
		
			
				|  |  | -        if (user == null || user.getId() == null) {
 | 
	
		
			
				|  |  | -            user = new SysUser();
 | 
	
		
			
				|  |  | -            user.setPhone(studentPreRegistration.getPhone());
 | 
	
		
			
				|  |  | -            user.setUsername(studentPreRegistration.getUserName());
 | 
	
		
			
				|  |  | -            user.setOrganId(musicGroup.getOrganId());
 | 
	
		
			
				|  |  | -            user.setUserType("STUDENT");
 | 
	
		
			
				|  |  | -            user.setCreateTime(date);
 | 
	
		
			
				|  |  | -            user.setUpdateTime(date);
 | 
	
		
			
				|  |  | -            // 注册账户信息
 | 
	
		
			
				|  |  | -            HttpResponseResult<Integer> result = sysUserFeignService.addUser(user);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            Integer userId = result.getData();
 | 
	
		
			
				|  |  | -            user.setId(userId);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            Student student = new Student();
 | 
	
		
			
				|  |  | -            student.setUserId(userId);
 | 
	
		
			
				|  |  | -            student.setCreateTime(date);
 | 
	
		
			
				|  |  | -            student.setUpdateTime(date);
 | 
	
		
			
				|  |  | -            student.setIsNewUser(true);
 | 
	
		
			
				|  |  | -            student.setCurrentGradeNum(studentPreRegistration.getCurrentGradeNum());
 | 
	
		
			
				|  |  | -            student.setCurrentClass(studentPreRegistration.getCurrentClass());
 | 
	
		
			
				|  |  | -            studentDao.insert(student);
 | 
	
		
			
				|  |  | -            sysUserCashAccountDao.insert(new SysUserCashAccount(userId, "CNY"));
 | 
	
		
			
				|  |  | -        } else {
 | 
	
		
			
				|  |  | -            if (musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE) {
 | 
	
		
			
				|  |  | -                //该学员是否在其他的会员团
 | 
	
		
			
				|  |  | -                boolean hasMemberGroup = studentRegistrationDao.checkHasMemberGroup(musicGroupId, user.getId());
 | 
	
		
			
				|  |  | -                if (hasMemberGroup) {
 | 
	
		
			
				|  |  | -                    throw new BizException("乐团报名失败:该学员已在其他系统收费乐团中,不可报名该乐团请联系教务老师");
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            user.setUsername(studentPreRegistration.getUserName());
 | 
	
		
			
				|  |  | -            if (!user.getUserType().contains("STUDENT")) {
 | 
	
		
			
				|  |  | -                user.setUserType(user.getUserType() + ",STUDENT");
 | 
	
		
			
				|  |  | +        studentPreRegistration.setTenantId(musicGroup.getTenantId());
 | 
	
		
			
				|  |  | +        studentPreRegistration.setOrganId(musicGroup.getOrganId());
 | 
	
		
			
				|  |  | +        //保存学员信息
 | 
	
		
			
				|  |  | +        SysUser user = studentService.upSetStudent(studentPreRegistration);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                Integer userId = user.getId();
 | 
	
		
			
				|  |  | -                //添加student
 | 
	
		
			
				|  |  | -                Student student = new Student();
 | 
	
		
			
				|  |  | -                student.setUserId(userId);
 | 
	
		
			
				|  |  | -                student.setCreateTime(date);
 | 
	
		
			
				|  |  | -                student.setUpdateTime(date);
 | 
	
		
			
				|  |  | -                student.setIsNewUser(true);
 | 
	
		
			
				|  |  | -                student.setCurrentGradeNum(studentPreRegistration.getCurrentGradeNum());
 | 
	
		
			
				|  |  | -                student.setCurrentClass(studentPreRegistration.getCurrentClass());
 | 
	
		
			
				|  |  | -                studentDao.insert(student);
 | 
	
		
			
				|  |  | +        if (musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE) {
 | 
	
		
			
				|  |  | +            //该学员是否在其他的会员团
 | 
	
		
			
				|  |  | +            boolean hasMemberGroup = studentRegistrationDao.checkHasMemberGroup(musicGroupId, user.getId());
 | 
	
		
			
				|  |  | +            if (hasMemberGroup) {
 | 
	
		
			
				|  |  | +                throw new BizException("乐团报名失败:该学员已在其他系统收费乐团中,不可报名该乐团请联系教务老师");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            user.setUpdateTime(new Date());
 | 
	
		
			
				|  |  | -            teacherDao.updateUser(user);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        studentPreRegistration.setCreateTime(date);
 | 
	
		
			
				|  |  | -        studentPreRegistration.setUserId(user.getId());
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          Organization organization = organizationDao.get(musicGroup.getOrganId());
 | 
	
		
			
				|  |  |          if (organization.getGradeType().equals(GradeTypeEnum.SIX_PLUS)) {
 | 
	
		
			
				|  |  |              for (SixPlusGradeEnum value : SixPlusGradeEnum.values()) {
 | 
	
	
		
			
				|  | @@ -414,12 +363,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          studentPreRegistrationDao.insert(studentPreRegistration);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          // 添加成员
 | 
	
		
			
				|  |  |          imGroupMemberService.join(Long.parseLong(musicGroupId), user.getId(), null, false);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          return true;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1680,7 +1626,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          //获取对外课程务老师
 | 
	
		
			
				|  |  |          teacherIds.addAll(teacherDao.findCommEducationalTeacherId(studentId));
 | 
	
		
			
				|  |  |          //获取关联的指导老师
 | 
	
		
			
				|  |  | -        Student student = studentDao.get(studentId);
 | 
	
		
			
				|  |  | +        Student student = studentService.get(studentId);
 | 
	
		
			
				|  |  |          if (student != null && student.getTeacherId() != null) {
 | 
	
		
			
				|  |  |              teacherIds.add(student.getTeacherId());
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -2962,7 +2908,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          if (user == null) {
 | 
	
		
			
				|  |  |              throw new BizException("学员 {} 信息不存在", userId);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        Student student = studentDao.get(userId);
 | 
	
		
			
				|  |  | +        Student student = studentService.get(userId);
 | 
	
		
			
				|  |  |          if (student == null) {
 | 
	
		
			
				|  |  |              throw new BizException("学员 {} 信息不存在", userId);
 | 
	
		
			
				|  |  |          }
 |