Browse Source

经营报表

zouxuan 2 years ago
parent
commit
8ee4d12b62
19 changed files with 378 additions and 469 deletions
  1. 5 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ChargeTypeSubjectMapperDao.java
  2. 8 44
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentStudentCourseDetailDao.java
  3. 6 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentMusicCourseFeeDao.java
  4. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ChargeTypeSubjectMapper.java
  5. 6 215
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderDetail.java
  6. 10 11
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentMusicCourseFee.java
  7. 33 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentStudentCourseDetailService.java
  8. 6 0
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentMusicCourseFeeService.java
  9. 4 11
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderCourseSettingsServiceImpl.java
  10. 12 95
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java
  11. 9 6
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  12. 173 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentStudentCourseDetailServiceImpl.java
  13. 10 45
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  14. 35 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentMusicCourseFeeServiceImpl.java
  15. 13 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderDetailServiceImpl.java
  16. 5 0
      mec-biz/src/main/resources/config/mybatis/ChargeTypeSubjectMapperMapper.xml
  17. 11 4
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml
  18. 10 37
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentStudentCourseDetailMapper.xml
  19. 21 0
      mec-biz/src/main/resources/config/mybatis/StudentMusicCourseFeeMapper.xml

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ChargeTypeSubjectMapperDao.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.dal.dao;
 import java.util.List;
 
 import com.ym.mec.biz.dal.entity.ChargeTypeSubjectMapper;
+import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 
@@ -27,4 +28,8 @@ public interface ChargeTypeSubjectMapperDao extends BaseDAO<Long, ChargeTypeSubj
     ChargeTypeSubjectMapper getSubjectDiscount(@Param("chargeTypeId") Integer chargeTypeId, @Param("subjectId") Integer subjectId);
 
     ChargeTypeSubjectMapper getSubjectsDiscount(@Param("chargeTypeId") Integer chargeTypeId, @Param("subjectIds") String subjectIds);
+
+    ChargeTypeSubjectMapper findByViewTypeANdSubject(@Param("courseViewType") CourseViewTypeEnum courseViewType,
+                                                     @Param("subjectId") Integer subjectId,
+                                                     @Param("tenantId") Integer tenantId);
 }

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

@@ -1,15 +1,13 @@
 package com.ym.mec.biz.dal.dao;
 
-import java.math.BigDecimal;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.ibatis.annotations.Param;
-
 import com.ym.mec.biz.dal.dto.StudentSubTotalCourseTimesDto;
 import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
 import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
 
 public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, MusicGroupPaymentStudentCourseDetail> {
 
@@ -60,31 +58,6 @@ public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, M
     int batchInsert(List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList);
 
     /**
-     * 删除用户购买乐团课程记录
-     *
-     * @param userId
-     * @param musicGroupId
-     * @return
-     */
-    int deleteByUserIdAndMusicGroupId(@Param("userId") Integer userId, @Param("musicGroupId") String musicGroupId);
-
-    /**
-     * 根据缴费编号删除信息
-     *
-     * @param musicGroupPaymentCalenderId
-     * @return
-     */
-    int deleteByMusicGroupPaymentCalenderId(Long musicGroupPaymentCalenderId);
-
-    /**
-     * 删除信息
-     *
-     * @param musicGroupPaymentCalenderDetailIdList
-     * @return
-     */
-    int deleteByMusicGroupPaymentCalenderDetailId(List<Long> musicGroupPaymentCalenderDetailIdList);
-
-    /**
      * 查询对象
      *
      * @param musicGroupPaymentCalenderDetailIdList
@@ -104,18 +77,7 @@ public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, M
 
     List<StudentSubTotalCourseTimesDto> pageStudentSubTotalCourseTimes(Map<String, Object> params);
 
-    List<MusicGroupPaymentStudentCourseDetail> findByCalenderAndUserId(@Param("calenderId") Long calenderId, @Param("userId") Integer userId);
-
-    /**
-     * 更新学员实际缴费金额
-     *
-     * @param courseType
-     * @param musicGroupPaymentCalenderIds
-     * @param courseCurrentPrice
-     */
-    void updateByCourseType(@Param("courseType") String courseType,
-                            @Param("musicGroupPaymentCalenderIds") String musicGroupPaymentCalenderIds,
-                            @Param("courseCurrentPrice") BigDecimal courseCurrentPrice);
+    List<MusicGroupPaymentStudentCourseDetail> findByCalenderAndUserId(@Param("calenderId") String calenderId, @Param("userId") Integer userId);
 
     /**
      * @param musicGroupId
@@ -137,5 +99,7 @@ public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, M
      */
     int clearRemainCourseMinutesByMusicGroupId(String musicGroupId);
 
-    void deleteByUserIdAndCalenderId(@Param("userId") Integer userId, @Param("calenderIds") List<Long> calenderIds);
+    void delByIds(@Param("courseDetailIds") List<Long> courseDetailIds);
+
+    List<MusicGroupPaymentStudentCourseDetail> findByUserIdAndMusicGroupId(@Param("userId") Integer userId, @Param("musicGroupId") String musicGroupId);
 }

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentMusicCourseFeeDao.java

@@ -2,7 +2,13 @@ package com.ym.mec.biz.dal.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ym.mec.biz.dal.entity.StudentMusicCourseFee;
+import org.apache.ibatis.annotations.Param;
+
+import java.math.BigDecimal;
 
 public interface StudentMusicCourseFeeDao extends BaseMapper<StudentMusicCourseFee> {
 
+    void addExpectPrice(@Param("id") Integer id, @Param("expectPrice") BigDecimal expectPrice);
+
+    void cutExpectPrice(@Param("id") Integer id, @Param("expectPrice") BigDecimal expectPrice);
 }

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

@@ -40,7 +40,7 @@ public class ChargeTypeSubjectMapper extends BaseEntity {
 	private BigDecimal depositFee;
 
 	/**  */
-	@ApiModelProperty(value = "课程费用(比例)",required = false)
+	@ApiModelProperty(value = "乐器收入",required = false)
 	private BigDecimal fee;
 	
 	@ApiModelProperty(value = "商品折扣率",required = false)

+ 6 - 215
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderDetail.java

@@ -1,21 +1,19 @@
 package com.ym.mec.biz.dal.entity;
 
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
 import com.ym.mec.biz.dal.enums.YesOrNoEnum;
-
+import com.ym.mec.common.entity.BaseEntity;
 import io.swagger.annotations.ApiModelProperty;
-
+import lombok.Data;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
-import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
-import com.ym.mec.common.entity.BaseEntity;
-
 import java.math.BigDecimal;
-import java.util.Date;
 
 /**
  * 对应数据库表(music_group_payment_calender_detail):
  */
+@Data
 public class MusicGroupPaymentCalenderDetail extends BaseEntity {
 
 	/**  */
@@ -89,215 +87,8 @@ public class MusicGroupPaymentCalenderDetail extends BaseEntity {
 	
 	private SysUser responsible = new SysUser();
 
-	public BigDecimal getExpectMemberAmount() {
-		return expectMemberAmount;
-	}
-
-	public void setExpectMemberAmount(BigDecimal expectMemberAmount) {
-		this.expectMemberAmount = expectMemberAmount;
-	}
-
-	public MusicGroupPaymentCalender.PaymentType getPaymentType() {
-		return paymentType;
-	}
-
-	public void setPaymentType(MusicGroupPaymentCalender.PaymentType paymentType) {
-		this.paymentType = paymentType;
-	}
-
-	public Date getStartPaymentDateMgpc() {
-		return startPaymentDateMgpc;
-	}
-
-	public void setStartPaymentDateMgpc(Date startPaymentDateMgpc) {
-		this.startPaymentDateMgpc = startPaymentDateMgpc;
-	}
-
-	public Date getDeadlinePaymentDateMgpc() {
-		return deadlinePaymentDateMgpc;
-	}
-
-	public void setDeadlinePaymentDateMgpc(Date deadlinePaymentDateMgpc) {
-		this.deadlinePaymentDateMgpc = deadlinePaymentDateMgpc;
-	}
-
-	public YesOrNoEnum getOpenFlag() {
-		return openFlag;
-	}
-
-	public void setOpenFlag(YesOrNoEnum openFlag) {
-		this.openFlag = openFlag;
-	}
-
-	private StudentRegistration studentRegistration = new StudentRegistration();
-
-	public String getMusicGroupId() {
-		return musicGroupId;
-	}
-
-	public void setMusicGroupId(String musicGroupId) {
-		this.musicGroupId = musicGroupId;
-	}
-
-	public Date getStartPaymentDate() {
-		return startPaymentDate;
-	}
-
-	public void setStartPaymentDate(Date startPaymentDate) {
-		this.startPaymentDate = startPaymentDate;
-	}
-
-	public Date getDeadlinePaymentDate() {
-		return deadlinePaymentDate;
-	}
-
-	public void setDeadlinePaymentDate(Date deadlinePaymentDate) {
-		this.deadlinePaymentDate = deadlinePaymentDate;
-	}
-
-	public Integer getOpen() {
-		return open;
-	}
-
-	public void setOpen(Integer open) {
-		this.open = open;
-	}
-
-	public StudentRegistration getStudentRegistration() {
-		return studentRegistration;
-	}
-
-	public void setStudentRegistration(StudentRegistration studentRegistration) {
-		this.studentRegistration = studentRegistration;
-	}
-
-	public SysUser getSysUser() {
-		return sysUser;
-	}
-
-	public void setSysUser(SysUser sysUser) {
-		this.sysUser = sysUser;
-	}
-
-	public void setId(Long id){
-		this.id = id;
-	}
-	
-	public Long getId(){
-		return this.id;
-	}
-			
-	public void setMusicGroupPaymentCalenderId(Long musicGroupPaymentCalenderId){
-		this.musicGroupPaymentCalenderId = musicGroupPaymentCalenderId;
-	}
-	
-	public Long getMusicGroupPaymentCalenderId(){
-		return this.musicGroupPaymentCalenderId;
-	}
-
-	public Long getPaymentOrderId() {
-		return paymentOrderId;
-	}
-
-	public void setPaymentOrderId(Long paymentOrderId) {
-		this.paymentOrderId = paymentOrderId;
-	}
-
-	public void setUserId(Integer userId){
-		this.userId = userId;
-	}
-	
-	public Integer getUserId(){
-		return this.userId;
-	}
-			
-	public void setExpectAmount(java.math.BigDecimal expectAmount){
-		this.expectAmount = expectAmount;
-	}
-	
-	public java.math.BigDecimal getExpectAmount(){
-		return this.expectAmount;
-	}
-			
-	public void setActualAmount(java.math.BigDecimal actualAmount){
-		this.actualAmount = actualAmount;
-	}
-	
-	public java.math.BigDecimal getActualAmount(){
-		return this.actualAmount;
-	}
-			
-	public void setPaymentStatus(PaymentStatus paymentStatus){
-		this.paymentStatus = paymentStatus;
-	}
-	
-	public PaymentStatus getPaymentStatus(){
-		return this.paymentStatus;
-	}
-			
-	public void setUserStatus(String userStatus){
-		this.userStatus = userStatus;
-	}
-	
-	public String getUserStatus(){
-		return this.userStatus;
-	}
-			
-	public void setPayTime(java.util.Date payTime){
-		this.payTime = payTime;
-	}
-	
-	public java.util.Date getPayTime(){
-		return this.payTime;
-	}
-			
-	public void setUpdateTime(java.util.Date updateTime){
-		this.updateTime = updateTime;
-	}
-	
-	public java.util.Date getUpdateTime(){
-		return this.updateTime;
-	}
-			
-	public void setCreateTime(java.util.Date createTime){
-		this.createTime = createTime;
-	}
-	
-	public java.util.Date getCreateTime(){
-		return this.createTime;
-	}
-
-	public Integer getUseInCourse() {
-		return useInCourse;
-	}
-
-	public void setUseInCourse(Integer useInCourse) {
-		this.useInCourse = useInCourse;
-	}
-
-	public Integer getResponsibleUserId() {
-		return responsibleUserId;
-	}
-
-	public void setResponsibleUserId(Integer responsibleUserId) {
-		this.responsibleUserId = responsibleUserId;
-	}
-
-	public String getResponsibleRecord() {
-		return responsibleRecord;
-	}
-
-	public void setResponsibleRecord(String responsibleRecord) {
-		this.responsibleRecord = responsibleRecord;
-	}
-
-	public SysUser getResponsible() {
-		return responsible;
-	}
-
-	public void setResponsible(SysUser responsible) {
-		this.responsible = responsible;
-	}
+	@ApiModelProperty(value = "乐器、云教练溢出的课程费用")
+	private BigDecimal courseIncome = BigDecimal.ZERO;
 
 	@Override
 	public String toString() {

+ 10 - 11
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentMusicCourseFee.java

@@ -4,36 +4,35 @@ import com.ym.mec.common.entity.BaseEntity;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.math.BigDecimal;
+
 /**
  * 对应数据库表(student_music_course_fee):
  */
 @Data
 public class StudentMusicCourseFee extends BaseEntity {
 
-	@ApiModelProperty(value = "收费类型编号",required = false)
 	private Integer id;
 
 	@ApiModelProperty(value = "学员编号",required = false)
 	private Integer userId;
 
-	@ApiModelProperty(value = "收费类型编号",required = false)
+	@ApiModelProperty(value = "分部编号",required = false)
 	private Integer organId;
 
-	@ApiModelProperty(value = "收费类型编号",required = false)
+	@ApiModelProperty(value = "乐团编号",required = false)
 	private String musicGroupId;
 
-	@ApiModelProperty(value = "收费类型编号",required = false)
-	private String expectPrice;
+	@ApiModelProperty(value = "预计总课费",required = false)
+	private BigDecimal expectPrice = BigDecimal.ZERO;
 
-	@ApiModelProperty(value = "收费类型编号",required = false)
-	private String actualPrice;
+	@ApiModelProperty(value = "总课费",required = false)
+	private BigDecimal actualPrice = BigDecimal.ZERO;
 
-	@ApiModelProperty(value = "收费类型编号",required = false)
-	private String receivablePrice;
+	@ApiModelProperty(value = "收",required = false)
+	private BigDecimal receivablePrice = BigDecimal.ZERO;
 
-	@ApiModelProperty(value = "收费类型编号",required = false)
 	private String createTime;
 
-	@ApiModelProperty(value = "收费类型编号",required = false)
 	private String updateTime;
 }

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

@@ -1,8 +1,41 @@
 package com.ym.mec.biz.service;
 
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
 import com.ym.mec.common.service.BaseService;
 
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 public interface MusicGroupPaymentStudentCourseDetailService extends BaseService<Long, MusicGroupPaymentStudentCourseDetail> {
 
+    /**
+    * @description: 新增学员可排课时长
+     * @param userIdList
+     * @param calender
+     * @param userCalenderDetailMap
+    * @return void
+    * @author zx
+    * @date 2023/3/23 11:07
+    */
+    void batchInsert(Set<Integer> userIdList,
+                     MusicGroupPaymentCalender calender,
+                     Map<Integer, Long> userCalenderDetailMap);
+
+    void batchInsert(Integer userId,
+                     MusicGroupPaymentCalender musicGroupPaymentCalender,
+                     Long calenderDetailId,
+                     Long paymentOrderId);
+
+    List<MusicGroupPaymentStudentCourseDetail> queryByMusicGroupPaymentStudentCourseDetailId(List<Long> musicGroupPaymentCalenderDetailIdList);
+
+    void deleteByMusicGroupPaymentCalenderDetailId(List<Long> musicGroupPaymentCalenderDetailIdList);
+
+    void deleteByMusicGroupPaymentCalenderId(String calenderId,Integer userId);
+
+    void deleteByUserIdAndMusicGroupId(Integer userId, String musicGroupId);
+
+    void clearRemainCourseMinutesByMusicGroupId(String musicGroupId);
 }

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentMusicCourseFeeService.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.ym.mec.biz.dal.dao.StudentMusicCourseFeeDao;
 import com.ym.mec.biz.dal.entity.StudentMusicCourseFee;
 
+import java.math.BigDecimal;
+
 
 /**
 * @description: 学员乐团课程费用汇总
@@ -13,6 +15,10 @@ import com.ym.mec.biz.dal.entity.StudentMusicCourseFee;
 public interface StudentMusicCourseFeeService extends IService<StudentMusicCourseFee> {
 
     StudentMusicCourseFeeDao getDao();
+
+    void addExpectPrice(Integer userId, String musicGroupId, BigDecimal expectPrice);
+
+    void cutExpectPrice(Integer userId, String musicGroupId, BigDecimal expectPrice);
 }
 
 

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

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.service.impl;
 
 import com.ym.mec.biz.dal.dao.MusicGroupOrganizationCourseSettingsDetailDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderCourseSettingsDao;
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentStudentCourseDetailDao;
 import com.ym.mec.biz.dal.dao.OrganizationCourseUnitPriceSettingsDao;
 import com.ym.mec.biz.dal.dto.MusicGroupPaymentBaseCalender;
@@ -8,26 +9,18 @@ import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.CalenderBaseServiceEnum;
 import com.ym.mec.biz.service.MusicGroupOrganizationCourseSettingsService;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderBaseService;
-import com.ym.mec.common.controller.BaseController;
-import com.ym.mec.common.exception.BizException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.stereotype.Service;
-
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderCourseSettingsDao;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderCourseSettingsService;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
-import org.springframework.transaction.interceptor.TransactionAspectSupport;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
 import java.util.*;
-import java.util.function.BiFunction;
-import java.util.function.BinaryOperator;
 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.PaymentCalenderStatusEnum.AUDITING;
 import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.MUSIC_APPLY;
 import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.MUSIC_RENEW;

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

@@ -46,9 +46,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
     @Autowired
     private MusicGroupPaymentCalenderService musicGroupPaymentCalenderService;
     @Autowired
-    private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
-    @Autowired
-    private MusicGroupPaymentStudentCourseDetailDao musicGroupPaymentStudentCourseDetailDao;
+    private MusicGroupPaymentStudentCourseDetailService musicGroupPaymentStudentCourseDetailService;
     @Autowired
     private MusicGroupDao musicGroupDao;
     @Autowired
@@ -70,8 +68,6 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
     @Autowired
     private StudentPaymentOrderDao studentPaymentOrderDao;
     @Autowired
-    private StudentDao studentDao;
-    @Autowired
     private VipGroupActivityDao vipGroupActivityDao;
     @Autowired
     private OperatingReportCloudService operatingReportCloudService;
@@ -215,11 +211,9 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
             throw new BizException("操作失败:包含已存在的学员");
         }
 
-        List<MusicGroupPaymentCalenderCourseSettings> courseSettingsList = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalender(musicGroupPaymentCalenderId);
-
         Date date = new Date();
         MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
-        Map<Integer, Long> userMap = new HashMap<>();
+        Map<Integer, Long> userCalenderDetailMap = new HashMap<>();
         Map<Integer, Integer> activityuserMap = new HashMap<>();
         List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<>();
         //创建缴费明细
@@ -300,7 +294,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 
         if (musicGroupPaymentCalenderDetailList.size() > 0) {
             musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
-            musicGroupPaymentCalenderDetailList.stream().forEach(e -> userMap.put(e.getUserId(), e.getId()));
+            musicGroupPaymentCalenderDetailList.stream().forEach(e -> userCalenderDetailMap.put(e.getUserId(), e.getId()));
         }
         //更新预计缴费人数
         musicGroupPaymentCalender.setExpectNum(musicGroupPaymentCalender.getExpectNum() + userIdList.size());
@@ -309,43 +303,9 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
             musicGroupPaymentCalender.setActualNum(musicGroupPaymentCalender.getActualNum() + userIdList.size());
         }
         musicGroupPaymentCalenderService.update(musicGroupPaymentCalender);
-
         //创建学生课排课分钟数
-        if (courseSettingsList != null && courseSettingsList.size() > 0) {
-            List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = new ArrayList<>();
-            MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = null;
-            for (Integer studentId : userIdList) {
-                for (MusicGroupPaymentCalenderCourseSettings courseSettings : courseSettingsList) {
-                    if (courseSettings.getCourseTotalMinuties() == null || courseSettings.getCourseTotalMinuties() == 0) {
-                        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);
-                    musicGroupPaymentStudentCourseDetail.setCloudTeacherPaymentFlag(musicGroupPaymentCalender.getCloudTeacherPaymentFlag());
-                    musicGroupPaymentStudentCourseDetailList.add(musicGroupPaymentStudentCourseDetail);
-                }
-            }
-            if (musicGroupPaymentStudentCourseDetailList.size() > 0) {
-                musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetailList);
-            }
-        }
+        musicGroupPaymentStudentCourseDetailService.batchInsert(userIdList,musicGroupPaymentCalender,userCalenderDetailMap);
+
         //给学员推送缴费通知
         if (musicGroupPaymentCalender.getPayUserType() == STUDENT && musicGroupPaymentCalender.getStatus() == PaymentCalenderStatusEnum.OPEN) {
             musicGroupPaymentCalenderService.pushWaitRenewMessage(musicGroupPaymentCalender.getId(),
@@ -383,7 +343,8 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
             musicGroupPaymentCalenderDetailIdList.add(Long.parseLong(s));
         }
         //是否已排课
-        List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = musicGroupPaymentStudentCourseDetailDao.queryByMusicGroupPaymentStudentCourseDetailId(musicGroupPaymentCalenderDetailIdList);
+        List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList =
+                musicGroupPaymentStudentCourseDetailService.queryByMusicGroupPaymentStudentCourseDetailId(musicGroupPaymentCalenderDetailIdList);
         count = musicGroupPaymentStudentCourseDetailList.stream().filter(e -> e.getUsedCourseMinutes() > 0).count();
         if (count > 0) {
             throw new BizException("删除失败:存在已排课的学员");
@@ -391,11 +352,10 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 
         int currentNum = musicGroupPaymentCalender.getExpectNum() - details.size();
         musicGroupPaymentCalender.setExpectNum(currentNum < 0 ? 0 : currentNum);
-        musicGroupPaymentCalender.setUpdateTime(new Date());
         musicGroupPaymentCalenderDao.update(musicGroupPaymentCalender);
 
         musicGroupPaymentCalenderDetailDao.batchDel(musicGroupPaymentCalenderDetailIds);
-        musicGroupPaymentStudentCourseDetailDao.deleteByMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetailIdList);
+        musicGroupPaymentStudentCourseDetailService.deleteByMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetailIdList);
     }
 
     @Override
@@ -551,53 +511,10 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 
         //保存、更新云教练缴费项目预收
         operatingReportCloudService.updateSet(musicGroupPaymentCalender,studentPaymentOrder.getId());
-
-        Boolean cloudTeacherPaymentFlag = false;
-        if(musicGroupPaymentCalender.getCloudTeacherPaymentFlag()){
-            List<MusicGroupPaymentCalenderCourseSettings> courseSettings = musicGroupPaymentCalenderCourseSettingsDao.queryCalenderCourseSettings(musicGroupPaymentCalender.getId());
-            BigDecimal reduce = courseSettings.stream().map(e -> e.getCourseCurrentPrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
-            cloudTeacherPaymentFlag = reduce.compareTo(BigDecimal.ZERO) == 0;
-        }
         //续费项目加学员时就生成了课程时长,报名项目在缴费成功后才需要添加课程时长
-        if (musicGroupPaymentCalender.getPaymentType() == MusicGroupPaymentCalender.PaymentType.MUSIC_APPLY) {
-            List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = new ArrayList<>();
-            List<String> orderDetailTypes = studentPaymentOrderDetailDao.getOrderDetailType(studentPaymentOrder.getId());
-            List<MusicGroupPaymentCalenderCourseSettings> courseSettingsList = musicGroupPaymentCalenderCourseSettingsDao
-                    .getWithPaymentCalender(musicGroupPaymentCalender.getId());
-            for (MusicGroupPaymentCalenderCourseSettings courseSetting : courseSettingsList) {
-                if (musicGroupPaymentCalender.getPayUserType().equals(MusicGroupPaymentCalender.PayUserType.STUDENT)
-                        && !orderDetailTypes.contains(courseSetting.getCourseType().getCode())) {
-                    continue;
-                }
-                if (courseSetting.getCourseTotalMinuties() == null || courseSetting.getCourseTotalMinuties() == 0) {
-                    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);
-                musicGroupPaymentStudentCourseDetail.setTenantId(tenantId);
-                musicGroupPaymentStudentCourseDetail.setCloudTeacherPaymentFlag(cloudTeacherPaymentFlag);
-                musicGroupPaymentStudentCourseDetails.add(musicGroupPaymentStudentCourseDetail);
-            }
-            if (musicGroupPaymentStudentCourseDetails.size() > 0) {
-                musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetails);
-            }
-        }
+        musicGroupPaymentStudentCourseDetailService.batchInsert(studentPaymentOrder.getUserId(),
+                musicGroupPaymentCalender,
+                musicGroupPaymentCalenderDetail.getId(),
+                studentPaymentOrder.getId());
     }
 }

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

@@ -27,7 +27,6 @@ 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 org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
@@ -62,7 +61,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
     @Autowired
     private MusicGroupPaymentCalenderCourseSettingsServiceImpl musicGroupPaymentCalenderCourseSettingsService;
     @Autowired
-    private MusicGroupPaymentStudentCourseDetailDao musicGroupPaymentStudentCourseDetailDao;
+    private MusicGroupPaymentStudentCourseDetailService musicGroupPaymentStudentCourseDetailService;
     @Autowired
     private MusicGroupSchoolTermCourseDetailDao musicGroupSchoolTermCourseDetailDao;
     @Autowired
@@ -433,11 +432,15 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
             addStudent(musicGroupPaymentCalender, musicGroup);
             //将0元未缴费学员缴费状态更新为已缴费
             this.updateNoPaymentAndZeroPaymentStatus(musicGroupPaymentCalender, true);
+            List<MusicGroupPaymentCalenderCourseSettings> settingsList = musicGroupPaymentBaseCalender.getMusicGroupPaymentCalenderCourseSettingsList();
             // 学生加到班级
             classGroupService.addStudentToClassGroupAndCourseArranging(calenderAddStudent.getStudentIds(), calenderAddStudent.getClassGroupIds(),
-                    batchNo, musicGroupPaymentBaseCalender.getMusicGroupPaymentCalenderCourseSettingsList(), musicGroup);
-            //记录学员课程费用
-            studentMusicCourseFeeService.addExpcetPrice(musicGroupPaymentCalender);
+                    batchNo, settingsList, musicGroup);
+            //记录经营报表学员课程费用
+            if(CollectionUtils.isNotEmpty(settingsList)){
+                BigDecimal coursePrice = settingsList.stream().map(e -> e.getCourseCurrentPrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
+                studentMusicCourseFeeService.addExpectPrice(calenderAddStudent.getStudentIds(),musicGroupId,coursePrice);
+            }
             ExecutorService executor = Executors.newFixedThreadPool(5);
             CompletableFuture.runAsync(() -> {
                 imUserFriendService.refreshGroupImUserFriend(musicGroupId, GroupType.MUSIC);
@@ -1338,7 +1341,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
         musicGroupPaymentCalenderDao.delete(id);
         musicGroupPaymentCalenderDetailDao.deleteByCalenderId(id);
-        musicGroupPaymentStudentCourseDetailDao.deleteByMusicGroupPaymentCalenderId(id);
+        musicGroupPaymentStudentCourseDetailService.deleteByMusicGroupPaymentCalenderId(id.toString(),null);
         musicGroupPaymentCalenderActivityService.delByCalenderId(id);
         musicGroupPaymentCalenderMemberService.deleteByCalenderId(id);
         musicGroupPaymentCalenderRepairService.deleteByCalenderId(id);

+ 173 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentStudentCourseDetailServiceImpl.java

@@ -1,21 +1,194 @@
 package com.ym.mec.biz.service.impl;
 
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderCourseSettingsDao;
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentStudentCourseDetailDao;
+import com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
 import com.ym.mec.biz.service.MusicGroupPaymentStudentCourseDetailService;
+import com.ym.mec.biz.service.StudentMusicCourseFeeService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.apache.commons.collections.CollectionUtils;
 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.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType.SCHOOL;
 
 @Service
 public class MusicGroupPaymentStudentCourseDetailServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentStudentCourseDetail>  implements MusicGroupPaymentStudentCourseDetailService {
 	
 	@Autowired
 	private MusicGroupPaymentStudentCourseDetailDao musicGroupPaymentStudentCourseDetailDao;
+	@Autowired
+	private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
+	@Autowired
+	private StudentMusicCourseFeeService studentMusicCourseFeeService;
+	@Autowired
+	private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
 
 	@Override
 	public BaseDAO<Long, MusicGroupPaymentStudentCourseDetail> getDAO() {
 		return musicGroupPaymentStudentCourseDetailDao;
 	}
+
+    @Override
+	@Transactional(rollbackFor = Exception.class)
+    public void batchInsert(Set<Integer> userIdList,
+							MusicGroupPaymentCalender calender,
+							Map<Integer, Long> userCalenderDetailMap) {
+		List<MusicGroupPaymentCalenderCourseSettings> courseSettingsList = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalender(calender.getId());
+		//创建学生课排课分钟数
+		if (courseSettingsList != null && courseSettingsList.size() > 0) {
+			List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = new ArrayList<>();
+			MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = null;
+			Long calenderId = calender.getId();
+			String musicGroupId = calender.getMusicGroupId();
+			MusicGroupPaymentCalender.PayUserType payUserType = calender.getPayUserType();
+			Boolean cloudTeacherPaymentFlag = calender.getCloudTeacherPaymentFlag();
+			for (Integer studentId : userIdList) {
+				BigDecimal reduce = BigDecimal.ZERO;
+
+				for (MusicGroupPaymentCalenderCourseSettings courseSettings : courseSettingsList) {
+					if (courseSettings.getCourseTotalMinuties() == null || courseSettings.getCourseTotalMinuties() == 0) {
+						continue;
+					}
+					musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
+					musicGroupPaymentStudentCourseDetail.setMusicGroupId(musicGroupId);
+					musicGroupPaymentStudentCourseDetail.setCourseType(courseSettings.getCourseType());
+					musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(calenderId);
+					musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(userCalenderDetailMap.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(payUserType == SCHOOL){
+						musicGroupPaymentStudentCourseDetail.setCourseCurrentPrice(BigDecimal.ZERO);
+						musicGroupPaymentStudentCourseDetail.setSubCourseCurrentPrice(BigDecimal.ZERO);
+					}
+					musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
+					musicGroupPaymentStudentCourseDetail.setUserId(studentId);
+					musicGroupPaymentStudentCourseDetail.setCloudTeacherPaymentFlag(cloudTeacherPaymentFlag);
+					musicGroupPaymentStudentCourseDetailList.add(musicGroupPaymentStudentCourseDetail);
+					reduce = reduce.add(musicGroupPaymentStudentCourseDetail.getCourseCurrentPrice());
+				}
+				if(reduce.compareTo(BigDecimal.ZERO) > 0){
+					//汇总学员乐团课费,如果有溢出的乐器费用、云教练费用,也一并汇总,用于计算经营报表
+					studentMusicCourseFeeService.addExpectPrice(studentId,musicGroupId,reduce);
+				}
+			}
+			if (musicGroupPaymentStudentCourseDetailList.size() > 0) {
+				musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetailList);
+			}
+		}
+    }
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void batchInsert(Integer userId, MusicGroupPaymentCalender musicGroupPaymentCalender, Long calenderDetailId, Long paymentOrderId) {
+		//续费项目加学员时就生成了课程时长,报名项目在缴费成功后才需要添加课程时长
+		if (musicGroupPaymentCalender.getPaymentType() == MusicGroupPaymentCalender.PaymentType.MUSIC_APPLY) {
+			List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = new ArrayList<>();
+			List<String> orderDetailTypes = studentPaymentOrderDetailDao.getOrderDetailType(paymentOrderId);
+			List<MusicGroupPaymentCalenderCourseSettings> courseSettingsList = musicGroupPaymentCalenderCourseSettingsDao
+					.getWithPaymentCalender(musicGroupPaymentCalender.getId());
+			Boolean cloudTeacherPaymentFlag = musicGroupPaymentCalender.getCloudTeacherPaymentFlag();
+			BigDecimal reduce = BigDecimal.ZERO;
+			for (MusicGroupPaymentCalenderCourseSettings courseSetting : courseSettingsList) {
+				if (musicGroupPaymentCalender.getPayUserType().equals(MusicGroupPaymentCalender.PayUserType.STUDENT)
+						&& !orderDetailTypes.contains(courseSetting.getCourseType().getCode())) {
+					continue;
+				}
+				if (courseSetting.getCourseTotalMinuties() == null || courseSetting.getCourseTotalMinuties() == 0) {
+					continue;
+				}
+				MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
+				musicGroupPaymentStudentCourseDetail.setMusicGroupId(musicGroupPaymentCalender.getMusicGroupId());
+				musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
+				musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(calenderDetailId);
+				musicGroupPaymentStudentCourseDetail.setUserId(userId);
+				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.setCloudTeacherPaymentFlag(cloudTeacherPaymentFlag);
+				musicGroupPaymentStudentCourseDetails.add(musicGroupPaymentStudentCourseDetail);
+			}
+			if(reduce.compareTo(BigDecimal.ZERO) > 0){
+				//汇总学员乐团课费,如果有溢出的乐器费用、云教练费用,也一并汇总,用于计算经营报表
+				studentMusicCourseFeeService.addExpectPrice(userId,musicGroupPaymentCalender.getMusicGroupId(),reduce);
+			}
+			if (musicGroupPaymentStudentCourseDetails.size() > 0) {
+				musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetails);
+			}
+		}
+	}
+
+	@Override
+	public List<MusicGroupPaymentStudentCourseDetail> queryByMusicGroupPaymentStudentCourseDetailId(List<Long> musicGroupPaymentCalenderDetailIdList) {
+		return musicGroupPaymentStudentCourseDetailDao.queryByMusicGroupPaymentStudentCourseDetailId(musicGroupPaymentCalenderDetailIdList);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void deleteByMusicGroupPaymentCalenderDetailId(List<Long> musicGroupPaymentCalenderDetailIdList) {
+		this.delByDetails(musicGroupPaymentStudentCourseDetailDao.queryByMusicGroupPaymentStudentCourseDetailId(musicGroupPaymentCalenderDetailIdList));
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void deleteByMusicGroupPaymentCalenderId(String calenderId,Integer userId) {
+		this.delByDetails(musicGroupPaymentStudentCourseDetailDao.findByCalenderAndUserId(calenderId, userId));
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void deleteByUserIdAndMusicGroupId(Integer userId, String musicGroupId) {
+		this.delByDetails(musicGroupPaymentStudentCourseDetailDao.findByUserIdAndMusicGroupId(userId, musicGroupId));
+	}
+
+    @Override
+	@Transactional(rollbackFor = Exception.class)
+    public void clearRemainCourseMinutesByMusicGroupId(String musicGroupId) {
+		musicGroupPaymentStudentCourseDetailDao.clearRemainCourseMinutesByMusicGroupId(musicGroupId);
+    }
+
+    void delByDetails(List<MusicGroupPaymentStudentCourseDetail> courseDetails){
+		if(CollectionUtils.isNotEmpty(courseDetails)){
+			List<Long> courseDetailIds = courseDetails.stream().map(e -> e.getId()).collect(Collectors.toList());
+			musicGroupPaymentStudentCourseDetailDao.delByIds(courseDetailIds);
+			//汇总学员乐团课费,如果有溢出的乐器费用、云教练费用,也一并汇总,用于计算经营报表
+			courseDetails = courseDetails.stream().filter(e -> e.getCourseCurrentPrice().compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
+			if(CollectionUtils.isNotEmpty(courseDetails)){
+				Map<Integer, List<MusicGroupPaymentStudentCourseDetail>> userMap = courseDetails.stream().collect(Collectors.groupingBy(e -> e.getUserId()));
+				for (Integer userId : userMap.keySet()) {
+					List<MusicGroupPaymentStudentCourseDetail> studentCourseDetails = userMap.get(userId);
+					Map<String, BigDecimal> priceMap = studentCourseDetails.stream().collect(Collectors.groupingBy(e -> e.getMusicGroupId(),
+							Collectors.collectingAndThen(Collectors.toList(), v -> v.stream().map(e -> e.getCourseCurrentPrice()).reduce(BigDecimal.ZERO, BigDecimal::add))));
+					for (String musicGroupId : priceMap.keySet()) {
+						studentMusicCourseFeeService.cutExpectPrice(userId,musicGroupId,priceMap.get(musicGroupId));
+					}
+				}
+			}
+		}
+	}
 }

+ 10 - 45
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -170,7 +170,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     @Autowired
     private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
     @Autowired
-    private MusicGroupPaymentStudentCourseDetailDao musicGroupPaymentStudentCourseDetailDao;
+    private MusicGroupPaymentStudentCourseDetailService musicGroupPaymentStudentCourseDetailService;
     @Autowired
     private SubjectChangeDao subjectChangeDao;
     @Autowired
@@ -413,11 +413,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 			MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
 			List<MusicGroupPaymentCalenderDetail> insertMusicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
 
-			List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = new ArrayList<>();
-
-			List<MusicGroupPaymentCalenderCourseSettings> courseSettingsList = musicGroupPaymentCalenderCourseSettingsDao
-					.getWithPaymentCalender(musicGroupPaymentCalender.getId());
-
 			for (StudentImportDto si : studentBasicList) {
 				musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
 				musicGroupPaymentCalenderDetail.setTenantId(tenantId);
@@ -432,45 +427,15 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 				musicGroupPaymentCalenderDetail.setUserStatus(null);
 				musicGroupPaymentCalenderDetail.setDeadlinePaymentDate(musicGroupPaymentCalender.getDeadlinePaymentDate());
 				musicGroupPaymentCalenderDetail.setStartPaymentDate(musicGroupPaymentCalender.getStartPaymentDate());
-				musicGroupPaymentCalenderDetail.setCreateTime(nowDate);
-				musicGroupPaymentCalenderDetail.setUpdateTime(nowDate);
-
 				insertMusicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
-
-				for (MusicGroupPaymentCalenderCourseSettings courseSetting : courseSettingsList) {
-					if (courseSetting.getCourseTotalMinuties() == null || courseSetting.getCourseTotalMinuties() == 0) {
-						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);
-					musicGroupPaymentStudentCourseDetail.setTenantId(tenantId);
-					musicGroupPaymentStudentCourseDetails.add(musicGroupPaymentStudentCourseDetail);
-				}
 			}
 			if (insertMusicGroupPaymentCalenderDetailList.size() > 0) {
 				musicGroupPaymentCalenderDetailDao.batchInsert(insertMusicGroupPaymentCalenderDetailList);
-
-				Map<Integer,Long> musicGroupPaymentCalenderDetailIdMap =  insertMusicGroupPaymentCalenderDetailList.stream().collect(Collectors.toMap(MusicGroupPaymentCalenderDetail :: getUserId, MusicGroupPaymentCalenderDetail :: getId));
-
-				if (musicGroupPaymentStudentCourseDetails.size() > 0) {
-					for(MusicGroupPaymentStudentCourseDetail cd : musicGroupPaymentStudentCourseDetails){
-						cd.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetailIdMap.get(cd.getUserId()));
-					}
-					musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetails);
-				}
+                //创建学生课排课分钟数
+                Map<Integer, Long> userCalenderDetailMap = new HashMap<>(insertMusicGroupPaymentCalenderDetailList.size());
+                insertMusicGroupPaymentCalenderDetailList.stream().forEach(e -> userCalenderDetailMap.put(e.getUserId(), e.getId()));
+                Set<Integer> userIdList = studentBasicList.stream().map(e -> e.getUserId()).collect(Collectors.toSet());
+                musicGroupPaymentStudentCourseDetailService.batchInsert(userIdList,musicGroupPaymentCalender,userCalenderDetailMap);
 			}
 		}
 
@@ -2339,7 +2304,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             List<MusicGroupPaymentCalender> paymentCalenders = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
             if(CollectionUtils.isNotEmpty(paymentCalenders)){
                 List<Long> calenderIds = paymentCalenders.stream().map(e -> e.getId()).collect(Collectors.toList());
-                musicGroupPaymentStudentCourseDetailDao.deleteByUserIdAndCalenderId(userId, calenderIds);
+                musicGroupPaymentStudentCourseDetailService.deleteByMusicGroupPaymentCalenderId(StringUtils.join(calenderIds,","),userId);
             }
 
             BigDecimal amount = new BigDecimal(0);
@@ -2605,7 +2570,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             musicGroupPaymentCalenderDetailDao.delete(mgpcd.getId());
         }
         //删除用户购买的课程记录
-        musicGroupPaymentStudentCourseDetailDao.deleteByUserIdAndMusicGroupId(userId, musicGroupId);
+        musicGroupPaymentStudentCourseDetailService.deleteByUserIdAndMusicGroupId(userId, musicGroupId);
 
         BigDecimal amount = new BigDecimal(0);
 
@@ -2826,7 +2791,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             musicGroupPaymentCalenderDetailDao.delete(mgpcd.getId());
         }
         //删除用户购买的课程记录
-        musicGroupPaymentStudentCourseDetailDao.deleteByUserIdAndMusicGroupId(userId, musicGroupId);
+        musicGroupPaymentStudentCourseDetailService.deleteByUserIdAndMusicGroupId(userId, musicGroupId);
 
         List<StudentPaymentOrder> studentPaymentOrderList = new ArrayList<StudentPaymentOrder>();
 
@@ -3772,7 +3737,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }*/
         
         //清除剩余未排课时长
-        musicGroupPaymentStudentCourseDetailDao.clearRemainCourseMinutesByMusicGroupId(musicGroupId);
+        musicGroupPaymentStudentCourseDetailService.clearRemainCourseMinutesByMusicGroupId(musicGroupId);
 
         //统计变更学员数
         groupEventSource.musicGroupStudentChangeEvent(closeMusicGroupDto.getMusicGroupId(), StudentMusicGroupStatusEnum.QUIT, null);

+ 35 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentMusicCourseFeeServiceImpl.java

@@ -5,6 +5,10 @@ import com.ym.mec.biz.dal.dao.StudentMusicCourseFeeDao;
 import com.ym.mec.biz.dal.entity.StudentMusicCourseFee;
 import com.ym.mec.biz.service.StudentMusicCourseFeeService;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+import java.util.Objects;
 
 
 @Service("studentMusicCourseFeeService")
@@ -16,6 +20,37 @@ public class StudentMusicCourseFeeServiceImpl extends ServiceImpl<StudentMusicCo
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void addExpectPrice(Integer userId, String musicGroupId, BigDecimal expectPrice) {
+        StudentMusicCourseFee one = this.lambdaQuery().eq(StudentMusicCourseFee::getMusicGroupId, musicGroupId)
+                .eq(StudentMusicCourseFee::getUserId, userId).one();
+        if(Objects.isNull(one)){
+            one = new StudentMusicCourseFee();
+            one.setExpectPrice(expectPrice);
+            one.setMusicGroupId(musicGroupId);
+            one.setUserId(userId);
+            this.save(one);
+        }else {
+            this.baseMapper.addExpectPrice(one.getId(),expectPrice);
+        }
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void cutExpectPrice(Integer userId, String musicGroupId, BigDecimal expectPrice) {
+        StudentMusicCourseFee one = this.lambdaQuery().eq(StudentMusicCourseFee::getMusicGroupId, musicGroupId)
+                .eq(StudentMusicCourseFee::getUserId, userId).one();
+        if(Objects.isNull(one)){
+            one = new StudentMusicCourseFee();
+            one.setMusicGroupId(musicGroupId);
+            one.setUserId(userId);
+            this.save(one);
+        }else {
+            this.baseMapper.cutExpectPrice(one.getId(),expectPrice);
+        }
+    }
+
+    @Override
     public boolean updateById(StudentMusicCourseFee entity) {
         this.lambdaQuery().eq(StudentMusicCourseFee::getMusicGroupId,entity.getMusicGroupId())
                 .eq(StudentMusicCourseFee::getUserId,entity.getUserId()).one();

+ 13 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderDetailServiceImpl.java

@@ -61,6 +61,10 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
     private StudentPaymentOrderService studentPaymentOrderService;
     @Autowired
     private MusicGroupPaymentCalenderDetailService musicGroupPaymentCalenderDetailService;
+    @Autowired
+    private ChargeTypeSubjectMapperDao chargeTypeSubjectMapperDao;
+    @Autowired
+    private StudentMusicCourseFeeService studentMusicCourseFeeService;
 
     @Override
     public BaseDAO<Long, StudentPaymentOrderDetail> getDAO() {
@@ -697,6 +701,15 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
                 repair.setStudentInstrumentId(studentInstrumentId);
                 studentPaymentOrderDetailDao.update(repair);
             }
+            //如果是免费团,那么要处理乐器溢出的课程费用
+            CourseViewTypeEnum courseViewType = musicGroup.getCourseViewType();
+            Integer subjectId = studentRegistration.getActualSubjectId();
+            ChargeTypeSubjectMapper chargeType = chargeTypeSubjectMapperDao.findByViewTypeANdSubject(courseViewType,subjectId,musicGroup.getTenantId());
+            if(Objects.nonNull(chargeType) && chargeType.getFee() != null && musical.getPrice().compareTo(BigDecimal.ZERO) > 0
+                    && chargeType.getFee().compareTo(musical.getPrice()) < 0){
+                studentMusicCourseFeeService.addExpectPrice(studentRegistration.getUserId(),
+                        musicGroup.getId(),musical.getPrice().subtract(chargeType.getFee()));
+            }
         }
 
         //学生云教练处理

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

@@ -168,4 +168,9 @@
         WHERE charge_type_id_ = #{chargeTypeId}
           AND FIND_IN_SET(subject_id_, #{subjectIds})
     </select>
+    <select id="findByViewTypeANdSubject" resultMap="ChargeTypeSubjectMapper">
+        select * from charge_type_subject_mapper
+        where course_view_type_ = #{courseViewType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        and subject_id_ = #{subjectId} and tenant_id_ = #{tenantId} LIMIT 1
+    </select>
 </mapper>

+ 11 - 4
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml

@@ -28,6 +28,7 @@
 		<result column="use_in_course_" property="useInCourse"/>
 		<result column="responsible_user_id_" property="responsibleUserId"/>
 		<result column="responsible_record_" property="responsibleRecord"/>
+		<result column="course_income_" property="courseIncome"/>
 		<result column="responsible_username_" property="responsible.username"/>
 		<association property="sysUser" javaType="com.ym.mec.auth.api.entity.SysUser">
 			<result column="username_" property="username" />
@@ -56,11 +57,11 @@
 		INSERT INTO music_group_payment_calender_detail
 		(music_group_payment_calender_id_,user_id_,expect_amount_,actual_amount_,payment_status_,
 		user_status_,pay_time_,update_time_,create_time_,start_payment_date_,deadline_payment_date_,
-		payment_order_id_,use_in_course_,responsible_user_id_,responsible_record_,expect_member_amount_,tenant_id_)
+		payment_order_id_,use_in_course_,responsible_user_id_,responsible_record_,expect_member_amount_,tenant_id_,course_income_)
 		VALUES(#{musicGroupPaymentCalenderId},#{userId},#{expectAmount},#{actualAmount},
 		       #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
 		#{userStatus},#{payTime},NOW(),NOW(),#{startPaymentDate},#{deadlinePaymentDate},
-		       #{paymentOrderId},#{useInCourse},#{responsibleUserId},#{responsibleRecord},#{expectMemberAmount},#{tenantId})
+		       #{paymentOrderId},#{useInCourse},#{responsibleUserId},#{responsibleRecord},#{expectMemberAmount},#{tenantId},#{courseIncome})
 	</insert>
 
     <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id"
@@ -68,13 +69,13 @@
         INSERT INTO music_group_payment_calender_detail
 		(music_group_payment_calender_id_,user_id_,expect_amount_,actual_amount_,
 		payment_status_,user_status_,pay_time_,update_time_,create_time_,start_payment_date_,
-		 deadline_payment_date_,payment_order_id_,use_in_course_,responsible_user_id_,responsible_record_,expect_member_amount_,tenant_id_)
+		 deadline_payment_date_,payment_order_id_,use_in_course_,responsible_user_id_,responsible_record_,expect_member_amount_,tenant_id_,course_income_)
 		VALUES
 		<foreach collection="list" item="item" separator=",">
             (#{item.musicGroupPaymentCalenderId},#{item.userId},#{item.expectAmount},
             #{item.actualAmount},#{item.paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.userStatus},#{item.payTime},
             #{item.updateTime},#{item.createTime},#{item.startPaymentDate},#{item.deadlinePaymentDate},
-             #{item.paymentOrderId},#{item.useInCourse},#{item.responsibleUserId},#{item.responsibleRecord},#{item.expectMemberAmount},#{item.tenantId})
+             #{item.paymentOrderId},#{item.useInCourse},#{item.responsibleUserId},#{item.responsibleRecord},#{item.expectMemberAmount},#{item.tenantId},#{item.courseIncome})
         </foreach>
     </insert>
 
@@ -83,6 +84,9 @@
 		parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail">
 		UPDATE music_group_payment_calender_detail
 		<set>
+			<if test="courseIncome != null">
+				course_income_ = #{courseIncome},
+			</if>
 			<if test="startPaymentDate != null">
 				start_payment_date_ = #{startPaymentDate},
 			</if>
@@ -138,6 +142,9 @@
 		<foreach collection="calenderDetails" item="item" index="index" open="" close="" separator=";">
 			UPDATE music_group_payment_calender_detail
 			<set>
+				<if test="item.courseIncome != null">
+					course_income_ = #{item.courseIncome},
+				</if>
 				<if test="item.startPaymentDate != null">
 					start_payment_date_ = #{item.startPaymentDate},
 				</if>

+ 10 - 37
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentStudentCourseDetailMapper.xml

@@ -160,13 +160,6 @@
             WHERE id_ = #{paymentCourseDetail.id} and tenant_id_ = #{paymentCourseDetail.tenantId}
         </foreach>
     </update>
-    <update id="updateByCourseType">
-        UPDATE music_group_payment_student_course_detail
-        SET course_current_price_ = #{courseCurrentPrice},
-            update_time_          = NOW()
-        WHERE course_type_ = #{courseType}
-          AND FIND_IN_SET(music_group_payment_calender_detail_id_, #{musicGroupPaymentCalenderIds})
-    </update>
 
     <!-- 根据主键删除一条记录 -->
     <delete id="delete">
@@ -175,23 +168,6 @@
         WHERE id_ = #{id}
     </delete>
 
-    <!-- 根据主键删除一条记录 -->
-    <delete id="deleteByMusicGroupPaymentCalenderId">
-        DELETE
-        FROM music_group_payment_student_course_detail
-        WHERE music_group_payment_calender_id_ = #{musicGroupPaymentCalenderId}
-    </delete>
-
-    <delete id="deleteByMusicGroupPaymentCalenderDetailId">
-        DELETE FROM music_group_payment_student_course_detail
-        <where>
-            music_group_payment_calender_detail_id_ IN
-            <foreach item="item" collection="list" separator="," open="(" close=")" index="">
-                #{item}
-            </foreach>
-        </where>
-    </delete>
-
     <!-- 分页查询 -->
     <select id="queryByMusicGroupPaymentStudentCourseDetailId" resultMap="MusicGroupPaymentStudentCourseDetail"
             parameterType="map">
@@ -266,22 +242,20 @@
         GROUP BY mgpscd.user_id_,mgpscd.course_type_
         HAVING SUM(mgpscd.sub_course_minutes_) > 0
     </select>
-
-    <delete id="deleteByUserIdAndMusicGroupId">
-        DELETE
-        FROM music_group_payment_student_course_detail
+    <select id="findByUserIdAndMusicGroupId" resultMap="MusicGroupPaymentStudentCourseDetail">
+        SELECT * FROM music_group_payment_student_course_detail
         WHERE user_id_ = #{userId}
           AND music_group_payment_calender_id_ IN (
             SELECT id_
             FROM music_group_payment_calender
             WHERE music_group_id_ = #{musicGroupId}
         )
-    </delete>
-    <delete id="deleteByUserIdAndCalenderId">
-        DELETE
-        FROM music_group_payment_student_course_detail
-        WHERE user_id_ = #{userId} AND music_group_payment_calender_id_ IN
-        <foreach collection="calenderIds" open="(" close=")" item="id" separator=",">
+    </select>
+
+    <delete id="delByIds">
+        DELETE FROM music_group_payment_student_course_detail
+        WHERE id_ IN
+        <foreach collection="courseDetailIds" open="(" close=")" item="id" separator=",">
             #{id}
         </foreach>
     </delete>
@@ -369,7 +343,7 @@
     </select>
 
     <select id="findByCalenderAndUserId" resultMap="MusicGroupPaymentStudentCourseDetail">
-        SELECT * FROM music_group_payment_student_course_detail WHERE music_group_payment_calender_id_ = #{calenderId}
+        SELECT * FROM music_group_payment_student_course_detail WHERE FIND_IN_SET(music_group_payment_calender_id_,#{calenderId})
         <if test="userId != null">
             AND user_id_ = #{userId}
         </if>
@@ -390,7 +364,6 @@
     </select>
 
     <update id="clearRemainCourseMinutesByMusicGroupId">
-    	update music_group_payment_student_course_detail
-		set sub_course_minutes_ = 0 WHERE sub_course_minutes_ > 0 and 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>

+ 21 - 0
mec-biz/src/main/resources/config/mybatis/StudentMusicCourseFeeMapper.xml

@@ -0,0 +1,21 @@
+<?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.StudentMusicCourseFeeDao">
+    <resultMap id="BaseResultMap" type="com.ym.mec.biz.dal.entity.StudentMusicCourseFee">
+        <id column="id_" property="id"/>
+        <id column="organ_id_" property="organId"/>
+        <id column="music_group_id_" property="musicGroupId"/>
+        <id column="expect_price_" property="expectPrice"/>
+        <id column="actual_price_" property="actualPrice"/>
+        <id column="receivable_price_" property="receivablePrice"/>
+        <id column="create_time_" property="createTime"/>
+        <id column="update_time_" property="updateTime"/>
+    </resultMap>
+    <insert id="addExpectPrice">
+        update student_music_course_fee set expect_price_ = expect_price_ + #{expectPrice} where id_ = #{id}
+    </insert>
+
+    <insert id="cutExpectPrice">
+        update student_music_course_fee set expect_price_ = expect_price_ - #{expectPrice} where id_ = #{id}
+    </insert>
+</mapper>