yonge 4 gadi atpakaļ
vecāks
revīzija
b360e0e5b3

+ 79 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -39,6 +39,7 @@ import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.CalenderPushDto;
 import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDetailDto;
 import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDto;
+import com.ym.mec.biz.dal.entity.ClassGroup;
 import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
 import com.ym.mec.biz.dal.entity.MusicGroup;
 import com.ym.mec.biz.dal.entity.MusicGroupBuildLog;
@@ -55,10 +56,12 @@ import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
 import com.ym.mec.biz.dal.entity.Organization;
 import com.ym.mec.biz.dal.entity.OrganizationCourseUnitPriceSettings;
+import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
 import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
 import com.ym.mec.biz.dal.page.MusicGroupPaymentCalenderQueryInfo;
+import com.ym.mec.biz.service.ClassGroupService;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
 import com.ym.mec.biz.service.SysConfigService;
 import com.ym.mec.biz.service.SysMessageService;
@@ -100,6 +103,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	private IdGeneratorService idGeneratorService;
 	
 	@Autowired
+	private ClassGroupService classGroupService;
+	
+	@Autowired
 	private MusicGroupDao musicGroupDao;
 	@Autowired
 	private MusicGroupBuildLogDao musicGroupBuildLogDao;
@@ -263,6 +269,15 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 						// 学生加到班级
 						String classGroupIdStr = musicGroupPaymentCalender.getAttribute1();
+						if(StringUtils.isNotBlank(classGroupIdStr)){
+							for(String classGroupId : classGroupIdStr.split(",")){
+								ClassGroup classGroup = classGroupService.get(Integer.parseInt(classGroupId));
+								if(classGroup == null){
+									throw new BizException("根据班级编号查询不到对应的班级");
+								}
+								classGroupService.addStudent(classGroup, Integer.parseInt(studentId), GroupType.MUSIC);
+							}
+						}
 					}
 				}
 			}
@@ -418,9 +433,72 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			} else {
 				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
 			}
+			
+			//如果是进行中加学生
+			if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
+				String studentIdStr = musicGroupPaymentCalender.getStudentIds();
+				if (StringUtils.isNoneBlank(studentIdStr)) {
+					//计算总费用
+					BigDecimal totalPrice = new BigDecimal(0);
+					for(MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings : musicGroupPaymentCalenderCourseSettingsList){
+						totalPrice = totalPrice.add(musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice());
+					}
+					
+					List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = new ArrayList<MusicGroupPaymentStudentCourseDetail>();
+					MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = null;
+					
+					for (String studentId : studentIdStr.split(",")) {
+						// 学生加到calenderDetail
+						MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
+						musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
+						musicGroupPaymentCalenderDetail.setCreateTime(date);
+						musicGroupPaymentCalenderDetail.setExpectAmount(totalPrice);
+						musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
+						musicGroupPaymentCalenderDetail.setUpdateTime(date);
+						musicGroupPaymentCalenderDetail.setUserId(Integer.parseInt(studentId));
+						musicGroupPaymentCalenderDetail.setStartPaymentDate(musicGroupPaymentCalender.getStartPaymentDate());
+						musicGroupPaymentCalenderDetail.setDeadlinePaymentDate(musicGroupPaymentCalender.getDeadlinePaymentDate());
+						
+						musicGroupPaymentCalenderDetailDao.insert(musicGroupPaymentCalenderDetail);
+						
+						// 学生加课程明细
+						for(MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList){
+							if (courseSettings.getIsStudentOptional() == true) {
+								continue;
+							}
+							musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
+							musicGroupPaymentStudentCourseDetail.setCourseType(courseSettings.getCourseType());
+							musicGroupPaymentStudentCourseDetail.setCreateTime(date);
+							musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
+							musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetail.getId());
+							musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSettings.getCourseTotalMinuties());
+							musicGroupPaymentStudentCourseDetail.setUpdateTime(date);
+							musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
+							musicGroupPaymentStudentCourseDetail.setUserId(Integer.parseInt(studentId));
+							
+							musicGroupPaymentStudentCourseDetailList.add(musicGroupPaymentStudentCourseDetail);
+						}
+						
+						if(musicGroupPaymentStudentCourseDetailList.size() > 0){
+							musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetailList);
+						}
+
+						// 学生加到班级
+						String classGroupIdStr = musicGroupPaymentCalender.getAttribute1();
+						if(StringUtils.isNotBlank(classGroupIdStr)){
+							for(String classGroupId : classGroupIdStr.split(",")){
+								ClassGroup classGroup = classGroupService.get(Integer.parseInt(classGroupId));
+								if(classGroup == null){
+									throw new BizException("根据班级编号查询不到对应的班级");
+								}
+								classGroupService.addStudent(classGroup, Integer.parseInt(studentId), GroupType.MUSIC);
+							}
+						}
+					}
+				}
+			}
 
 			// 如果是报名,需要修改乐团状态
-
 			if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY) {
 				int countAuditReject = musicGroupPaymentCalenderDao.countAuditReject(musicGroupPaymentCalender.getMusicGroupId(),musicGroupPaymentCalender.getId());
 				if(countAuditReject == 0){

+ 22 - 15
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java

@@ -1,12 +1,33 @@
 package com.ym.mec.web.controller;
 
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.ui.ModelMap;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
 import com.ym.mec.biz.dal.entity.Employee;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
 import com.ym.mec.biz.dal.entity.StudentRegistration;
 import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
 import com.ym.mec.biz.dal.page.MusicGroupPaymentCalenderQueryInfo;
@@ -14,21 +35,7 @@ import com.ym.mec.biz.service.MusicGroupPaymentCalenderCourseSettingsService;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
-
 import com.ym.mec.common.exception.BizException;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.MediaType;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.ui.ModelMap;
-import org.springframework.util.CollectionUtils;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.*;
-import java.util.stream.Collectors;
 
 @RequestMapping("musicGroupPaymentCalender")
 @Api(tags = "乐团缴费日历服务")