소스 검색

拆班合班

zouxuan 4 년 전
부모
커밋
0da9f36490

+ 7 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderCourseSettings.java

@@ -4,6 +4,8 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
 
+import java.math.BigDecimal;
+
 /**
  * 对应数据库表(music_group_payment_calender_course_settings):
  */
@@ -34,7 +36,7 @@ public class MusicGroupPaymentCalenderCourseSettings {
 	private java.math.BigDecimal courseCurrentPrice;
 	
 	/** 是否学生可选 */
-	private boolean isStudentOptional;
+	private boolean isStudentOptional = false;
 	
 	/**  */
 	private java.util.Date createTime;
@@ -42,6 +44,10 @@ public class MusicGroupPaymentCalenderCourseSettings {
 	/**  */
 	private java.util.Date updateTime;
 
+	public void setStudentOptional(boolean studentOptional) {
+		isStudentOptional = studentOptional;
+	}
+
 	public String getName() {
 		return name;
 	}

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupService.java

@@ -2,6 +2,7 @@ package com.ym.mec.biz.service;
 
 import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.ClassGroup;
+import com.ym.mec.biz.dal.entity.MusicGroupOrganizationCourseSettingsDetail;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
 import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
@@ -470,5 +471,5 @@ public interface ClassGroupService extends BaseService<Integer, ClassGroup> {
      * @param classGroupIds
      * @return
      */
-    List<MusicGroupPaymentCalender> getDefaultPaymentCalender(List<Integer> classGroupIds);
+    Map<Integer,Map<String, MusicGroupOrganizationCourseSettingsDetail>> getDefaultPaymentCalender(List<Integer> classGroupIds);
 }

+ 23 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -25,6 +25,7 @@ import java.util.Objects;
 import java.util.Set;
 import java.util.stream.Collectors;
 
+import com.alibaba.fastjson.JSONArray;
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.entity.*;
 import org.apache.commons.lang3.StringUtils;
@@ -3243,30 +3244,43 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
     }
 
     @Override
-    public List<MusicGroupPaymentCalender> getDefaultPaymentCalender(List<Integer> classGroupIds) {
+    public Map<Integer,Map<String,MusicGroupOrganizationCourseSettingsDetail>> getDefaultPaymentCalender(List<Integer> classGroupIds) {
         if(classGroupIds == null || classGroupIds.size() == 0){
             throw new BizException("参数校验失败");
         }
+        Map<Integer,Map<String,MusicGroupOrganizationCourseSettingsDetail>> resultMap = new HashMap<>();
+        //获取默认的排课时长
+        String courseDefaultMinutes = sysConfigDao.findConfigValue("music_course_default_minutes");
+        JSONObject jsonObject = JSON.parseObject(courseDefaultMinutes);
         //获取所选班级最大剩余课时
-        Map<String,Integer> map = MapUtil.convertIntegerMap(courseScheduleDao.findClassMaxCourseNumMap(classGroupIds));
+        Map<String,Long> map = MapUtil.convertIntegerMap(courseScheduleDao.findClassMaxCourseNumMap(classGroupIds));
         //获取每个班级对应课程类型最后一节课
         Set<String> courseTypes = map.keySet();
         for (Integer classGroupId : classGroupIds) {
+            Map<String,MusicGroupOrganizationCourseSettingsDetail> courseMap = new HashMap<>();
             //获取当前班级剩余课次
-            Map<String,Integer> subCourseNumMap = MapUtil.convertIntegerMap(courseScheduleDao.querySubCourseNumMap(classGroupId));
+            Map<String,Long> subCourseNumMap = MapUtil.convertIntegerMap(courseScheduleDao.querySubCourseNumMap(classGroupId));
             for (String courseType : courseTypes) {
-                Integer currentNum = subCourseNumMap.get(courseType);
-                Integer maxNum = map.get(courseType);
+                Long currentNum = subCourseNumMap.get(courseType);
+                if(currentNum == null){
+                    throw new BizException("所选班级课程类型不一致,请重新选择");
+                }
+                Long maxNum = map.get(courseType);
                 //如果当前课程类型不需要新增缴费项目
-                if(currentNum != null && currentNum >= maxNum){
+                if(currentNum >= maxNum){
                     continue;
                 }
+                Long subNum = maxNum - currentNum;
+                //生成缴费项目
                 MusicGroupOrganizationCourseSettingsDetail settingsDetail = musicGroupPaymentCalenderCourseSettingsService.getClassLastSetting(classGroupId,courseType);
                 settingsDetail.setCourseType(CourseScheduleType.valueOf(courseType));
+                settingsDetail.setCourseTotalMinuties(Integer.parseInt(jsonObject.get(courseType).toString()) * subNum.intValue());
+                settingsDetail.setCourseCurrentPrice(settingsDetail.getCourseCurrentPrice().multiply(new BigDecimal(subNum)));
+                settingsDetail.setCourseOriginalPrice(settingsDetail.getCourseOriginalPrice().multiply(new BigDecimal(subNum)));
+                courseMap.put(courseType,settingsDetail);
             }
+            resultMap.put(classGroupId,courseMap);
         }
-        //获取最后一节课现价,原价
-        //生成缴费项目
-        return null;
+        return resultMap;
     }
 }

+ 3 - 3
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -3352,12 +3352,12 @@
         SELECT COUNT(id_) FROM course_schedule WHERE new_course_id_=#{courseId}
     </select>
     <select id="querySubCourseNumMap" resultType="java.util.Map">
-        SELECT cs.type_ 'key',COUNT(cs.id_) 'value' FROM course_schedule cs
-        WHERE cs.class_group_id_ = #{classGroupId} AND CONCAT(cs.class_date_," ",cs.start_class_time_) > NOW()
+        SELECT cs.type_ 'key',COUNT(CASE WHEN (CONCAT(cs.class_date_," ",cs.start_class_time_) > NOW()) THEN 1 ELSE NULL END) 'value' FROM course_schedule cs
+        WHERE cs.class_group_id_ = #{classGroupId}
         GROUP BY cs.type_
     </select>
     <select id="findClassMaxCourseNumMap" resultType="java.util.Map">
-        SELECT c.type_ 'key',MAX(c.subCourseNum) 'vslue' FROM (SELECT cs.type_,COUNT(cs.id_) subCourseNum FROM course_schedule cs
+        SELECT c.type_ 'key',MAX(c.subCourseNum) 'value' FROM (SELECT cs.type_,COUNT(cs.id_) subCourseNum FROM course_schedule cs
         WHERE cs.class_group_id_ IN
         <foreach collection="classGroupIds" open="(" close=")" separator="," item="item">
             #{item}

+ 3 - 2
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderCourseSettingsMapper.xml

@@ -155,9 +155,10 @@
 		GROUP BY mgpccs.course_type_
 	</select>
     <select id="getClassLastSetting" resultMap="MusicGroupPaymentCalenderCourseSettings">
-		SELECT cssp.original_price_,cssp.expect_price_,0 is_student_optional_ FROM course_schedule cs
+		SELECT cssp.original_price_ course_original_price_,cssp.expect_price_ course_current_price_
+		FROM course_schedule cs
 		LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
-		WHERE cs.class_group_id_ = #{classGroupId} AND cs.type_ = #{courseType}
+		WHERE cs.class_group_id_ = #{classGroupId} AND cs.type_ = #{courseType} AND cssp.original_price_ IS NOT NULL
 		ORDER BY cs.class_date_,cs.start_class_time_ DESC
 		LIMIT 1
 	</select>

+ 3 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml

@@ -455,6 +455,9 @@
         SUM(mgpccs.course_total_minuties_) course_total_minuties_,
         SUM(mgpccs.course_original_price_) course_original_price_,SUM(mgpccs.course_current_price_) course_current_price_,
         MAX(mg.name_) music_group_name_,MAX(mg.organ_id_) organ_id_,MAX(mgpc.payment_pattern_)payment_pattern_
+        FROM music_group_payment_calender mgpc
+        LEFT JOIN music_group mg ON mg.id_ = mgpc.music_group_id_
+        LEFT JOIN music_group_payment_calender_course_settings mgpccs ON mgpc.id_ = mgpccs.music_group_payment_calender_id_
         <include refid="MusicGroupPaymentCalenderAuditDtoSql"/>
         GROUP BY mgpc.batch_no_
         ORDER BY create_time_ DESC

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/ClassGroupController.java

@@ -344,7 +344,7 @@ public class ClassGroupController extends BaseController {
     @ApiOperation(value = "进行中乐团-修改-班级详情-学员班级调整-生成默认缴费信息")
     @GetMapping("/getDefaultPaymentCalender")
     @PreAuthorize("@pcs.hasPermissions('classGroup/getDefaultPaymentCalender')")
-    public HttpResponseResult studentClassAuditDetail(List<Integer> classGroupIds){
+    public HttpResponseResult studentClassAuditDetail(@RequestBody List<Integer> classGroupIds){
         return succeed(classGroupService.getDefaultPaymentCalender(classGroupIds));
     }
 }