浏览代码

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

zouxuan 10 月之前
父节点
当前提交
0094d7b2d7
共有 31 个文件被更改,包括 1196 次插入168 次删除
  1. 9 0
      mec-application/src/main/java/com/ym/mec/web/controller/TaskController.java
  2. 29 5
      mec-application/src/main/resources/exportColumnMapper.ini
  3. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ExportDao.java
  4. 7 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupDao.java
  5. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentStudentCourseDetailLogDao.java
  6. 4 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/OperatingReportNewDao.java
  7. 315 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ExportWrapper.java
  8. 52 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentStudentCourseDetailLog.java
  9. 9 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/ExportEnum.java
  10. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/ExportTypeEnum.java
  11. 3 2
      mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleStudentPaymentService.java
  12. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentStudentCourseDetailLogService.java
  13. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupService.java
  14. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/service/OperatingReportNewService.java
  15. 28 8
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java
  16. 11 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java
  17. 99 55
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java
  18. 76 3
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java
  19. 2 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java
  20. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  21. 17 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentStudentCourseDetailLogServiceImpl.java
  22. 13 17
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentStudentCourseDetailServiceImpl.java
  23. 235 71
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  24. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/OperatingReportNewServiceImpl.java
  25. 131 0
      mec-biz/src/main/resources/config/mybatis/ExportMapper.xml
  26. 51 1
      mec-biz/src/main/resources/config/mybatis/MusicGroupMapper.xml
  27. 6 0
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentStudentCourseDetailLogMapper.xml
  28. 13 0
      mec-biz/src/main/resources/config/mybatis/OperatingReportNewMapper.xml
  29. 4 0
      mec-client-api/src/main/java/com/ym/mec/task/TaskRemoteService.java
  30. 4 0
      mec-client-api/src/main/java/com/ym/mec/task/fallback/TaskRemoteServiceFallback.java
  31. 20 0
      mec-task/src/main/java/com/ym/mec/task/jobs/BalancedRelationshipTask.java

+ 9 - 0
mec-application/src/main/java/com/ym/mec/web/controller/TaskController.java

@@ -155,6 +155,15 @@ public class TaskController extends BaseController {
 		studentTeacherMapperService.init();
 		studentTeacherMapperService.init();
 	}
 	}
 
 
+	//每月平衡关系
+	@GetMapping(value = "/balancedRelationship")
+	public void balancedRelationship(String month){
+		if(month == null){
+			month = DateUtil.dateToString(DateUtil.getFirstDayOfMonth(new Date()),DateUtil.ISO_YEAR_MONTH_FORMAT);
+		}
+		operatingReportNewService.balancedRelationship(month);
+	}
+
 	//每月经营报表
 	//每月经营报表
 	@GetMapping(value = "/operatingReportMonth")
 	@GetMapping(value = "/operatingReportMonth")
 	public void operatingReportMonth(){
 	public void operatingReportMonth(){

+ 29 - 5
mec-application/src/main/resources/exportColumnMapper.ini

@@ -26,10 +26,6 @@ fieldColumns = ["organName","userId", "username", "phone", "subjectName", "type.
 headColumns = ["分部", "学员编号", "姓名", "电话", "声部","交易类型", "交易金额", "交易时间", "备注","可用余额"]
 headColumns = ["分部", "学员编号", "姓名", "电话", "声部","交易类型", "交易金额", "交易时间", "备注","可用余额"]
 fieldColumns = ["organName", "userId", "username", "phone", "subjectName", "type.msg", "amount", "createTime", "comment","balance"]
 fieldColumns = ["organName", "userId", "username", "phone", "subjectName", "type.msg", "amount", "createTime", "comment","balance"]
 
 
-[班级列表导出]
-headColumns = ["课程组编号", "课程组名称", "分部名称", "班级名称","班级类型", "班级人数", "主教老师", "助教老师", "已上课时", "总课数"]
-fieldColumns = ["musicGroupId", "musicGroupName", "organName", "name", "type.msg", "studentNum == NUll?0:studentNum", "bishopTeacherName", "teachingTeacherName", "currentClassTimes", "totalClassTimes"]
-
 [商品列表导出]
 [商品列表导出]
 headColumns = ["商品编号", "货号", "品牌", "商品名称","是否组合商品", "商品类型", "商品分类", "具体型号", "内部库存", "税务库存", "库存类型", "市场价(元)","零售价(元)", "商品团购价(元)", "商品描述", "商品详情", "是否上下架"]
 headColumns = ["商品编号", "货号", "品牌", "商品名称","是否组合商品", "商品类型", "商品分类", "具体型号", "内部库存", "税务库存", "库存类型", "市场价(元)","零售价(元)", "商品团购价(元)", "商品描述", "商品详情", "是否上下架"]
 fieldColumns = ["id", "sn", "brand", "name", "complementGoodsIdList == null || complementGoodsIdList == '' ? '否':'是'", "type.desc", "goodsCategoryName", "specification", "stockCount", "taxStockCount", "stockType.msg", "marketPrice", "discountPrice", "groupPurchasePrice", "brief", "desc", "status.msg"]
 fieldColumns = ["id", "sn", "brand", "name", "complementGoodsIdList == null || complementGoodsIdList == '' ? '否':'是'", "type.desc", "goodsCategoryName", "specification", "stockCount", "taxStockCount", "stockType.msg", "marketPrice", "discountPrice", "groupPurchasePrice", "brief", "desc", "status.msg"]
@@ -375,6 +371,14 @@ headColumns = ["分部","学员编号","学员姓名","手机号","学员声部"
 fieldColumns = ["organName","studentId","name","phone","subjectName","type.msg","time","amount","status == 1 ? '待激活':'已取消'","cancelReason","operatorName","operateTime","createTime"]
 fieldColumns = ["organName","studentId","name","phone","subjectName","type.msg","time","amount","status == 1 ? '待激活':'已取消'","cancelReason","operatorName","operateTime","createTime"]
 
 
 [平衡关系-乐团课]
 [平衡关系-乐团课]
+headColumns = ["分部","乐团名称","乐团编号","班级名称","班级类型","班级编号","课程类型","期初预收款","期初剩余课次","期初课酬","期初被合并课预收款","期初被合并课剩余课次","期初被合并课课酬","当月新增预收","当月新增课酬","当月新增课次","当月被合并新增预收","当月被合并新增课酬","当月被合并新增课次","当月课耗收入","当月消耗课酬","当月消耗课次","当月被合并课耗收入","当月被合并消耗课酬","当月被合并消耗课次","期末预收款","期末剩余课次","期末课酬","期末被合并课预收款","期末被合并课剩余课次","期末被合并课课酬"]
+fieldColumns = ["organName","musicGroupName","musicGroupId","className","classType","classId","courseType","firstMonthPreAmount","firstMonthSubCourseNum","firstMonthCourseSalary","firstMonthPreMergeAmount","firstMonthSubMergeCourseNum","firstMonthMergeCourseSalary","currentMonthAddCourseAmount","currentMonthAddReward","currentMonthAdd","currentMonthAddMergeCourseAmount","currentMonthMergedAddReward","currentMonthMergedAdd","currentMonthCourseAmount","currentMonthConsumeReward","currentMonthConsume","currentMonthMergeCourseAmount","currentMonthMergedConsumeReward","currentMonthMergedConsume","lastMonthPreAmount","lastMonthSubCourseNum","lastMonthCourseSalary","lastMonthPreMergeAmount","lastMonthSubMergeCourseNum","lastMonthMergeCourseSalary"]
+
+[平衡关系-乐团课汇总]
+headColumns = ["期初预收款","期初剩余课次","期初课酬","当月新增预收","当月新增课酬","当月新增课次","当月课耗收入","当月消耗课酬","当月消耗课次","期末预收款","期末剩余课次","期末课酬"]
+fieldColumns = ["firstMonthPreAmount","firstMonthSubCourseNum","firstMonthCourseSalary","currentMonthAddCourseAmount","currentMonthAddReward","currentMonthAdd","currentMonthCourseAmount","currentMonthConsumeReward","currentMonthConsume","lastMonthPreAmount","lastMonthSubCourseNum","lastMonthCourseSalary"]
+
+[平衡关系-乐团课1]
 headColumns = ["分部","乐团名称","乐团编号","班级名称","班级类型","班级编号","课程类型","剩余课次","剩余课次课酬","剩余被合并课次","剩余被合并课次课酬","已上课次","已上课次课酬","已上被合并课次","已上被合并课次课酬","当月新增","当月新增课酬","当月被合并新增","当月被合并新增课酬","当月消耗","当月消耗课酬","当月被合并消耗","当月被合并消耗课酬"]
 headColumns = ["分部","乐团名称","乐团编号","班级名称","班级类型","班级编号","课程类型","剩余课次","剩余课次课酬","剩余被合并课次","剩余被合并课次课酬","已上课次","已上课次课酬","已上被合并课次","已上被合并课次课酬","当月新增","当月新增课酬","当月被合并新增","当月被合并新增课酬","当月消耗","当月消耗课酬","当月被合并消耗","当月被合并消耗课酬"]
 fieldColumns = ["organName","musicGroupName","musicGroupId","className","classType","classId","courseType","surplusCourse","surplusCourseReward","surplusMergedCourse","surplusMergedCourseReward","alreadyCourse","alreadyCourseReward","alreadyMergedCourse","alreadyMergedCourseReward","currentMonthAdd","currentMonthAddReward","currentMonthMergedAdd","currentMonthMergedAddReward","currentMonthConsume","currentMonthConsumeReward","currentMonthMergedConsume","currentMonthMergedConsumeReward"]
 fieldColumns = ["organName","musicGroupName","musicGroupId","className","classType","classId","courseType","surplusCourse","surplusCourseReward","surplusMergedCourse","surplusMergedCourseReward","alreadyCourse","alreadyCourseReward","alreadyMergedCourse","alreadyMergedCourseReward","currentMonthAdd","currentMonthAddReward","currentMonthMergedAdd","currentMonthMergedAddReward","currentMonthConsume","currentMonthConsumeReward","currentMonthMergedConsume","currentMonthMergedConsumeReward"]
 
 
@@ -408,4 +412,24 @@ fieldColumns = ["organizationName","memberNum","noPlayNum","playTimeLess10","pla
 
 
 [云课堂统计详情导出]
 [云课堂统计详情导出]
 headColumns = ["声部老师","会员人数","无练习人数","0-10分钟","10-60分钟","60-120分钟","120-240分钟",">240分钟","平均时长(分钟)"]
 headColumns = ["声部老师","会员人数","无练习人数","0-10分钟","10-60分钟","60-120分钟","120-240分钟",">240分钟","平均时长(分钟)"]
-fieldColumns = ["teacherName","memberNum","noPlayNum","playTimeLess10","playTimeLess60","playTimeLess120","playTimeLess240","playTimeRather240","avgPlayTime"]
+fieldColumns = ["teacherName","memberNum","noPlayNum","playTimeLess10","playTimeLess60","playTimeLess120","playTimeLess240","playTimeRather240","avgPlayTime"]
+
+[平衡关系-已分班未排课]
+headColumns = ["分部","乐团名称","乐团编号","班级名称","班级类型","班级编号","课程类型","剩余可排课时长","总预收","总课酬"]
+fieldColumns = ["organName","musicGroupName","musicGroupId","className","classType","classId","courseType","subCourseMinutes","totalCoursePrice","totalCourseSalary"]
+
+[平衡关系-已分班未排课汇总]
+headColumns = ["期初剩余可排课时长", "期初总预收", "期初总课酬", "期末剩余可排课时长", "期末总预收", "期末总课酬", "当月新增剩余可排课时长", "当月新增总预收", "当月新增总课酬", "当月消耗可排课时长", "当月消耗总预收", "当月消耗总课酬"]
+fieldColumns = ["firstSubCourseMinutes", "firstTotalCoursePrice", "firstTotalCourseSalary", "lastSubCourseMinutes", "lastTotalCoursePrice", "lastTotalCourseSalary", "currentSubCourseMinutes", "currentTotalCoursePrice", "currentTotalCourseSalary", "currentConsumeCourseMinutes", "currentConsumeCoursePrice", "currentConsumeCourseSalary"]
+
+[平衡关系-VIP剩余课时及金额明细]
+headColumns = ["分部","学校","学生编号","学生姓名","课程类型","期初预收款(已排)","期初预收款(未排)","期初剩余课次(已排)","期初剩余课次(未排)","期初课酬成本(已排)","期初课酬成本(未排)","当月现金收款","当月余额收款","当月新增课次","当月新增课酬(已排)","当月新增课酬(未排)","当月消耗课次","当月课酬","当月课耗总收入","期末预收款(已排)","期末预收款(未排)","期末余额(已排)","期末余额(未排)","期末课酬(已排)","期末课酬(未排)"]
+fieldColumns = ["organName","coopName","userId","username","courseType","firstMonthPreCourseAmount","firstMonthPreNoCourseAmount","firstMonthSubCourseNum","firstMonthSubNoCourseNum","firstMonthCourseSalary","firstMonthNoCourseSalary","currentMonthActualAmount","currentMonthBalanceAmount","currentMonthAddCourseNum","currentMonthAddCourseSalary","currentMonthAddNoCourseSalary","currentMonthConsumeCourseNum","currentMonthCourseSalary","currentMonthCourseAmount","lastMonthPreCourseAmount","lastMonthPreNoCourseAmount","lastMonthSubCourseNum","lastMonthSubNoCourseNum","lastMonthCourseSalary","lastMonthNoCourseSalary"]
+
+[平衡关系-VIP剩余课时及金额汇总]
+headColumns = ["期初预收款(已排)","期初预收款(未排)","期初剩余课次(已排)","期初剩余课次(未排)","期初课酬成本(已排)","期初课酬成本(未排)","当月现金收款","当月余额收款","当月新增课次","当月新增课酬(已排)","当月新增课酬(未排)","当月消耗课次","当月课酬","当月课耗总收入","期末预收款(已排)","期末预收款(未排)","期末余额(已排)","期末余额(未排)","期末课酬(已排)","期末课酬(未排)"]
+fieldColumns = ["firstMonthPreCourseAmount","firstMonthPreNoCourseAmount","firstMonthSubCourseNum","firstMonthSubNoCourseNum","firstMonthCourseSalary","firstMonthNoCourseSalary","currentMonthActualAmount","currentMonthBalanceAmount","currentMonthAddCourseNum","currentMonthAddCourseSalary","currentMonthAddNoCourseSalary","currentMonthConsumeCourseNum","currentMonthCourseSalary","currentMonthCourseAmount","lastMonthPreCourseAmount","lastMonthPreNoCourseAmount","lastMonthSubCourseNum","lastMonthSubNoCourseNum","lastMonthCourseSalary","lastMonthNoCourseSalary"]
+
+[平衡关系-云教练汇总]
+headColumns = ["期初预收款(已激活)", "期初预收款(待激活)", "期初激活人数", "期初待激活人数", "当月新增预收款(当月购买)", "当月新增人数(当月购买)", "当月续费预收款", "当月续费人数", "当月减少人数(到期)", "当月消耗的云教练金额", "当月退费人数", "当月退费金额", "当月激活人数", "期末预收款(已激活)", "期末预收款(待激活)", "期末激活人数", "期末待激活人数"]
+fieldColumns = ["firstMonthPreAmount", "firstMonthPreWaitAmount", "firstMonthActiveNum", "firstMonthWaitActiveNum", "currentMonthAddPreAmount", "currentMonthAddNum", "currentMonthRenewPreAmount", "currentMonthRenewNum", "currentMonthCutNum", "currentMonthAmount", "currentMonthReturnNum", "currentMonthReturnAmount", "currentMonthActiveNum", "lastMonthPreAmount", "lastMonthPreWaitAmount", "lastMonthActiveNum", "lastMonthWaitActiveNum"]

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ExportDao.java

@@ -11,6 +11,8 @@ public interface ExportDao {
 
 
     //平衡关系-乐团课
     //平衡关系-乐团课
     List<ExportWrapper.ExportBalancedRelationshipMusicCourse> exportBalancedRelationshipMusicCourse(@Param("month") String month, @Param("organIds") String organIds);
     List<ExportWrapper.ExportBalancedRelationshipMusicCourse> exportBalancedRelationshipMusicCourse(@Param("month") String month, @Param("organIds") String organIds);
+    //平衡关系-乐团课
+    List<ExportWrapper.ExportBalancedRelationshipMusicCourse> exportBalancedRelationshipMusicCourse1(@Param("month") String month, @Param("organIds") String organIds);
 
 
     //平衡关系-VIP已排课
     //平衡关系-VIP已排课
     List<ExportWrapper.ExportBalancedRelationshipVipCourse> exportBalancedRelationshipVipCourse(@Param("month") String month, @Param("organIds") String organIds);
     List<ExportWrapper.ExportBalancedRelationshipVipCourse> exportBalancedRelationshipVipCourse(@Param("month") String month, @Param("organIds") String organIds);
@@ -35,4 +37,11 @@ public interface ExportDao {
 
 
     //小组课学员课程导出
     //小组课学员课程导出
     List<ExportStudentCourseInfoDto> queryStudentCourseInfo(@Param("organId") String organId, @Param("tenantId") Integer tenantId, @Param("groupType") String groupType);
     List<ExportStudentCourseInfoDto> queryStudentCourseInfo(@Param("organId") String organId, @Param("tenantId") Integer tenantId, @Param("groupType") String groupType);
+
+    //平衡关系-VIP剩余课时及金额明细
+    List<ExportWrapper.ExportBalancedRelationshipVipSubCourseDetail> exportBalancedRelationshipVipSubCourseDetail(@Param("month") String month, @Param("organIds") String organIds);
+
+    List<ExportWrapper.ExportBalancedRelationshipVipSubCourseDetail> exportBalancedRelationshipVipSubCourseSum(@Param("month") String month);
+
+    List<ExportWrapper.ExportBalancedRelationshipCloudSum> exportBalancedRelationshipCloudSum(@Param("month") String month);
 }
 }

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

@@ -546,4 +546,11 @@ public interface MusicGroupDao extends BaseDAO<String, MusicGroup> {
     List<ExportMusicGroupEchelonDataDto> queryMusicGroupEchelonData(@Param("musicGroupIds") List<String> musicGroupIds);
     List<ExportMusicGroupEchelonDataDto> queryMusicGroupEchelonData(@Param("musicGroupIds") List<String> musicGroupIds);
 
 
     List<String> getDelImGroupId();
     List<String> getDelImGroupId();
+
+    List<ExportWrapper.ExportBalancedRelationshipMusicNoCourse> exportBalancedRelationshipMusicNoCourse(@Param("month") String month,@Param("organIds") String organIds);
+
+    BigDecimal exportBalancedRelationshipMusicNoClassNoCourseSum(@Param("month") String month);
+
+    //平衡关系-乐团课
+    ExportWrapper.ExportBalancedRelationshipMusicCourseSum exportBalancedRelationshipMusicCourseSum(@Param("month") String month);
 }
 }

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentStudentCourseDetailLogDao.java

@@ -0,0 +1,9 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetailLog;
+
+public interface MusicGroupPaymentStudentCourseDetailLogDao extends BaseMapper<MusicGroupPaymentStudentCourseDetailLog> {
+
+
+}

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/OperatingReportNewDao.java

@@ -118,4 +118,8 @@ public interface OperatingReportNewDao extends BaseDAO<Integer, OperatingReportN
 
 
     //oa费用明细
     //oa费用明细
     List<FinancialExpenditure> queryOASummaryExpensesDetail(@Param("month") String month);
     List<FinancialExpenditure> queryOASummaryExpensesDetail(@Param("month") String month);
+
+    void firstBalancedRelationship(@Param("month") String month);
+
+    void lastBalancedRelationship(@Param("lastMonth") String lastMonth);
 }
 }

+ 315 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ExportWrapper.java

@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
 
 
+import java.math.BigDecimal;
+
 /**
 /**
  * @author zx
  * @author zx
  */
  */
@@ -254,6 +256,24 @@ public class ExportWrapper {
         @ApiModelProperty("课程类型")
         @ApiModelProperty("课程类型")
         private String courseType;
         private String courseType;
 
 
+        @ApiModelProperty("期初预收款")
+        private Integer firstMonthPreAmount;
+
+        @ApiModelProperty("期初剩余课次")
+        private Integer firstMonthSubCourseNum;
+
+        @ApiModelProperty("期初课酬")
+        private String firstMonthCourseSalary;
+
+        @ApiModelProperty("期初被合并课预收款")
+        private Integer firstMonthPreMergeAmount;
+
+        @ApiModelProperty("期初被合并课剩余课次")
+        private Integer firstMonthSubMergeCourseNum;
+
+        @ApiModelProperty("期初被合并课课酬")
+        private String firstMonthMergeCourseSalary;
+
         @ApiModelProperty("剩余课次")
         @ApiModelProperty("剩余课次")
         private Integer surplusCourse;
         private Integer surplusCourse;
 
 
@@ -281,25 +301,320 @@ public class ExportWrapper {
         @ApiModelProperty("当月新增")
         @ApiModelProperty("当月新增")
         private Integer currentMonthAdd;
         private Integer currentMonthAdd;
 
 
+        @ApiModelProperty("当月新增预收")
+        private String currentMonthAddCourseAmount;
+
         @ApiModelProperty("当月新增课酬")
         @ApiModelProperty("当月新增课酬")
         private String currentMonthAddReward;
         private String currentMonthAddReward;
 
 
         @ApiModelProperty("当月被合并新增")
         @ApiModelProperty("当月被合并新增")
         private Integer currentMonthMergedAdd;
         private Integer currentMonthMergedAdd;
 
 
+        @ApiModelProperty("当月被合并新增预收")
+        private String currentMonthAddMergeCourseAmount;
+
         @ApiModelProperty("当月被合并新增课酬")
         @ApiModelProperty("当月被合并新增课酬")
         private String currentMonthMergedAddReward;
         private String currentMonthMergedAddReward;
 
 
         @ApiModelProperty("当月消耗")
         @ApiModelProperty("当月消耗")
         private Integer currentMonthConsume;
         private Integer currentMonthConsume;
 
 
+        @ApiModelProperty("当月课耗收入")
+        private String currentMonthCourseAmount;
+
         @ApiModelProperty("当月消耗课酬")
         @ApiModelProperty("当月消耗课酬")
         private String currentMonthConsumeReward;
         private String currentMonthConsumeReward;
 
 
         @ApiModelProperty("当月被合并消耗")
         @ApiModelProperty("当月被合并消耗")
         private Integer currentMonthMergedConsume;
         private Integer currentMonthMergedConsume;
 
 
+        @ApiModelProperty("当月被合并课耗收入")
+        private String currentMonthMergeCourseAmount;
+
         @ApiModelProperty("当月被合并消耗课酬")
         @ApiModelProperty("当月被合并消耗课酬")
         private String currentMonthMergedConsumeReward;
         private String currentMonthMergedConsumeReward;
+
+        @ApiModelProperty("期末预收款")
+        private Integer lastMonthPreAmount;
+
+        @ApiModelProperty("期末剩余课次")
+        private Integer lastMonthSubCourseNum;
+
+        @ApiModelProperty("期末课酬")
+        private String lastMonthCourseSalary;
+
+        @ApiModelProperty("期末被合并课预收款")
+        private Integer lastMonthPreMergeAmount;
+
+        @ApiModelProperty("期末被合并课剩余课次")
+        private Integer lastMonthSubMergeCourseNum;
+
+        @ApiModelProperty("期末被合并课课酬")
+        private String lastMonthMergeCourseSalary;
+    }
+    @Data
+    @ApiModel("平衡关系-乐团课汇总")
+    public static class ExportBalancedRelationshipMusicCourseSum {
+
+        @ApiModelProperty("期初预收款")
+        private BigDecimal firstMonthPreAmount;
+
+        @ApiModelProperty("期初剩余课次")
+        private Integer firstMonthSubCourseNum;
+
+        @ApiModelProperty("期初课酬")
+        private BigDecimal firstMonthCourseSalary;
+
+        @ApiModelProperty("当月新增")
+        private Integer currentMonthAdd;
+
+        @ApiModelProperty("当月新增预收")
+        private BigDecimal currentMonthAddCourseAmount;
+
+        @ApiModelProperty("当月新增课酬")
+        private BigDecimal currentMonthAddReward;
+
+        @ApiModelProperty("当月消耗")
+        private Integer currentMonthConsume;
+
+        @ApiModelProperty("当月课耗收入")
+        private BigDecimal currentMonthCourseAmount;
+
+        @ApiModelProperty("当月消耗课酬")
+        private BigDecimal currentMonthConsumeReward;
+
+        @ApiModelProperty("期末预收款")
+        private BigDecimal lastMonthPreAmount;
+
+        @ApiModelProperty("期末剩余课次")
+        private Integer lastMonthSubCourseNum;
+
+        @ApiModelProperty("期末课酬")
+        private BigDecimal lastMonthCourseSalary;
+    }
+
+    @Data
+    @ApiModel("平衡关系-云教练汇总")
+    public static class ExportBalancedRelationshipCloudSum {
+
+        @ApiModelProperty("期初预收款(已激活)")
+        private BigDecimal firstMonthPreAmount = BigDecimal.ZERO;
+
+        @ApiModelProperty("期初预收款(待激活)")
+        private BigDecimal firstMonthPreWaitAmount = BigDecimal.ZERO;
+
+        @ApiModelProperty("期初激活人数")
+        private Integer firstMonthActiveNum = 0;
+
+        @ApiModelProperty("期初待激活人数")
+        private Integer firstMonthWaitActiveNum = 0;
+
+        @ApiModelProperty("当月新增预收款(当月购买)")
+        private BigDecimal currentMonthAddPreAmount = BigDecimal.ZERO;
+
+        @ApiModelProperty("当月新增人数(当月购买)")
+        private Integer currentMonthAddNum = 0;
+
+        @ApiModelProperty("当月续费预收款")
+        private BigDecimal currentMonthRenewPreAmount = BigDecimal.ZERO;
+
+        @ApiModelProperty("当月续费人数")
+        private Integer currentMonthRenewNum = 0;
+
+        @ApiModelProperty("当月减少人数(到期)")
+        private Integer currentMonthCutNum = 0;
+
+        @ApiModelProperty("当月消耗的云教练金额")
+        private BigDecimal currentMonthAmount = BigDecimal.ZERO;
+
+        @ApiModelProperty("当月退费人数")
+        private Integer currentMonthReturnNum = 0;
+
+        @ApiModelProperty("当月退费金额")
+        private BigDecimal currentMonthReturnAmount = BigDecimal.ZERO;
+
+        @ApiModelProperty("当月激活人数")
+        private Integer currentMonthActiveNum = 0;
+
+        @ApiModelProperty("期末预收款(已激活)")
+        private BigDecimal lastMonthPreAmount = BigDecimal.ZERO;
+
+        @ApiModelProperty("期末预收款(待激活)")
+        private BigDecimal lastMonthPreWaitAmount = BigDecimal.ZERO;
+
+        @ApiModelProperty("期末激活人数")
+        private Integer lastMonthActiveNum = 0;
+
+        @ApiModelProperty("期末待激活人数")
+        private Integer lastMonthWaitActiveNum = 0;
+    }
+
+    @Data
+    @ApiModel("平衡关系-已分班未排课")
+    public static class ExportBalancedRelationshipMusicNoCourse {
+        @ApiModelProperty("分部")
+        private String organName;
+
+        @ApiModelProperty("乐团名称")
+        private String musicGroupName;
+
+        @ApiModelProperty("乐团编号")
+        private String musicGroupId;
+
+        @ApiModelProperty("班级名称")
+        private String className;
+
+        @ApiModelProperty("班级类型")
+        private String classType;
+
+        @ApiModelProperty("班级编号")
+        private String classId;
+
+        @ApiModelProperty("学生人数")
+        private Integer studentNum;
+
+        @ApiModelProperty("课程类型")
+        private String courseType;
+
+        @ApiModelProperty("老师编号")
+        private Integer teacherId;
+
+        @ApiModelProperty("剩余可排课时长")
+        private Integer subCourseMinutes = 0;
+
+        @ApiModelProperty("总预收")
+        private BigDecimal totalCoursePrice = BigDecimal.ZERO;
+
+        @ApiModelProperty("总课酬")
+        private BigDecimal totalCourseSalary = BigDecimal.ZERO;
+
+        @ApiModelProperty("期初剩余可排课时长")
+        private Integer firstSubCourseMinutes = 0;
+
+        @ApiModelProperty("期初总预收")
+        private BigDecimal firstTotalCoursePrice = BigDecimal.ZERO;
+
+        @ApiModelProperty("期初总课酬")
+        private BigDecimal firstTotalCourseSalary = BigDecimal.ZERO;
+
+        @ApiModelProperty("期末剩余可排课时长")
+        private Integer lastSubCourseMinutes = 0;
+
+        @ApiModelProperty("期末总预收")
+        private BigDecimal lastTotalCoursePrice = BigDecimal.ZERO;
+
+        @ApiModelProperty("期末总课酬")
+        private BigDecimal lastTotalCourseSalary = BigDecimal.ZERO;
+
+        @ApiModelProperty("当月新增剩余可排课时长")
+        private Integer currentSubCourseMinutes = 0;
+
+        @ApiModelProperty("当月新增总预收")
+        private BigDecimal currentTotalCoursePrice = BigDecimal.ZERO;
+
+        @ApiModelProperty("当月新增总课酬")
+        private BigDecimal currentTotalCourseSalary = BigDecimal.ZERO;
+
+        @ApiModelProperty("当月消耗可排课时长")
+        private Integer currentConsumeCourseMinutes = 0;
+
+        @ApiModelProperty("当月消耗总预收")
+        private BigDecimal currentConsumeCoursePrice = BigDecimal.ZERO;
+
+        @ApiModelProperty("当月消耗总课酬")
+        private BigDecimal currentConsumeCourseSalary = BigDecimal.ZERO;
+    }
+
+    @Data
+    @ApiModel("平衡关系-未分班未排课")
+    public static class ExportBalancedRelationshipMusicNoClassNoCourse {
+
+        @ApiModelProperty("期初总预收")
+        private BigDecimal firstTotalCoursePrice = BigDecimal.ZERO;
+
+        @ApiModelProperty("期末总预收")
+        private BigDecimal lastTotalCoursePrice = BigDecimal.ZERO;
+
+        @ApiModelProperty("当月新增总预收")
+        private BigDecimal currentTotalCoursePrice = BigDecimal.ZERO;
+    }
+
+    @Data
+    @ApiModel("平衡关系-VIP剩余课时及金额明细")
+    public static class ExportBalancedRelationshipVipSubCourseDetail {
+        @ApiModelProperty("分部")
+        private String organName;
+
+        @ApiModelProperty("学校")
+        private String coopName;
+
+        @ApiModelProperty("学生编号")
+        private Integer userId;
+
+        @ApiModelProperty("学生姓名")
+        private String username;
+
+        @ApiModelProperty("课程类型")
+        private String courseType;
+
+        @ApiModelProperty("期初预收款(已排)")
+        private BigDecimal firstMonthPreCourseAmount;
+
+        @ApiModelProperty("期初预收款(未排)")
+        private BigDecimal firstMonthPreNoCourseAmount;
+
+        @ApiModelProperty("期初剩余课次(已排)")
+        private Integer firstMonthSubCourseNum;
+
+        @ApiModelProperty("期初剩余课次(未排)")
+        private Integer firstMonthSubNoCourseNum;
+
+        @ApiModelProperty("期初课酬成本(已排)")
+        private BigDecimal firstMonthCourseSalary;
+
+        @ApiModelProperty("期初课酬成本(未排)")
+        private BigDecimal firstMonthNoCourseSalary;
+
+        @ApiModelProperty("当月现金收款")
+        private BigDecimal currentMonthActualAmount;
+
+        @ApiModelProperty("当月余额收款")
+        private BigDecimal currentMonthBalanceAmount;
+
+        @ApiModelProperty("当月新增课次")
+        private Integer currentMonthAddCourseNum;
+
+        @ApiModelProperty("当月新增课酬(已排)")
+        private BigDecimal currentMonthAddCourseSalary;
+
+        @ApiModelProperty("当月新增课酬(未排)")
+        private BigDecimal currentMonthAddNoCourseSalary;
+
+        @ApiModelProperty("当月消耗课次")
+        private Integer currentMonthConsumeCourseNum;
+
+        @ApiModelProperty("当月课酬")
+        private BigDecimal currentMonthCourseSalary;
+
+        @ApiModelProperty("当月课耗总收入")
+        private BigDecimal currentMonthCourseAmount;
+
+        @ApiModelProperty("期末预收款(已排)")
+        private BigDecimal lastMonthPreCourseAmount;
+
+        @ApiModelProperty("期末预收款(未排)")
+        private BigDecimal lastMonthPreNoCourseAmount;
+
+        @ApiModelProperty("期末余额(已排)")
+        private Integer lastMonthSubCourseNum;
+
+        @ApiModelProperty("期末余额(未排)")
+        private Integer lastMonthSubNoCourseNum;
+
+        @ApiModelProperty("期末课酬(已排)")
+        private BigDecimal lastMonthCourseSalary;
+
+        @ApiModelProperty("期末课酬(未排)")
+        private BigDecimal lastMonthNoCourseSalary;
     }
     }
 }
 }

+ 52 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentStudentCourseDetailLog.java

@@ -0,0 +1,52 @@
+package com.ym.mec.biz.dal.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * 对应数据库表(music_group_payment_student_course_detail_log):
+ */
+@Data
+public class MusicGroupPaymentStudentCourseDetailLog{
+	@TableId(value = "id_")
+	private Long id;
+
+	@ApiModelProperty(value = "班级编号")
+	@TableField(value = "class_group_id_")
+	private Integer classGroupId;
+
+	@ApiModelProperty(value = "课程类型")
+	@TableField(value = "course_type_")
+	private String courseType;
+
+	@ApiModelProperty(value = "排课时长编号")
+	@TableField(value = "music_group_payment_student_course_detail_id_")
+	private Long musicGroupPaymentStudentCourseDetailId;
+
+	@ApiModelProperty(value = "本次排课预收款")
+	@TableField(value = "course_price_")
+	private BigDecimal coursePrice = BigDecimal.ZERO;
+
+	@ApiModelProperty(value = "本次排课总课酬")
+	@TableField(value = "course_salary_")
+	private BigDecimal courseSalary = BigDecimal.ZERO;
+
+	@ApiModelProperty(value = "本次消耗排课时长")
+	@TableField(value = "used_course_minutes_")
+	private Integer usedCourseMinutes = 0;
+
+	@ApiModelProperty(value = "本次排课次数")
+	@TableField(value = "course_num_")
+	private Integer courseNum = 0;
+
+	@TableField(value = "create_time_")
+	private java.util.Date createTime;
+
+	@TableField(value = "update_time_")
+	private java.util.Date updateTime;
+
+}

+ 9 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/ExportEnum.java

@@ -96,7 +96,7 @@ public enum ExportEnum implements BaseEnum<String, ExportEnum> {
     EXPORT_MUSIC_GROUP_ECHELON_DATA("EXPORT_MUSIC_GROUP_ECHELON_DATA","乐团梯队数据导出"),
     EXPORT_MUSIC_GROUP_ECHELON_DATA("EXPORT_MUSIC_GROUP_ECHELON_DATA","乐团梯队数据导出"),
     EXPORT_CLOUD_TEACHER_ORDER_INACTIVE("EXPORT_CLOUD_TEACHER_ORDER_INACTIVE","云教练待激活明细"),
     EXPORT_CLOUD_TEACHER_ORDER_INACTIVE("EXPORT_CLOUD_TEACHER_ORDER_INACTIVE","云教练待激活明细"),
     EXPORT_MUSIC_GROUP_NO_COURSE("EXPORT_MUSIC_GROUP_NO_COURSE","乐团未排课时长"),
     EXPORT_MUSIC_GROUP_NO_COURSE("EXPORT_MUSIC_GROUP_NO_COURSE","乐团未排课时长"),
-    EXPORT_BALANCED_RELATIONSHIP_MUSIC_COURSE("EXPORT_MUSIC_GROUP_NO_COURSE","平衡关系-乐团课"),
+    EXPORT_BALANCED_RELATIONSHIP_MUSIC_COURSE("EXPORT_BALANCED_RELATIONSHIP_MUSIC_COURSE","平衡关系-乐团课"),
     EXPORT_BALANCED_RELATIONSHIP_VIP_COURSE("EXPORT_BALANCED_RELATIONSHIP_VIP_COURSE","平衡关系-VIP已排课"),
     EXPORT_BALANCED_RELATIONSHIP_VIP_COURSE("EXPORT_BALANCED_RELATIONSHIP_VIP_COURSE","平衡关系-VIP已排课"),
     EXPORT_BALANCED_RELATIONSHIP_VIP_NO_COURSE("EXPORT_BALANCED_RELATIONSHIP_VIP_NO_COURSE","平衡关系-VIP未排课"),
     EXPORT_BALANCED_RELATIONSHIP_VIP_NO_COURSE("EXPORT_BALANCED_RELATIONSHIP_VIP_NO_COURSE","平衡关系-VIP未排课"),
     EXPORT_BALANCED_RELATIONSHIP_MUSIC_SUB_COURSE("EXPORT_BALANCED_RELATIONSHIP_MUSIC_SUB_COURSE","平衡关系-缴费项目课时明细"),
     EXPORT_BALANCED_RELATIONSHIP_MUSIC_SUB_COURSE("EXPORT_BALANCED_RELATIONSHIP_MUSIC_SUB_COURSE","平衡关系-缴费项目课时明细"),
@@ -105,6 +105,14 @@ public enum ExportEnum implements BaseEnum<String, ExportEnum> {
     EXPORT_BALANCED_RELATIONSHIP_STUDENT_QUIT_DETAIL("EXPORT_BALANCED_RELATIONSHIP_STUDENT_QUIT_DETAIL","平衡关系(分表)-乐团退团学员"),
     EXPORT_BALANCED_RELATIONSHIP_STUDENT_QUIT_DETAIL("EXPORT_BALANCED_RELATIONSHIP_STUDENT_QUIT_DETAIL","平衡关系(分表)-乐团退团学员"),
     VIDEO_PLAY_STAT("VIDEO_PLAY_STAT","云课堂统计导出"),
     VIDEO_PLAY_STAT("VIDEO_PLAY_STAT","云课堂统计导出"),
     VIDEO_PLAY_DETAIL_STAT("VIDEO_PLAY_DETAIL_STAT","云课堂统计详情导出"),
     VIDEO_PLAY_DETAIL_STAT("VIDEO_PLAY_DETAIL_STAT","云课堂统计详情导出"),
+    EXPORT_BALANCED_RELATIONSHIP_MUSIC_NO_COURSE("EXPORT_BALANCED_RELATIONSHIP_MUSIC_NO_COURSE","平衡关系-已分班未排课"),
+    EXPORT_BALANCED_RELATIONSHIP_MUSIC_NO_COURSE_SUM("EXPORT_BALANCED_RELATIONSHIP_MUSIC_NO_COURSE_SUM","平衡关系-已分班未排课汇总"),
+
+    EXPORT_BALANCED_RELATIONSHIP_MUSIC_NO_CLASS_NO_COURSE_SUM("EXPORT_BALANCED_RELATIONSHIP_MUSIC_NO_CLASS_NO_COURSE_SUM","平衡关系-未分班未排课汇总"),
+    EXPORT_BALANCED_RELATIONSHIP_VIP_SUB_COURSE_DETAIL("EXPORT_BALANCED_RELATIONSHIP_VIP_SUB_COURSE_DETAIL","平衡关系-VIP剩余课时及金额明细"),
+    EXPORT_BALANCED_RELATIONSHIP_VIP_SUB_COURSE_SUM("EXPORT_BALANCED_RELATIONSHIP_VIP_SUB_COURSE_SUM","平衡关系-VIP剩余课时及金额汇总"),
+    EXPORT_BALANCED_RELATIONSHIP_MUSIC_COURSE_SUM("EXPORT_BALANCED_RELATIONSHIP_MUSIC_COURSE_SUM","平衡关系-乐团课汇总"),
+    EXPORT_BALANCED_RELATIONSHIP_CLOUD_SUM("EXPORT_BALANCED_RELATIONSHIP_CLOUD_SUM","平衡关系-云教练汇总"),
     ;
     ;
 
 
     private String code;
     private String code;

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/ExportTypeEnum.java

@@ -43,6 +43,15 @@ public enum ExportTypeEnum implements BaseEnum<Integer, ExportTypeEnum> {
 	EXPORT_BALANCED_RELATIONSHIP_STUDENT_QUIT_DETAIL(36,"平衡关系(分表)-乐团退团学员"),
 	EXPORT_BALANCED_RELATIONSHIP_STUDENT_QUIT_DETAIL(36,"平衡关系(分表)-乐团退团学员"),
 	VIDEO_PLAY_STAT(37,"云课堂统计导出"),
 	VIDEO_PLAY_STAT(37,"云课堂统计导出"),
 	VIDEO_PLAY_DETAIL_STAT(38,"云课堂统计详情导出"),
 	VIDEO_PLAY_DETAIL_STAT(38,"云课堂统计详情导出"),
+	EXPORT_BALANCED_RELATIONSHIP_MUSIC_NO_COURSE(39,"平衡关系-已分班未排课"),
+	EXPORT_BALANCED_RELATIONSHIP_VIP_SUB_COURSE_DETAIL(40,"平衡关系-VIP剩余课时及金额明细"),
+	EXPORT_BALANCED_RELATIONSHIP_VIP_SUB_COURSE_SUM(41,"平衡关系-VIP剩余课时及金额汇总"),
+
+	EXPORT_BALANCED_RELATIONSHIP_MUSIC_NO_COURSE_SUM(42,"平衡关系-已分班未排课汇总"),
+
+	EXPORT_BALANCED_RELATIONSHIP_MUSIC_NO_CLASS_NO_COURSE_SUM(43,"平衡关系-未分班未排课汇总"),
+	EXPORT_BALANCED_RELATIONSHIP_MUSIC_COURSE_SUM(44,"平衡关系-乐团课汇总"),
+	EXPORT_BALANCED_RELATIONSHIP_CLOUD_SUM(45,"平衡关系-云教练汇总")
 	;
 	;
 
 
 	private Integer code;
 	private Integer code;

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

@@ -8,6 +8,7 @@ import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.page.CourseScheduleStudentPaymentQueryInfo;
 import com.ym.mec.biz.dal.page.CourseScheduleStudentPaymentQueryInfo;
 import com.ym.mec.common.service.BaseService;
 import com.ym.mec.common.service.BaseService;
 
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
@@ -70,7 +71,7 @@ public interface CourseScheduleStudentPaymentService extends BaseService<Long, C
 	 * @param studentIds: 课程学员列表
 	 * @param studentIds: 课程学员列表
 	 * @return void
 	 * @return void
 	 */
 	 */
-	void createForMusicGroup(String musicGroupId, List<CourseSchedule> courseSchedules, List<Integer> studentIds);
+	void createForMusicGroup(String musicGroupId, List<CourseSchedule> courseSchedules, List<Integer> studentIds,Map<Long, BigDecimal> salaryMap);
 
 
 	/**
 	/**
 	 * @describe 创建课程缴费记录-会员乐团
 	 * @describe 创建课程缴费记录-会员乐团
@@ -91,7 +92,7 @@ public interface CourseScheduleStudentPaymentService extends BaseService<Long, C
 	 * @param studentIds: 课程学员列表
 	 * @param studentIds: 课程学员列表
 	 * @return void
 	 * @return void
 	 */
 	 */
-	void createForMusicGroup(List<CourseSchedule> courseSchedules, List<Integer> studentIds,Integer musicGroupStudentClassAdjustId);
+	void createForMusicGroup(List<CourseSchedule> courseSchedules, List<Integer> studentIds,Integer musicGroupStudentClassAdjustId,Map<Long,BigDecimal> salaryMap);
 
 
 	/**
 	/**
 	 * 获取班级未开始的的课程
 	 * 获取班级未开始的的课程

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentStudentCourseDetailLogService.java

@@ -0,0 +1,9 @@
+package com.ym.mec.biz.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetailLog;
+
+
+public interface MusicGroupPaymentStudentCourseDetailLogService extends IService<MusicGroupPaymentStudentCourseDetailLog>  {
+
+}

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupService.java

@@ -486,4 +486,12 @@ public interface MusicGroupService extends BaseService<String, MusicGroup> {
     List<Subject> getSubjectListByIdAndCoopId(String musicGroupId, Integer coopId);
     List<Subject> getSubjectListByIdAndCoopId(String musicGroupId, Integer coopId);
 
 
     Map<String, List<ExportMusicGroupEchelonDataDto>> queryMusicGroupEchelonData(List<Integer> organIds);
     Map<String, List<ExportMusicGroupEchelonDataDto>> queryMusicGroupEchelonData(List<Integer> organIds);
+
+    List<ExportWrapper.ExportBalancedRelationshipMusicNoCourse> exportBalancedRelationshipMusicNoCourse(String month, String organIds);
+
+    List<ExportWrapper.ExportBalancedRelationshipMusicNoCourse> exportBalancedRelationshipMusicNoCourseSum(String month);
+
+    List<ExportWrapper.ExportBalancedRelationshipMusicNoClassNoCourse> exportBalancedRelationshipMusicNoClassNoCourseSum(String month);
+
+    List<ExportWrapper.ExportBalancedRelationshipMusicCourseSum> exportBalancedRelationshipMusicCourseSum(String month);
 }
 }

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/OperatingReportNewService.java

@@ -20,4 +20,6 @@ public interface OperatingReportNewService extends BaseService<Integer, Operatin
 
 
     //oa费用明细
     //oa费用明细
     List<FinancialExpenditure> queryOASummaryExpensesDetail(String month);
     List<FinancialExpenditure> queryOASummaryExpensesDetail(String month);
+
+    void balancedRelationship(String month);
 }
 }

+ 28 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -2242,18 +2242,23 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             }
             }
         }
         }
 
 
-        if (courseScheduleList.size() > 0) {
+        if (CollectionUtils.isNotEmpty(courseScheduleList)) {
             //检测新排课冲突
             //检测新排课冲突
             courseScheduleService.checkNewCourseSchedules(courseScheduleList, false, false);
             courseScheduleService.checkNewCourseSchedules(courseScheduleList, false, false);
         }
         }
 
 
         //老师结算表
         //老师结算表
-        if (courseScheduleTeacherSalaryList.size() > 0) {
+        if (CollectionUtils.isNotEmpty(courseScheduleTeacherSalaryList)) {
             courseScheduleTeacherSalaryService.batchInsert(courseScheduleTeacherSalaryList);
             courseScheduleTeacherSalaryService.batchInsert(courseScheduleTeacherSalaryList);
         }
         }
         //学生结算表
         //学生结算表
-        if (courseScheduleList.size() > 0) {
-            courseScheduleStudentPaymentService.createForMusicGroup(musicGroupId, courseScheduleList, studentIdList);
+        if (CollectionUtils.isNotEmpty(courseScheduleList)){
+            Map<Long,BigDecimal> salaryMap = new HashMap<>();
+            if (CollectionUtils.isNotEmpty(courseScheduleTeacherSalaryList)) {
+                salaryMap = courseScheduleTeacherSalaryList.stream()
+                        .collect(Collectors.toMap(CourseScheduleTeacherSalary::getCourseScheduleId, CourseScheduleTeacherSalary::getExpectSalary));
+            }
+            courseScheduleStudentPaymentService.createForMusicGroup(musicGroupId, courseScheduleList, studentIdList,salaryMap);
             studentService.updateStudentServiceTag(null, studentIdList, YesOrNoEnum.YES.getCode());
             studentService.updateStudentServiceTag(null, studentIdList, YesOrNoEnum.YES.getCode());
         }
         }
         //创建IM群组
         //创建IM群组
@@ -2518,7 +2523,12 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             }
             }
             Integer musicGroupStudentClassAdjustId = classGroup4MixDto.getMusicGroupStudentClassAdjustId();
             Integer musicGroupStudentClassAdjustId = classGroup4MixDto.getMusicGroupStudentClassAdjustId();
             //学生结算表
             //学生结算表
-            courseScheduleStudentPaymentService.createForMusicGroup(courseScheduleList, studentIdList, musicGroupStudentClassAdjustId);
+            Map<Long,BigDecimal> salaryMap = new HashMap<>();
+            if (org.apache.commons.collections.CollectionUtils.isNotEmpty(courseScheduleTeacherSalaryList)) {
+                salaryMap = courseScheduleTeacherSalaryList.stream()
+                        .collect(Collectors.toMap(CourseScheduleTeacherSalary::getCourseScheduleId, CourseScheduleTeacherSalary::getExpectSalary));
+            }
+            courseScheduleStudentPaymentService.createForMusicGroup(courseScheduleList, studentIdList, musicGroupStudentClassAdjustId,salaryMap);
             return classGroup;
             return classGroup;
         }
         }
         return null;
         return null;
@@ -2832,9 +2842,14 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 
 
         if (!CollectionUtils.isEmpty(studentList)) {
         if (!CollectionUtils.isEmpty(studentList)) {
             studentService.updateStudentServiceTag(null, studentIds, YesOrNoEnum.YES.getCode());
             studentService.updateStudentServiceTag(null, studentIds, YesOrNoEnum.YES.getCode());
-
+            Map<Long,BigDecimal> salaryMap = new HashMap<>();
+            if (CollectionUtils.isNotEmpty(courseScheduleTeacherSalaryList)) {
+                //汇总同一节课课程课酬
+                salaryMap = courseScheduleTeacherSalaryList.stream().collect(Collectors.groupingBy(CourseScheduleTeacherSalary::getCourseScheduleId,
+                        Collectors.reducing(BigDecimal.ZERO, CourseScheduleTeacherSalary::getExpectSalary, BigDecimal::add)));
+            }
             //学生结算表
             //学生结算表
-            courseScheduleStudentPaymentService.createForMusicGroup(musicGroupId, courseScheduleList, studentIds);
+            courseScheduleStudentPaymentService.createForMusicGroup(musicGroupId, courseScheduleList, studentIds,salaryMap);
         }
         }
         //学校端推送
         //学校端推送
         courseScheduleModifyLogService.pushSchoolCourseCreate(courseScheduleList.get(0),musicGroup);
         courseScheduleModifyLogService.pushSchoolCourseCreate(courseScheduleList.get(0),musicGroup);
@@ -3482,7 +3497,12 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 
 
         //学生结算表
         //学生结算表
         if (!CollectionUtils.isEmpty(studentIdList)) {
         if (!CollectionUtils.isEmpty(studentIdList)) {
-            courseScheduleStudentPaymentService.createForMusicGroup(musicGroupId, courseScheduleList, studentIdList);
+            Map<Long,BigDecimal> salaryMap = new HashMap<>();
+            if (CollectionUtils.isNotEmpty(courseScheduleTeacherSalaryList)) {
+                salaryMap = courseScheduleTeacherSalaryList.stream()
+                        .collect(Collectors.toMap(CourseScheduleTeacherSalary::getCourseScheduleId, CourseScheduleTeacherSalary::getExpectSalary));
+            }
+            courseScheduleStudentPaymentService.createForMusicGroup(musicGroupId, courseScheduleList, studentIdList,salaryMap);
             studentService.updateStudentServiceTag(null, studentIdList, YesOrNoEnum.YES.getCode());
             studentService.updateStudentServiceTag(null, studentIdList, YesOrNoEnum.YES.getCode());
         }
         }
         return classGroup;
         return classGroup;

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

@@ -550,10 +550,10 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
             courseScheduleDao.deleteMusicGroupCourseSchedulesWithStudents(courseIds, new ArrayList<>(removeStudentIds));
             courseScheduleDao.deleteMusicGroupCourseSchedulesWithStudents(courseIds, new ArrayList<>(removeStudentIds));
         }
         }
 
 
-        if (!CollectionUtils.isEmpty(addStudentIds)) {
+        /*if (!CollectionUtils.isEmpty(addStudentIds)) {
             courseScheduleStudentPaymentService.createForMusicGroup(classGroup.getMusicGroupId(), classGroupNotStartCourse, new ArrayList<>(addStudentIds));
             courseScheduleStudentPaymentService.createForMusicGroup(classGroup.getMusicGroupId(), classGroupNotStartCourse, new ArrayList<>(addStudentIds));
             studentDao.updateStudentServiceTag(null, new ArrayList<>(addStudentIds), YesOrNoEnum.YES.getCode());
             studentDao.updateStudentServiceTag(null, new ArrayList<>(addStudentIds), YesOrNoEnum.YES.getCode());
-        }
+        }*/
 
 
         //4、调整未上课课酬
         //4、调整未上课课酬
         if(!CollectionUtils.isEmpty(classGroupNotStartCourse)){
         if(!CollectionUtils.isEmpty(classGroupNotStartCourse)){
@@ -573,6 +573,15 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
                 courseScheduleTeacherSalaryService.createMusicGroupCourseTeacherSalary(null, idCourseMap.get(oldCourseSalary.getCourseScheduleId()), oldCourseSalary);
                 courseScheduleTeacherSalaryService.createMusicGroupCourseTeacherSalary(null, idCourseMap.get(oldCourseSalary.getCourseScheduleId()), oldCourseSalary);
             }
             }
             courseScheduleTeacherSalaryService.batchInsert(oldCourseSalaries);
             courseScheduleTeacherSalaryService.batchInsert(oldCourseSalaries);
+            if (!CollectionUtils.isEmpty(addStudentIds)) {
+                Map<Long,BigDecimal> salaryMap = new HashMap<>();
+                if (org.apache.commons.collections.CollectionUtils.isNotEmpty(oldCourseSalaries)) {
+                    salaryMap = oldCourseSalaries.stream()
+                            .collect(Collectors.toMap(CourseScheduleTeacherSalary::getCourseScheduleId, CourseScheduleTeacherSalary::getExpectSalary));
+                }
+                courseScheduleStudentPaymentService.createForMusicGroup(classGroup.getMusicGroupId(), classGroupNotStartCourse, new ArrayList<>(addStudentIds),salaryMap);
+                studentDao.updateStudentServiceTag(null, new ArrayList<>(addStudentIds), YesOrNoEnum.YES.getCode());
+            }
         }
         }
 
 
         if(musicGroup.getStatus() == MusicGroupStatusEnum.PROGRESS){
         if(musicGroup.getStatus() == MusicGroupStatusEnum.PROGRESS){

+ 99 - 55
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java

@@ -10,10 +10,7 @@ import com.ym.mec.biz.dal.dto.VipGroupGiveCourseSortDto;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.page.CourseScheduleStudentPaymentQueryInfo;
 import com.ym.mec.biz.dal.page.CourseScheduleStudentPaymentQueryInfo;
-import com.ym.mec.biz.service.CourseScheduleStudentPaymentService;
-import com.ym.mec.biz.service.OperatingReportCloudService;
-import com.ym.mec.biz.service.StudentRegistrationService;
-import com.ym.mec.biz.service.SysUserCashAccountService;
+import com.ym.mec.biz.service.*;
 import com.ym.mec.common.constant.CommonConstants;
 import com.ym.mec.common.constant.CommonConstants;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.exception.BizException;
@@ -22,13 +19,12 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.date.DateUtil;
 import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.CollectionUtils;
-
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.math.RoundingMode;
 import java.util.*;
 import java.util.*;
@@ -60,6 +56,8 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 	@Autowired
 	@Autowired
 	private MusicGroupPaymentStudentCourseDetailDao musicGroupPaymentStudentCourseDetailDao;
 	private MusicGroupPaymentStudentCourseDetailDao musicGroupPaymentStudentCourseDetailDao;
 	@Autowired
 	@Autowired
+	private MusicGroupPaymentStudentCourseDetailLogService musicGroupPaymentStudentCourseDetailLogService;
+	@Autowired
 	private TeacherDao teacherDao;
 	private TeacherDao teacherDao;
 	@Autowired
 	@Autowired
 	private StudentAttendanceDao studentAttendanceDao;
 	private StudentAttendanceDao studentAttendanceDao;
@@ -123,39 +121,39 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 			List<CourseSchedule> courseSchedules = courseScheduleGroupByTeachMode.get(teachModeEnum)
 			List<CourseSchedule> courseSchedules = courseScheduleGroupByTeachMode.get(teachModeEnum)
 					.stream()
 					.stream()
 					.sorted(Comparator.comparing(CourseSchedule::getStartClassTime)).collect(Collectors.toList());
 					.sorted(Comparator.comparing(CourseSchedule::getStartClassTime)).collect(Collectors.toList());
-			for(int i=0;i<courseSchedules.size();i++) {
-				//创建学生课程应缴费记录
-				CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
-				courseScheduleStudentPayment.setUserId(userId);
-	            courseScheduleStudentPayment.setGroupType(courseSchedules.get(i).getGroupType());
-	            courseScheduleStudentPayment.setMusicGroupId(courseSchedules.get(i).getMusicGroupId());
-				courseScheduleStudentPayment.setCourseScheduleId(courseSchedules.get(i).getId());
-				courseScheduleStudentPayment.setClassGroupId(courseSchedules.get(i).getClassGroupId());
-
-				if (teachModeEnum == TeachModeEnum.ONLINE) {
-					//学生线上单节课应缴费计算
-					courseScheduleStudentPayment.setExpectPrice(
-							vipGroup.getOnlineClassesUnitPrice().multiply(vipGroupActivity.getDiscount())
-									.divide(new BigDecimal(100), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP)
-									.subtract(couponFee));
-				}else{
-					//学生线下单节课应缴费计算
-					courseScheduleStudentPayment.setExpectPrice(
-							vipGroup.getOfflineClassesUnitPrice().multiply(vipGroupActivity.getDiscount())
-									.divide(new BigDecimal(100), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP)
-									.subtract(couponFee));
-				}
-                courseScheduleStudentPayment.setOriginalPrice(TeachModeEnum.ONLINE.equals(teachModeEnum)?vipGroupDefaultClassesUnitPrice.getOnlineClassesUnitPrice():vipGroupDefaultClassesUnitPrice.getOfflineClassesUnitPrice());
-				courseScheduleStudentPayment.setActualPrice(courseScheduleStudentPayment.getExpectPrice());
-				courseScheduleStudentPayments.add(courseScheduleStudentPayment);
-			}
+            for (CourseSchedule courseSchedule : courseSchedules) {
+                //创建学生课程应缴费记录
+                CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
+                courseScheduleStudentPayment.setUserId(userId);
+                courseScheduleStudentPayment.setGroupType(courseSchedule.getGroupType());
+                courseScheduleStudentPayment.setMusicGroupId(courseSchedule.getMusicGroupId());
+                courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
+                courseScheduleStudentPayment.setClassGroupId(courseSchedule.getClassGroupId());
+
+                if (teachModeEnum == TeachModeEnum.ONLINE) {
+                    //学生线上单节课应缴费计算
+                    courseScheduleStudentPayment.setExpectPrice(
+                            vipGroup.getOnlineClassesUnitPrice().multiply(vipGroupActivity.getDiscount())
+                                    .divide(new BigDecimal(100), CommonConstants.DECIMAL_FINAL_PLACE, RoundingMode.HALF_UP)
+                                    .subtract(couponFee));
+                } else {
+                    //学生线下单节课应缴费计算
+                    courseScheduleStudentPayment.setExpectPrice(
+                            vipGroup.getOfflineClassesUnitPrice().multiply(vipGroupActivity.getDiscount())
+                                    .divide(new BigDecimal(100), CommonConstants.DECIMAL_FINAL_PLACE, RoundingMode.HALF_UP)
+                                    .subtract(couponFee));
+                }
+                courseScheduleStudentPayment.setOriginalPrice(TeachModeEnum.ONLINE.equals(teachModeEnum) ? vipGroupDefaultClassesUnitPrice.getOnlineClassesUnitPrice() : vipGroupDefaultClassesUnitPrice.getOfflineClassesUnitPrice());
+                courseScheduleStudentPayment.setActualPrice(courseScheduleStudentPayment.getExpectPrice());
+                courseScheduleStudentPayments.add(courseScheduleStudentPayment);
+            }
 		}
 		}
 		return courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
 		return courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
 	}
 	}
 
 
     @Override
     @Override
     public int deleteStudentCourseSchedule(Integer userId, List<CourseSchedule> courseScheduleList) {
     public int deleteStudentCourseSchedule(Integer userId, List<CourseSchedule> courseScheduleList) {
-		if(courseScheduleList.size() == 0){
+		if(CollectionUtils.isEmpty(courseScheduleList)){
 			return 0;
 			return 0;
 		}
 		}
 		List<Long> courseScheduleIdList = courseScheduleList.stream().map(CourseSchedule :: getId).collect(Collectors.toList());
 		List<Long> courseScheduleIdList = courseScheduleList.stream().map(CourseSchedule :: getId).collect(Collectors.toList());
@@ -286,7 +284,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 
 
 	@Override
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	@Transactional(rollbackFor = Exception.class)
-	public void createForMusicGroup(List<CourseSchedule> courseSchedules, List<Integer> studentIds,Integer musicGroupStudentClassAdjustId) {
+	public void createForMusicGroup(List<CourseSchedule> courseSchedules, List<Integer> studentIds,Integer musicGroupStudentClassAdjustId,Map<Long,BigDecimal> salaryMap) {
 		//获取提交的合班申请
 		//获取提交的合班申请
 		MusicGroupStudentClassAdjust classAdjust = musicGroupStudentClassAdjustDao.get(musicGroupStudentClassAdjustId);
 		MusicGroupStudentClassAdjust classAdjust = musicGroupStudentClassAdjustDao.get(musicGroupStudentClassAdjustId);
 		List<Long> studentPaymentIds = JSON.parseArray(classAdjust.getStudentPaymentIds(), Long.class);
 		List<Long> studentPaymentIds = JSON.parseArray(classAdjust.getStudentPaymentIds(), Long.class);
@@ -297,18 +295,19 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 //		String courseDefaultMinutes = sysConfigDao.findConfigValue("music_course_default_minutes");
 //		String courseDefaultMinutes = sysConfigDao.findConfigValue("music_course_default_minutes");
 		JSONObject jsonObject = JSON.parseObject(classAdjust.getDefaultCourseTypeMinute());
 		JSONObject jsonObject = JSON.parseObject(classAdjust.getDefaultCourseTypeMinute());
 		List<CourseScheduleStudentPayment> totalCourseScheduleStudentPayments = new ArrayList<>();
 		List<CourseScheduleStudentPayment> totalCourseScheduleStudentPayments = new ArrayList<>();
+		List<MusicGroupPaymentStudentCourseDetailLog> musicGroupPaymentStudentCourseDetailLogs = new ArrayList<>();
 		for (Integer studentId : studentIds) {
 		for (Integer studentId : studentIds) {
 			List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = null;
 			List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = null;
 			BigDecimal typeCourseTotalOriginalPrice = new BigDecimal("0"), typeCourseTotalCurrentPrice = new BigDecimal("0");
 			BigDecimal typeCourseTotalOriginalPrice = new BigDecimal("0"), typeCourseTotalCurrentPrice = new BigDecimal("0");
-			List<CourseScheduleStudentPayment> oldCourseScheduleStudentPayments = new ArrayList<>();
+//			List<CourseScheduleStudentPayment> oldCourseScheduleStudentPayments = new ArrayList<>();
 			List<CourseScheduleStudentPayment> newCourseScheduleStudentPayments = new ArrayList<>();
 			List<CourseScheduleStudentPayment> newCourseScheduleStudentPayments = new ArrayList<>();
 			for (int i = 0; i < courseSchedules.size(); i++) {
 			for (int i = 0; i < courseSchedules.size(); i++) {
 				CourseSchedule courseSchedule = courseSchedules.get(i);
 				CourseSchedule courseSchedule = courseSchedules.get(i);
 				//优先处理之前的剩余课程
 				//优先处理之前的剩余课程
 				//获取调班之前,学员剩余的课程列表
 				//获取调班之前,学员剩余的课程列表
-				if(studentPaymentIds != null && studentPaymentIds.size() > 0){
+				if(CollectionUtils.isNotEmpty(studentPaymentIds)){
 					List<CourseScheduleStudentPayment> studentPayments = courseScheduleStudentPaymentDao.queryByIdsAndStudentId(studentPaymentIds,studentId,courseSchedule.getType().getCode());
 					List<CourseScheduleStudentPayment> studentPayments = courseScheduleStudentPaymentDao.queryByIdsAndStudentId(studentPaymentIds,studentId,courseSchedule.getType().getCode());
-					if(studentPayments != null && studentPayments.size() > 0){
+					if(CollectionUtils.isNotEmpty(studentPayments)){
 						CourseScheduleStudentPayment studentPayment = new CourseScheduleStudentPayment();
 						CourseScheduleStudentPayment studentPayment = new CourseScheduleStudentPayment();
 						try {
 						try {
 							BeanUtils.copyProperties(studentPayment, studentPayments.get(0));
 							BeanUtils.copyProperties(studentPayment, studentPayments.get(0));
@@ -322,7 +321,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 						studentPayment.setSettlementTime(null);
 						studentPayment.setSettlementTime(null);
 						studentPayment.setExamSongDownloadJson(null);
 						studentPayment.setExamSongDownloadJson(null);
 						studentPayment.setId(null);
 						studentPayment.setId(null);
-						oldCourseScheduleStudentPayments.add(studentPayment);
+//						oldCourseScheduleStudentPayments.add(studentPayment);
 						totalCourseScheduleStudentPayments.add(studentPayment);
 						totalCourseScheduleStudentPayments.add(studentPayment);
 						continue ;
 						continue ;
 					}
 					}
@@ -331,7 +330,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				if(musicGroupPaymentStudentCourseDetails == null){
 				if(musicGroupPaymentStudentCourseDetails == null){
 					musicGroupPaymentStudentCourseDetails = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(studentId,courseSchedule.getType(),courseSchedule.getMusicGroupId());
 					musicGroupPaymentStudentCourseDetails = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(studentId,courseSchedule.getType(),courseSchedule.getMusicGroupId());
 				}
 				}
-				if(musicGroupPaymentStudentCourseDetails == null || musicGroupPaymentStudentCourseDetails.size() == 0){
+				if(CollectionUtils.isEmpty(musicGroupPaymentStudentCourseDetails)){
 					throw new BizException("学员缴费详情获取失败");
 					throw new BizException("学员缴费详情获取失败");
 				}
 				}
 				//获取合班时的缴费项目
 				//获取合班时的缴费项目
@@ -339,17 +338,17 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalendersAndCourseType(calenderIds, courseSchedule.getType());
 				List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalendersAndCourseType(calenderIds, courseSchedule.getType());
 				MusicGroupPaymentCalenderCourseSettings courseSetting = musicGroupPaymentCalenderCourseSettings.get(0);
 				MusicGroupPaymentCalenderCourseSettings courseSetting = musicGroupPaymentCalenderCourseSettings.get(0);
 				//课程每分钟原价
 				//课程每分钟原价
-				BigDecimal unitMinuteOriginalPrice = courseSetting.getCourseOriginalPrice().divide(new BigDecimal(courseSetting.getCourseTotalMinuties()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
+				BigDecimal unitMinuteOriginalPrice = courseSetting.getCourseOriginalPrice().divide(new BigDecimal(courseSetting.getCourseTotalMinuties()), CommonConstants.DECIMAL_PLACE, RoundingMode.DOWN);
 
 
 				//课程每分钟现价
 				//课程每分钟现价
-				BigDecimal unitMinuteCurrentPrice = courseSetting.getOverflowCoursePrice().divide(new BigDecimal(courseSetting.getCourseTotalMinuties()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
+				BigDecimal unitMinuteCurrentPrice = courseSetting.getOverflowCoursePrice().divide(new BigDecimal(courseSetting.getCourseTotalMinuties()), CommonConstants.DECIMAL_PLACE, RoundingMode.DOWN);
 
 
 				//默认课程时长
 				//默认课程时长
 				int courseDuration = Integer.parseInt(jsonObject.get(courseSchedule.getType().getCode()).toString());
 				int courseDuration = Integer.parseInt(jsonObject.get(courseSchedule.getType().getCode()).toString());
-				BigDecimal courseOriginalPrice = unitMinuteOriginalPrice.multiply(new BigDecimal(courseDuration)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
+				BigDecimal courseOriginalPrice = unitMinuteOriginalPrice.multiply(new BigDecimal(courseDuration)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, RoundingMode.DOWN);
 				typeCourseTotalOriginalPrice = typeCourseTotalOriginalPrice.add(courseOriginalPrice);
 				typeCourseTotalOriginalPrice = typeCourseTotalOriginalPrice.add(courseOriginalPrice);
 				//课程现价
 				//课程现价
-				BigDecimal courseCurrentPrice = unitMinuteCurrentPrice.multiply(new BigDecimal(courseDuration)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
+				BigDecimal courseCurrentPrice = unitMinuteCurrentPrice.multiply(new BigDecimal(courseDuration)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, RoundingMode.DOWN);
 				typeCourseTotalCurrentPrice = typeCourseTotalCurrentPrice.add(courseCurrentPrice);
 				typeCourseTotalCurrentPrice = typeCourseTotalCurrentPrice.add(courseCurrentPrice);
 				CourseScheduleStudentPayment cssp = new CourseScheduleStudentPayment();
 				CourseScheduleStudentPayment cssp = new CourseScheduleStudentPayment();
 				cssp.setGroupType(courseSchedule.getGroupType());
 				cssp.setGroupType(courseSchedule.getGroupType());
@@ -372,16 +371,33 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				}
 				}
 				//获取课程类型默认排课时长
 				//获取课程类型默认排课时长
 				int typeCourseDuration = Integer.parseInt(jsonObject.get(courseSchedule.getType().getCode()).toString());
 				int typeCourseDuration = Integer.parseInt(jsonObject.get(courseSchedule.getType().getCode()).toString());
+				Map<Long,MusicGroupPaymentStudentCourseDetailLog> courseDetailLogsMap = musicGroupPaymentStudentCourseDetailLogs
+						.stream().collect(Collectors.toMap(MusicGroupPaymentStudentCourseDetailLog::getMusicGroupPaymentStudentCourseDetailId, a -> a,(k1,k2)->k1));
 				for (MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail : musicGroupPaymentStudentCourseDetails) {
 				for (MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail : musicGroupPaymentStudentCourseDetails) {
+					MusicGroupPaymentStudentCourseDetailLog detailLog = courseDetailLogsMap.get(musicGroupPaymentStudentCourseDetail.getId());
+					if(detailLog == null){
+						detailLog = new MusicGroupPaymentStudentCourseDetailLog();
+						musicGroupPaymentStudentCourseDetailLogs.add(detailLog);
+						detailLog.setMusicGroupPaymentStudentCourseDetailId(musicGroupPaymentStudentCourseDetail.getId());
+						detailLog.setClassGroupId(courseSchedule.getClassGroupId());
+						detailLog.setCourseType(courseSchedule.getType().getCode());
+					}
+					detailLog.setCourseNum(detailLog.getCourseNum() + 1);
+					detailLog.setCoursePrice(detailLog.getCoursePrice().add(courseCurrentPrice));
+					detailLog.setCourseSalary(detailLog.getCourseSalary().add(salaryMap.get(courseSchedule.getId()) == null ? BigDecimal.ZERO : salaryMap.get(courseSchedule.getId())));
 					if(typeCourseDuration > musicGroupPaymentStudentCourseDetail.getTotalCourseMinutes()){
 					if(typeCourseDuration > musicGroupPaymentStudentCourseDetail.getTotalCourseMinutes()){
+						detailLog.setUsedCourseMinutes(detailLog.getUsedCourseMinutes() + musicGroupPaymentStudentCourseDetail.getTotalCourseMinutes());
 						musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(musicGroupPaymentStudentCourseDetail.getTotalCourseMinutes());
 						musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(musicGroupPaymentStudentCourseDetail.getTotalCourseMinutes());
 					}else{
 					}else{
+						detailLog.setUsedCourseMinutes(detailLog.getUsedCourseMinutes() + typeCourseDuration);
 						musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(musicGroupPaymentStudentCourseDetail.getUsedCourseMinutes() + typeCourseDuration);
 						musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(musicGroupPaymentStudentCourseDetail.getUsedCourseMinutes() + typeCourseDuration);
 					}
 					}
 				}
 				}
 			}
 			}
-			if(musicGroupPaymentStudentCourseDetails != null && musicGroupPaymentStudentCourseDetails.size() > 0){
+			if(CollectionUtils.isNotEmpty(musicGroupPaymentStudentCourseDetails)){
 				musicGroupPaymentStudentCourseDetailDao.batchUpdate(musicGroupPaymentStudentCourseDetails);
 				musicGroupPaymentStudentCourseDetailDao.batchUpdate(musicGroupPaymentStudentCourseDetails);
+				//保存排课日志
+				musicGroupPaymentStudentCourseDetailLogService.saveBatch(musicGroupPaymentStudentCourseDetailLogs);
 			}
 			}
 		}
 		}
 		courseScheduleStudentPaymentDao.batchInsert(totalCourseScheduleStudentPayments);
 		courseScheduleStudentPaymentDao.batchInsert(totalCourseScheduleStudentPayments);
@@ -390,12 +406,12 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 
 
 	@Override
 	@Override
 	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
 	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-	public void createForMusicGroup(String musicGroupId, List<CourseSchedule> courseSchedules, List<Integer> studentIds) {
+	public void createForMusicGroup(String musicGroupId, List<CourseSchedule> courseSchedules, List<Integer> studentIds,Map<Long,BigDecimal> salaryMap) {
 		Map<Integer, List<CourseSchedule>> memberCourseMap = courseSchedules.stream().collect(Collectors.groupingBy(CourseSchedule::getMemberFlag));
 		Map<Integer, List<CourseSchedule>> memberCourseMap = courseSchedules.stream().collect(Collectors.groupingBy(CourseSchedule::getMemberFlag));
 		Map<Long,List<Long>> courseCalenderMap = new HashMap<>(10);
 		Map<Long,List<Long>> courseCalenderMap = new HashMap<>(10);
 		for (Integer memberFlag : memberCourseMap.keySet()) {
 		for (Integer memberFlag : memberCourseMap.keySet()) {
 			List<CourseSchedule> courseScheduleList = memberCourseMap.get(memberFlag);
 			List<CourseSchedule> courseScheduleList = memberCourseMap.get(memberFlag);
-			if(courseScheduleList != null && courseScheduleList.size() > 0){
+			if(CollectionUtils.isNotEmpty(courseScheduleList)){
 				if(memberFlag == 1){
 				if(memberFlag == 1){
 					createForMemberMusicGroup(musicGroupId,courseScheduleList,studentIds);
 					createForMemberMusicGroup(musicGroupId,courseScheduleList,studentIds);
 				}else {
 				}else {
@@ -453,6 +469,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 							List<CourseScheduleStudentPayment> typeCourseStudentPayments = new ArrayList<>();
 							List<CourseScheduleStudentPayment> typeCourseStudentPayments = new ArrayList<>();
 							courseScheduleTypeListEntry.getValue().sort(Comparator.comparing(CourseSchedule::getStartClassTime));
 							courseScheduleTypeListEntry.getValue().sort(Comparator.comparing(CourseSchedule::getStartClassTime));
 							List<CourseSchedule> scheduleList = courseScheduleTypeListEntry.getValue();
 							List<CourseSchedule> scheduleList = courseScheduleTypeListEntry.getValue();
+							List<MusicGroupPaymentStudentCourseDetailLog> musicGroupPaymentStudentCourseDetailLogs = new ArrayList<>();
 							for (CourseSchedule courseSchedule : scheduleList) {
 							for (CourseSchedule courseSchedule : scheduleList) {
 								if(existCourseIds.contains(courseSchedule.getId())){
 								if(existCourseIds.contains(courseSchedule.getId())){
 									throw new BizException("该学员已在此班级{}课程中", courseSchedule.getId());
 									throw new BizException("该学员已在此班级{}课程中", courseSchedule.getId());
@@ -463,18 +480,22 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 								cssp.setUserId(studentId);
 								cssp.setUserId(studentId);
 								//扣除可排课时长
 								//扣除可排课时长
 								//处理经营报表
 								//处理经营报表
-								this.calcCourseMinutes(musicGroupPaymentStudentCourseDetails,courseDuration,cssp,musicGroupPaymentCalenders,courseCalenderMap);
+								this.calcCourseMinutes(musicGroupPaymentStudentCourseDetails,courseDuration,
+										cssp,musicGroupPaymentCalenders,courseCalenderMap,musicGroupPaymentStudentCourseDetailLogs,
+										salaryMap.get(courseSchedule.getId()),courseSchedule);
 								typeCourseStudentPayments.add(cssp);
 								typeCourseStudentPayments.add(cssp);
 							}
 							}
 							courseScheduleStudentPayments.addAll(typeCourseStudentPayments);
 							courseScheduleStudentPayments.addAll(typeCourseStudentPayments);
 							musicGroupPaymentStudentCourseDetailDao.batchUpdate(musicGroupPaymentStudentCourseDetails);
 							musicGroupPaymentStudentCourseDetailDao.batchUpdate(musicGroupPaymentStudentCourseDetails);
+							//记录排课日志
+							musicGroupPaymentStudentCourseDetailLogService.saveBatch(musicGroupPaymentStudentCourseDetailLogs);
 						}
 						}
 					}
 					}
 					courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
 					courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
 				}
 				}
 			}
 			}
 		}
 		}
-		if(!CollectionUtils.isEmpty(courseCalenderMap)){
+		if(!courseCalenderMap.isEmpty()){
 			for (Long calenderId : courseCalenderMap.keySet()) {
 			for (Long calenderId : courseCalenderMap.keySet()) {
 				List<Long> courseIds = courseCalenderMap.get(calenderId);
 				List<Long> courseIds = courseCalenderMap.get(calenderId);
 				operatingReportCloudService.updateSet(calenderId,courseIds);
 				operatingReportCloudService.updateSet(calenderId,courseIds);
@@ -482,22 +503,38 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 		}
 		}
 	}
 	}
 
 
-	private Boolean calcCourseMinutes(List<MusicGroupPaymentStudentCourseDetail> courseDetails,
-									  Integer courseDuration,
-									  CourseScheduleStudentPayment studentPayment,
-									  List<MusicGroupPaymentCalender> musicGroupPaymentCalenders,
-									  Map<Long,List<Long>> courseCalenderMap){
+	private void calcCourseMinutes(List<MusicGroupPaymentStudentCourseDetail> courseDetails,
+								   Integer courseDuration,
+								   CourseScheduleStudentPayment studentPayment,
+								   List<MusicGroupPaymentCalender> musicGroupPaymentCalenders,
+								   Map<Long,List<Long>> courseCalenderMap,
+								   List<MusicGroupPaymentStudentCourseDetailLog> musicGroupPaymentStudentCourseDetailLogs, BigDecimal salary, CourseSchedule courseSchedule){
 		Boolean result = true;
 		Boolean result = true;
 		Integer courseMinutes = courseDuration;
 		Integer courseMinutes = courseDuration;
 		Map<Long, List<MusicGroupPaymentCalender>> calenderMap = musicGroupPaymentCalenders.stream().collect(Collectors.groupingBy(MusicGroupPaymentCalender::getId));
 		Map<Long, List<MusicGroupPaymentCalender>> calenderMap = musicGroupPaymentCalenders.stream().collect(Collectors.groupingBy(MusicGroupPaymentCalender::getId));
+		Map<Long, MusicGroupPaymentStudentCourseDetailLog> courseDetailLogMap = musicGroupPaymentStudentCourseDetailLogs.stream().
+				collect(Collectors.toMap(MusicGroupPaymentStudentCourseDetailLog::getMusicGroupPaymentStudentCourseDetailId, a -> a, (k1, k2) -> k1));
 		for (int i = 0; i < courseDetails.size(); i++) {
 		for (int i = 0; i < courseDetails.size(); i++) {
 			MusicGroupPaymentStudentCourseDetail detail = courseDetails.get(i);
 			MusicGroupPaymentStudentCourseDetail detail = courseDetails.get(i);
+			MusicGroupPaymentStudentCourseDetailLog detailLog = courseDetailLogMap.get(detail.getId());
 			if(detail.getSubCourseMinutes() > 0){
 			if(detail.getSubCourseMinutes() > 0){
 				if(!detail.getCloudTeacherPaymentFlag()){
 				if(!detail.getCloudTeacherPaymentFlag()){
 					result = false;
 					result = false;
 				}
 				}
+				if (detailLog == null){
+					detailLog = new MusicGroupPaymentStudentCourseDetailLog();
+					detailLog.setMusicGroupPaymentStudentCourseDetailId(detail.getId());
+					detailLog.setClassGroupId(courseSchedule.getClassGroupId());
+					detailLog.setCourseType(courseSchedule.getType().getCode());
+					musicGroupPaymentStudentCourseDetailLogs.add(detailLog);
+				}
 				if(courseMinutes >= detail.getSubCourseMinutes()){
 				if(courseMinutes >= detail.getSubCourseMinutes()){
 					courseMinutes = courseMinutes - detail.getSubCourseMinutes();
 					courseMinutes = courseMinutes - detail.getSubCourseMinutes();
+					//记录排课日志
+					detailLog.setCourseNum(detailLog.getCourseNum() + 1);
+					detailLog.setCoursePrice(detailLog.getCoursePrice().add(detail.getSubCourseCurrentPrice()));
+					detailLog.setUsedCourseMinutes(detailLog.getUsedCourseMinutes() + detail.getSubCourseMinutes());
+
 					detail.setUsedCourseMinutes(detail.getUsedCourseMinutes() + detail.getSubCourseMinutes());
 					detail.setUsedCourseMinutes(detail.getUsedCourseMinutes() + detail.getSubCourseMinutes());
 					detail.setSubCourseMinutes(0);
 					detail.setSubCourseMinutes(0);
 					studentPayment.setOriginalPrice(studentPayment.getOriginalPrice().add(detail.getSubCourseOriginalPrice()));
 					studentPayment.setOriginalPrice(studentPayment.getOriginalPrice().add(detail.getSubCourseOriginalPrice()));
@@ -505,6 +542,10 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 					detail.setSubCourseCurrentPrice(BigDecimal.ZERO);
 					detail.setSubCourseCurrentPrice(BigDecimal.ZERO);
 					detail.setSubCourseOriginalPrice(BigDecimal.ZERO);
 					detail.setSubCourseOriginalPrice(BigDecimal.ZERO);
 				}else{
 				}else{
+					//记录排课日志
+					detailLog.setCourseNum(detailLog.getCourseNum() + 1);
+					detailLog.setUsedCourseMinutes(detailLog.getUsedCourseMinutes() + courseMinutes);
+
 					detail.setUsedCourseMinutes(detail.getUsedCourseMinutes() + courseMinutes);
 					detail.setUsedCourseMinutes(detail.getUsedCourseMinutes() + courseMinutes);
 					detail.setSubCourseMinutes(detail.getSubCourseMinutes() - courseMinutes);
 					detail.setSubCourseMinutes(detail.getSubCourseMinutes() - courseMinutes);
 					//课程每分钟现价
 					//课程每分钟现价
@@ -515,6 +556,9 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 					studentPayment.setOriginalPrice(studentPayment.getOriginalPrice().add(originalPrice));
 					studentPayment.setOriginalPrice(studentPayment.getOriginalPrice().add(originalPrice));
 					studentPayment.setExpectPrice(studentPayment.getExpectPrice().add(expectPrice));
 					studentPayment.setExpectPrice(studentPayment.getExpectPrice().add(expectPrice));
 					detail.setSubCourseCurrentPrice(detail.getSubCourseCurrentPrice().subtract(expectPrice));
 					detail.setSubCourseCurrentPrice(detail.getSubCourseCurrentPrice().subtract(expectPrice));
+					//记录排课日志
+					detailLog.setCoursePrice(detailLog.getCoursePrice().add(expectPrice));
+
 					detail.setSubCourseOriginalPrice(detail.getSubCourseOriginalPrice().subtract(originalPrice));
 					detail.setSubCourseOriginalPrice(detail.getSubCourseOriginalPrice().subtract(originalPrice));
 					courseMinutes = 0;
 					courseMinutes = 0;
 				}
 				}
@@ -540,14 +584,14 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 //					operatingReportCloudService.updateSet(calender,courseIds);
 //					operatingReportCloudService.updateSet(calender,courseIds);
 				}
 				}
 				if(courseMinutes == 0){
 				if(courseMinutes == 0){
-					return result;
+					detailLog.setCourseSalary(detailLog.getCourseSalary().add(salary == null?BigDecimal.ZERO:salary));
+					return;
 				}
 				}
 			}
 			}
 			if(i == courseDetails.size() - 1 && courseMinutes > 0){
 			if(i == courseDetails.size() - 1 && courseMinutes > 0){
 				throw new BizException("操作失败:学员可排课时长不足");
 				throw new BizException("操作失败:学员可排课时长不足");
 			}
 			}
 		}
 		}
-		return result;
 	}
 	}
 
 
 
 

+ 76 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java

@@ -171,8 +171,6 @@ public class ExportServiceImpl implements ExportService {
     @Resource
     @Resource
     private StudentCourseConsumerService studentCourseConsumerService;
     private StudentCourseConsumerService studentCourseConsumerService;
     @Resource
     @Resource
-    private StudentTeacherMapperDao studentTeacherMapperDao;
-    @Resource
     private TeacherCloudCourseReportService teacherCloudCourseReportService;
     private TeacherCloudCourseReportService teacherCloudCourseReportService;
     @Resource
     @Resource
     private OssPluginContext ossPluginContext;
     private OssPluginContext ossPluginContext;
@@ -390,6 +388,13 @@ public class ExportServiceImpl implements ExportService {
         exportManageFuncMap.put(ExportEnum.EXPORT_BALANCED_RELATIONSHIP_STUDENT_QUIT_DETAIL, this::exportBalancedRelationshipStudentQuitDetail);
         exportManageFuncMap.put(ExportEnum.EXPORT_BALANCED_RELATIONSHIP_STUDENT_QUIT_DETAIL, this::exportBalancedRelationshipStudentQuitDetail);
         exportManageFuncMap.put(ExportEnum.VIDEO_PLAY_STAT, this::exportVideoPlayStat);
         exportManageFuncMap.put(ExportEnum.VIDEO_PLAY_STAT, this::exportVideoPlayStat);
         exportManageFuncMap.put(ExportEnum.VIDEO_PLAY_DETAIL_STAT, this::exportVideoPlayDetailStat);
         exportManageFuncMap.put(ExportEnum.VIDEO_PLAY_DETAIL_STAT, this::exportVideoPlayDetailStat);
+        exportManageFuncMap.put(ExportEnum.EXPORT_BALANCED_RELATIONSHIP_MUSIC_NO_COURSE, this::exportBalancedRelationshipMusicNoCourse);
+        exportManageFuncMap.put(ExportEnum.EXPORT_BALANCED_RELATIONSHIP_MUSIC_NO_COURSE_SUM, this::exportBalancedRelationshipMusicNoCourseSum);
+        exportManageFuncMap.put(ExportEnum.EXPORT_BALANCED_RELATIONSHIP_MUSIC_NO_CLASS_NO_COURSE_SUM, this::exportBalancedRelationshipMusicNoClassNoCourseSum);
+        exportManageFuncMap.put(ExportEnum.EXPORT_BALANCED_RELATIONSHIP_VIP_SUB_COURSE_DETAIL, this::exportBalancedRelationshipVipSubCourseDetail);
+        exportManageFuncMap.put(ExportEnum.EXPORT_BALANCED_RELATIONSHIP_VIP_SUB_COURSE_SUM, this::exportBalancedRelationshipVipSubCourseSum);
+        exportManageFuncMap.put(ExportEnum.EXPORT_BALANCED_RELATIONSHIP_MUSIC_COURSE_SUM, this::exportBalancedRelationshipMusicCourseSum);
+        exportManageFuncMap.put(ExportEnum.EXPORT_BALANCED_RELATIONSHIP_CLOUD_SUM, this::exportBalancedRelationshipCloudSum);
     }
     }
 
 
     private HttpResponseResult<String> exportVideoPlayStat(Map<String, Object> info) {
     private HttpResponseResult<String> exportVideoPlayStat(Map<String, Object> info) {
@@ -461,10 +466,29 @@ public class ExportServiceImpl implements ExportService {
         SysUser sysUser = sysUserService.getUser();
         SysUser sysUser = sysUserService.getUser();
         String organIds = organizationService.getEmployeeOrgan(sysUser.getId(), null, sysUser.getIsSuperAdmin() && sysUser.getTenantId() == -1);
         String organIds = organizationService.getEmployeeOrgan(sysUser.getId(), null, sysUser.getIsSuperAdmin() && sysUser.getTenantId() == -1);
         ManagerDownload managerDownload = saveManagerDownload(ExportTypeEnum.EXPORT_BALANCED_RELATIONSHIP_MUSIC_COURSE,sysUser.getId());
         ManagerDownload managerDownload = saveManagerDownload(ExportTypeEnum.EXPORT_BALANCED_RELATIONSHIP_MUSIC_COURSE,sysUser.getId());
-        return this.asyncExport(() -> this.initExportInfo(exportDao.exportBalancedRelationshipMusicCourse(month,organIds),
+        return this.asyncExport(() -> this.initExportInfo(exportDao.exportBalancedRelationshipMusicCourse1(month,organIds),
                         managerDownload,ExportEnum.EXPORT_BALANCED_RELATIONSHIP_MUSIC_COURSE),
                         managerDownload,ExportEnum.EXPORT_BALANCED_RELATIONSHIP_MUSIC_COURSE),
                 managerDownload.getName());
                 managerDownload.getName());
     }
     }
+
+    private HttpResponseResult<String> exportBalancedRelationshipMusicCourseSum(Map<String, Object> info){
+        String month = getParam(info, "month", String.class);
+        SysUser sysUser = sysUserService.getUser();
+        ManagerDownload managerDownload = saveManagerDownload(ExportTypeEnum.EXPORT_BALANCED_RELATIONSHIP_MUSIC_COURSE_SUM,sysUser.getId());
+        return this.asyncExport(() -> this.initExportInfo(musicGroupService.exportBalancedRelationshipMusicCourseSum(month),
+                        managerDownload,ExportEnum.EXPORT_BALANCED_RELATIONSHIP_MUSIC_COURSE_SUM),
+                managerDownload.getName());
+    }
+
+    private HttpResponseResult<String> exportBalancedRelationshipCloudSum(Map<String, Object> info){
+        String month = getParam(info, "month", String.class);
+        SysUser sysUser = sysUserService.getUser();
+        ManagerDownload managerDownload = saveManagerDownload(ExportTypeEnum.EXPORT_BALANCED_RELATIONSHIP_CLOUD_SUM,sysUser.getId());
+        return this.asyncExport(() -> this.initExportInfo(exportDao.exportBalancedRelationshipCloudSum(month),
+                        managerDownload,ExportEnum.EXPORT_BALANCED_RELATIONSHIP_CLOUD_SUM),
+                managerDownload.getName());
+    }
+
     private HttpResponseResult<String> exportBalancedRelationshipVipCourse(Map<String, Object> info){
     private HttpResponseResult<String> exportBalancedRelationshipVipCourse(Map<String, Object> info){
         String month = getParam(info, "month", String.class);
         String month = getParam(info, "month", String.class);
         SysUser sysUser = sysUserService.getUser();
         SysUser sysUser = sysUserService.getUser();
@@ -510,6 +534,7 @@ public class ExportServiceImpl implements ExportService {
                         managerDownload,ExportEnum.EXPORT_BALANCED_RELATIONSHIP_STUDENT_NORMAL_DETAIL),
                         managerDownload,ExportEnum.EXPORT_BALANCED_RELATIONSHIP_STUDENT_NORMAL_DETAIL),
                 managerDownload.getName());
                 managerDownload.getName());
     }
     }
+
     private HttpResponseResult<String> exportBalancedRelationshipStudentQuitDetail(Map<String, Object> info){
     private HttpResponseResult<String> exportBalancedRelationshipStudentQuitDetail(Map<String, Object> info){
         String month = getParam(info, "month", String.class);
         String month = getParam(info, "month", String.class);
         SysUser sysUser = sysUserService.getUser();
         SysUser sysUser = sysUserService.getUser();
@@ -520,6 +545,54 @@ public class ExportServiceImpl implements ExportService {
                 managerDownload.getName());
                 managerDownload.getName());
     }
     }
 
 
+    private HttpResponseResult<String> exportBalancedRelationshipMusicNoCourse(Map<String, Object> info){
+        String month = getParam(info, "month", String.class);
+        SysUser sysUser = sysUserService.getUser();
+        String organIds = organizationService.getEmployeeOrgan(sysUser.getId(), null, sysUser.getIsSuperAdmin() && sysUser.getTenantId() == -1);
+        ManagerDownload managerDownload = saveManagerDownload(ExportTypeEnum.EXPORT_BALANCED_RELATIONSHIP_MUSIC_NO_COURSE,sysUser.getId());
+        return this.asyncExport(() -> this.initExportInfo(musicGroupService.exportBalancedRelationshipMusicNoCourse(month,organIds),
+                        managerDownload,ExportEnum.EXPORT_BALANCED_RELATIONSHIP_MUSIC_NO_COURSE),
+                managerDownload.getName());
+    }
+
+    private HttpResponseResult<String> exportBalancedRelationshipMusicNoCourseSum(Map<String, Object> info){
+        String month = getParam(info, "month", String.class);
+        SysUser sysUser = sysUserService.getUser();
+        ManagerDownload managerDownload = saveManagerDownload(ExportTypeEnum.EXPORT_BALANCED_RELATIONSHIP_MUSIC_NO_COURSE_SUM,sysUser.getId());
+        return this.asyncExport(() -> this.initExportInfo(musicGroupService.exportBalancedRelationshipMusicNoCourseSum(month),
+                        managerDownload,ExportEnum.EXPORT_BALANCED_RELATIONSHIP_MUSIC_NO_COURSE_SUM),
+                managerDownload.getName());
+    }
+
+    private HttpResponseResult<String> exportBalancedRelationshipMusicNoClassNoCourseSum(Map<String, Object> info){
+        String month = getParam(info, "month", String.class);
+        SysUser sysUser = sysUserService.getUser();
+        ManagerDownload managerDownload = saveManagerDownload(ExportTypeEnum.EXPORT_BALANCED_RELATIONSHIP_MUSIC_NO_CLASS_NO_COURSE_SUM,sysUser.getId());
+        return this.asyncExport(() -> this.initExportInfo(musicGroupService.exportBalancedRelationshipMusicNoClassNoCourseSum(month),
+                        managerDownload,ExportEnum.EXPORT_BALANCED_RELATIONSHIP_MUSIC_NO_CLASS_NO_COURSE_SUM),
+                managerDownload.getName());
+    }
+
+    private HttpResponseResult<String> exportBalancedRelationshipVipSubCourseDetail(Map<String, Object> info){
+        String month = getParam(info, "month", String.class);
+        SysUser sysUser = sysUserService.getUser();
+        String organIds = organizationService.getEmployeeOrgan(sysUser.getId(), null, sysUser.getIsSuperAdmin() && sysUser.getTenantId() == -1);
+        ManagerDownload managerDownload = saveManagerDownload(ExportTypeEnum.EXPORT_BALANCED_RELATIONSHIP_VIP_SUB_COURSE_DETAIL,sysUser.getId());
+        return this.asyncExport(() -> this.initExportInfo(exportDao.exportBalancedRelationshipVipSubCourseDetail(month,organIds),
+                        managerDownload,ExportEnum.EXPORT_BALANCED_RELATIONSHIP_VIP_SUB_COURSE_DETAIL),
+                managerDownload.getName());
+    }
+
+    private HttpResponseResult<String> exportBalancedRelationshipVipSubCourseSum(Map<String, Object> info){
+        String month = getParam(info, "month", String.class);
+        SysUser sysUser = sysUserService.getUser();
+//        String organIds = organizationService.getEmployeeOrgan(sysUser.getId(), null, sysUser.getIsSuperAdmin() && sysUser.getTenantId() == -1);
+        ManagerDownload managerDownload = saveManagerDownload(ExportTypeEnum.EXPORT_BALANCED_RELATIONSHIP_VIP_SUB_COURSE_DETAIL,sysUser.getId());
+        return this.asyncExport(() -> this.initExportInfo(exportDao.exportBalancedRelationshipVipSubCourseSum(month),
+                        managerDownload,ExportEnum.EXPORT_BALANCED_RELATIONSHIP_VIP_SUB_COURSE_DETAIL),
+                managerDownload.getName());
+    }
+
     private HttpResponseResult<String> exportOperatingSummaryIncome(Map<String, Object> info) {
     private HttpResponseResult<String> exportOperatingSummaryIncome(Map<String, Object> info) {
         String month = getParam(info, "month", String.class);
         String month = getParam(info, "month", String.class);
         Map<String, Object> params = new HashMap<>(1);
         Map<String, Object> params = new HashMap<>(1);

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

@@ -111,7 +111,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
                 push.put(userId, userId + "");
                 push.put(userId, userId + "");
             }
             }
             MusicGroup musicGroup = musicGroupDao.get(calender.getMusicGroupId());
             MusicGroup musicGroup = musicGroupDao.get(calender.getMusicGroupId());
-            String baseUrl = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
+            String baseUrl = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL_MDAYA);
             String memo = "4?" + baseUrl + "/#/musicGroupRenew?calenderId=" + calender.getId() + "&id=" + calender.getMusicGroupId();
             String memo = "4?" + baseUrl + "/#/musicGroupRenew?calenderId=" + calender.getId() + "&id=" + calender.getMusicGroupId();
             // 发送续费通知
             // 发送续费通知
             sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_WAIT_RENEW_MESSAGE, push,
             sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_WAIT_RENEW_MESSAGE, push,
@@ -423,7 +423,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
         //未缴费
         //未缴费
         Map<Integer, String> studentMaps = MapUtil.convertMybatisMap(musicGroupPaymentCalenderDetailDao.queryNoPaymentAndNotZeroStudent(calenderId, studentIdList));
         Map<Integer, String> studentMaps = MapUtil.convertMybatisMap(musicGroupPaymentCalenderDetailDao.queryNoPaymentAndNotZeroStudent(calenderId, studentIdList));
         MusicGroup musicGroup = musicGroupDao.get(paymentCalender.getMusicGroupId());
         MusicGroup musicGroup = musicGroupDao.get(paymentCalender.getMusicGroupId());
-        String baseUrl = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
+        String baseUrl = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL_MDAYA);
         String memo = "4?" + baseUrl + "/#/musicGroupRenew?calenderId=" + calenderId + "&id=" + musicGroup.getId();
         String memo = "4?" + baseUrl + "/#/musicGroupRenew?calenderId=" + calenderId + "&id=" + musicGroup.getId();
         Map<Integer, String> push = new HashMap<>();
         Map<Integer, String> push = new HashMap<>();
         for (Integer userId : studentIdList) {
         for (Integer userId : studentIdList) {

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

@@ -1409,7 +1409,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
             studentIds = musicGroupPaymentCalenderDetailDao.queryNoPaymentStudentIds(calenderId);
             studentIds = musicGroupPaymentCalenderDetailDao.queryNoPaymentStudentIds(calenderId);
         }
         }
         if (studentIds.size() > 0) {
         if (studentIds.size() > 0) {
-            String baseUrl = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
+            String baseUrl = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL_MDAYA);
             StringBuffer memo = new StringBuffer("4?").append(baseUrl).append("/#/musicGroupRenew?calenderId=").append(calenderId).append("&id=").append(musicGroup.getId());
             StringBuffer memo = new StringBuffer("4?").append(baseUrl).append("/#/musicGroupRenew?calenderId=").append(calenderId).append("&id=").append(musicGroup.getId());
             Map<Integer, String> push = new HashMap<>(studentIds.size());
             Map<Integer, String> push = new HashMap<>(studentIds.size());
             studentIds.forEach(e -> push.put(e, e.toString()));
             studentIds.forEach(e -> push.put(e, e.toString()));

+ 17 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentStudentCourseDetailLogServiceImpl.java

@@ -0,0 +1,17 @@
+package com.ym.mec.biz.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentStudentCourseDetailLogDao;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetailLog;
+import com.ym.mec.biz.service.MusicGroupPaymentStudentCourseDetailLogService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+
+@Slf4j
+@Service
+public class MusicGroupPaymentStudentCourseDetailLogServiceImpl extends ServiceImpl<MusicGroupPaymentStudentCourseDetailLogDao, MusicGroupPaymentStudentCourseDetailLog> implements MusicGroupPaymentStudentCourseDetailLogService {
+
+
+
+}

+ 13 - 17
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentStudentCourseDetailServiceImpl.java

@@ -1,19 +1,17 @@
 package com.ym.mec.biz.service.impl;
 package com.ym.mec.biz.service.impl;
 
 
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dao.*;
-import com.ym.mec.biz.dal.dto.StudentApplyInstrumentDto;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
 import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
 import com.ym.mec.biz.service.MusicGroupPaymentStudentCourseDetailService;
 import com.ym.mec.biz.service.MusicGroupPaymentStudentCourseDetailService;
-import com.ym.mec.biz.service.StudentMusicCourseFeeService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.CollectionUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 
 
+import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.math.RoundingMode;
 import java.util.*;
 import java.util.*;
@@ -25,21 +23,19 @@ import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType.ST
 @Service
 @Service
 public class MusicGroupPaymentStudentCourseDetailServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentStudentCourseDetail>  implements MusicGroupPaymentStudentCourseDetailService {
 public class MusicGroupPaymentStudentCourseDetailServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentStudentCourseDetail>  implements MusicGroupPaymentStudentCourseDetailService {
 	
 	
-	@Autowired
+	@Resource
 	private MusicGroupPaymentStudentCourseDetailDao musicGroupPaymentStudentCourseDetailDao;
 	private MusicGroupPaymentStudentCourseDetailDao musicGroupPaymentStudentCourseDetailDao;
-	@Autowired
+	@Resource
 	private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
 	private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
-	@Autowired
-	private StudentMusicCourseFeeService studentMusicCourseFeeService;
-	@Autowired
+	@Resource
 	private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
 	private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
-	@Autowired
+	@Resource
 	private MusicGroupDao musicGroupDao;
 	private MusicGroupDao musicGroupDao;
-	@Autowired
+	@Resource
 	private StudentRegistrationDao studentRegistrationDao;
 	private StudentRegistrationDao studentRegistrationDao;
-	@Autowired
+	@Resource
 	private ChargeTypeSubjectMapperDao chargeTypeSubjectMapperDao;
 	private ChargeTypeSubjectMapperDao chargeTypeSubjectMapperDao;
-	@Autowired
+	@Resource
 	private StudentCourseFeeDetailDao studentCourseFeeDetailDao;
 	private StudentCourseFeeDetailDao studentCourseFeeDetailDao;
 
 
 	@Override
 	@Override
@@ -54,7 +50,7 @@ public class MusicGroupPaymentStudentCourseDetailServiceImpl extends BaseService
 							Map<Integer, Long> userCalenderDetailMap) {
 							Map<Integer, Long> userCalenderDetailMap) {
 		List<MusicGroupPaymentCalenderCourseSettings> courseSettingsList = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalender(calender.getId());
 		List<MusicGroupPaymentCalenderCourseSettings> courseSettingsList = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalender(calender.getId());
 		//创建学生课排课分钟数
 		//创建学生课排课分钟数
-		if (courseSettingsList != null && courseSettingsList.size() > 0) {
+		if (CollectionUtils.isNotEmpty(courseSettingsList)) {
 			List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = new ArrayList<>();
 			List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = new ArrayList<>();
 			MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = null;
 			MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = null;
 			Long calenderId = calender.getId();
 			Long calenderId = calender.getId();
@@ -94,7 +90,7 @@ public class MusicGroupPaymentStudentCourseDetailServiceImpl extends BaseService
 //					studentMusicCourseFeeService.addExpectPrice(studentId,musicGroupId,reduce);
 //					studentMusicCourseFeeService.addExpectPrice(studentId,musicGroupId,reduce);
 //				}
 //				}
 			}
 			}
-			if (musicGroupPaymentStudentCourseDetailList.size() > 0) {
+			if (CollectionUtils.isNotEmpty(musicGroupPaymentStudentCourseDetailList)) {
 				musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetailList);
 				musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetailList);
 			}
 			}
 		}
 		}
@@ -172,7 +168,7 @@ public class MusicGroupPaymentStudentCourseDetailServiceImpl extends BaseService
 				musicGroupPaymentStudentCourseDetail.setCloudTeacherPaymentFlag(cloudTeacherPaymentFlag);
 				musicGroupPaymentStudentCourseDetail.setCloudTeacherPaymentFlag(cloudTeacherPaymentFlag);
 				musicGroupPaymentStudentCourseDetails.add(musicGroupPaymentStudentCourseDetail);
 				musicGroupPaymentStudentCourseDetails.add(musicGroupPaymentStudentCourseDetail);
 			}
 			}
-			if (musicGroupPaymentStudentCourseDetails.size() > 0) {
+			if (CollectionUtils.isNotEmpty(musicGroupPaymentStudentCourseDetails)) {
 				if(musicGroupPaymentCalender.getPayUserType() == STUDENT && musicGroup.getCourseViewType() == CourseViewTypeEnum.FREE) {
 				if(musicGroupPaymentCalender.getPayUserType() == STUDENT && musicGroup.getCourseViewType() == CourseViewTypeEnum.FREE) {
 					List<StudentPaymentOrderDetail> instrumentDtos = studentPaymentOrderDetailDao.getWithUserAndOrderType(userId, musicGroupId, OrderDetailTypeEnum.MUSICAL);
 					List<StudentPaymentOrderDetail> instrumentDtos = studentPaymentOrderDetailDao.getWithUserAndOrderType(userId, musicGroupId, OrderDetailTypeEnum.MUSICAL);
 					//是否买过乐器
 					//是否买过乐器
@@ -201,7 +197,7 @@ public class MusicGroupPaymentStudentCourseDetailServiceImpl extends BaseService
 		}
 		}
 		BigDecimal remainingAmount = totalAmount;
 		BigDecimal remainingAmount = totalAmount;
 		int lastIndex = courseDetails.size() - 1;
 		int lastIndex = courseDetails.size() - 1;
-		BigDecimal totalUnitPrice = courseDetails.stream().map(e -> e.getCourseOriginalPrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
+		BigDecimal totalUnitPrice = courseDetails.stream().map(MusicGroupPaymentStudentCourseDetail::getCourseOriginalPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
 
 
 		// 分摊总金额
 		// 分摊总金额
 		for (int i = 0; i < lastIndex; i++) {
 		for (int i = 0; i < lastIndex; i++) {
@@ -250,7 +246,7 @@ public class MusicGroupPaymentStudentCourseDetailServiceImpl extends BaseService
 
 
     void delByDetails(List<MusicGroupPaymentStudentCourseDetail> courseDetails){
     void delByDetails(List<MusicGroupPaymentStudentCourseDetail> courseDetails){
 		if(CollectionUtils.isNotEmpty(courseDetails)){
 		if(CollectionUtils.isNotEmpty(courseDetails)){
-			List<Long> courseDetailIds = courseDetails.stream().map(e -> e.getId()).collect(Collectors.toList());
+			List<Long> courseDetailIds = courseDetails.stream().map(MusicGroupPaymentStudentCourseDetail::getId).collect(Collectors.toList());
 			musicGroupPaymentStudentCourseDetailDao.delByIds(courseDetailIds);
 			musicGroupPaymentStudentCourseDetailDao.delByIds(courseDetailIds);
 			//汇总学员乐团课费,如果有溢出的乐器费用、云教练费用,也一并汇总,用于计算经营报表
 			//汇总学员乐团课费,如果有溢出的乐器费用、云教练费用,也一并汇总,用于计算经营报表
 			/*courseDetails = courseDetails.stream().filter(e -> e.getCourseCurrentPrice().compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
 			/*courseDetails = courseDetails.stream().filter(e -> e.getCourseCurrentPrice().compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());

+ 235 - 71
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.service.impl;
 package com.ym.mec.biz.service.impl;
 
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.TypeReference;
 import com.alibaba.fastjson.TypeReference;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -23,6 +24,7 @@ import com.ym.mec.biz.dal.wrapper.SchoolStaffWrapper;
 import com.ym.mec.biz.event.source.GroupEventSource;
 import com.ym.mec.biz.event.source.GroupEventSource;
 import com.ym.mec.biz.event.source.SendSeoMessageSource;
 import com.ym.mec.biz.event.source.SendSeoMessageSource;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.biz.service.*;
+import com.ym.mec.common.constant.CommonConstants;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.entity.HttpResponseResult;
@@ -54,10 +56,12 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
 
 
+import javax.annotation.Resource;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStream;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.*;
 import java.util.Map.Entry;
 import java.util.Map.Entry;
@@ -78,150 +82,156 @@ import static com.ym.mec.biz.dal.enums.SysUserRoleEnum.ORGAN_MANAGER;
 @Service
 @Service
 public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> implements MusicGroupService {
 public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> implements MusicGroupService {
 
 
-    @Autowired
+    @Resource
     private MusicGroupDao musicGroupDao;
     private MusicGroupDao musicGroupDao;
-    @Autowired
+    @Resource
     private TeacherDao teacherDao;
     private TeacherDao teacherDao;
-    @Autowired
+    @Resource
     private MusicGroupDeliveryRecordDao musicGroupDeliveryRecordDao;
     private MusicGroupDeliveryRecordDao musicGroupDeliveryRecordDao;
-    @Autowired
+    @Resource
     private StudentService studentService;
     private StudentService studentService;
-    @Autowired
+    @Resource
     private IdGeneratorService idGeneratorService;
     private IdGeneratorService idGeneratorService;
-    @Autowired
+    @Resource
     private SchoolDao schoolDao;
     private SchoolDao schoolDao;
-    @Autowired
+    @Resource
     private MusicGroupPaymentCalenderMemberDao musicGroupPaymentCalenderMemberDao;
     private MusicGroupPaymentCalenderMemberDao musicGroupPaymentCalenderMemberDao;
-    @Autowired
+    @Resource
     private MusicGroupPaymentCalenderService musicGroupPaymentCalenderService;
     private MusicGroupPaymentCalenderService musicGroupPaymentCalenderService;
-    @Autowired
+    @Resource
     private MusicGroupPaymentEntitiesDao musicGroupPaymentEntitiesDao;
     private MusicGroupPaymentEntitiesDao musicGroupPaymentEntitiesDao;
-    @Autowired
+    @Resource
     private MusicGroupSubjectPlanDao musicGroupSubjectPlanDao;
     private MusicGroupSubjectPlanDao musicGroupSubjectPlanDao;
-    @Autowired
+    @Resource
     private StudentTeacherMapperDao studentTeacherMapperDao;
     private StudentTeacherMapperDao studentTeacherMapperDao;
-    @Autowired
+    @Resource
     private MusicGroupBuildLogDao musicGroupBuildLogDao;
     private MusicGroupBuildLogDao musicGroupBuildLogDao;
-    @Autowired
+    @Resource
     private MusicGroupPurchaseListDao musicGroupPurchaseListDao;
     private MusicGroupPurchaseListDao musicGroupPurchaseListDao;
-    @Autowired
+    @Resource
     private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
     private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
-    @Autowired
+    @Resource
     private ClassGroupStudentMapperDao classGroupStudentMapperDao;
     private ClassGroupStudentMapperDao classGroupStudentMapperDao;
-    @Autowired
+    @Resource
     private ClassGroupTeacherMapperDao classGroupTeacherMapperDao;
     private ClassGroupTeacherMapperDao classGroupTeacherMapperDao;
-    @Autowired
+    @Resource
     private StudentPaymentOrderDao studentPaymentOrderDao;
     private StudentPaymentOrderDao studentPaymentOrderDao;
-    @Autowired
+    @Resource
     private SysUserCashAccountService sysUserCashAccountService;
     private SysUserCashAccountService sysUserCashAccountService;
-    @Autowired
+    @Resource
     private SysUserCashAccountDetailService sysUserCashAccountDetailService;
     private SysUserCashAccountDetailService sysUserCashAccountDetailService;
-    @Autowired
+    @Resource
     private MusicGroupPaymentCalenderStudentDetailDao musicGroupPaymentCalenderStudentDetailDao;
     private MusicGroupPaymentCalenderStudentDetailDao musicGroupPaymentCalenderStudentDetailDao;
-    @Autowired
+    @Resource
     private MusicGroupQuitDao musicGroupQuitDao;
     private MusicGroupQuitDao musicGroupQuitDao;
-    @Autowired
+    @Resource
     private StudentRegistrationDao studentRegistrationDao;
     private StudentRegistrationDao studentRegistrationDao;
-    @Autowired
+    @Resource
     private CourseScheduleDao courseScheduleDao;
     private CourseScheduleDao courseScheduleDao;
-    @Autowired
+    @Resource
     private ClassGroupDao classGroupDao;
     private ClassGroupDao classGroupDao;
-    @Autowired
+    @Resource
     private OrganizationDao organizationDao;
     private OrganizationDao organizationDao;
-    @Autowired
+    @Resource
     private CourseScheduleTeacherSalaryDao courseScheduleTeacherSalaryDao;
     private CourseScheduleTeacherSalaryDao courseScheduleTeacherSalaryDao;
-    @Autowired
+    @Resource
     private CourseScheduleStudentPaymentService courseScheduleStudentPaymentService;
     private CourseScheduleStudentPaymentService courseScheduleStudentPaymentService;
-    @Autowired
+    @Resource
     private CooperationOrganDao cooperationOrganDao;
     private CooperationOrganDao cooperationOrganDao;
-    @Autowired
+    @Resource
     private TeacherAttendanceDao teacherAttendanceDao;
     private TeacherAttendanceDao teacherAttendanceDao;
-    @Autowired
+    @Resource
     private StudentPaymentOrderService studentPaymentOrderService;
     private StudentPaymentOrderService studentPaymentOrderService;
-    @Autowired
+    @Resource
     private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
     private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
-    @Autowired
+    @Resource
     private PayService payService;
     private PayService payService;
-    @Autowired
+    @Resource
     private SysUserService sysUserService;
     private SysUserService sysUserService;
-    @Autowired
+    @Resource
     private SysMessageService sysMessageService;
     private SysMessageService sysMessageService;
-    @Autowired
+    @Resource
     private SysConfigDao sysConfigDao;
     private SysConfigDao sysConfigDao;
-    @Autowired
+    @Resource
     private SysTenantConfigService sysTenantConfigService;
     private SysTenantConfigService sysTenantConfigService;
-    @Autowired
+    @Resource
     private ClassGroupService classGroupService;
     private ClassGroupService classGroupService;
-    @Autowired
+    @Resource
     private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
     private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
-    @Autowired
+    @Resource
     private StudentRegistrationService studentRegistrationService;
     private StudentRegistrationService studentRegistrationService;
-    @Autowired
+    @Resource
     private SporadicChargeInfoDao sporadicChargeInfoDao;
     private SporadicChargeInfoDao sporadicChargeInfoDao;
-    @Autowired
+    @Resource
     private MusicGroupSubjectGoodsGroupService musicGroupSubjectGoodsGroupService;
     private MusicGroupSubjectGoodsGroupService musicGroupSubjectGoodsGroupService;
-    @Autowired
+    @Resource
     private GoodsService goodsService;
     private GoodsService goodsService;
-    @Autowired
+    @Resource
     private ClassGroupStudentMapperService classGroupStudentMapperService;
     private ClassGroupStudentMapperService classGroupStudentMapperService;
-    @Autowired
+    @Resource
     private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
     private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
-    @Autowired
+    @Resource
     private ImGroupMemberService imGroupMemberService;
     private ImGroupMemberService imGroupMemberService;
-    @Autowired
+    @Resource
     private ImUserFriendService imUserFriendService;
     private ImUserFriendService imUserFriendService;
-    @Autowired
+    @Resource
     private ImGroupService imGroupService;
     private ImGroupService imGroupService;
-    @Autowired
+    @Resource
     private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
     private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
-    @Autowired
+    @Resource
     private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
     private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
-    @Autowired
+    @Resource
     private MusicGroupPaymentStudentCourseDetailService musicGroupPaymentStudentCourseDetailService;
     private MusicGroupPaymentStudentCourseDetailService musicGroupPaymentStudentCourseDetailService;
-    @Autowired
+    @Resource
     private SubjectChangeDao subjectChangeDao;
     private SubjectChangeDao subjectChangeDao;
-    @Autowired
+    @Resource
     private StudentVisitDao studentVisitDao;
     private StudentVisitDao studentVisitDao;
-    @Autowired
+    @Resource
     private SubjectDao subjectDao;
     private SubjectDao subjectDao;
-    @Autowired
+    @Resource
     private GoodsDao goodsDao;
     private GoodsDao goodsDao;
-    @Autowired
+    @Resource
     @Lazy
     @Lazy
     private ContractService contractService;
     private ContractService contractService;
-    @Autowired
+    @Resource
     private StudentPreRegistrationDao studentPreRegistrationDao;
     private StudentPreRegistrationDao studentPreRegistrationDao;
-    @Autowired
+    @Resource
     private GroupEventSource groupEventSource;
     private GroupEventSource groupEventSource;
-    @Autowired
+    @Resource
     private StudentInstrumentDao studentInstrumentDao;
     private StudentInstrumentDao studentInstrumentDao;
-    @Autowired
+    @Resource
     private SysUserCashAccountLogDao sysUserCashAccountLogDao;
     private SysUserCashAccountLogDao sysUserCashAccountLogDao;
-    @Autowired
+    @Resource
     private MusicGroupSchoolTermCourseDetailDao musicGroupSchoolTermCourseDetailDao;
     private MusicGroupSchoolTermCourseDetailDao musicGroupSchoolTermCourseDetailDao;
-    @Autowired
+    @Resource
     private MusicGroupSchoolTermStudentCourseDetailDao musicGroupSchoolTermStudentCourseDetailDao;
     private MusicGroupSchoolTermStudentCourseDetailDao musicGroupSchoolTermStudentCourseDetailDao;
-    @Autowired
+    @Resource
     private SysCouponCodeService sysCouponCodeService;
     private SysCouponCodeService sysCouponCodeService;
-    @Autowired
+    @Resource
     private SendSeoMessageSource sendSeoMessageSource;
     private SendSeoMessageSource sendSeoMessageSource;
-    @Autowired
+    @Resource
     private SysEmployeePositionService employeePositionService;
     private SysEmployeePositionService employeePositionService;
-    @Autowired
+    @Resource
     private SysUserCashAccountDao sysUserCashAccountDao;
     private SysUserCashAccountDao sysUserCashAccountDao;
-    @Autowired
+    @Resource
     private StudentDao studentDao;
     private StudentDao studentDao;
-    @Autowired
+    @Resource
     private MusicGroupPaymentCalenderRepairDao musicGroupPaymentCalenderRepairDao;
     private MusicGroupPaymentCalenderRepairDao musicGroupPaymentCalenderRepairDao;
-    @Autowired
+    @Resource
     private MusicGroupPaymentCalenderActivityDao musicGroupPaymentCalenderActivityDao;
     private MusicGroupPaymentCalenderActivityDao musicGroupPaymentCalenderActivityDao;
 
 
-    @Autowired
+    @Resource
     private SchoolStaffService schoolStaffService;
     private SchoolStaffService schoolStaffService;
 
 
-    @Autowired
+    @Resource
     private SysMessageConfigDao sysMessageConfigDao;
     private SysMessageConfigDao sysMessageConfigDao;
 
 
+    @Resource
+    private TeacherDefaultMusicGroupSalaryDao teacherDefaultMusicGroupSalaryDao;
+
+    @Resource
+    private MusicGroupPaymentStudentCourseDetailLogService musicGroupPaymentStudentCourseDetailLogService;
+
     private SimpleDateFormat sdf_ymd = new SimpleDateFormat("yyyy-MM-dd");
     private SimpleDateFormat sdf_ymd = new SimpleDateFormat("yyyy-MM-dd");
 
 
     private SimpleDateFormat sdf_hms = new SimpleDateFormat("HH:mm:ss");
     private SimpleDateFormat sdf_hms = new SimpleDateFormat("HH:mm:ss");
@@ -4234,7 +4244,161 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 		return resultMap;
 		return resultMap;
 	}
 	}
 
 
-	// 辅助方法:创建年级映射
+    @Override
+    public List<ExportWrapper.ExportBalancedRelationshipMusicNoCourse> exportBalancedRelationshipMusicNoCourse(String month, String organIds) {
+		List<ExportWrapper.ExportBalancedRelationshipMusicNoCourse> exportBalancedRelationshipMusicNoCourses = musicGroupDao.exportBalancedRelationshipMusicNoCourse(month, organIds);
+		if(CollectionUtils.isNotEmpty(exportBalancedRelationshipMusicNoCourses)){
+			//计算课酬
+			this.createMusicGroupCourseTeacherSalaries(exportBalancedRelationshipMusicNoCourses);
+		}
+		return exportBalancedRelationshipMusicNoCourses;
+	}
+
+    @Override
+    public List<ExportWrapper.ExportBalancedRelationshipMusicNoCourse> exportBalancedRelationshipMusicNoCourseSum(String month) {
+		List<ExportWrapper.ExportBalancedRelationshipMusicNoCourse> result = new ArrayList<>();
+		ExportWrapper.ExportBalancedRelationshipMusicNoCourse sum = new ExportWrapper.ExportBalancedRelationshipMusicNoCourse();
+		//期初已分班未排课
+		List<ExportWrapper.ExportBalancedRelationshipMusicNoCourse> first =
+				musicGroupDao.exportBalancedRelationshipMusicNoCourse(month + "-01 00:00:00", null);
+		if(CollectionUtils.isNotEmpty(first)){
+			//计算课酬
+			this.createMusicGroupCourseTeacherSalaries(first);
+			//将列表所有字段汇总
+			sum.setFirstSubCourseMinutes(first.stream().map(ExportWrapper.ExportBalancedRelationshipMusicNoCourse::getSubCourseMinutes).reduce(0, Integer::sum));
+			sum.setFirstTotalCourseSalary(first.stream().map(ExportWrapper.ExportBalancedRelationshipMusicNoCourse::getTotalCourseSalary).reduce(BigDecimal.ZERO, BigDecimal::add));
+			sum.setFirstTotalCoursePrice(first.stream().map(ExportWrapper.ExportBalancedRelationshipMusicNoCourse::getTotalCoursePrice).reduce(BigDecimal.ZERO, BigDecimal::add));
+		}
+
+		//期末已分班未排课
+		List<ExportWrapper.ExportBalancedRelationshipMusicNoCourse> exportBalancedRelationshipMusicNoCourses =
+				musicGroupDao.exportBalancedRelationshipMusicNoCourse(month + "-31 23:59:59", null);
+		if(CollectionUtils.isNotEmpty(exportBalancedRelationshipMusicNoCourses)){
+			//计算课酬
+			this.createMusicGroupCourseTeacherSalaries(exportBalancedRelationshipMusicNoCourses);
+			//将列表所有字段汇总
+			sum.setLastSubCourseMinutes(exportBalancedRelationshipMusicNoCourses.stream().map(ExportWrapper.ExportBalancedRelationshipMusicNoCourse::getSubCourseMinutes).reduce(0, Integer::sum));
+			sum.setLastTotalCourseSalary(exportBalancedRelationshipMusicNoCourses.stream().map(ExportWrapper.ExportBalancedRelationshipMusicNoCourse::getTotalCourseSalary).reduce(BigDecimal.ZERO, BigDecimal::add));
+			sum.setLastTotalCoursePrice(exportBalancedRelationshipMusicNoCourses.stream().map(ExportWrapper.ExportBalancedRelationshipMusicNoCourse::getTotalCoursePrice).reduce(BigDecimal.ZERO, BigDecimal::add));
+		}
+
+		//当月新增已分班未排课(期末-期初)
+		sum.setCurrentSubCourseMinutes(sum.getLastSubCourseMinutes() - sum.getFirstSubCourseMinutes());
+		sum.setCurrentTotalCourseSalary(sum.getLastTotalCourseSalary().subtract(sum.getFirstTotalCourseSalary()));
+		sum.setCurrentTotalCoursePrice(sum.getLastTotalCoursePrice().subtract(sum.getFirstTotalCoursePrice()));
+
+		//当月消耗已分班未排课
+		musicGroupPaymentStudentCourseDetailLogService.lambdaQuery()
+				.gt(MusicGroupPaymentStudentCourseDetailLog::getCreateTime, month + "-01 00:00:00")
+				.lt(MusicGroupPaymentStudentCourseDetailLog::getCreateTime, month + "-31 23:59:59")
+				.list().forEach(e->{
+			sum.setCurrentConsumeCourseMinutes(sum.getCurrentConsumeCourseMinutes() + e.getUsedCourseMinutes());
+			sum.setCurrentConsumeCoursePrice(sum.getCurrentConsumeCoursePrice().add(e.getCoursePrice()));
+			sum.setTotalCourseSalary(sum.getTotalCourseSalary().add(e.getCourseSalary()));
+		});
+		result.add(sum);
+		return result;
+	}
+
+    @Override
+    public List<ExportWrapper.ExportBalancedRelationshipMusicNoClassNoCourse> exportBalancedRelationshipMusicNoClassNoCourseSum(String month) {
+		List<ExportWrapper.ExportBalancedRelationshipMusicNoClassNoCourse> result = new ArrayList<>();
+		ExportWrapper.ExportBalancedRelationshipMusicNoClassNoCourse sum = new ExportWrapper.ExportBalancedRelationshipMusicNoClassNoCourse();
+		//期初未分班未排课
+		BigDecimal first = musicGroupDao.exportBalancedRelationshipMusicNoClassNoCourseSum(month + "-01 00:00:00");
+		sum.setFirstTotalCoursePrice(first);
+		//期末未分班未排课
+		BigDecimal last = musicGroupDao.exportBalancedRelationshipMusicNoClassNoCourseSum(month + "-31 23:59:59");
+		sum.setLastTotalCoursePrice(last);
+		//当月新增未分班未排课(期末-期初)
+		sum.setCurrentTotalCoursePrice(last.subtract(first));
+		result.add(sum);
+		return result;
+	}
+
+	@Override
+	public List<ExportWrapper.ExportBalancedRelationshipMusicCourseSum> exportBalancedRelationshipMusicCourseSum(String month) {
+		List<ExportWrapper.ExportBalancedRelationshipMusicCourseSum> result = new ArrayList<>();
+		ExportWrapper.ExportBalancedRelationshipMusicCourseSum courseSum = musicGroupDao.exportBalancedRelationshipMusicCourseSum(month);
+		//获取排课日志
+		musicGroupPaymentStudentCourseDetailLogService.lambdaQuery()
+				.gt(MusicGroupPaymentStudentCourseDetailLog::getCreateTime, month + "-01 00:00:00")
+				.lt(MusicGroupPaymentStudentCourseDetailLog::getCreateTime, month + "-31 23:59:59")
+				.list().forEach(e->{
+			courseSum.setCurrentMonthAdd(courseSum.getCurrentMonthConsume() + e.getCourseNum());
+			courseSum.setCurrentMonthAddReward(courseSum.getCurrentMonthAddReward().add(e.getCourseSalary()));
+			courseSum.setCurrentMonthAddCourseAmount(courseSum.getCurrentMonthAddCourseAmount().add(e.getCoursePrice()));
+		});
+		result.add(courseSum);
+		return result;
+	}
+
+	private void createMusicGroupCourseTeacherSalaries(List<ExportWrapper.ExportBalancedRelationshipMusicNoCourse> noCours) {
+		List<Integer> teacherIds = noCours.stream().map(ExportWrapper.ExportBalancedRelationshipMusicNoCourse::getTeacherId).distinct().collect(Collectors.toList());
+
+		List<TeacherDefaultMusicGroupSalary> allTeacherDefaultMusicGroupSalary = teacherDefaultMusicGroupSalaryDao.findByTeacher(teacherIds);
+		Map<Integer, List<TeacherDefaultMusicGroupSalary>> teacherSalaryMap =
+				allTeacherDefaultMusicGroupSalary.stream().collect(Collectors.groupingBy(TeacherDefaultMusicGroupSalary::getUserId));
+
+		for (ExportWrapper.ExportBalancedRelationshipMusicNoCourse noCour : noCours) {
+			List<TeacherDefaultMusicGroupSalary> teacherSalaryList = teacherSalaryMap.get(noCour.getTeacherId());
+			if(CollectionUtils.isEmpty(teacherSalaryList)){
+				continue;
+			}
+
+			BigDecimal salary;
+
+			Map<String, TeacherDefaultMusicGroupSalary> collect = teacherSalaryList.stream().collect(Collectors.toMap(e->e.getCourseScheduleType().getCode(), teacherDefaultMusicGroupSalary -> teacherDefaultMusicGroupSalary));
+
+			TeacherDefaultMusicGroupSalary teacherDefaultMusicGroupSalary =
+					collect.get(StringUtils.equals(noCour.getCourseType(),CourseSchedule.CourseScheduleType.HIGH.getCode())? CourseSchedule.CourseScheduleType.HIGH_ONLINE.getCode():noCour.getCourseType());
+
+			if (teacherDefaultMusicGroupSalary == null) {
+				continue;
+			}
+
+			//基准课酬
+			//课程时长与结算单位时长占比
+			BigDecimal classTimeDuty = new BigDecimal(noCour.getSubCourseMinutes()).divide(new BigDecimal(30), CommonConstants.DECIMAL_PLACE, RoundingMode.DOWN);
+			BigDecimal baseSalary = teacherDefaultMusicGroupSalary.getMainTeacher30MinSalary();
+			if(Objects.isNull(baseSalary)){
+				continue;
+			}
+
+			salary = baseSalary.multiply(classTimeDuty).setScale(2, RoundingMode.HALF_UP);
+			//课堂课课酬
+			if (StringUtils.equals(noCour.getCourseType(),CourseSchedule.CourseScheduleType.CLASSROOM.getCode())) {
+				salary = teacherDefaultMusicGroupSalary.getMainTeacher90MinSalary();
+			}
+			//基础技能提高课
+			if (StringUtils.equals(noCour.getCourseType(),CourseSchedule.CourseScheduleType.HIGH_ONLINE.getCode()) || StringUtils.equals(noCour.getCourseType(),CourseSchedule.CourseScheduleType.HIGH.getCode())) {
+
+				if(StringUtils.isBlank(teacherDefaultMusicGroupSalary.getSalaryRuleJson())){
+					continue;
+				}
+
+				int studentNum = noCour.getStudentNum();
+				if(studentNum <= 0){
+					return;
+				}
+				if(studentNum>5){
+					studentNum=5;
+				}
+				salary = JSON.parseObject(teacherDefaultMusicGroupSalary.getSalaryRuleJson()).getBigDecimal(studentNum+"");
+			}
+
+			if (StringUtils.equals(noCour.getCourseType(),CourseSchedule.CourseScheduleType.MUSIC_NETWORK.getCode())) {
+				salary = JSON.parseObject(teacherDefaultMusicGroupSalary.getSalaryRuleJson()).getBigDecimal("1");
+			}
+
+			if(Objects.isNull(salary)){
+				throw new BizException("课酬设置异常");
+			}
+			noCour.setTotalCourseSalary(salary);
+		}
+	}
+
+    // 辅助方法:创建年级映射
 	private static Map<String, String> createGradeMap() {
 	private static Map<String, String> createGradeMap() {
 		Map<String, String> gradeMap = new HashMap<>();
 		Map<String, String> gradeMap = new HashMap<>();
 		gradeMap.put("1", "一年级");
 		gradeMap.put("1", "一年级");

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OperatingReportNewServiceImpl.java

@@ -207,6 +207,17 @@ public class OperatingReportNewServiceImpl extends BaseServiceImpl<Integer, Oper
 		return operatingReportNewDao.queryOASummaryExpensesDetail(month);
 		return operatingReportNewDao.queryOASummaryExpensesDetail(month);
 	}
 	}
 
 
+	@Override
+	public void balancedRelationship(String month) {
+		//月头的数据统计
+		operatingReportNewDao.firstBalancedRelationship(month);
+
+		//上月月末的数据统计
+		//获取上个月时间
+		String lastMonth = DateUtil.dateToString(DateUtil.addMonths(DateUtil.stringToDate(month,DateUtil.ISO_YEAR_MONTH_FORMAT),-1),DateUtil.ISO_YEAR_MONTH_FORMAT);
+		operatingReportNewDao.lastBalancedRelationship(lastMonth);
+	}
+
 	private BigDecimal getAmount(BigDecimal amount){
 	private BigDecimal getAmount(BigDecimal amount){
 		if(amount == null){
 		if(amount == null){
 			amount = BigDecimal.ZERO;
 			amount = BigDecimal.ZERO;

+ 131 - 0
mec-biz/src/main/resources/config/mybatis/ExportMapper.xml

@@ -2,6 +2,53 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!-- 这个文件是自动生成的。 不要修改此文件。所有改动将在下次重新自动生成时丢失。 -->
 <!-- 这个文件是自动生成的。 不要修改此文件。所有改动将在下次重新自动生成时丢失。 -->
 <mapper namespace="com.ym.mec.biz.dal.dao.ExportDao">
 <mapper namespace="com.ym.mec.biz.dal.dao.ExportDao">
+    <select id="exportBalancedRelationshipMusicCourse1"
+            resultType="com.ym.mec.biz.dal.dto.ExportWrapper$ExportBalancedRelationshipMusicCourse">
+        select o.name_ organName,mg.name_ musicGroupName,mg.id_ musicGroupId,cg.name_ className,mm.class_group_id_ classId,
+               CASE WHEN cg.type_ = 'NORMAL' THEN '声部班'
+                    WHEN cg.type_ = 'MIX' THEN '合奏班'
+                    WHEN cg.type_ = 'HIGH' THEN '基础技能班'
+                    WHEN cg.type_ = 'VIP' THEN 'vip课'
+                    WHEN cg.type_ = 'DEMO' THEN '试听课'
+                    WHEN cg.type_ = 'PRACTICE' THEN '网管课'
+                    WHEN cg.type_ = 'SNAP' THEN '临时班'
+                    WHEN cg.type_ = 'COMM' THEN '对外课程'
+                    WHEN cg.type_ = 'HIGH_ONLINE' THEN '线上基础技能班'
+                    WHEN cg.type_ = 'MUSIC_NETWORK' THEN '乐团网管课'
+                    WHEN cg.type_ = 'LIVE' THEN '直播课' END classType,
+               CASE WHEN mm.course_type_ = 'SINGLE' THEN '声部课'
+                    WHEN mm.course_type_ = 'MIX' THEN '合奏课'
+                    WHEN mm.course_type_ = 'HIGH' THEN '基础技能课'
+                    WHEN mm.course_type_ = 'VIP' THEN 'vip课'
+                    WHEN mm.course_type_ = 'DEMO' THEN '试听课'
+                    WHEN mm.course_type_ = 'COMPREHENSIVE' THEN '综合课'
+                    WHEN mm.course_type_ = 'PRACTICE' THEN '网管课'
+                    WHEN mm.course_type_ = 'ENLIGHTENMENT' THEN '启蒙课'
+                    WHEN mm.course_type_ = 'TRAINING_SINGLE' THEN '集训声部课'
+                    WHEN mm.course_type_ = 'TRAINING_MIX' THEN '集训合奏课'
+                    WHEN mm.course_type_ = 'CLASSROOM' THEN '课堂课'
+                    WHEN mm.course_type_ = 'COMM' THEN '对外课程'
+                    WHEN mm.course_type_ = 'HIGH_ONLINE' THEN '线上基础技能课'
+                    WHEN mm.course_type_ = 'MUSIC_NETWORK' THEN '乐团网管课'
+                    WHEN mm.course_type_ = 'LIVE' THEN '直播课' END courseType,
+               first_month_pre_amount_ firstMonthPreAmount, first_month_sub_course_num_ firstMonthSubCourseNum,
+               first_month_course_salary_ firstMonthCourseSalary, first_month_pre_merge_amount_ firstMonthPreMergeAmount, first_month_sub_merge_course_num_ firstMonthSubMergeCourseNum,
+               first_month_merge_course_salary_ firstMonthMergeCourseSalary, current_month_add_course_amount_ currentMonthAddCourseAmount, current_month_add_course_num_ currentMonthAdd,
+               current_month_add_course_salary_ currentMonthAddReward, current_month_add_merge_course_amount_ currentMonthAddMergeCourseAmount, current_month_add_merge_course_num_ currentMonthMergedAdd,
+               current_month_add_merge_course_salary_ currentMonthMergedAddReward, current_month_consume_course_num_ currentMonthConsume, current_month_course_salary_ currentMonthConsumeReward,
+               current_month_course_amount_ currentMonthCourseAmount, current_month_consume_merge_course_num_ currentMonthMergedConsume, current_month_merge_course_salary_ currentMonthMergedConsumeReward,
+               current_month_merge_course_amount_ currentMonthMergeCourseAmount, last_month_pre_amount_ lastMonthPreAmount, last_month_sub_course_num_ lastMonthSubCourseNum, last_month_course_salary_ lastMonthCourseSalary,
+               last_month_pre_merge_amount_ lastMonthPreMergeAmount, last_month_sub_merge_course_num_ lastMonthSubMergeCourseNum, last_month_merge_course_salary_ lastMonthMergeCourseSalary
+        from month_music_class_report_statis mm
+                 left join class_group cg ON cg.id_ = mm.class_group_id_
+                 left join music_group mg ON mg.id_ = cg.music_group_id_
+                 left join organization o ON o.id_ = mg.organ_id_
+        where mm.month_ = #{month}
+        <if test="organIds != null and organIds != ''">
+            AND FIND_IN_SET(mg.organ_id_,#{organIds})
+        </if>
+        order by mg.organ_id_,cg.id_,mm.course_type_
+    </select>
     <select id="exportBalancedRelationshipMusicCourse"
     <select id="exportBalancedRelationshipMusicCourse"
             resultType="com.ym.mec.biz.dal.dto.ExportWrapper$ExportBalancedRelationshipMusicCourse">
             resultType="com.ym.mec.biz.dal.dto.ExportWrapper$ExportBalancedRelationshipMusicCourse">
         select o.name_ organName,mg.name_ musicGroupName,mg.id_ musicGroupId,cg.name_ className,
         select o.name_ organName,mg.name_ musicGroupName,mg.id_ musicGroupId,cg.name_ className,
@@ -228,6 +275,90 @@
         <include refid="hasStudentMusicTheoryCourseInfo"/>
         <include refid="hasStudentMusicTheoryCourseInfo"/>
         LIMIT 1
         LIMIT 1
     </select>
     </select>
+    <select id="exportBalancedRelationshipVipSubCourseDetail"
+            resultType="com.ym.mec.biz.dal.dto.ExportWrapper$ExportBalancedRelationshipVipSubCourseDetail">
+        select sbi.organ_name_ organName,sbi.cooperation_organ_name_ coopName,sbi.user_id_ userId,sbi.user_name_ username,
+               vgc.name_ courseType,
+               first_month_pre_no_course_amount_ AS firstMonthPreNoCourseAmount,
+               first_month_sub_course_num_ AS firstMonthSubCourseNum,
+               first_month_sub_no_course_num_ AS firstMonthSubNoCourseNum,
+               first_month_course_salary_ AS firstMonthCourseSalary,
+               first_month_no_course_salary_ AS firstMonthNoCourseSalary,
+               current_month_actual_amount_ AS currentMonthActualAmount,
+               current_month_balance_amount_ AS currentMonthBalanceAmount,
+               current_month_add_course_num_ AS currentMonthAddCourseNum,
+               current_month_add_course_salary_ AS currentMonthAddCourseSalary,
+               current_month_add_no_course_salary_ AS currentMonthAddNoCourseSalary,
+               current_month_consume_course_num_ AS currentMonthConsumeCourseNum,
+               current_month_course_salary_ AS currentMonthCourseSalary,
+               current_month_course_amount_ AS currentMonthCourseAmount,
+               last_month_pre_course_amount_ AS lastMonthPreCourseAmount,
+               last_month_pre_no_course_amount_ AS lastMonthPreNoCourseAmount,
+               last_month_sub_course_num_ AS lastMonthSubCourseNum,
+               last_month_sub_no_course_num_ AS lastMonthSubNoCourseNum,
+               last_month_course_salary_ AS lastMonthCourseSalary,
+               last_month_no_course_salary_ AS lastMonthNoCourseSalary
+        from month_vip_report_statis mv
+                 left join student_basic_info sbi ON sbi.user_id_ = mv.user_id_
+                 left join vip_group_category vgc ON vgc.id_ = mv.course_type_
+        where mv.month_ = #{month}
+        <if test="organIds != null and organIds.size > 0">
+            AND sbi.organ_id_ IN
+            <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+                #{organId}
+            </foreach>
+        </if>
+        order by sbi.organ_id_,sbi.user_id_,mv.course_type_
+    </select>
+    <select id="exportBalancedRelationshipVipSubCourseSum"
+            resultType="com.ym.mec.biz.dal.dto.ExportWrapper$ExportBalancedRelationshipVipSubCourseDetail">
+        select
+            SUM(mv.first_month_pre_no_course_amount_) AS firstMonthPreNoCourseAmount,
+            SUM(mv.first_month_sub_course_num_) AS firstMonthSubCourseNum,
+            SUM(mv.first_month_sub_no_course_num_) AS firstMonthSubNoCourseNum,
+            SUM(mv.first_month_course_salary_) AS firstMonthCourseSalary,
+            SUM(mv.first_month_no_course_salary_) AS firstMonthNoCourseSalary,
+            SUM(mv.current_month_actual_amount_) AS currentMonthActualAmount,
+            SUM(mv.current_month_balance_amount_) AS currentMonthBalanceAmount,
+            SUM(mv.current_month_add_course_num_) AS currentMonthAddCourseNum,
+            SUM(mv.current_month_add_course_salary_) AS currentMonthAddCourseSalary,
+            SUM(mv.current_month_add_no_course_salary_) AS currentMonthAddNoCourseSalary,
+            SUM(mv.current_month_consume_course_num_) AS currentMonthConsumeCourseNum,
+            SUM(mv.current_month_course_salary_) AS currentMonthCourseSalary,
+            SUM(mv.current_month_course_amount_) AS currentMonthCourseAmount,
+            SUM(mv.last_month_pre_course_amount_) AS lastMonthPreCourseAmount,
+            SUM(mv.last_month_pre_no_course_amount_) AS lastMonthPreNoCourseAmount,
+            SUM(mv.last_month_sub_course_num_) AS lastMonthSubCourseNum,
+            SUM(mv.last_month_sub_no_course_num_) AS lastMonthSubNoCourseNum,
+            SUM(mv.last_month_course_salary_) AS lastMonthCourseSalary,
+            SUM(mv.last_month_no_course_salary_) AS lastMonthNoCourseSalary
+        from month_vip_report_statis mv
+        where mv.month_ = #{month}
+    </select>
+    <select id="exportBalancedRelationshipCloudSum"
+            resultType="com.ym.mec.biz.dal.dto.ExportWrapper$ExportBalancedRelationshipCloudSum">
+        SELECT
+            first_month_pre_amount_ AS firstMonthPreAmount,
+            first_month_pre_wait_amount_ AS firstMonthPreWaitAmount,
+            first_month_active_num_ AS firstMonthActiveNum,
+            first_month_wait_active_num_ AS firstMonthWaitActiveNum,
+            current_month_add_pre_amount_ AS currentMonthAddPreAmount,
+            current_month_add_num_ AS currentMonthAddNum,
+            current_month_renew_pre_amount_ AS currentMonthRenewPreAmount,
+            current_month_renew_num_ AS currentMonthRenewNum,
+            current_month_cut_num_ AS currentMonthCutNum,
+            current_month_amount_ AS currentMonthAmount,
+            current_month_return_num_ AS currentMonthReturnNum,
+            current_month_return_amount_ AS currentMonthReturnAmount,
+            current_month_active_num_ AS currentMonthActiveNum,
+            last_month_pre_amount_ AS lastMonthPreAmount,
+            last_month_pre_wait_amount_ AS lastMonthPreWaitAmount,
+            last_month_active_num_ AS lastMonthActiveNum,
+            last_month_wait_active_num_ AS lastMonthWaitActiveNum
+        FROM
+            month_cloud_report_statis
+        where month_ = #{month}
+    </select>
     <sql id="hasStudentMusicTheoryCourseInfo">
     <sql id="hasStudentMusicTheoryCourseInfo">
         <where>
         <where>
             cssp.`group_type_` = 'VIP' AND cs.`del_flag_` != 1 AND cs.`is_lock_` != 1
             cssp.`group_type_` = 'VIP' AND cs.`del_flag_` != 1 AND cs.`is_lock_` != 1

+ 51 - 1
mec-biz/src/main/resources/config/mybatis/MusicGroupMapper.xml

@@ -1331,6 +1331,56 @@
         select distinct ig.id_ from music_group mg
         select distinct ig.id_ from music_group mg
                              left join class_group cg ON cg.music_group_id_ = mg.id_
                              left join class_group cg ON cg.music_group_id_ = mg.id_
                              left join im_group ig ON ig.id_ = cg.id_
                              left join im_group ig ON ig.id_ = cg.id_
-        where mg.status_ IN ('CANCELED','CLOSE') and cg.group_type_ = 'MUSIC';
+        where mg.status_ IN ('CANCELED','CLOSE') and cg.group_type_ = 'MUSIC'
+    </select>
+    <select id="exportBalancedRelationshipMusicNoCourse"
+            resultType="com.ym.mec.biz.dal.dto.ExportWrapper$ExportBalancedRelationshipMusicNoCourse">
+        select o.name_ organName,mg.name_ musicGroupName,cgtm.user_id_,cgsm.class_group_id_ classId,
+               mgpscd.music_group_id_ musicGroupId,cg.name_ className,cg.type_ classType,cgtm.user_id_ teacherId,
+               mgpscd.course_type_ courseType,SUM(mgpscd.sub_course_current_price_) totalCoursePrice,
+               SUM(mgpscd.sub_course_minutes_) subCourseMinutes,COUNT(DISTINCT cgsm.user_id_) studentNum
+        from music_group_payment_student_course_detail mgpscd
+                 left join class_group_student_mapper cgsm ON cgsm.music_group_id_ = mgpscd.music_group_id_ and cgsm.user_id_ = mgpscd.user_id_ AND cgsm.status_ = 'NORMAL'
+                 left join class_group cg ON cg.id_ = cgsm.class_group_id_
+                 left join music_group mg ON mg.id_ = cg.music_group_id
+                 left join organization o ON o.id_ = mg.organ_id__
+                 left join class_group_teacher_mapper cgtm ON cgtm.class_group_id_ = cg.id_ AND cgtm.teacher_role_ = 'BISHOP'
+        where mgpscd.sub_course_current_price_ > 0 AND mgpscd.sub_course_minutes_ > 0
+          AND (cg.type_ = mgpscd.course_type_ OR
+                   (cg.type_ = 'NORMAL' AND mgpscd.course_type_ IN ('SINGLE','TRAINING_SINGLE')) OR
+                   (cg.type_ = 'MIX' AND mgpscd.course_type_ IN ('MIX','TRAINING_MIX')) OR cg.type_ = 'SNAP')
+          <if test="month != null and month != ''">
+                AND mgpscd.create_time_ $lt; #{month}
+          </if>
+        <if test="organIds != null and organIds.size > 0">
+            AND mg.organ_id_ IN
+            <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+                #{organId}
+            </foreach>
+        </if>
+        group by mg.organ_id_,cgsm.class_group_id_,mgpscd.course_type_
+        order by mg.organ_id_,cgsm.class_group_id_,mgpscd.course_type_
+    </select>
+    <select id="exportBalancedRelationshipMusicNoClassNoCourseSum" resultType="java.math.BigDecimal">
+        select SUM(mgpscd.sub_course_current_price_)
+        from music_group_payment_student_course_detail mgpscd
+        left join (select cgsm.user_id_,cg.type_,cg.music_group_id_,cgsm.class_group_id_  from class_group_student_mapper cgsm
+        left join class_group cg ON cg.id_ = cgsm.class_group_id_
+        where cg.group_type_ = 'MUSIC' AND cgsm.status_ = 'NORMAL') cgsm ON cgsm.music_group_id_ = mgpscd.music_group_id_ and cgsm.user_id_ = mgpscd.user_id_
+        AND (cgsm.type_ = mgpscd.course_type_ OR
+        (cgsm.type_ = 'NORMAL' AND mgpscd.course_type_ IN ('SINGLE','TRAINING_SINGLE')) OR
+        (cgsm.type_ = 'MIX' AND mgpscd.course_type_ IN ('MIX','TRAINING_MIX')) OR cgsm.type_ = 'SNAP')
+        where mgpscd.sub_course_current_price_ > 0 AND mgpscd.sub_course_minutes_ > 0
+        AND mgpscd.create_time_ $lt;= #{month} AND cgsm.class_group_id_ IS NULL;
+    </select>
+    <select id="exportBalancedRelationshipMusicCourseSum"
+            resultType="com.ym.mec.biz.dal.dto.ExportWrapper$ExportBalancedRelationshipMusicCourseSum">
+        select
+        first_month_pre_amount_ firstMonthPreAmount, first_month_sub_course_num_ firstMonthSubCourseNum,
+        first_month_course_salary_ firstMonthCourseSalary, current_month_consume_course_num_ currentMonthConsume, current_month_course_salary_ currentMonthConsumeReward,
+        current_month_course_amount_ currentMonthCourseAmount, last_month_pre_amount_ lastMonthPreAmount,
+        last_month_sub_course_num_ lastMonthSubCourseNum, last_month_course_salary_ lastMonthCourseSalary
+        from month_music_class_report_statis mm
+        where mm.month_ = #{month}
     </select>
     </select>
 </mapper>
 </mapper>

+ 6 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentStudentCourseDetailLogMapper.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE  mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.ym.mec.biz.dal.dao.InstrumentDao">
+
+
+</mapper>

+ 13 - 0
mec-biz/src/main/resources/config/mybatis/OperatingReportNewMapper.xml

@@ -428,4 +428,17 @@
 		from human_cost
 		from human_cost
 		where month_ = #{month} group by organ_id_
 		where month_ = #{month} group by organ_id_
 	</select>
 	</select>
+	<select id="firstBalancedRelationship">
+		select firstMonthVipReportStatis(#{month});
+		select firstMonthMusicClassReportStatis(#{month});
+		select firstMonthCloudReportStatis(#{month});
+	</select>
+	<select id="lastBalancedRelationship">
+		select currentMonthVipReportStatis(#{month});
+		select lastMonthVipReportStatis(#{month});
+		select currentMonthMusicClassReportStatis(#{month});
+		select lastMonthMusicClassReportStatis(#{month});
+		select currentMonthCloudReportStatis(#{month});
+		select lastMonthCloudReportStatis(#{month});
+	</select>
 </mapper>
 </mapper>

+ 4 - 0
mec-client-api/src/main/java/com/ym/mec/task/TaskRemoteService.java

@@ -12,6 +12,10 @@ import org.springframework.web.bind.annotation.GetMapping;
         configuration = {FeignConfiguration.class}, fallback = TaskRemoteServiceFallback.class)
         configuration = {FeignConfiguration.class}, fallback = TaskRemoteServiceFallback.class)
 public interface TaskRemoteService {
 public interface TaskRemoteService {
 
 
+    @GetMapping(value = "task/balancedRelationshipTask")
+    // 每月一次平衡关系任务
+    public void balancedRelationshipTask();
+
     @GetMapping(value = "task/pushWaitSendMessageTask")
     @GetMapping(value = "task/pushWaitSendMessageTask")
     // 每天9点推送前一天22点之后的推送消息
     // 每天9点推送前一天22点之后的推送消息
     public void pushWaitSendMessageTask();
     public void pushWaitSendMessageTask();

+ 4 - 0
mec-client-api/src/main/java/com/ym/mec/task/fallback/TaskRemoteServiceFallback.java

@@ -155,6 +155,10 @@ public class TaskRemoteServiceFallback implements TaskRemoteService {
     public void pushWaitSendMessageTask() {
     public void pushWaitSendMessageTask() {
         logger.info("延时推送执行失败");
         logger.info("延时推送执行失败");
     }
     }
+    @Override
+    public void balancedRelationshipTask() {
+        logger.info("平衡关系执行失败");
+    }
 
 
     @Override
     @Override
     public void pushTeacherExceptionAttendanceTask() {
     public void pushTeacherExceptionAttendanceTask() {

+ 20 - 0
mec-task/src/main/java/com/ym/mec/task/jobs/BalancedRelationshipTask.java

@@ -0,0 +1,20 @@
+package com.ym.mec.task.jobs;
+
+import com.ym.mec.task.TaskRemoteService;
+import com.ym.mec.task.core.BaseTask;
+import com.ym.mec.task.core.TaskException;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+@Service
+public class BalancedRelationshipTask extends BaseTask {
+
+	@Resource
+	private TaskRemoteService taskRemoteService;
+
+	@Override
+	public void execute() throws TaskException {
+		taskRemoteService.balancedRelationshipTask();
+	}
+}