瀏覽代碼

Merge branch 'system_fee' of http://git.dayaedu.com/yonge/mec into system_fee

yonge 4 年之前
父節點
當前提交
1e0d386e3d

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java

@@ -1877,4 +1877,11 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      * @return
      */
     int sumCourseMinutes(List<Long> courseScheduleIds);
+
+    /**
+     * 获取班级最小剩余可排课时长
+     * @param classGroupSet
+     * @return
+     */
+    List<Map<Integer, Long>> countPreSubMinutesByClassGroupId(@Param("classGroupSet") List<Integer> classGroupSet, @Param("courseDetailId") Integer courseDetailId);
 }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ClassGroupTeachersDto.java

@@ -23,6 +23,16 @@ public class ClassGroupTeachersDto extends ClassGroup {
 
 	private Integer preTotalClassTimes;
 
+	private Integer preSubMinutes;
+
+	public Integer getPreSubMinutes() {
+		return preSubMinutes;
+	}
+
+	public void setPreSubMinutes(Integer preSubMinutes) {
+		this.preSubMinutes = preSubMinutes;
+	}
+
 	public Integer getPreTotalClassTimes() {
 		return preTotalClassTimes;
 	}

+ 24 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -3503,7 +3503,13 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         Map<Integer, Integer> studyNums = JSONObject.parseObject(JSONObject.toJSONString(MapUtil.convertIntegerMap(classGroupDao.countStudyNum(classGroupIds))), HashMap.class);
 
         Map<Integer, Long> totalNumMap = MapUtil.convertIntegerMap(courseScheduleDao.countTotalNumByClassGroupId(classGroupSet, null));
-        Map<Integer, Long> preTotalNumMap = MapUtil.convertIntegerMap(courseScheduleDao.countPreTotalNumByClassGroupId(classGroupSet));
+        MusicGroupSchoolTermCourseDetail termCourseDetail = musicGroupSchoolTermCourseDetailDao.findByCourseDateAndMusicGroupId(musicGroupId, null);
+        Map<Integer, Long> preTotalNumMap = null;
+        Map<Integer, Long> preSubMinutesMap = null;
+        if(termCourseDetail != null){
+            preTotalNumMap = MapUtil.convertIntegerMap(courseScheduleDao.countPreTotalNumByClassGroupId(classGroupSet));
+            preSubMinutesMap = MapUtil.convertIntegerMap(courseScheduleDao.countPreSubMinutesByClassGroupId(classGroupSet,termCourseDetail.getId()));
+        }
         Map<Integer, Long> currentNumMap = MapUtil.convertIntegerMap(courseScheduleDao.countExpendNumByClassGroupId(classGroupSet));
 
         for (ClassGroupTeachersDto classGroup : classGroups) {
@@ -3515,18 +3521,27 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             classGroup.setClassGroupTeacherMapperList(classGroupTeacherMappers);
             classGroup.setStudentNum(studyNums.get(classGroup.getId()));
             int totalClassTimes = 0;
-            int preTotalClassTimes = 0;
             int currentClassTimes = 0;
-            if (preTotalNumMap.containsKey(classGroup.getId())) {
-                preTotalClassTimes = preTotalNumMap.get(classGroup.getId()).intValue();
+            if(preSubMinutesMap != null){
+                if (preSubMinutesMap.containsKey(classGroup.getId())) {
+                    Long aLong = preSubMinutesMap.get(classGroup.getId());
+                    classGroup.setPreSubMinutes(aLong==null?0:aLong.intValue());
+                }
+            }
+            if(preTotalNumMap != null){
+                if (preTotalNumMap.containsKey(classGroup.getId())) {
+                    Long aLong = preTotalNumMap.get(classGroup.getId());
+                    classGroup.setPreTotalClassTimes(aLong==null?0:aLong.intValue());
+                }
             }
+
             if (totalNumMap.containsKey(classGroup.getId())) {
                 totalClassTimes = totalNumMap.get(classGroup.getId()).intValue();
             }
             if (currentNumMap.containsKey(classGroup.getId())) {
                 currentClassTimes = currentNumMap.get(classGroup.getId()).intValue();
             }
-            classGroup.setPreTotalClassTimes(preTotalClassTimes);
+
             classGroup.setTotalClassTimes(totalClassTimes);
             classGroup.setCurrentClassTimes(currentClassTimes);
         }
@@ -4344,6 +4359,10 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         }
         //获取分布默认的课程类型单价
         MusicGroup musicGroup = musicGroupDao.findByClassGroupId(masterClassGroupId);
+        //主班乐团不能是系统收费团
+        if(musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE){
+            throw new BizException("操作失败:主班乐团不能是系统收费团");
+        }
         Map<String, BigDecimal> unitPriceMap = MapUtil.convertIntegerMap(organizationCourseUnitPriceSettingsDao.queryMapByOrganIdAndChargeTypeId(musicGroup.getChargeTypeId(), musicGroup.getOrganId()));
         Set<String> masterKeySet = masterMap.keySet();
         //计算主班课程类型剩余价值

+ 30 - 20
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -282,13 +282,13 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				}
 				switch (musicGroupPaymentCalenderDto.getMemberValidDate()){
 					case 1 :
-						memberPaymentAmount = memberFee.getCurrentMonthFee();
+						memberPaymentAmount = memberFee.getCurrentMonthFee().setScale(0, BigDecimal.ROUND_HALF_UP);
 						break;
 					case 6 :
-						memberPaymentAmount = memberFee.getCurrentHalfYearFee();
+						memberPaymentAmount = memberFee.getCurrentHalfYearFee().setScale(0, BigDecimal.ROUND_HALF_UP);
 						break;
 					case 12 :
-						memberPaymentAmount = memberFee.getCurrentYearFee();
+						memberPaymentAmount = memberFee.getCurrentYearFee().setScale(0, BigDecimal.ROUND_HALF_UP);
 						break;
 					default:
 						throw new BizException("请选择正确的会员有效期");
@@ -392,10 +392,12 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			}
 			//校验缴费有效期冲突
 			if (paymentType != ADD_STUDENT && paymentType != ADD_COURSE && paymentType != SPAN_GROUP_CLASS_ADJUST) {
-				int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPayUserType(),
-						musicGroupPaymentCalender.getPaymentValidStartDate(), musicGroupPaymentCalender.getPaymentValidEndDate(), null);
-				if (count > 0) {
-					throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
+				if(musicGroupPaymentCalender.getPaymentValidStartDate() != null){
+					int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPayUserType(),
+							musicGroupPaymentCalender.getPaymentValidStartDate(), musicGroupPaymentCalender.getPaymentValidEndDate(), null);
+					if (count > 0) {
+						throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
+					}
 				}
 			}
 
@@ -580,6 +582,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 //			musicGroupPaymentCalenderCourseSettingsList = new ArrayList<>();
 //		}
 
+		//会员原价
+		BigDecimal memberPaymentAmount = BigDecimal.ZERO;
 		if (payUserType == SCHOOL) {
 			status = AUDITING;
 		} else {
@@ -660,22 +664,21 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 					musicGroupPaymentCalenderStudentDetailDao.batchInsert(calenderStudentDetails,batchNo);
 				}
 			}
-			if(status != AUDITING && musicGroupPaymentCalenderDto.getMemberRankSettingId() != null){
+			if(musicGroupPaymentCalenderDto.getMemberRankSettingId() != null){
 				//会员价格是否变动
 				MemberFeeSetting memberFee = memberFeeSettingDao.findByRankIdAndOrganId(musicGroup.getOrganId(), musicGroupPaymentCalenderDto.getMemberRankSettingId());
 				if(memberFee == null){
 					throw new BizException("操作失败:请配置当前分部会员收费标准");
 				}
-				BigDecimal memberPaymentAmount;
 				switch (musicGroupPaymentCalenderDto.getMemberValidDate()){
 					case 1 :
-						memberPaymentAmount = memberFee.getCurrentMonthFee();
+						memberPaymentAmount = memberFee.getCurrentMonthFee().setScale(0, BigDecimal.ROUND_HALF_UP);
 						break;
 					case 6 :
-						memberPaymentAmount = memberFee.getCurrentHalfYearFee();
+						memberPaymentAmount = memberFee.getCurrentHalfYearFee().setScale(0, BigDecimal.ROUND_HALF_UP);
 						break;
 					case 12 :
-						memberPaymentAmount = memberFee.getCurrentYearFee();
+						memberPaymentAmount = memberFee.getCurrentYearFee().setScale(0, BigDecimal.ROUND_HALF_UP);
 						break;
 					default:
 						throw new BizException("请选择正确的会员有效期");
@@ -704,12 +707,13 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			MusicGroupPaymentCalender musicGroupPaymentCalender = new MusicGroupPaymentCalender();
 			musicGroupPaymentCalender.setAttribute1(musicGroupPaymentCalenderDto.getAttribute1());
 			musicGroupPaymentCalender.setAttribute2(musicGroupPaymentCalenderDto.getAttribute2());
+			musicGroupPaymentCalender.setOriginalMemberPaymentAmount(memberPaymentAmount);
 			musicGroupPaymentCalender.setDeadlinePaymentDate(musicGroupPaymentDateRange.getDeadlinePaymentDate());
 			musicGroupPaymentCalender.setIsGiveMusicNetwork(musicGroupPaymentCalenderDto.getIsGiveMusicNetwork());
 			musicGroupPaymentCalender.setMemo(musicGroupPaymentCalenderDto.getMemo());
 			musicGroupPaymentCalender.setMusicGroupId(musicGroupId);
 			musicGroupPaymentCalender.setMusicGroupOrganizationCourseSettingId(musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId());
-			BigDecimal totalPaymentAmount = musicGroupPaymentCalender.getMemberPaymentAmount();
+			BigDecimal totalPaymentAmount = musicGroupPaymentCalenderDto.getMemberPaymentAmount();
 			if(musicGroupPaymentCalenderCourseSettingsList != null){
 				List<MusicGroupPaymentCalenderCourseSettings> newCSList = new ArrayList<MusicGroupPaymentCalenderCourseSettings>(
 						musicGroupPaymentCalenderCourseSettingsList.size());
@@ -753,7 +757,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			}
 
 			musicGroupPaymentCalender.setPaymentAmount(totalPaymentAmount);
-
 			musicGroupPaymentCalender.setPaymentPattern(musicGroupPaymentCalenderDto.getPaymentPattern());
 			musicGroupPaymentCalender.setPaymentValidEndDate(musicGroupPaymentDateRange.getPaymentValidEndDate());
 			musicGroupPaymentCalender.setPaymentValidStartDate(musicGroupPaymentDateRange.getPaymentValidStartDate());
@@ -781,10 +784,12 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
 			}
 			if (paymentType != ADD_STUDENT && paymentType != ADD_COURSE && paymentType != SPAN_GROUP_CLASS_ADJUST) {
-				int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPayUserType(),
-						musicGroupPaymentCalender.getPaymentValidStartDate(), musicGroupPaymentCalender.getPaymentValidEndDate(), null);
-				if (count > 0) {
-					throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
+				if(musicGroupPaymentCalender.getPaymentValidStartDate() != null){
+					int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPayUserType(),
+							musicGroupPaymentCalender.getPaymentValidStartDate(), musicGroupPaymentCalender.getPaymentValidEndDate(), null);
+					if (count > 0) {
+						throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
+					}
 				}
 			}
 
@@ -807,6 +812,11 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 			// 设置批次号
 			musicGroupPaymentCalender.setBatchNo(batchNo);
+			//设置会员缴费金额、级别以及有效期
+			musicGroupPaymentCalender.setMemberPaymentAmount(musicGroupPaymentCalenderDto.getMemberPaymentAmount());
+			musicGroupPaymentCalender.setMemberRankSettingId(musicGroupPaymentCalenderDto.getMemberRankSettingId());
+			musicGroupPaymentCalender.setMemberValidDate(musicGroupPaymentCalenderDto.getMemberValidDate());
+			musicGroupPaymentCalenderDto.setBatchNo(batchNo);
 			musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
 			List<MusicGroupPaymentCalenderCourseSettings> currentMusicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalender
 					.getMusicGroupPaymentCalenderCourseSettingsList();
@@ -987,7 +997,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 				}
 				//如果是系统收费乐团
-				if(musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE){
+				/*if(musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE){
 					//获取会员收费排课的课程
 					List<RemainCourseTypeDurationDto> durationDtos = courseScheduleDao.queryRemainCourseTypeDuration(musicGroupPaymentCalender.getAttribute1(), 1);
 					if(durationDtos != null && durationDtos.size() > 0){
@@ -1006,7 +1016,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 						musicGroupPaymentStudentCourseDetail.setUserId(Integer.parseInt(studentId));
 						musicGroupPaymentStudentCourseDetailList.add(musicGroupPaymentStudentCourseDetail);
 					}
-				}
+				}*/
 				if(musicGroupPaymentStudentCourseDetailList.size() > 0){
 					musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetailList);
 				}

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

@@ -3880,7 +3880,7 @@
     <select id="queryPreCourseListByMusicGroupId" resultMap="CourseSchedule">
         SELECT * FROM course_schedule WHERE music_group_id_ = #{musicGroupId} AND group_type_ = 'MUSIC' AND is_lock_ = 1 AND pre_course_flag_ = 1
     </select>
-    <select id="sumCourseMinutes" resultType="java.lang.Integer">
+    <select id="sumCourseMinutes" resultType="int">
         SELECT SUM(c.course_mintues_) FROM (SELECT FLOOR((UNIX_TIMESTAMP(CONCAT(class_date_, ' ', end_class_time_)) -
         UNIX_TIMESTAMP(CONCAT(class_date_, ' ', start_class_time_))) / 60) course_mintues_ FROM course_schedule
         WHERE id_ IN
@@ -3888,4 +3888,15 @@
             #{courseId}
         </foreach>) c
     </select>
+    <select id="countPreSubMinutesByClassGroupId" resultType="java.util.Map">
+        SELECT cgsm.class_group_id_,MIN(mgst.member_course_minutes_ - mgst.pre_member_course_minutes_)
+        FROM class_group_student_mapper cgsm
+        LEFT JOIN music_group_school_term_student_course_detail mgst ON mgst.user_id_ = cgsm.user_id_
+        WHERE cgsm.class_group_id_ IN
+        <foreach collection="classGroupSet" open="(" close=")" item="classGroupId" separator=",">
+            #{classGroupId}
+        </foreach>
+        AND mgst.music_group_school_term_course_detail_id_ = #{courseDetailId}
+        GROUP BY cgsm.class_group_id_
+    </select>
 </mapper>

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

@@ -1,27 +1,5 @@
 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;
@@ -36,6 +14,18 @@ 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 = "乐团缴费日历服务")