Pārlūkot izejas kodu

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

zouxuan 4 gadi atpakaļ
vecāks
revīzija
9a067933bb

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

@@ -1870,7 +1870,7 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      * @param classGroupIds
      * @return
      */
-    int queryPreCourseListByClassGroupIds(List<Integer> classGroupIds);
+    int queryPreCourseListByClassGroupIds(@Param("classGroupIds") List<Integer> classGroupIds);
 
     /**
      * 获取预排课程列表

+ 14 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/IndexBaseMonthDataDao.java

@@ -289,6 +289,20 @@ public interface IndexBaseMonthDataDao extends BaseDAO<Long, IndexBaseMonthData>
                                                             @Param("endDate") String endDate,
                                                             @Param("organIds") List<Integer> organIds);
 
+    List<IndexBaseMonthData> getTotalAmountDataWithTimelyDetails(@Param("startDate") String startDate,
+                                                                 @Param("endDate") String endDate,
+                                                                 @Param("organIds") List<Integer> organIds,
+                                                                 @Param("orderType") String orderType,
+                                                                 @Param("notOrderType") List<String> notOrderType);
+
+    List<IndexBaseMonthData> getVipAmountDataWithTimelyDetails(@Param("startDate") String startDate,
+                                                                 @Param("endDate") String endDate,
+                                                                 @Param("organIds") List<Integer> organIds);
+
+    List<IndexBaseMonthData> getOtherAmountDataWithTimelyDetails(@Param("startDate") String startDate,
+                                                                 @Param("endDate") String endDate,
+                                                                 @Param("organIds") List<Integer> organIds);
+
     int countStudentErrorLeave(@Param("organIdList") Set<Integer> organIdList, @Param("format") String format, @Param("classGroupIds") List<Long> classGroupIds);
 
     int countStudentErrorLeave1(Map<String, Object> params);

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/IndexBaseMonthData.java

@@ -16,6 +16,9 @@ public class IndexBaseMonthData {
 	/**  */
 	private java.util.Date month;
 
+	/**  */
+	private String monthStr;
+
 	private String title;
 	
 	/** 分部编号 */
@@ -38,6 +41,14 @@ public class IndexBaseMonthData {
 
 	private Date updateTime;
 
+	public String getMonthStr() {
+		return monthStr;
+	}
+
+	public void setMonthStr(String monthStr) {
+		this.monthStr = monthStr;
+	}
+
 	public IndexBaseMonthData() {
 	}
 

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/IndexDataType.java

@@ -43,6 +43,13 @@ public enum IndexDataType implements BaseEnum<String, IndexDataType> {
     FINANCE_AMOUNT("FINANCE_AMOUNT","现金收入", false, false),
     TOTAL_AMOUNT("TOTAL_AMOUNT","总收入", false, false),
 
+    //经营数据详情
+    APPLY_AMOUNT("APPLY_AMOUNT","报名缴费收入", false, false),
+    RENEW_AMOUNT("RENEW_AMOUNT","乐团续费收入", false, false),
+    VIP_AMOUNT("VIP_AMOUNT","VIP课收入", false, false),
+    PRACTICE_AMOUNT("PRACTICE_AMOUNT","网管课收入", false, false),
+    OTHER_AMOUNT("OTHER_AMOUNT","其他收入", false, false),
+
     //业务数据
     HOMEWORK_CREATE_RATE("HOMEWORK_CREATE_RATE","作业布置率", true, true),
     HOMEWORK_SUBMIT_RATE("HOMEWORK_SUBMIT_RATE","作业提交率", true, true),

+ 3 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java

@@ -463,8 +463,9 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
         if (Objects.isNull(classGroup)) {
             throw new BizException("班级信息错误");
         }
+        MusicGroup musicGroup = musicGroupDao.get(classGroup.getMusicGroupId());
         //是否有预排课
-        if(courseScheduleDao.queryPreCourseListByClassGroupId(classGroupId.intValue()).size() > 0){
+        if(courseScheduleDao.queryPreCourseListByMusicGroupId(musicGroup.getId()).size() > 0){
             throw new BizException("调整失败:请先完成预排课操作");
         }
         if (ClassGroupTypeEnum.MUSIC_NETWORK.equals(classGroup.getType())) {
@@ -489,7 +490,7 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
             oldStudentIds = classGroupStudents.stream().map(ClassGroupStudentMapper::getUserId).collect(Collectors.toSet());
             oldNormalStudentIds = classGroupStudents.stream().filter(s -> ClassGroupStudentStatusEnum.NORMAL.equals(s.getStatus())).map(ClassGroupStudentMapper::getUserId).collect(Collectors.toSet());
         }
-        MusicGroup musicGroup = musicGroupDao.get(classGroup.getMusicGroupId());
+
         //线上基础技能班,原始分班人数不能小于3人大于6人
         if (classGroup.getType().equals(ClassGroupTypeEnum.HIGH_ONLINE)) {
 

+ 19 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java

@@ -150,8 +150,18 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			typeDateMap.put(IndexDataType.FINANCE_BALANCE_AMOUNT,indexBaseMonthDataDao.getFinanceBalanceDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds)));
 			typeDateMap.put(FINANCE_AMOUNT,indexBaseMonthDataDao.getFinanceActualDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds)));
 			List<IndexBaseMonthData> totalAmountDataWithTimely = indexBaseMonthDataDao.getTotalAmountDataWithTimely(startDate.toString(), endDate.toString(), new ArrayList<>(organIds));
-
 			typeDateMap.put(IndexDataType.TOTAL_AMOUNT,totalAmountDataWithTimely);
+			//经营报表细化
+			List<IndexBaseMonthData> applyAmount = indexBaseMonthDataDao.getTotalAmountDataWithTimelyDetails(startDate.toString(), endDate.toString(), new ArrayList<>(organIds),"APPLY",null);
+			typeDateMap.put(APPLY_AMOUNT,applyAmount);
+			List<IndexBaseMonthData> renewAmount = indexBaseMonthDataDao.getTotalAmountDataWithTimelyDetails(startDate.toString(), endDate.toString(), new ArrayList<>(organIds),"RENEW",null);
+			typeDateMap.put(RENEW_AMOUNT,renewAmount);
+			List<IndexBaseMonthData> vipAmount = indexBaseMonthDataDao.getVipAmountDataWithTimelyDetails(startDate.toString(), endDate.toString(), new ArrayList<>(organIds));
+			typeDateMap.put(VIP_AMOUNT,vipAmount);
+			List<IndexBaseMonthData> practiceAmount = indexBaseMonthDataDao.getTotalAmountDataWithTimelyDetails(startDate.toString(), endDate.toString(), new ArrayList<>(organIds),"PRACTICE_GROUP_BUY,PRACTICE_GROUP_RENEW",null);
+			typeDateMap.put(PRACTICE_AMOUNT,practiceAmount);
+			List<IndexBaseMonthData> otherAmount = indexBaseMonthDataDao.getOtherAmountDataWithTimelyDetails(startDate.toString(), endDate.toString(), new ArrayList<>(organIds));
+			typeDateMap.put(OTHER_AMOUNT,otherAmount);
 		}
 
 
@@ -211,9 +221,14 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			}
 			IndexBaseDto indexBaseData = new IndexBaseDto(typeDateMapEntry.getKey(),typeDateMapEntry.getKey().getMsg());
 			indexBaseData.setIndexMonthData(typeDateMapEntry.getValue(), currentMonth);
-			if(IndexDataType.FINANCE_PAY.equals(typeDateMapEntry.getKey()) || FINANCE_AMOUNT.equals(typeDateMapEntry.getKey()) ||
-				IndexDataType.FINANCE_BALANCE_AMOUNT.equals(typeDateMapEntry.getKey()) ||
-					IndexDataType.TOTAL_AMOUNT.equals(typeDateMapEntry.getKey())){
+			if(FINANCE_PAY.equals(typeDateMapEntry.getKey()) || FINANCE_AMOUNT.equals(typeDateMapEntry.getKey()) ||
+				FINANCE_BALANCE_AMOUNT.equals(typeDateMapEntry.getKey()) ||
+					TOTAL_AMOUNT.equals(typeDateMapEntry.getKey()) ||
+					APPLY_AMOUNT.equals(typeDateMapEntry.getKey()) ||
+					RENEW_AMOUNT.equals(typeDateMapEntry.getKey()) ||
+					VIP_AMOUNT.equals(typeDateMapEntry.getKey()) ||
+					PRACTICE_AMOUNT.equals(typeDateMapEntry.getKey()) ||
+					OTHER_AMOUNT.equals(typeDateMapEntry.getKey())){
 				indexBaseData.setPercent(typeDateMapEntry.getValue().stream().map(IndexBaseMonthData::getPercent).reduce(BigDecimal.ZERO, BigDecimal::add));
 			}
 			if(IndexDataType.VIP_GROUP_COURSE.equals(typeDateMapEntry.getKey()) || VIP_GROUP_ONLINE_COURSE.equals(typeDateMapEntry.getKey()) ||

+ 89 - 0
mec-biz/src/main/resources/config/mybatis/IndexBaseMonthDataMapper.xml

@@ -9,6 +9,7 @@
 	<resultMap type="com.ym.mec.biz.dal.entity.IndexBaseMonthData" id="IndexBaseMonthData">
 		<result column="id_" property="id" />
 		<result column="month_" property="month" />
+		<result column="month_" property="monthStr" />
 		<result column="organ_id_" property="organId" />
 		<result column="total_num_" property="totalNum" />
 		<result column="activate_num_" property="activateNum" />
@@ -1329,6 +1330,94 @@
 		</if>
 		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
 	</select>
+	<select id="getTotalAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
+		SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
+		                         CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_,
+			   SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
+		CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) activate_num_,
+			   SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
+		CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
+		FROM student_payment_order spo
+		WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
+		<if test="orderType != null">
+			AND FIND_IN_SET(spo.type_,#{orderType})
+		</if>
+		<if test="notOrderType != null">
+			AND spo.type_ NOT IN
+			<foreach collection="notOrderType" open="(" close=")" item="item" separator=",">
+				#{item}
+			</foreach>
+		</if>
+		<if test="organIds!=null and organIds.size()>0">
+			AND spo.organ_id_ IN
+			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+				#{organId}
+			</foreach>
+		</if>
+		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
+	</select>
+
+	<select id="getVipAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
+		SELECT organ_id_,SUM(c.total_num_) total_num_,SUM(c.total_num_) activate_num_,SUM(c.total_num_) percent_,month_ FROM (
+		SELECT spo.organ_id_,SUM(CASE WHEN spod.price_ IS NULL THEN 0 ELSE spod.price_ END) total_num_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
+		FROM student_payment_order spo
+		LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
+		WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
+		AND spo.type_ = 'DEGREE' AND spod.type_ IN ('THEORY_COURSE','VIP')
+		<if test="organIds!=null and organIds.size()>0">
+			AND spo.organ_id_ IN
+			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+				#{organId}
+			</foreach>
+		</if>
+		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
+		UNION
+		SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
+		CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_
+		,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
+		FROM student_payment_order spo
+		WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
+		AND spo.type_ = 'SMALL_CLASS_TO_BUY'
+		<if test="organIds!=null and organIds.size()>0">
+			AND spo.organ_id_ IN
+			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+				#{organId}
+			</foreach>
+		</if>
+		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
+		)c GROUP BY DATE_FORMAT(c.month_,'%Y-%m-%d')
+	</select>
+
+	<select id="getOtherAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
+		SELECT organ_id_,SUM(c.total_num_) total_num_,month_ FROM (
+		SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
+							   CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_
+		   ,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
+		FROM student_payment_order spo
+		WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
+		AND spo.type_ NOT IN ('APPLY','RENEW','PRACTICE_GROUP_BUY','PRACTICE_GROUP_RENEW','SMALL_CLASS_TO_BUY','DEGREE')
+		<if test="organIds!=null and organIds.size()>0">
+			AND spo.organ_id_ IN
+			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+				#{organId}
+			</foreach>
+		</if>
+		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
+		UNION
+		SELECT spo.organ_id_,SUM(CASE WHEN spod.price_ IS NULL THEN 0 ELSE spod.price_ END) total_num_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
+		FROM student_payment_order spo
+			   LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
+		WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
+		AND spo.type_ = 'DEGREE' AND spod.type_ = 'DEGREE_REGISTRATION'
+		<if test="organIds!=null and organIds.size()>0">
+			AND spo.organ_id_ IN
+			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+				#{organId}
+			</foreach>
+		</if>
+		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
+		)c GROUP BY DATE_FORMAT(c.month_,'%Y-%m-%d')
+	</select>
 
 	<sql id="queryTeacherServeInfoCondition">
 		<where>