|
@@ -6,12 +6,17 @@ import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
+import com.ym.mec.biz.dal.dao.SubjectDao;
|
|
|
import com.ym.mec.biz.dal.dao.TeacherDao;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
|
|
|
+import com.ym.mec.common.entity.ImResult;
|
|
|
+import com.ym.mec.common.entity.ImUserModel;
|
|
|
+import com.ym.mec.im.ImFeignService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -44,14 +49,16 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
@Resource
|
|
|
private StudentRegistrationDao studentRegistrationDao;
|
|
|
@Autowired
|
|
|
- private SysUserFeignService sysUserFeignService;
|
|
|
- @Autowired
|
|
|
private StudentPaymentOrderService studentPaymentOrderService;
|
|
|
@Autowired
|
|
|
private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
|
|
|
@Autowired
|
|
|
private TeacherDao teacherDao;
|
|
|
@Autowired
|
|
|
+ private SubjectDao subjectDao;
|
|
|
+ @Autowired
|
|
|
+ private ImFeignService imFeignService;
|
|
|
+ @Autowired
|
|
|
private MusicGroupSubjectPlanService musicGroupSubjectPlanService;
|
|
|
|
|
|
@Override
|
|
@@ -102,13 +109,31 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<StudentRegistration> getNoClassStuBySubjectId(String musicGroupId, Integer actualSubjectId) {
|
|
|
- return studentRegistrationDao.getNoClassStuBySubjectId(musicGroupId, actualSubjectId);
|
|
|
+ public List<Map<String,Object>> getNoClassStuBySubjectId(String musicGroupId, String actualSubjectId) {
|
|
|
+ List<StudentRegistration> students = studentRegistrationDao.getNoClassStuBySubjectId(musicGroupId, actualSubjectId);
|
|
|
+ List<Map<String,Object>> mapArrayList = new ArrayList<>();
|
|
|
+ if(students != null && students.size() > 0){
|
|
|
+ String[] subjectIds = actualSubjectId.split(",");
|
|
|
+ if(subjectIds != null && subjectIds.length > 0){
|
|
|
+ List<Map<Integer, String>> subjectNames = subjectDao.queryNameByIds(actualSubjectId);
|
|
|
+ Map<Integer, String> subjectNameMap = MapUtil.convertMybatisMap(subjectNames);
|
|
|
+ for (int i = 0;i<subjectIds.length;i++){
|
|
|
+ Map<String,Object> resultMap = new HashMap<>(3);
|
|
|
+ int subjectId = Integer.parseInt(subjectIds[i]);
|
|
|
+ List<StudentRegistration> collect = students.stream().filter(e -> e.getSubjectId().equals(subjectId)).collect(Collectors.toList());
|
|
|
+ resultMap.put("subjectId",subjectId);
|
|
|
+ resultMap.put("subjectName",subjectNameMap.get(subjectId));
|
|
|
+ resultMap.put("rows",collect);
|
|
|
+ mapArrayList.add(resultMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return mapArrayList;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Integer getNoClassStuCountBySubjectId(String musicGroupId, Integer actualSubjectId) {
|
|
|
- return studentRegistrationDao.getNoClassStuCountBySubjectId(musicGroupId, actualSubjectId);
|
|
|
+ public List<Map<Integer,Long>> getNoClassStuCountBySubjectId(String musicGroupId) {
|
|
|
+ return studentRegistrationDao.getNoClassStuCountBySubjectId(musicGroupId);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -324,4 +349,33 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
return studentRegistrationDao.getByPhoneAndMusicGroupId(musicGroupId, parentsPhone);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Integer insertStudent(StudentRegistration studentRegistration) throws Exception {
|
|
|
+ StudentRegistration phoneAndMusicGroupId = studentRegistrationDao.getByPhoneAndMusicGroupId(studentRegistration.getMusicGroupId(), studentRegistration.getParentsPhone());
|
|
|
+ if(phoneAndMusicGroupId != null){
|
|
|
+ throw new Exception("该学员已存在");
|
|
|
+ }else {
|
|
|
+ SysUser sysUser = studentRegistrationDao.getSysUserByPhone(studentRegistration.getParentsPhone());
|
|
|
+ if(sysUser == null){
|
|
|
+ //新增user
|
|
|
+ sysUser = new SysUser();
|
|
|
+ sysUser.setRealName(studentRegistration.getName());
|
|
|
+ sysUser.setUsername(studentRegistration.getName());
|
|
|
+ sysUser.setGender(studentRegistration.getGender());
|
|
|
+ sysUser.setUserType(SysUserType.STUDENT);
|
|
|
+ teacherDao.addSysUser(sysUser);
|
|
|
+ //注册到融云
|
|
|
+ ImResult register = imFeignService.register(new ImUserModel(sysUser.getId().toString(), sysUser.getUsername(), sysUser.getAvatar()));
|
|
|
+ sysUser.setImToken(register.getToken());
|
|
|
+ teacherDao.updateUser(sysUser);
|
|
|
+ }
|
|
|
+ //学生报名表
|
|
|
+ studentRegistrationDao.insert(studentRegistration);
|
|
|
+ //学生注册
|
|
|
+ //缴费金额
|
|
|
+ //学员加入的金额
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
}
|