Преглед на файлове

Merge branch 'saas' of http://git.dayaedu.com/yonge/mec into 2022DoubleEleven

zouxuan преди 2 години
родител
ревизия
8c3d96c9ed
променени са 71 файла, в които са добавени 3224 реда и са изтрити 850 реда
  1. 31 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CooperationShareProfitDao.java
  2. 32 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupCalenderRefundPeriodDao.java
  3. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupOrganizationCourseSettingsDao.java
  4. 3 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentStudentCourseDetailDao.java
  5. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPlanMakingDao.java
  6. 7 6
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/OrganizationCourseUnitPriceSettingsDao.java
  7. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysPositionDao.java
  8. 141 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CooperationCalenderRefundDto.java
  9. 108 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CooperationRefundDto.java
  10. 78 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupPaymentBaseCalender.java
  11. 19 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupPlanMakingDto.java
  12. 14 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SubFeeSettingDto.java
  13. 142 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CooperationShareProfit.java
  14. 65 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CooperationShareProfitDto.java
  15. 3 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CourseScheduleStudentPayment.java
  16. 78 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroup.java
  17. 151 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupCalenderRefundPeriod.java
  18. 55 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalender.java
  19. 9 6
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderCourseSettings.java
  20. 56 15
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentStudentCourseDetail.java
  21. 70 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPlanMaking.java
  22. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupSubjectGoodsGroup.java
  23. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Organization.java
  24. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/IndexErrorType.java
  25. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/MusicGroupStatusEnum.java
  26. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/OrderDetailTypeEnum.java
  27. 73 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/CooperationRefundQueryInfo.java
  28. 44 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/CooperationShareProfitQueryInfo.java
  29. 18 0
      mec-biz/src/main/java/com/ym/mec/biz/service/CooperationShareProfitService.java
  30. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleStudentPaymentService.java
  31. 38 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupCalenderRefundPeriodService.java
  32. 0 11
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java
  33. 0 5
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentStudentCourseDetailService.java
  34. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPlanMakingService.java
  35. 4 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java
  36. 106 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CooperationShareProfitServiceImpl.java
  37. 85 72
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java
  38. 15 10
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java
  39. 191 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupCalenderRefundPeriodServiceImpl.java
  40. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderCourseSettingsServiceImpl.java
  41. 29 27
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java
  42. 161 184
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  43. 2 11
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentStudentCourseDetailServiceImpl.java
  44. 23 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPlanMakingServiceImpl.java
  45. 225 244
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  46. 19 47
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentAttendanceServiceImpl.java
  47. 11 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderDetailServiceImpl.java
  48. 17 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java
  49. 25 23
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentRouteOrderServiceImpl.java
  50. 214 51
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  51. 2 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SubjectChangeServiceImpl.java
  52. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysEmployeePositionServiceImpl.java
  53. 132 0
      mec-biz/src/main/resources/config/mybatis/CooperationShareProfitMapper.xml
  54. 209 0
      mec-biz/src/main/resources/config/mybatis/MusicGroupCalenderRefundPeriodMapper.xml
  55. 32 2
      mec-biz/src/main/resources/config/mybatis/MusicGroupMapper.xml
  56. 6 0
      mec-biz/src/main/resources/config/mybatis/MusicGroupOrganizationCourseSettingsMapper.xml
  57. 25 5
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml
  58. 64 49
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentStudentCourseDetailMapper.xml
  59. 74 0
      mec-biz/src/main/resources/config/mybatis/MusicGroupPlanMakingMapper.xml
  60. 8 4
      mec-biz/src/main/resources/config/mybatis/MusicGroupSubjectGoodsGroupMapper.xml
  61. 5 0
      mec-biz/src/main/resources/config/mybatis/OrganizationCourseUnitPriceSettingsMapper.xml
  62. 6 2
      mec-biz/src/main/resources/config/mybatis/OrganizationMapper.xml
  63. 2 2
      mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupRegisterController.java
  64. 41 0
      mec-web/src/main/java/com/ym/mec/web/controller/CooperationShareProfitController.java
  65. 52 0
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupCalenderRefundPeriodController.java
  66. 21 14
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupController.java
  67. 0 2
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java
  68. 104 0
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPlanMakingController.java
  69. 21 33
      mec-web/src/main/java/com/ym/mec/web/controller/StudentPaymentRouteOrderController.java
  70. 5 1
      mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java
  71. 2 5
      mec-web/src/main/java/com/ym/mec/web/controller/UploadFileController.java

+ 31 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CooperationShareProfitDao.java

@@ -0,0 +1,31 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.biz.dal.entity.CooperationShareProfitDto;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.biz.dal.entity.CooperationShareProfit;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+public interface CooperationShareProfitDao extends BaseDAO<Integer, CooperationShareProfit> {
+
+
+    /**
+    * @description: 获取已添加分润记录的乐团
+     * @param musicGroupIds
+    * @return java.util.List<java.lang.String>
+    * @author zx
+    * @date 2022/10/20 11:00
+    */
+    List<String> queryNotShare(@Param("musicGroupIds") List<String> musicGroupIds);
+
+
+    List<CooperationShareProfit> initShareProfit(@Param("musicGroupIds") List<String> musicGroupIds);
+
+    void batchInsert(@Param("profits") List<CooperationShareProfit> profits);
+
+    int countDto(Map<String, Object> params);
+
+    List<CooperationShareProfitDto> queryDtoPage(Map<String, Object> params);
+}

+ 32 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupCalenderRefundPeriodDao.java

@@ -0,0 +1,32 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.biz.dal.dto.CooperationCalenderRefundDto;
+import com.ym.mec.biz.dal.dto.CooperationRefundDto;
+import com.ym.mec.biz.dal.entity.MusicGroupCalenderRefundPeriod;
+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 MusicGroupCalenderRefundPeriodDao extends BaseDAO<Integer, MusicGroupCalenderRefundPeriod> {
+
+    void batchInsert(@Param("refundPeriods") List<MusicGroupCalenderRefundPeriod> refundPeriods);
+
+    List<MusicGroupCalenderRefundPeriod> findByCalenderId(@Param("calenderId") Long calenderId);
+
+    int countCoopRefund(Map<String, Object> params);
+
+    List<CooperationRefundDto> queryCoopRefund(Map<String, Object> params);
+
+    BigDecimal sumCoopRefund(Map<String, Object> params);
+
+    int countCoopCalender(Map<String, Object> params);
+
+    List<CooperationCalenderRefundDto> queryCoopCalender(Map<String, Object> params);
+
+    void deleteByCalenderId(@Param("calenderId") Long calenderId);
+
+    void batchUpdate(@Param("refundPeriods") List<MusicGroupCalenderRefundPeriod> refundPeriods);
+}

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupOrganizationCourseSettingsDao.java

@@ -3,6 +3,8 @@ package com.ym.mec.biz.dal.dao;
 import com.ym.mec.biz.dal.entity.MusicGroupOrganizationCourseSettings;
 import com.ym.mec.common.dal.BaseDAO;
 
+import java.util.List;
+
 public interface MusicGroupOrganizationCourseSettingsDao extends BaseDAO<Integer, MusicGroupOrganizationCourseSettings> {
 
 }

+ 3 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentStudentCourseDetailDao.java

@@ -31,9 +31,9 @@ public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, M
      * @author Joburgess
      * @date 2020.11.04
      */
-    List<MusicGroupPaymentStudentCourseDetail> getUnUseWithStudentAndCourseTypeAndCourseMinutes(@Param("batchNo") String batchNo,
-                                                                                                @Param("studentId") Integer studentId,
-                                                                                                @Param("courseType") CourseSchedule.CourseScheduleType courseType);
+    List<MusicGroupPaymentStudentCourseDetail> getUnUseWithStudentAndCourseTypeAndCourseMinutes(@Param("studentId") Integer studentId,
+                                                                                                @Param("courseType") CourseSchedule.CourseScheduleType courseType,
+                                                                                                @Param("musicGroupId") String musicGroupId);
 
     /**
      * @param studentId:

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPlanMakingDao.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.MusicGroupPlanMaking;
+
+public interface MusicGroupPlanMakingDao extends BaseDAO<Integer, MusicGroupPlanMaking> {
+
+	
+}

+ 7 - 6
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/OrganizationCourseUnitPriceSettingsDao.java

@@ -1,13 +1,12 @@
 package com.ym.mec.biz.dal.dao;
 
-import java.util.List;
-import java.util.Map;
-
-import org.apache.ibatis.annotations.Param;
-
-import com.ym.mec.biz.dal.entity.OrganizationCourseUnitPriceSettings;
 import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
+import com.ym.mec.biz.dal.entity.OrganizationCourseUnitPriceSettings;
 import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
 
 public interface OrganizationCourseUnitPriceSettingsDao extends BaseDAO<Integer, OrganizationCourseUnitPriceSettings> {
 
@@ -38,4 +37,6 @@ public interface OrganizationCourseUnitPriceSettingsDao extends BaseDAO<Integer,
     List<Map<String, Integer>> queryMapByOrganIdAndChargeTypeId(@Param("chargeTypeId") Integer chargeTypeId, @Param("organId") Integer organId);
 
     List<OrganizationCourseUnitPriceSettings> querySingle(@Param("organId")Integer organId, @Param("courseType") String courseType, @Param("tenantId") Integer tenantId);
+
+	List<OrganizationCourseUnitPriceSettings> queryByMusicGroupId(@Param("musicGroupId") String musicGroupId);
 }

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

@@ -12,5 +12,5 @@ import java.util.Set;
 public interface SysPositionDao extends BaseDAO<Integer, SysPosition> {
 
 
-    List<Map<Integer, String>> findMapByIds(@Param("positionIds") Collection<Integer> positionIds);
+    List<Map<Integer, String>> findMapByIds();
 }

+ 141 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CooperationCalenderRefundDto.java

@@ -0,0 +1,141 @@
+package com.ym.mec.biz.dal.dto;
+
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+
+public class CooperationCalenderRefundDto {
+
+    @ApiModelProperty(value = "缴费项目编号",required = false)
+    private Long calenderId;
+
+    @ApiModelProperty(value = "乐团编号",required = false)
+    private String musicGroupId;
+
+    @ApiModelProperty(value = "乐团",required = false)
+    private String musicGroupName;
+
+    @ApiModelProperty(value = "缴费批次",required = false)
+    private String batchNo;
+
+    @ApiModelProperty(value = "缴费类型",required = false)
+    private String paymentType;
+
+    @ApiModelProperty(value = "计价方式",required = false)
+    private String calenderFeeType;
+
+    @ApiModelProperty(value = "应收账款",required = false)
+    private BigDecimal receivable = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "实际收入",required = false)
+    private BigDecimal income = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "预收",required = false)
+    private BigDecimal prepaidFee = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "下次回款时间",required = false)
+    private String nextRefundDate;
+
+    @ApiModelProperty(value = "回款状态",required = false)
+    private String refundStatus;
+
+    @ApiModelProperty(value = "合同",required = false)
+    private String contractUrl;
+
+    public String getContractUrl() {
+        return contractUrl;
+    }
+
+    public void setContractUrl(String contractUrl) {
+        this.contractUrl = contractUrl;
+    }
+
+    public Long getCalenderId() {
+        return calenderId;
+    }
+
+    public void setCalenderId(Long calenderId) {
+        this.calenderId = calenderId;
+    }
+
+    public String getMusicGroupId() {
+        return musicGroupId;
+    }
+
+    public void setMusicGroupId(String musicGroupId) {
+        this.musicGroupId = musicGroupId;
+    }
+
+    public String getMusicGroupName() {
+        return musicGroupName;
+    }
+
+    public void setMusicGroupName(String musicGroupName) {
+        this.musicGroupName = musicGroupName;
+    }
+
+    public String getBatchNo() {
+        return batchNo;
+    }
+
+    public void setBatchNo(String batchNo) {
+        this.batchNo = batchNo;
+    }
+
+    public String getPaymentType() {
+        return paymentType;
+    }
+
+    public void setPaymentType(String paymentType) {
+        this.paymentType = paymentType;
+    }
+
+    public String getCalenderFeeType() {
+        return calenderFeeType;
+    }
+
+    public void setCalenderFeeType(String calenderFeeType) {
+        this.calenderFeeType = calenderFeeType;
+    }
+
+    public BigDecimal getReceivable() {
+        return receivable;
+    }
+
+    public void setReceivable(BigDecimal receivable) {
+        this.receivable = receivable;
+    }
+
+    public BigDecimal getIncome() {
+        return income;
+    }
+
+    public void setIncome(BigDecimal income) {
+        this.income = income;
+    }
+
+    public BigDecimal getPrepaidFee() {
+        return prepaidFee;
+    }
+
+    public void setPrepaidFee(BigDecimal prepaidFee) {
+        this.prepaidFee = prepaidFee;
+    }
+
+    public String getNextRefundDate() {
+        return nextRefundDate;
+    }
+
+    public void setNextRefundDate(String nextRefundDate) {
+        this.nextRefundDate = nextRefundDate;
+    }
+
+    public String getRefundStatus() {
+        return refundStatus;
+    }
+
+    public void setRefundStatus(String refundStatus) {
+        this.refundStatus = refundStatus;
+    }
+}

+ 108 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CooperationRefundDto.java

@@ -0,0 +1,108 @@
+package com.ym.mec.biz.dal.dto;
+
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+
+public class CooperationRefundDto{
+
+    @ApiModelProperty(value = "分部",required = false)
+    private Integer organId;
+
+    @ApiModelProperty(value = "分部",required = false)
+    private String organName;
+
+    @ApiModelProperty(value = "合作单位",required = false)
+    private Integer cooperationOrganId;
+
+    @ApiModelProperty(value = "合作单位",required = false)
+    private String cooperationOrganName;
+
+    @ApiModelProperty(value = "乐团主管",required = false)
+    private Integer educationUserId;
+
+    @ApiModelProperty(value = "乐团主管",required = false)
+    private String educationUserName;
+
+    @ApiModelProperty(value = "应收账款",required = false)
+    private BigDecimal receivable = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "实际收入",required = false)
+    private BigDecimal income = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "预收",required = false)
+    private BigDecimal prepaidFee = BigDecimal.ZERO;
+
+    public Integer getCooperationOrganId() {
+        return cooperationOrganId;
+    }
+
+    public void setCooperationOrganId(Integer cooperationOrganId) {
+        this.cooperationOrganId = cooperationOrganId;
+    }
+
+    public Integer getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(Integer organId) {
+        this.organId = organId;
+    }
+
+    public String getOrganName() {
+        return organName;
+    }
+
+    public void setOrganName(String organName) {
+        this.organName = organName;
+    }
+
+    public String getCooperationOrganName() {
+        return cooperationOrganName;
+    }
+
+    public void setCooperationOrganName(String cooperationOrganName) {
+        this.cooperationOrganName = cooperationOrganName;
+    }
+
+    public Integer getEducationUserId() {
+        return educationUserId;
+    }
+
+    public void setEducationUserId(Integer educationUserId) {
+        this.educationUserId = educationUserId;
+    }
+
+    public String getEducationUserName() {
+        return educationUserName;
+    }
+
+    public void setEducationUserName(String educationUserName) {
+        this.educationUserName = educationUserName;
+    }
+
+    public BigDecimal getReceivable() {
+        return receivable;
+    }
+
+    public void setReceivable(BigDecimal receivable) {
+        this.receivable = receivable;
+    }
+
+    public BigDecimal getIncome() {
+        return income;
+    }
+
+    public void setIncome(BigDecimal income) {
+        this.income = income;
+    }
+
+    public BigDecimal getPrepaidFee() {
+        return prepaidFee;
+    }
+
+    public void setPrepaidFee(BigDecimal prepaidFee) {
+        this.prepaidFee = prepaidFee;
+    }
+}

+ 78 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupPaymentBaseCalender.java

@@ -5,6 +5,7 @@ import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType;
 import io.swagger.annotations.ApiModelProperty;
 
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 
@@ -57,6 +58,75 @@ public class MusicGroupPaymentBaseCalender {
 	@ApiModelProperty(value = "缴费项目显示状态", required = false)
 	private String paymentItemShowState;
 	
+	@ApiModelProperty(value = "是否显示销售价", required = false)
+	private Boolean isShowSalePrice;
+
+	@ApiModelProperty(value = "学校缴费计价json", required = false)
+	private String calenderFeeJson;
+
+	@ApiModelProperty(value = "学校缴费计价标准,STUDENT、TEACHER", required = false)
+	private String calenderFeeType;
+
+	@ApiModelProperty(value = "学校缴费回款周期", required = false)
+	private List<MusicGroupCalenderRefundPeriod> musicGroupCalenderRefundPeriods;
+
+	@ApiModelProperty(value = "学校缴费折扣价", required = false)
+	private BigDecimal currentTotalAmount;
+
+	@ApiModelProperty(value = "合同url", required = false)
+	private String contractUrl;
+
+	@ApiModelProperty(value = "缴费项目名称", required = false)
+	private String name;
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getContractUrl() {
+		return contractUrl;
+	}
+
+	public void setContractUrl(String contractUrl) {
+		this.contractUrl = contractUrl;
+	}
+
+	public BigDecimal getCurrentTotalAmount() {
+		return currentTotalAmount;
+	}
+
+	public void setCurrentTotalAmount(BigDecimal currentTotalAmount) {
+		this.currentTotalAmount = currentTotalAmount;
+	}
+
+	public List<MusicGroupCalenderRefundPeriod> getMusicGroupCalenderRefundPeriods() {
+		return musicGroupCalenderRefundPeriods;
+	}
+
+	public void setMusicGroupCalenderRefundPeriods(List<MusicGroupCalenderRefundPeriod> musicGroupCalenderRefundPeriods) {
+		this.musicGroupCalenderRefundPeriods = musicGroupCalenderRefundPeriods;
+	}
+
+	public String getCalenderFeeJson() {
+		return calenderFeeJson;
+	}
+
+	public void setCalenderFeeJson(String calenderFeeJson) {
+		this.calenderFeeJson = calenderFeeJson;
+	}
+
+	public String getCalenderFeeType() {
+		return calenderFeeType;
+	}
+
+	public void setCalenderFeeType(String calenderFeeType) {
+		this.calenderFeeType = calenderFeeType;
+	}
+
 	public Boolean getConfirmCreate() {
 		return confirmCreate;
 	}
@@ -193,4 +263,12 @@ public class MusicGroupPaymentBaseCalender {
 		this.paymentItemShowState = paymentItemShowState;
 	}
 
+	public Boolean getIsShowSalePrice() {
+		return isShowSalePrice;
+	}
+
+	public void setIsShowSalePrice(Boolean isShowSalePrice) {
+		this.isShowSalePrice = isShowSalePrice;
+	}
+
 }

+ 19 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupPlanMakingDto.java

@@ -0,0 +1,19 @@
+package com.ym.mec.biz.dal.dto;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.ym.mec.biz.dal.entity.MusicGroupPlanMaking;
+
+public class MusicGroupPlanMakingDto extends MusicGroupPlanMaking {
+
+	private Map<Integer,String> subjectMap = new HashMap<Integer,String>();
+
+	public Map<Integer, String> getSubjectMap() {
+		return subjectMap;
+	}
+
+	public void setSubjectMap(Map<Integer, String> subjectMap) {
+		this.subjectMap = subjectMap;
+	}
+}

+ 14 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SubFeeSettingDto.java

@@ -2,7 +2,10 @@ package com.ym.mec.biz.dal.dto;
 
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
+
 import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
 import java.util.List;
 
 public class SubFeeSettingDto {
@@ -30,6 +33,9 @@ public class SubFeeSettingDto {
 
     @ApiModelProperty(value = "乐团状态(修改时用)",required = false)
     private MusicGroupStatusEnum musicGroupStatus;
+    
+    @ApiModelProperty(value = "分部乐器分润上限",required = false)
+    private BigDecimal maxMusicalInstrumentsProfits;
 
     public MusicGroupStatusEnum getMusicGroupStatus() {
         return musicGroupStatus;
@@ -94,4 +100,12 @@ public class SubFeeSettingDto {
     public void setSubjectRegisters(List<SubjectRegisterDto> subjectRegisters) {
         this.subjectRegisters = subjectRegisters;
     }
+
+	public BigDecimal getMaxMusicalInstrumentsProfits() {
+		return maxMusicalInstrumentsProfits;
+	}
+
+	public void setMaxMusicalInstrumentsProfits(BigDecimal maxMusicalInstrumentsProfits) {
+		this.maxMusicalInstrumentsProfits = maxMusicalInstrumentsProfits;
+	}
 }

+ 142 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CooperationShareProfit.java

@@ -0,0 +1,142 @@
+package com.ym.mec.biz.dal.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(cooperation_share_profit):
+ */
+public class CooperationShareProfit {
+
+	private Integer id;
+	
+	private Integer organId;
+	
+	private Integer cooperationId;
+	
+	private String musicGroupId;
+	
+	@ApiModelProperty(value = "乐器数量", required = false)
+	private Integer musicalNum;
+	
+	@ApiModelProperty(value = "分润总额", required = false)
+	private java.math.BigDecimal totalAmount;
+	
+	@ApiModelProperty(value = "付款状态PAID_COMPLETED(\"已缴费\"), NON_PAYMENT(\"未缴费\")", required = false)
+	private String paymentStatus = "NON_PAYMENT";
+	
+	@ApiModelProperty(value = "交易流水号", required = false)
+	private String paymentNo;
+	
+	@ApiModelProperty(value = "备注", required = false)
+	private String memo;
+
+	@ApiModelProperty(value = "凭证", required = false)
+	private String credentials;
+	
+	private java.util.Date createTime;
+	
+	private java.util.Date updateTime;
+
+	public String getCredentials() {
+		return credentials;
+	}
+
+	public void setCredentials(String credentials) {
+		this.credentials = credentials;
+	}
+
+	public void setId(Integer id){
+		this.id = id;
+	}
+	
+	public Integer getId(){
+		return this.id;
+	}
+			
+	public void setOrganId(Integer organId){
+		this.organId = organId;
+	}
+	
+	public Integer getOrganId(){
+		return this.organId;
+	}
+			
+	public void setCooperationId(Integer cooperationId){
+		this.cooperationId = cooperationId;
+	}
+	
+	public Integer getCooperationId(){
+		return this.cooperationId;
+	}
+			
+	public void setMusicGroupId(String musicGroupId){
+		this.musicGroupId = musicGroupId;
+	}
+	
+	public String getMusicGroupId(){
+		return this.musicGroupId;
+	}
+			
+	public void setMusicalNum(Integer musicalNum){
+		this.musicalNum = musicalNum;
+	}
+	
+	public Integer getMusicalNum(){
+		return this.musicalNum;
+	}
+			
+	public void setTotalAmount(java.math.BigDecimal totalAmount){
+		this.totalAmount = totalAmount;
+	}
+	
+	public java.math.BigDecimal getTotalAmount(){
+		return this.totalAmount;
+	}
+			
+	public void setPaymentStatus(String paymentStatus){
+		this.paymentStatus = paymentStatus;
+	}
+	
+	public String getPaymentStatus(){
+		return this.paymentStatus;
+	}
+			
+	public void setPaymentNo(String paymentNo){
+		this.paymentNo = paymentNo;
+	}
+	
+	public String getPaymentNo(){
+		return this.paymentNo;
+	}
+			
+	public void setMemo(String memo){
+		this.memo = memo;
+	}
+	
+	public String getMemo(){
+		return this.memo;
+	}
+			
+	public void setCreateTime(java.util.Date createTime){
+		this.createTime = createTime;
+	}
+	
+	public java.util.Date getCreateTime(){
+		return this.createTime;
+	}
+			
+	public void setUpdateTime(java.util.Date updateTime){
+		this.updateTime = updateTime;
+	}
+	
+	public java.util.Date getUpdateTime(){
+		return this.updateTime;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 65 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CooperationShareProfitDto.java

@@ -0,0 +1,65 @@
+package com.ym.mec.biz.dal.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(cooperation_share_profit):
+ */
+public class CooperationShareProfitDto extends CooperationShareProfit{
+
+	@ApiModelProperty(value = "分部", required = false)
+	private String organName;
+
+	@ApiModelProperty(value = "合作单位", required = false)
+	private String cooperationName;
+
+	@ApiModelProperty(value = "乐团名称", required = false)
+	private String musicGroupName;
+
+	@ApiModelProperty(value = "乐团主管", required = false)
+	private Integer educationUserId;
+
+	@ApiModelProperty(value = "乐团主管", required = false)
+	private String educationUserName;
+
+	public String getOrganName() {
+		return organName;
+	}
+
+	public void setOrganName(String organName) {
+		this.organName = organName;
+	}
+
+	public String getCooperationName() {
+		return cooperationName;
+	}
+
+	public void setCooperationName(String cooperationName) {
+		this.cooperationName = cooperationName;
+	}
+
+	public String getMusicGroupName() {
+		return musicGroupName;
+	}
+
+	public void setMusicGroupName(String musicGroupName) {
+		this.musicGroupName = musicGroupName;
+	}
+
+	public Integer getEducationUserId() {
+		return educationUserId;
+	}
+
+	public void setEducationUserId(Integer educationUserId) {
+		this.educationUserId = educationUserId;
+	}
+
+	public String getEducationUserName() {
+		return educationUserName;
+	}
+
+	public void setEducationUserName(String educationUserName) {
+		this.educationUserName = educationUserName;
+	}
+}

+ 3 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CourseScheduleStudentPayment.java

@@ -29,13 +29,13 @@ public class CourseScheduleStudentPayment extends BaseEntity implements Comparab
 	/**  */
 	private Integer userId;
 
-	private BigDecimal originalPrice;
+	private BigDecimal originalPrice = BigDecimal.ZERO;
 	
 	/** 预计价格 */
-	private java.math.BigDecimal expectPrice;
+	private java.math.BigDecimal expectPrice = BigDecimal.ZERO;
 	
 	/**  */
-	private java.math.BigDecimal actualPrice;
+	private java.math.BigDecimal actualPrice = BigDecimal.ZERO;
 	
 	/**  */
 	private java.util.Date createTime;

+ 78 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroup.java

@@ -212,7 +212,28 @@ public class MusicGroup extends BaseEntity {
 	
 	@ApiModelProperty(value = "第一节课实际开始时间",required = false)
 	private Date firstCourseStartTime;
-
+	
+	@ApiModelProperty(value = "建团编制",required = false)
+	private Integer musicGroupPlanMakingId;
+	
+	@ApiModelProperty(value = "成团年级",required = false)
+	private Integer firstRecruitGrade;
+	
+	@ApiModelProperty(value = "默认收费标准",required = false)
+	private BigDecimal defaultChargeStandard;
+	
+	@ApiModelProperty(value = "单次训练时长",required = false)
+	private String singleTrainMinutes;
+	
+	@ApiModelProperty(value = "课程计划",required = false)
+	private String coursePlan;
+	
+	@ApiModelProperty(value = "销售活动描述",required = false)
+	private String saleActivityDesc;
+	
+	@ApiModelProperty(value = "毕业年级",required = false)
+	private Integer graduateGrade;
+	
 	public String getMusicalInstrumentsProvideTime() {
 		return musicalInstrumentsProvideTime;
 	}
@@ -734,4 +755,60 @@ public class MusicGroup extends BaseEntity {
 	public void setFirstCourseStartTime(Date firstCourseStartTime) {
 		this.firstCourseStartTime = firstCourseStartTime;
 	}
+
+	public Integer getMusicGroupPlanMakingId() {
+		return musicGroupPlanMakingId;
+	}
+
+	public void setMusicGroupPlanMakingId(Integer musicGroupPlanMakingId) {
+		this.musicGroupPlanMakingId = musicGroupPlanMakingId;
+	}
+
+	public Integer getFirstRecruitGrade() {
+		return firstRecruitGrade;
+	}
+
+	public void setFirstRecruitGrade(Integer firstRecruitGrade) {
+		this.firstRecruitGrade = firstRecruitGrade;
+	}
+
+	public BigDecimal getDefaultChargeStandard() {
+		return defaultChargeStandard;
+	}
+
+	public void setDefaultChargeStandard(BigDecimal defaultChargeStandard) {
+		this.defaultChargeStandard = defaultChargeStandard;
+	}
+
+	public String getSingleTrainMinutes() {
+		return singleTrainMinutes;
+	}
+
+	public void setSingleTrainMinutes(String singleTrainMinutes) {
+		this.singleTrainMinutes = singleTrainMinutes;
+	}
+
+	public String getCoursePlan() {
+		return coursePlan;
+	}
+
+	public void setCoursePlan(String coursePlan) {
+		this.coursePlan = coursePlan;
+	}
+
+	public String getSaleActivityDesc() {
+		return saleActivityDesc;
+	}
+
+	public void setSaleActivityDesc(String saleActivityDesc) {
+		this.saleActivityDesc = saleActivityDesc;
+	}
+
+	public Integer getGraduateGrade() {
+		return graduateGrade;
+	}
+
+	public void setGraduateGrade(Integer graduateGrade) {
+		this.graduateGrade = graduateGrade;
+	}
 }

+ 151 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupCalenderRefundPeriod.java

@@ -0,0 +1,151 @@
+package com.ym.mec.biz.dal.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+import java.math.BigDecimal;
+
+/**
+ * 对应数据库表(music_group_calender_refund_period):
+ */
+public class MusicGroupCalenderRefundPeriod {
+
+	/**  */
+	private Integer id;
+	
+	@ApiModelProperty(value = "分部",required = false)
+	private Integer organId;
+	
+	@ApiModelProperty(value = "合作单位编号",required = false)
+	private Integer cooperationOrganId;
+	
+	@ApiModelProperty(value = "缴费项目编号",required = false)
+	private Long calenderId;
+	
+	@ApiModelProperty(value = "回款时间",required = false)
+	private String refundDate;
+	
+	@ApiModelProperty(value = "回款金额",required = false)
+	private java.math.BigDecimal refundAmount;
+
+	@ApiModelProperty(value = "已回款金额",required = false)
+	private java.math.BigDecimal income = BigDecimal.ZERO;
+	
+	@ApiModelProperty(value = "剩余待回款金额",required = false)
+	private java.math.BigDecimal subRefundAmount;
+
+	@ApiModelProperty(value = "是否完成回款",required = false)
+	private Boolean refundFlag = false;
+
+	@ApiModelProperty(value = "订单编号",required = false)
+	private String orderNos;
+	
+	/**  */
+	private java.util.Date createTime;
+	
+	/**  */
+	private java.util.Date updateTime;
+
+	public String getOrderNos() {
+		return orderNos;
+	}
+
+	public void setOrderNos(String orderNos) {
+		this.orderNos = orderNos;
+	}
+
+	public BigDecimal getIncome() {
+		return income;
+	}
+
+	public void setIncome(BigDecimal income) {
+		this.income = income;
+	}
+
+	public Boolean getRefundFlag() {
+		return refundFlag;
+	}
+
+	public void setRefundFlag(Boolean refundFlag) {
+		this.refundFlag = refundFlag;
+	}
+
+	public void setId(Integer id){
+		this.id = id;
+	}
+	
+	public Integer getId(){
+		return this.id;
+	}
+			
+	public void setOrganId(Integer organId){
+		this.organId = organId;
+	}
+	
+	public Integer getOrganId(){
+		return this.organId;
+	}
+			
+	public void setCooperationOrganId(Integer cooperationOrganId){
+		this.cooperationOrganId = cooperationOrganId;
+	}
+	
+	public Integer getCooperationOrganId(){
+		return this.cooperationOrganId;
+	}
+			
+	public void setCalenderId(Long calenderId){
+		this.calenderId = calenderId;
+	}
+	
+	public Long getCalenderId(){
+		return this.calenderId;
+	}
+			
+	public void setRefundDate(String refundDate){
+		this.refundDate = refundDate;
+	}
+	
+	public String getRefundDate(){
+		return this.refundDate;
+	}
+			
+	public void setRefundAmount(java.math.BigDecimal refundAmount){
+		this.refundAmount = refundAmount;
+	}
+	
+	public java.math.BigDecimal getRefundAmount(){
+		return this.refundAmount;
+	}
+			
+	public void setSubRefundAmount(java.math.BigDecimal subRefundAmount){
+		this.subRefundAmount = subRefundAmount;
+	}
+	
+	public java.math.BigDecimal getSubRefundAmount(){
+		return this.subRefundAmount;
+	}
+			
+	public void setCreateTime(java.util.Date createTime){
+		this.createTime = createTime;
+	}
+	
+	public java.util.Date getCreateTime(){
+		return this.createTime;
+	}
+			
+	public void setUpdateTime(java.util.Date updateTime){
+		this.updateTime = updateTime;
+	}
+	
+	public java.util.Date getUpdateTime(){
+		return this.updateTime;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 55 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalender.java

@@ -205,6 +205,53 @@ public class MusicGroupPaymentCalender extends BaseEntity {
 	
 	@ApiModelProperty(value = "缴费项目显示状态", required = false)
 	private String paymentItemShowState;
+	
+	@ApiModelProperty(value = "是否显示销售价", required = false)
+	private Boolean isShowSalePrice;
+
+	@ApiModelProperty(value = "学校缴费计价json", required = false)
+	private String calenderFeeJson;
+
+	@ApiModelProperty(value = "学校缴费计价标准,STUDENT、TEACHER", required = false)
+	private String calenderFeeType;
+
+	@ApiModelProperty(value = "合同", required = false)
+	private String contractUrl;
+
+	@ApiModelProperty(value = "缴费项目名称", required = false)
+	private String name;
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getContractUrl() {
+		return contractUrl;
+	}
+
+	public void setContractUrl(String contractUrl) {
+		this.contractUrl = contractUrl;
+	}
+
+	public String getCalenderFeeJson() {
+		return calenderFeeJson;
+	}
+
+	public void setCalenderFeeJson(String calenderFeeJson) {
+		this.calenderFeeJson = calenderFeeJson;
+	}
+
+	public String getCalenderFeeType() {
+		return calenderFeeType;
+	}
+
+	public void setCalenderFeeType(String calenderFeeType) {
+		this.calenderFeeType = calenderFeeType;
+	}
 
 	public Boolean getCloudTeacherPaymentFlag() {
 		return cloudTeacherPaymentFlag;
@@ -502,6 +549,14 @@ public class MusicGroupPaymentCalender extends BaseEntity {
 		this.paymentItemShowState = paymentItemShowState;
 	}
 
+	public Boolean getIsShowSalePrice() {
+		return isShowSalePrice;
+	}
+
+	public void setIsShowSalePrice(Boolean isShowSalePrice) {
+		this.isShowSalePrice = isShowSalePrice;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

+ 9 - 6
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderCourseSettings.java

@@ -1,10 +1,13 @@
 package com.ym.mec.biz.dal.entity;
 
+import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
 import com.ym.mec.common.entity.BaseEntity;
 
+import java.math.BigDecimal;
+
 /**
  * 对应数据库表(music_group_payment_calender_course_settings):
  */
@@ -19,22 +22,22 @@ public class MusicGroupPaymentCalenderCourseSettings extends BaseEntity {
 	/**  */
 	private String name;
 	
-	/** 课程类型 */
+	@ApiModelProperty(value = "课程类型", required = false)
 	private CourseSchedule.CourseScheduleType courseType;
 
-	/** 课程总时间 */
+	@ApiModelProperty(value = "课程总时间", required = false)
 	private Integer courseTotalMinuties;
 	
-	/** 单价 */
+	@ApiModelProperty(value = "单价", required = false)
 	private java.math.BigDecimal unitPrice;
 	
-	/** 课程原价 */
+	@ApiModelProperty(value = "课程原价", required = false)
 	private java.math.BigDecimal courseOriginalPrice;
 	
-	/** 课程现价 */
+	@ApiModelProperty(value = "课程现价", required = false)
 	private java.math.BigDecimal courseCurrentPrice;
 	
-	/** 是否学生可选 */
+	@ApiModelProperty(value = "是否学生可选", required = false)
 	private boolean isStudentOptional = true;
 	
 	/**  */

+ 56 - 15
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentStudentCourseDetail.java

@@ -2,7 +2,6 @@ package com.ym.mec.biz.dal.entity;
 
 import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
 import com.ym.mec.common.entity.BaseEntity;
-
 import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
@@ -13,36 +12,78 @@ import java.math.BigDecimal;
  */
 public class MusicGroupPaymentStudentCourseDetail extends BaseEntity {
 
-	/**  */
+	@ApiModelProperty(value = "乐团编号", required = false)
+	private String musicGroupId;
+
 	private Long id;
-	
-	/**  */
+
+	@ApiModelProperty(value = "缴费项目编号", required = false)
 	private Long musicGroupPaymentCalenderId;
-	
-	/**  */
+
+	@ApiModelProperty(value = "缴费项目详情编号", required = false)
 	private Long musicGroupPaymentCalenderDetailId;
-	
-	/**  */
+
 	private Integer userId;
-	
-	/**  */
+
+	@ApiModelProperty(value = "课程类型", required = false)
 	private CourseScheduleType courseType;
-	
-	/**  */
+
+	@ApiModelProperty(value = "总课时数", required = false)
 	private Integer totalCourseMinutes;
 
-	/**  */
+	@ApiModelProperty(value = "课程原价", required = false)
 	private BigDecimal courseOriginalPrice;
 
-	/**  */
+	@ApiModelProperty(value = "课程现价", required = false)
 	private BigDecimal courseCurrentPrice;
 
-	/**  已消耗时长*/
+	@ApiModelProperty(value = "剩余可排课课程原价", required = false)
+	private java.math.BigDecimal subCourseOriginalPrice;
+
+	@ApiModelProperty(value = "剩余可排课课程现价", required = false)
+	private java.math.BigDecimal subCourseCurrentPrice;
+
+	@ApiModelProperty(value = "已消耗时长", required = false)
 	private Integer usedCourseMinutes;
 
+	@ApiModelProperty(value = "剩余课程时长", required = false)
+	private Integer subCourseMinutes;
+
 	@ApiModelProperty(value = "标记是否云教练缴费项目",required = false)
 	private Boolean cloudTeacherPaymentFlag = false;
 
+	public BigDecimal getSubCourseOriginalPrice() {
+		return subCourseOriginalPrice;
+	}
+
+	public void setSubCourseOriginalPrice(BigDecimal subCourseOriginalPrice) {
+		this.subCourseOriginalPrice = subCourseOriginalPrice;
+	}
+
+	public BigDecimal getSubCourseCurrentPrice() {
+		return subCourseCurrentPrice;
+	}
+
+	public void setSubCourseCurrentPrice(BigDecimal subCourseCurrentPrice) {
+		this.subCourseCurrentPrice = subCourseCurrentPrice;
+	}
+
+	public Integer getSubCourseMinutes() {
+		return subCourseMinutes;
+	}
+
+	public void setSubCourseMinutes(Integer subCourseMinutes) {
+		this.subCourseMinutes = subCourseMinutes;
+	}
+
+	public String getMusicGroupId() {
+		return musicGroupId;
+	}
+
+	public void setMusicGroupId(String musicGroupId) {
+		this.musicGroupId = musicGroupId;
+	}
+
 	public Boolean getCloudTeacherPaymentFlag() {
 		return cloudTeacherPaymentFlag;
 	}

+ 70 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPlanMaking.java

@@ -0,0 +1,70 @@
+package com.ym.mec.biz.dal.entity;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(music_group_plan_making):
+ */
+public class MusicGroupPlanMaking {
+
+	/**  */
+	private Integer id;
+	
+	/**  */
+	private String name;
+	
+	/**  */
+	private String subjectIdList;
+	
+	/**  */
+	private java.util.Date createTime;
+	
+	/**  */
+	private java.util.Date updateTime;
+	
+	public void setId(Integer id){
+		this.id = id;
+	}
+	
+	public Integer getId(){
+		return this.id;
+	}
+			
+	public void setName(String name){
+		this.name = name;
+	}
+	
+	public String getName(){
+		return this.name;
+	}
+			
+	public void setSubjectIdList(String subjectIdList){
+		this.subjectIdList = subjectIdList;
+	}
+	
+	public String getSubjectIdList(){
+		return this.subjectIdList;
+	}
+			
+	public void setCreateTime(java.util.Date createTime){
+		this.createTime = createTime;
+	}
+	
+	public java.util.Date getCreateTime(){
+		return this.createTime;
+	}
+			
+	public void setUpdateTime(java.util.Date updateTime){
+		this.updateTime = updateTime;
+	}
+	
+	public java.util.Date getUpdateTime(){
+		return this.updateTime;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

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

@@ -78,6 +78,9 @@ public class MusicGroupSubjectGoodsGroup extends BaseEntity {
 	/** 打包价格 */
 	@ApiModelProperty(value = "打包价格",required = false)
 	private BigDecimal price = new BigDecimal(0);
+	
+	@ApiModelProperty(value = "分部分润金额",required = false)
+	private BigDecimal organShareProfit;
 
 	public List<String> getGoodsName() {
 		return goodsName;
@@ -228,4 +231,12 @@ public class MusicGroupSubjectGoodsGroup extends BaseEntity {
 	public void setChildGoodsList(List<Goods> childGoodsList) {
 		this.childGoodsList = childGoodsList;
 	}
+
+	public BigDecimal getOrganShareProfit() {
+		return organShareProfit;
+	}
+
+	public void setOrganShareProfit(BigDecimal organShareProfit) {
+		this.organShareProfit = organShareProfit;
+	}
 }

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

@@ -2,6 +2,7 @@ package com.ym.mec.biz.dal.entity;
 
 import io.swagger.annotations.ApiModelProperty;
 
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 
@@ -44,6 +45,8 @@ public class Organization extends BaseEntity {
 	
 	private String corporateFinancialSeal;
 	
+	private BigDecimal maxMusicalInstrumentsProfits;
+	
 	/** 创建时间 */
 	private Date createTime;
 	
@@ -213,4 +216,12 @@ public class Organization extends BaseEntity {
 		this.corporateFinancialSeal = corporateFinancialSeal;
 	}
 
+	public BigDecimal getMaxMusicalInstrumentsProfits() {
+		return maxMusicalInstrumentsProfits;
+	}
+
+	public void setMaxMusicalInstrumentsProfits(BigDecimal maxMusicalInstrumentsProfits) {
+		this.maxMusicalInstrumentsProfits = maxMusicalInstrumentsProfits;
+	}
+
 }

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/IndexErrorType.java

@@ -24,6 +24,8 @@ public enum IndexErrorType implements BaseEnum<String, IndexErrorType> {
     ATTENDANCE_ERR_STUDENT_NUM("COURSE_TRUANT_STUDENT_NUM", "学员考勤异常"),
     COURSE_TRUANT_STUDENT_NUM("COURSE_TRUANT_STUDENT_NUM", "学员旷课"),
     COURSE_LEAVE_STUDENT_NUM("COURSE_LEAVE_STUDENT_NUM", "学员请假"),
+    COOPERATION_PAYMENT_ERROR("COOPERATION_PAYMENT_ERROR", "合作单位回款异常"),
+    COOPERATION_PAYMENT_ALERT("COOPERATION_PAYMENT_ALERT", "合作单位回款提醒"),
 
     TEACHER_INFO("TEACHER_INFO", "日常行政"),
 

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

@@ -4,7 +4,7 @@ import com.ym.mec.common.enums.BaseEnum;
 
 public enum MusicGroupStatusEnum implements BaseEnum<String, MusicGroupStatusEnum> {
 	DRAFT("草稿"), AUDIT("审核中"), AUDIT_FAILED("审核失败"), PRE_APPLY("预报名"), PRE_BUILD_FEE("创建缴费"),
-	FEE_AUDIT("费用审核中"), APPLY("报名中"), PAY("缴费中"), PREPARE("筹备中"), PROGRESS(
+	FEE_AUDIT("费用审核中"),FEE_AUDIT_FAILED("费用审核失败"), APPLY("报名中"), PAY("缴费中"), PREPARE("筹备中"), PROGRESS(
 			"进行中"), CANCELED("取消"), PAUSE("暂停"), CLOSE("关闭");
 
 	private String msg;

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/OrderDetailTypeEnum.java

@@ -30,7 +30,8 @@ public enum OrderDetailTypeEnum implements BaseEnum<String, OrderDetailTypeEnum>
     CLOUD_TEACHER("CLOUD_TEACHER","云教练"),
     CLOUD_TEACHER_PLUS("CLOUD_TEACHER_PLUS","云教练"),
     THEORY_COURSE("THEORY_COURSE", "乐理课"),
-    REPAIR("REPAIR", "乐器维修");
+    REPAIR("REPAIR", "乐器维修"),
+    ORGAN_SHARE_PROFIT("ORGAN_SHARE_PROFIT", "分部分润");
 
     private String code;
 

+ 73 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/CooperationRefundQueryInfo.java

@@ -0,0 +1,73 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+public class CooperationRefundQueryInfo extends QueryInfo {
+
+    @ApiModelProperty(value = "合作单位编号",required = false)
+    private Integer cooperationId;
+
+    @ApiModelProperty(value = "分部",required = false)
+    private String organId;
+
+    @ApiModelProperty(value = "回访状态",required = false)
+    private String refundStatus;
+
+    @ApiModelProperty(value = "缴费开始时间",required = false)
+    private String refundStartDate;
+
+    @ApiModelProperty(value = "缴费结束时间",required = false)
+    private String refundEndDate;
+
+    @ApiModelProperty(value = "异常类型,COOPERATION_PAYMENT_ERROR 回款异常,COOPERATION_PAYMENT_ALERT 回款提醒",required = false)
+    private String errorType;
+
+    public String getErrorType() {
+        return errorType;
+    }
+
+    public void setErrorType(String errorType) {
+        this.errorType = errorType;
+    }
+
+    public Integer getCooperationId() {
+        return cooperationId;
+    }
+
+    public void setCooperationId(Integer cooperationId) {
+        this.cooperationId = cooperationId;
+    }
+
+    public String getRefundStatus() {
+        return refundStatus;
+    }
+
+    public void setRefundStatus(String refundStatus) {
+        this.refundStatus = refundStatus;
+    }
+
+    public String getRefundStartDate() {
+        return refundStartDate;
+    }
+
+    public void setRefundStartDate(String refundStartDate) {
+        this.refundStartDate = refundStartDate;
+    }
+
+    public String getRefundEndDate() {
+        return refundEndDate;
+    }
+
+    public void setRefundEndDate(String refundEndDate) {
+        this.refundEndDate = refundEndDate;
+    }
+
+    public String getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(String organId) {
+        this.organId = organId;
+    }
+}

+ 44 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/CooperationShareProfitQueryInfo.java

@@ -0,0 +1,44 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+* @author zx
+* @date 2021/9/26 15:52
+*/
+public class CooperationShareProfitQueryInfo extends QueryInfo {
+
+    @ApiModelProperty(value = "分部",required = false)
+    private String organId;
+
+    @ApiModelProperty(value = "合作单位编号",required = false)
+    private Integer cooperationOrganId;
+
+    @ApiModelProperty(value = "付款状态",required = false)
+    private String paymentStatus;
+
+    public String getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(String organId) {
+        this.organId = organId;
+    }
+
+    public Integer getCooperationOrganId() {
+        return cooperationOrganId;
+    }
+
+    public void setCooperationOrganId(Integer cooperationOrganId) {
+        this.cooperationOrganId = cooperationOrganId;
+    }
+
+    public String getPaymentStatus() {
+        return paymentStatus;
+    }
+
+    public void setPaymentStatus(String paymentStatus) {
+        this.paymentStatus = paymentStatus;
+    }
+}

+ 18 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/CooperationShareProfitService.java

@@ -0,0 +1,18 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.CooperationShareProfit;
+import com.ym.mec.biz.dal.entity.CooperationShareProfitDto;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.page.QueryInfo;
+import com.ym.mec.common.service.BaseService;
+
+import java.util.List;
+
+public interface CooperationShareProfitService extends BaseService<Integer, CooperationShareProfit> {
+
+    PageInfo<CooperationShareProfitDto> queryDtoPage(QueryInfo queryInfo);
+
+    void init(List<Long> courseIds);
+
+    void addCredentials(CooperationShareProfit profit);
+}

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

@@ -153,4 +153,6 @@ public interface CourseScheduleStudentPaymentService extends BaseService<Long, C
 	* @date 2022/9/26 18:08
 	*/
     void splitStudentPayment(List<CourseScheduleStudentPayment> courseScheduleStudentPayments,List<CourseScheduleStudentPayment> studentPayments);
+
+    CourseScheduleStudentPayment init(CourseSchedule courseSchedule);
 }

+ 38 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupCalenderRefundPeriodService.java

@@ -0,0 +1,38 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.dto.CooperationCalenderRefundDto;
+import com.ym.mec.biz.dal.dto.CooperationRefundDto;
+import com.ym.mec.biz.dal.dto.MusicGroupPaymentBaseCalender;
+import com.ym.mec.biz.dal.entity.MusicGroupCalenderRefundPeriod;
+import com.ym.mec.biz.dal.page.CooperationRefundQueryInfo;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.service.BaseService;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+public interface MusicGroupCalenderRefundPeriodService extends BaseService<Integer, MusicGroupCalenderRefundPeriod> {
+
+    void savePeriod(MusicGroupPaymentBaseCalender musicGroupPaymentBaseCalender);
+
+    List<MusicGroupCalenderRefundPeriod> findByCalenderId(Long calenderId);
+
+    PageInfo<CooperationRefundDto> queryCoopRefund(CooperationRefundQueryInfo queryInfo);
+
+    BigDecimal sumCoopRefund(CooperationRefundQueryInfo queryInfo);
+
+
+    PageInfo<CooperationCalenderRefundDto> queryCoopCalender(CooperationRefundQueryInfo queryInfo);
+
+    void deleteByCalenderId(Long id);
+
+    /**
+    * @description: 学校缴费回款
+     * @param calenderId
+     * @param amount
+    * @return void
+    * @author zx
+    * @date 2022/10/19 11:20
+    */
+    Boolean calcRefundAmount(Long calenderId,String orderNo, BigDecimal amount);
+}

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

@@ -89,17 +89,6 @@ public interface MusicGroupPaymentCalenderService extends BaseService<Long, Musi
 	boolean deleteByBatchNo(String batchNo);
 
 	/**
-	 * @describe 更新乐团学员缴费状态
-	 * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
-	 * @author zouxuan
-	 * @date 2020/9/21
-	 * @time 13:56
-	 * @param :
-	 * @return void
-	 */
-	void autoUpdateMusicGroupStudentFeeStatus();
-
-	/**
 	 * @describe 乐团缴费日历审核列表
 	 * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
 	 * @author zouxuan

+ 0 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentStudentCourseDetailService.java

@@ -1,13 +1,8 @@
 package com.ym.mec.biz.service;
 
-import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
 import com.ym.mec.common.service.BaseService;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
 
 public interface MusicGroupPaymentStudentCourseDetailService extends BaseService<Long, MusicGroupPaymentStudentCourseDetail> {
 
-    String getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(String musicGroupId,Integer studentId,CourseSchedule.CourseScheduleType courseType,List<String> batchNos);
 }

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

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

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

@@ -1967,12 +1967,12 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             return classGroup;
         }
 
-        List<Integer> allTeacherIds = classGroupTeacherMapperList.stream()
-                .map(ClassGroupTeacherMapper::getUserId)
-                .collect(Collectors.toList());
+//        List<Integer> allTeacherIds = classGroupTeacherMapperList.stream()
+//                .map(ClassGroupTeacherMapper::getUserId)
+//                .collect(Collectors.toList());
 
         //所有教师列表
-        List<Teacher> teachers = teacherDao.findByTeacherIds(allTeacherIds);
+//        List<Teacher> teachers = teacherDao.findByTeacherIds(allTeacherIds);
         Map<String, Integer> courseTypeMinutesMap = musicGroupPaymentCalenderCourseSettingsService.getMusicCourseSettingsWithStudents(musicGroupId, studentIdList);
 
         //计算每节课的课酬

+ 106 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CooperationShareProfitServiceImpl.java

@@ -0,0 +1,106 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dao.CourseScheduleDao;
+import com.ym.mec.biz.dal.dao.TeacherDao;
+import com.ym.mec.biz.dal.entity.CooperationShareProfitDto;
+import com.ym.mec.biz.dal.entity.CourseSchedule;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.page.QueryInfo;
+import com.ym.mec.util.collection.MapUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.biz.dal.entity.CooperationShareProfit;
+import com.ym.mec.biz.service.CooperationShareProfitService;
+import com.ym.mec.biz.dal.dao.CooperationShareProfitDao;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Service
+public class CooperationShareProfitServiceImpl extends BaseServiceImpl<Integer, CooperationShareProfit>  implements CooperationShareProfitService {
+	
+	@Autowired
+	private CooperationShareProfitDao cooperationShareProfitDao;
+	@Autowired
+	private CourseScheduleDao courseScheduleDao;
+	@Autowired
+	private TeacherDao teacherDao;
+
+	@Override
+	public BaseDAO<Integer, CooperationShareProfit> getDAO() {
+		return cooperationShareProfitDao;
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public PageInfo<CooperationShareProfitDto> queryDtoPage(QueryInfo queryInfo){
+		PageInfo<CooperationShareProfitDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+		Map<String, Object> params = new HashMap<>();
+		MapUtil.populateMap(params, queryInfo);
+
+		List<CooperationShareProfitDto> dataList = null;
+		int count = cooperationShareProfitDao.countDto(params);
+		if (count > 0) {
+			pageInfo.setTotal(count);
+			params.put("offset", pageInfo.getOffset());
+			dataList = cooperationShareProfitDao.queryDtoPage(params);
+			List<Integer> eduUserIds = dataList.stream().map(e -> e.getEducationUserId()).distinct().collect(Collectors.toList());
+			List<String> groupIds = dataList.stream().map(e -> e.getMusicGroupId()).distinct().collect(Collectors.toList());
+			List<Integer> organIds = dataList.stream().map(e -> e.getOrganId()).distinct().collect(Collectors.toList());
+			Map<Integer, String> eduNameMap = MapUtil.convertMybatisMap(teacherDao.queryNameByIdList(eduUserIds));
+			Map<Integer, String> organNameMap = getMap("organization", "id_", "name_", organIds,queryInfo.getTenantId(), Integer.class, String.class);
+			Map<String, String> groupNameMap = getMap("music_group", "id_", "name_", groupIds,queryInfo.getTenantId(), String.class, String.class);
+			for (CooperationShareProfitDto dto : dataList) {
+				dto.setEducationUserName(eduNameMap.get(dto.getEducationUserId()));
+				dto.setOrganName(organNameMap.get(dto.getOrganId()));
+				dto.setMusicGroupName(groupNameMap.get(dto.getMusicGroupId()));
+			}
+		}
+		if (count == 0) {
+			dataList = new ArrayList<>();
+		}
+		pageInfo.setRows(dataList);
+		return pageInfo;
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void init(List<Long> courseIds) {
+		if(CollectionUtils.isEmpty(courseIds)){
+			return;
+		}
+		List<CourseSchedule> courseSchedules = courseScheduleDao.findByCourseScheduleIds(courseIds);
+		List<String> musicGroupIds = courseSchedules.stream().map(e -> e.getMusicGroupId()).distinct().collect(Collectors.toList());
+		musicGroupIds.removeAll(cooperationShareProfitDao.queryNotShare(musicGroupIds));
+		musicGroupIds.removeAll(Collections.singleton(null));
+		if(CollectionUtils.isEmpty(musicGroupIds)){
+			return;
+		}
+		List<CooperationShareProfit> profits = cooperationShareProfitDao.initShareProfit(musicGroupIds);
+		if(CollectionUtils.isEmpty(profits)){
+			return;
+		}
+		cooperationShareProfitDao.batchInsert(profits);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void addCredentials(CooperationShareProfit profit) {
+		CooperationShareProfit shareProfit = Optional.
+				ofNullable(cooperationShareProfitDao.get(profit.getId())).orElseThrow(()->new BizException("分润信息不存在"));
+		if(StringUtils.equals(shareProfit.getPaymentStatus(),"PAID_COMPLETED")){
+			throw new BizException("操作失败:请勿重复录入");
+		}
+		shareProfit.setCredentials(profit.getCredentials());
+		shareProfit.setPaymentNo(profit.getPaymentNo());
+		shareProfit.setMemo(profit.getMemo());
+		shareProfit.setPaymentStatus("PAID_COMPLETED");
+		cooperationShareProfitDao.update(shareProfit);
+	}
+}

+ 85 - 72
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java

@@ -73,6 +73,8 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 	private MusicGroupStudentClassAdjustDao musicGroupStudentClassAdjustDao;
 	@Autowired
 	private StudentPaymentOrderDao studentPaymentOrderDaop;
+	@Autowired
+	private OrganizationCourseUnitPriceSettingsDao organizationCourseUnitPriceSettingsDao;
 
 	@Override
 	public BaseDAO<Long, CourseScheduleStudentPayment> getDAO() {
@@ -326,7 +328,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				}
 				//处理缴费的排课信息
 				if(musicGroupPaymentStudentCourseDetails == null){
-					musicGroupPaymentStudentCourseDetails = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(batchNo, studentId,courseSchedule.getType());
+					musicGroupPaymentStudentCourseDetails = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(studentId,courseSchedule.getType(),courseSchedule.getMusicGroupId());
 				}
 				if(musicGroupPaymentStudentCourseDetails == null || musicGroupPaymentStudentCourseDetails.size() == 0){
 					throw new BizException("学员缴费详情获取失败");
@@ -389,8 +391,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
 	public void createForMusicGroup(String musicGroupId, List<CourseSchedule> courseSchedules, List<Integer> studentIds) {
 		Map<Integer, List<CourseSchedule>> memberCourseMap = courseSchedules.stream().collect(Collectors.groupingBy(CourseSchedule::getMemberFlag));
-		//课程是否需要标记为云教练赠送
-		Boolean cloudTeacherPaymentFlag = false;
+		List<Long> operatingCourse = new ArrayList<>();
 		Long calenderId = null;
 		for (Integer memberFlag : memberCourseMap.keySet()) {
 			List<CourseSchedule> courseScheduleList = memberCourseMap.get(memberFlag);
@@ -426,8 +427,6 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 
 					List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
 
-					List<String> allBatchNos = new ArrayList<>();
-
 					for (Integer studentId : studentIds) {
 						Set<Long> existCourseIds = new HashSet<>();
 						if(studentCourseIdsMap.containsKey(studentId)){
@@ -437,11 +436,9 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 							//当前课程类型总课程时长
 							Integer typeCourseDuration = courseTypeCourseDurationMap.get(courseScheduleTypeListEntry.getKey()).get(studentId);
 
-							String batchNo = musicGroupPaymentStudentCourseDetailDao.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, studentId, courseScheduleTypeListEntry.getKey(),null);
-
-							List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(batchNo, studentId, courseScheduleTypeListEntry.getKey());
-							int totalCourseMinutes = musicGroupPaymentStudentCourseDetails.stream().mapToInt(MusicGroupPaymentStudentCourseDetail::getTotalCourseMinutes).reduce(0, Integer::sum);
-							if(CollectionUtils.isEmpty(musicGroupPaymentStudentCourseDetails) || totalCourseMinutes < typeCourseDuration){
+							List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(studentId, courseScheduleTypeListEntry.getKey(),musicGroupId);
+							int subCourseMinutes = musicGroupPaymentStudentCourseDetails.stream().mapToInt(MusicGroupPaymentStudentCourseDetail::getSubCourseMinutes).reduce(0, Integer::sum);
+							if(CollectionUtils.isEmpty(musicGroupPaymentStudentCourseDetails) || subCourseMinutes < typeCourseDuration){
 								SysUser user = teacherDao.getUser(studentId);
 								throw new BizException("{}在{}课程类型上的课程时长不足", user.getUsername(), courseScheduleTypeListEntry.getKey().getMsg());
 							}
@@ -453,29 +450,8 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 								throw new BizException("缴费设置异常");
 							}
 
-							List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalendersAndCourseType(calenderIds, courseScheduleTypeListEntry.getKey());
-							int originalCourseTotalMinutes = musicGroupPaymentCalenderCourseSettings.stream().mapToInt(MusicGroupPaymentCalenderCourseSettings::getCourseTotalMinuties).reduce(0, Integer::sum);
-							if(Objects.isNull(musicGroupPaymentCalenderCourseSettings)||originalCourseTotalMinutes!=totalCourseMinutes){
-								throw new BizException("缴费设置异常");
-							}
-
-							allBatchNos.add(batchNo);
-
-							BigDecimal totalCourseOriginalPrice = musicGroupPaymentCalenderCourseSettings.stream().map(MusicGroupPaymentCalenderCourseSettings::getCourseOriginalPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
-							BigDecimal totalCourseCurrentPrice = musicGroupPaymentCalenderCourseSettings.stream().map(MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
-
-							//课程每分钟原价
-							BigDecimal unitMinuteOriginalPrice = totalCourseOriginalPrice.divide(new BigDecimal(originalCourseTotalMinutes), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
-							//课程每分钟现价
-							BigDecimal unitMinuteCurrentPrice = totalCourseCurrentPrice.divide(new BigDecimal(originalCourseTotalMinutes), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
-
-							if(MusicGroupPaymentCalender.PayUserType.SCHOOL.equals(musicGroupPaymentCalenders.get(0).getPayUserType())){
-								unitMinuteCurrentPrice = new BigDecimal("0");
-							}
-
 							List<CourseScheduleStudentPayment> typeCourseStudentPayments = new ArrayList<>();
 							courseScheduleTypeListEntry.getValue().sort(Comparator.comparing(CourseSchedule::getStartClassTime));
-							BigDecimal typeCourseTotalOriginalPrice = new BigDecimal("0"), typeCourseTotalCurrentPrice = new BigDecimal("0");
 							List<CourseSchedule> scheduleList = courseScheduleTypeListEntry.getValue();
 							for (CourseSchedule courseSchedule : scheduleList) {
 								if(existCourseIds.contains(courseSchedule.getId())){
@@ -483,48 +459,16 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 								}
 								//课程时长
 								int courseDuration = DateUtil.minutesBetween(courseSchedule.getStartClassTime(), courseSchedule.getEndClassTime());
-
-								//课程原价
-								BigDecimal courseOriginalPrice = unitMinuteOriginalPrice.multiply(new BigDecimal(courseDuration)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
-								typeCourseTotalOriginalPrice = typeCourseTotalOriginalPrice.add(courseOriginalPrice);
-
-								//课程现价
-								BigDecimal courseCurrentPrice = unitMinuteCurrentPrice.multiply(new BigDecimal(courseDuration)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
-								typeCourseTotalCurrentPrice = typeCourseTotalCurrentPrice.add(courseCurrentPrice);
-
-								CourseScheduleStudentPayment cssp = new CourseScheduleStudentPayment();
-								cssp.setGroupType(courseSchedule.getGroupType());
-								cssp.setMusicGroupId(courseSchedule.getMusicGroupId());
-								cssp.setCourseScheduleId(courseSchedule.getId());
-								cssp.setClassGroupId(courseSchedule.getClassGroupId());
-								cssp.setBatchNo(batchNo);
+								CourseScheduleStudentPayment cssp = this.init(courseSchedule);
 								cssp.setUserId(studentId);
-								cssp.setOriginalPrice(courseOriginalPrice);
-								cssp.setExpectPrice(courseCurrentPrice);
-								cssp.setActualPrice(BigDecimal.ZERO);
-								cssp.setBeMerged(false);
+								//扣除可排课时长
+								if(this.calcCourseMinutes(musicGroupPaymentStudentCourseDetails,courseDuration,cssp,musicGroupPaymentCalenders)){
+									//课程是否需要标记为云教练赠送
+									operatingCourse.add(courseSchedule.getId());
+								}
 								typeCourseStudentPayments.add(cssp);
 							}
-
-							typeCourseStudentPayments.get(0).setOriginalPrice(typeCourseStudentPayments.get(0).getOriginalPrice().add(totalCourseOriginalPrice.subtract(typeCourseTotalOriginalPrice)));
-							if(MusicGroupPaymentCalender.PayUserType.STUDENT.equals(musicGroupPaymentCalenders.get(0).getPayUserType())) {
-								typeCourseStudentPayments.get(0).setExpectPrice(typeCourseStudentPayments.get(0).getExpectPrice().add(totalCourseCurrentPrice.subtract(typeCourseTotalCurrentPrice)));
-							}
 							courseScheduleStudentPayments.addAll(typeCourseStudentPayments);
-							for (MusicGroupPaymentStudentCourseDetail detail : musicGroupPaymentStudentCourseDetails) {
-								if(typeCourseDuration>detail.getTotalCourseMinutes()){
-									detail.setUsedCourseMinutes(detail.getTotalCourseMinutes());
-									typeCourseDuration = typeCourseDuration-detail.getTotalCourseMinutes();
-								}else{
-									detail.setUsedCourseMinutes(typeCourseDuration);
-									typeCourseDuration = 0;
-								}
-								//如果是免费的云教练课程
-								if(detail.getCloudTeacherPaymentFlag() && !cloudTeacherPaymentFlag){
-									cloudTeacherPaymentFlag = true;
-									calenderId = detail.getMusicGroupPaymentCalenderId();
-								}
-							}
 							musicGroupPaymentStudentCourseDetailDao.batchUpdate(musicGroupPaymentStudentCourseDetails);
 						}
 					}
@@ -532,11 +476,68 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				}
 			}
 		}
-		if(cloudTeacherPaymentFlag){
-			operatingReportCloudService.updateSet(calenderId,courseSchedules.stream().map(e->e.getId()).collect(Collectors.toList()));
+		if(!CollectionUtils.isEmpty(operatingCourse)){
+			operatingReportCloudService.updateSet(calenderId,operatingCourse);
 		}
 	}
 
+	private Boolean calcCourseMinutes(List<MusicGroupPaymentStudentCourseDetail> courseDetails,
+									  Integer courseDuration,
+									  CourseScheduleStudentPayment studentPayment,
+									  List<MusicGroupPaymentCalender> musicGroupPaymentCalenders){
+		Boolean result = true;
+		Integer courseMinutes = courseDuration;
+		Map<Long, List<MusicGroupPaymentCalender>> calenderMap = musicGroupPaymentCalenders.stream().collect(Collectors.groupingBy(MusicGroupPaymentCalender::getId));
+		for (int i = 0; i < courseDetails.size(); i++) {
+			MusicGroupPaymentStudentCourseDetail detail = courseDetails.get(i);
+			if(detail.getSubCourseMinutes() > 0){
+				if(!detail.getCloudTeacherPaymentFlag()){
+					result = false;
+				}
+				if(courseMinutes >= detail.getSubCourseMinutes()){
+					courseMinutes = courseMinutes - detail.getSubCourseMinutes();
+					detail.setUsedCourseMinutes(detail.getUsedCourseMinutes() + detail.getSubCourseMinutes());
+					detail.setSubCourseMinutes(0);
+					studentPayment.setOriginalPrice(studentPayment.getOriginalPrice().add(detail.getSubCourseOriginalPrice()));
+					studentPayment.setExpectPrice(studentPayment.getExpectPrice().add(detail.getSubCourseCurrentPrice()));
+					detail.setSubCourseCurrentPrice(BigDecimal.ZERO);
+					detail.setSubCourseOriginalPrice(BigDecimal.ZERO);
+				}else{
+					detail.setUsedCourseMinutes(detail.getUsedCourseMinutes() + courseMinutes);
+					detail.setSubCourseMinutes(detail.getSubCourseMinutes() - courseMinutes);
+					//课程每分钟现价
+					BigDecimal unitMinuteCurrentPrice = detail.getCourseCurrentPrice().divide(new BigDecimal(detail.getTotalCourseMinutes()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
+					BigDecimal unitMinuteOriginalPrice = detail.getCourseOriginalPrice().divide(new BigDecimal(detail.getTotalCourseMinutes()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
+					BigDecimal originalPrice = unitMinuteOriginalPrice.multiply(new BigDecimal(courseMinutes)).setScale(2, BigDecimal.ROUND_DOWN);
+					BigDecimal expectPrice = unitMinuteCurrentPrice.multiply(new BigDecimal(courseMinutes)).setScale(2, BigDecimal.ROUND_DOWN);
+					studentPayment.setOriginalPrice(studentPayment.getOriginalPrice().add(originalPrice));
+					studentPayment.setExpectPrice(studentPayment.getExpectPrice().add(expectPrice));
+					detail.setSubCourseCurrentPrice(detail.getSubCourseCurrentPrice().subtract(expectPrice));
+					detail.setSubCourseOriginalPrice(detail.getSubCourseOriginalPrice().subtract(originalPrice));
+					courseMinutes = 0;
+				}
+				MusicGroupPaymentCalender calender = calenderMap.get(detail.getMusicGroupPaymentCalenderId()).get(0);
+				if(StringUtils.isEmpty(studentPayment.getBatchNo())){
+					studentPayment.setBatchNo(calender.getBatchNo());
+				}else {
+					studentPayment.setBatchNo(studentPayment.getBatchNo() + "," + calender.getBatchNo());
+				}
+
+				if(MusicGroupPaymentCalender.PayUserType.SCHOOL.equals(calender.getPayUserType())){
+					studentPayment.setExpectPrice(BigDecimal.ZERO);
+				}
+				if(courseMinutes == 0){
+					return result;
+				}
+			}
+			if(i == courseDetails.size() - 1 && courseMinutes > 0){
+				throw new BizException("操作失败:学员可排课时长不足");
+			}
+		}
+		return result;
+	}
+
+
 	@Override
 	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
 	public void createForMemberMusicGroup(String musicGroupId, List<CourseSchedule> courseSchedules, List<Integer> studentIds) {
@@ -762,7 +763,19 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 		courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
     }
 
-    @Override
+	@Override
+	public CourseScheduleStudentPayment init(CourseSchedule courseSchedule) {
+		CourseScheduleStudentPayment cssp = new CourseScheduleStudentPayment();
+		cssp.setGroupType(courseSchedule.getGroupType());
+		cssp.setMusicGroupId(courseSchedule.getMusicGroupId());
+		cssp.setCourseScheduleId(courseSchedule.getId());
+		cssp.setClassGroupId(courseSchedule.getClassGroupId());
+		cssp.setActualPrice(BigDecimal.ZERO);
+		cssp.setBeMerged(false);
+		return cssp;
+	}
+
+	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void updateCourseActualPrice(List<String> groupIds, List<Integer> userIds, GroupType groupType) {
 		studentDao.lockUser(1);

+ 15 - 10
mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java

@@ -63,6 +63,8 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 	private StudentDao studentDao;
 	@Autowired
 	private SysEmployeePositionService employeePositionService;
+	@Autowired
+	private MusicGroupCalenderRefundPeriodDao musicGroupCalenderRefundPeriodDao;
 
 	private static ThreadLocal<Set<Integer>> organIds = new ThreadLocal<Set<Integer>>(){
 		@Override
@@ -732,16 +734,12 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			params.put("tenantId", tenantId);
 			twoChild.add(new IndexErrInfoDto(IndexErrorType.HAS_FREE_COURSE_TIMES, IndexErrorType.HAS_FREE_COURSE_TIMES.getMsg(), musicGroupDao.countHasFreeCourseTimes(params), null));
 
-			//乐团学员会员到期首页提醒
-//			List<StudentRegistration> studentRegistrations = studentRegistrationDao.queryMemberEndAutoQuitMusic(null,educationUserId,organIdsStr);
-//			IndexErrInfoDto noClassMusicGroupStudentInfo = new IndexErrInfoDto();
-//			Set<String> musicGroupIds = studentRegistrations.stream().map(e -> e.getMusicGroupId()).collect(Collectors.toSet());
-//			Set<Integer> userIds = studentRegistrations.stream().map(e -> e.getUserId()).collect(Collectors.toSet());
-//			noClassMusicGroupStudentInfo.setErrorType(IndexErrorType.NO_MEMBER_STUDENT_INFO);
-//			noClassMusicGroupStudentInfo.setNum(musicGroupIds.size());
-//			noClassMusicGroupStudentInfo.setNum2(userIds.size());
-//			noClassMusicGroupStudentInfo.setDesc(IndexErrorType.NO_MEMBER_STUDENT_INFO.getMsg());
-//			twoChild.add(noClassMusicGroupStudentInfo);
+			//合作单位回款异常
+			Map<String, Object> params1 = new HashMap<>();
+			params1.put("organId", organIdsStr);
+			params1.put("errorType", "COOPERATION_PAYMENT_ERROR");
+			twoChild.add(new IndexErrInfoDto(IndexErrorType.COOPERATION_PAYMENT_ERROR, IndexErrorType.COOPERATION_PAYMENT_ERROR.getMsg(), musicGroupCalenderRefundPeriodDao.countCoopRefund(params1), null));
+
 			two.setNum(twoChild.stream().mapToInt(IndexErrInfoDto::getNum).sum());
 			two.setResult(twoChild);
 			all.add(two);
@@ -1126,6 +1124,13 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 		//乐团剩余时长未排课
 		List<String> musicGroupIds = musicGroupDao.queryHasSubCourseTimes(organIds,tenantId);
 		result.add(new IndexErrInfoDto(IndexErrorType.MUSIC_GROUP_HAS_COURSE_TIMES, IndexErrorType.MUSIC_GROUP_HAS_COURSE_TIMES.getMsg(),musicGroupIds.size(), null));
+
+		//合作单位回款提醒
+		Map<String, Object> params = new HashMap<>();
+		params.put("organId", organIds);
+		params.put("errorType", "COOPERATION_PAYMENT_ALERT");
+		result.add(new IndexErrInfoDto(IndexErrorType.COOPERATION_PAYMENT_ALERT, IndexErrorType.COOPERATION_PAYMENT_ALERT.getMsg(), musicGroupCalenderRefundPeriodDao.countCoopRefund(params), null));
+
 		return result;
 	}
 

+ 191 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupCalenderRefundPeriodServiceImpl.java

@@ -0,0 +1,191 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dao.MusicGroupCalenderRefundPeriodDao;
+import com.ym.mec.biz.dal.dao.MusicGroupDao;
+import com.ym.mec.biz.dal.dao.TeacherDao;
+import com.ym.mec.biz.dal.dto.CooperationCalenderRefundDto;
+import com.ym.mec.biz.dal.dto.CooperationRefundDto;
+import com.ym.mec.biz.dal.dto.MusicGroupPaymentBaseCalender;
+import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.MusicGroupCalenderRefundPeriod;
+import com.ym.mec.biz.dal.page.CooperationRefundQueryInfo;
+import com.ym.mec.biz.service.MusicGroupCalenderRefundPeriodService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.util.collection.MapUtil;
+import org.apache.commons.collections.CollectionUtils;
+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.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType.SCHOOL;
+
+@Service
+public class MusicGroupCalenderRefundPeriodServiceImpl extends BaseServiceImpl<Integer, MusicGroupCalenderRefundPeriod>  implements MusicGroupCalenderRefundPeriodService {
+
+    @Autowired
+    private MusicGroupCalenderRefundPeriodDao musicGroupCalenderRefundPeriodDao;
+    @Autowired
+    private MusicGroupDao musicGroupDao;
+    @Autowired
+    private TeacherDao teacherDao;
+
+    @Override
+    public BaseDAO<Integer, MusicGroupCalenderRefundPeriod> getDAO() {
+        return musicGroupCalenderRefundPeriodDao;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void savePeriod(MusicGroupPaymentBaseCalender baseCalender) {
+        if(baseCalender.getPayUserType() != SCHOOL || baseCalender.getCurrentTotalAmount().compareTo(BigDecimal.ZERO) == 0){
+            return;
+        }
+        List<MusicGroupCalenderRefundPeriod> refundPeriods = baseCalender.getMusicGroupCalenderRefundPeriods();
+        if(CollectionUtils.isEmpty(refundPeriods)){
+            throw new BizException("请录入回款周期");
+        }
+        MusicGroup musicGroup = musicGroupDao.get(baseCalender.getMusicGroupId());
+        Date date = new Date();
+        refundPeriods.forEach(e-> {
+            e.setCalenderId(baseCalender.getCalenderId());
+            e.setSubRefundAmount(e.getRefundAmount());
+            e.setOrganId(musicGroup.getOrganId());
+            e.setCooperationOrganId(musicGroup.getCooperationOrganId());
+            e.setCreateTime(date);
+            e.setUpdateTime(date);
+        });
+        musicGroupCalenderRefundPeriodDao.batchInsert(refundPeriods);
+    }
+
+    @Override
+    public List<MusicGroupCalenderRefundPeriod> findByCalenderId(Long calenderId) {
+        return musicGroupCalenderRefundPeriodDao.findByCalenderId(calenderId);
+    }
+
+    @Override
+    public PageInfo<CooperationRefundDto> queryCoopRefund(CooperationRefundQueryInfo queryInfo) {
+        PageInfo<CooperationRefundDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+        Map<String, Object> params = new HashMap<String, Object>();
+        MapUtil.populateMap(params, queryInfo);
+
+        List<CooperationRefundDto> dataList = null;
+        int count = musicGroupCalenderRefundPeriodDao.countCoopRefund(params);
+        if (count > 0) {
+            pageInfo.setTotal(count);
+            params.put("offset", pageInfo.getOffset());
+            dataList = musicGroupCalenderRefundPeriodDao.queryCoopRefund(params);
+            List<Integer> organIds = dataList.stream().map(e -> e.getOrganId()).distinct().collect(Collectors.toList());
+            List<Integer> eduUserIds = dataList.stream().map(e -> e.getEducationUserId()).distinct().collect(Collectors.toList());
+            Map<Integer, String> maps = MapUtil.convertIntegerMap(teacherDao.queryNameByIdList(eduUserIds));
+            Map<Integer, String> userOrganNameMap = this.getMap("organization","id_","name_",organIds,queryInfo.getTenantId(),Integer.class,String.class);
+            dataList.forEach(e->{
+                e.setEducationUserName(maps.get(e.getEducationUserId()));
+                e.setOrganName(userOrganNameMap.get(e.getOrganId()));
+                e.setIncome(e.getReceivable().subtract(e.getPrepaidFee()));
+            });
+        }
+        if (count == 0) {
+            dataList = new ArrayList<>();
+        }
+        pageInfo.setRows(dataList);
+        return pageInfo;
+    }
+
+    @Override
+    public BigDecimal sumCoopRefund(CooperationRefundQueryInfo queryInfo) {
+        Map<String, Object> params = new HashMap<String, Object>();
+        MapUtil.populateMap(params, queryInfo);
+        return musicGroupCalenderRefundPeriodDao.sumCoopRefund(params);
+    }
+
+    @Override
+    public PageInfo<CooperationCalenderRefundDto> queryCoopCalender(CooperationRefundQueryInfo queryInfo) {
+        PageInfo<CooperationCalenderRefundDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+        Map<String, Object> params = new HashMap<String, Object>();
+        MapUtil.populateMap(params, queryInfo);
+
+        List<CooperationCalenderRefundDto> dataList = null;
+        int count = musicGroupCalenderRefundPeriodDao.countCoopCalender(params);
+        if (count > 0) {
+            pageInfo.setTotal(count);
+            params.put("offset", pageInfo.getOffset());
+            dataList = musicGroupCalenderRefundPeriodDao.queryCoopCalender(params);
+            dataList.forEach(e->{
+                int compareTo = e.getPrepaidFee().compareTo(BigDecimal.ZERO);
+                e.setRefundStatus(compareTo > 0 ? "ING":"END");
+            });
+        }
+        if (count == 0) {
+            dataList = new ArrayList<>();
+        }
+        pageInfo.setRows(dataList);
+        return pageInfo;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void deleteByCalenderId(Long id) {
+        musicGroupCalenderRefundPeriodDao.deleteByCalenderId(id);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean calcRefundAmount(Long calenderId,String orderNo, BigDecimal amount) {
+        if(calenderId != null){
+            //获取回款周期
+            List<MusicGroupCalenderRefundPeriod> refundPeriods = musicGroupCalenderRefundPeriodDao.findByCalenderId(calenderId);
+            if(CollectionUtils.isNotEmpty(refundPeriods)){
+                Date date = new Date();
+                BigDecimal subAmount = amount;
+                for (int i = 0; i < refundPeriods.size(); i++) {
+                    MusicGroupCalenderRefundPeriod refundPeriod = refundPeriods.get(i);
+                    if(i == refundPeriods.size() - 1 && refundPeriod.getRefundFlag()){
+                        refundPeriod.setIncome(refundPeriod.getIncome().add(subAmount));
+                        if(StringUtils.isEmpty(refundPeriod.getOrderNos())){
+                            refundPeriod.setOrderNos(orderNo);
+                        }else {
+                            refundPeriod.setOrderNos(refundPeriod.getOrderNos() + "," + orderNo);
+                        }
+                        refundPeriod.setUpdateTime(date);
+                        break;
+                    }
+                    if(refundPeriod.getRefundFlag()){
+                        continue;
+                    }
+                    if(subAmount.compareTo(refundPeriod.getSubRefundAmount()) >= 0){
+                        if(i == refundPeriods.size() - 1){
+                            refundPeriod.setIncome(refundPeriod.getIncome().add(subAmount));
+                            subAmount = BigDecimal.ZERO;
+                        }else {
+                            refundPeriod.setIncome(refundPeriod.getIncome().add(refundPeriod.getSubRefundAmount()));
+                            subAmount = subAmount.subtract(refundPeriod.getSubRefundAmount());
+                        }
+                        refundPeriod.setSubRefundAmount(BigDecimal.ZERO);
+                        refundPeriod.setRefundFlag(true);
+                    }else {
+                        refundPeriod.setIncome(refundPeriod.getIncome().add(subAmount));
+                        refundPeriod.setSubRefundAmount(refundPeriod.getSubRefundAmount().subtract(subAmount));
+                        subAmount = BigDecimal.ZERO;
+                    }
+                    if(StringUtils.isEmpty(refundPeriod.getOrderNos())){
+                        refundPeriod.setOrderNos(orderNo);
+                    }else {
+                        refundPeriod.setOrderNos(refundPeriod.getOrderNos() + "," + orderNo);
+                    }
+                    refundPeriod.setUpdateTime(date);
+                }
+                musicGroupCalenderRefundPeriodDao.batchUpdate(refundPeriods);
+                return refundPeriods.get(refundPeriods.size()-1).getRefundFlag();
+            }
+        }
+        return false;
+    }
+}

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

@@ -73,7 +73,7 @@ public class MusicGroupPaymentCalenderCourseSettingsServiceImpl extends BaseServ
 			for (Map.Entry<Integer, List<MusicGroupPaymentStudentCourseDetail>> userDetailsEntry : userDetailsMap.entrySet()) {
 				details.add(userDetailsEntry.getValue().stream().min(Comparator.comparing(MusicGroupPaymentStudentCourseDetail::getId)).get());
 			}
-			result.put(courseTypeDetailsEntry.getKey().getCode(), details.stream().min(Comparator.comparing(MusicGroupPaymentStudentCourseDetail::getTotalCourseMinutes)).get().getTotalCourseMinutes());
+			result.put(courseTypeDetailsEntry.getKey().getCode(), details.stream().min(Comparator.comparing(MusicGroupPaymentStudentCourseDetail::getSubCourseMinutes)).get().getSubCourseMinutes());
 		}
 		//校验剩余时长是否一致
 		List<CourseSchedule.CourseScheduleType> courseTypes = mgpscds.stream().map(e -> e.getCourseType()).distinct().collect(Collectors.toList());

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

@@ -28,6 +28,7 @@ import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType.SCHOOL;
 import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType.STUDENT;
 import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum.AUDITING;
 import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.NON_PAYMENT;
@@ -183,13 +184,6 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
         }
         MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderList.get(0);
         String musicGroupId = musicGroupPaymentCalender.getMusicGroupId();
-        // 所有缴费项目已完成排课才能创建下一个缴费项目
-        List<String> batchNoList = new ArrayList<>();
-        batchNoList.add(batchNo);
-		/*String orignBatchNo = musicGroupPaymentStudentCourseDetailDao.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, null, null,batchNoList);
-		if (StringUtils.isNoneBlank(orignBatchNo)) {
-			throw new BizException("当前乐团存在未排课的缴费项目,请先完成排课再操作");
-		}*/
         //获取欠费学员列表
         List<Integer> noPaymentUserIds = musicGroupPaymentCalenderDetailDao.queryNoPaymentUserIds(musicGroupId, new ArrayList<>(userIdList), null);
         if (noPaymentUserIds.size() > 0) {
@@ -221,28 +215,11 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 
         List<MusicGroupPaymentCalenderCourseSettings> courseSettingsList = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalender(musicGroupPaymentCalenderId);
 
-        if (courseSettingsList != null && courseSettingsList.size() > 0) {
-            List<StudentSubTotalCourseTimesDto> studentCourseTypeDtos = musicGroupPaymentStudentCourseDetailDao.queryStudentSubTotalCourseTimes(musicGroupId);
-
-            Set<String> courseTypes = new HashSet<String>();
-            for (StudentSubTotalCourseTimesDto dto : studentCourseTypeDtos) {
-                if (userIdList.contains(dto.getUserId())) {
-                    courseTypes.addAll(dto.getMapDtos().stream().filter(t -> t.getValue() > 0).map(t -> t.getKey()).collect(Collectors.toSet()));
-                }
-            }
-
-            for (MusicGroupPaymentCalenderCourseSettings mgpccs : courseSettingsList) {
-                if (courseTypes.contains(mgpccs.getCourseType().name())) {
-                    throw new BizException("操作失败:存在未排完的[{}]", mgpccs.getCourseType().getMsg());
-                }
-            }
-        }
-
         Date date = new Date();
         MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
         Map<Integer, Long> userMap = new HashMap<>();
         Map<Integer, Integer> activityuserMap = new HashMap<>();
-        List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
+        List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<>();
         //创建缴费明细
         MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
 
@@ -270,7 +247,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
             musicGroupPaymentCalenderDetail.setDeadlinePaymentDate(musicGroupPaymentCalender.getDeadlinePaymentDate());
             musicGroupPaymentCalenderDetail.setResponsibleUserId(musicGroupPaymentCalender.getOperator());
             musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
-            if (musicGroupPaymentCalender.getCurrentTotalAmount().compareTo(BigDecimal.ZERO) == 0) {
+            if (musicGroupPaymentCalender.getCurrentTotalAmount().compareTo(BigDecimal.ZERO) == 0 || musicGroupPaymentCalender.getPayUserType() == SCHOOL) {
                 // 添加会员
                 if (calenderMember != null) {
                     CloudTeacherOrder cloudTeacherOrder = new CloudTeacherOrder();
@@ -281,7 +258,11 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
                     cloudTeacherOrder.setLevel(calenderMember.getMemberRankSettingId());
                     cloudTeacherOrder.setTime(calenderMember.getNum().intValue());
                     cloudTeacherOrder.setStatus(1);
-                    cloudTeacherOrder.setRemark("缴费项目0元新增学员");
+                    if(musicGroupPaymentCalender.getPayUserType() == SCHOOL){
+                        cloudTeacherOrder.setRemark("学校缴费新增学员");
+                    }else {
+                        cloudTeacherOrder.setRemark("缴费项目0元新增学员");
+                    }
                     cloudTeacherOrder.setMusicGroupId(musicGroupId);
                     cloudTeacherOrderService.save(cloudTeacherOrder,calenderMember.getAutoActivationFlag());
                 }
@@ -297,6 +278,11 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
                         activityUserMapper.setUserId(studentId);
                         activityUserMapper.setTeacherId(student.getTeacherId());
                         activityUserMapper.setOrganId(musicGroup.getOrganId());
+                        if(musicGroupPaymentCalender.getPayUserType() == SCHOOL){
+                            activityUserMapper.setAddMemo("学校缴费新增学员");
+                        }else {
+                            activityUserMapper.setAddMemo("缴费项目0元新增学员");
+                        }
                         VipGroupActivity activity = collect.get(activityUserMapper.getActivityId());
                         activityUserMapperService.copyProperty(activityUserMapper,activity,false,true);
                         if ("网管课".equals(calenderActivity.getCategoryName())) {
@@ -334,13 +320,21 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
                         continue;
                     }
                     musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
+                    musicGroupPaymentStudentCourseDetail.setMusicGroupId(musicGroupId);
                     musicGroupPaymentStudentCourseDetail.setCourseType(courseSettings.getCourseType());
                     musicGroupPaymentStudentCourseDetail.setCreateTime(date);
                     musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalenderId);
                     musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(userMap.get(studentId));
                     musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSettings.getCourseTotalMinuties());
+                    musicGroupPaymentStudentCourseDetail.setSubCourseMinutes(courseSettings.getCourseTotalMinuties());
                     musicGroupPaymentStudentCourseDetail.setCourseOriginalPrice(courseSettings.getCourseOriginalPrice());
                     musicGroupPaymentStudentCourseDetail.setCourseCurrentPrice(courseSettings.getCourseCurrentPrice());
+                    musicGroupPaymentStudentCourseDetail.setSubCourseOriginalPrice(courseSettings.getCourseOriginalPrice());
+                    musicGroupPaymentStudentCourseDetail.setSubCourseCurrentPrice(courseSettings.getCourseCurrentPrice());
+                    if(musicGroupPaymentCalender.getPayUserType() == SCHOOL){
+                        musicGroupPaymentStudentCourseDetail.setCourseCurrentPrice(BigDecimal.ZERO);
+                        musicGroupPaymentStudentCourseDetail.setSubCourseCurrentPrice(BigDecimal.ZERO);
+                    }
                     musicGroupPaymentStudentCourseDetail.setUpdateTime(date);
                     musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
                     musicGroupPaymentStudentCourseDetail.setUserId(studentId);
@@ -579,13 +573,21 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
                     continue;
                 }
                 MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
+                musicGroupPaymentStudentCourseDetail.setMusicGroupId(musicGroupPaymentCalender.getMusicGroupId());
                 musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
                 musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetail.getId());
                 musicGroupPaymentStudentCourseDetail.setUserId(studentPaymentOrder.getUserId());
                 musicGroupPaymentStudentCourseDetail.setCourseType(courseSetting.getCourseType());
                 musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSetting.getCourseTotalMinuties());
+                musicGroupPaymentStudentCourseDetail.setSubCourseMinutes(courseSetting.getCourseTotalMinuties());
                 musicGroupPaymentStudentCourseDetail.setCourseOriginalPrice(courseSetting.getCourseOriginalPrice());
                 musicGroupPaymentStudentCourseDetail.setCourseCurrentPrice(courseSetting.getCourseCurrentPrice());
+                musicGroupPaymentStudentCourseDetail.setSubCourseOriginalPrice(courseSetting.getCourseOriginalPrice());
+                musicGroupPaymentStudentCourseDetail.setSubCourseCurrentPrice(courseSetting.getCourseCurrentPrice());
+                if(musicGroupPaymentCalender.getPayUserType() == SCHOOL){
+                    musicGroupPaymentStudentCourseDetail.setCourseCurrentPrice(BigDecimal.ZERO);
+                    musicGroupPaymentStudentCourseDetail.setSubCourseCurrentPrice(BigDecimal.ZERO);
+                }
                 musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
                 musicGroupPaymentStudentCourseDetail.setCreateTime(nowDate);
                 musicGroupPaymentStudentCourseDetail.setUpdateTime(nowDate);

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

@@ -26,15 +26,14 @@ import com.ym.mec.common.service.IdGeneratorService;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
-import com.ym.mec.util.date.DateUtil;
+
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.ui.ModelMap;
 
 import java.math.BigDecimal;
@@ -121,6 +120,12 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
     private VipGroupActivityDao vipGroupActivityDao;
     @Autowired
     private OperatingReportCloudService operatingReportCloudService;
+    @Autowired
+    private MusicGroupCalenderRefundPeriodService musicGroupCalenderRefundPeriodService;
+    @Autowired
+    private ImGroupService imGroupService;
+    @Autowired
+    private ImGroupMemberService imGroupMemberService;
 
     @Override
     public BaseDAO<Long, MusicGroupPaymentCalender> getDAO() {
@@ -238,16 +243,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
             throw new BizException("请登录");
         });
 
-        if (musicGroup.getStatus() != MusicGroupStatusEnum.PROGRESS && musicGroup.getStatus() != MusicGroupStatusEnum.PRE_BUILD_FEE) {
-            throw new BizException("创建缴费失败:已存在缴费项目");
-        }
-        // 所有缴费项目已完成排课才能创建下一个缴费项目
-        String orignBatchNo = musicGroupPaymentStudentCourseDetailDao.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, null, null, null);
-        if (!musicGroupPaymentBaseCalender.getConfirmCreate() && StringUtils.isNoneBlank(orignBatchNo)) {
-            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-            return BaseController.failed(HttpStatus.MULTI_STATUS,"当前乐团存在未排课的缴费项目,请再次确认操作");
-        }
-
         // 不是进行中,只能创建一次缴费
         if (musicGroup.getStatus() != MusicGroupStatusEnum.PROGRESS) {
             List<MusicGroupPaymentCalender> list = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
@@ -258,12 +253,13 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         //进行中加学员拓展信息
         CalenderAddStudent calenderAddStudent = musicGroupPaymentBaseCalender.getCalenderAddStudent();
         MusicGroupPaymentCalender musicGroupPaymentCalender = new MusicGroupPaymentCalender();
+        BeanUtils.copyProperties(musicGroupPaymentBaseCalender,musicGroupPaymentCalender);
         //判断缴费项目类型
-        if (musicGroup.getStatus() == MusicGroupStatusEnum.PRE_BUILD_FEE) {
-            musicGroupPaymentBaseCalender.setPaymentType(MUSIC_APPLY);
+        if (musicGroup.getStatus() == MusicGroupStatusEnum.DRAFT || musicGroup.getStatus() == MusicGroupStatusEnum.AUDIT_FAILED || musicGroup.getStatus() == MusicGroupStatusEnum.FEE_AUDIT_FAILED) {
+            musicGroupPaymentCalender.setPaymentType(MUSIC_APPLY);
         } else {
             if (calenderAddStudent != null && calenderAddStudent.getStudentIds() != null) {
-                musicGroupPaymentBaseCalender.setPaymentType(ADD_STUDENT);
+                musicGroupPaymentCalender.setPaymentType(ADD_STUDENT);
                 //预计缴费人数
                 musicGroupPaymentCalender.setAttribute1(calenderAddStudent.getClassGroupIds());
                 musicGroupPaymentCalender.setStudentIds(calenderAddStudent.getStudentIds().toString());
@@ -272,9 +268,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
                 checkAddStudent(calenderAddStudent, musicGroup);
             } else {
                 if (musicGroupPaymentBaseCalender.getMusicGroupOrganizationCourseSettingId() != null) {
-                    musicGroupPaymentBaseCalender.setPaymentType(MUSIC_RENEW);
+                    musicGroupPaymentCalender.setPaymentType(MUSIC_RENEW);
                 } else {
-                    musicGroupPaymentBaseCalender.setPaymentType(ADD_COURSE);
+                    musicGroupPaymentCalender.setPaymentType(ADD_COURSE);
                 }
             }
         }
@@ -299,10 +295,29 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         BigDecimal actualTotalAmount = courseActualAmount.add(memberActualAmount)
                 .add(repairActualAmount)
                 .add(activityActualAmount).setScale(0, BigDecimal.ROUND_HALF_UP);
+        //标记是否云教练缴费
+        if(musicGroupPaymentCalender.getPayUserType() == STUDENT && musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE){
+            if(musicGroupPaymentCalender.getPaymentType() == ADD_STUDENT){
+                musicGroupPaymentCalender.setCloudTeacherPaymentFlag(true);
+            }else if(memberActualAmount.compareTo(BigDecimal.ZERO) > 0 &&
+                    ((courseActualAmount.compareTo(BigDecimal.ZERO) == 0 && CollectionUtils.isNotEmpty(musicGroupPaymentBaseCalender.getMusicGroupPaymentCalenderCourseSettingsList()))
+                            || (activityActualAmount.compareTo(BigDecimal.ZERO) == 0 && CollectionUtils.isNotEmpty(musicGroupPaymentBaseCalender.getCalenderActivityList())))) {
+                musicGroupPaymentCalender.setCloudTeacherPaymentFlag(true);
+            }
+        }
+
+        if(musicGroupPaymentBaseCalender.getPayUserType() == SCHOOL){
+            actualTotalAmount = musicGroupPaymentBaseCalender.getCurrentTotalAmount();
+        }
 
         PaymentCalenderStatusEnum status;
-        if (musicGroupPaymentBaseCalender.getPayUserType() == SCHOOL) {
+        if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY || musicGroupPaymentCalender.getPayUserType() == SCHOOL) {
             status = AUDITING;
+            if(musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY){
+            	if(musicGroup.getStatus() == MusicGroupStatusEnum.DRAFT || musicGroup.getStatus() == MusicGroupStatusEnum.AUDIT_FAILED){
+            		status = DRAFT;
+            	}
+            }
         } else {
             //计算项目原现价
             BigDecimal courseCurrentAmount = musicGroupPaymentCalenderCourseSettingsService.getCurrentAmount(musicGroupPaymentBaseCalender);
@@ -321,26 +336,18 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
                 status = actualTotalAmount.compareTo(currentTotalAmount) == 0 ? NO : AUDITING;
             }
         }
-
         Date date = new Date();
 
-        musicGroupPaymentCalender.setDeadlinePaymentDate(musicGroupPaymentBaseCalender.getDeadlinePaymentDate());
-        musicGroupPaymentCalender.setMemo(musicGroupPaymentBaseCalender.getMemo());
         musicGroupPaymentCalender.setMusicGroupId(musicGroupId);
-        musicGroupPaymentCalender.setMusicGroupOrganizationCourseSettingId(musicGroupPaymentBaseCalender.getMusicGroupOrganizationCourseSettingId());
-        musicGroupPaymentCalender.setPayUserType(musicGroupPaymentBaseCalender.getPayUserType());
-        musicGroupPaymentCalender.setStartPaymentDate(musicGroupPaymentBaseCalender.getStartPaymentDate());
         musicGroupPaymentCalender.setOperator(sysUser.getId());
         musicGroupPaymentCalender.setCreateTime(date);
         musicGroupPaymentCalender.setUpdateTime(date);
-        musicGroupPaymentCalender.setPaymentType(musicGroupPaymentBaseCalender.getPaymentType());
         musicGroupPaymentCalender.setCurrentTotalAmount(actualTotalAmount);
         musicGroupPaymentCalender.setOriginalTotalAmount(originalTotalAmount);
         musicGroupPaymentCalender.setStatus(status);
         musicGroupPaymentCalender.setOrganId(musicGroup.getOrganId());
-        musicGroupPaymentCalender.setPaymentItemShowState(musicGroupPaymentBaseCalender.getPaymentItemShowState());
 
-        if (musicGroupPaymentCalender.getStatus() != AUDITING) {
+        if (musicGroupPaymentCalender.getStatus() != AUDITING && musicGroupPaymentCalender.getPaymentType() != MUSIC_APPLY) {
             if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
                 musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
             } else if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
@@ -349,52 +356,40 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
                 musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
             }
         }
-
         // 设置批次号
         String batchNo = idGeneratorService.generatorId() + "";
         musicGroupPaymentCalender.setBatchNo(batchNo);
-        //标记是否云教练缴费
-        if(musicGroupPaymentCalender.getPayUserType() == STUDENT && musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE){
-            if(musicGroupPaymentCalender.getPaymentType() == ADD_STUDENT){
-                musicGroupPaymentCalender.setCloudTeacherPaymentFlag(true);
-            }else if(memberActualAmount.compareTo(BigDecimal.ZERO) > 0 &&
-                    ((courseActualAmount.compareTo(BigDecimal.ZERO) == 0 && CollectionUtils.isNotEmpty(musicGroupPaymentBaseCalender.getMusicGroupPaymentCalenderCourseSettingsList()))
-                            || (activityActualAmount.compareTo(BigDecimal.ZERO) == 0 && CollectionUtils.isNotEmpty(musicGroupPaymentBaseCalender.getCalenderActivityList())))) {
-                musicGroupPaymentCalender.setCloudTeacherPaymentFlag(true);
-            }
-        }
+
         musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
+        musicGroupPaymentBaseCalender.setCurrentTotalAmount(musicGroupPaymentCalender.getCurrentTotalAmount());
+        musicGroupPaymentBaseCalender.setCalenderId(musicGroupPaymentCalender.getId());
+        //如果是学校缴费,需要保存还款周期
+        musicGroupCalenderRefundPeriodService.savePeriod(musicGroupPaymentBaseCalender);
 
+        //云教练团经营报表相关
         operatingReportCloudService.save(musicGroupPaymentCalender);
         Long calenderId = musicGroupPaymentCalender.getId();
         //保存会员缴费信息
         MusicGroupPaymentCalenderMember calenderMember = musicGroupPaymentBaseCalender.getCalenderMember();
         if (calenderMember != null) {
             calenderMember = musicGroupPaymentCalenderMemberService.initBean(calenderMember);
+            calenderMember.setActualAmount(memberActualAmount);
             calenderMember.setOriginalAmount(memberOriginalAmount);
             calenderMember.setCalenderId(calenderId);
-            if (musicGroupPaymentBaseCalender.getPayUserType() == SCHOOL) {
-                calenderMember.setActualAmount(BigDecimal.ZERO);
-            }
             musicGroupPaymentCalenderMemberService.insert(calenderMember);
         }
         //保存乐保缴费信息
         MusicGroupPaymentCalenderRepair musicRepair = musicGroupPaymentBaseCalender.getMusicRepair();
         if (musicRepair != null) {
             musicRepair.setOriginalAmount(repairOriginalAmount);
+            musicRepair.setActualAmount(repairActualAmount);
             musicRepair.setCalenderId(calenderId);
-            if (musicGroupPaymentBaseCalender.getPayUserType() == SCHOOL) {
-                musicRepair.setActualAmount(BigDecimal.ZERO);
-            }
             musicGroupPaymentCalenderRepairService.insert(musicRepair);
         }
         //保存活动缴费信息
         List<MusicGroupPaymentCalenderActivity> calenderActivityList = musicGroupPaymentBaseCalender.getCalenderActivityList();
         if (calenderActivityList != null && calenderActivityList.size() > 0) {
             musicGroupPaymentCalenderActivityService.initBean(calenderActivityList);
-            if (musicGroupPaymentBaseCalender.getPayUserType() == SCHOOL) {
-                calenderActivityList.forEach(e -> e.setActualAmount(BigDecimal.ZERO));
-            }
             musicGroupPaymentCalenderActivityService.batchInsert(musicGroupPaymentBaseCalender, calenderId);
         }
         //保存课程费用列表
@@ -402,39 +397,35 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         musicGroupPaymentCalenderCourseSettingsService.batchInsert(musicGroupPaymentCalender);
 
         // 如果是报名,需要修改乐团状态
-        if (musicGroupPaymentBaseCalender.getPaymentType() == MUSIC_APPLY) {
-            if (status != AUDITING) {
-                musicGroup.setStatus(MusicGroupStatusEnum.APPLY);
-                // 记录操作日志
-                musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "报名缴费项目创建成功(创建缴费中 -> 报名中)", sysUser.getId(), ""));
-            } else {
+        if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY) {
+        	// 记录操作日志
+            musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "报名缴费项目创建成功", sysUser.getId(), ""));
+            if(musicGroup.getStatus() != MusicGroupStatusEnum.DRAFT && musicGroup.getStatus() != MusicGroupStatusEnum.AUDIT_FAILED){
                 musicGroup.setStatus(MusicGroupStatusEnum.FEE_AUDIT);
-                // 记录操作日志
-                musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "报名缴费项目创建成功(创建缴费 -> 费用审核中)", sysUser.getId(), ""));
             }
+            musicGroup.setApplyExpireDate(musicGroupPaymentCalender.getDeadlinePaymentDate());
             musicGroup.setUpdateTime(date);
             musicGroupDao.update(musicGroup);
         }
-        if (status == AUDITING) {
-            // 如果是审核中
-            Organization organization = organizationDao.get(musicGroup.getOrganId());
-            sendSeoMessageSource.sendSeoMessage(musicGroup.getOrganId(), new SysUserRoleEnum[]{ORGAN_MANAGER},
-                    null, null, MessageTypeEnum.BACKSTAGE_PAYMENT_CALENDER_AUDIT, organization.getName(), musicGroup.getName());
-        } else {
-            if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
-                addStudent(musicGroupPaymentCalender, musicGroup);
-                //将0元未缴费学员缴费状态更新为已缴费
-                this.updateNoPaymentAndZeroPaymentStatus(musicGroupPaymentCalender, true);
-                // 学生加到班级
-                classGroupService.addStudentToClassGroupAndCourseArranging(calenderAddStudent.getStudentIds(), calenderAddStudent.getClassGroupIds(),
-                        batchNo, musicGroupPaymentBaseCalender.getMusicGroupPaymentCalenderCourseSettingsList(), musicGroup);
-                ExecutorService executor = Executors.newFixedThreadPool(5);
-                CompletableFuture.runAsync(() -> {
-                    imUserFriendService.refreshGroupImUserFriend(musicGroupId, GroupType.MUSIC);
-                }, executor);
-                executor.shutdown();
-            }
-        }
+        
+        Organization organization = organizationDao.get(musicGroup.getOrganId());
+        sendSeoMessageSource.sendSeoMessage(musicGroup.getOrganId(), new SysUserRoleEnum[]{ORGAN_MANAGER},
+                null, null, MessageTypeEnum.BACKSTAGE_PAYMENT_CALENDER_AUDIT, organization.getName(), musicGroup.getName());
+        
+        if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
+            addStudent(musicGroupPaymentCalender, musicGroup);
+            //将0元未缴费学员缴费状态更新为已缴费
+            this.updateNoPaymentAndZeroPaymentStatus(musicGroupPaymentCalender, true);
+            // 学生加到班级
+            classGroupService.addStudentToClassGroupAndCourseArranging(calenderAddStudent.getStudentIds(), calenderAddStudent.getClassGroupIds(),
+                    batchNo, musicGroupPaymentBaseCalender.getMusicGroupPaymentCalenderCourseSettingsList(), musicGroup);
+            ExecutorService executor = Executors.newFixedThreadPool(5);
+            CompletableFuture.runAsync(() -> {
+                imUserFriendService.refreshGroupImUserFriend(musicGroupId, GroupType.MUSIC);
+            }, executor);
+            executor.shutdown();
+        }
+        
         ModelMap map = new ModelMap(1);
         map.put("musicGroupPaymentCalenderBatchNo", batchNo);
         return BaseController.succeed(map);
@@ -484,7 +475,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
     @Override
     public Map<String, Object> getDetail(Long id) {
-        Map<String, Object> result = new HashMap<>(10);
+        Map<String, Object> result = new HashMap<>(11);
         //获取缴费项目详情
         MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(id);
         //统计预计缴费人数
@@ -497,6 +488,10 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         if (actualNumMap != null) {
             calender.setActualNum(actualNumMap.get(id) == null ? 0 : actualNumMap.get(id).intValue());
         }
+        //如果是学校缴费并且金额不为0,返回费用信息
+        if (calender.getPayUserType() == SCHOOL && calender.getCurrentTotalAmount().compareTo(BigDecimal.ZERO) > 0){
+            result.put("calenderRefundPeriods",musicGroupCalenderRefundPeriodService.findByCalenderId(id));
+        }
 
         if (calender.getOrganId() != null) {
             Organization organization = organizationDao.get(calender.getOrganId());
@@ -629,8 +624,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         musicGroupPaymentCalender.setBatchNo(batchNo);
         musicGroupPaymentCalenderDto.setBatchNo(batchNo);
         musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
-//        List<MusicGroupPaymentCalenderCourseSettings> currentMusicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalender
-//                .getMusicGroupPaymentCalenderCourseSettingsList();
 
         if (musicGroupPaymentCalender.getStatus() != AUDITING) {
             // 如果是进行中加学生
@@ -703,8 +696,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         if (StringUtils.isNoneBlank(studentIdStr)) {
             //当前乐团是否有预排课计划
             MusicGroupSchoolTermCourseDetail termCourseDetail = musicGroupSchoolTermCourseDetailDao.findByCourseDateAndMusicGroupId(musicGroup.getId(), null, 0);
-//            List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = new ArrayList<MusicGroupPaymentStudentCourseDetail>();
-//            MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = null;
 
             List<MusicGroupPaymentCalenderActivity> calenderActivities = musicGroupPaymentCalenderActivityService.findByCalenderId(musicGroupPaymentCalender.getId());
             Map<Integer, VipGroupActivity> collect = new HashMap<>();
@@ -787,92 +778,10 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
                     //统计变更学员数
                     groupEventSource.musicGroupStudentChangeEvent(musicGroupPaymentCalender.getMusicGroupId(), StudentMusicGroupStatusEnum.NORMAL, new ArrayList<>(Arrays.asList(Integer.parseInt(studentId))));
                 }
-                /*if (musicGroupPaymentCalenderCourseSettingsList != null && musicGroupPaymentCalenderCourseSettingsList.size() > 0) {
-                    // 学生加课程明细
-                    for (MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList) {
-                        if (courseSettings.getIsStudentOptional() == true) {
-                            continue;
-                        }
-                        musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
-                        musicGroupPaymentStudentCourseDetail.setCourseType(courseSettings.getCourseType());
-                        musicGroupPaymentStudentCourseDetail.setCreateTime(date);
-                        musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
-                        musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetail.getId());
-                        musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSettings.getCourseTotalMinuties());
-                        musicGroupPaymentStudentCourseDetail.setCourseOriginalPrice(courseSettings.getCourseOriginalPrice());
-                        musicGroupPaymentStudentCourseDetail.setCourseCurrentPrice(courseSettings.getCourseCurrentPrice());
-                        musicGroupPaymentStudentCourseDetail.setUpdateTime(date);
-                        musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(courseSettings.getCourseTotalMinuties());
-                        musicGroupPaymentStudentCourseDetail.setUserId(Integer.parseInt(studentId));
-                        musicGroupPaymentStudentCourseDetailList.add(musicGroupPaymentStudentCourseDetail);
-                    }
-                }
-                if (musicGroupPaymentStudentCourseDetailList.size() > 0) {
-                    musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetailList);
-                }*/
             }
         }
     }
 
-    @Override
-    public void autoUpdateMusicGroupStudentFeeStatus() {
-        Date date = new Date();
-        String format = DateUtil.format(date, DateUtil.DEFAULT_PATTERN);
-        // 获取距离缴费开启指定天数后的缴费明细
-        String configValue = sysConfigDao.findConfigValue("push_payment_detail");
-        Map<Long, Long> maps = MapUtil.convertIntegerMap(musicGroupPaymentCalenderDao.queryCalenderByDay(configValue, format));
-        if (maps != null && maps.size() > 0) {
-            Set<Long> calenderId = maps.keySet();
-            List<CalenderPushDto> calenderPushDtos = musicGroupPaymentCalenderDao.getCalenderPushDto(calenderId);
-            Map<Long, List<CalenderPushDto>> collect = calenderPushDtos.stream().collect(Collectors.groupingBy(CalenderPushDto::getCalenderId));
-            calenderId.forEach(e -> {
-                CalenderPushDto calenderPushDto = collect.get(e).get(0);
-                Map<Integer, String> receivers = new HashMap<>(1);
-                receivers.put(calenderPushDto.getTeacherId(), calenderPushDto.getTeacherPhone());
-                sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, MessageTypeEnum.SYSTEM_SMS_PUSH_PAYMENT_DETAIL, receivers, null, 0,
-                        null, null, calenderPushDto.getMusicGroupName(), calenderPushDto.getPaymentValidStartDate(), calenderPushDto.getPaymentValidEndDate(),
-                        maps.get(e));
-                Map<Integer, String> receivers1 = new HashMap<>(1);
-                receivers1.put(calenderPushDto.getTeacherId(), calenderPushDto.getTeacherId().toString());
-                sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.SYSTEM_SMS_PUSH_PAYMENT_DETAIL, receivers1, null, 0,
-                        null, "SYSTEM", calenderPushDto.getMusicGroupName(), calenderPushDto.getPaymentValidStartDate(), calenderPushDto.getPaymentValidEndDate(),
-                        maps.get(e));
-            });
-        }
-        // 获取离截止还有指定时间的缴费项,并发送推送消息给指定老师
-        String configValue1 = sysConfigDao.findConfigValue("push_create_payment_calender");
-        List<Long> calenderIds = musicGroupPaymentCalenderDao.queryEndIds(configValue1, format, null);
-        if (calenderIds != null && calenderIds.size() > 0) {
-            List<CalenderPushDto> calenderPushDtos = musicGroupPaymentCalenderDao.getCalenderPushDto(calenderIds);
-            Map<Long, List<CalenderPushDto>> collect = calenderPushDtos.stream().collect(Collectors.groupingBy(CalenderPushDto::getCalenderId));
-            calenderIds.forEach(e -> {
-                CalenderPushDto calenderPushDto = collect.get(e).get(0);
-                Map<Integer, String> receivers = new HashMap<>(1);
-                receivers.put(calenderPushDto.getTeacherId(), calenderPushDto.getTeacherPhone());
-                sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, MessageTypeEnum.SYSTEM_SMS_PUSH_PAYMENT_CREATE, receivers, null, 0,
-                        null, null, calenderPushDto.getMusicGroupName(), calenderPushDto.getPaymentValidStartDate(), calenderPushDto.getPaymentValidEndDate());
-                Map<Integer, String> receivers1 = new HashMap<>(1);
-                receivers1.put(calenderPushDto.getTeacherId(), calenderPushDto.getTeacherId().toString());
-                sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.SYSTEM_SMS_PUSH_PAYMENT_CREATE, receivers1, null, 0,
-                        null, "SYSTEM", calenderPushDto.getMusicGroupName(), calenderPushDto.getPaymentValidStartDate(), calenderPushDto.getPaymentValidEndDate());
-            });
-        }
-
-        // 乐团报名到期,提醒教务老师创建缴费
-        List<CalenderPushDto> calenderPushDtos = musicGroupPaymentCalenderDao.getMusicCalenderPushDto(configValue1, format);
-        if (calenderPushDtos != null && calenderPushDtos.size() > 0) {
-            calenderPushDtos.forEach(e -> {
-                Map<Integer, String> receivers = new HashMap<>(1);
-                receivers.put(e.getTeacherId(), e.getTeacherPhone());
-                sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, MessageTypeEnum.SYSTEM_SMS_PUSH_PAYMENT_CREATE, receivers, null, 0,
-                        null, null, e.getMusicGroupName(), e.getPaymentValidStartDate(), e.getPaymentValidEndDate());
-                Map<Integer, String> receivers1 = new HashMap<>(1);
-                receivers1.put(e.getTeacherId(), e.getTeacherId().toString());
-                sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.SYSTEM_SMS_PUSH_PAYMENT_CREATE, receivers1, null, 0,
-                        null, "SYSTEM", e.getMusicGroupName(), e.getPaymentValidStartDate(), e.getPaymentValidEndDate());
-            });
-        }
-    }
 
     @Override
     public PageInfo<MusicGroupPaymentCalenderAuditDto> auditList(MusicGroupPaymentCalenderQueryInfo queryInfo) {
@@ -954,6 +863,15 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
             }
             MusicGroupPaymentCalender calender = musicGroupPaymentCalenders.get(0);
             MusicGroup musicGroup = musicGroupDao.get(calender.getMusicGroupId());
+
+            if (musicGroup.getStatus() != MusicGroupStatusEnum.PROGRESS && musicGroup.getStatus() != MusicGroupStatusEnum.FEE_AUDIT) {
+                throw new BizException("当前乐团状态不支持此操作");
+            }
+            
+            if(calender.getStatus() != PaymentCalenderStatusEnum.AUDITING){
+            	throw new BizException("缴费项目不是在审核中状态");
+            }
+            
             for (MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenders) {
                 //如果是报名项目,将乐团改为审核中,缴费项目修改状态,审核状态改为审核通过
                 if (musicGroupPaymentCalender.getPayUserType() == SCHOOL) {
@@ -980,12 +898,12 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
             }
             if (calender.getPaymentType() == ADD_STUDENT || calender.getPaymentType() == SPAN_GROUP_CLASS_ADJUST) {
                 // 所有缴费项目已完成排课才能创建下一个缴费项目
-                List<String> batchNoList = new ArrayList<>();
-                batchNoList.add(batchNo);
-                String orignBatchNo = musicGroupPaymentStudentCourseDetailDao.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(calender.getMusicGroupId(), null, null, batchNoList);
-                if (StringUtils.isNoneBlank(orignBatchNo)) {
-                    throw new BizException("{} 存在未排课的缴费项目,请先完成排课再操作", musicGroup.getName());
-                }
+//                List<String> batchNoList = new ArrayList<>();
+//                batchNoList.add(batchNo);
+//                String orignBatchNo = musicGroupPaymentStudentCourseDetailDao.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(calender.getMusicGroupId(), null, null, batchNoList);
+//                if (StringUtils.isNoneBlank(orignBatchNo)) {
+//                    throw new BizException("{} 存在未排课的缴费项目,请先完成排课再操作", musicGroup.getName());
+//                }
                 List<Integer> userIds = Arrays.stream(calender.getStudentIds().split(",")).mapToInt(Integer::valueOf).boxed().collect(Collectors.toList());
                 //获取欠费学员列表
                 List<Integer> noPaymentUserIds = musicGroupPaymentCalenderDetailDao.queryNoPaymentUserIds(calender.getMusicGroupId(), userIds,null);
@@ -1007,7 +925,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
                 //统计乐团还在审核中或者审核被拒的缴费
                 int count = musicGroupPaymentCalenderDao.countAuditReject(calender.getMusicGroupId(), calender.getId());
                 if (count == 0) {
-                    musicGroup.setStatus(MusicGroupStatusEnum.APPLY);
+                    musicGroup.setStatus(MusicGroupStatusEnum.PRE_APPLY);
                     musicGroup.setUpdateTime(date);
                     musicGroupDao.update(musicGroup);
                     SysUser sysUser = sysUserFeignService.queryUserInfo();
@@ -1015,7 +933,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
                         throw new BizException("请重新登录");
                     }
                     //记录操作日志
-                    musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroup.getId(), "报名缴费项目通过(费用审核中 -> 报名中)", sysUser.getId(), ""));
+                    musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroup.getId(), "报名缴费项目通过(费用审核中 -> 预报名)", sysUser.getId(), ""));
+                    this.createPreImGroup(musicGroup);
                 }
             } else if (calender.getPaymentType() == ADD_STUDENT) {
                 // 学生加到班级
@@ -1024,11 +943,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
                     classGroupService.addStudentToClassGroupAndCourseArranging(Integer.parseInt(calender.getStudentIds()), classGroupIdStr, batchNo,
                             musicGroupPaymentCalenderCourseSettingsService.queryCalenderCourseSettingsByBatchNo(batchNo), musicGroup);
                 }
-//                MusicGroupStudentClassAdjust musicGroupStudentClassAdjust = musicGroupStudentClassAdjustDao.findByBatchNo(batchNo);
-//                if (musicGroupStudentClassAdjust != null) {
-//                    如果是合班缴费
-//                    autoClassGroupAdjust(musicGroupStudentClassAdjust);
-//                }
             } else if (calender.getPaymentType() == SPAN_GROUP_CLASS_ADJUST) {
                 List<MusicGroupPaymentCalenderStudentDetail> calenderStudentDetails = musicGroupPaymentCalenderStudentDetailDao.findByBatchNo(batchNo);
                 //将学员加入新乐团、扣除原乐团剩余课程余额、补充到现有乐团
@@ -1059,6 +973,38 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         }
     }
 
+    private void createPreImGroup(MusicGroup musicGroup){
+        // 创建群
+        imGroupService.create(musicGroup.getId(), null, "乐团预报名", null,
+                musicGroup.getName(), musicGroup.getName(), null, GroupType.MUSIC.getCode(), ImGroup.GroupTypeEnum.PARENT_MEETING);
+
+        Map<Integer, String> userRoleMap = new HashMap<Integer, String>();
+
+        if (musicGroup.getTeamTeacherId() != null) {
+            userRoleMap.put(musicGroup.getTeamTeacherId(), "运营主管");
+        }
+        if (musicGroup.getEducationalTeacherId() != null) {
+            userRoleMap.put(musicGroup.getEducationalTeacherId(), "乐团主管");
+        }
+        if (musicGroup.getDirectorUserId() != null) {
+            userRoleMap.put(musicGroup.getDirectorUserId(), "乐队指导");
+        }
+        if (musicGroup.getTransactionTeacherId() != null) {
+            userRoleMap.put(musicGroup.getTransactionTeacherId(), "衔接老师");
+        }
+        // 添加成员
+        imGroupMemberService.join(musicGroup.getId(), userRoleMap);
+        //缴费老师推送消息
+        sendSeoMessageSource.sendSeoMessage(musicGroup.getOrganId(), null,
+                null, musicGroup.getEducationalTeacherId(), MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_ADJUST_SUCCESS, musicGroup.getName());
+        Map<Integer, String> map = new HashMap<>(1);
+        map.put(musicGroup.getEducationalTeacherId(), musicGroup.getEducationalTeacherId().toString());
+        if (map != null && map.size() > 0) {
+            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_ADJUST_SUCCESS,
+                    map, null, 0, null, "SYSTEM", musicGroup.getName());
+        }
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void auditRefuse(String batchNs, String auditMemo) {
@@ -1068,27 +1014,44 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         }
         String[] split = batchNs.split(",");
         Date date = new Date();
+        
+        List<String> musicGroupIdList = new ArrayList<String>();
+        
         for (String batchNo : split) {
             List<MusicGroupPaymentCalender> musicGroupPaymentCalenders = musicGroupPaymentCalenderDao.findByBatchNo(batchNo);
             if (musicGroupPaymentCalenders == null || musicGroupPaymentCalenders.size() == 0) {
                 throw new BizException("缴费项目不存在");
             }
             for (MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenders) {
+                
+                if(musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING){
+                	throw new BizException("缴费项目不是在审核中状态");
+                }
+                
                 musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.REJECT);
                 musicGroupPaymentCalender.setUpdateTime(date);
                 musicGroupPaymentCalender.setAuditMemo(auditMemo);
             }
             MusicGroupPaymentCalender calender = musicGroupPaymentCalenders.get(0);
+
+			MusicGroup musicGroup = musicGroupDao.get(calender.getMusicGroupId());
+            if (musicGroup.getStatus() != MusicGroupStatusEnum.PROGRESS && musicGroup.getStatus() != MusicGroupStatusEnum.FEE_AUDIT) {
+                throw new BizException("当前乐团状态不支持此操作");
+            }
             //如果是报名,并且所有的报名都审核通过,需要修改乐团状态
             if (calender.getPaymentType() == MUSIC_APPLY) {
-                MusicGroup musicGroup = musicGroupDao.get(calender.getMusicGroupId());
-                musicGroup.setStatus(MusicGroupStatusEnum.PRE_BUILD_FEE);
-                musicGroup.setUpdateTime(date);
-                musicGroupDao.update(musicGroup);
-                //记录操作日志
-                musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroup.getId(), "报名缴费项目失败(费用审核中 -> 审核拒绝)", sysUser.getId(), ""));
+				if (!musicGroupIdList.contains(calender.getMusicGroupId())) {
+					musicGroup.setStatus(MusicGroupStatusEnum.FEE_AUDIT_FAILED);
+					musicGroup.setUpdateTime(date);
+					musicGroupDao.update(musicGroup);
+					// 记录操作日志
+					musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroup.getId(), "报名缴费项目失败(费用审核中 -> 审核拒绝)", sysUser.getId(), ""));
+					
+					musicGroupIdList.add(calender.getMusicGroupId());
+				}
             }
             musicGroupPaymentCalenderDao.batchUpdate(musicGroupPaymentCalenders);
+            
         }
     }
 
@@ -1134,11 +1097,11 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
             if (e.getPaymentType() == MUSIC_APPLY) {
                 //如果是报名,并且所有的报名都审核通过,需要修改乐团状态
                 MusicGroup musicGroup = musicGroupDao.get(e.getMusicGroupId());
-                musicGroup.setStatus(MusicGroupStatusEnum.PRE_BUILD_FEE);
+                musicGroup.setStatus(MusicGroupStatusEnum.DRAFT);
                 musicGroup.setUpdateTime(date);
                 musicGroupDao.update(musicGroup);
                 //记录操作日志
-                musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroup.getId(), "报名缴费项目撤回(费用审核中 -> 撤回)", sysUser.getId(), ""));
+                musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroup.getId(), "报名缴费项目撤回(费用审核中 -> 草稿)", sysUser.getId(), ""));
             }
             e.setStatus(DRAFT);
         });
@@ -1182,6 +1145,18 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
     @Override
     @Transactional(rollbackFor = Exception.class)
     public HttpResponseResult<ModelMap> merge1(MusicGroupPaymentBaseCalender musicGroupPaymentBaseCalender) {
+    	
+    	Long calenderId = musicGroupPaymentBaseCalender.getCalenderId();
+    	
+    	MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(calenderId);
+    	if(musicGroupPaymentCalender == null){
+    		throw new BizException("缴费项目[{}]查询失败", calenderId);
+    	}
+    	
+    	if(musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.DRAFT && musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.REJECT){
+    		throw new BizException("当前缴费项目状态不支持修改");
+    	}
+    	
         del(musicGroupPaymentBaseCalender.getCalenderId());
         return create1(musicGroupPaymentBaseCalender);
     }
@@ -1321,6 +1296,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         if (musicGroupPaymentCalenderDetailList != null && musicGroupPaymentCalenderDetailList.size() > 0) {
             throw new BizException("操作失败:缴费项目中已存在学员");
         }
+        //如果是学校缴费,删除缴费周期
+        musicGroupCalenderRefundPeriodService.deleteByCalenderId(id);
         MusicGroupStudentClassAdjust adjust = musicGroupStudentClassAdjustDao.findByBatchNo(calender.getBatchNo());
         if (!Objects.isNull(adjust)) {
 //            throw new BizException("操作失败:班级调整的缴费项目不支持");

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

@@ -1,16 +1,12 @@
 package com.ym.mec.biz.service.impl;
 
-import com.ym.mec.biz.dal.entity.CourseSchedule;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentStudentCourseDetailDao;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
 import com.ym.mec.biz.service.MusicGroupPaymentStudentCourseDetailService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
-
-import java.util.List;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
 
 @Service
 public class MusicGroupPaymentStudentCourseDetailServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentStudentCourseDetail>  implements MusicGroupPaymentStudentCourseDetailService {
@@ -22,9 +18,4 @@ public class MusicGroupPaymentStudentCourseDetailServiceImpl extends BaseService
 	public BaseDAO<Long, MusicGroupPaymentStudentCourseDetail> getDAO() {
 		return musicGroupPaymentStudentCourseDetailDao;
 	}
-
-    @Override
-    public String getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(String musicGroupId, Integer studentId, CourseSchedule.CourseScheduleType courseType, List<String> batchNos) {
-        return musicGroupPaymentStudentCourseDetailDao.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, studentId, courseType, batchNos);
-    }
 }

+ 23 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPlanMakingServiceImpl.java

@@ -0,0 +1,23 @@
+package com.ym.mec.biz.service.impl;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.ym.mec.biz.dal.dao.MusicGroupPlanMakingDao;
+import com.ym.mec.biz.dal.entity.MusicGroupPlanMaking;
+import com.ym.mec.biz.service.MusicGroupPlanMakingService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+
+@Service
+public class MusicGroupPlanMakingServiceImpl extends BaseServiceImpl<Integer, MusicGroupPlanMaking>  implements MusicGroupPlanMakingService {
+	
+	@Autowired
+	private MusicGroupPlanMakingDao musicGroupPlanMakingDao;
+
+	@Override
+	public BaseDAO<Integer, MusicGroupPlanMaking> getDAO() {
+		return musicGroupPlanMakingDao;
+	}
+	
+}

+ 225 - 244
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -1,198 +1,22 @@
 package com.ym.mec.biz.service.impl;
 
-import static com.ym.mec.biz.dal.entity.ApprovalStatus.PROCESSING;
-import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED;
-import static com.ym.mec.biz.dal.enums.DealStatusEnum.ING;
-import static com.ym.mec.biz.dal.enums.DealStatusEnum.SUCCESS;
-import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.ACCESSORIES;
-import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.MAINTENANCE;
-import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.MUSICAL;
-import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.TEACHING;
-import static com.ym.mec.biz.dal.enums.PaymentStatusEnum.YES;
-import static com.ym.mec.biz.dal.enums.SysUserRoleEnum.ORGAN_MANAGER;
-
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Lazy;
-import org.springframework.http.HttpStatus;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Propagation;
-import org.springframework.transaction.annotation.Transactional;
-
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.TypeReference;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
-import com.ym.mec.biz.dal.dao.ChargeTypeDao;
-import com.ym.mec.biz.dal.dao.ClassGroupDao;
-import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
-import com.ym.mec.biz.dal.dao.ClassGroupTeacherMapperDao;
-import com.ym.mec.biz.dal.dao.CooperationOrganDao;
-import com.ym.mec.biz.dal.dao.CourseScheduleDao;
-import com.ym.mec.biz.dal.dao.CourseScheduleTeacherSalaryDao;
-import com.ym.mec.biz.dal.dao.GoodsDao;
-import com.ym.mec.biz.dal.dao.MusicGroupBuildLogDao;
-import com.ym.mec.biz.dal.dao.MusicGroupDao;
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderCourseSettingsDao;
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderStudentDetailDao;
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentEntitiesDao;
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentStudentCourseDetailDao;
-import com.ym.mec.biz.dal.dao.MusicGroupPurchaseListDao;
-import com.ym.mec.biz.dal.dao.MusicGroupQuitDao;
-import com.ym.mec.biz.dal.dao.MusicGroupSchoolTermCourseDetailDao;
-import com.ym.mec.biz.dal.dao.MusicGroupSchoolTermStudentCourseDetailDao;
-import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
-import com.ym.mec.biz.dal.dao.MusicGroupSubjectGoodsGroupDao;
-import com.ym.mec.biz.dal.dao.MusicGroupSubjectPlanDao;
-import com.ym.mec.biz.dal.dao.OrganizationDao;
-import com.ym.mec.biz.dal.dao.SchoolDao;
-import com.ym.mec.biz.dal.dao.SporadicChargeInfoDao;
-import com.ym.mec.biz.dal.dao.StudentDao;
-import com.ym.mec.biz.dal.dao.StudentInstrumentDao;
-import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
-import com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao;
-import com.ym.mec.biz.dal.dao.StudentPreRegistrationDao;
-import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
-import com.ym.mec.biz.dal.dao.StudentVisitDao;
-import com.ym.mec.biz.dal.dao.SubjectChangeDao;
-import com.ym.mec.biz.dal.dao.SubjectDao;
-import com.ym.mec.biz.dal.dao.SysConfigDao;
-import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
-import com.ym.mec.biz.dal.dao.SysUserCashAccountLogDao;
-import com.ym.mec.biz.dal.dao.TeacherAttendanceDao;
-import com.ym.mec.biz.dal.dao.TeacherDao;
-import com.ym.mec.biz.dal.dto.BasicUserDto;
-import com.ym.mec.biz.dal.dto.CloseMusicGroupDto;
-import com.ym.mec.biz.dal.dto.CourseScheduleTeachersDto;
-import com.ym.mec.biz.dal.dto.HighClassGroupDto;
-import com.ym.mec.biz.dal.dto.MusicCardDto;
-import com.ym.mec.biz.dal.dto.MusicGroupApplyGoodsDto;
-import com.ym.mec.biz.dal.dto.MusicGroupBasicDto;
-import com.ym.mec.biz.dal.dto.MusicGroupQuitDto;
-import com.ym.mec.biz.dal.dto.RegisterPayDto;
-import com.ym.mec.biz.dal.dto.SporadicPayDto;
-import com.ym.mec.biz.dal.dto.StudentApplyInstrumentDto;
-import com.ym.mec.biz.dal.dto.StudentImportDto;
-import com.ym.mec.biz.dal.dto.SubFeeSettingDto;
-import com.ym.mec.biz.dal.dto.SubjectRegisterDto;
-import com.ym.mec.biz.dal.dto.UpdateExpectedNumDto;
-import com.ym.mec.biz.dal.entity.ApprovalStatus;
-import com.ym.mec.biz.dal.entity.ChargeType;
-import com.ym.mec.biz.dal.entity.ClassGroup;
-import com.ym.mec.biz.dal.entity.CooperationOrgan;
-import com.ym.mec.biz.dal.entity.CouponPayParam;
-import com.ym.mec.biz.dal.entity.CourseSchedule;
-import com.ym.mec.biz.dal.entity.CourseScheduleTeacherSalary;
-import com.ym.mec.biz.dal.entity.FinancialExpenditure;
-import com.ym.mec.biz.dal.entity.Goods;
-import com.ym.mec.biz.dal.entity.ImGroup;
-import com.ym.mec.biz.dal.entity.MusicGroup;
-import com.ym.mec.biz.dal.entity.MusicGroupBuildLog;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.dto.*;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderStudentDetail;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
-import com.ym.mec.biz.dal.entity.MusicGroupPurchaseList;
-import com.ym.mec.biz.dal.entity.MusicGroupQuit;
-import com.ym.mec.biz.dal.entity.MusicGroupReturnFeeDto;
-import com.ym.mec.biz.dal.entity.MusicGroupSchoolTermCourseDetail;
-import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
-import com.ym.mec.biz.dal.entity.MusicGroupSubjectGoodsGroup;
-import com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan;
-import com.ym.mec.biz.dal.entity.MusicMemberDto;
-import com.ym.mec.biz.dal.entity.Organization;
-import com.ym.mec.biz.dal.entity.School;
-import com.ym.mec.biz.dal.entity.SporadicChargeInfo;
-import com.ym.mec.biz.dal.entity.Student;
-import com.ym.mec.biz.dal.entity.StudentInstrument;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
-import com.ym.mec.biz.dal.entity.StudentPreRegistration;
-import com.ym.mec.biz.dal.entity.StudentRegistration;
-import com.ym.mec.biz.dal.entity.Subject;
-import com.ym.mec.biz.dal.entity.SubjectChange;
-import com.ym.mec.biz.dal.entity.SysUserCashAccount;
-import com.ym.mec.biz.dal.entity.SysUserCashAccountDetail;
-import com.ym.mec.biz.dal.entity.SysUserCashAccountLog;
-import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
-import com.ym.mec.biz.dal.enums.CouponDetailTypeEnum;
-import com.ym.mec.biz.dal.enums.CourseStatusEnum;
-import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
-import com.ym.mec.biz.dal.enums.DealStatusEnum;
-import com.ym.mec.biz.dal.enums.FivePlusGradeEnum;
-import com.ym.mec.biz.dal.enums.GoodsType;
-import com.ym.mec.biz.dal.enums.GradeTypeEnum;
-import com.ym.mec.biz.dal.enums.GroupType;
-import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
-import com.ym.mec.biz.dal.enums.MessageTypeEnum;
-import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
-import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
-import com.ym.mec.biz.dal.enums.OrderTypeEnum;
-import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
-import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
-import com.ym.mec.biz.dal.enums.ReturnFeeEnum;
-import com.ym.mec.biz.dal.enums.SixPlusGradeEnum;
-import com.ym.mec.biz.dal.enums.SporadicChargeTypeEnum;
-import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
-import com.ym.mec.biz.dal.enums.SysUserRoleEnum;
-import com.ym.mec.biz.dal.enums.TeachTypeEnum;
-import com.ym.mec.biz.dal.enums.YesOrNoEnum;
+import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.page.MusicGroupQueryInfo;
 import com.ym.mec.biz.dal.page.MusicMemberQueryInfo;
 import com.ym.mec.biz.event.source.GroupEventSource;
 import com.ym.mec.biz.event.source.SendSeoMessageSource;
-import com.ym.mec.biz.service.ClassGroupService;
-import com.ym.mec.biz.service.ClassGroupStudentMapperService;
-import com.ym.mec.biz.service.ContractService;
-import com.ym.mec.biz.service.CourseScheduleStudentPaymentService;
-import com.ym.mec.biz.service.GoodsService;
-import com.ym.mec.biz.service.ImGroupMemberService;
-import com.ym.mec.biz.service.ImGroupService;
-import com.ym.mec.biz.service.ImUserFriendService;
-import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
-import com.ym.mec.biz.service.MusicGroupService;
-import com.ym.mec.biz.service.MusicGroupSubjectGoodsGroupService;
-import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
-import com.ym.mec.biz.service.PayService;
-import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
-import com.ym.mec.biz.service.StudentPaymentOrderService;
-import com.ym.mec.biz.service.StudentPaymentRouteOrderService;
-import com.ym.mec.biz.service.StudentRegistrationService;
-import com.ym.mec.biz.service.StudentService;
-import com.ym.mec.biz.service.SysConfigService;
-import com.ym.mec.biz.service.SysCouponCodeService;
-import com.ym.mec.biz.service.SysEmployeePositionService;
-import com.ym.mec.biz.service.SysMessageService;
-import com.ym.mec.biz.service.SysTenantConfigService;
-import com.ym.mec.biz.service.SysUserCashAccountDetailService;
-import com.ym.mec.biz.service.SysUserCashAccountService;
+import com.ym.mec.biz.service.*;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.entity.HttpResponseResult;
@@ -208,6 +32,33 @@ import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.http.HttpUtil;
 import com.ym.mec.util.json.JsonUtil;
 import com.ym.mec.util.validator.CommonValidator;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.http.HttpStatus;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
+
+import static com.ym.mec.biz.dal.entity.ApprovalStatus.PROCESSING;
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType.SCHOOL;
+import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED;
+import static com.ym.mec.biz.dal.enums.DealStatusEnum.ING;
+import static com.ym.mec.biz.dal.enums.DealStatusEnum.SUCCESS;
+import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.*;
+import static com.ym.mec.biz.dal.enums.PaymentStatusEnum.YES;
+import static com.ym.mec.biz.dal.enums.SysUserRoleEnum.ORGAN_MANAGER;
 
 @Service
 public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> implements MusicGroupService {
@@ -583,13 +434,17 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 						continue;
 					}
 					MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
+					musicGroupPaymentStudentCourseDetail.setMusicGroupId(musicGroupPaymentCalender.getMusicGroupId());
 					musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
 					//musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetail.getId());
 					musicGroupPaymentStudentCourseDetail.setUserId(si.getUserId());
 					musicGroupPaymentStudentCourseDetail.setCourseType(courseSetting.getCourseType());
 					musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSetting.getCourseTotalMinuties());
+					musicGroupPaymentStudentCourseDetail.setSubCourseMinutes(courseSetting.getCourseTotalMinuties());
 					musicGroupPaymentStudentCourseDetail.setCourseOriginalPrice(courseSetting.getCourseOriginalPrice());
 					musicGroupPaymentStudentCourseDetail.setCourseCurrentPrice(courseSetting.getCourseCurrentPrice());
+					musicGroupPaymentStudentCourseDetail.setSubCourseOriginalPrice(courseSetting.getCourseOriginalPrice());
+					musicGroupPaymentStudentCourseDetail.setSubCourseCurrentPrice(courseSetting.getCourseCurrentPrice());
 					musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
 					musicGroupPaymentStudentCourseDetail.setCreateTime(nowDate);
 					musicGroupPaymentStudentCourseDetail.setUpdateTime(nowDate);
@@ -785,6 +640,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean finishPreApply(String musicGroupId, boolean isCheckStudentNum) {
+
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null || sysUser.getId() == null) {
+            throw new BizException("请重新登录");
+        }
         MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
         if (musicGroup == null) {
             throw new BizException("乐团信息查询失败");
@@ -806,17 +666,34 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 }
             }
         }
-        musicGroup.setStatus(MusicGroupStatusEnum.PRE_BUILD_FEE);
+        musicGroup.setStatus(MusicGroupStatusEnum.PAY);
         musicGroup.setUpdateTime(new Date());
         musicGroupDao.update(musicGroup);
 
-        SysUser sysUser = sysUserFeignService.queryUserInfo();
-        if (sysUser == null || sysUser.getId() == null) {
-            throw new BizException("请重新登录");
-        }
-
         //记录操作日志
-        musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroup.getId(), "报名缴费项目失败(预报名 -> 准备创建缴费)", sysUser.getId(), ""));
+        musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroup.getId(), "预报名完成(预报名 -> 报名缴费中)", sysUser.getId(), ""));
+        
+        studentRegistrationDao.musicGroupOpenPay(musicGroupId, PaymentStatusEnum.OPEN);
+        MusicGroupPaymentCalender regCalender = musicGroupPaymentCalenderDao.findByMusicGroupRegCalender(musicGroupId);
+        if (regCalender != null && regCalender.getPayUserType().equals(MusicGroupPaymentCalender.PayUserType.STUDENT)) {
+            regCalender.setStatus(MusicGroupPaymentCalender.PaymentCalenderStatusEnum.OPEN);
+            regCalender.setUpdateTime(new Date());
+            musicGroupPaymentCalenderDao.update(regCalender);
+        }
+        //三方乐团不发送缴费通知
+        if (musicGroup.getOwnershipType() != null && musicGroup.getOwnershipType() == CooperationOrgan.OwnershipType.OWN) {
+            List<Map<Integer, String>> mapList = studentRegistrationDao.findMapByMusicGroupId(musicGroupId, 0);
+            //获取所有已报名学员列表
+            HashMap<Integer, String> map = JSONObject.parseObject(JSONObject.toJSONString(MapUtil.convertMybatisMap(mapList)), HashMap.class);
+            if (map != null && map.size() > 0) {
+                String studentApplyUrl = sysConfigDao.findConfigValue(SysConfigService.STUDENT_APPLY_URL) + musicGroupId;
+//                String serverPhone = sysConfigDao.findConfigValue(SysConfigService.SERVER_PHONE);
+                sysMessageService.batchSendMessage(MessageSender.AWSMS, MessageTypeEnum.SMS_PAYMENT_MESSAGE,
+                        map, null, 0, "", "", musicGroup.getName(), studentApplyUrl);
+            }
+        }
+        sendSeoMessageSource.sendSeoMessage(musicGroup.getOrganId(), new SysUserRoleEnum[]{ORGAN_MANAGER}, null,
+                musicGroup.getEducationalTeacherId(), MessageTypeEnum.BACKSTAGE_ACTION_PAYMENT, musicGroup.getName());
 
         return true;
     }
@@ -1153,6 +1030,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                     }
                 } else {
                     goodsDto.setOrderAmount(goodsDto.getOrderAmount().add(goodsGroup.getPrice()));
+
+                    //分部分润金额
+                    if(goodsGroup.getOrganShareProfit() != null){
+                    	goodsDto.setOrderAmount(goodsDto.getOrderAmount().add(goodsGroup.getOrganShareProfit()));
+                    }
                 }
             }
             goodsDto.setOrderAmount(goodsDto.getOrderAmount().subtract(goodsDto.getRemitFee()));
@@ -1413,12 +1295,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
 
         if (musicGroup.getStatus() == MusicGroupStatusEnum.DRAFT || musicGroup.getStatus() == MusicGroupStatusEnum.AUDIT_FAILED) {
-            musicGroup.setStatus(subFeeSettingDto.getMusicGroupStatus());
+            //musicGroup.setStatus(subFeeSettingDto.getMusicGroupStatus());
             musicGroup.setUpdateTime(new Date());
             musicGroupDao.update(musicGroup);
         }
         //记录日志信息
-        musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "基础信息提交审核(编辑中 -> 审核中)", sysUser.getId(), JSONObject.toJSONString(subFeeSettingDto)));
+        //musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "基础信息提交审核(编辑中 -> 审核中)", sysUser.getId(), JSONObject.toJSONString(subFeeSettingDto)));
         //删除原有的乐团声部规划
         musicGroupSubjectPlanDao.delByMusicGroupId(musicGroupId);
         //删除原有的声部商品组合
@@ -1431,12 +1313,25 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             musicGroupSubjectPlanDao.batchAdd(musicGroupSubjectPlans, musicGroupId);
         }
         if (subFeeSettingDto.getMusicGroupSubjectGoodsGroups() != null && subFeeSettingDto.getMusicGroupSubjectGoodsGroups().size() > 0) {
+        	//获取分部最大分润金额
+        	Organization organ = organizationDao.get(musicGroup.getOrganId());
+        	if(organ == null){
+        		throw new BizException("分部信息查询失败");
+        	}
+        	BigDecimal maxProfits = organ.getMaxMusicalInstrumentsProfits();
+        	
             for (MusicGroupSubjectGoodsGroup musicGroupSubjectGoodsGroup : subFeeSettingDto.getMusicGroupSubjectGoodsGroups()) {
                 if (musicGroupSubjectGoodsGroup.getType().equals(GoodsType.INSTRUMENT) && (musicGroupSubjectGoodsGroup.getKitGroupPurchaseTypeJson() == null
                         || musicGroupSubjectGoodsGroup.getKitGroupPurchaseTypeJson().isEmpty()
                         || musicGroupSubjectGoodsGroup.getKitGroupPurchaseTypeJson().equals("{}"))) {
                     throw new BizException(musicGroupSubjectGoodsGroup.getName() + " 请选择提供方式");
                 }
+                
+                //判断分润是否超过最大值
+                if(musicGroupSubjectGoodsGroup.getOrganShareProfit() != null && maxProfits.compareTo(musicGroupSubjectGoodsGroup.getOrganShareProfit()) < 0){
+                	throw new BizException("超过了分润最大金额[{}],请重新设置分润金额", maxProfits.doubleValue());
+                }
+                
                 if (musicGroupSubjectGoodsGroup.getGroupRemissionCourseFee() == null) {
                     musicGroupSubjectGoodsGroup.setGroupRemissionCourseFee(0);
                 }
@@ -1546,11 +1441,43 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (sysUser == null) {
             throw new BizException("用户信息获取失败");
         }
-        MusicGroup musicGroup = saveLog(musicGroupId, MusicGroupStatusEnum.DRAFT);
+        Date date = new Date();
+        
+        MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
+        if (musicGroup == null) {
+            throw new BizException("乐团信息不存在");
+        }
+        
+        if (musicGroup.getStatus() != MusicGroupStatusEnum.DRAFT && musicGroup.getStatus() != MusicGroupStatusEnum.AUDIT_FAILED) {
+            throw new BizException("当前乐团状态不支持此操作");
+        }
+        List<MusicGroupSubjectPlan> musicSubjectClassPlan = musicGroupSubjectPlanDao.getMusicSubjectClassPlan(musicGroupId);
+        if(CollectionUtils.isEmpty(musicSubjectClassPlan)){
+            throw new BizException("请填写乐团声部信息");
+        }
+
         //记录操作日志
         musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "提交审核(草稿 -> 审核中)", sysUser.getId(), ""));
         musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
+        musicGroup.setUpdateTime(date);
         musicGroupDao.update(musicGroup);
+        
+        List<PaymentCalenderStatusEnum> statusList = new ArrayList<MusicGroupPaymentCalender.PaymentCalenderStatusEnum>();
+        statusList.add(PaymentCalenderStatusEnum.DRAFT);
+        //修改乐团报名缴费项目状态
+        List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList = musicGroupPaymentCalenderDao.queryByPaymentStatus(musicGroupId, statusList, null);
+        
+        if(musicGroupPaymentCalenderList == null || musicGroupPaymentCalenderList.size() == 0) {
+        	throw new BizException("请先创建缴费项目");
+        }
+        
+        musicGroupPaymentCalenderList.forEach(t -> {
+        	t.setStatus(PaymentCalenderStatusEnum.AUDITING);
+        	t.setUpdateTime(date);
+        });
+        
+        musicGroupPaymentCalenderDao.batchUpdate(musicGroupPaymentCalenderList);
+        
         sendSeoMessageSource.sendSeoMessage(musicGroup.getOrganId(), new SysUserRoleEnum[]{ORGAN_MANAGER},
                 null, null, MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_APPLY, sysUser.getRealName(), musicGroup.getName());
     }
@@ -1562,20 +1489,60 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (sysUser == null) {
             throw new BizException("用户信息获取失败");
         }
-        MusicGroup musicGroup = saveLog(musicGroupId, MusicGroupStatusEnum.AUDIT);
+        MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
+        if (musicGroup == null) {
+            throw new BizException("乐团信息不存在");
+        }
+        if (musicGroup.getTenantId() == null) {
+            throw new BizException("乐团机构信息异常,请联系管理员");
+        }
+        if (musicGroup.getStatus() != MusicGroupStatusEnum.AUDIT) {
+            throw new BizException("当前乐团状态不支持此操作");
+        }
+        
+        Date date = new Date();
+        
         //记录操作日志
-        musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "乐团审核失败(审核中 -> 审核失败)", sysUser.getId(), memo));
-        musicGroup.setMemo(memo);
-        musicGroup.setStatus(MusicGroupStatusEnum.AUDIT_FAILED);
-        musicGroupDao.update(musicGroup);
-        //修改缴费项目状态
-        List<MusicGroupPaymentCalender> musicGroupPaymentCalenders = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
-        if (musicGroupPaymentCalenders != null && musicGroupPaymentCalenders.size() > 0) {
-            musicGroupPaymentCalenders.forEach(e -> {
-                e.setStatus(MusicGroupPaymentCalender.PaymentCalenderStatusEnum.REJECT);
+        if (musicGroup.getStatus() == MusicGroupStatusEnum.AUDIT){
+        	musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "乐团审核失败(审核中 -> 审核失败)", sysUser.getId(), memo));
+        	musicGroup.setStatus(MusicGroupStatusEnum.AUDIT_FAILED);
+            musicGroup.setMemo(memo);
+            musicGroup.setUpdateTime(date);
+            musicGroupDao.update(musicGroup);
+            
+            List<PaymentCalenderStatusEnum> statusList = new ArrayList<MusicGroupPaymentCalender.PaymentCalenderStatusEnum>();
+            statusList.add(PaymentCalenderStatusEnum.AUDITING);
+            //修改乐团报名缴费项目状态
+            List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList = musicGroupPaymentCalenderDao.queryByPaymentStatus(musicGroupId, statusList, null);
+            
+            musicGroupPaymentCalenderList.forEach(t -> {
+            	t.setStatus(PaymentCalenderStatusEnum.DRAFT);
+            	t.setUpdateTime(date);
+            });
+            
+            musicGroupPaymentCalenderDao.batchUpdate(musicGroupPaymentCalenderList);
+            
+        }else if(musicGroup.getStatus() == MusicGroupStatusEnum.FEE_AUDIT){
+        	musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "乐团审核失败(费用审核中 -> 费用审核失败)", sysUser.getId(), memo));
+        	List<PaymentCalenderStatusEnum> statusList = new ArrayList<MusicGroupPaymentCalender.PaymentCalenderStatusEnum>();
+            statusList.add(PaymentCalenderStatusEnum.AUDITING);
+            //修改乐团报名缴费项目状态
+            List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList = musicGroupPaymentCalenderDao.queryByPaymentStatus(musicGroupId, statusList, null);
+            
+            musicGroupPaymentCalenderList.forEach(t -> {
+            	t.setStatus(PaymentCalenderStatusEnum.REJECT);
+            	t.setUpdateTime(date);
+            	t.setMemo(memo);
             });
-            musicGroupPaymentCalenderDao.batchUpdate(musicGroupPaymentCalenders);
+            
+            musicGroupPaymentCalenderDao.batchUpdate(musicGroupPaymentCalenderList);
+            
+            //修改乐团状态
+            musicGroup.setStatus(MusicGroupStatusEnum.FEE_AUDIT_FAILED);
+            musicGroup.setUpdateTime(date);
+            musicGroupDao.update(musicGroup);
         }
+        
     }
 
     @Override
@@ -1585,44 +1552,58 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (sysUser == null) {
             throw new BizException("用户信息获取失败");
         }
-        MusicGroup musicGroup = saveLog(musicGroupId, MusicGroupStatusEnum.AUDIT);
+        MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
+        if (musicGroup == null) {
+            throw new BizException("乐团信息不存在");
+        }
         if (musicGroup.getTenantId() == null) {
             throw new BizException("乐团机构信息异常,请联系管理员");
         }
-        //记录操作日志
-        musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "审核通过(审核中 -> 预报名)", sysUser.getId(), ""));
-        musicGroup.setStatus(MusicGroupStatusEnum.PRE_APPLY);
-        musicGroupDao.update(musicGroup);
-
-        // 创建群
-        imGroupService.create(musicGroupId, null, "乐团预报名", null,
-                musicGroup.getName(), musicGroup.getName(), null, GroupType.MUSIC.getCode(), ImGroup.GroupTypeEnum.PARENT_MEETING);
-
-        Map<Integer, String> userRoleMap = new HashMap<Integer, String>();
-
-        if (musicGroup.getTeamTeacherId() != null) {
-            userRoleMap.put(musicGroup.getTeamTeacherId(), "运营主管");
-        }
-        if (musicGroup.getEducationalTeacherId() != null) {
-            userRoleMap.put(musicGroup.getEducationalTeacherId(), "乐团主管");
-        }
-        if (musicGroup.getDirectorUserId() != null) {
-            userRoleMap.put(musicGroup.getDirectorUserId(), "乐队指导");
-        }
-        if (musicGroup.getTransactionTeacherId() != null) {
-            userRoleMap.put(musicGroup.getTransactionTeacherId(), "衔接老师");
+        if (musicGroup.getStatus() != MusicGroupStatusEnum.AUDIT) {
+            throw new BizException("当前乐团状态不支持此操作");
         }
-        // 添加成员
-        imGroupMemberService.join(musicGroupId, userRoleMap);
-        //缴费老师推送消息
-        sendSeoMessageSource.sendSeoMessage(musicGroup.getOrganId(), null,
-                null, musicGroup.getEducationalTeacherId(), MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_ADJUST_SUCCESS, musicGroup.getName());
-        Map<Integer, String> map = new HashMap<>(1);
-        map.put(musicGroup.getEducationalTeacherId(), musicGroup.getEducationalTeacherId().toString());
-        if (map != null && map.size() > 0) {
-            sysMessageService.batchSendMessage(MessageSender.JIGUANG, MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_ADJUST_SUCCESS,
-                    map, null, 0, null, "SYSTEM", musicGroup.getName());
+        
+        Date date = new Date();
+        
+        if(musicGroup.getStatus() == MusicGroupStatusEnum.AUDIT){
+            //记录操作日志
+            musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "审核通过(审核中 -> 费用审核中)", sysUser.getId(), ""));
+            musicGroup.setStatus(MusicGroupStatusEnum.FEE_AUDIT);
+        }else if(musicGroup.getStatus() == MusicGroupStatusEnum.FEE_AUDIT){
+            musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "审核通过(费用审核中 -> 预报名)", sysUser.getId(), ""));
+            musicGroup.setStatus(MusicGroupStatusEnum.PRE_APPLY);
+            
+
+            List<PaymentCalenderStatusEnum> statusList = new ArrayList<MusicGroupPaymentCalender.PaymentCalenderStatusEnum>();
+            statusList.add(PaymentCalenderStatusEnum.AUDITING);
+            //修改乐团报名缴费项目状态
+            List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList = musicGroupPaymentCalenderDao.queryByPaymentStatus(musicGroupId, statusList, null);
+            
+            if(musicGroupPaymentCalenderList == null || musicGroupPaymentCalenderList.size() == 0){
+            	throw new BizException("没有审核中的缴费项目");
+            }
+            
+            musicGroupPaymentCalenderList.forEach(t -> {
+                if (t.getPayUserType() == SCHOOL) {
+                    if (t.getCurrentTotalAmount().compareTo(BigDecimal.ZERO) > 0) {
+                        t.setStatus(PaymentCalenderStatusEnum.OPEN);
+                    } else {
+                        t.setStatus(PaymentCalenderStatusEnum.PAID);
+                    }
+                } else if (date.after(t.getStartPaymentDate())) {
+                    t.setStatus(PaymentCalenderStatusEnum.OPEN);
+                } else if (date.after(t.getDeadlinePaymentDate())) {
+                    t.setStatus(PaymentCalenderStatusEnum.OVER);
+                } else {
+                    t.setStatus(PaymentCalenderStatusEnum.NO);
+                }
+            	t.setUpdateTime(date);
+            });
+            
+            musicGroupPaymentCalenderDao.batchUpdate(musicGroupPaymentCalenderList);
         }
+        musicGroup.setUpdateTime(date);
+        musicGroupDao.update(musicGroup);
     }
 
     @Override
@@ -1830,25 +1811,23 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
     @Override
     public boolean deleteMusicGroup(String musicGroupId) {
-
         MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
-
         if (musicGroup == null) {
             throw new BizException("乐团不存在");
         }
-
         if (musicGroup.getDelFlag() == true) {
             throw new BizException("乐团已删除");
         }
-
         if (musicGroup.getStatus() != MusicGroupStatusEnum.CANCELED) {
             throw new BizException("乐团当前状态是{},不能删除", musicGroup.getStatus().getMsg());
         }
-
+//        MusicGroupPaymentCalender musicGroupRegCalender = musicGroupPaymentCalenderService.findByMusicGroupRegCalender(musicGroupId);
+//        if(Objects.nonNull(musicGroupRegCalender)){
+//            musicGroupPaymentCalenderService.del(musicGroupRegCalender.getId());
+//        }
         musicGroup.setUpdateTime(new Date());
         musicGroup.setDelFlag(true);
         musicGroupDao.update(musicGroup);
-
         return true;
     }
 
@@ -1939,12 +1918,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             throw new BizException("乐团找不到");
         }
 
-        if (!(musicGroup.getStatus() == MusicGroupStatusEnum.APPLY ||
+        /*if (!(musicGroup.getStatus() == MusicGroupStatusEnum.APPLY ||
                 musicGroup.getStatus() == MusicGroupStatusEnum.PAY ||
                 musicGroup.getStatus() == MusicGroupStatusEnum.PREPARE ||
                 musicGroup.getStatus() == MusicGroupStatusEnum.PROGRESS)) {
             throw new BizException("乐团当前状态是[{}],不能延长缴费", musicGroup.getStatus().getMsg());
-        }
+        }*/
 
         Date date = new Date();
 
@@ -1959,7 +1938,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         MusicGroupPaymentCalender regCalender = musicGroupPaymentCalenderService.findByMusicGroupRegCalender(musicGroup.getId());
         if (regCalender != null && regCalender.getPayUserType().equals(MusicGroupPaymentCalender.PayUserType.STUDENT)) {
             regCalender.setDeadlinePaymentDate(expireDate);
-            regCalender.setStatus(MusicGroupPaymentCalender.PaymentCalenderStatusEnum.OPEN);
+            
+            //regCalender.setStatus(MusicGroupPaymentCalender.PaymentCalenderStatusEnum.OPEN);
             regCalender.setUpdateTime(date);
             musicGroupPaymentCalenderService.update(regCalender);
         }
@@ -3433,6 +3413,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         subFeeSettingDto.setMusicGroup(musicGroup);
         //获取付费主体
         subFeeSettingDto.setMusicGroupPaymentEntities(musicGroupPaymentEntitiesDao.findByMusicGroupId(musicGroupId));
+        subFeeSettingDto.setMaxMusicalInstrumentsProfits(organizationDao.get(musicGroup.getOrganId()).getMaxMusicalInstrumentsProfits());
         //获取缴费周期
         //List<Integer> paymentMonth = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId).stream().map(e -> e.getPaymentMonth()).collect(Collectors.toList());
         //subFeeSettingDto.setMonths(paymentMonth);

+ 19 - 47
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentAttendanceServiceImpl.java

@@ -1,66 +1,40 @@
 package com.ym.mec.biz.service.impl;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.stream.Collectors;
-
 import com.alibaba.fastjson.JSON;
-import com.ym.mec.biz.dal.dto.*;
-import com.ym.mec.biz.dal.entity.*;
-import com.ym.mec.biz.service.SysTenantConfigService;
-import com.ym.mec.common.tenant.TenantContextHolder;
-import com.ym.mec.util.encode.AES;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Isolation;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.transaction.interceptor.TransactionAspectSupport;
-import org.springframework.util.CollectionUtils;
-
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
-import com.ym.mec.biz.dal.dao.ClassGroupDao;
-import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
-import com.ym.mec.biz.dal.dao.CourseScheduleDao;
-import com.ym.mec.biz.dal.dao.CourseScheduleStudentPaymentDao;
-import com.ym.mec.biz.dal.dao.CourseScheduleTeacherSalaryDao;
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
-import com.ym.mec.biz.dal.dao.MusicGroupQuitDao;
-import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
-import com.ym.mec.biz.dal.dao.SchoolDao;
-import com.ym.mec.biz.dal.dao.StudentAttendanceDao;
-import com.ym.mec.biz.dal.dao.StudentDao;
-import com.ym.mec.biz.dal.dao.SysConfigDao;
-import com.ym.mec.biz.dal.dao.TeacherAttendanceDao;
-import com.ym.mec.biz.dal.enums.CourseStatusEnum;
-import com.ym.mec.biz.dal.enums.GroupType;
-import com.ym.mec.biz.dal.enums.MessageTypeEnum;
-import com.ym.mec.biz.dal.enums.StudentAttendanceStatusEnum;
-import com.ym.mec.biz.dal.enums.TeachModeEnum;
-import com.ym.mec.biz.dal.enums.YesOrNoEnum;
+import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.dto.*;
+import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.page.CourseHomeworkQueryInfo;
 import com.ym.mec.biz.dal.page.ExportStudentAttendanceQueryInfo;
 import com.ym.mec.biz.dal.page.StudentAttendanceQueryInfo;
 import com.ym.mec.biz.service.StudentAttendanceService;
 import com.ym.mec.biz.service.SysConfigService;
 import com.ym.mec.biz.service.SysMessageService;
+import com.ym.mec.biz.service.SysTenantConfigService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.common.tenant.TenantContextHolder;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
+import org.springframework.util.CollectionUtils;
+
+import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentAttendance> implements StudentAttendanceService {
@@ -778,9 +752,7 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
         }
     }
 
-
-    @Override
-    public PageInfo<ExportStudentAttendanceDto> exportStudentAttendancesQueryPage(ExportStudentAttendanceQueryInfo queryInfo) {
+    @Override    public PageInfo<ExportStudentAttendanceDto> exportStudentAttendancesQueryPage(ExportStudentAttendanceQueryInfo queryInfo) {
         PageInfo<ExportStudentAttendanceDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
         Map<String, Object> params = new HashMap<>();
         MapUtil.populateMap(params, queryInfo);

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

@@ -110,7 +110,7 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
             BigDecimal waitRemitFee = couponRemitFee;
             //已使用减免金额
             BigDecimal useRemitFee = BigDecimal.ZERO;
-            List<StudentPaymentOrderDetail> collect = studentPaymentOrderDetailList.stream().filter(e -> e.getPrice().compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
+            List<StudentPaymentOrderDetail> collect = studentPaymentOrderDetailList.stream().filter(e -> (e.getPrice().compareTo(BigDecimal.ZERO) > 0 && e.getType() != OrderDetailTypeEnum.ORGAN_SHARE_PROFIT)).collect(Collectors.toList());
             if (collect.size() == 0) {
                 throw new BizException("订单金额异常");
             }
@@ -571,9 +571,11 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
                         && !(o.getType() == MAINTENANCE)
                         && !(o.getType() == CLOUD_TEACHER)
                         && !(o.getType() == CLOUD_TEACHER_PLUS)
+                        && !(o.getType() == ORGAN_SHARE_PROFIT)
                         && !(o.getType() == ACCESSORIES))
                 .map(o -> o.getPrice().subtract(o.getRemitFee() == null ? BigDecimal.ZERO : o.getRemitFee()))
                 .reduce(BigDecimal.ZERO, BigDecimal::add);
+        
         if (studentRegistration.getTemporaryCourseFee() != null) {
             studentRegistration.setTemporaryCourseFee(new BigDecimal(0));
         }
@@ -609,6 +611,14 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
                         .map(StudentPaymentOrderDetail::getPrice)
                         .reduce(BigDecimal.ZERO, BigDecimal::add);
                 BigDecimal expectAmount = studentPaymentOrder.getExpectAmount();
+                
+				BigDecimal organShareProfit = allDetails.stream().filter(o -> o.getType() == ORGAN_SHARE_PROFIT).map(StudentPaymentOrderDetail::getPrice)
+						.reduce(BigDecimal.ZERO, BigDecimal::add);
+				
+				if(organShareProfit != null){
+					expectAmount = expectAmount.subtract(organShareProfit);
+				}
+                
                 //获取比例
                 BigDecimal ratioAmount = musicFee.divide(expectAmount, 6, BigDecimal.ROUND_HALF_UP);
                 //获取分配的减免金额

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

@@ -709,6 +709,8 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
                 order.setPayingStatus(2);
             }
             if (order.getOrderDetailList() == null) continue;
+            
+            BigDecimal organShareProfit = BigDecimal.ZERO;
             for (StudentPaymentOrderDetail studentPaymentOrderDetail : order.getOrderDetailList()) {
                 if (studentPaymentOrderDetail.getGoodsList() == null) continue;
 
@@ -724,6 +726,21 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
                 if (studentPaymentOrderDetail.getType() == OrderDetailTypeEnum.CLOUD_TEACHER || studentPaymentOrderDetail.getType() == OrderDetailTypeEnum.CLOUD_TEACHER_PLUS) {
                     studentPaymentOrderDetail.setCloudTeacherOrderDto(cloudTeacherOrderService.queryOrderInfoByOrderId(studentPaymentOrderDetail.getPaymentOrderId()));
                 }
+                
+                if (studentPaymentOrderDetail.getType() == OrderDetailTypeEnum.ORGAN_SHARE_PROFIT){
+                	organShareProfit = organShareProfit.add(studentPaymentOrderDetail.getPrice());
+                }
+            }
+            
+            StudentPaymentOrderDetail spod = null;
+            Iterator<StudentPaymentOrderDetail> iterator = order.getOrderDetailList().iterator();
+            while(iterator.hasNext()){
+            	spod = iterator.next();
+            	if(spod.getType() == OrderDetailTypeEnum.MUSICAL){
+            		spod.setPrice(spod.getPrice().add(organShareProfit));
+            	}else if(spod.getType() == OrderDetailTypeEnum.ORGAN_SHARE_PROFIT){
+            		iterator.remove();
+            	}
             }
         }
         return orders;

+ 25 - 23
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentRouteOrderServiceImpl.java

@@ -13,6 +13,7 @@ import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
+import com.ym.mec.biz.service.MusicGroupCalenderRefundPeriodService;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.tenant.TenantContextHolder;
 import com.ym.mec.util.date.DateUtil;
@@ -71,6 +72,8 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
     private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
     @Autowired
     private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
+    @Autowired
+    private MusicGroupCalenderRefundPeriodService musicGroupCalenderRefundPeriodService;
 
     @Override
     public BaseDAO<Long, StudentPaymentRouteOrder> getDAO() {
@@ -133,11 +136,6 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
     @Override
     @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
     public StudentPaymentRouteOrder addOutOrder(StudentPaymentRouteOrder studentPaymentRouteOrder) {
-//        Map<String, Object> params = new HashMap<>();
-//        params.put("transNo", studentPaymentRouteOrder.getTransNo());
-//        if (studentPaymentRouteOrderDao.queryAuditCount(params) > 0) {
-//            throw new BizException("流水号不能重复");
-//        }
         if (studentPaymentRouteOrder.getCalenderId() != null) {
             MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderDao.getSchoolCalender(studentPaymentRouteOrder.getCalenderId());
             if (musicGroupPaymentCalender == null) {
@@ -306,26 +304,30 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
             }
 
             //根据学校缴费项id,确定缴费状态
-            BigDecimal amount = studentPaymentRouteOrderDao.sumAmountByCalenderId(studentPaymentRouteOrder.getCalenderId());
-            List<MusicGroupPaymentCalenderDetail> calenderDetails = musicGroupPaymentCalenderDetailDao.getCalenderDetailWithCalender(studentPaymentRouteOrder.getCalenderId());
-            MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(studentPaymentRouteOrder.getCalenderId());
-
-            if (amount.compareTo(musicGroupPaymentCalender.getCurrentTotalAmount()) >= 0) {
-                musicGroupPaymentCalender.setActualNum(musicGroupPaymentCalender.getExpectNum());
-                musicGroupPaymentCalender.setStatus(MusicGroupPaymentCalender.PaymentCalenderStatusEnum.PAID);
-                musicGroupPaymentCalenderDao.update(musicGroupPaymentCalender);
-
-                for (MusicGroupPaymentCalenderDetail calenderDetail : calenderDetails) {
-//                    calenderDetail.setActualAmount(calenderDetail.getExpectAmount().add(calenderDetail.getExpectMemberAmount()));
-                    calenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED);
-                    calenderDetail.setPayTime(nowDate);
-                    calenderDetail.setUpdateTime(nowDate);
-                }
-                if (calenderDetails.size() > 0) {
-                    musicGroupPaymentCalenderDetailDao.batchUpdate(calenderDetails);
+//            BigDecimal amount = studentPaymentRouteOrderDao.sumAmountByCalenderId(studentPaymentRouteOrder.getCalenderId());
+            //修改学员缴费回款周期
+            Boolean aBoolean = musicGroupCalenderRefundPeriodService.calcRefundAmount(studentPaymentRouteOrder.getCalenderId(),studentPaymentRouteOrder.getOrderNo(), studentPaymentRouteOrder.getRouteAmount());
+
+            //是否已完成回款
+            if(aBoolean){
+                List<MusicGroupPaymentCalenderDetail> calenderDetails = musicGroupPaymentCalenderDetailDao.getCalenderDetailWithCalender(studentPaymentRouteOrder.getCalenderId());
+                MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(studentPaymentRouteOrder.getCalenderId());
+
+                if (studentPaymentRouteOrder.getRouteAmount().compareTo(musicGroupPaymentCalender.getCurrentTotalAmount()) >= 0) {
+                    musicGroupPaymentCalender.setActualNum(musicGroupPaymentCalender.getExpectNum());
+                    musicGroupPaymentCalender.setStatus(MusicGroupPaymentCalender.PaymentCalenderStatusEnum.PAID);
+                    musicGroupPaymentCalenderDao.update(musicGroupPaymentCalender);
+
+                    for (MusicGroupPaymentCalenderDetail calenderDetail : calenderDetails) {
+                        calenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED);
+                        calenderDetail.setPayTime(nowDate);
+                        calenderDetail.setUpdateTime(nowDate);
+                    }
+                    if (calenderDetails.size() > 0) {
+                        musicGroupPaymentCalenderDetailDao.batchUpdate(calenderDetails);
+                    }
                 }
             }
-
         }
         return true;
     }

+ 214 - 51
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -1,16 +1,158 @@
 package com.ym.mec.biz.service.impl;
 
+import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.NON_PAYMENT;
+import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED;
+import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.MAINTENANCE;
+import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.PRACTICE;
+import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.VIP;
+import static com.ym.mec.biz.dal.enums.PaymentStatusEnum.YES;
+import static com.ym.mec.biz.dal.enums.SysUserRoleEnum.ORGAN_MANAGER;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Collectors;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
 import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.auth.api.enums.CertificateTypeEnum;
-import com.ym.mec.biz.dal.dao.*;
-import com.ym.mec.biz.dal.dto.*;
-import com.ym.mec.biz.dal.entity.*;
-import com.ym.mec.biz.dal.enums.*;
-import com.ym.mec.biz.dal.page.*;
+import com.ym.mec.biz.dal.dao.CourseScheduleDao;
+import com.ym.mec.biz.dal.dao.GoodsDao;
+import com.ym.mec.biz.dal.dao.GoodsProcurementDao;
+import com.ym.mec.biz.dal.dao.ImGroupDao;
+import com.ym.mec.biz.dal.dao.MusicGroupDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderStudentDetailDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentStudentCourseDetailDao;
+import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
+import com.ym.mec.biz.dal.dao.MusicGroupSubjectPlanDao;
+import com.ym.mec.biz.dal.dao.OrganizationDao;
+import com.ym.mec.biz.dal.dao.StudentCourseFeeDetailDao;
+import com.ym.mec.biz.dal.dao.StudentDao;
+import com.ym.mec.biz.dal.dao.StudentInstrumentDao;
+import com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao;
+import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
+import com.ym.mec.biz.dal.dao.SubjectChangeDao;
+import com.ym.mec.biz.dal.dao.SubjectDao;
+import com.ym.mec.biz.dal.dao.SysConfigDao;
+import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
+import com.ym.mec.biz.dal.dao.TeacherDao;
+import com.ym.mec.biz.dal.dto.MusicGroupApplyGoodsDto;
+import com.ym.mec.biz.dal.dto.NoClassMusicStudentDto;
+import com.ym.mec.biz.dal.dto.PageInfoReg;
+import com.ym.mec.biz.dal.dto.RegisterDto;
+import com.ym.mec.biz.dal.dto.RegisterPayDto;
+import com.ym.mec.biz.dal.dto.StudentAddDto;
+import com.ym.mec.biz.dal.dto.StudentApplyDetailDto;
+import com.ym.mec.biz.dal.dto.StudentCourseInfoDto;
+import com.ym.mec.biz.dal.dto.StudentInfo;
+import com.ym.mec.biz.dal.dto.StudentMusicDetailDto;
+import com.ym.mec.biz.dal.dto.StudentMusicGroupDto;
+import com.ym.mec.biz.dal.dto.StudentRegisterInstrumentsDetailDto;
+import com.ym.mec.biz.dal.entity.ClassGroup;
+import com.ym.mec.biz.dal.entity.ClassGroupStudentMapper;
+import com.ym.mec.biz.dal.entity.CloudTeacherOrder;
+import com.ym.mec.biz.dal.entity.CooperationOrgan;
+import com.ym.mec.biz.dal.entity.CouponPayParam;
+import com.ym.mec.biz.dal.entity.CouponPayTypeInfo;
+import com.ym.mec.biz.dal.entity.CourseSchedule;
+import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
+import com.ym.mec.biz.dal.entity.Goods;
+import com.ym.mec.biz.dal.entity.GoodsProcurement;
+import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderActivity;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderMember;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderRepair;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderStudentDetail;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
+import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
+import com.ym.mec.biz.dal.entity.MusicGroupSubjectGoodsGroup;
+import com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan;
+import com.ym.mec.biz.dal.entity.Organization;
+import com.ym.mec.biz.dal.entity.Student;
+import com.ym.mec.biz.dal.entity.StudentCourseFeeDetail;
+import com.ym.mec.biz.dal.entity.StudentInstrument;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
+import com.ym.mec.biz.dal.entity.StudentRegistration;
+import com.ym.mec.biz.dal.entity.Subject;
+import com.ym.mec.biz.dal.entity.SubjectChange;
+import com.ym.mec.biz.dal.entity.SysUserCashAccount;
+import com.ym.mec.biz.dal.entity.SysUserCashAccountDetail;
+import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
+import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
+import com.ym.mec.biz.dal.enums.CouponDetailTypeEnum;
+import com.ym.mec.biz.dal.enums.CourseStatusEnum;
+import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
+import com.ym.mec.biz.dal.enums.GoodsType;
+import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
+import com.ym.mec.biz.dal.enums.MessageTypeEnum;
+import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
+import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
+import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
+import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
+import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
+import com.ym.mec.biz.dal.enums.SysUserRoleEnum;
+import com.ym.mec.biz.dal.page.MusicGroupRecordStudentQueryInfo;
+import com.ym.mec.biz.dal.page.NoClassMusicStudentQueryInfo;
+import com.ym.mec.biz.dal.page.RegistrationOrPreQueryInfo;
+import com.ym.mec.biz.dal.page.StudentPreRegistrationQueryInfo;
+import com.ym.mec.biz.dal.page.StudentRegistrationQueryInfo;
 import com.ym.mec.biz.event.source.SendSeoMessageSource;
-import com.ym.mec.biz.service.*;
+import com.ym.mec.biz.service.ClassGroupService;
+import com.ym.mec.biz.service.ClassGroupStudentMapperService;
+import com.ym.mec.biz.service.CloudTeacherOrderService;
+import com.ym.mec.biz.service.ContractService;
+import com.ym.mec.biz.service.CourseScheduleService;
+import com.ym.mec.biz.service.CourseScheduleStudentPaymentService;
+import com.ym.mec.biz.service.GoodsService;
+import com.ym.mec.biz.service.ImGroupMemberService;
+import com.ym.mec.biz.service.MusicGroupPaymentCalenderActivityService;
+import com.ym.mec.biz.service.MusicGroupPaymentCalenderMemberService;
+import com.ym.mec.biz.service.MusicGroupPaymentCalenderRepairService;
+import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
+import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
+import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
+import com.ym.mec.biz.service.StudentPaymentOrderService;
+import com.ym.mec.biz.service.StudentRegistrationService;
+import com.ym.mec.biz.service.StudentService;
+import com.ym.mec.biz.service.SubjectService;
+import com.ym.mec.biz.service.SysConfigService;
+import com.ym.mec.biz.service.SysCouponCodeService;
+import com.ym.mec.biz.service.SysMessageService;
+import com.ym.mec.biz.service.SysTenantConfigService;
+import com.ym.mec.biz.service.SysUserCashAccountDetailService;
+import com.ym.mec.biz.service.SysUserCashAccountLogService;
+import com.ym.mec.biz.service.SysUserCashAccountService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.entity.ImResult;
@@ -24,29 +166,6 @@ import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.http.HttpUtil;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Propagation;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Collectors;
-
-import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.NON_PAYMENT;
-import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED;
-import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.*;
-import static com.ym.mec.biz.dal.enums.PaymentStatusEnum.YES;
-import static com.ym.mec.biz.dal.enums.SysUserRoleEnum.ORGAN_MANAGER;
 
 @Service
 public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, StudentRegistration> implements StudentRegistrationService {
@@ -528,7 +647,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         if(musicGroup == null){
         	throw new BizException("乐团[{}]信息查询失败", studentRegistration.getMusicGroupId());
         }
-        
+        MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(studentPaymentOrder.getCalenderId());
+
         boolean isGiveAccessories = musicGroup.getIsGiveAccessories() == null ? false : musicGroup.getIsGiveAccessories();
         
         Date date = new Date();
@@ -539,6 +659,9 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         List<MusicGroupPaymentCalenderCourseSettings> newCourses = goodsDto.getNewCourses();
         BigDecimal remitFee = goodsDto.getRemitFee();
         if (CollectionUtils.isNotEmpty(goodsGroups)) {
+        	
+        	BigDecimal organShareProfit = BigDecimal.ZERO;
+        	
             for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
                 StudentPaymentOrderDetail studentPaymentOrderDetail4goodsGroup = new StudentPaymentOrderDetail();
                 studentPaymentOrderDetail4goodsGroup.setRemitFee(BigDecimal.ZERO);
@@ -580,6 +703,22 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 if (OrderDetailTypeEnum.MUSICAL.equals(type)) {
                     maintenanceGoodsId = goodsGroup.getGoodsIdList();
                 }
+                
+                if(goodsGroup.getOrganShareProfit() != null){
+                	organShareProfit = organShareProfit.add(goodsGroup.getOrganShareProfit());
+                }
+            }
+            
+            //分部分润
+            if(organShareProfit.compareTo(BigDecimal.ZERO) > 0) {
+            	StudentPaymentOrderDetail spod = new StudentPaymentOrderDetail();
+                spod.setType(OrderDetailTypeEnum.ORGAN_SHARE_PROFIT);
+                spod.setPrice(organShareProfit);
+                spod.setRemitFee(BigDecimal.ZERO);
+                spod.setCreateTime(date);
+                spod.setUpdateTime(date);
+                spod.setPaymentOrderId(studentPaymentOrder.getId());
+                studentPaymentOrderDetailList.add(spod);
             }
         }
 
@@ -635,13 +774,21 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         }
 
         //活动 todo  VIP 或 网管课
+        List<MusicGroupPaymentCalenderActivity> calenderActivities = null;
         List<Long> buyCalenderActivityId = registerPayDto.getBuyCalenderActivityId();
         if (CollectionUtils.isNotEmpty(buyCalenderActivityId)) {
-            List<MusicGroupPaymentCalenderActivity> calenderActivities = musicGroupPaymentCalenderActivityService.findByIds(buyCalenderActivityId);
+            calenderActivities = musicGroupPaymentCalenderActivityService.findByIds(buyCalenderActivityId);
+        }else if(Objects.nonNull(calender) && calender.getPayUserType() == MusicGroupPaymentCalender.PayUserType.SCHOOL){
+            calenderActivities = musicGroupPaymentCalenderActivityService.findByCalenderId(calender.getId());
+        }
+        if(CollectionUtils.isNotEmpty(calenderActivities)){
             for (MusicGroupPaymentCalenderActivity calenderActivity : calenderActivities) {
                 StudentPaymentOrderDetail maintenanceOrderDetail = new StudentPaymentOrderDetail();
                 maintenanceOrderDetail.setType("网管课".equals(calenderActivity.getCategoryName()) ? PRACTICE : VIP);
                 maintenanceOrderDetail.setPrice(calenderActivity.getActualAmount());
+                if(calender.getPayUserType() == MusicGroupPaymentCalender.PayUserType.SCHOOL){
+                    maintenanceOrderDetail.setPrice(BigDecimal.ZERO);
+                }
                 maintenanceOrderDetail.setRemitFee(BigDecimal.ZERO);
                 maintenanceOrderDetail.setCreateTime(date);
                 maintenanceOrderDetail.setUpdateTime(date);
@@ -653,18 +800,24 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             }
         }
 
+
         //云教练/云教练+  todo  团练宝
-        if (registerPayDto.getBuyCloudTeacher()) {
+        if (registerPayDto.getBuyCloudTeacher() || (Objects.nonNull(calender) && calender.getPayUserType() == MusicGroupPaymentCalender.PayUserType.SCHOOL)) {
             MusicGroupPaymentCalenderMember calenderMember = musicGroupPaymentCalenderMemberService.findByCalenderId(studentPaymentOrder.getCalenderId());
-            StudentPaymentOrderDetail cloudTeacherOrderDetail = new StudentPaymentOrderDetail();
-            cloudTeacherOrderDetail.setType(OrderDetailTypeEnum.CLOUD_TEACHER);
-            cloudTeacherOrderDetail.setPrice(calenderMember.getActualAmount());
-            cloudTeacherOrderDetail.setRemitFee(BigDecimal.ZERO);
-            cloudTeacherOrderDetail.setCreateTime(date);
-            cloudTeacherOrderDetail.setUpdateTime(date);
-            cloudTeacherOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
-            cloudTeacherOrderDetail.setIsRenew(0);
-            studentPaymentOrderDetailList.add(cloudTeacherOrderDetail);
+            if(Objects.nonNull(calenderMember)){
+                StudentPaymentOrderDetail cloudTeacherOrderDetail = new StudentPaymentOrderDetail();
+                cloudTeacherOrderDetail.setType(OrderDetailTypeEnum.CLOUD_TEACHER);
+                cloudTeacherOrderDetail.setPrice(calenderMember.getActualAmount());
+                if(calender.getPayUserType() == MusicGroupPaymentCalender.PayUserType.SCHOOL){
+                    cloudTeacherOrderDetail.setPrice(BigDecimal.ZERO);
+                }
+                cloudTeacherOrderDetail.setRemitFee(BigDecimal.ZERO);
+                cloudTeacherOrderDetail.setCreateTime(date);
+                cloudTeacherOrderDetail.setUpdateTime(date);
+                cloudTeacherOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
+                cloudTeacherOrderDetail.setIsRenew(0);
+                studentPaymentOrderDetailList.add(cloudTeacherOrderDetail);
+            }
         }
 
         //开始计算商品的优惠券
@@ -1438,9 +1591,10 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 //当前课程类型总课程时长
                 Integer typeCourseDuration = courseTypeCourseDurationMap.get(courseScheduleTypeListEntry.getKey());
 
-                String batchNo = musicGroupPaymentStudentCourseDetailDao.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, student.getUserId(), courseScheduleTypeListEntry.getKey(), null);
+//                String batchNo = musicGroupPaymentStudentCourseDetailDao.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, student.getUserId(), courseScheduleTypeListEntry.getKey(), null);
 
-                List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(batchNo, student.getUserId(), courseScheduleTypeListEntry.getKey());
+                List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails =
+                        musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(student.getUserId(), courseScheduleTypeListEntry.getKey(),musicGroupId);
                 int totalCourseMinutes = musicGroupPaymentStudentCourseDetails.stream().mapToInt(MusicGroupPaymentStudentCourseDetail::getTotalCourseMinutes).reduce(0, Integer::sum);
                 if (CollectionUtils.isEmpty(musicGroupPaymentStudentCourseDetails) || totalCourseMinutes < typeCourseDuration) {
                     iterator.remove();
@@ -1676,15 +1830,15 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             if (regCalender == null) {
                 return "乐团没有报名缴费项";
             }
-            List<MusicGroupPaymentCalender> musicGroupCalenderBatchNoTimes = musicGroupPaymentCalenderDao.getMusicGroupCalenderBatchNoTimes(musicGroup.getId());
+            /*List<MusicGroupPaymentCalender> musicGroupCalenderBatchNoTimes = musicGroupPaymentCalenderDao.getMusicGroupCalenderBatchNoTimes(musicGroup.getId());
             if (musicGroupCalenderBatchNoTimes.size() > 1) {
                 return "乐团已进入续费阶段";
-            }
+            }*/
 
-//            Integer hasStartCourseNum = courseScheduleDao.getMusicGroupHasStartCourseNum(musicGroup.getId());
-//            if (hasStartCourseNum != null && hasStartCourseNum > 0) {
-//                return "乐团已开课";
-//            }
+            Integer hasStartCourseNum = courseScheduleDao.getMusicGroupHasStartCourseNum(musicGroup.getId());
+            if (hasStartCourseNum != null && hasStartCourseNum > 0) {
+                return "乐团已开课";
+            }
         }
         return null;
     }
@@ -1696,13 +1850,22 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         for (MusicGroupPaymentCalender regCalender : regCalenders) {
             viewMap.put(regCalender.getMusicGroupId(), true);
         }
+        
+        //判断乐团是否开课
+        List<MusicGroup> musicGroupList = musicGroupDao.getMusicGroupByIds(ids);
+        
+        for(MusicGroup mg : musicGroupList){
+        	if (viewMap.containsKey(mg.getId()) && mg.getFirstCourseStartTime() != null) {
+                viewMap.remove(mg.getId());
+            }
+        }
 
-        Map<String, List<MusicGroupPaymentCalender>> musicGroupBatchNoTimes = musicGroupPaymentCalenderDao.getMusicGroupCalenderBatchNoByIds(ids).stream().collect(Collectors.groupingBy(MusicGroupPaymentCalender::getMusicGroupId));
+        /*Map<String, List<MusicGroupPaymentCalender>> musicGroupBatchNoTimes = musicGroupPaymentCalenderDao.getMusicGroupCalenderBatchNoByIds(ids).stream().collect(Collectors.groupingBy(MusicGroupPaymentCalender::getMusicGroupId));
         musicGroupBatchNoTimes.forEach((musicGroupId, calenders) -> {
             if (viewMap.containsKey(musicGroupId) && calenders.size() > 1) {
                 viewMap.remove(musicGroupId);
             }
-        });
+        });*/
         return viewMap;
     }
 

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

@@ -533,7 +533,7 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
         subjectChangeDao.insert(subjectChange);
         //差价小于0退到余额
         if (amountMargin.compareTo(BigDecimal.ZERO) <= 0) {
-//            sysUserCashAccountService.updateBalance(subjectChange.getStudentId(), amountMargin.negate(), PlatformCashAccountDetailTypeEnum.REFUNDS, "声部更换退还");
+            /*sysUserCashAccountService.updateBalance(subjectChange.getStudentId(), amountMargin.negate(), PlatformCashAccountDetailTypeEnum.REFUNDS, "声部更换退还");
             if (amountMargin.compareTo(BigDecimal.ZERO) < 0) {
                 SysUserCashAccountLog sysUserCashAccountLog = new SysUserCashAccountLog();
                 sysUserCashAccountLog.setUserId(subjectChange.getStudentId());
@@ -544,7 +544,7 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
                 sysUserCashAccountLog.setReturnFeeType(ReturnFeeEnum.SUBJECT_CHANGE);
                 sysUserCashAccountLog.setComment("声部更换退还");
                 sysUserCashAccountLogDao.insert(sysUserCashAccountLog);
-            }
+            }*/
             studentRegistrationService.changeStudentSubject(subjectChange.getStudentId(), subjectChange.getMusicGroupId(), subjectChange.getOriginalSubjectId(), subjectChange.getChangeSubjectId());
         }
 

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

@@ -56,7 +56,7 @@ public class SysEmployeePositionServiceImpl extends BaseServiceImpl<Integer, Sys
 		if(organPosition != null && organPosition.size() > 0){
 			Map<Integer, List<SimpleUserDto>> collect = organPosition.stream().collect(Collectors.groupingBy(e -> e.getPositionId()));
 			Map<String,List<SimpleUserDto>> resultMap = new HashMap<>(collect.size());
-			Map<Integer,String> positionNameMap = MapUtil.convertMybatisMap(positionDao.findMapByIds(collect.keySet()));
+			Map<Integer,String> positionNameMap = MapUtil.convertMybatisMap(positionDao.findMapByIds());
 			collect.keySet().forEach(e->resultMap.put(positionNameMap.get(e),collect.get(e)));
 			return resultMap;
 		}

+ 132 - 0
mec-biz/src/main/resources/config/mybatis/CooperationShareProfitMapper.xml

@@ -0,0 +1,132 @@
+<?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.CooperationShareProfitDao">
+	
+	<resultMap type="com.ym.mec.biz.dal.entity.CooperationShareProfit" id="CooperationShareProfit">
+		<result column="id_" property="id" />
+		<result column="organ_id_" property="organId" />
+		<result column="cooperation_id_" property="cooperationId" />
+		<result column="music_group_id_" property="musicGroupId" />
+		<result column="musical_num_" property="musicalNum" />
+		<result column="total_amount_" property="totalAmount" />
+		<result column="payment_status_" property="paymentStatus" />
+		<result column="credentials_" property="credentials" />
+		<result column="payment_no_" property="paymentNo" />
+		<result column="memo_" property="memo" />
+		<result column="credentials_" property="credentials" />
+		<result column="create_time_" property="createTime" />
+		<result column="update_time_" property="updateTime" />
+	</resultMap>
+	
+	<!-- 根据主键查询一条记录 -->
+	<select id="get" resultMap="CooperationShareProfit" >
+		SELECT * FROM cooperation_share_profit WHERE id_ = #{id} 
+	</select>
+	
+	<!-- 全查询 -->
+	<select id="findAll" resultMap="CooperationShareProfit">
+		SELECT * FROM cooperation_share_profit ORDER BY id_
+	</select>
+	
+	<!-- 向数据库增加一条记录 -->
+	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.CooperationShareProfit" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+		INSERT INTO cooperation_share_profit (organ_id_,cooperation_id_,music_group_id_,musical_num_,total_amount_,payment_status_,payment_no_,memo_,create_time_,update_time_)
+		VALUES(#{organId},#{cooperationId},#{musicGroupId},#{musicalNum},#{totalAmount},#{paymentStatus},#{paymentNo},#{memo},NOW(),NOW())
+	</insert>
+	<insert id="batchInsert">
+		INSERT INTO cooperation_share_profit (organ_id_,cooperation_id_,music_group_id_,musical_num_,total_amount_,
+		                                      payment_status_,create_time_,update_time_)
+		VALUES
+		<foreach collection="profits" item="bean" separator=",">
+			(#{bean.organId},#{bean.cooperationId},#{bean.musicGroupId},#{bean.musicalNum},#{bean.totalAmount},
+			 #{bean.paymentStatus},NOW(),NOW())
+		</foreach>
+	</insert>
+
+	<!-- 根据主键查询一条记录 -->
+	<update id="update" parameterType="com.ym.mec.biz.dal.entity.CooperationShareProfit">
+		UPDATE cooperation_share_profit <set>
+		<if test="credentials != null and credentials != ''">
+			credentials_ = #{credentials},
+		</if>
+		<if test="paymentNo != null">
+			payment_no_ = #{paymentNo},
+		</if>
+		<if test="paymentStatus != null">
+			payment_status_ = #{paymentStatus},
+		</if>
+		<if test="memo != null">
+			memo_ = #{memo},
+		</if>
+			update_time_ = NOW()
+	</set> WHERE id_ = #{id}
+	</update>
+	
+	<!-- 根据主键删除一条记录 -->
+	<delete id="delete" >
+		DELETE FROM cooperation_share_profit WHERE id_ = #{id} 
+	</delete>
+	
+	<!-- 分页查询 -->
+	<select id="queryPage" resultMap="CooperationShareProfit" parameterType="map">
+		SELECT * FROM cooperation_share_profit ORDER BY id_ <include refid="global.limit"/>
+	</select>
+	
+	<!-- 查询当前表的总记录数 -->
+	<select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM cooperation_share_profit
+	</select>
+	<select id="queryNotShare" resultType="java.lang.String">
+		select music_group_id_ from cooperation_share_profit where music_group_id_ IN
+		<foreach collection="musicGroupIds" item="id" open="(" close=")">
+			#{id}
+		</foreach>
+	</select>
+	<select id="initShareProfit" resultMap="CooperationShareProfit">
+		select spo.organ_id_,mg.cooperation_organ_id_ cooperation_id_,sr.music_group_id_,spod.price_,COUNT(distinct spod.id_) musical_num_,
+		SUM(CASE WHEN spod.price_ IS NULL THEN 0 ELSE spod.price_ END) total_amount_ from student_registration sr
+		left join music_group mg ON mg.id_ = sr.music_group_id_
+		left join music_group_payment_calender mgpc ON mgpc.id_ = sr.music_group_payment_calender_id_
+		left join student_payment_order spo ON spo.calender_id_ = sr.music_group_payment_calender_id_ and sr.user_id_ = spo.user_id_
+		left join student_payment_order_detail spod ON spod.payment_order_id_ = spo.id_
+		where sr.music_group_id_ IN
+		<foreach collection="musicGroupIds" item="id" open="(" close=")">
+			#{id}
+		</foreach>
+		AND sr.music_group_status_ = 'NORMAL'
+		AND mgpc.payment_type_ = 'MUSIC_APPLY' AND spo.type_ = 'APPLY' AND spo.status_ = 'SUCCESS' AND spod.type_ = 'ORGAN_SHARE_PROFIT'
+		group by sr.music_group_id_
+	</select>
+	<resultMap id="CooperationShareProfitDto" type="com.ym.mec.biz.dal.entity.CooperationShareProfitDto" extends="CooperationShareProfit">
+		<result property="educationUserId" column="education_user_id_"/>
+		<result property="cooperationName" column="cooperation_organ_name_"/>
+	</resultMap>
+	<sql id="queryDtoPageSql">
+		<where>
+			<if test="organId != null and organId != ''">
+				AND FIND_IN_SET(csp.organ_id_,#{organId})
+			</if>
+			<if test="cooperationOrganId != null">
+				AND csp.cooperation_id_ = #{cooperationOrganId}
+			</if>
+			<if test="paymentStatus != null and paymentStatus != ''">
+				AND csp.payment_status_ = #{paymentStatus}
+			</if>
+		</where>
+	</sql>
+	<select id="countDto" resultType="java.lang.Integer">
+		SELECT COUNT(csp.id_) FROM cooperation_share_profit csp
+		<include refid="queryDtoPageSql"/>
+	</select>
+	<select id="queryDtoPage" resultMap="CooperationShareProfitDto">
+		SELECT csp.*,co.education_user_id_,co.name_ cooperation_organ_name_ FROM cooperation_share_profit csp
+		left join cooperation_organ co ON co.id_ = csp.cooperation_id_
+		<include refid="queryDtoPageSql"/>
+		ORDER BY csp.id_
+		<include refid="global.limit"/>
+	</select>
+</mapper>

+ 209 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupCalenderRefundPeriodMapper.xml

@@ -0,0 +1,209 @@
+<?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.MusicGroupCalenderRefundPeriodDao">
+	
+	<resultMap type="com.ym.mec.biz.dal.entity.MusicGroupCalenderRefundPeriod" id="MusicGroupCalenderRefundPeriod">
+		<result column="id_" property="id" />
+		<result column="organ_id_" property="organId" />
+		<result column="order_nos_" property="orderNos" />
+		<result column="cooperation_organ_id_" property="cooperationOrganId" />
+		<result column="calender_id_" property="calenderId" />
+		<result column="refund_date_" property="refundDate" />
+		<result column="refund_amount_" property="refundAmount" />
+		<result column="income_" property="income" />
+		<result column="sub_refund_amount_" property="subRefundAmount" />
+		<result column="refund_flag_" property="refundFlag" />
+		<result column="create_time_" property="createTime" />
+		<result column="update_time_" property="updateTime" />
+	</resultMap>
+
+	<update id="batchUpdate">
+		<foreach collection="refundPeriods" item="bean" index="index" open="" close="" separator=";">
+			UPDATE music_group_calender_refund_period <set>
+			<if test="bean.orderNos != null and bean.orderNos != ''">
+				order_nos_ = #{bean.orderNos},
+			</if>
+			<if test="bean.subRefundAmount != null">
+				sub_refund_amount_ = #{bean.subRefundAmount},
+			</if>
+			<if test="bean.income != null">
+				income_ = #{bean.income},
+			</if>
+			<if test="bean.refundFlag != null">
+				refund_flag_ = #{bean.refundFlag},
+			</if>
+			update_time_ = #{bean.updateTime}
+		</set> WHERE id_ = #{bean.id}
+		</foreach>
+	</update>
+	<delete id="deleteByCalenderId">
+		DELETE FROM music_group_calender_refund_period WHERE calender_id_ = #{calenderId}
+	</delete>
+
+	<!-- 全查询 -->
+	<select id="findAll" resultMap="MusicGroupCalenderRefundPeriod">
+		SELECT * FROM music_group_calender_refund_period
+	</select>
+	
+	<!-- 向数据库增加一条记录 -->
+	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupCalenderRefundPeriod" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+		INSERT INTO music_group_calender_refund_period (organ_id_,cooperation_organ_id_,calender_id_,
+		                                                refund_date_,refund_amount_,sub_refund_amount_,income_,refund_flag_,order_nos_,create_time_,update_time_)
+		VALUES(#{organId},#{cooperationOrganId},#{calenderId},#{refundDate},#{refundAmount},#{subRefundAmount},#{income},#{refundFlag},#{orderNos},NOW(),NOW())
+	</insert>
+	<insert id="batchInsert">
+		INSERT INTO music_group_calender_refund_period (organ_id_,cooperation_organ_id_,calender_id_,
+														refund_date_,refund_amount_,sub_refund_amount_,income_,refund_flag_,order_nos_,create_time_,update_time_)
+		VALUES
+		<foreach collection="refundPeriods" separator="," item="bean">
+			(#{bean.organId},#{bean.cooperationOrganId},#{bean.calenderId},#{bean.refundDate},
+			 #{bean.refundAmount},#{bean.subRefundAmount},#{bean.income},#{bean.refundFlag},#{bean.orderNos},#{bean.createTime},#{bean.updateTime})
+		</foreach>
+	</insert>
+
+	<update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupCalenderRefundPeriod">
+		UPDATE music_group_calender_refund_period <set>
+		<if test="orderNos != null and orderNos != ''">
+			order_nos_ = #{orderNos},
+		</if>
+		<if test="subRefundAmount != null">
+			sub_refund_amount_ = #{subRefundAmount},
+		</if>
+		<if test="income != null">
+			income_ = #{income},
+		</if>
+		<if test="refundFlag != null">
+			refund_flag_ = #{refundFlag},
+		</if>
+		update_time_ = NOW()
+	</set> WHERE id_ = #{id}
+	</update>
+
+	<!-- 分页查询 -->
+	<select id="queryPage" resultMap="MusicGroupCalenderRefundPeriod" parameterType="map">
+		SELECT * FROM music_group_calender_refund_period <include refid="global.limit"/>
+	</select>
+	
+	<!-- 查询当前表的总记录数 -->
+	<select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM music_group_calender_refund_period
+	</select>
+	<select id="findByCalenderId" resultMap="MusicGroupCalenderRefundPeriod">
+		SELECT * FROM music_group_calender_refund_period where calender_id_ = #{calenderId} ORDER BY refund_date_
+	</select>
+	<resultMap id="CooperationRefundDto" type="com.ym.mec.biz.dal.dto.CooperationRefundDto">
+		<result property="organId" column="organ_id_"/>
+		<result property="cooperationOrganId" column="cooperation_organ_id_"/>
+		<result property="cooperationOrganName" column="cooperation_organ_name_"/>
+		<result property="receivable" column="receivable_"/>
+		<result property="prepaidFee" column="prepaidFee"/>
+		<result property="educationUserId" column="education_user_id_"/>
+	</resultMap>
+	<sql id="queryCoopRefundSql">
+		<where>
+			mgpc.status_ IN ('OPEN','OVER','PAID')
+			<if test="errorType != null and errorType != ''">
+				<if test="errorType == 'COOPERATION_PAYMENT_ERROR'">
+					AND TIMESTAMPDIFF(DAY,crp.refund_date_,DATE_FORMAT(NOW(),'%Y-%m-%d')) >= 1
+				</if>
+				<if test="errorType == 'COOPERATION_PAYMENT_ALERT'">
+					AND TIMESTAMPDIFF(DAY,crp.refund_date_,DATE_FORMAT(NOW(),'%Y-%m-%d')) BETWEEN -2 AND 0
+				</if>
+			</if>
+			<if test="organId != null and organId != ''">
+				AND FIND_IN_SET(crp.organ_id_,#{organId})
+			</if>
+			<if test="search != null and search != ''">
+				AND (co.name_ LIKE CONCAT('%',#{search},'%') OR co.id_ = #{search})
+			</if>
+		</where>
+	</sql>
+	<select id="countCoopRefund" resultType="java.lang.Integer">
+		select COUNT(DISTINCT crp.cooperation_organ_id_)
+		from music_group_calender_refund_period crp
+		left join cooperation_organ co ON co.id_ = crp.cooperation_organ_id_
+		left join music_group_payment_calender mgpc ON mgpc.id_ = crp.calender_id_
+		<include refid="queryCoopRefundSql"/>
+	</select>
+	<select id="queryCoopRefund" resultMap="CooperationRefundDto">
+		select co.organ_id_,crp.cooperation_organ_id_,co.name_ cooperation_organ_name_,
+		SUM(refund_amount_) receivable_,SUM(sub_refund_amount_) prepaidFee,co.education_user_id_
+		from music_group_calender_refund_period crp
+		left join cooperation_organ co ON co.id_ = crp.cooperation_organ_id_
+		left join music_group_payment_calender mgpc ON mgpc.id_ = crp.calender_id_
+		<include refid="queryCoopRefundSql"/>
+		group by crp.cooperation_organ_id_
+		order by crp.id_ DESC
+	</select>
+	<resultMap id="CooperationCalenderRefundDto" type="com.ym.mec.biz.dal.dto.CooperationCalenderRefundDto">
+		<result property="calenderId" column="calender_id_"/>
+		<result property="batchNo" column="batch_no_"/>
+		<result property="paymentType" column="payment_type_"/>
+		<result property="musicGroupId" column="music_group_id_"/>
+		<result property="musicGroupName" column="music_group_name_"/>
+		<result property="calenderFeeType" column="calender_fee_type_"/>
+		<result property="receivable" column="receivable_"/>
+		<result property="prepaidFee" column="prepaidFee"/>
+		<result property="income" column="income_"/>
+		<result property="nextRefundDate" column="nextRefundDate"/>
+		<result property="refundStatus" column="refundStatus"/>
+		<result property="contractUrl" column="contract_url_"/>
+	</resultMap>
+	<sql id="queryCoopCalenderSql">
+		<where>
+			mgpc.status_ IN ('OPEN','OVER','PAID')
+			<if test="cooperationId != null">
+				AND crp.cooperation_organ_id_ = #{cooperationId}
+			</if>
+			<if test="calenderId != null">
+				AND crp.calender_id_ = #{calenderId}
+			</if>
+			<if test="refundStartDate != null and refundStartDate != ''">
+				AND crp.refund_date_ BETWEEN #{refundStartDate} AND #{refundEndDate}
+			</if>
+			<if test="search != null and search != ''">
+				AND (mg.name_ LIKE CONCAT('%',#{search},'%') OR mg.id_ = #{search})
+			</if>
+		</where>
+	</sql>
+	<sql id="queryCoopCalenderHavingSql">
+		<if test="refundStatus != null and refundStatus != ''">
+			<if test="refundStatus == 'ING'">
+				HAVING SUM(crp.sub_refund_amount_) > 0
+			</if>
+			<if test="refundStatus == 'END'">
+				HAVING SUM(crp.sub_refund_amount_) = 0
+			</if>
+		</if>
+	</sql>
+	<select id="queryCoopCalender" resultMap="CooperationCalenderRefundDto">
+		select crp.calender_id_,mgpc.music_group_id_,mg.name_ music_group_name_,mgpc.batch_no_,mgpc.payment_type_,mgpc.calender_fee_type_,
+			   SUM(crp.refund_amount_) receivable_,SUM(crp.sub_refund_amount_) prepaidFee,SUM(crp.income_) income_,
+			   MIN(CASE WHEN crp.refund_flag_ = 0 THEN crp.refund_date_ ELSE NULL END) nextRefundDate,crp.organ_id_,mgpc.contract_url_
+		from music_group_calender_refund_period crp
+		left join music_group_payment_calender mgpc ON mgpc.id_ = crp.calender_id_
+		left join music_group mg ON mg.id_ = mgpc.music_group_id_
+		<include refid="queryCoopCalenderSql"/>
+		group by crp.calender_id_
+		<include refid="queryCoopCalenderHavingSql"/>
+	</select>
+	<select id="countCoopCalender" resultType="java.lang.Integer">
+		select COUNT(calender_id_) from (select crp.calender_id_
+		from music_group_calender_refund_period crp
+		left join music_group_payment_calender mgpc ON mgpc.id_ = crp.calender_id_
+		left join music_group mg ON mg.id_ = mgpc.music_group_id_
+		<include refid="queryCoopCalenderSql"/>
+		group by crp.calender_id_
+		<include refid="queryCoopCalenderHavingSql"/>)crp
+	</select>
+	<select id="sumCoopRefund" resultType="java.math.BigDecimal">
+		select CASE WHEN crp.id_ IS NULL THEN 0 ELSE SUM(sub_refund_amount_) END from music_group_calender_refund_period crp
+		left join cooperation_organ co ON co.id_ = crp.cooperation_organ_id_
+		left join music_group_payment_calender mgpc ON mgpc.id_ = crp.calender_id_
+		<include refid="queryCoopRefundSql"/>
+	</select>
+</mapper>

+ 32 - 2
mec-biz/src/main/resources/config/mybatis/MusicGroupMapper.xml

@@ -50,6 +50,13 @@
         <result column="homework_push_flag_" property="homeworkPushFlag"/>
         <result column="tenant_id_" property="tenantId"/>
         <result column="is_give_accessories_" property="isGiveAccessories"/>
+        <result column="music_group_plan_making_id_" property="musicGroupPlanMakingId"/>
+        <result column="first_recruit_grade_" property="firstRecruitGrade"/>
+        <result column="default_charge_standard_" property="defaultChargeStandard"/>
+        <result column="single_train_minutes_" property="singleTrainMinutes"/>
+        <result column="course_plan_" property="coursePlan"/>
+        <result column="sale_activity_desc_" property="saleActivityDesc"/>
+        <result column="graduate_grade_" property="graduateGrade"/>
     </resultMap>
 
     <resultMap type="com.ym.mec.biz.dal.dto.MusicGroupBasicDto" id="MusicGroupBasicDto" extends="MusicGroup">
@@ -109,7 +116,8 @@
                  settlement_type_, cooperation_organ_id_, enlightenment_course_time_,
                  parent_meeting_time_, img_, director_user_id_, is_classroom_lessons_, memo_, expect_start_group_date_,
                  ownership_type_, repair_user_id_, del_flag_, payment_valid_start_date_, payment_valid_end_date_,
-                 payment_pattern_, course_view_type_, transaction_teacher_id_,homework_push_flag_,member_course_show_flag_,tenant_id_,is_give_accessories_,extracurricular_teacher_,first_course_start_time_)
+                 payment_pattern_, course_view_type_, transaction_teacher_id_,homework_push_flag_,member_course_show_flag_,tenant_id_,is_give_accessories_,extracurricular_teacher_,first_course_start_time_,
+                 music_group_plan_making_id_,first_recruit_grade_,default_charge_standard_,single_train_minutes_,course_plan_,sale_activity_desc_,graduate_grade_)
         VALUES (#{id}, #{name}, #{organId}, #{schoolId}, #{applyExpireDate}, #{preApplyExpireDate}, #{teamTeacherId},
                 #{educationalTeacherId},
                 #{chargeTypeId}, #{courseForm}, now(), now(),
@@ -122,7 +130,8 @@
                 #{ownershipType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{repairUserId},
                 #{delFlag}, #{paymentValidStartDate}, #{paymentValidEndDate}, #{paymentPattern},
                 #{courseViewType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{transactionTeacherId},#{homeworkPushFlag},#{memberCourseShowFlag},#{tenantId},#{isGiveAccessories},
-                #{extracurricularTeacher,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{firstCourseStartTime})
+                #{extracurricularTeacher,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{firstCourseStartTime},
+                #{musicGroupPlanMakingId},#{firstRecruitGrade},#{defaultChargeStandard},#{singleTrainMinutes},#{coursePlan},#{saleActivityDesc},#{graduateGrade})
     </insert>
 
     <!-- 根据主键查询一条记录 -->
@@ -246,6 +255,27 @@
             <if test="firstCourseStartTime != null">
                 first_course_start_time_ = #{firstCourseStartTime},
             </if>
+            <if test="musicGroupPlanMakingId != null">
+                music_group_plan_making_id_ = #{musicGroupPlanMakingId},
+            </if>
+            <if test="firstRecruitGrade != null">
+                first_recruit_grade_ = #{firstRecruitGrade},
+            </if>
+            <if test="defaultChargeStandard != null">
+                default_charge_standard_ = #{defaultChargeStandard},
+            </if>
+            <if test="singleTrainMinutes != null">
+                single_train_minutes_ = #{singleTrainMinutes},
+            </if>
+            <if test="coursePlan != null">
+                course_plan_ = #{coursePlan},
+            </if>
+            <if test="saleActivityDesc != null">
+                sale_activity_desc_ = #{saleActivityDesc},
+            </if>
+            <if test="graduateGrade != null">
+                graduate_grade_ = #{graduateGrade},
+            </if>
         </set>
         WHERE id_ = #{id}
     </update>

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

@@ -71,6 +71,12 @@
     </update>
 
     <!-- 分页查询 -->
+    <select id="findAll" resultMap="MusicGroupOrganizationCourseSettings" parameterType="map">
+        SELECT mgocs.* FROM music_group_organization_course_settings mgocs
+        <include refid="queryCondition"/>
+    </select>
+
+    <!-- 分页查询 -->
     <select id="queryPage" resultMap="MusicGroupOrganizationCourseSettings" parameterType="map">
         SELECT mgocs.* FROM music_group_organization_course_settings mgocs
         <include refid="queryCondition"/>

+ 25 - 5
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml

@@ -11,6 +11,7 @@
         <result column="music_group_id_" property="musicGroupId"/>
         <result column="tenant_id_" property="tenantId"/>
         <result column="organ_id_" property="organId"/>
+        <result column="name_" property="name"/>
         <result column="music_group_organization_course_settings_id_" property="musicGroupOrganizationCourseSettingId"/>
         <result column="pay_user_type_" property="payUserType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="start_payment_date_" property="startPaymentDate"/>
@@ -40,6 +41,10 @@
         <result column="current_total_amount_" property="currentTotalAmount"/>
         <result column="original_total_amount_" property="originalTotalAmount"/>
         <result column="payment_item_show_state_" property="paymentItemShowState"/>
+        <result column="is_show_sale_price_" property="isShowSalePrice"/>
+        <result column="calender_fee_type_" property="calenderFeeType"/>
+        <result column="calender_fee_json_" property="calenderFeeJson"/>
+        <result column="contract_url_" property="contractUrl"/>
     </resultMap>
 
     <!-- 根据主键查询一条记录 -->
@@ -56,18 +61,20 @@
     <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender" useGeneratedKeys="true"
             keyColumn="id_" keyProperty="id">
         INSERT INTO music_group_payment_calender
-        (music_group_id_,music_group_organization_course_settings_id_,pay_user_type_,reject_reason_,start_payment_date_,deadline_payment_date_,status_,expect_num_,
+        (name_,music_group_id_,music_group_organization_course_settings_id_,pay_user_type_,reject_reason_,start_payment_date_,deadline_payment_date_,status_,expect_num_,
         actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,
         payment_pattern_,payment_type_,payment_amount_,batch_no_,audit_memo_,operator_,attribute1_,
          attribute2_,student_ids_,member_payment_amount_,member_rank_setting_id_,member_valid_date_
-         ,original_member_payment_amount_,current_total_amount_,original_total_amount_,tenant_id_,organ_id_,cloud_teacher_payment_flag_,payment_item_show_state_)
-        VALUES(#{musicGroupId},#{musicGroupOrganizationCourseSettingId},#{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+         ,original_member_payment_amount_,current_total_amount_,original_total_amount_,tenant_id_,organ_id_,
+         cloud_teacher_payment_flag_,payment_item_show_state_,is_show_sale_price_,calender_fee_type_,calender_fee_json_,contract_url_)
+        VALUES(#{name},#{musicGroupId},#{musicGroupOrganizationCourseSettingId},#{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{rejectReason},#{startPaymentDate},#{deadlinePaymentDate},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{expectNum},#{actualNum},#{memo},#{isGiveMusicNetwork},now(),now(),
         #{paymentValidStartDate},#{paymentValidEndDate},#{paymentPattern},#{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{paymentAmount},#{batchNo},#{auditMemo},#{operator},#{attribute1},#{attribute2},#{studentIds},
                #{memberPaymentAmount},#{memberRankSettingId},#{memberValidDate},#{originalMemberPaymentAmount},
-               #{currentTotalAmount},#{originalTotalAmount},#{tenantId},#{organId},#{cloudTeacherPaymentFlag},#{paymentItemShowState})
+               #{currentTotalAmount},#{originalTotalAmount},#{tenantId},#{organId},#{cloudTeacherPaymentFlag},
+               #{paymentItemShowState},#{isShowSalePrice},#{calenderFeeType},#{calenderFeeJson},#{contractUrl})
     </insert>
 
 
@@ -75,6 +82,9 @@
     <update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender">
         UPDATE music_group_payment_calender
         <set>
+            <if test="name != null and name != ''">
+                name_ = #{name},
+            </if>
             <if test="currentTotalAmount != null">
                 current_total_amount_ = #{currentTotalAmount},
             </if>
@@ -160,6 +170,9 @@
             <if test="paymentItemShowState != null">
                 payment_item_show_state_ = #{paymentItemShowState},
             </if>
+            <if test="isShowSalePrice != null">
+                is_show_sale_price_ = #{isShowSalePrice},
+            </if>
         </set>
         WHERE id_ = #{id} and tenant_id_ = #{tenantId}
     </update>
@@ -168,6 +181,9 @@
 	    <foreach collection="list" item="item" index="index" open="" close="" separator=";">
 	        UPDATE music_group_payment_calender
 	        <set>
+                <if test="item.name != null">
+                    name_ = #{item.name},
+                </if>
                 <if test="item.currentTotalAmount != null">
                     current_total_amount_ = #{item.currentTotalAmount},
                 </if>
@@ -246,6 +262,9 @@
 	            <if test="item.paymentItemShowState != null">
 	                payment_item_show_state_ = #{item.paymentItemShowState},
 	            </if>
+	            <if test="item.isShowSalePrice != null">
+	                is_show_sale_price_ = #{item.isShowSalePrice},
+	            </if>
 	        </set>
 	        WHERE id_ = #{item.id} and tenant_id_ = #{item.tenantId}
 		</foreach>
@@ -461,7 +480,7 @@
     </resultMap>
     <sql id="MusicGroupPaymentCalenderAuditDtoSql">
         <where>
-                mgpc.batch_no_ IS NOT NULL and mgpc.tenant_id_ = #{tenantId}
+                mgpc.batch_no_ IS NOT NULL and mgpc.tenant_id_ = #{tenantId} AND mg.del_flag_ = 0
             <if test="paymentType != null">
                 AND mgpc.payment_type_ = #{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
             </if>
@@ -628,6 +647,7 @@
     </select>
     <sql id="queryCalenderPageSql">
         <where>
+                mg.del_flag_ = 0
             <if test="search != null and search != ''">
                 AND (mgpc.music_group_id_ = #{search} OR mg.name_ LIKE CONCAT('%',#{search},'%'))
             </if>

+ 64 - 49
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentStudentCourseDetailMapper.xml

@@ -7,6 +7,7 @@
             type="com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail"
             id="MusicGroupPaymentStudentCourseDetail">
         <result column="id_" property="id"/>
+        <result column="music_group_id_" property="musicGroupId"/>
         <result column="music_group_payment_calender_id_" property="musicGroupPaymentCalenderId"/>
         <result column="music_group_payment_calender_detail_id_"
                 property="musicGroupPaymentCalenderDetailId"/>
@@ -14,8 +15,11 @@
         <result column="course_type_" property="courseType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="course_original_price_" property="courseOriginalPrice"/>
         <result column="course_current_price_" property="courseCurrentPrice"/>
+        <result column="sub_course_original_price_" property="subCourseOriginalPrice"/>
+        <result column="sub_course_current_price_" property="subCourseCurrentPrice"/>
         <result column="total_course_minutes_" property="totalCourseMinutes"/>
         <result column="used_course_minutes_" property="usedCourseMinutes"/>
+        <result column="sub_course_minutes_" property="subCourseMinutes"/>
         <result column="cloud_teacher_payment_flag_" property="cloudTeacherPaymentFlag"/>
         <result column="create_time_" property="createTime"/>
         <result column="update_time_" property="updateTime"/>
@@ -42,27 +46,27 @@
             parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail"
             useGeneratedKeys="true" keyColumn="id" keyProperty="id">
         INSERT INTO music_group_payment_student_course_detail
-        (music_group_payment_calender_id_, music_group_payment_calender_detail_id_, user_id_, course_type_,
-         total_course_minutes_, used_course_minutes_, create_time_, update_time_, course_original_price_,
-         course_current_price_, tenant_id_,cloud_teacher_payment_flag_)
-        VALUES (#{musicGroupPaymentCalenderId}, #{musicGroupPaymentCalenderDetailId}, #{userId},
+        (music_group_id_,music_group_payment_calender_id_, music_group_payment_calender_detail_id_, user_id_, course_type_,
+         total_course_minutes_, used_course_minutes_,sub_course_minutes_, create_time_, update_time_, course_original_price_,
+         course_current_price_, sub_course_original_price_,sub_course_current_price_, tenant_id_,cloud_teacher_payment_flag_)
+        VALUES (#{musicGroupId}, #{musicGroupPaymentCalenderId}, #{musicGroupPaymentCalenderDetailId}, #{userId},
                 #{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{totalCourseMinutes},
-                #{usedCourseMinutes},
-                NOW(), NOW(), #{courseOriginalPrice}, #{courseCurrentPrice}, #{tenantId},#{cloudTeacherPaymentFlag})
+                #{usedCourseMinutes},#{subCourseMinutes},
+                NOW(), NOW(), #{courseOriginalPrice}, #{courseCurrentPrice}, #{subCourseOriginalPrice}, #{subCourseCurrentPrice}, #{tenantId},#{cloudTeacherPaymentFlag})
     </insert>
 
     <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id"
             keyProperty="id">
         INSERT INTO music_group_payment_student_course_detail
-        (music_group_payment_calender_id_,music_group_payment_calender_detail_id_,user_id_,
-        course_type_,total_course_minutes_,used_course_minutes_,create_time_,update_time_,course_original_price_,
-         course_current_price_,tenant_id_,cloud_teacher_payment_flag_)
+        (music_group_id_,music_group_payment_calender_id_,music_group_payment_calender_detail_id_,user_id_,
+        course_type_,total_course_minutes_,used_course_minutes_,sub_course_minutes_,create_time_,update_time_,course_original_price_,
+         course_current_price_,sub_course_original_price_,sub_course_current_price_,tenant_id_,cloud_teacher_payment_flag_)
         VALUES
         <foreach collection="list" item="item" separator=",">
-            (#{item.musicGroupPaymentCalenderId},#{item.musicGroupPaymentCalenderDetailId},
+            (#{item.musicGroupId},#{item.musicGroupPaymentCalenderId},#{item.musicGroupPaymentCalenderDetailId},
             #{item.userId},#{item.courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-            #{item.totalCourseMinutes},#{item.usedCourseMinutes},NOW(),NOW(),#{item.courseOriginalPrice},
-             #{item.courseCurrentPrice},#{item.tenantId},#{item.cloudTeacherPaymentFlag})
+            #{item.totalCourseMinutes},#{item.usedCourseMinutes},#{item.subCourseMinutes},NOW(),NOW(),#{item.courseOriginalPrice},
+             #{item.courseCurrentPrice}, #{item.subCourseOriginalPrice}, #{item.subCourseCurrentPrice},#{item.tenantId},#{item.cloudTeacherPaymentFlag})
         </foreach>
     </insert>
 
@@ -77,6 +81,15 @@
             <if test="courseCurrentPrice != null">
                 course_current_price_ = #{courseCurrentPrice},
             </if>
+            <if test="subCourseOriginalPrice != null">
+                sub_course_original_price_ = #{subCourseOriginalPrice},
+            </if>
+            <if test="subCourseCurrentPrice != null">
+                sub_course_current_price_ = #{subCourseCurrentPrice},
+            </if>
+            <if test="subCourseMinutes != null">
+                sub_course_minutes_ = #{subCourseMinutes},
+            </if>
             <if test="usedCourseMinutes != null">
                 used_course_minutes_ = #{usedCourseMinutes},
             </if>
@@ -111,6 +124,18 @@
                 <if test="paymentCourseDetail.courseCurrentPrice != null">
                     course_current_price_ = #{paymentCourseDetail.courseCurrentPrice},
                 </if>
+                <if test="paymentCourseDetail.subCourseOriginalPrice != null">
+                    sub_course_original_price_ = #{paymentCourseDetail.subCourseOriginalPrice},
+                </if>
+                <if test="paymentCourseDetail.subCourseCurrentPrice != null">
+                    sub_course_current_price_ = #{paymentCourseDetail.subCourseCurrentPrice},
+                </if>
+                <if test="paymentCourseDetail.subCourseMinutes != null">
+                    used_course_minutes_ = #{paymentCourseDetail.subCourseMinutes},
+                </if>
+                <if test="paymentCourseDetail.subCourseMinutes != null">
+                    sub_course_minutes_ = #{paymentCourseDetail.subCourseMinutes},
+                </if>
                 <if test="paymentCourseDetail.usedCourseMinutes != null">
                     used_course_minutes_ = #{paymentCourseDetail.usedCourseMinutes},
                 </if>
@@ -193,24 +218,12 @@
         where tenant_id_ = #{tenantId}
     </select>
 
-    <select id="getUnUseWithStudentAndCourseTypeAndCourseMinutes" resultMap="MusicGroupPaymentStudentCourseDetail">
-        SELECT mgpscd.*
-        FROM music_group_payment_student_course_detail mgpscd
-                 LEFT JOIN music_group_payment_calender mgpc ON mgpscd.music_group_payment_calender_id_ = mgpc.id_
-        WHERE FIND_IN_SET(mgpc.batch_no_, #{batchNo})
-          AND mgpscd.user_id_ = #{studentId}
-          AND mgpscd.course_type_ = #{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
-          AND mgpscd.used_course_minutes_ &lt;= 0
-        ORDER BY mgpscd.id_;
-    </select>
-
     <select id="getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes" resultType="string">
         SELECT
         mgpc.batch_no_
         FROM music_group_payment_calender mgpc
         LEFT JOIN music_group_payment_student_course_detail mgpscd ON mgpscd.music_group_payment_calender_id_ = mgpc.id_
-        WHERE
-        mgpc.music_group_id_ = #{musicGroupId}
+        WHERE mgpc.music_group_id_ = #{musicGroupId} AND mgpscd.sub_course_minutes_ > 0
         <if test="studentId != null">
             AND mgpscd.user_id_ = #{studentId}
         </if>
@@ -223,7 +236,16 @@
         <if test="courseType != null">
             AND mgpscd.course_type_ = #{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
         </if>
-        GROUP BY mgpc.batch_no_ HAVING min(mgpscd.used_course_minutes_) &lt;=0 ORDER BY MIN(mgpc.id_) LIMIT 1;
+        GROUP BY mgpc.batch_no_ ORDER BY MIN(mgpc.id_) LIMIT 1;
+    </select>
+
+    <select id="getUnUseWithStudentAndCourseTypeAndCourseMinutes" resultMap="MusicGroupPaymentStudentCourseDetail">
+        SELECT mgpscd.*
+        FROM music_group_payment_student_course_detail mgpscd
+        WHERE mgpscd.user_id_ = #{studentId}
+        AND mgpscd.course_type_ = #{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        AND mgpscd.sub_course_minutes_ > 0 AND mgpscd.music_group_id_ = #{musicGroupId}
+        ORDER BY mgpscd.id_
     </select>
 
     <select id="getUnUseWithStudents" resultMap="MusicGroupPaymentStudentCourseDetail">
@@ -233,16 +255,16 @@
         mgpscd.user_id_,
         mgpscd.course_type_,
         SUM(mgpscd.total_course_minutes_) total_course_minutes_,
-        SUM(mgpscd.used_course_minutes_) used_course_minutes_
+        SUM(mgpscd.used_course_minutes_) used_course_minutes_,
+        SUM(mgpscd.sub_course_minutes_) sub_course_minutes_
         FROM music_group_payment_student_course_detail mgpscd
-        LEFT JOIN music_group_payment_calender mgpc ON mgpscd.music_group_payment_calender_id_ = mgpc.id_
-        WHERE mgpc.music_group_id_ = #{musicGroupId}
-        AND user_id_ IN
+        WHERE mgpscd.music_group_id_ = #{musicGroupId}
+        AND mgpscd.user_id_ IN
         <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
             #{studentId}
         </foreach>
-        GROUP BY mgpscd.user_id_,mgpscd.course_type_,mgpc.batch_no_
-        HAVING used_course_minutes_ &lt;= 0
+        GROUP BY mgpscd.user_id_,mgpscd.course_type_
+        HAVING SUM(mgpscd.sub_course_minutes_) > 0
     </select>
 
     <delete id="deleteByUserIdAndMusicGroupId">
@@ -272,18 +294,15 @@
         SELECT mgpscd.user_id_,
                su.username_,
                su.phone_,
-               mgpscd.course_type_ 'key', SUM(CASE
-                                                  WHEN mgpscd.used_course_minutes_ = 0 THEN mgpscd.total_course_minutes_
-                                                  ELSE 0 END) 'value'
+               mgpscd.course_type_ 'key', SUM(mgpscd.sub_course_minutes_) 'value'
         FROM music_group_payment_student_course_detail mgpscd
-                 LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpscd.music_group_payment_calender_id_
                  LEFT JOIN sys_user su ON su.id_ = mgpscd.user_id_
-        WHERE mgpc.music_group_id_ = #{musicGroupId}
+        WHERE mgpscd.music_group_id_ = #{musicGroupId}
         GROUP BY mgpscd.user_id_, mgpscd.course_type_
     </select>
 
     <sql id="sqlStudentSubTotalCourseTimes">
-        WHERE mgpc.music_group_id_ = #{musicGroupId}
+        WHERE mgpscd.music_group_id_ = #{musicGroupId}
         <if test="search != null and search != ''">
             and (
             mgpscd.user_id_ like CONCAT('%',#{search},'%')
@@ -292,10 +311,10 @@
             )
         </if>
         <if test="hastimer != null and hastimer == true">
-            and (mgpscd.used_course_minutes_ is null or mgpscd.used_course_minutes_ = 0)
+            and mgpscd.sub_course_minutes_ > 0
         </if>
         <if test="hastimer != null and hastimer == false">
-            and mgpscd.used_course_minutes_ &gt; 0
+            and mgpscd.used_course_minutes_ = 0
         </if>
         <if test="courseType != null and courseType != ''">
             and mgpscd.course_type_ = #{courseType}
@@ -310,7 +329,6 @@
     select count(*) from (
         SELECT mgpscd.user_id_ FROM music_group_payment_student_course_detail mgpscd
         LEFT JOIN sys_user su ON su.id_ = mgpscd.user_id_
-        LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpscd.music_group_payment_calender_id_
         left join (
             SELECT
                 user_id_ ,GROUP_CONCAT(class_group_id_) as class_group_id_
@@ -328,10 +346,9 @@
             SELECT
                 mgpscd.user_id_,su.username_,su.phone_,
                 mgpscd.course_type_ 'key',
-                SUM(CASE WHEN mgpscd.used_course_minutes_ = 0 THEN mgpscd.total_course_minutes_ ELSE 0 END) 'value'
+                SUM(mgpscd.sub_course_minutes_) 'value'
             FROM music_group_payment_student_course_detail mgpscd
             LEFT JOIN sys_user su ON su.id_ = mgpscd.user_id_
-            LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpscd.music_group_payment_calender_id_
             left join (
                 SELECT
                     user_id_ ,GROUP_CONCAT(class_group_id_) as class_group_id_
@@ -353,8 +370,7 @@
         SELECT SUM(c.a) >= SUM(c.b) FROM (
         SELECT COUNT(DISTINCT mgpscd.course_type_) a,COUNT(DISTINCT mgpscd.total_course_minutes_) b FROM
         music_group_payment_student_course_detail mgpscd
-        LEFT JOIN music_group_payment_calender mgpc ON mgpscd.music_group_payment_calender_id_ = mgpc.id_
-        WHERE mgpc.music_group_id_ = #{musicGroupId} AND mgpscd.used_course_minutes_ = 0
+        WHERE mgpscd.music_group_id_ = #{musicGroupId} AND mgpscd.sub_course_minutes_ > 0
         AND mgpscd.course_type_ IN
         <foreach collection="courseTypes" item="courseType" open="(" close=")" separator=",">
             #{courseType}
@@ -364,10 +380,9 @@
             #{studentId}
         </foreach>)c
     </select>
-    
+
     <update id="clearRemainCourseMinutesByMusicGroupId">
-    	update `music_group_payment_student_course_detail` cd LEFT JOIN `music_group_payment_calender` pc on cd.`music_group_payment_calender_id_` = pc.`id_` 
-		set cd.`used_course_minutes_` = 1
-		WHERE cd.`used_course_minutes_` = 0 and pc.`music_group_id_` = #{musicGroupId}  
+    	update music_group_payment_student_course_detail
+		set sub_course_minutes_ = 0 WHERE sub_course_minutes_ > 0 and music_group_id_ = #{musicGroupId}
     </update>
 </mapper>

+ 74 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupPlanMakingMapper.xml

@@ -0,0 +1,74 @@
+<?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.MusicGroupPlanMakingDao">
+
+	<resultMap type="com.ym.mec.biz.dal.entity.MusicGroupPlanMaking"
+		id="MusicGroupPlanMaking">
+		<result column="id_" property="id" />
+		<result column="name_" property="name" />
+		<result column="subject_id_list_" property="subjectIdList" />
+		<result column="create_time_" property="createTime" />
+		<result column="update_time_" property="updateTime" />
+	</resultMap>
+
+	<!-- 根据主键查询一条记录 -->
+	<select id="get" resultMap="MusicGroupPlanMaking">
+		SELECT * FROM music_group_plan_making WHERE id_ = #{id}
+	</select>
+
+	<!-- 全查询 -->
+	<select id="findAll" resultMap="MusicGroupPlanMaking">
+		SELECT * FROM music_group_plan_making ORDER BY id_
+	</select>
+
+	<!-- 向数据库增加一条记录 -->
+	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPlanMaking"
+		useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+		<!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval 
+			AS ID FROM DUAL </selectKey> -->
+		INSERT INTO music_group_plan_making
+		(id_,name_,subject_id_list_,create_time_,update_time_)
+		VALUES(#{id},#{name},#{subjectIdList},#{createTime},#{updateTime})
+	</insert>
+
+	<!-- 根据主键查询一条记录 -->
+	<update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPlanMaking">
+		UPDATE music_group_plan_making
+		<set>
+			<if test="subjectIdList != null">
+				subject_id_list_ = #{subjectIdList},
+			</if>
+			<if test="id != null">
+				id_ = #{id},
+			</if>
+			<if test="updateTime != null">
+				update_time_ = #{updateTime},
+			</if>
+			<if test="name != null">
+				name_ = #{name},
+			</if>
+			<if test="createTime != null">
+				create_time_ = #{createTime},
+			</if>
+		</set>
+		WHERE id_ = #{id}
+	</update>
+
+	<!-- 根据主键删除一条记录 -->
+	<delete id="delete">
+		DELETE FROM music_group_plan_making WHERE
+		id_ = #{id}
+	</delete>
+
+	<!-- 分页查询 -->
+	<select id="queryPage" resultMap="MusicGroupPlanMaking" parameterType="map">
+		SELECT * FROM music_group_plan_making ORDER BY id_
+		<include refid="global.limit" />
+	</select>
+
+	<!-- 查询当前表的总记录数 -->
+	<select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM music_group_plan_making
+	</select>
+</mapper>

+ 8 - 4
mec-biz/src/main/resources/config/mybatis/MusicGroupSubjectGoodsGroupMapper.xml

@@ -20,6 +20,7 @@
         <result column="group_remission_course_fee_" property="groupRemissionCourseFee"/>
         <result column="kit_group_purchase_type_json_" property="kitGroupPurchaseTypeJson"/>
         <result column="course_purchase_type_json_" property="coursePurchaseTypeJson"/>
+        <result column="organ_share_profit_" property="organShareProfit"/>
         <result column="tenant_id_" property="tenantId"/>
     </resultMap>
 
@@ -41,16 +42,16 @@
             parameterType="com.ym.mec.biz.dal.entity.MusicGroupSubjectGoodsGroup"
             useGeneratedKeys="true" keyColumn="id" keyProperty="id">
         INSERT INTO music_group_subject_goods_group
-        (id_,name_,type_,music_group_id_,subject_id_,goods_id_list_,create_time_,update_time_,price_,deposit_fee_,remission_course_fee_,kit_group_purchase_type_json_,course_purchase_type_json_,tenant_id_)
-        VALUES(#{id},#{name},#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{musicGroupId},#{subjectId},#{goodsIdList},NOW(),NOW(),#{price},#{depositFee},#{remissionCourseFee},#{kitGroupPurchaseTypeJson},#{coursePurchaseTypeJson},#{tenantId})
+        (id_,name_,type_,music_group_id_,subject_id_,goods_id_list_,create_time_,update_time_,price_,deposit_fee_,remission_course_fee_,kit_group_purchase_type_json_,course_purchase_type_json_,organ_share_profit_,tenant_id_)
+        VALUES(#{id},#{name},#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{musicGroupId},#{subjectId},#{goodsIdList},NOW(),NOW(),#{price},#{depositFee},#{remissionCourseFee},#{kitGroupPurchaseTypeJson},#{coursePurchaseTypeJson},#{organShareProfit},#{tenantId})
     </insert>
 
     <insert id="batchInsert" parameterType="java.util.List">
         INSERT INTO music_group_subject_goods_group
-        (name_,type_,music_group_id_,subject_id_,goods_id_list_,create_time_,update_time_,price_,deposit_fee_,remission_course_fee_,group_remission_course_fee_,kit_group_purchase_type_json_,course_purchase_type_json_,tenant_id_) VALUES
+        (name_,type_,music_group_id_,subject_id_,goods_id_list_,create_time_,update_time_,price_,deposit_fee_,remission_course_fee_,group_remission_course_fee_,kit_group_purchase_type_json_,course_purchase_type_json_,organ_share_profit_,tenant_id_) VALUES
         <foreach collection="lists" item="item" index="index" separator=",">
             (#{item.name},#{item.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-            #{musicGroupId},#{item.subjectId},#{item.goodsIdList},now(),now(),#{item.price},#{item.depositFee},#{item.remissionCourseFee},#{item.groupRemissionCourseFee},#{item.kitGroupPurchaseTypeJson},#{item.coursePurchaseTypeJson},#{item.tenantId})
+            #{musicGroupId},#{item.subjectId},#{item.goodsIdList},now(),now(),#{item.price},#{item.depositFee},#{item.remissionCourseFee},#{item.groupRemissionCourseFee},#{item.kitGroupPurchaseTypeJson},#{item.coursePurchaseTypeJson},#{item.organShareProfit},#{item.tenantId})
         </foreach>
     </insert>
 
@@ -89,6 +90,9 @@
             <if test="name != null">
                 name_ = #{name},
             </if>
+            <if test="organShareProfit != null">
+                organ_share_profit_ = #{organShareProfit},
+            </if>
         </set>
         WHERE id_ = #{id} and tenant_id_ = #{tenantId}
     </update>

+ 5 - 0
mec-biz/src/main/resources/config/mybatis/OrganizationCourseUnitPriceSettingsMapper.xml

@@ -129,4 +129,9 @@
 			and tenant_id_ = #{tenantId}
 		</if>
 	</select>
+    <select id="queryByMusicGroupId" resultMap="OrganizationCourseUnitPriceSettings">
+		select ocups.* from organization_course_unit_price_settings ocups
+		LEFT JOIN music_group mg ON mg.organ_id_ = ocups.organ_id_ AND mg.charge_type_id_ = ocups.charge_type_id_
+		where mg.id_ = #{musicGroupId}
+	</select>
 </mapper>

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

@@ -22,6 +22,7 @@
         <result column="corporate_code_" property="corporateCode"/>
         <result column="corporate_seal_" property="corporateSeal"/>
         <result column="corporate_financial_seal_" property="corporateFinancialSeal"/>
+        <result column="max_musical_instruments_profits_" property="maxMusicalInstrumentsProfits"/>
         <result column="tenant_id_" property="tenantId"/>
         <result column="grade_type_" property="gradeType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
     </resultMap>
@@ -40,9 +41,9 @@
     <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.Organization" useGeneratedKeys="true" keyColumn="id"
             keyProperty="id">
         INSERT INTO organization (id_,name_,area_id_,create_time_,update_time_,
-                                  register_date_,linkman_,mobile_,address_,grade_type_,tenant_id_,corporate_name_,corporate_code_,corporate_seal_,corporate_financial_seal_)
+                                  register_date_,linkman_,mobile_,address_,grade_type_,tenant_id_,corporate_name_,corporate_code_,corporate_seal_,corporate_financial_seal_,max_musical_instruments_profits_)
         VALUES(#{id},#{name},#{areaId},now(),now(),#{registerDate},#{linkman},#{mobile},#{address},
-               #{gradeType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{tenantId},#{corporateName},#{corporateCode},#{corporateSeal},#{corporateFinancialSeal})
+               #{gradeType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{tenantId},#{corporateName},#{corporateCode},#{corporateSeal},#{corporateFinancialSeal},#{maxMusicalInstrumentsProfits})
     </insert>
 
     <!-- 根据主键查询一条记录 -->
@@ -85,6 +86,9 @@
             <if test="corporateFinancialSeal != null">
                 corporate_financial_seal_ = #{corporateFinancialSeal},
             </if>
+            <if test="maxMusicalInstrumentsProfits != null">
+                max_musical_instruments_profits_ = #{maxMusicalInstrumentsProfits},
+            </if>
             <if test="gradeType != null">
                 grade_type_ = #{gradeType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             </if>

+ 2 - 2
mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupRegisterController.java

@@ -50,12 +50,12 @@ public class MusicGroupRegisterController extends BaseController {
         if (musicGroup == null) {
             return failed("乐团信息不存在");
         }
-        if(musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE){
+        /*if(musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE){
             boolean hasMemberGroup = studentRegistrationDao.checkHasMemberGroup(musicGroup.getId(), userId);
             if(hasMemberGroup){
                 throw new BizException("您已在其他会员团中,不可报名该乐团,请联系乐团主管");
             }
-        }
+        }*/
 
         if (date.compareTo(DateUtil.getLastTimeWithDay(musicGroup.getApplyExpireDate())) > 0 && studentRegistration.getId() == null) {
             return failed("乐团已截止报名");

+ 41 - 0
mec-web/src/main/java/com/ym/mec/web/controller/CooperationShareProfitController.java

@@ -0,0 +1,41 @@
+package com.ym.mec.web.controller;
+
+import com.ym.mec.biz.dal.entity.CooperationShareProfit;
+import com.ym.mec.biz.dal.entity.CooperationShareProfitDto;
+import com.ym.mec.biz.dal.page.CooperationShareProfitQueryInfo;
+import com.ym.mec.biz.service.CooperationShareProfitService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.page.PageInfo;
+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;
+
+@RequestMapping("cooperationShareProfit")
+@Api(tags = "合作单位分润")
+@RestController
+public class CooperationShareProfitController extends BaseController {
+
+    @Autowired
+    private CooperationShareProfitService cooperationShareProfitService;
+
+    @ApiOperation(value = "获取合作单位分润列表")
+    @PostMapping("/queryPage")
+    @PreAuthorize("@pcs.hasPermissions('cooperationShareProfit/queryPage')")
+    public HttpResponseResult<PageInfo<CooperationShareProfitDto>> queryPage(@RequestBody CooperationShareProfitQueryInfo queryInfo) throws Exception {
+        return succeed(cooperationShareProfitService.queryDtoPage(queryInfo));
+    }
+
+    @ApiOperation(value = "添加付款凭证")
+    @PostMapping("/addCredentials")
+    @PreAuthorize("@pcs.hasPermissions('cooperationShareProfit/addCredentials')")
+    public HttpResponseResult addCredentials(@RequestBody CooperationShareProfit profit) throws Exception {
+        cooperationShareProfitService.addCredentials(profit);
+        return succeed();
+    }
+}

+ 52 - 0
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupCalenderRefundPeriodController.java

@@ -0,0 +1,52 @@
+package com.ym.mec.web.controller;
+
+import com.ym.mec.biz.dal.dto.CooperationCalenderRefundDto;
+import com.ym.mec.biz.dal.page.CooperationRefundQueryInfo;
+import com.ym.mec.biz.service.MusicGroupCalenderRefundPeriodService;
+import com.ym.mec.biz.service.OrganizationService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.page.PageInfo;
+import com.yonge.log.model.AuditLogAnnotation;
+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.HashMap;
+
+@RequestMapping("musicGroupCalenderRefundPeriod")
+@Api(tags = "学校缴费项目缴费周期")
+@RestController
+public class MusicGroupCalenderRefundPeriodController extends BaseController {
+
+    @Autowired
+    private MusicGroupCalenderRefundPeriodService musicGroupCalenderRefundPeriodService;
+    @Autowired
+    private OrganizationService organizationService;
+
+    @ApiOperation(value = "获取合作单位费用汇总列表")
+    @PostMapping("/queryCoopRefund")
+    @PreAuthorize("@pcs.hasPermissions('musicGroupCalenderRefundPeriod/queryCoopRefund')")
+    @AuditLogAnnotation(operateName = "获取合作单位费用汇总列表")
+    public HttpResponseResult<HashMap<String, Object>> queryCoopRefund(@RequestBody CooperationRefundQueryInfo queryInfo) {
+        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
+        HashMap<String, Object> resultMap = new HashMap<>(2);
+        resultMap.put("pageInfo",musicGroupCalenderRefundPeriodService.queryCoopRefund(queryInfo));
+        resultMap.put("amount",musicGroupCalenderRefundPeriodService.sumCoopRefund(queryInfo));
+        return succeed(resultMap);
+    }
+
+    @ApiOperation(value = "获取合作单位学校缴费列表")
+    @PostMapping("/queryCoopCalender")
+    @PreAuthorize("@pcs.hasPermissions('musicGroupCalenderRefundPeriod/queryCoopCalender')")
+    @AuditLogAnnotation(operateName = "获取合作单位学校缴费列表")
+    public HttpResponseResult<PageInfo<CooperationCalenderRefundDto>> queryCoopCalender(@RequestBody CooperationRefundQueryInfo queryInfo) {
+        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
+        return succeed(musicGroupCalenderRefundPeriodService.queryCoopCalender(queryInfo));
+    }
+}

+ 21 - 14
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupController.java

@@ -1,5 +1,24 @@
 package com.ym.mec.web.controller;
 
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
 import com.ym.mec.biz.dal.dto.CloseMusicGroupDto;
 import com.ym.mec.biz.dal.dto.MusicGroupRegsDto;
 import com.ym.mec.biz.dal.dto.SubFeeSettingDto;
@@ -11,25 +30,13 @@ import com.ym.mec.biz.dal.page.MusicGroupQueryInfo;
 import com.ym.mec.biz.dal.page.MusicMemberQueryInfo;
 import com.ym.mec.biz.service.MusicGroupService;
 import com.ym.mec.biz.service.OrganizationService;
+import com.ym.mec.biz.service.SysEmployeePositionService;
 import com.ym.mec.biz.service.SysUserService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.yonge.log.model.AuditLogAnnotation;
-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;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
 @RequestMapping("musicGroup")
 @Api(tags = "乐团服务")
@@ -42,7 +49,7 @@ public class MusicGroupController extends BaseController {
 	private SysUserService sysUserService;
 	@Autowired
 	private OrganizationService organizationService;
-
+	
 	@ApiOperation(value = "修改乐团基本信息")
 	@PostMapping("/update")
 	@AuditLogAnnotation(operateName = "乐团基本信息修改",interfaceURL = "musicGroup/update")

+ 0 - 2
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java

@@ -1,6 +1,5 @@
 package com.ym.mec.web.controller;
 
-import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
 import com.ym.mec.biz.dal.dto.HasFreeCourseTimesDto;
 import com.ym.mec.biz.dal.dto.MusicGroupPaymentBaseCalender;
@@ -16,7 +15,6 @@ import com.ym.mec.common.controller.BaseController;
 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.common.page.QueryInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;

+ 104 - 0
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPlanMakingController.java

@@ -0,0 +1,104 @@
+package com.ym.mec.web.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.ym.mec.biz.dal.dto.MusicGroupPlanMakingDto;
+import com.ym.mec.biz.dal.entity.MusicGroupPlanMaking;
+import com.ym.mec.biz.dal.entity.Subject;
+import com.ym.mec.biz.service.MusicGroupPlanMakingService;
+import com.ym.mec.biz.service.SubjectService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.yonge.log.model.AuditLogAnnotation;
+
+@RequestMapping("musicGroupPlanMaking")
+@Api(tags = "乐团编制服务")
+@RestController
+public class MusicGroupPlanMakingController extends BaseController {
+	
+	@Autowired
+	private MusicGroupPlanMakingService musicGroupPlanMakingService;
+	
+	@Autowired
+	private SubjectService subjectService;
+
+	@ApiOperation(value = "查询所有乐团编制")
+	@GetMapping(value = "/queryAll", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	@PreAuthorize("@pcs.hasPermissions('musicGroupPlanMaking/queryAll')")
+	public HttpResponseResult<List<MusicGroupPlanMakingDto>> queryAll() throws Exception {
+
+		List<MusicGroupPlanMakingDto> result = new ArrayList<MusicGroupPlanMakingDto>();
+
+		List<MusicGroupPlanMaking> list = musicGroupPlanMakingService.findAll(new HashMap<String, Object>());
+
+		for (MusicGroupPlanMaking pm : list) {
+			MusicGroupPlanMakingDto dto = new MusicGroupPlanMakingDto();
+
+			BeanUtils.copyProperties(pm, dto);
+
+			List<Subject> subjectList = subjectService.findBySubjectByIdList(pm.getSubjectIdList());
+			if (subjectList != null) {
+				dto.setSubjectMap(subjectList.stream().collect(Collectors.toMap(Subject::getId, Subject::getName)));
+			}
+
+			result.add(dto);
+		}
+		return succeed(result);
+	}
+
+	@ApiOperation(value = "查询乐团编制")
+	@GetMapping(value = "/query", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	@PreAuthorize("@pcs.hasPermissions('musicGroupPlanMaking/query')")
+	public HttpResponseResult<MusicGroupPlanMakingDto> query(Integer id) throws Exception {
+
+		MusicGroupPlanMaking pm = musicGroupPlanMakingService.get(id);
+
+		if (pm != null) {
+			MusicGroupPlanMakingDto dto = new MusicGroupPlanMakingDto();
+
+			BeanUtils.copyProperties(pm, dto);
+
+			List<Subject> subjectList = subjectService.findBySubjectByIdList(pm.getSubjectIdList());
+			if (subjectList != null) {
+				dto.setSubjectMap(subjectList.stream().collect(Collectors.toMap(Subject::getId, Subject::getName)));
+			}
+			return succeed(dto);
+		}
+		return succeed();
+	}
+
+	@ApiOperation(value = "新增乐团编制")
+	@PostMapping(value = "/add", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	@AuditLogAnnotation(operateName = "新增乐团编制",interfaceURL = "musicGroupPlanMaking/add")
+	@PreAuthorize("@pcs.hasPermissions('musicGroupPlanMaking/add')")
+	public Object add(@RequestBody MusicGroupPlanMaking musicGroupPlanMaking) throws Exception {
+		musicGroupPlanMakingService.insert(musicGroupPlanMaking);
+		return succeed();
+	}
+
+	@ApiOperation(value = "修改乐团编制")
+	@PostMapping(value = "/update", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	@AuditLogAnnotation(operateName = "修改乐团编制",interfaceURL = "musicGroupPlanMaking/update")
+	@PreAuthorize("@pcs.hasPermissions('musicGroupPlanMaking/update')")
+	public Object update(@RequestBody MusicGroupPlanMaking musicGroupPlanMaking) throws Exception {
+		musicGroupPlanMakingService.update(musicGroupPlanMaking);
+		return succeed();
+	}
+	
+}

+ 21 - 33
mec-web/src/main/java/com/ym/mec/web/controller/StudentPaymentRouteOrderController.java

@@ -1,44 +1,34 @@
 package com.ym.mec.web.controller;
 
-import com.ym.mec.biz.dal.dao.StudentPaymentRouteOrderDao;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
-import com.ym.mec.biz.service.OrganizationService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-
-import java.math.BigDecimal;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import com.ym.mec.auth.api.client.SysUserFeignService;
-import com.ym.mec.auth.api.entity.SysUser;
-import com.ym.mec.biz.dal.dao.EmployeeDao;
 import com.ym.mec.biz.dal.dao.SellOrderDao;
 import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
+import com.ym.mec.biz.dal.dao.StudentPaymentRouteOrderDao;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
 import com.ym.mec.biz.dal.dto.OutOrderInfoDto;
 import com.ym.mec.biz.dal.dto.StudentPaymentRouteOrderDto;
-import com.ym.mec.biz.dal.entity.Employee;
 import com.ym.mec.biz.dal.entity.SellOrder;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.StudentPaymentRouteOrder;
 import com.ym.mec.biz.dal.enums.AuditStatusEnum;
 import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
 import com.ym.mec.biz.dal.page.StudentPaymentRouteOrderQueryInfo;
+import com.ym.mec.biz.service.OrganizationService;
 import com.ym.mec.biz.service.StudentPaymentRouteOrderService;
+import com.ym.mec.biz.service.SysUserService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.page.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
 
 @RequestMapping("routeOrder")
 @Api(tags = "分润订单服务")
@@ -48,7 +38,7 @@ public class StudentPaymentRouteOrderController extends BaseController {
     @Autowired
     private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
     @Autowired
-    private SysUserFeignService sysUserFeignService;
+    private SysUserService sysUserService;
     @Autowired
     private OrganizationService organizationService;
     @Autowired
@@ -98,15 +88,15 @@ public class StudentPaymentRouteOrderController extends BaseController {
     @PostMapping("/add")
     @PreAuthorize("@pcs.hasPermissions('routeOrder/add')")
     public HttpResponseResult<StudentPaymentRouteOrder> add(@RequestBody StudentPaymentRouteOrder studentPaymentRouteOrder) {
-        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        Integer userId = sysUserService.getUserId();
         if (studentPaymentRouteOrder.getServiceAmount() == null) {
         	studentPaymentRouteOrder.setServiceAmount(BigDecimal.ZERO);
         }
         if (studentPaymentRouteOrder.getSaleAmount() == null) {
         	studentPaymentRouteOrder.setSaleAmount(BigDecimal.ZERO);
         }
-        studentPaymentRouteOrder.setCreateBy(sysUser.getId());
-        studentPaymentRouteOrder.setUpdateBy(sysUser.getId());
+        studentPaymentRouteOrder.setCreateBy(userId);
+        studentPaymentRouteOrder.setUpdateBy(userId);
         if(studentPaymentRouteOrder.getPayTime().after(new Date())){
             failed("交易日期不能大于当前时间");
         }
@@ -119,8 +109,7 @@ public class StudentPaymentRouteOrderController extends BaseController {
 	@PostMapping("/auditOutOrder")
 	@PreAuthorize("@pcs.hasPermissions('routeOrder/auditOutOrder')")
 	public HttpResponseResult<String> auditOutOrder(Long studentPaymentRouteOrderId, AuditStatusEnum auditStatus, String memo) {
-		SysUser sysUser = sysUserFeignService.queryUserInfo();
-		studentPaymentRouteOrderService.auditOutOrder(studentPaymentRouteOrderId, auditStatus, memo, sysUser.getId());
+		studentPaymentRouteOrderService.auditOutOrder(studentPaymentRouteOrderId, auditStatus, memo,sysUserService.getUserId());
 		return succeed();
 	}
 
@@ -136,14 +125,13 @@ public class StudentPaymentRouteOrderController extends BaseController {
     	if(originOrder.getAuditStatus() != AuditStatusEnum.REJECT ){
     		return failed("只有“拒绝”状态才能修改订单");
     	}
-        SysUser sysUser = sysUserFeignService.queryUserInfo();
         if (studentPaymentRouteOrder.getServiceAmount() == null) {
         	studentPaymentRouteOrder.setServiceAmount(BigDecimal.ZERO);
         }
         if (studentPaymentRouteOrder.getSaleAmount() == null) {
         	studentPaymentRouteOrder.setSaleAmount(BigDecimal.ZERO);
         }
-        studentPaymentRouteOrder.setUpdateBy(sysUser.getId());
+        studentPaymentRouteOrder.setUpdateBy(sysUserService.getUserId());
         if(studentPaymentRouteOrder.getSchoolId() == null){
             studentPaymentRouteOrder.setSchoolId(999999999);
         }

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

@@ -120,6 +120,8 @@ public class TaskController extends BaseController {
     private TempLittleArtistTrainingCampService tempLittleArtistTrainingCampService;
     @Autowired
     private OperatingReportNewService operatingReportNewService;
+    @Autowired
+    private CooperationShareProfitService cooperationShareProfitService;
 
 	//每月经营报表
 	@GetMapping(value = "/operatingReportMonth")
@@ -240,7 +242,10 @@ public class TaskController extends BaseController {
 	// 更新课程状态至已结束
 	public void updateCourseScheduleToOverStatus() throws Exception {
 		List<Long> courseIds = courseScheduleService.updateCourseScheduleToOverStatus();
+		//更新合作单位分润
+		cooperationShareProfitService.init(courseIds);
 		courseEventSource.courseStatusChange(courseIds);
+
 		courseIds = courseScheduleService.updateCourseScheduleToUnderway();
 		courseEventSource.courseStatusChange(courseIds);
 		//发送定时群消息
@@ -260,7 +265,6 @@ public class TaskController extends BaseController {
 	public void stopVipGroupWithNoCreate() {
 		vipGroupService.stopVipGroupWithNoCreate(null);
 	}
-
 	@GetMapping("/pushNoSignOutMessage")
 	// 推送未签退消息提醒
 	public void pushNoSignOutMessage() {

+ 2 - 5
mec-web/src/main/java/com/ym/mec/web/controller/UploadFileController.java

@@ -14,10 +14,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.Base64Utils;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
@@ -40,7 +37,7 @@ public class UploadFileController extends BaseController {
 	
 	private SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
 
-	@PostMapping(value = "uploadFile")
+	@RequestMapping(value = "uploadFile")
 	public Object uploadFile(@ApiParam(value = "上传的文件", required = true) @RequestParam("file") MultipartFile file){
 		try {
 //			BucketContextHolder.setBucket(bucket);