zouxuan 2 年 前
コミット
74020156a7
35 ファイル変更1129 行追加227 行削除
  1. 4 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CloudTeacherFreeCourseDao.java
  2. 1 8
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CloudTeacherOrderDao.java
  3. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicMarginDao.java
  4. 9 2
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/OperatingReportCloudDao.java
  5. 68 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/OperatingReportNewDao.java
  6. 13 25
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CloudTeacherFreeCourse.java
  7. 12 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CloudTeacherOrder.java
  8. 191 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicMargin.java
  9. 8 19
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/OperatingReportCloud.java
  10. 54 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/OperatingReportNew.java
  11. 16 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/MusicMarginQueryInfo.java
  12. 15 0
      mec-biz/src/main/java/com/ym/mec/biz/service/CloudTeacherFreeCourseService.java
  13. 0 8
      mec-biz/src/main/java/com/ym/mec/biz/service/CloudTeacherOrderService.java
  14. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicMarginService.java
  15. 5 4
      mec-biz/src/main/java/com/ym/mec/biz/service/OperatingReportCloudService.java
  16. 14 0
      mec-biz/src/main/java/com/ym/mec/biz/service/OperatingReportNewService.java
  17. 5 3
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ActivityUserMapperServiceImpl.java
  18. 36 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CloudTeacherFreeCourseServiceImpl.java
  19. 9 5
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CloudTeacherOrderServiceImpl.java
  20. 3 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java
  21. 6 34
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MemberRankSettingServiceImpl.java
  22. 1 15
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java
  23. 4 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  24. 22 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicMarginServiceImpl.java
  25. 43 28
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/OperatingReportCloudServiceImpl.java
  26. 97 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/OperatingReportNewServiceImpl.java
  27. 22 32
      mec-biz/src/main/resources/config/mybatis/CloudTeacherFreeCourseMapper.xml
  28. 7 12
      mec-biz/src/main/resources/config/mybatis/CloudTeacherOrderMapper.xml
  29. 123 0
      mec-biz/src/main/resources/config/mybatis/MusicMarginMapper.xml
  30. 6 6
      mec-biz/src/main/resources/config/mybatis/OperatingReportCloudMapper.xml
  31. 237 0
      mec-biz/src/main/resources/config/mybatis/OperatingReportNewMapper.xml
  32. 0 14
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupQuitController.java
  33. 70 0
      mec-web/src/main/java/com/ym/mec/web/controller/MusicMarginController.java
  34. 0 7
      mec-web/src/main/java/com/ym/mec/web/controller/OperatingReportController.java
  35. 11 2
      mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java

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

@@ -2,8 +2,11 @@ package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.biz.dal.entity.CloudTeacherFreeCourse;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface CloudTeacherFreeCourseDao extends BaseDAO<Long, CloudTeacherFreeCourse> {
 
-	
+    void batchInsert(@Param("scheduleIdList") String scheduleIdList, @Param("calenderId") Long calenderId);
 }

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

@@ -3,11 +3,11 @@ package com.ym.mec.biz.dal.dao;
 import com.ym.mec.biz.dal.dto.CloudTeacherActiveTargetDetailDto;
 import com.ym.mec.biz.dal.dto.CloudTeacherOrderDto;
 import com.ym.mec.biz.dal.dto.Mapper;
-import com.ym.mec.biz.dal.dto.SysUserDto;
 import com.ym.mec.biz.dal.entity.CloudTeacherOrder;
 import com.ym.mec.biz.dal.entity.CloudTeacherStudent;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
+
 import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
@@ -39,13 +39,6 @@ public interface CloudTeacherOrderDao extends BaseDAO<Long, CloudTeacherOrder> {
     List<CloudTeacherOrder> getStudentCloudTeacherOrders(@Param("studentIds") List<Integer> studentIds, @Param("musicGroupId") String musicGroupId);
 
     /**
-     * 获取乐团报名的云教练订单
-     * @param studentId
-     * @return
-     */
-    List<CloudTeacherOrder> getStudentCloudTeacherOrder(@Param("studentId") Integer studentId, @Param("musicGroupId") String musicGroupId);
-    
-    /**
      * 根据订单编号查询订单详情
      * @param orderId
      * @return

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

@@ -0,0 +1,9 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.biz.dal.entity.MusicMargin;
+
+public interface MusicMarginDao extends BaseDAO<Integer, MusicMargin> {
+
+	
+}

+ 9 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/OperatingReportCloudDao.java

@@ -8,8 +8,15 @@ import java.util.List;
 
 public interface OperatingReportCloudDao extends BaseDAO<Integer, OperatingReportCloud> {
 
-
     void batchInsert(@Param("operatingReportClouds") List<OperatingReportCloud> operatingReportClouds);
 
-    OperatingReportCloud findByCalenderId(@Param("calenderId") Long calenderId, @Param("userId") Integer userId);
+    /**
+    * @description: 根据缴费项目编号和是否当月结算查询
+     * @param calenderId
+     * @param monthFlag
+    * @return com.ym.mec.biz.dal.entity.OperatingReportCloud
+    * @author zx
+    * @date 2022/9/7 09:45
+    */
+    OperatingReportCloud findByCalenderId(@Param("calenderId") Long calenderId, @Param("monthFlag") Boolean monthFlag);
 }

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

@@ -0,0 +1,68 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.biz.dal.entity.OperatingReportNew;
+import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+
+public interface OperatingReportNewDao extends BaseDAO<Integer, OperatingReportNew> {
+
+    List<OperatingReportNew> initOperatingReport(String currentMonth);
+
+    //获取销售收入和销售成本
+    List<OperatingReportNew> sumSellAmount(String month);
+
+    //云教练赠送课程服务收入
+    List<Map<Integer,BigDecimal>> sumCloudCourseAmount(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay);
+
+    //付费课程收入
+    List<Map<Integer,BigDecimal>> sumCourseAmount(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay);
+
+    //个人云教练服务收入
+    List<Map<Integer,BigDecimal>> sumPersonalCloudAmount(@Param("month") String month, @Param("firstDay") String firstDay, @Param("lastDay") String lastDay);
+
+    //团体云教练服务收入
+    List<Map<Integer,BigDecimal>> sumGroupCloudAmount(@Param("month") String month, @Param("firstDay") String firstDay, @Param("lastDay") String lastDay);
+
+    //业务退费
+    List<Map<Integer,BigDecimal>> sumRefundAmount(@Param("month") String month);
+
+    //变动费用
+    List<Map<Integer,BigDecimal>> sumVariableCosts(@Param("month") String month);
+
+    //固定费用
+    List<Map<Integer,BigDecimal>> sumFixedCosts(@Param("month") String month);
+
+    //个人云教练预收款
+    List<Map<Integer,BigDecimal>> sumCloudPreAmount(@Param("month") String month, @Param("lastDay") String lastDay);
+
+    //团体云教练分月结转
+    List<Map<Integer,BigDecimal>> sumGroupCloudPreAmount(@Param("month") String month, @Param("lastDay") String lastDay);
+
+    //团体云教练当月一次性结转
+    List<Map<Integer,BigDecimal>> sumGroupAmount();
+
+    //云教练赠课预收
+    List<Map<Integer,BigDecimal>> sumCloudCoursePreAmount(@Param("lastDay") String lastDay);
+
+    //付费课程预收
+    List<Map<Integer,BigDecimal>> sumCoursePreAmount(@Param("lastDay") String lastDay);
+
+    //其他预收
+    List<Map<Integer,BigDecimal>> sumOtherPreAmount();
+
+    //销售预收
+    List<Map<Integer,BigDecimal>> sumSalePreAmount();
+
+    //欠费总金额
+    List<Map<Integer,BigDecimal>> sumArrearsAmount();
+
+    //待缴费学校金额
+    List<Map<Integer,BigDecimal>> sumSchoolAmount();
+
+    //更新云教练计费时间
+    void initCloudStartTime(@Param("lastDay") String lastDay);
+}

+ 13 - 25
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CloudTeacherFreeCourse.java

@@ -12,22 +12,26 @@ public class CloudTeacherFreeCourse {
 	
 	/** 课程编号 */
 	private Long courseId;
-	
-	/** 学员缴费项目详情编号 */
-	private Integer calenderDetailId;
+
+	private Long calenderId;
 	
 	/** 课程成本 */
 	private java.math.BigDecimal cost;
 	
-	/** 是否结算经营报表 */
-	private Integer operatingFlag;
-	
 	/**  */
 	private java.util.Date createTime;
 	
 	/**  */
 	private java.util.Date updateTime;
-	
+
+	public Long getCalenderId() {
+		return calenderId;
+	}
+
+	public void setCalenderId(Long calenderId) {
+		this.calenderId = calenderId;
+	}
+
 	public void setId(Long id){
 		this.id = id;
 	}
@@ -43,15 +47,7 @@ public class CloudTeacherFreeCourse {
 	public Long getCourseId(){
 		return this.courseId;
 	}
-			
-	public void setCalenderDetailId(Integer calenderDetailId){
-		this.calenderDetailId = calenderDetailId;
-	}
-	
-	public Integer getCalenderDetailId(){
-		return this.calenderDetailId;
-	}
-			
+
 	public void setCost(java.math.BigDecimal cost){
 		this.cost = cost;
 	}
@@ -59,15 +55,7 @@ public class CloudTeacherFreeCourse {
 	public java.math.BigDecimal getCost(){
 		return this.cost;
 	}
-			
-	public void setOperatingFlag(Integer operatingFlag){
-		this.operatingFlag = operatingFlag;
-	}
-	
-	public Integer getOperatingFlag(){
-		return this.operatingFlag;
-	}
-			
+
 	public void setCreateTime(java.util.Date createTime){
 		this.createTime = createTime;
 	}

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CloudTeacherOrder.java

@@ -50,6 +50,9 @@ public class CloudTeacherOrder extends BaseEntity {
     @ApiModelProperty(value = "购买价格")
     private BigDecimal amount;
 
+    @ApiModelProperty(value = "经营报表结算价")
+    private BigDecimal operatingAmount = BigDecimal.ZERO;
+
     /**
      * 退回金额
      */
@@ -116,10 +119,19 @@ public class CloudTeacherOrder extends BaseEntity {
     @ApiModelProperty(value = "更新时间")
     private Date updateTime;
 
+    @ApiModelProperty(value = "乐团编号")
     private String musicGroupId;
     
     private StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
 
+    public BigDecimal getOperatingAmount() {
+        return operatingAmount;
+    }
+
+    public void setOperatingAmount(BigDecimal operatingAmount) {
+        this.operatingAmount = operatingAmount;
+    }
+
     public Integer getActiveRemark() {
         return activeRemark;
     }

+ 191 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicMargin.java

@@ -0,0 +1,191 @@
+package com.ym.mec.biz.dal.entity;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(music_margin):
+ */
+public class MusicMargin {
+
+	/**  */
+	private Integer id;
+	
+	/** 类型 */
+	private String type;
+	
+	/** 日期 */
+	private String date;
+	
+	/** 分部 */
+	private String organ;
+	
+	/** 学校 */
+	private String school;
+	
+	/** 用户编号,财务操作退款时填入 */
+	private Integer userId;
+	
+	/** 学员姓名 */
+	private String username;
+	
+	/** 期初 */
+	private java.math.BigDecimal init;
+	
+	/** 收款 */
+	private java.math.BigDecimal payment;
+	
+	/** 退款 */
+	private java.math.BigDecimal refund;
+	
+	/** 是否退款0否1是2拒绝 */
+	private Integer refundFlag;
+	
+	/** 余额 */
+	private java.math.BigDecimal balance;
+	
+	/** 保证金类型 */
+	private String marginType;
+	
+	/** 匹配 */
+	private String match;
+	
+	/** 备注 */
+	private String memo;
+	
+	/** 流程编号 */
+	private String processNo;
+	
+	public void setId(Integer id){
+		this.id = id;
+	}
+	
+	public Integer getId(){
+		return this.id;
+	}
+			
+	public void setType(String type){
+		this.type = type;
+	}
+	
+	public String getType(){
+		return this.type;
+	}
+			
+	public void setDate(String date){
+		this.date = date;
+	}
+	
+	public String getDate(){
+		return this.date;
+	}
+			
+	public void setOrgan(String organ){
+		this.organ = organ;
+	}
+	
+	public String getOrgan(){
+		return this.organ;
+	}
+			
+	public void setSchool(String school){
+		this.school = school;
+	}
+	
+	public String getSchool(){
+		return this.school;
+	}
+			
+	public void setUserId(Integer userId){
+		this.userId = userId;
+	}
+	
+	public Integer getUserId(){
+		return this.userId;
+	}
+			
+	public void setUsername(String username){
+		this.username = username;
+	}
+	
+	public String getUsername(){
+		return this.username;
+	}
+			
+	public void setInit(java.math.BigDecimal init){
+		this.init = init;
+	}
+	
+	public java.math.BigDecimal getInit(){
+		return this.init;
+	}
+			
+	public void setPayment(java.math.BigDecimal payment){
+		this.payment = payment;
+	}
+	
+	public java.math.BigDecimal getPayment(){
+		return this.payment;
+	}
+			
+	public void setRefund(java.math.BigDecimal refund){
+		this.refund = refund;
+	}
+	
+	public java.math.BigDecimal getRefund(){
+		return this.refund;
+	}
+			
+	public void setRefundFlag(Integer refundFlag){
+		this.refundFlag = refundFlag;
+	}
+	
+	public Integer getRefundFlag(){
+		return this.refundFlag;
+	}
+			
+	public void setBalance(java.math.BigDecimal balance){
+		this.balance = balance;
+	}
+	
+	public java.math.BigDecimal getBalance(){
+		return this.balance;
+	}
+			
+	public void setMarginType(String marginType){
+		this.marginType = marginType;
+	}
+	
+	public String getMarginType(){
+		return this.marginType;
+	}
+			
+	public void setMatch(String match){
+		this.match = match;
+	}
+	
+	public String getMatch(){
+		return this.match;
+	}
+			
+	public void setMemo(String memo){
+		this.memo = memo;
+	}
+	
+	public String getMemo(){
+		return this.memo;
+	}
+			
+	public void setProcessNo(String processNo){
+		this.processNo = processNo;
+	}
+	
+	public String getProcessNo(){
+		return this.processNo;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 8 - 19
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/OperatingReportCloud.java

@@ -12,17 +12,14 @@ public class OperatingReportCloud {
 	/**  */
 	private Integer id;
 	
-	/** 缴费项目关联的课程编号 */
-	private String courseIds;
-
 	/** 分部编号 */
 	private Integer organId;
 	
-	/** 学员编号 */
-	private Integer userId;
-
 	/** 缴费项目编号 */
 	private Long calenderId;
+
+	//是否是当月全部结转(欠费或者进行中加学员都在当月全部结转)
+	private Boolean monthFlag = false;
 	
 	/** 云教练预收开始计费时间(该字段只会再结算经营报表的时候去更新,因为课程会不断调整,结算的时候取缴费项目关联的课程的第一节课的日期) */
 	private java.util.Date startDate;
@@ -35,7 +32,7 @@ public class OperatingReportCloud {
 	
 	/** 课程预收 */
 	private java.math.BigDecimal coursePrice = BigDecimal.ZERO;
-	
+
 	/** 月底结算经营报表的标识,如果已经结算过,那么这条记录不会再修改 */
 	private Boolean settlementFlag = false;
 	
@@ -45,20 +42,12 @@ public class OperatingReportCloud {
 	/**  */
 	private java.util.Date updateTime;
 
-	public String getCourseIds() {
-		return courseIds;
-	}
-
-	public void setCourseIds(String courseIds) {
-		this.courseIds = courseIds;
-	}
-
-	public Integer getUserId() {
-		return userId;
+	public Boolean getMonthFlag() {
+		return monthFlag;
 	}
 
-	public void setUserId(Integer userId) {
-		this.userId = userId;
+	public void setMonthFlag(Boolean monthFlag) {
+		this.monthFlag = monthFlag;
 	}
 
 	public void setId(Integer id){

+ 54 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/OperatingReportNew.java

@@ -6,12 +6,17 @@ import java.math.BigDecimal;
 
 public class OperatingReportNew {
 
+    private Integer id;
+
     @ApiModelProperty(value="负责人")
     private String principal;
 
     @ApiModelProperty(value="城市")
     private String organName;
 
+    @ApiModelProperty(value="城市")
+    private Integer organId;
+
     @ApiModelProperty(value="销售收入(当月实收)")
     //实物销售收入(已收货商品)
     private BigDecimal saleAmount;
@@ -20,6 +25,15 @@ public class OperatingReportNew {
     @ApiModelProperty(value="服务收入(当月实收)")
     private BigDecimal serviceAmount;
 
+    @ApiModelProperty(value="课程收入")
+    private BigDecimal courseAmount;
+
+    @ApiModelProperty(value="云教练收入")
+    private BigDecimal cloudAmount;
+
+    @ApiModelProperty(value="其他收入")
+    private BigDecimal otherAmount;
+
     //当月退费列表总金额(当月退费列表已退费总金额)
     @ApiModelProperty(value="业务退费")
     private BigDecimal businessRefund;
@@ -69,6 +83,46 @@ public class OperatingReportNew {
     @ApiModelProperty(value="月份")
     private String month;
 
+    public Integer getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(Integer organId) {
+        this.organId = organId;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public BigDecimal getCourseAmount() {
+        return courseAmount;
+    }
+
+    public void setCourseAmount(BigDecimal courseAmount) {
+        this.courseAmount = courseAmount;
+    }
+
+    public BigDecimal getCloudAmount() {
+        return cloudAmount;
+    }
+
+    public void setCloudAmount(BigDecimal cloudAmount) {
+        this.cloudAmount = cloudAmount;
+    }
+
+    public BigDecimal getOtherAmount() {
+        return otherAmount;
+    }
+
+    public void setOtherAmount(BigDecimal otherAmount) {
+        this.otherAmount = otherAmount;
+    }
+
     public String getMonth() {
         return month;
     }

+ 16 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/MusicMarginQueryInfo.java

@@ -0,0 +1,16 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+
+public class MusicMarginQueryInfo extends QueryInfo {
+
+    private Integer refundFlag;
+
+    public Integer getRefundFlag() {
+        return refundFlag;
+    }
+
+    public void setRefundFlag(Integer refundFlag) {
+        this.refundFlag = refundFlag;
+    }
+}

+ 15 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/CloudTeacherFreeCourseService.java

@@ -0,0 +1,15 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.dao.CloudTeacherFreeCourseDao;
+import com.ym.mec.biz.dal.entity.CloudTeacherFreeCourse;
+import com.ym.mec.common.service.BaseService;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface CloudTeacherFreeCourseService extends BaseService<Long, CloudTeacherFreeCourse> {
+
+    CloudTeacherFreeCourseDao getDao();
+
+    void batchInsert(List<Long> scheduleIdList,Long calenderId);
+}

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

@@ -53,14 +53,6 @@ public interface CloudTeacherOrderService extends BaseService<Long, CloudTeacher
     List<CloudTeacherOrder> getStudentCloudTeacherOrders(List<Integer> studentIds, String musicGroupId);
 
     /**
-     * 获取乐团报名的云教练订单
-     *
-     * @param studentId
-     * @return
-     */
-    List<CloudTeacherOrder> getStudentCloudTeacherOrder(Integer studentId, String musicGroupId);
-
-    /**
      * 根据订单编号查询订单详情
      *
      * @param orderId

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

@@ -0,0 +1,8 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.MusicMargin;
+import com.ym.mec.common.service.BaseService;
+
+public interface MusicMarginService extends BaseService<Integer, MusicMargin> {
+
+}

+ 5 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/OperatingReportCloudService.java

@@ -7,6 +7,7 @@ import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
 import com.ym.mec.biz.dal.entity.OperatingReportCloud;
 import com.ym.mec.common.service.BaseService;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 public interface OperatingReportCloudService extends BaseService<Integer, OperatingReportCloud> {
@@ -16,21 +17,21 @@ public interface OperatingReportCloudService extends BaseService<Integer, Operat
     /**
     * @description: 缴费后,更新缴费项目关联的课程、云教练预收
      * @param musicGroupPaymentCalender
-     * @param userId
     * @return void
     * @author zx
     * @date 2022/9/6 10:09
     */
-    void updateSet(MusicGroupPaymentCalender musicGroupPaymentCalender,Integer userId);
+    void updateSet(MusicGroupPaymentCalender musicGroupPaymentCalender, BigDecimal amount);
 
     /**
     * @description: 乐团排课、活动排课,计算课程预收
      * @param calenderId
      * @param scheduleIdList
-     * @param userId
     * @return void
     * @author zx
     * @date 2022/9/6 10:52
     */
-    void updateSet(Long calenderId,Integer userId, String scheduleIdList);
+    void updateSet(Long calenderId, List<Long> scheduleIdList);
+
+    void save(MusicGroupPaymentCalender musicGroupPaymentCalender);
 }

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

@@ -0,0 +1,14 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.dao.OperatingReportNewDao;
+import com.ym.mec.biz.dal.entity.OperatingReportNew;
+import com.ym.mec.common.service.BaseService;
+
+import java.util.Date;
+
+public interface OperatingReportNewService extends BaseService<Integer, OperatingReportNew> {
+
+    OperatingReportNewDao getDao();
+
+    void operatingReportMonth(Date month);
+}

+ 5 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ActivityUserMapperServiceImpl.java

@@ -101,6 +101,8 @@ public class ActivityUserMapperServiceImpl extends BaseServiceImpl<Integer, Acti
 	private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
 	@Autowired
 	private MusicGroupPaymentCalenderActivityDao musicGroupPaymentCalenderActivityDao;
+	@Autowired
+	private CloudTeacherFreeCourseService cloudTeacherFreeCourseService;
 
 	@Override
 	public BaseDAO<Integer, ActivityUserMapper> getDAO() {
@@ -681,9 +683,9 @@ public class ActivityUserMapperServiceImpl extends BaseServiceImpl<Integer, Acti
 				Map<Long,List<CourseScheduleStudentPayment>> map = payments.stream().collect(Collectors.groupingBy(CourseScheduleStudentPayment::getCalenderId));
 				for (Long calenderId : map.keySet()) {
 					List<CourseScheduleStudentPayment> studentPayments = map.get(calenderId);
-					Map<Integer,String> userMap = studentPayments.stream().collect(Collectors.groupingBy(CourseScheduleStudentPayment::getUserId,
-							Collectors.collectingAndThen(Collectors.toList(),value->value.stream().map(e->e.getCourseScheduleId().toString()).collect(Collectors.joining(",")))));
-					userMap.keySet().stream().forEach(e-> operatingReportCloudService.updateSet(calenderId,e,userMap.get(e)));
+					Map<Integer,List<Long>> userMap = studentPayments.stream().collect(Collectors.groupingBy(CourseScheduleStudentPayment::getUserId,
+							Collectors.collectingAndThen(Collectors.toList(),value->value.stream().map(e->e.getCourseScheduleId()).collect(Collectors.toList()))));
+					userMap.keySet().stream().forEach(e-> operatingReportCloudService.updateSet(calenderId,userMap.get(e)));
 				}
 				//标记赠送课
 				String courseIdList = payments.stream().map(e -> e.getCourseScheduleId().toString()).collect(Collectors.joining(","));

+ 36 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CloudTeacherFreeCourseServiceImpl.java

@@ -0,0 +1,36 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dao.CloudTeacherFreeCourseDao;
+import com.ym.mec.biz.dal.entity.CloudTeacherFreeCourse;
+import com.ym.mec.biz.service.CloudTeacherFreeCourseService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+@Service
+public class CloudTeacherFreeCourseServiceImpl extends BaseServiceImpl<Long, CloudTeacherFreeCourse>  implements CloudTeacherFreeCourseService {
+	
+	@Autowired
+	private CloudTeacherFreeCourseDao cloudTeacherFreeCourseDao;
+
+	@Override
+	public BaseDAO<Long, CloudTeacherFreeCourse> getDAO() {
+		return cloudTeacherFreeCourseDao;
+	}
+
+	@Override
+	public CloudTeacherFreeCourseDao getDao() {
+		return cloudTeacherFreeCourseDao;
+	}
+
+    @Override
+	@Transactional(rollbackFor = Exception.class)
+    public void batchInsert(List<Long> scheduleIdList,Long calenderId) {
+		cloudTeacherFreeCourseDao.batchInsert(StringUtils.join(scheduleIdList,","),calenderId);
+    }
+}

+ 9 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CloudTeacherOrderServiceImpl.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ym.mec.biz.dal.dao.CloudTeacherOrderDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
 import com.ym.mec.biz.dal.dto.CloudTeacherOrderDto;
 import com.ym.mec.biz.dal.dto.Mapper;
 import com.ym.mec.biz.dal.entity.*;
@@ -52,6 +53,8 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
     private IdGeneratorService idGenerator;
     @Autowired
     private TenantOrderRecordService tenantOrderRecordService;
+    @Autowired
+    private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
 
     @Override
     public BaseDAO<Long, CloudTeacherOrder> getDAO() {
@@ -283,6 +286,12 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
         cloudTeacherOrder.setAmount(cloudTeacherFee);
         cloudTeacherOrder.setStudentId(order.getUserId());
         cloudTeacherOrder.setStatus(1);
+        MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(order.getCalenderId());
+        if(calender.getCloudTeacherPaymentFlag()){
+            cloudTeacherOrder.setOperatingAmount(BigDecimal.ZERO);
+        }else {
+            cloudTeacherOrder.setOperatingAmount(cloudTeacherFee);
+        }
         //保存云教练订单
         this.save(cloudTeacherOrder,calenderMember.getAutoActivationFlag());
     }
@@ -324,11 +333,6 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
     }
 
     @Override
-    public List<CloudTeacherOrder> getStudentCloudTeacherOrder(Integer studentId, String musicGroupId) {
-        return cloudTeacherOrderDao.getStudentCloudTeacherOrder(studentId, musicGroupId);
-    }
-
-    @Override
     public CloudTeacherOrderDto queryOrderInfoByOrderId(Long orderId) {
         return cloudTeacherOrderDao.queryOrderInfoByOrderId(orderId);
     }

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

@@ -77,6 +77,8 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 	private MusicGroupStudentClassAdjustDao musicGroupStudentClassAdjustDao;
 	@Autowired
 	private StudentPaymentOrderDao studentPaymentOrderDaop;
+	@Autowired
+	private CloudTeacherFreeCourseDao cloudTeacherFreeCourseDao;
 
 	@Override
 	public BaseDAO<Long, CourseScheduleStudentPayment> getDAO() {
@@ -520,8 +522,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 								//如果是免费的云教练课程
 								if(detail.getCloudTeacherPaymentFlag()){
 									cloudTeacherPaymentFlag = true;
-									String courseIds = scheduleList.stream().map(e -> e.getId().toString()).collect(Collectors.joining(","));
-									operatingReportCloudService.updateSet(detail.getMusicGroupPaymentCalenderId(),detail.getUserId(),courseIds);
+									operatingReportCloudService.updateSet(detail.getMusicGroupPaymentCalenderId(),scheduleList.stream().map(e->e.getId()).collect(Collectors.toList()));
 								}
 							}
 							musicGroupPaymentStudentCourseDetailDao.batchUpdate(musicGroupPaymentStudentCourseDetails);

+ 6 - 34
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MemberRankSettingServiceImpl.java

@@ -269,6 +269,7 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
         cloudTeacherOrder.setStudentId(sysUser.getId());
         cloudTeacherOrder.setOrganId(studentPaymentOrder.getOrganId());
         cloudTeacherOrder.setAmount(studentPaymentOrder.getExpectAmount());
+        cloudTeacherOrder.setOperatingAmount(studentPaymentOrder.getExpectAmount());
         cloudTeacherOrderService.insert(cloudTeacherOrder);
         return BaseController.succeed(result);
     }
@@ -695,6 +696,7 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
             cloudTeacherOrder.setStudentId(studentPaymentOrder.getUserId());
             cloudTeacherOrder.setOrganId(studentPaymentOrder.getOrganId());
             cloudTeacherOrder.setAmount(studentPaymentOrder.getExpectAmount());
+            cloudTeacherOrder.setOperatingAmount(studentPaymentOrder.getExpectAmount());
             cloudTeacherOrderService.save(cloudTeacherOrder,tenantConfigService.autoActivationFlag(cloudTeacherOrder.getTenantId()));
             //赠送陪练课
             ActivityUserMapper activityUserMapper = new ActivityUserMapper();
@@ -785,7 +787,6 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
         if (studentPaymentOrder.getStatus() == DealStatusEnum.SUCCESS) {
             //是否通过活动购买的团练宝
             if(Objects.nonNull(studentPaymentOrder.getActivityId())){
-//                Student student = studentService.get(userId);
                 VipGroupActivity activity = vipGroupActivityDao.get(Integer.parseInt(studentPaymentOrder.getActivityId()));
                 //保存团练宝数据
                 CloudTeacherOrder cloudTeacherOrder = new CloudTeacherOrder();
@@ -797,40 +798,9 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
                 cloudTeacherOrder.setStudentId(studentPaymentOrder.getUserId());
                 cloudTeacherOrder.setOrganId(studentPaymentOrder.getOrganId());
                 cloudTeacherOrder.setAmount(studentPaymentOrder.getExpectAmount());
+                cloudTeacherOrder.setOperatingAmount(studentPaymentOrder.getExpectAmount());
                 cloudTeacherOrderService.save(cloudTeacherOrder,tenantConfigService.autoActivationFlag(cloudTeacherOrder.getTenantId()));
-                //赠送陪练课
-//                ActivityUserMapper activityUserMapper = new ActivityUserMapper();
-//                activityUserMapper.setTeacherId(student.getTeacherId());
-//                activityUserMapper.setPaymentOrderId(studentPaymentOrder.getId());
-//                activityUserMapper.setUserId(studentPaymentOrder.getUserId());
-//                activityUserMapper.setActivityId(activity.getId());
-//                activityUserMapper.setActualPrice(BigDecimal.ZERO);
-//                activityUserMapper.setGivePracticeFlag(1);
-//                activityUserMapper.setReturnFee(false);
-//                activityUserMapperDao.insert(activityUserMapper);
-                //赠送训练营
-//                TempLittleArtistTrainingCampUserRelation tempLittleArtistTrainingCamp = new TempLittleArtistTrainingCampUserRelation();
-//                tempLittleArtistTrainingCamp.setUserId(studentPaymentOrder.getUserId());
-//                tempLittleArtistTrainingCamp.setState("NOT_APPLY");
-//                tempLittleArtistTrainingCamp.setCreateTime(nowDate);
-//                tempLittleArtistTrainingCampUserRelationDao.insert(tempLittleArtistTrainingCamp);
-                //生成订单详情
-//                StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
-//                studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
-//                studentPaymentOrderDetail.setType(OrderDetailTypeEnum.CLOUD_TEACHER);
-//                studentPaymentOrderDetail.setGoodsIdList("1");
-//                studentPaymentOrderDetail.setPrice(studentPaymentOrder.getExpectAmount());
-//                studentPaymentOrderDetail.setTenantId(studentPaymentOrder.getTenantId());
-//                studentPaymentOrderDetail.setCreateTime(nowDate);
-//                studentPaymentOrderDetail.setUpdateTime(nowDate);
-//                studentPaymentOrderDetailDao.insert(studentPaymentOrderDetail);
-                //赠送优惠券
-//                Integer giveCouponId = activity.getGiveCouponId();
-//                Integer giveCouponNum = activity.getGiveCouponNum();
-//                if(Objects.nonNull(giveCouponId) && Objects.nonNull(giveCouponNum)){
-//                    sysCouponCodeService.exchangeCoupon(userId,giveCouponId,
-//                            studentPaymentOrder.getId(),giveCouponNum,2,null);
-//                }
+
                 Map<Integer, String> phoneMaps = MapUtil.convertMybatisMap(teacherDao.queryPhoneByIds(userId.toString()));
                 String baseApiUrl = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
                 StringBuffer pushUrl = new StringBuffer(baseApiUrl).append("/#/artistRegistration");
@@ -877,6 +847,7 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
                         cloudTeacherOrder.setStudentId(coachPaymentDetails.getUserId());
                         cloudTeacherOrder.setOrganId(studentPaymentOrder.getOrganId());
                         cloudTeacherOrder.setAmount(studentPaymentOrder.getExpectAmount());
+                        cloudTeacherOrder.setOperatingAmount(studentPaymentOrder.getExpectAmount());
                         cloudTeacherOrderService.save(cloudTeacherOrder,cloudCoachPaymentProgram.getAutoActivationFlag());
 
                         //修改缴费状态
@@ -926,6 +897,7 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
         cto.setLevel(1);
         cto.setTime(totalMonth.intValue());
         cto.setAmount(studentPaymentOrder.getActualAmount().add(studentPaymentOrder.getBalancePaymentAmount()));
+        cto.setOperatingAmount(cto.getAmount());
         cto.setStartTime(now.toDate());
         cto.setEndTime(DateUtil.addDays(now.plusMonths(totalMonth.intValue()).toDate(),1));
         cto.setOrderId(studentPaymentOrder.getId());

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

@@ -351,20 +351,6 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
                 musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetailList);
             }
         }
-
-        //记录云教练缴费预收
-        if(musicGroupPaymentCalender.getCloudTeacherPaymentFlag() && musicGroupPaymentCalender.getCurrentTotalAmount().compareTo(BigDecimal.ZERO) == 0){
-            List<OperatingReportCloud> operatingReportClouds = new ArrayList<>();
-            for (Integer studentId : userIdList) {
-                OperatingReportCloud operatingReportCloud = new OperatingReportCloud();
-                operatingReportCloud.setCalenderId(musicGroupPaymentCalenderId);
-                operatingReportCloud.setOrganId(musicGroupPaymentCalender.getOrganId());
-                operatingReportCloud.setUserId(operatingReportCloud.getUserId());
-                operatingReportClouds.add(operatingReportCloud);
-            }
-            operatingReportCloudService.getDao().batchInsert(operatingReportClouds);
-        }
-
         //给学员推送缴费通知
         if (musicGroupPaymentCalender.getPayUserType() == STUDENT && musicGroupPaymentCalender.getStatus() == PaymentCalenderStatusEnum.OPEN) {
             musicGroupPaymentCalenderService.pushWaitRenewMessage(musicGroupPaymentCalender.getId(),
@@ -571,7 +557,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
         }
 
         //保存、更新云教练缴费项目预收
-        operatingReportCloudService.updateSet(musicGroupPaymentCalender,studentPaymentOrder.getUserId());
+        operatingReportCloudService.updateSet(musicGroupPaymentCalender,studentPaymentOrder.getActualAmount());
 
         Boolean cloudTeacherPaymentFlag = false;
         if(musicGroupPaymentCalender.getCloudTeacherPaymentFlag()){

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

@@ -119,6 +119,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
     private StudentRegistrationService studentRegistrationService;
     @Autowired
     private VipGroupActivityDao vipGroupActivityDao;
+    @Autowired
+    private OperatingReportCloudService operatingReportCloudService;
 
     @Override
     public BaseDAO<Long, MusicGroupPaymentCalender> getDAO() {
@@ -354,6 +356,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         String batchNo = idGeneratorService.generatorId() + "";
         musicGroupPaymentCalender.setBatchNo(batchNo);
         musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
+
+        operatingReportCloudService.save(musicGroupPaymentCalender);
         Long calenderId = musicGroupPaymentCalender.getId();
         //保存会员缴费信息
         MusicGroupPaymentCalenderMember calenderMember = musicGroupPaymentBaseCalender.getCalenderMember();

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicMarginServiceImpl.java

@@ -0,0 +1,22 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.common.dal.BaseDAO;
+import org.springframework.beans.factory.annotation.Autowired;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.biz.dal.entity.MusicMargin;
+import com.ym.mec.biz.service.MusicMarginService;
+import com.ym.mec.biz.dal.dao.MusicMarginDao;
+import org.springframework.stereotype.Service;
+
+@Service
+public class MusicMarginServiceImpl extends BaseServiceImpl<Integer, MusicMargin>  implements MusicMarginService {
+	
+	@Autowired
+	private MusicMarginDao musicMarginDao;
+
+	@Override
+	public BaseDAO<Integer, MusicMargin> getDAO() {
+		return musicMarginDao;
+	}
+	
+}

+ 43 - 28
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OperatingReportCloudServiceImpl.java

@@ -4,6 +4,7 @@ import com.ym.mec.biz.dal.dao.OperatingReportCloudDao;
 import com.ym.mec.biz.dal.dao.OrganCourseTypeOriginalCostDao;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.OperatingReportCloud;
+import com.ym.mec.biz.service.CloudTeacherFreeCourseService;
 import com.ym.mec.biz.service.OperatingReportCloudService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
@@ -15,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 import java.util.Objects;
 
 @Service
@@ -24,6 +26,8 @@ public class OperatingReportCloudServiceImpl extends BaseServiceImpl<Integer, Op
 	private OperatingReportCloudDao operatingReportCloudDao;
 	@Autowired
 	private OrganCourseTypeOriginalCostDao organCourseTypeOriginalCostDao;
+	@Autowired
+	private CloudTeacherFreeCourseService cloudTeacherFreeCourseService;
 
 	@Override
 	public BaseDAO<Integer, OperatingReportCloud> getDAO() {
@@ -37,29 +41,30 @@ public class OperatingReportCloudServiceImpl extends BaseServiceImpl<Integer, Op
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public void updateSet(MusicGroupPaymentCalender calender, Integer userId) {
-		if(calender.getCloudTeacherPaymentFlag()){
-			//获取云教练信息
-			OperatingReportCloud reportCloud = operatingReportCloudDao.findByCalenderId(calender.getId(),userId);
-			if(Objects.isNull(reportCloud)){
-				reportCloud = new OperatingReportCloud();
+	public void updateSet(MusicGroupPaymentCalender calender, BigDecimal amount) {
+		if(!calender.getCloudTeacherPaymentFlag()){
+			return;
+		}
+		//找出非当月结算的缴费项目预算,如果为空则创建。如果已结算则创建当月结转的云教练预收、否则修改云教练预算
+		//获取云教练信息
+		OperatingReportCloud reportCloud = operatingReportCloudDao.findByCalenderId(calender.getId(),false);
+		if(Objects.isNull(reportCloud)){
+			reportCloud = new OperatingReportCloud();
+			reportCloud.setCalenderId(calender.getId());
+			reportCloud.setCloudPrice(amount);
+			reportCloud.setOrganId(calender.getOrganId());
+			operatingReportCloudDao.insert(reportCloud);
+		}else {
+			if(reportCloud.getSettlementFlag()){
+				OperatingReportCloud monthReportCloud = new OperatingReportCloud();
 				reportCloud.setCalenderId(calender.getId());
-				reportCloud.setCloudPrice(calender.getCurrentTotalAmount());
-				reportCloud.setUserId(userId);
+				reportCloud.setCloudPrice(amount);
 				reportCloud.setOrganId(calender.getOrganId());
-				operatingReportCloudDao.insert(reportCloud);
+				reportCloud.setMonthFlag(true);
+				operatingReportCloudDao.insert(monthReportCloud);
 			}else {
-				//如果缴费项目还没有排课,所以把应收转化为云教练预收
+				reportCloud.setCloudPrice(reportCloud.getCloudPrice().add(amount));
 				reportCloud.setUpdateTime(new Date());
-				if(StringUtils.isEmpty(reportCloud.getCourseIds())){
-					reportCloud.setCloudPrice(calender.getCurrentTotalAmount());
-				}else {
-					//如果已排课,需要更新课程、云教练预收
-					//计算课程预收
-					BigDecimal costPrice = organCourseTypeOriginalCostDao.getCourseCostPrice(reportCloud.getCourseIds());
-					reportCloud.setCloudPrice(reportCloud.getCloudPrice().subtract(costPrice));
-					reportCloud.setCoursePrice(reportCloud.getCoursePrice().add(reportCloud.getCoursePrice()));
-				}
 				operatingReportCloudDao.update(reportCloud);
 			}
 		}
@@ -67,22 +72,32 @@ public class OperatingReportCloudServiceImpl extends BaseServiceImpl<Integer, Op
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public void updateSet(Long calenderId,Integer userId,String scheduleIdList) {
-		OperatingReportCloud reportCloud = operatingReportCloudDao.findByCalenderId(calenderId,userId);
+	public void updateSet(Long calenderId,List<Long> scheduleIdList) {
+		OperatingReportCloud reportCloud = operatingReportCloudDao.findByCalenderId(calenderId,false);
 		if(Objects.isNull(reportCloud)){
 			throw new BizException("操作失败,请联系管理员");
 		}
-		String courseIds = StringUtils.join(scheduleIdList,",");
-		if(StringUtils.isEmpty(reportCloud.getCourseIds())){
-			reportCloud.setCourseIds(courseIds);
-		}else {
-			reportCloud.setCourseIds(reportCloud.getCourseIds() + "," + StringUtils.join(scheduleIdList,","));
+		if(reportCloud.getSettlementFlag()){
+			return;
 		}
-		reportCloud.setUpdateTime(new Date());
+		cloudTeacherFreeCourseService.batchInsert(scheduleIdList,calenderId);
 		//计算课程预收
-		BigDecimal costPrice = organCourseTypeOriginalCostDao.getCourseCostPrice(courseIds);
+		BigDecimal costPrice = organCourseTypeOriginalCostDao.getCourseCostPrice(StringUtils.join(scheduleIdList,","));
 		reportCloud.setCloudPrice(reportCloud.getCloudPrice().subtract(costPrice));
 		reportCloud.setCoursePrice(reportCloud.getCoursePrice().add(reportCloud.getCoursePrice()));
+		reportCloud.setUpdateTime(new Date());
 		operatingReportCloudDao.update(reportCloud);
 	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void save(MusicGroupPaymentCalender musicGroupPaymentCalender) {
+		if(musicGroupPaymentCalender.getCloudTeacherPaymentFlag()){
+			OperatingReportCloud reportCloud = new OperatingReportCloud();
+			reportCloud.setCalenderId(musicGroupPaymentCalender.getId());
+			reportCloud.setCloudPrice(BigDecimal.ZERO);
+			reportCloud.setOrganId(musicGroupPaymentCalender.getOrganId());
+			operatingReportCloudDao.insert(reportCloud);
+		}
+	}
 }

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

@@ -0,0 +1,97 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dao.OperatingReportNewDao;
+import com.ym.mec.biz.dal.entity.OperatingReport;
+import com.ym.mec.biz.dal.entity.OperatingReportNew;
+import com.ym.mec.biz.service.OperatingReportNewService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.util.collection.MapUtil;
+import com.ym.mec.util.date.DateUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Service
+public class OperatingReportNewServiceImpl extends BaseServiceImpl<Integer, OperatingReportNew>  implements OperatingReportNewService {
+	
+	@Autowired
+	private OperatingReportNewDao operatingReportNewDao;
+
+	@Override
+	public BaseDAO<Integer, OperatingReportNew> getDAO() {
+		return operatingReportNewDao;
+	}
+
+    @Override
+    public OperatingReportNewDao getDao() {
+        return operatingReportNewDao;
+    }
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void operatingReportMonth(Date month) {
+		String firstDayOfMonth = DateUtil.dateToString(DateUtil.getFirstDayOfMonth(month),DateUtil.ISO_EXPANDED_DATE_FORMAT);
+		String lastDayOfMonth = DateUtil.dateToString(DateUtil.getLastDayOfMonth(month),DateUtil.ISO_EXPANDED_DATE_FORMAT);
+		String currentMonth = DateUtil.dateToString(DateUtil.getLastDayOfMonth(month),DateUtil.ISO_YEAR_MONTH_FORMAT);
+		List<OperatingReportNew> operatingList = operatingReportNewDao.initOperatingReport(currentMonth);
+		//更新团体云教练计费时间()
+		operatingReportNewDao.initCloudStartTime(lastDayOfMonth);
+		//销售收入、销售成本
+		List<OperatingReportNew> sellList = operatingReportNewDao.sumSellAmount(currentMonth);
+		Map<Integer, OperatingReportNew> collect = sellList.stream().collect(Collectors.groupingBy(OperatingReportNew::getOrganId,Collectors.collectingAndThen(Collectors.toList(),value->value.get(0))));
+		//服务收入
+		//云教练赠送课程实际收入
+		Map<Integer, BigDecimal> collect1 = MapUtil.mapListToMap(operatingReportNewDao.sumCloudCourseAmount(firstDayOfMonth,lastDayOfMonth),Integer.class,BigDecimal.class);
+		//付费课程实际收入
+		Map<Integer, BigDecimal> collect2 = MapUtil.mapListToMap(operatingReportNewDao.sumCourseAmount(firstDayOfMonth,lastDayOfMonth),Integer.class,BigDecimal.class);
+		//个人云教练当月收入
+		Map<Integer, BigDecimal> collect3 = MapUtil.mapListToMap(operatingReportNewDao.sumPersonalCloudAmount(currentMonth,firstDayOfMonth,lastDayOfMonth),Integer.class,BigDecimal.class);
+		//团体云教练费用
+		Map<Integer, BigDecimal> collect4 = MapUtil.mapListToMap(operatingReportNewDao.sumGroupCloudAmount(currentMonth,firstDayOfMonth,lastDayOfMonth),Integer.class,BigDecimal.class);
+		//团体云教练当月一次性结转
+		Map<Integer, BigDecimal> collect5 = MapUtil.mapListToMap(operatingReportNewDao.sumGroupAmount(),Integer.class,BigDecimal.class);
+
+		//业务退费
+		Map<Integer, BigDecimal> collect6 = MapUtil.mapListToMap(operatingReportNewDao.sumRefundAmount(currentMonth),Integer.class,BigDecimal.class);
+		//变动费用
+		Map<Integer, BigDecimal> collect7 = MapUtil.mapListToMap(operatingReportNewDao.sumVariableCosts(currentMonth),Integer.class,BigDecimal.class);
+		//固定费用
+		Map<Integer, BigDecimal> collect8 = MapUtil.mapListToMap(operatingReportNewDao.sumFixedCosts(currentMonth),Integer.class,BigDecimal.class);
+		//内部结算
+
+		//云教练预收款
+		//个人云教练预收款
+		Map<Integer, BigDecimal> collect9 = MapUtil.mapListToMap(operatingReportNewDao.sumCloudPreAmount(currentMonth,lastDayOfMonth),Integer.class,BigDecimal.class);
+		//团体云教练预收款
+		Map<Integer, BigDecimal> collect10 = MapUtil.mapListToMap(operatingReportNewDao.sumGroupCloudPreAmount(currentMonth,lastDayOfMonth),Integer.class,BigDecimal.class);
+
+		//课程预收
+		//云教练赠课预收
+		Map<Integer, BigDecimal> collect11 = MapUtil.mapListToMap(operatingReportNewDao.sumCloudCoursePreAmount(lastDayOfMonth),Integer.class,BigDecimal.class);
+		//付费课程预收
+		Map<Integer, BigDecimal> collect12 = MapUtil.mapListToMap(operatingReportNewDao.sumCoursePreAmount(lastDayOfMonth),Integer.class,BigDecimal.class);
+		//销售预收
+		Map<Integer, BigDecimal> collect13 = MapUtil.mapListToMap(operatingReportNewDao.sumSalePreAmount(),Integer.class,BigDecimal.class);
+		//其他预收
+		Map<Integer, BigDecimal> collect14 = MapUtil.mapListToMap(operatingReportNewDao.sumOtherPreAmount(),Integer.class,BigDecimal.class);
+
+		//预付款
+
+		//应收
+		//欠费学员总金额
+		Map<Integer, BigDecimal> collect15 = MapUtil.mapListToMap(operatingReportNewDao.sumArrearsAmount(),Integer.class,BigDecimal.class);
+		//学校缴费订单待收款金额
+		Map<Integer, BigDecimal> collect16 = MapUtil.mapListToMap(operatingReportNewDao.sumSchoolAmount(),Integer.class,BigDecimal.class);
+
+		//应付(乐器押金)
+
+
+	}
+}

+ 22 - 32
mec-biz/src/main/resources/config/mybatis/CloudTeacherFreeCourseMapper.xml

@@ -9,9 +9,8 @@
 	<resultMap type="com.ym.mec.biz.dal.entity.CloudTeacherFreeCourse" id="CloudTeacherFreeCourse">
 		<result column="id_" property="id" />
 		<result column="course_id_" property="courseId" />
-		<result column="calender_detail_id_" property="calenderDetailId" />
+		<result column="calender_id_" property="calenderId" />
 		<result column="cost_" property="cost" />
-		<result column="operating_flag_" property="operatingFlag" />
 		<result column="create_time_" property="createTime" />
 		<result column="update_time_" property="updateTime" />
 	</resultMap>
@@ -28,39 +27,30 @@
 	
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.CloudTeacherFreeCourse" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-		<!--
-		<selectKey resultClass="int" keyProperty="id" > 
-		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
-		</selectKey>
-		-->
-		INSERT INTO cloud_teacher_free_course (id_,course_id_,calender_detail_id_,cost_,operating_flag_,create_time_,update_time_) VALUES(#{id},#{courseId},#{calenderDetailId},#{cost},#{operatingFlag},#{createTime},#{updateTime})
+		INSERT INTO cloud_teacher_free_course (id_,course_id_,cost_,calender_id_,create_time_,update_time_)
+		VALUES(#{id},#{courseId},#{cost},#{calenderId},NOW(),NOW())
 	</insert>
-	
-	<!-- 根据主键查询一条记录 -->
+    <insert id="batchInsert">
+		insert into cloud_teacher_free_course (course_id_, cost_,calender_id_, create_time_, update_time_)
+		SELECT cs.id_,oct.price_,#{calenderId},NOW(),NOW() FROM course_schedule cs
+		LEFT JOIN organ_course_type_original_cost oct ON oct.course_type_ = cs.type_ AND (oct.organ_id_ = cs.organ_id_  OR oct.organ_id_ = 0)
+		where FIND_IN_SET(cs.id_,#{scheduleIdList})
+		GROUP BY cs.id_
+	</insert>
+
+    <!-- 根据主键查询一条记录 -->
 	<update id="update" parameterType="com.ym.mec.biz.dal.entity.CloudTeacherFreeCourse">
 		UPDATE cloud_teacher_free_course <set>
-<if test="id != null">
-id_ = #{id},
-</if>
-<if test="cost != null">
-cost_ = #{cost},
-</if>
-<if test="updateTime != null">
-update_time_ = #{updateTime},
-</if>
-<if test="courseId != null">
-course_id_ = #{courseId},
-</if>
-<if test="calenderDetailId != null">
-calender_detail_id_ = #{calenderDetailId},
-</if>
-<if test="operatingFlag != null">
-operating_flag_ = #{operatingFlag},
-</if>
-<if test="createTime != null">
-create_time_ = #{createTime},
-</if>
-</set> WHERE id_ = #{id} 
+		<if test="cost != null">
+		cost_ = #{cost},
+		</if>
+		<if test="updateTime != null">
+		update_time_ = #{updateTime},
+		</if>
+		<if test="courseId != null">
+		course_id_ = #{courseId},
+		</if>
+		</set> WHERE id_ = #{id}
 	</update>
 	
 	<!-- 根据主键删除一条记录 -->

+ 7 - 12
mec-biz/src/main/resources/config/mybatis/CloudTeacherOrderMapper.xml

@@ -11,6 +11,7 @@
         <result column="level_" property="level"/>
         <result column="time_" property="time"/>
         <result column="amount_" property="amount"/>
+        <result column="operating_amount_" property="operatingAmount"/>
         <result column="refund_amount_" property="refundAmount"/>
         <result column="status_" property="status"/>
         <result column="start_time_" property="startTime"/>
@@ -34,6 +35,7 @@
         <result column="level_" property="cloudTeacherOrder.level"/>
         <result column="time_" property="cloudTeacherOrder.time"/>
         <result column="amount_" property="cloudTeacherOrder.amount"/>
+        <result column="operating_amount_" property="cloudTeacherOrder.operatingAmount"/>
         <result column="refund_amount_" property="cloudTeacherOrder.refundAmount"/>
         <result column="status_" property="cloudTeacherOrder.status"/>
         <result column="start_time_" property="cloudTeacherOrder.startTime"/>
@@ -58,9 +60,9 @@
     </delete>
     <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.CloudTeacherOrder"
             useGeneratedKeys="true">
-        INSERT INTO cloud_teacher_order (organ_id_,student_id_, type_, level_, time_, amount_, refund_amount_, status_,
+        INSERT INTO cloud_teacher_order (organ_id_,student_id_, type_, level_, time_, amount_, operating_amount_, refund_amount_, status_,
         order_id_,platform_order_id_,start_time_,end_time_,remark_, create_time_, update_time_,music_group_id_,active_remark_,tenant_id_)
-        VALUES (#{organId},#{studentId}, #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{level}, #{time}, #{amount}, #{refundAmount},
+        VALUES (#{organId},#{studentId}, #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{level}, #{time}, #{amount}, #{operatingAmount}, #{refundAmount},
         #{status},#{orderId},#{platformOrderId},#{startTime},#{endTime}, #{remark}, NOW(), NOW(),#{musicGroupId},#{activeRemark},#{tenantId})
     </insert>
     <update id="update" parameterType="com.ym.mec.biz.dal.entity.CloudTeacherOrder">
@@ -91,6 +93,9 @@
             <if test="amount != null">
                 amount_ = #{amount},
             </if>
+            <if test="operatingAmount != null">
+                operating_amount_ = #{operatingAmount},
+            </if>
             <if test="refundAmount != null">
                 refund_amount_ = #{refundAmount},
             </if>
@@ -220,16 +225,6 @@
         AND status_ IN (1,2)
     </select>
 
-    <select id="getStudentCloudTeacherOrder" resultMap="CloudTeacherOrder">
-        SELECT *
-        FROM cloud_teacher_order
-        WHERE student_id_ = #{studentId}
-        <if test="musicGroupId != null and musicGroupId != ''">
-          AND music_group_id_ = #{musicGroupId}
-        </if>
-          AND status_ IN (1, 2)
-    </select>
-
     <select id="queryByOrderId" resultMap="CloudTeacherOrder">
         SELECT cto.* FROM cloud_teacher_order cto
         WHERE order_id_ = #{orderId}

+ 123 - 0
mec-biz/src/main/resources/config/mybatis/MusicMarginMapper.xml

@@ -0,0 +1,123 @@
+<?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.MusicMarginDao">
+	
+	<resultMap type="com.ym.mec.biz.dal.entity.MusicMargin" id="MusicMargin">
+		<result column="id_" property="id" />
+		<result column="type_" property="type" />
+		<result column="date_" property="date" />
+		<result column="organ_" property="organ" />
+		<result column="school_" property="school" />
+		<result column="user_id_" property="userId" />
+		<result column="username_" property="username" />
+		<result column="init_" property="init" />
+		<result column="payment_" property="payment" />
+		<result column="refund_" property="refund" />
+		<result column="refund_flag_" property="refundFlag" />
+		<result column="balance_" property="balance" />
+		<result column="margin_type_" property="marginType" />
+		<result column="match_" property="match" />
+		<result column="memo_" property="memo" />
+		<result column="process_no_" property="processNo" />
+	</resultMap>
+	
+	<!-- 根据主键查询一条记录 -->
+	<select id="get" resultMap="MusicMargin" >
+		SELECT * FROM music_margin WHERE id_ = #{id} 
+	</select>
+	
+	<!-- 全查询 -->
+	<select id="findAll" resultMap="MusicMargin">
+		SELECT * FROM music_margin ORDER BY id_
+	</select>
+	
+	<!-- 向数据库增加一条记录 -->
+	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicMargin" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+		INSERT INTO music_margin (id_,type_,date_,organ_,school_,user_id_,username_,init_,payment_,refund_,refund_flag_,balance_,margin_type_,match_,memo_,process_no_) VALUES(#{id},#{type},#{date},#{organ},#{school},#{userId},#{username},#{init},#{payment},#{refund},#{refundFlag},#{balance},#{marginType},#{match},#{memo},#{processNo})
+	</insert>
+	
+	<!-- 根据主键查询一条记录 -->
+	<update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicMargin">
+		UPDATE music_margin <set>
+<if test="school != null">
+school_ = #{school},
+</if>
+<if test="id != null">
+id_ = #{id},
+</if>
+<if test="balance != null">
+balance_ = #{balance},
+</if>
+<if test="memo != null">
+memo_ = #{memo},
+</if>
+<if test="organ != null">
+organ_ = #{organ},
+</if>
+<if test="username != null">
+username_ = #{username},
+</if>
+<if test="refundFlag != null">
+refund_flag_ = #{refundFlag},
+</if>
+<if test="userId != null">
+user_id_ = #{userId},
+</if>
+<if test="payment != null">
+payment_ = #{payment},
+</if>
+<if test="refund != null">
+refund_ = #{refund},
+</if>
+<if test="init != null">
+init_ = #{init},
+</if>
+<if test="match != null">
+match_ = #{match},
+</if>
+<if test="processNo != null">
+process_no_ = #{processNo},
+</if>
+<if test="marginType != null">
+margin_type_ = #{marginType},
+</if>
+<if test="type != null">
+type_ = #{type},
+</if>
+<if test="date != null">
+date_ = #{date},
+</if>
+</set> WHERE id_ = #{id} 
+	</update>
+	
+	<!-- 根据主键删除一条记录 -->
+	<delete id="delete" >
+		DELETE FROM music_margin WHERE id_ = #{id} 
+	</delete>
+	
+	<!-- 分页查询 -->
+	<select id="queryPage" resultMap="MusicMargin" parameterType="map">
+		SELECT * FROM music_margin
+		ORDER BY id_
+		<include refid="global.limit"/>
+	</select>
+	<sql id="queryPageSql">
+		<where>
+			<if test="refundFlag != null">
+				AND refund_flag_ = #{refundFlag}
+			</if>
+			<if test="search != null and search != ''">
+				AND (username_ LIKE CONCAT('%',#{search},'%') OR user_id_ = #{search})
+			</if>
+		</where>
+	</sql>
+	
+	<!-- 查询当前表的总记录数 -->
+	<select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM music_margin
+	</select>
+</mapper>

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

@@ -10,7 +10,7 @@
 		<result column="id_" property="id" />
 		<result column="organ_id_" property="organId" />
 		<result column="calender_id_" property="calenderId" />
-		<result column="user_id_" property="userId" />
+		<result column="month_flag_" property="monthFlag" />
 		<result column="start_date_" property="startDate" />
 		<result column="end_date_" property="endDate" />
 		<result column="cloud_price_" property="cloudPrice" />
@@ -32,13 +32,13 @@
 	
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.OperatingReportCloud" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-		INSERT INTO operating_report_cloud (organ_id_,calender_id_,user_id_,start_date_,end_date_,cloud_price_,course_price_,settlement_flag_,create_time_,update_time_)
-		VALUES(#{organId},#{calenderId},#{userId},#{startDate},#{endDate},#{cloudPrice},#{coursePrice},#{settlementFlag},#{createTime},#{updateTime})
+		INSERT INTO operating_report_cloud (organ_id_,calender_id_,start_date_,end_date_,cloud_price_,course_price_,settlement_flag_,month_flag_,create_time_,update_time_)
+		VALUES(#{organId},#{calenderId},#{startDate},#{endDate},#{cloudPrice},#{coursePrice},#{settlementFlag},#{monthFlag},NOW(),NOW())
 	</insert>
 	<insert id="batchInsert">
-		INSERT INTO operating_report_cloud (organ_id_,calender_id_,user_id_,create_time_,update_time_) VALUES
+		INSERT INTO operating_report_cloud (organ_id_,calender_id_,month_flag_,create_time_,update_time_) VALUES
 		<foreach collection="operatingReportClouds" separator="," item="item">
-			(#{item.organId},#{item.calenderId},#{item.userId},NOW(),NOW())
+			(#{item.organId},#{item.calenderId},#{item.monthFlag},NOW(),NOW())
 		</foreach>
 	</insert>
 
@@ -81,6 +81,6 @@
 		SELECT COUNT(*) FROM operating_report_cloud
 	</select>
 	<select id="findByCalenderId" resultMap="OperatingReportCloud">
-		SELECT * FROM operating_report_cloud WHERE calender_id_ = #{calenderId} AND user_id_ = #{userId} LIMIT 1
+		SELECT * FROM operating_report_cloud WHERE calender_id_ = #{calenderId} AND month_flag_ = #{monthFlag} LIMIT 1
 	</select>
 </mapper>

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

@@ -0,0 +1,237 @@
+<?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.OperatingReportNewDao">
+	
+	<resultMap type="com.ym.mec.biz.dal.entity.OperatingReportNew" id="OperatingReportNew">
+		<result column="id_" property="id" />
+		<result column="principal_" property="principal" />
+		<result column="organ_name_" property="organName" />
+		<result column="organ_id_" property="organId" />
+		<result column="sale_amount_" property="saleAmount" />
+		<result column="service_amount_" property="serviceAmount" />
+		<result column="business_refund_" property="businessRefund" />
+		<result column="total_income_" property="totalIncome" />
+		<result column="sale_cost_" property="saleCost" />
+		<result column="fixed_costs_" property="fixedCosts" />
+		<result column="variable_costs_" property="variableCosts" />
+		<result column="internal_settlement_" property="internalSettlement" />
+		<result column="total_cost_" property="totalCost" />
+		<result column="quasi_discretionary_profit_" property="quasiDiscretionaryProfit" />
+		<result column="prepaid_fee_" property="prepaidFee" />
+		<result column="prepayments_" property="prepayments" />
+		<result column="receivables_" property="receivables" />
+		<result column="payable_" property="payable" />
+		<result column="month_" property="month" />
+	</resultMap>
+	
+	<!-- 根据主键查询一条记录 -->
+	<select id="get" resultMap="OperatingReportNew" >
+		SELECT * FROM operating_report_new WHERE id_ = #{id} 
+	</select>
+	
+	<!-- 全查询 -->
+	<select id="findAll" resultMap="OperatingReportNew">
+		SELECT * FROM operating_report_new ORDER BY id_
+	</select>
+	
+	<!-- 向数据库增加一条记录 -->
+	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.OperatingReportNew" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+		INSERT INTO operating_report_new (id_,principal_,organ_name_,sale_amount_,service_amount_,business_refund_,total_income_,sale_cost_,fixed_costs_,variable_costs_,internal_settlement_,total_cost_,quasi_discretionary_profit_,prepaid_fee_,prepayments_,receivables_,payable_,month_)
+		VALUES(#{id},#{principal},#{organName},#{saleAmount},#{serviceAmount},#{businessRefund},#{totalIncome},#{saleCost},#{fixedCosts},#{variableCosts},#{internalSettlement},#{totalCost},#{quasiDiscretionaryProfit},#{prepaidFee},#{prepayments},#{receivables},#{payable},#{month})
+	</insert>
+	
+	<!-- 根据主键查询一条记录 -->
+	<update id="update" parameterType="com.ym.mec.biz.dal.entity.OperatingReportNew">
+		UPDATE operating_report_new <set>
+		<if test="saleAmount != null">
+		sale_amount_ = #{saleAmount},
+		</if>
+		<if test="prepaidFee != null">
+		prepaid_fee_ = #{prepaidFee},
+		</if>
+		<if test="serviceAmount != null">
+		service_amount_ = #{serviceAmount},
+		</if>
+		<if test="payable != null">
+		payable_ = #{payable},
+		</if>
+		<if test="businessRefund != null">
+		business_refund_ = #{businessRefund},
+		</if>
+		<if test="totalCost != null">
+		total_cost_ = #{totalCost},
+		</if>
+		<if test="totalIncome != null">
+		total_income_ = #{totalIncome},
+		</if>
+		<if test="quasiDiscretionaryProfit != null">
+		quasi_discretionary_profit_ = #{quasiDiscretionaryProfit},
+		</if>
+		<if test="fixedCosts != null">
+		fixed_costs_ = #{fixedCosts},
+		</if>
+		<if test="internalSettlement != null">
+		internal_settlement_ = #{internalSettlement},
+		</if>
+		<if test="prepayments != null">
+		prepayments_ = #{prepayments},
+		</if>
+		<if test="month != null">
+		month_ = #{month},
+		</if>
+		<if test="variableCosts != null">
+		variable_costs_ = #{variableCosts},
+		</if>
+		<if test="organName != null">
+		organ_name_ = #{organName},
+		</if>
+		<if test="saleCost != null">
+		sale_cost_ = #{saleCost},
+		</if>
+		<if test="receivables != null">
+		receivables_ = #{receivables},
+		</if>
+		<if test="principal != null">
+		principal_ = #{principal},
+		</if>
+		</set> WHERE id_ = #{id}
+	</update>
+    <update id="initCloudStartTime">
+		update operating_report_cloud orc
+		left join (
+		select orc.calender_id_,MIN(cs.class_date_) start_date_ from operating_report_cloud orc
+		LEFT JOIN cloud_teacher_free_course ctf ON ctf.calender_id_ = orc.calender_id_
+		LEFT JOIN course_schedule cs ON cs.id_ = ctf.course_id_
+		where orc.month_flag_ = false AND orc.settlement_flag_ = false AND orc.start_date_ IS NULL
+		AND cs.class_date_ &lt;= #{lastDay}
+		group by orc.calender_id_) mc ON orc.calender_id_ = mc.calender_id_
+		LEFT JOIN (select calender_id_,DATE_ADD(
+		DATE_ADD(create_time_, interval CASE WHEN period_ = 'YEAR_HALF' THEN 6
+		WHEN period_ = 'YEAR' THEN 12
+		WHEN period_ = 'QUARTERLY' THEN 3 ELSE num_ END MONTH),interval 1 DAY) end_date_
+		from music_group_payment_calender_member order by id_ DESC) mgpcm
+		ON mc.calender_id_ = mgpcm.calender_id_
+		set orc.start_date_ = mc.start_date_,orc.end_date_ = mgpcm.end_date_
+		where orc.calender_id_ = mc.calender_id_
+	</update>
+
+    <!-- 根据主键删除一条记录 -->
+	<delete id="delete" >
+		DELETE FROM operating_report_new WHERE id_ = #{id} 
+	</delete>
+	
+	<!-- 分页查询 -->
+	<select id="queryPage" resultMap="OperatingReportNew" parameterType="map">
+		SELECT * FROM operating_report_new ORDER BY id_ <include refid="global.limit"/>
+	</select>
+	
+	<!-- 查询当前表的总记录数 -->
+	<select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM operating_report_new
+	</select>
+	<select id="initOperatingReport" resultMap="OperatingReportNew">
+		select id_ organ_id_,name_ organ_name_ from organization where del_flag_ = 0 and tenant_id_ = 1
+	</select>
+	<select id="sumSellAmount" resultMap="OperatingReportNew">
+		select so.organ_id_,SUM(so.actual_amount_) sale_amount_,SUM(so.sell_cost_) sale_cost_ from sell_order so
+		left join student_payment_order spo ON spo.order_no_ = so.order_no_
+		left join music_group mg ON mg.id_ = spo.music_group_id_ AND spo.group_type_ = 'MUSIC'
+		LEFT JOIN organization o ON o.id_ = so.organ_id_
+		where (mg.musical_instruments_provide_status_ = 1 AND mg.musical_instruments_provide_date_ = #{month}) OR (DATE_FORMAT(so.create_ime_,'%Y-%m') = #{month} AND (mg.musical_instruments_provide_status_ IS NULL OR mg.musical_instruments_provide_status_ = 1))
+		group by so.organ_id_
+	</select>
+	<select id="sumCloudCourseAmount" resultType="java.util.Map">
+		SELECT cs.organ_id_ 'key',SUM(ctf.cost_) 'value' FROM cloud_teacher_free_course ctf
+		LEFT JOIN course_schedule cs ON cs.id_ = ctf.course_id_
+		where cs.del_flag_ = 0 AND cs.is_lock_ = 0 AND cs.class_date_ BETWEEN #{firstDay} AND #{lastDay} group by cs.organ_id_;
+	</select>
+	<select id="sumCourseAmount" resultType="java.util.Map">
+		SELECT cs.organ_id_ 'key',SUM(cssp.actual_price_) 'value' FROM course_schedule cs
+		LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
+		left join organization o ON o.id_ = cs.organ_id_
+		where cs.del_flag_ = 0 AND cs.is_lock_ = 0 AND cs.class_date_ BETWEEN #{firstDay} AND #{lastDay} group by cs.organ_id_;
+	</select>
+	<select id="sumPersonalCloudAmount" resultType="java.util.Map">
+		select cto.organ_id_ 'key',TRUNCATE(SUM(amount_ / TIMESTAMPDIFF(DAY,start_time_,end_time_) *
+		TIMESTAMPDIFF(DAY,CASE WHEN start_time_ &lt; #{firstDay} THEN #{firstDay} ELSE DATE_FORMAT(start_time_,'%Y-%m-%d') END,
+		CASE WHEN end_time_ > #{month} THEN #{lastDay} ELSE DATE_FORMAT(end_time_,'%Y-%m-%d') END)),2) 'value'
+		from cloud_teacher_order cto
+		where music_group_id_ IS NULL AND amount_ > 0 AND #{month} BETWEEN DATE_FORMAT(start_time_,'%Y-%m') AND DATE_FORMAT(end_time_,'%Y-%m') group by cto.organ_id_;
+	</select>
+	<select id="sumGroupCloudAmount" resultType="java.util.Map">
+		select orc.organ_id_ 'key',TRUNCATE(SUM(orc.cloud_price_ / TIMESTAMPDIFF(DAY,orc.start_date_,orc.end_date_) *
+		TIMESTAMPDIFF(DAY,CASE WHEN orc.start_date_ &lt; #{firstDay} THEN #{firstDay} ELSE orc.start_date_ END,
+		CASE WHEN orc.end_date_ > #{month} THEN #{lastDay} ELSE orc.end_date_ END)),2) 'value' from operating_report_cloud orc
+		where #{month} BETWEEN DATE_FORMAT(orc.start_date_,'%Y-%m') AND DATE_FORMAT(orc.end_date_,'%Y-%m') AND orc.start_date_  IS NOT NULL;
+	</select>
+	<select id="sumRefundAmount" resultType="java.util.Map">
+		select suc.organ_id_ 'key',SUM(amount_) 'value' from sys_user_cash_account_log suc
+		where DATE_FORMAT(suc.create_time_,'%Y-%m') = #{month} AND suc.amount_ > 0 group by suc.organ_id_;
+	</select>
+	<select id="sumVariableCosts" resultType="java.util.Map">
+		select fe.organ_id_ 'key',SUM(amount_) 'value' from financial_expenditure fe
+		where DATE_FORMAT(fe.create_time_,'%Y-%m') = #{month} AND fee_project_ BETWEEN 6 AND 18 AND process_id_ = 28 group by fe.organ_id_;
+	</select>
+	<select id="sumFixedCosts" resultType="java.util.Map">
+		select fe.organ_id_ 'key',SUM(amount_) 'value' from financial_expenditure fe
+		where DATE_FORMAT(fe.create_time_,'%Y-%m') = #{month} AND fee_project_ BETWEEN 1 AND 5 AND process_id_ = 28 group by fe.organ_id_;
+	</select>
+	<select id="sumCloudPreAmount" resultType="java.util.Map">
+		select orc.organ_id_ 'key',TRUNCATE(SUM(operating_amount_ / TIMESTAMPDIFF(DAY,start_time_,end_time_) * TIMESTAMPDIFF(DAY,#{lastDay},end_time_)),2) 'value'
+		from cloud_teacher_order orc
+		where operating_amount_ > 0 AND DATE_FORMAT(end_time_,'%Y-%m') > #{month} group by orc.organ_id_;
+	</select>
+	<select id="sumGroupCloudPreAmount" resultType="java.util.Map">
+		select orc.organ_id_ 'key',TRUNCATE(SUM(orc.cloud_price_ / TIMESTAMPDIFF(DAY,orc.start_date_,orc.end_date_) * TIMESTAMPDIFF(DAY,#{lastDay},orc.end_date_)),2) 'value'
+		from operating_report_cloud orc
+		where DATE_FORMAT(orc.end_date_,'%Y-%m') > #{month} AND orc.cloud_price_ > 0 AND orc.month_flag_ = false group by orc.organ_id_;
+	</select>
+	<select id="sumGroupAmount" resultType="java.util.Map">
+		select orc.organ_id_ 'key',SUM(orc.cloud_price_) 'value'
+		from operating_report_cloud orc
+		where orc.cloud_price_ > 0 AND orc.month_flag_ = true AND orc.settlement_flag_ = false group by orc.organ_id_;
+	</select>
+	<select id="sumCloudCoursePreAmount" resultType="java.util.Map">
+		SELECT cs.organ_id_ 'key',SUM(ctf.cost_) 'value' FROM cloud_teacher_free_course ctf
+		LEFT JOIN course_schedule cs ON cs.id_ = ctf.course_id_
+		where cs.del_flag_ = 0 AND cs.is_lock_ = 0 AND cs.class_date_ > #{lastDay}
+		group by cs.organ_id_;
+	</select>
+	<select id="sumCoursePreAmount" resultType="java.util.Map">
+		SELECT cs.organ_id_ 'key',SUM(cssp.actual_price_) 'value' FROM course_schedule cs
+		LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
+		where cs.del_flag_ = 0 AND cs.is_lock_ = 0 AND cs.class_date_ > #{lastDay}
+		group by cs.organ_id_;
+	</select>
+	<select id="sumOtherPreAmount" resultType="java.util.Map">
+		select orc.organ_id_ 'key',SUM(orc.cloud_price_) 'value' from operating_report_cloud orc
+		where orc.course_price_ = 0 AND orc.month_flag_ = false AND orc.settlement_flag_ = false GROUP BY orc.organ_id_;
+	</select>
+	<select id="sumSalePreAmount" resultType="java.util.Map">
+		select mg.organ_id_ 'key',SUM(so.actual_amount_) 'value' from sell_order so
+		left join student_payment_order spo ON spo.order_no_ = so.order_no_
+		left join music_group mg ON mg.id_ = spo.music_group_id_ AND spo.group_type_ = 'MUSIC'
+		where mg.musical_instruments_provide_status_ = 0 AND so.actual_amount_ > 0
+		group by mg.organ_id_;
+	</select>
+	<select id="sumArrearsAmount" resultType="java.util.Map">
+		select a.organ_id_ 'key',SUM(a.amount_) 'value' FROM (
+		select SUM(mgpc.current_total_amount_) amount_,mgpc.organ_id_ from music_group_payment_calender_detail mgpcd
+		LEFT JOIN (select * from music_group_payment_student_course_detail where used_course_minutes_ > 0 group by music_group_payment_calender_id_,user_id_) mgpscd 			ON mgpscd.music_group_payment_calender_detail_id_ = mgpcd.id_
+		LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpscd.music_group_payment_calender_id_
+		WHERE mgpcd.payment_status_ = 'NON_PAYMENT' AND mgpscd.used_course_minutes_ > 0 AND mgpc.current_total_amount_ > 0
+		GROUP BY mgpscd.music_group_payment_calender_id_,mgpscd.user_id_) a
+		group by organ_id_
+	</select>
+	<select id="sumSchoolAmount" resultType="java.util.Map">
+		select mgpc.organ_id_ 'key',SUM(mgpc.current_total_amount_ * mgpc.actual_num_) - SUM(spro.service_amount_) - SUM(spro.sale_amount_) 'value'
+		from student_payment_route_order spro
+		LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = spro.calender_id_
+		where spro.calender_id_ IS NOT NULL AND spro.audit_status_ = 'PASS' AND mgpc.id_ = spro.calender_id_
+		group by mgpc.organ_id_
+	</select>
+</mapper>

+ 0 - 14
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupQuitController.java

@@ -15,11 +15,8 @@ import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.util.collection.MapUtil;
-import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.json.JsonUtil;
 import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -81,17 +78,6 @@ public class MusicGroupQuitController extends BaseController {
                 if (studentMaintenance != null) {
                     row.setHasMaintenance(true);
                 }
-                List<CloudTeacherOrder> cloudTeacherOrders = cloudTeacherOrderDao.getStudentCloudTeacherOrder(row.getUserId(),row.getMusicGroupId());
-                if(cloudTeacherOrders.size() > 0){
-                    BigDecimal orderAmount = BigDecimal.ZERO;
-                    for (CloudTeacherOrder cloudTeacherOrder : cloudTeacherOrders) {
-                        if (cloudTeacherOrder.getEndTime() == null || DateUtil.stringToDate(DateUtil.format(cloudTeacherOrder.getEndTime(),DateUtil.ISO_EXPANDED_DATE_FORMAT),DateUtil.ISO_EXPANDED_DATE_FORMAT).compareTo(
-                                DateUtil.stringToDate(DateUtil.format(nowDate,DateUtil.ISO_EXPANDED_DATE_FORMAT),DateUtil.ISO_EXPANDED_DATE_FORMAT)) >= 0) {
-                            orderAmount = orderAmount.add(cloudTeacherOrder.getAmount());
-                        }
-                    }
-                    row.setCloudTeacherAmount(orderAmount);
-                }
             }
         }
         return succeed(musicGroupQuitPageInfo);

+ 70 - 0
mec-web/src/main/java/com/ym/mec/web/controller/MusicMarginController.java

@@ -0,0 +1,70 @@
+package com.ym.mec.web.controller;
+
+import com.ym.mec.biz.dal.entity.MusicMargin;
+import com.ym.mec.biz.dal.page.MusicMarginQueryInfo;
+import com.ym.mec.biz.service.MusicMarginService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.exception.BizException;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Objects;
+
+@Api(tags = "乐器保证金")
+@RequestMapping("musicMargin")
+@RestController
+public class MusicMarginController extends BaseController {
+
+    @Autowired
+    private MusicMarginService musicMarginService;
+
+    @ApiOperation(value = "退款")
+    @PostMapping("/refund")
+    @PreAuthorize("@pcs.hasPermissions('musicMargin/refund')")
+    public Object refund(@RequestBody MusicMargin musicMargin){
+        MusicMargin margin = musicMarginService.get(musicMargin.getId());
+        if(Objects.isNull(margin)){
+            throw new BizException("乐器保证金不存在");
+        }
+        margin.setRefundFlag(1);
+        margin.setRefund(musicMargin.getRefund());
+        margin.setMemo(musicMargin.getMemo());
+        musicMarginService.update(margin);
+        return succeed();
+    }
+
+    @ApiOperation(value = "拒绝退款")
+    @PostMapping("/refusedRefund")
+    @PreAuthorize("@pcs.hasPermissions('musicMargin/refusedRefund')")
+    public Object refusedRefund(@RequestBody MusicMargin musicMargin){
+        MusicMargin margin = musicMarginService.get(musicMargin.getId());
+        if(Objects.isNull(margin)){
+            throw new BizException("乐器保证金不存在");
+        }
+        margin.setRefundFlag(2);
+        margin.setMemo(musicMargin.getMemo());
+        musicMarginService.update(margin);
+        return succeed();
+    }
+
+    @ApiOperation(value = "分页查询")
+    @PostMapping("/queryPage")
+    @PreAuthorize("@pcs.hasPermissions('musicMargin/queryPage')")
+    public Object queryPage(@RequestBody MusicMarginQueryInfo queryInfo){
+        return succeed(musicMarginService.queryPage(queryInfo));
+    }
+
+    @ApiOperation(value = "删除")
+    @PostMapping("/delete")
+    @PreAuthorize("@pcs.hasPermissions('musicMargin/delete')")
+    public Object delete(Integer id){
+        musicMarginService.delete(id);
+        return succeed();
+    }
+}

+ 0 - 7
mec-web/src/main/java/com/ym/mec/web/controller/OperatingReportController.java

@@ -1,9 +1,5 @@
 package com.ym.mec.web.controller;
 
-import com.ym.mec.auth.api.client.SysUserFeignService;
-import com.ym.mec.auth.api.entity.SysUser;
-import com.ym.mec.biz.dal.dao.EmployeeDao;
-import com.ym.mec.biz.dal.entity.Employee;
 import com.ym.mec.biz.dal.entity.OperatingReport;
 import com.ym.mec.biz.dal.page.OperatingReportQueryInfo;
 import com.ym.mec.biz.service.OperatingReportService;
@@ -15,7 +11,6 @@ import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.excel.POIUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -26,9 +21,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Arrays;
 import java.util.Date;
-import java.util.List;
 
 @Api(tags = "经营报表服务")
 @RequestMapping("operatingReport")

+ 11 - 2
mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java

@@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ym.mec.biz.dal.dao.MusicGroupSchoolTermCourseDetailDao;
 import com.ym.mec.biz.dal.entity.MusicGroupSchoolTermCourseDetail;
+import com.ym.mec.biz.dal.entity.OperatingReport;
+import com.ym.mec.biz.dal.entity.OperatingReportCloud;
 import com.ym.mec.biz.dal.entity.TenantInfo;
 import com.ym.mec.biz.dal.enums.IndexDataType;
 import com.ym.mec.biz.event.source.CourseEventSource;
@@ -49,8 +51,6 @@ public class TaskController extends BaseController {
 	@Autowired
 	private StudentPaymentOrderService studentPaymentOrderService;
 	@Autowired
-	private TenantPaymentOrderService tenantPaymentOrderService;
-	@Autowired
 	private TeacherCourseStatisticsService teacherCourseStatisticsService;
 	@Autowired
 	private PracticeGroupService practiceGroupService;
@@ -120,6 +120,15 @@ public class TaskController extends BaseController {
 	private ImSendGroupMessageService imSendGroupMessageService;
     @Autowired
     private TempLittleArtistTrainingCampService tempLittleArtistTrainingCampService;
+    @Autowired
+    private OperatingReportNewService operatingReportNewService;
+
+	//每月经营报表
+	@GetMapping(value = "/operatingReportMonth")
+	public void operatingReportMonth(){
+		Date month = DateUtil.addMonths(new Date(),-1);
+		operatingReportNewService.operatingReportMonth(month);
+	}
 
     @GetMapping(value = "/syncImHistoryMessageTask")
 	// 同步即时通讯聊天记录