|
@@ -9,6 +9,7 @@ import javax.annotation.Resource;
|
|
|
import com.ym.mec.auth.api.entity.SysMenu;
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
+import com.ym.mec.biz.dal.enums.*;
|
|
|
import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
|
|
|
import com.ym.mec.common.entity.ImResult;
|
|
|
import com.ym.mec.common.entity.ImUserModel;
|
|
@@ -25,11 +26,6 @@ import com.ym.mec.auth.api.enums.UserLockFlag;
|
|
|
import com.ym.mec.biz.dal.dto.StudentApplyDetailDto;
|
|
|
import com.ym.mec.biz.dal.dto.StudentFeeDto;
|
|
|
import com.ym.mec.biz.dal.dto.StudentInfo;
|
|
|
-import com.ym.mec.biz.dal.enums.DealStatusEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.GoodsType;
|
|
|
-import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.OrderTypeEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.YesOrNoEnum;
|
|
|
import com.ym.mec.biz.dal.page.StudentRegistrationQueryInfo;
|
|
|
import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
|
|
|
import com.ym.mec.biz.service.StudentPaymentOrderService;
|
|
@@ -115,21 +111,21 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Map<String,Object>> getNoClassStuBySubjectId(String musicGroupId, String 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){
|
|
|
+ List<Map<String, Object>> mapArrayList = new ArrayList<>();
|
|
|
+ if (students != null && students.size() > 0) {
|
|
|
String[] subjectIds = actualSubjectId.split(",");
|
|
|
- if(subjectIds != null && subjectIds.length > 0){
|
|
|
+ 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);
|
|
|
+ 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);
|
|
|
+ resultMap.put("subjectId", subjectId);
|
|
|
+ resultMap.put("subjectName", subjectNameMap.get(subjectId));
|
|
|
+ resultMap.put("rows", collect);
|
|
|
mapArrayList.add(resultMap);
|
|
|
}
|
|
|
}
|
|
@@ -138,7 +134,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Map<Integer,Long>> getNoClassStuCountBySubjectId(String musicGroupId) {
|
|
|
+ public List<Map<Integer, Long>> getNoClassStuCountBySubjectId(String musicGroupId) {
|
|
|
return studentRegistrationDao.getNoClassStuCountBySubjectId(musicGroupId);
|
|
|
}
|
|
|
|
|
@@ -172,7 +168,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
studentRegistrationDao.insert(studentRegistration);
|
|
|
//增加报名学生数
|
|
|
MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getSubjectId());
|
|
|
- musicOneSubjectClassPlan.setApplyStudentNum(musicOneSubjectClassPlan.getApplyStudentNum()+1);
|
|
|
+ musicOneSubjectClassPlan.setApplyStudentNum(musicOneSubjectClassPlan.getApplyStudentNum() + 1);
|
|
|
return studentRegistration;
|
|
|
}
|
|
|
|
|
@@ -358,12 +354,12 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
@Override
|
|
|
public Integer insertStudent(StudentRegistration studentRegistration) throws Exception {
|
|
|
StudentRegistration phoneAndMusicGroupId = studentRegistrationDao.getByPhoneAndMusicGroupId(studentRegistration.getMusicGroupId(), studentRegistration.getParentsPhone());
|
|
|
- if(phoneAndMusicGroupId != null){
|
|
|
+ if (phoneAndMusicGroupId != null) {
|
|
|
throw new Exception("该学员已存在");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
SysUser sysUser = studentRegistrationDao.getSysUserByPhone(studentRegistration.getParentsPhone());
|
|
|
Integer userId;
|
|
|
- if(sysUser == null){
|
|
|
+ if (sysUser == null) {
|
|
|
//新增user
|
|
|
sysUser = new SysUser();
|
|
|
sysUser.setRealName(studentRegistration.getName());
|
|
@@ -376,28 +372,28 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
ImResult register = imFeignService.register(new ImUserModel(userId.toString(), sysUser.getUsername(), sysUser.getAvatar()));
|
|
|
sysUser.setImToken(register.getToken());
|
|
|
teacherDao.updateUser(sysUser);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
userId = sysUser.getId();
|
|
|
}
|
|
|
studentRegistration.setUserId(userId);
|
|
|
//学生报名表
|
|
|
studentRegistrationDao.insert(studentRegistration);
|
|
|
- if(studentRegistration.getClassGroupId() != null){
|
|
|
+ if (studentRegistration.getClassGroupId() != null) {
|
|
|
ClassGroup classGroup = classGroupDao.get(studentRegistration.getClassGroupId());
|
|
|
- if(classGroup != null){
|
|
|
- if(classGroup.getMusicGroupId().equals(studentRegistration.getMusicGroupId())){
|
|
|
+ if (classGroup != null) {
|
|
|
+ if (classGroup.getMusicGroupId().equals(studentRegistration.getMusicGroupId())) {
|
|
|
throw new Exception("班级录入错误");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//修改实际学生人数
|
|
|
classGroup.setStudentNum(classGroup.getStudentNum() + 1);
|
|
|
classGroup.setUpdateTime(new Date());
|
|
|
classGroupDao.update(classGroup);
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
throw new Exception("班级不存在");
|
|
|
}
|
|
|
//新增班级学生关系
|
|
|
- classGroupStudentMapperDao.insert(new ClassGroupStudentMapper(studentRegistration.getClassGroupId(),userId));
|
|
|
+ classGroupStudentMapperDao.insert(new ClassGroupStudentMapper(studentRegistration.getClassGroupId(), userId));
|
|
|
//乐团学生费用表
|
|
|
MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getActualSubjectId());
|
|
|
//获取当前月
|
|
@@ -405,9 +401,9 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
//获取下次缴费月份
|
|
|
List<MusicGroupPaymentCalender> musicGroupPaymentCalenders = musicGroupPaymentCalenderDao.findByMusicGroupId(studentRegistration.getMusicGroupId());
|
|
|
List<Integer> months = musicGroupPaymentCalenders.stream().map(e -> e.getPaymentMonth()).collect(Collectors.toList());
|
|
|
- for (int i = 0;i<months.size();i++){
|
|
|
- if(months.get(i).equals(month)){
|
|
|
- month = i == months.size()-1?months.get(0):months.get(i+1);
|
|
|
+ for (int i = 0; i < months.size(); i++) {
|
|
|
+ if (months.get(i).equals(month)) {
|
|
|
+ month = i == months.size() - 1 ? months.get(0) : months.get(i + 1);
|
|
|
}
|
|
|
}
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
@@ -415,8 +411,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
DateUtil.getFirstDayOfMonth(calendar.getTime());
|
|
|
//保存乐团学生费用表
|
|
|
musicGroupStudentFeeDao.insert(new MusicGroupStudentFee(studentRegistration.getMusicGroupId(),
|
|
|
- userId,studentRegistration.getSubjectId(),musicOneSubjectClassPlan.getFee(),
|
|
|
- DateUtil.getFirstDayOfMonth(calendar.getTime()),0,studentRegistration.getTemporaryCourseFee()));
|
|
|
+ userId, studentRegistration.getSubjectId(), musicOneSubjectClassPlan.getFee(),
|
|
|
+ DateUtil.getFirstDayOfMonth(calendar.getTime()), 0, studentRegistration.getTemporaryCourseFee()));
|
|
|
}
|
|
|
return userId;
|
|
|
}
|
|
@@ -426,4 +422,29 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
public List<StudentRegistration> findClassGroupStu(String musicGroupId, Integer classGroupId) {
|
|
|
return studentRegistrationDao.findClassGroupStu(musicGroupId, classGroupId);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public StudentPaymentOrder updateApplyOrder(StudentPaymentOrder studentPaymentOrder) {
|
|
|
+ //更新订单状态
|
|
|
+ studentPaymentOrderService.update(studentPaymentOrder);
|
|
|
+
|
|
|
+ //成功报名状态变更
|
|
|
+ StudentRegistration studentRegistration = studentRegistrationDao.queryByUserIdAndMusicGroupId(studentPaymentOrder.getUserId(), studentPaymentOrder.getMusicGroupId());
|
|
|
+ if (studentPaymentOrder.getStatus().equals(DealStatusEnum.SUCCESS)) {
|
|
|
+ studentRegistration.setPaymentStatus(YesOrNoEnum.YES);
|
|
|
+ studentRegistration.setMusicGroupStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
|
+ studentRegistrationDao.update(studentRegistration);
|
|
|
+ }
|
|
|
+
|
|
|
+ //失败减去已收款金额
|
|
|
+
|
|
|
+ //减去缴费人数
|
|
|
+ if (studentPaymentOrder.getStatus().equals(DealStatusEnum.SUCCESS)) {
|
|
|
+ MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getSubjectId());
|
|
|
+ musicOneSubjectClassPlan.setPaidStudentNum(musicOneSubjectClassPlan.getPaidStudentNum() - 1);
|
|
|
+ musicGroupSubjectPlanService.update(musicOneSubjectClassPlan);
|
|
|
+ }
|
|
|
+
|
|
|
+ return studentPaymentOrder;
|
|
|
+ }
|
|
|
}
|