Forráskód Böngészése

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

# Conflicts:
#	mec-biz/src/main/java/com/ym/mec/biz/service/StudentAttendanceService.java
#	mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentAttendanceServiceImpl.java
yonge 2 éve
szülő
commit
a12e5a7686
19 módosított fájl, 697 hozzáadás és 164 törlés
  1. 18 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupCalenderRefundPeriodDao.java
  2. 3 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentStudentCourseDetailDao.java
  3. 130 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CooperationCalenderRefundDto.java
  4. 108 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CooperationRefundDto.java
  5. 34 15
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentStudentCourseDetail.java
  6. 51 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/CooperationRefundQueryInfo.java
  7. 18 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupCalenderRefundPeriodService.java
  8. 4 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java
  9. 5 5
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java
  10. 84 3
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupCalenderRefundPeriodServiceImpl.java
  11. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderCourseSettingsServiceImpl.java
  12. 30 19
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  13. 19 47
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentAttendanceServiceImpl.java
  14. 3 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  15. 100 3
      mec-biz/src/main/resources/config/mybatis/MusicGroupCalenderRefundPeriodMapper.xml
  16. 6 2
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml
  17. 34 55
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentStudentCourseDetailMapper.xml
  18. 47 0
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupCalenderRefundPeriodController.java
  19. 2 5
      mec-web/src/main/java/com/ym/mec/web/controller/UploadFileController.java

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

@@ -1,12 +1,30 @@
 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);
 }

+ 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:

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

@@ -0,0 +1,130 @@
+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;
+
+    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;
+    }
+}

+ 34 - 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,56 @@ 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 Integer usedCourseMinutes;
 
+	@ApiModelProperty(value = "剩余课程时长", required = false)
+	private Integer subCourseMinutes;
+
 	@ApiModelProperty(value = "标记是否云教练缴费项目",required = false)
 	private Boolean cloudTeacherPaymentFlag = false;
 
+	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;
 	}

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

@@ -0,0 +1,51 @@
+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 String organId;
+
+    @ApiModelProperty(value = "回访状态",required = false)
+    private Integer refundStatus;
+
+    @ApiModelProperty(value = "缴费开始时间",required = false)
+    private String refundStartDate;
+
+    @ApiModelProperty(value = "缴费结束时间",required = false)
+    private String refundEndDate;
+
+    public Integer getRefundStatus() {
+        return refundStatus;
+    }
+
+    public void setRefundStatus(Integer 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;
+    }
+}

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

@@ -1,10 +1,28 @@
 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);
 }

+ 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);
 
         //计算每节课的课酬

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

@@ -326,7 +326,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("学员缴费详情获取失败");
@@ -439,9 +439,9 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 
 							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());
 							}
@@ -455,7 +455,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 
 							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){
+							if(Objects.isNull(musicGroupPaymentCalenderCourseSettings) || originalCourseTotalMinutes != subCourseMinutes){
 								throw new BizException("缴费设置异常");
 							}
 

+ 84 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupCalenderRefundPeriodServiceImpl.java

@@ -2,20 +2,27 @@ 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.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.Date;
-import java.util.List;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
 
 import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType.SCHOOL;
 
@@ -26,6 +33,8 @@ public class MusicGroupCalenderRefundPeriodServiceImpl extends BaseServiceImpl<I
     private MusicGroupCalenderRefundPeriodDao musicGroupCalenderRefundPeriodDao;
     @Autowired
     private MusicGroupDao musicGroupDao;
+    @Autowired
+    private TeacherDao teacherDao;
 
     @Override
     public BaseDAO<Integer, MusicGroupCalenderRefundPeriod> getDAO() {
@@ -35,7 +44,7 @@ public class MusicGroupCalenderRefundPeriodServiceImpl extends BaseServiceImpl<I
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void savePeriod(MusicGroupPaymentBaseCalender baseCalender) {
-        if(baseCalender.getPayUserType() != SCHOOL){
+        if(baseCalender.getPayUserType() != SCHOOL || baseCalender.getCurrentTotalAmount().compareTo(BigDecimal.ZERO) == 0){
             return;
         }
         List<MusicGroupCalenderRefundPeriod> refundPeriods = baseCalender.getMusicGroupCalenderRefundPeriods();
@@ -54,4 +63,76 @@ public class MusicGroupCalenderRefundPeriodServiceImpl extends BaseServiceImpl<I
         });
         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->{
+                e.setIncome(e.getReceivable().subtract(e.getPrepaidFee()));
+                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);
+    }
 }

+ 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());

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

@@ -241,9 +241,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
             throw new BizException("请登录");
         });
 
-        if (musicGroup.getStatus() != MusicGroupStatusEnum.DRAFT) {
-            throw new BizException("只有‘草稿’状态才能创建报名缴费");
-        }
+//        if (musicGroup.getStatus() != MusicGroupStatusEnum.DRAFT) {
+//            throw new BizException("只有‘草稿’状态才能创建报名缴费");
+//        }
         // 所有缴费项目已完成排课才能创建下一个缴费项目
         /*String orignBatchNo = musicGroupPaymentStudentCourseDetailDao.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, null, null, null);
         if (!musicGroupPaymentBaseCalender.getConfirmCreate() && StringUtils.isNoneBlank(orignBatchNo)) {
@@ -264,10 +264,10 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         BeanUtils.copyProperties(musicGroupPaymentBaseCalender,musicGroupPaymentCalender);
         //判断缴费项目类型
         if (musicGroup.getStatus() == MusicGroupStatusEnum.DRAFT) {
-            musicGroupPaymentBaseCalender.setPaymentType(MUSIC_APPLY);
+            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());
@@ -276,9 +276,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);
                 }
             }
         }
@@ -307,11 +307,24 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
             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);
+                }
+            }
         }
 
         PaymentCalenderStatusEnum status;
-        if (musicGroupPaymentBaseCalender.getPaymentType() == MUSIC_APPLY || musicGroupPaymentBaseCalender.getPayUserType() == SCHOOL) {
+        if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY || musicGroupPaymentCalender.getPayUserType() == SCHOOL) {
             status = AUDITING;
+            if(musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY){
+                status = DRAFT;
+            }
         } else {
             //计算项目原现价
             BigDecimal courseCurrentAmount = musicGroupPaymentCalenderCourseSettingsService.getCurrentAmount(musicGroupPaymentBaseCalender);
@@ -353,17 +366,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         // 设置批次号
         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);
@@ -480,7 +485,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);
         //统计预计缴费人数
@@ -493,6 +498,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());
@@ -1317,6 +1326,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("操作失败:班级调整的缴费项目不支持");

+ 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);

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

@@ -1438,9 +1438,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();

+ 100 - 3
mec-biz/src/main/resources/config/mybatis/MusicGroupCalenderRefundPeriodMapper.xml

@@ -17,8 +17,10 @@
 		<result column="create_time_" property="createTime" />
 		<result column="update_time_" property="updateTime" />
 	</resultMap>
-	
-	
+	<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
@@ -35,7 +37,8 @@
 														refund_date_,refund_amount_,sub_refund_amount_,create_time_,update_time_)
 		VALUES
 		<foreach collection="refundPeriods" separator="," item="bean">
-			(#{organId},#{cooperationOrganId},#{calenderId},#{refundDate},#{refundAmount},#{subRefundAmount},#{createTime},#{updateTime})
+			(#{bean.organId},#{bean.cooperationOrganId},#{bean.calenderId},#{bean.refundDate},
+			 #{bean.refundAmount},#{bean.subRefundAmount},#{bean.createTime},#{bean.updateTime})
 		</foreach>
 	</insert>
 
@@ -49,4 +52,98 @@
 	<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>
+			<if test="organId != null and organId != ''">
+				AND FIND_IN_SET(co.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_
+		<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_
+		<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="nextRefundDate" column="nextRefundDate"/>
+		<result property="refundStatus" column="refundStatus"/>
+	</resultMap>
+	<sql id="queryCoopCalenderSql">
+		<if test="calenderId != null">
+			AND crp.calender_id_
+		</if>
+		<if test="refundStartDate != null and refundStartDate != ''">
+			AND crp.refund_date_ BETWEEN #{refundStartDate} AND #{refundEndDate}
+		</if>
+		<if test="search != '' and search != ''">
+			AND (mg.name_ LIKE CONCAT('%',#{search},'%') OR mg.id_ = #{search})
+		</if>
+	</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,
+			   MIN(CASE WHEN crp.refund_flag_ = 0 THEN crp.refund_date_ ELSE NULL END) nextRefundDate
+		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(refund_amount_) - SUM(sub_refund_amount_) END from music_group_calender_refund_period crp
+		left join cooperation_organ co ON co.id_ = crp.cooperation_organ_id_
+		<include refid="queryCoopRefundSql"/>
+	</select>
 </mapper>

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

@@ -41,6 +41,8 @@
         <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"/>
     </resultMap>
 
     <!-- 根据主键查询一条记录 -->
@@ -61,14 +63,16 @@
         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_,is_show_sale_price_)
+         ,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_)
         VALUES(#{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},#{isShowSalePrice})
+               #{currentTotalAmount},#{originalTotalAmount},#{tenantId},#{organId},#{cloudTeacherPaymentFlag},
+               #{paymentItemShowState},#{isShowSalePrice},#{calenderFeeType},#{calenderFeeJson})
     </insert>
 
 

+ 34 - 55
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"/>
@@ -16,6 +17,7 @@
         <result column="course_current_price_" property="courseCurrentPrice"/>
         <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,26 +44,26 @@
             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_,
+        (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_, tenant_id_,cloud_teacher_payment_flag_)
-        VALUES (#{musicGroupPaymentCalenderId}, #{musicGroupPaymentCalenderDetailId}, #{userId},
+        VALUES (#{musicGroupId}, #{musicGroupPaymentCalenderId}, #{musicGroupPaymentCalenderDetailId}, #{userId},
                 #{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{totalCourseMinutes},
-                #{usedCourseMinutes},
+                #{usedCourseMinutes},#{subCourseMinutes},
                 NOW(), NOW(), #{courseOriginalPrice}, #{courseCurrentPrice}, #{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_,
+        (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_,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.totalCourseMinutes},#{item.usedCourseMinutes},#{item.subCourseMinutes},NOW(),NOW(),#{item.courseOriginalPrice},
              #{item.courseCurrentPrice},#{item.tenantId},#{item.cloudTeacherPaymentFlag})
         </foreach>
     </insert>
@@ -77,6 +79,9 @@
             <if test="courseCurrentPrice != null">
                 course_current_price_ = #{courseCurrentPrice},
             </if>
+            <if test="subCourseMinutes != null">
+                used_course_minutes_ = #{subCourseMinutes},
+            </if>
             <if test="usedCourseMinutes != null">
                 used_course_minutes_ = #{usedCourseMinutes},
             </if>
@@ -111,6 +116,9 @@
                 <if test="paymentCourseDetail.courseCurrentPrice != null">
                     course_current_price_ = #{paymentCourseDetail.courseCurrentPrice},
                 </if>
+                <if test="paymentCourseDetail.subCourseMinutes != null">
+                    used_course_minutes_ = #{paymentCourseDetail.subCourseMinutes},
+                </if>
                 <if test="paymentCourseDetail.usedCourseMinutes != null">
                     used_course_minutes_ = #{paymentCourseDetail.usedCourseMinutes},
                 </if>
@@ -196,34 +204,10 @@
     <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}
-        <if test="studentId != null">
-            AND mgpscd.user_id_ = #{studentId}
-        </if>
-        <if test="batchNos != null">
-            AND mgpc.batch_no_ NOT IN
-            <foreach collection="batchNos" item="item" open="(" close=")" separator=",">
-                #{item}
-            </foreach>
-        </if>
-        <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;
+        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 +217,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 mgpscd.sub_course_minutes_ > 0
     </select>
 
     <delete id="deleteByUserIdAndMusicGroupId">
@@ -276,14 +260,13 @@
                                                   WHEN mgpscd.used_course_minutes_ = 0 THEN mgpscd.total_course_minutes_
                                                   ELSE 0 END) '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 +275,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 +293,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_
@@ -331,7 +313,6 @@
                 SUM(CASE WHEN mgpscd.used_course_minutes_ = 0 THEN mgpscd.total_course_minutes_ ELSE 0 END) '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 +334,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 +344,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>

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

@@ -0,0 +1,47 @@
+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.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;
+
+    @ApiOperation(value = "获取合作单位费用汇总列表")
+    @PostMapping("/queryCoopRefund")
+    @PreAuthorize("@pcs.hasPermissions('musicGroupCalenderRefundPeriod/queryCoopRefund')")
+    @AuditLogAnnotation(operateName = "获取合作单位费用汇总列表")
+    public HttpResponseResult<HashMap<String, Object>> queryCoopRefund(@RequestBody CooperationRefundQueryInfo queryInfo) {
+        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) {
+        return succeed(musicGroupCalenderRefundPeriodService.queryCoopCalender(queryInfo));
+    }
+}

+ 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);