Browse Source

Merge remote-tracking branch 'origin/master'

周箭河 4 years ago
parent
commit
bc9aed429f
26 changed files with 515 additions and 283 deletions
  1. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleStudentPaymentDao.java
  2. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/GoodsDao.java
  3. 33 26
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderCourseSettingsDao.java
  4. 11 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDao.java
  5. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDetailDao.java
  6. 3 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDetailDao.java
  7. 0 65
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupPaymentCalenderDto.java
  8. 20 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/TeacherClassCourseSchudeleDto.java
  9. 21 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CourseScheduleStudentPayment.java
  10. 35 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalender.java
  11. 3 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderCourseSettings.java
  12. 10 22
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderDetail.java
  13. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleStudentPaymentService.java
  14. 1 2
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java
  15. 98 34
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java
  16. 5 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java
  17. 109 79
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  18. 1 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java
  19. 10 2
      mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  20. 35 17
      mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml
  21. 8 3
      mec-biz/src/main/resources/config/mybatis/GoodsMapper.xml
  22. 12 2
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderCourseSettingsMapper.xml
  23. 25 5
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml
  24. 34 10
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml
  25. 7 0
      mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderDetailMapper.xml
  26. 5 6
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java

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

@@ -325,4 +325,13 @@ public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseSch
      * @return
      */
     List<RongyunBasicUserDto> queryNoJoinStu(@Param("roomId") String roomId, @Param("courseScheduleId") String courseScheduleId);
+
+    /**
+     * @describe 根据批次号获取学员课程缴费记录
+     * @author Joburgess
+     * @date 2020.10.30
+     * @param batchNo:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment>
+     */
+    List<CourseScheduleStudentPayment> findByBatchNo(@Param("batchNo") String batchNo);
 }

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

@@ -11,6 +11,8 @@ import java.util.List;
 
 public interface GoodsDao extends BaseDAO<Integer, Goods> {
 
+    Goods lock(@Param("goodsId") Integer goodsId);
+
     /**
      * 通过科目编号查询商品(教材、辅件)列表
      *

+ 33 - 26
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderCourseSettingsDao.java

@@ -8,31 +8,38 @@ import java.util.List;
 
 public interface MusicGroupPaymentCalenderCourseSettingsDao extends BaseDAO<Integer, MusicGroupPaymentCalenderCourseSettings> {
 
-    /**
-     * @param calenderId:
-     * @return java.util.List<com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings>
-     * @describe 获取指定缴费日历的课程价格设置
-     * @author Joburgess
-     * @date 2020.10.27
-     */
-    List<MusicGroupPaymentCalenderCourseSettings> getWithPaymentCalender(@Param("calenderId") Long calenderId);
-
-    int deleteByMusicGroupPaymentCalenderId(Long musicGroupPaymentCalenderId);
-
-    /**
-     * 获取乐团的缴费课程
-     *
-     * @param musicGroupId
-     * @return
-     */
-    List<MusicGroupPaymentCalenderCourseSettings> getMusicGroupRegCalenderCourseSettings(@Param("musicGroupId") String musicGroupId);
-
-    /**
-     * 获取乐团的缴费课程
-     *
-     * @param ids
-     * @return
-     */
-    List<MusicGroupPaymentCalenderCourseSettings> getCalenderCourseSettings(@Param("ids") List<Integer> ids);
+	/**
+	 * @param calenderId:
+	 * @return java.util.List<com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings>
+	 * @describe 获取指定缴费日历的课程价格设置
+	 * @author Joburgess
+	 * @date 2020.10.27
+	 */
+	List<MusicGroupPaymentCalenderCourseSettings> getWithPaymentCalender(@Param("calenderId") Long calenderId);
+
+	int deleteByMusicGroupPaymentCalenderId(Long musicGroupPaymentCalenderId);
+
+	/**
+	 * 获取乐团的缴费课程
+	 *
+	 * @param musicGroupId
+	 * @return
+	 */
+	List<MusicGroupPaymentCalenderCourseSettings> getMusicGroupRegCalenderCourseSettings(@Param("musicGroupId") String musicGroupId);
+
+	/**
+	 * 获取乐团的缴费课程
+	 *
+	 * @param ids
+	 * @return
+	 */
+	List<MusicGroupPaymentCalenderCourseSettings> getCalenderCourseSettings(@Param("ids") List<Integer> ids);
+
+	/**
+	 * 批量新增
+	 * @param musicGroupPaymentCalenderCourseSettingsList
+	 * @return
+	 */
+	int batchInsert(List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList);
 
 }

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

@@ -121,7 +121,8 @@ public interface MusicGroupPaymentCalenderDao extends BaseDAO<Long, MusicGroupPa
      * @param musicGroupId:
      * @return com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender
      */
-    MusicGroupPaymentCalender getMusicGroupUnusedFirstPaymentCalender(@Param("musicGroupId") String musicGroupId);
+    MusicGroupPaymentCalender getMusicGroupUnusedFirstPaymentCalender(@Param("musicGroupId") String musicGroupId,
+                                                                      @Param("studentIds") List<Integer> studentIds);
 
     /**
      * @describe 获取指定缴费日历中下未使用的最早的缴费记录
@@ -131,4 +132,13 @@ public interface MusicGroupPaymentCalenderDao extends BaseDAO<Long, MusicGroupPa
      * @return com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender
      */
     MusicGroupPaymentCalender getUnusedFirstPaymentCalenderWithCalenders(@Param("calenderIds") List<Long> calenderIds);
+
+    /**
+     * @describe 根据批次号获取缴费日历
+     * @author Joburgess
+     * @date 2020.10.30
+     * @param batchNo: 批次号
+     * @return java.util.List<com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender>
+     */
+    List<MusicGroupPaymentCalender> findByBatchNo(@Param("batchNo") String batchNo);
 }

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

@@ -138,6 +138,15 @@ public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicG
 	 */
 	List<MusicGroupPaymentCalenderDetail> getCalenderDetailWithCalender(@Param("calenderId") Long calenderId);
 
+	/**
+	 * @describe 获取指定缴费日历的详情
+	 * @author Joburgess
+	 * @date 2020.10.30
+	 * @param calenderIds:
+	 * @return java.util.List<com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail>
+	 */
+	List<MusicGroupPaymentCalenderDetail> getWithCalenderIds(@Param("calenderIds") List<Long> calenderIds);
+
     /**
      * @describe 获取乐团下未使用的缴费日历记录
      * @author Joburgess

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

@@ -117,4 +117,6 @@ public interface StudentPaymentOrderDetailDao extends BaseDAO<Long, StudentPayme
      * @return
      */
     List<StudentPaymentOrderDetail> getOrderGoodies(@Param("orderIds") List<Long> orderIds);
-}
+
+    List<StudentPaymentOrderDetail> getWithIds(@Param("paymentOrderIds") List<Long> paymentOrderIds);
+}

+ 0 - 65
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupPaymentCalenderDto.java

@@ -1,65 +0,0 @@
-package com.ym.mec.biz.dal.dto;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
-
-public class MusicGroupPaymentCalenderDto extends MusicGroupPaymentCalender {
-
-	private String studentIds;
-
-	private List<MusicGroupPaymentCalenderCourseSettings> MusicGroupPaymentCalenderCourseSettingsList = new ArrayList<MusicGroupPaymentCalenderCourseSettings>();
-
-	private List<PaymentDateRange> paymentDateRangeList = new ArrayList<PaymentDateRange>();
-
-	public String getStudentIds() {
-		return studentIds;
-	}
-
-	public void setStudentIds(String studentIds) {
-		this.studentIds = studentIds;
-	}
-
-	public List<MusicGroupPaymentCalenderCourseSettings> getMusicGroupPaymentCalenderCourseSettingsList() {
-		return MusicGroupPaymentCalenderCourseSettingsList;
-	}
-
-	public void setMusicGroupPaymentCalenderCourseSettingsList(List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList) {
-		MusicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalenderCourseSettingsList;
-	}
-
-	public List<PaymentDateRange> getPaymentDateRangeList() {
-		return paymentDateRangeList;
-	}
-
-	public void setPaymentDateRangeList(List<PaymentDateRange> paymentDateRangeList) {
-		this.paymentDateRangeList = paymentDateRangeList;
-	}
-
-	public class PaymentDateRange {
-
-		private Date startDate;
-
-		private Date endDate;
-
-		public Date getStartDate() {
-			return startDate;
-		}
-
-		public void setStartDate(Date startDate) {
-			this.startDate = startDate;
-		}
-
-		public Date getEndDate() {
-			return endDate;
-		}
-
-		public void setEndDate(Date endDate) {
-			this.endDate = endDate;
-		}
-	}
-
-}

+ 20 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/TeacherClassCourseSchudeleDto.java

@@ -63,6 +63,26 @@ public class TeacherClassCourseSchudeleDto {
     @ApiModelProperty(value = "能否进行调整")
     private int enableAdjustInToday;
 
+    private Integer schoolId;
+
+    private String schoolName;
+
+    public Integer getSchoolId() {
+        return schoolId;
+    }
+
+    public void setSchoolId(Integer schoolId) {
+        this.schoolId = schoolId;
+    }
+
+    public String getSchoolName() {
+        return schoolName;
+    }
+
+    public void setSchoolName(String schoolName) {
+        this.schoolName = schoolName;
+    }
+
     public int getEnableAdjustInToday() {
         return enableAdjustInToday;
     }

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

@@ -27,6 +27,8 @@ public class CourseScheduleStudentPayment {
 	
 	/**  */
 	private Integer userId;
+
+	private BigDecimal originalPrice;
 	
 	/** 预计价格 */
 	private java.math.BigDecimal expectPrice;
@@ -45,6 +47,8 @@ public class CourseScheduleStudentPayment {
 	
 	private Integer classGroupId;
 
+	private String batchNo;
+
 	public CourseScheduleStudentPayment() {
 	}
 
@@ -99,7 +103,15 @@ public class CourseScheduleStudentPayment {
 	public Integer getUserId(){
 		return this.userId;
 	}
-			
+
+	public BigDecimal getOriginalPrice() {
+		return originalPrice;
+	}
+
+	public void setOriginalPrice(BigDecimal originalPrice) {
+		this.originalPrice = originalPrice;
+	}
+
 	public void setExpectPrice(java.math.BigDecimal expectPrice){
 		this.expectPrice = expectPrice;
 	}
@@ -148,6 +160,14 @@ public class CourseScheduleStudentPayment {
 		this.classGroupId = classGroupId;
 	}
 
+	public String getBatchNo() {
+		return batchNo;
+	}
+
+	public void setBatchNo(String batchNo) {
+		this.batchNo = batchNo;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

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

@@ -2,7 +2,9 @@ package com.ym.mec.biz.dal.entity;
 
 import io.swagger.annotations.ApiModelProperty;
 
+import java.util.ArrayList;
 import java.util.Date;
+import java.util.List;
 
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
@@ -96,6 +98,15 @@ public class MusicGroupPaymentCalender {
 
 	private java.util.Date updateTime;
 
+	private String studentIds;
+
+	private List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = new ArrayList<MusicGroupPaymentCalenderCourseSettings>();
+
+	private String batchNo;
+
+	private List<MusicGroupPaymentCalenderCourseSettings> MusicGroupPaymentCalenderCourseSettingsList = new ArrayList<MusicGroupPaymentCalenderCourseSettings>();
+
+
 	public Integer getPaymentType() {
 		return paymentType;
 	}
@@ -240,6 +251,30 @@ public class MusicGroupPaymentCalender {
 		this.payUserType = payUserType;
 	}
 
+	public String getStudentIds() {
+		return studentIds;
+	}
+
+	public void setStudentIds(String studentIds) {
+		this.studentIds = studentIds;
+	}
+
+	public List<MusicGroupPaymentCalenderCourseSettings> getMusicGroupPaymentCalenderCourseSettingsList() {
+		return musicGroupPaymentCalenderCourseSettingsList;
+	}
+
+	public void setMusicGroupPaymentCalenderCourseSettingsList(List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList) {
+		this.musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalenderCourseSettingsList;
+	}
+
+	public String getBatchNo() {
+		return batchNo;
+	}
+
+	public void setBatchNo(String batchNo) {
+		this.batchNo = batchNo;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

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

@@ -13,7 +13,7 @@ public class MusicGroupPaymentCalenderCourseSettings {
 	private Integer id;
 	
 	/**  */
-	private Integer musicGroupPaymentCalenderId;
+	private Long musicGroupPaymentCalenderId;
 	
 	/** 课程类型 */
 	private CourseSchedule.CourseScheduleType courseType;
@@ -47,11 +47,11 @@ public class MusicGroupPaymentCalenderCourseSettings {
 		return this.id;
 	}
 			
-	public void setMusicGroupPaymentCalenderId(Integer musicGroupPaymentCalenderId){
+	public void setMusicGroupPaymentCalenderId(Long musicGroupPaymentCalenderId){
 		this.musicGroupPaymentCalenderId = musicGroupPaymentCalenderId;
 	}
 	
-	public Integer getMusicGroupPaymentCalenderId(){
+	public Long getMusicGroupPaymentCalenderId(){
 		return this.musicGroupPaymentCalenderId;
 	}
 			

+ 10 - 22
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderDetail.java

@@ -53,12 +53,6 @@ public class MusicGroupPaymentCalenderDetail {
 	/**  */
 	private java.util.Date deadlinePaymentDate;
 
-	/**  */
-	private java.util.Date startPaymentDateMgpc;
-
-	/**  */
-	private java.util.Date deadlinePaymentDateMgpc;
-
 	@ApiModelProperty(value = "订单编号",required = true)
 	private Long paymentOrderId;
 
@@ -68,21 +62,7 @@ public class MusicGroupPaymentCalenderDetail {
 	/**  */
 	private java.util.Date createTime;
 
-	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;
-	}
+	private Integer useInCourse;
 
 	private SysUser sysUser = new SysUser();
 
@@ -231,7 +211,15 @@ public class MusicGroupPaymentCalenderDetail {
 	public java.util.Date getCreateTime(){
 		return this.createTime;
 	}
-			
+
+	public Integer getUseInCourse() {
+		return useInCourse;
+	}
+
+	public void setUseInCourse(Integer useInCourse) {
+		this.useInCourse = useInCourse;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

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

@@ -65,4 +65,13 @@ public interface CourseScheduleStudentPaymentService extends BaseService<Long, C
 	 */
 	void createForMusicGroup(String musicGroupId, List<CourseSchedule> courseSchedules, List<Integer> studentIds);
 
+	/**
+	 * @describe 根据缴费日历更新乐团课程学院课程价格
+	 * @author Joburgess
+	 * @date 2020.10.29
+	 * @param batchNo: 缴费日历批次号
+	 * @return void
+	 */
+	void updateForMusicGroupWithPaymentCalender(String batchNo);
+
 }

+ 1 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java

@@ -2,7 +2,6 @@ package com.ym.mec.biz.service;
 
 import java.util.List;
 
-import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderDto;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.common.service.BaseService;
 
@@ -13,7 +12,7 @@ public interface MusicGroupPaymentCalenderService extends BaseService<Long, Musi
 	 * @param musicGroupPaymentCalenderDto
 	 * @return
 	 */
-	boolean create(MusicGroupPaymentCalenderDto musicGroupPaymentCalenderDto);
+	boolean create(MusicGroupPaymentCalender musicGroupPaymentCalender);
 	
 	/**
 	 * 更新缴费信息

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

@@ -10,8 +10,12 @@ import com.ym.mec.common.constant.CommonConstants;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.thirdparty.yqpay.DateUtils;
+import com.ym.mec.util.date.DateUtil;
+import org.springframework.beans.BeanUtils;
 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.util.CollectionUtils;
 
@@ -274,60 +278,84 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
 	public void createForMusicGroup(String musicGroupId, List<CourseSchedule> courseSchedules, List<Integer> studentIds) {
-		List<MusicGroupPaymentCalenderDetail> AllUnusedPaymentCalender = musicGroupPaymentCalenderDetailDao.getUnusedPaymentCalenderWithMusicGroup(musicGroupId);
-		if(CollectionUtils.isEmpty(AllUnusedPaymentCalender)){
-			throw new BizException("当前乐团无学员缴费信息");
-		}
-
-		Map<Long, Long> calenderStudentNumMap = AllUnusedPaymentCalender.stream().collect(Collectors.groupingBy(MusicGroupPaymentCalenderDetail::getMusicGroupPaymentCalenderId, Collectors.counting()));
-
-		//所有学员公共可用缴费日历编号
-		List<Long> calenderIds = new ArrayList<>();
-
-		for (Map.Entry<Long, Long> calenderIdStudentNumEntry : calenderStudentNumMap.entrySet()) {
-			if(calenderIdStudentNumEntry.getValue().intValue()==studentIds.size()){
-				calenderIds.add(calenderIdStudentNumEntry.getKey());
-			}
-		}
-
-		if(CollectionUtils.isEmpty(calenderIds)){
-			throw new BizException("部分学员无缴费信息");
-		}
-
-		MusicGroupPaymentCalender musicGroupUnusedFirstPaymentCalender = musicGroupPaymentCalenderDao.getUnusedFirstPaymentCalenderWithCalenders(calenderIds);
+		MusicGroupPaymentCalender musicGroupUnusedFirstPaymentCalender = musicGroupPaymentCalenderDao.getMusicGroupUnusedFirstPaymentCalender(musicGroupId, studentIds);
 		if(Objects.isNull(musicGroupUnusedFirstPaymentCalender)){
 			throw new BizException("当前乐团无未使用缴费记录");
 		}
 
-		List<MusicGroupPaymentCalenderDetail> unusedPaymentCalender = musicGroupPaymentCalenderDetailDao.getCalenderDetailWithCalender(musicGroupUnusedFirstPaymentCalender.getId());
-		if(CollectionUtils.isEmpty(unusedPaymentCalender)){
+		List<MusicGroupPaymentCalenderDetail> unusedPaymentCalenderDetail = musicGroupPaymentCalenderDetailDao.getCalenderDetailWithCalender(musicGroupUnusedFirstPaymentCalender.getId());
+		if(CollectionUtils.isEmpty(unusedPaymentCalenderDetail)){
 			throw new BizException("当前乐团无学员缴费信息");
 		}
-		Map<Integer, List<MusicGroupPaymentCalenderDetail>> studentPaymentCalenderMap = unusedPaymentCalender.stream().collect(Collectors.groupingBy(MusicGroupPaymentCalenderDetail::getUserId));
+		Map<Integer, List<MusicGroupPaymentCalenderDetail>> studentPaymentCalenderMap = unusedPaymentCalenderDetail.stream().collect(Collectors.groupingBy(MusicGroupPaymentCalenderDetail::getUserId));
 
 		List<MusicGroupPaymentCalenderCourseSettings> calenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalender(musicGroupUnusedFirstPaymentCalender.getId());
 		if(CollectionUtils.isEmpty(calenderCourseSettings)){
 			throw new BizException("课程收费标准设置异常");
 		}
 
-		Set<Long> paymentOrderIds = unusedPaymentCalender.stream().map(MusicGroupPaymentCalenderDetail::getPaymentOrderId).collect(Collectors.toSet());
-		if(CollectionUtils.isEmpty(paymentOrderIds)){
-
+		Set<Long> paymentOrderIds = unusedPaymentCalenderDetail.stream().map(MusicGroupPaymentCalenderDetail::getPaymentOrderId).collect(Collectors.toSet());
+		List<StudentPaymentOrderDetail> allStudentPaymentOrderDetails = new ArrayList<>();
+		if(!CollectionUtils.isEmpty(paymentOrderIds)){
+			allStudentPaymentOrderDetails = studentPaymentOrderDetailDao.getWithIds(new ArrayList<>(paymentOrderIds));
 		}
+		Map<Long, List<StudentPaymentOrderDetail>> orderIdOrderDetailMap = allStudentPaymentOrderDetails.stream().collect(Collectors.groupingBy(StudentPaymentOrderDetail::getPaymentOrderId));
 
 		Map<CourseSchedule.CourseScheduleType, MusicGroupPaymentCalenderCourseSettings> courseTypeCourseSettingMap = calenderCourseSettings.stream().collect(Collectors.toMap(MusicGroupPaymentCalenderCourseSettings::getCourseType, cs -> cs, (c1, c2) -> c1));
 
-		Map<CourseSchedule.CourseScheduleType, List<CourseSchedule>> courseTypeCourseMap = courseSchedules.stream().collect(Collectors.groupingBy(CourseSchedule::getType));
-		for (Map.Entry<CourseSchedule.CourseScheduleType, List<CourseSchedule>> courseScheduleTypeListEntry : courseTypeCourseMap.entrySet()) {
-			CourseSchedule.CourseScheduleType courseType = courseScheduleTypeListEntry.getKey();
-			MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings = courseTypeCourseSettingMap.get(courseType);
+		List<CourseScheduleStudentPayment> baseCourseScheduleStudentPayments = new ArrayList<>();
+
+		Map<CourseSchedule.CourseScheduleType, List<CourseSchedule>> typeCourseMap = courseSchedules.stream().collect(Collectors.groupingBy(CourseSchedule::getType));
+		for (Map.Entry<CourseSchedule.CourseScheduleType, List<CourseSchedule>> typeCoursesEntry : typeCourseMap.entrySet()) {
+			MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings = courseTypeCourseSettingMap.get(typeCoursesEntry.getKey());
 			if(musicGroupPaymentCalenderCourseSettings.isIsStudentOptional()){
-				//如果学生可选,则必须缴费才能排课
+				//如果可选,则必须缴费才能排课
+				long paymentStudentNum = allStudentPaymentOrderDetails.stream().filter(spd -> musicGroupPaymentCalenderCourseSettings.getCourseType().getCode().equals(spd.getType().getCode())).count();
+				if(paymentStudentNum<studentIds.size()){
+					throw new BizException("部分学员未完成自选课程缴费");
+				}
 			}
-
+			List<CourseScheduleStudentPayment> typeCourseStudentPayments = new ArrayList<>();
+			BigDecimal typeCourseTotalOriginalPrice = new BigDecimal("0"), typeCourseTotalCurrentPrice = new BigDecimal("0");
+			typeCoursesEntry.getValue().sort(Comparator.comparing(CourseSchedule::getStartClassTime));
+			for (CourseSchedule courseSchedule : typeCoursesEntry.getValue()) {
+				//课程每分钟原价
+				BigDecimal unitMinuteOriginalPrice = musicGroupPaymentCalenderCourseSettings.getCourseOriginalPrice().divide(new BigDecimal(musicGroupPaymentCalenderCourseSettings.getCourseTotalMinuties()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
+				//课程每分钟现价
+				BigDecimal unitMinuteCurrentPrice = musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice().divide(new BigDecimal(musicGroupPaymentCalenderCourseSettings.getCourseTotalMinuties()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
+
+				//课程时长
+				int courseDuration = DateUtil.minutesBetween(courseSchedule.getStartClassTime(), courseSchedule.getEndClassTime());
+
+				//课程原价
+				BigDecimal courseOriginalPrice = unitMinuteOriginalPrice.multiply(new BigDecimal(courseDuration)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
+				typeCourseTotalOriginalPrice = typeCourseTotalOriginalPrice.add(courseOriginalPrice);
+
+				//课程现价
+				BigDecimal courseCurrentPrice = unitMinuteCurrentPrice.multiply(new BigDecimal(courseDuration)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
+				typeCourseTotalCurrentPrice = typeCourseTotalCurrentPrice.add(courseCurrentPrice);
+
+				CourseScheduleStudentPayment cssp = new CourseScheduleStudentPayment();
+				cssp.setGroupType(courseSchedule.getGroupType());
+				cssp.setMusicGroupId(courseSchedule.getMusicGroupId());
+				cssp.setCourseScheduleId(courseSchedule.getId());
+				cssp.setClassGroupId(courseSchedule.getClassGroupId());
+				cssp.setBatchNo(musicGroupUnusedFirstPaymentCalender.getBatchNo());
+				cssp.setOriginalPrice(courseOriginalPrice);
+				cssp.setExpectPrice(courseCurrentPrice);
+				cssp.setActualPrice(BigDecimal.ZERO);
+				typeCourseStudentPayments.add(cssp);
+			}
+			typeCourseStudentPayments.get(0).setOriginalPrice(typeCourseStudentPayments.get(0).getOriginalPrice().add(musicGroupPaymentCalenderCourseSettings.getCourseOriginalPrice().subtract(typeCourseTotalOriginalPrice)));
+			typeCourseStudentPayments.get(0).setExpectPrice(typeCourseStudentPayments.get(0).getExpectPrice().add(musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice().subtract(typeCourseTotalCurrentPrice)));
+			baseCourseScheduleStudentPayments.addAll(typeCourseStudentPayments);
 		}
 
+		List<MusicGroupPaymentCalenderDetail> needUpdateCalenderDetails = new ArrayList<>();
+		List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
+
 		for (Integer studentId : studentIds) {
 			List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetails = studentPaymentCalenderMap.get(studentId);
 			if(CollectionUtils.isEmpty(musicGroupPaymentCalenderDetails)){
@@ -337,9 +365,45 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 			if(!musicGroupPaymentCalenderDetail.getMusicGroupPaymentCalenderId().equals(musicGroupUnusedFirstPaymentCalender.getId())){
 				throw new BizException("缴费信息异常");
 			}
-			for (CourseSchedule courseSchedule : courseSchedules) {
+			musicGroupPaymentCalenderDetail.setUseInCourse(1);
+			needUpdateCalenderDetails.add(musicGroupPaymentCalenderDetail);
+
+			for (CourseScheduleStudentPayment baseCourseScheduleStudentPayment : baseCourseScheduleStudentPayments) {
+				CourseScheduleStudentPayment cssp = new CourseScheduleStudentPayment();
+				BeanUtils.copyProperties(baseCourseScheduleStudentPayment, cssp);
+				cssp.setUserId(studentId);
+				courseScheduleStudentPayments.add(cssp);
+			}
+		}
+		courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
+		musicGroupPaymentCalenderDetailDao.batchUpdate(needUpdateCalenderDetails);
+	}
 
+	@Override
+	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
+	public void updateForMusicGroupWithPaymentCalender(String batchNo) {
+		List<CourseScheduleStudentPayment> courseScheduleStudentPayments = courseScheduleStudentPaymentDao.findByBatchNo(batchNo);
+		if(CollectionUtils.isEmpty(courseScheduleStudentPayments)){
+			return;
+		}
+		List<MusicGroupPaymentCalender> musicGroupPaymentCalenders = musicGroupPaymentCalenderDao.findByBatchNo(batchNo);
+		if(CollectionUtils.isEmpty(musicGroupPaymentCalenders)){
+			return;
+		}
+		List<Long> calenderIds = musicGroupPaymentCalenders.stream().map(MusicGroupPaymentCalender::getId).collect(Collectors.toList());
+		List<MusicGroupPaymentCalenderDetail> calenderDetails = musicGroupPaymentCalenderDetailDao.getWithCalenderIds(calenderIds);
+		//学员总缴费金额
+		BigDecimal totalActualAmount = calenderDetails.stream().map(MusicGroupPaymentCalenderDetail::getActualAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+		for (CourseScheduleStudentPayment courseScheduleStudentPayment : courseScheduleStudentPayments) {
+			if(totalActualAmount.compareTo(courseScheduleStudentPayment.getExpectPrice())>=0){
+				courseScheduleStudentPayment.setActualPrice(courseScheduleStudentPayment.getExpectPrice());
+				totalActualAmount=totalActualAmount.subtract(courseScheduleStudentPayment.getExpectPrice());
+			}else{
+				courseScheduleStudentPayment.setActualPrice(totalActualAmount);
+				totalActualAmount=BigDecimal.ZERO;
 			}
 		}
+		courseScheduleStudentPaymentDao.batchUpdate(courseScheduleStudentPayments);
 	}
 }

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

@@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.multipart.MultipartFile;
@@ -455,13 +456,13 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		Map<Integer, Goods> idTempGoodsMap = tempGoodsList.stream().collect(Collectors.toMap(Goods::getId, g -> g));
 		List<GoodsProcurement> goodsProcurements = new ArrayList<>();
 		for (Integer goodsId : goodsIds) {
-			Goods tempGoods = goodsDao.get(goodsId);
+			Goods tempGoods = idTempGoodsMap.get(goodsId);
 			List<Goods> childGoods = new ArrayList<>();
 			if(StringUtils.isBlank(tempGoods.getComplementGoodsIdList())){
 				childGoods.add(tempGoods);
 			}else{
 				List<Integer> complementGoodsIds = Arrays.stream(tempGoods.getComplementGoodsIdList().split(",")).map(s -> Integer.valueOf(s)).collect(Collectors.toList());
-				childGoods = goodsDao.getGoodies(complementGoodsIds);
+				childGoods = goodsDao.lockGoods(complementGoodsIds);
 			}
 			for (Goods goods : childGoods) {
 				GoodsProcurement goodsProcurement = null;
@@ -532,7 +533,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		List<GoodsProcurement> groupGoodsList = goodsProcurements.stream().filter(g -> Objects.nonNull(g.getParentGoodsId())||Objects.isNull(g.getBatchNo())).collect(Collectors.toList());
 		if(!CollectionUtils.isEmpty(groupGoodsList)){
 			for (GoodsProcurement goodsProcurement : groupGoodsList) {
-				Goods goods = goodsDao.get(goodsProcurement.getGoodsId());
+				Goods goods = idTempGoodsMap.get(goodsProcurement.getGoodsId());
 				SellOrder sellOrder = new SellOrder();
 				sellOrder.setParentGoodsId(goodsProcurement.getParentGoodsId());
 				sellOrder.setGoodsId(goodsProcurement.getGoodsId());
@@ -581,7 +582,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		goodsDao.lockGoods(new ArrayList<>(goodsIdList));
 
 		for (SellOrder sellOrder : sellOrders) {
-			Goods goods = goodsDao.get(sellOrder.getGoodsId());
+			Goods goods = goodsDao.lock(sellOrder.getGoodsId());
 			GoodsProcurement goodsProcurement = goodsProcurementDao.getWithGoodsAndBatchNo(sellOrder.getGoodsId(), sellOrder.getBatchNo());
 			if(StockType.INTERNAL.equals(sellOrder.getStockType())){
 				goods.setStockCount(new AtomicInteger(goods.getStockCount()).addAndGet(sellOrder.getNum()));

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

@@ -25,8 +25,6 @@ import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
 import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.CalenderPushDto;
-import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderDto;
-import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderDto.PaymentDateRange;
 import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
 import com.ym.mec.biz.dal.entity.MusicGroup;
 import com.ym.mec.biz.dal.entity.MusicGroupOrganizationCourseSettingsDetail;
@@ -79,9 +77,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public boolean create(MusicGroupPaymentCalenderDto musicGroupPaymentCalenderDto) {
+	public boolean create(MusicGroupPaymentCalender musicGroupPaymentCalender) {
 		
-		String musicGroupId = musicGroupPaymentCalenderDto.getMusicGroupId();
+		String musicGroupId = musicGroupPaymentCalender.getMusicGroupId();
 
 		MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
 		
@@ -91,95 +89,104 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 		Date date = new Date();
 		Map<Integer, String> pushUserMap = new HashMap<Integer, String>();
-		MusicGroupPaymentCalender musicGroupPaymentCalender = null;
 		MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
-		List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList = new ArrayList<MusicGroupPaymentCalender>();
 		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
 		
-		for(PaymentDateRange paymentDateRange : musicGroupPaymentCalenderDto.getPaymentDateRangeList()){
-			musicGroupPaymentCalender = musicGroupPaymentCalenderDto;
-			musicGroupPaymentCalender.setCreateTime(date);
-			musicGroupPaymentCalender.setUpdateTime(date);
-			musicGroupPaymentCalender.setPaymentValidStartDate(paymentDateRange.getStartDate());
-			musicGroupPaymentCalender.setPaymentValidEndDate(paymentDateRange.getEndDate());
-			
-			if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null) {
-				musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
-			}
-			int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPaymentValidStartDate(),
-					musicGroupPaymentCalender.getPaymentValidEndDate(), null);
-			if (count > 0) {
-				throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
+
+		musicGroupPaymentCalender.setCreateTime(date);
+		musicGroupPaymentCalender.setUpdateTime(date);
+		
+		if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null) {
+			musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
+		}
+		int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPaymentValidStartDate(),
+				musicGroupPaymentCalender.getPaymentValidEndDate(), null);
+		if (count > 0) {
+			throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
+		}
+		
+		//获取设置的课程
+		List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalender.getMusicGroupPaymentCalenderCourseSettingsList();
+		if(musicGroupPaymentCalenderCourseSettingsList == null){
+			musicGroupPaymentCalenderCourseSettingsList = new ArrayList<MusicGroupPaymentCalenderCourseSettings>();
+		}
+		
+		//查询默认课程费用
+		Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalender.getMusicGroupOrganizationCourseSettingId();
+		Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId).stream().collect(Collectors.toMap(MusicGroupOrganizationCourseSettingsDetail :: getCourseType, MusicGroupOrganizationCourseSettingsDetail :: getCourseCurrentPrice));
+		
+		//当前缴费的课程费用
+		Map<CourseScheduleType,BigDecimal> currentCoursePrice = musicGroupPaymentCalenderCourseSettingsList.stream().collect(Collectors.toMap(MusicGroupPaymentCalenderCourseSettings :: getCourseType, MusicGroupPaymentCalenderCourseSettings :: getCourseCurrentPrice));
+		
+		BigDecimal totalPrice = new BigDecimal(0);
+		//相同类型的课程如果修改了课程费用,需要走审批
+		for(Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()){
+			if(defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0){
+				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
 			}
-			
-			//查询默认课程费用
-			Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalender.getMusicGroupOrganizationCourseSettingId();
-			Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId).stream().collect(Collectors.toMap(MusicGroupOrganizationCourseSettingsDetail :: getCourseType, MusicGroupOrganizationCourseSettingsDetail :: getCourseCurrentPrice));
-			
-			//当前缴费的课程费用
-			Map<CourseScheduleType,BigDecimal> currentCoursePrice = musicGroupPaymentCalenderDto.getMusicGroupPaymentCalenderCourseSettingsList().stream().collect(Collectors.toMap(MusicGroupPaymentCalenderCourseSettings :: getCourseType, MusicGroupPaymentCalenderCourseSettings :: getCourseCurrentPrice));
-			
-			BigDecimal totalPrice = new BigDecimal(0);
-			//相同类型的课程如果修改了课程费用,需要走审批
-			for(Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()){
-				if(defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0){
-					musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
-				}
-				totalPrice.add(entry.getValue());
+			totalPrice.add(entry.getValue());
+		}
+		
+		if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
+			if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
+				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
+			} else if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
+				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
+			} else {
+				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
 			}
 			
-			if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
-				if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
-					musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
-				} else if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
-					musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
-				} else {
-					musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
-				}
-				
-				//如果是报名,需要修改乐团状态
-				if (musicGroupPaymentCalender.getPaymentType() == 1) {
-					musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
-					musicGroup.setUpdateTime(date);
-					musicGroupDao.update(musicGroup);
-				}
+			//如果是报名,需要修改乐团状态
+			if (musicGroupPaymentCalender.getPaymentType() == 1) {
+				musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
+				musicGroup.setUpdateTime(date);
+				musicGroupDao.update(musicGroup);
 			}
+		}
 
-			musicGroupPaymentCalender.setExpectNum(0);
-			if(StringUtils.isNoneBlank(musicGroupPaymentCalenderDto.getStudentIds())){
-				String[] sutdentIdList = musicGroupPaymentCalenderDto.getStudentIds().split(",");
-				musicGroupPaymentCalender.setExpectNum(sutdentIdList.length);
-				
-				if (musicGroupPaymentCalender.getStatus() == PaymentCalenderStatusEnum.OPEN) {
-					for(String studentId : sutdentIdList){
-						pushUserMap.put(Integer.parseInt(studentId), studentId);
-					}
-				}
-				
-				//创建缴费明细
+		musicGroupPaymentCalender.setExpectNum(0);
+		if(StringUtils.isNoneBlank(musicGroupPaymentCalender.getStudentIds())){
+			String[] sutdentIdList = musicGroupPaymentCalender.getStudentIds().split(",");
+			musicGroupPaymentCalender.setExpectNum(sutdentIdList.length);
+			
+			if (musicGroupPaymentCalender.getStatus() == PaymentCalenderStatusEnum.OPEN) {
 				for(String studentId : sutdentIdList){
-					musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
-					musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
-					musicGroupPaymentCalenderDetail.setCreateTime(date);
-					musicGroupPaymentCalenderDetail.setExpectAmount(totalPrice);
-					musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
-					musicGroupPaymentCalenderDetail.setUpdateTime(date);
-					musicGroupPaymentCalenderDetail.setUserId(Integer.parseInt(studentId));
-					
-					musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
+					pushUserMap.put(Integer.parseInt(studentId), studentId);
 				}
 			}
 			
-			musicGroupPaymentCalenderList.add(musicGroupPaymentCalender);
+			//创建缴费明细
+			for(String studentId : sutdentIdList){
+				musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
+				musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
+				musicGroupPaymentCalenderDetail.setCreateTime(date);
+				musicGroupPaymentCalenderDetail.setExpectAmount(totalPrice);
+				musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
+				musicGroupPaymentCalenderDetail.setUpdateTime(date);
+				musicGroupPaymentCalenderDetail.setUserId(Integer.parseInt(studentId));
+				musicGroupPaymentCalenderDetail.setStartPaymentDate(musicGroupPaymentCalender.getStartPaymentDate());
+				musicGroupPaymentCalenderDetail.setDeadlinePaymentDate(musicGroupPaymentCalender.getDeadlinePaymentDate());
+				
+				musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
+			}
+		}
+		
+		musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
+		
+		for(MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings : musicGroupPaymentCalenderCourseSettingsList){
+			musicGroupPaymentCalenderCourseSettings.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
+			musicGroupPaymentCalenderCourseSettings.setCreateTime(date);
+			musicGroupPaymentCalenderCourseSettings.setUpdateTime(date);
+		}
+		
+		if(musicGroupPaymentCalenderCourseSettingsList.size() > 0){
+			musicGroupPaymentCalenderCourseSettingsDao.batchInsert(musicGroupPaymentCalenderCourseSettingsList);
 		}
 
 		if (musicGroupPaymentCalenderDetailList.size() > 0) {
 			musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
 		}
 		
-		if(musicGroupPaymentCalenderList.size() > 0){
-			musicGroupPaymentCalenderDao.batchInsert(musicGroupPaymentCalenderList);
-		}
 		
 		// 发送续费通知
 		if (pushUserMap.size() > 0) {
@@ -196,6 +203,16 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public int update(MusicGroupPaymentCalender musicGroupPaymentCalender) {
+		
+		MusicGroupPaymentCalender orginMusicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(musicGroupPaymentCalender.getId());
+		if(orginMusicGroupPaymentCalender == null){
+			throw new BizException("查询不到缴费记录");
+		}
+		//只有“拒绝”才能修改
+		if(orginMusicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.REJECT){
+			throw new BizException("缴费记录只有被“审核拒绝”才能修改");
+		}
+		
 		String musicGroupId = musicGroupPaymentCalender.getMusicGroupId();
 
 		MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
@@ -216,13 +233,18 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
 		}
 		
+		//获取设置的课程
+		List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalender.getMusicGroupPaymentCalenderCourseSettingsList();
+		if(musicGroupPaymentCalenderCourseSettingsList == null){
+			musicGroupPaymentCalenderCourseSettingsList = new ArrayList<MusicGroupPaymentCalenderCourseSettings>();
+		}
+		
 		//查询默认课程费用
 		Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalender.getMusicGroupOrganizationCourseSettingId();
 		Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId).stream().collect(Collectors.toMap(MusicGroupOrganizationCourseSettingsDetail :: getCourseType, MusicGroupOrganizationCourseSettingsDetail :: getCourseCurrentPrice));
 		
 		//当前缴费的课程费用
-		Map<CourseScheduleType,BigDecimal> currentCoursePrice = null;
-				//musicGroupPaymentCalender.getMusicGroupPaymentCalenderCourseSettingsList().stream().collect(Collectors.toMap(MusicGroupPaymentCalenderCourseSettings :: getCourseType, MusicGroupPaymentCalenderCourseSettings :: getCourseCurrentPrice));
+		Map<CourseScheduleType,BigDecimal> currentCoursePrice = musicGroupPaymentCalenderCourseSettingsList.stream().collect(Collectors.toMap(MusicGroupPaymentCalenderCourseSettings :: getCourseType, MusicGroupPaymentCalenderCourseSettings :: getCourseCurrentPrice));
 		
 		BigDecimal totalPrice = new BigDecimal(0);
 		//相同类型的课程如果修改了课程费用,需要走审批
@@ -253,7 +275,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		Map<Integer, String> pushUserMap = new HashMap<Integer, String>();
 
 		musicGroupPaymentCalender.setExpectNum(0);
-		/*if(StringUtils.isNoneBlank(musicGroupPaymentCalender.getStudentIds())){
+		if(StringUtils.isNoneBlank(musicGroupPaymentCalender.getStudentIds())){
 			String[] sutdentIdList = musicGroupPaymentCalender.getStudentIds().split(",");
 			musicGroupPaymentCalender.setExpectNum(sutdentIdList.length);
 			
@@ -276,10 +298,12 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
 				musicGroupPaymentCalenderDetail.setUpdateTime(date);
 				musicGroupPaymentCalenderDetail.setUserId(Integer.parseInt(studentId));
+				musicGroupPaymentCalenderDetail.setStartPaymentDate(musicGroupPaymentCalender.getStartPaymentDate());
+				musicGroupPaymentCalenderDetail.setDeadlinePaymentDate(musicGroupPaymentCalender.getDeadlinePaymentDate());
 				
 				musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
 			}
-		}*/
+		}
 		
 		musicGroupPaymentCalenderDao.update(musicGroupPaymentCalender);
 
@@ -287,6 +311,12 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
 		}
 		
+		musicGroupPaymentCalenderCourseSettingsDao.deleteByMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
+		
+		if(musicGroupPaymentCalenderCourseSettingsList.size() > 0){
+			musicGroupPaymentCalenderCourseSettingsDao.batchInsert(musicGroupPaymentCalenderCourseSettingsList);
+		}
+		
 		// 发送续费通知
 		if (pushUserMap.size() > 0) {
 			String configValue = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);

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

@@ -26,6 +26,7 @@ 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.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 

+ 10 - 2
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -1324,6 +1324,8 @@
         <result property="totalClassTimes" column="total_class_times_"/>
         <result property="studentNames" column="student_names_"/>
         <result column="teach_mode_" property="teachMode" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+        <result column="school_id_" property="schoolId"/>
+        <result column="school_name_" property="schoolName"/>
     </resultMap>
 
     <sql id="teacherClassCourseScheduleQueryCondition">
@@ -1354,12 +1356,15 @@
         cs.actual_teacher_id_,
         cs.teach_mode_,
         su.real_name_ username_,
-        cg.total_class_times_
+        cg.total_class_times_,
+        cs.schoole_id_ school_id_,
+        s.name_ school_name_
         FROM
         course_schedule_teacher_salary csts
         LEFT JOIN course_schedule cs ON cs.id_ = csts.course_schedule_id_
         LEFT JOIN class_group cg ON cs.class_group_id_=cg.id_
         LEFT JOIN sys_user su ON cs.actual_teacher_id_ = su.id_
+        LEFT JOIN school s ON cs.schoole_id_=s.id_
         <include refid="teacherClassCourseScheduleQueryCondition"/>
         ORDER BY start_class_time_
         <include refid="global.limit"/>
@@ -1417,13 +1422,16 @@
         su.username_,
         cg.total_class_times_,
         GROUP_CONCAT(IF(sa.status_='NORMAL',ssu.username_,NULL)) student_names_,
-        MAX(sa.current_class_times_) current_class_times_
+        MAX(sa.current_class_times_) current_class_times_,
+        cs.schoole_id_ school_id_,
+        s.name_ school_name_
         FROM
         student_attendance sa
         LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
         LEFT JOIN class_group cg ON cs.class_group_id_=cg.id_
         LEFT JOIN sys_user su ON cs.actual_teacher_id_ = su.id_
         LEFT JOIN sys_user ssu ON sa.user_id_=ssu.id_
+        LEFT JOIN school s ON cs.schoole_id_ = s.id_
         WHERE
         (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
         AND sa.class_group_id_=#{classGroupId}

+ 35 - 17
mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml

@@ -12,12 +12,14 @@
         <result column="music_group_id_" property="musicGroupId"/>
 		<result column="course_schedule_id_" property="courseScheduleId" />
 		<result column="user_id_" property="userId" />
+		<result column="original_price_" property="originalPrice"/>
 		<result column="expect_price_" property="expectPrice" />
 		<result column="actual_price_" property="actualPrice" />
 		<result column="create_time_" property="createTime" />
 		<result column="update_time_" property="updateTime" />
 		<result column="settlement_time_" property="settlementTime" />
 		<result column="class_group_id_" property="classGroupId" />
+		<result column="batch_no_" property="batchNo"/>
 	</resultMap>
 	
 	<resultMap type="com.ym.mec.biz.dal.dto.StudentCourseTimesDto" id="studentCourseTimesDto">
@@ -45,13 +47,18 @@
 		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
 		</selectKey>
 		-->
-		INSERT INTO course_schedule_student_payment (id_,group_type_,music_group_id_,course_schedule_id_,user_id_,expect_price_,actual_price_,create_time_,update_time_,settlement_time_,class_group_id_) VALUES(#{id},#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{musicGroupId},#{courseScheduleId},#{userId},#{expectPrice},#{actualPrice},#{createTime},NOW(),#{settlementTime},#{classGroupId})
+		INSERT INTO course_schedule_student_payment (id_,group_type_,music_group_id_,course_schedule_id_,user_id_,
+			original_price_,expect_price_,actual_price_,create_time_,update_time_,settlement_time_,class_group_id_,batch_no_)
+		VALUES(#{id},#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{musicGroupId},#{courseScheduleId},#{userId},
+			#{originalPrice},#{expectPrice},#{actualPrice},#{createTime},NOW(),#{settlementTime},#{classGroupId},#{batchNo})
 	</insert>
     <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id_">
-		INSERT INTO course_schedule_student_payment (id_,group_type_,music_group_id_,course_schedule_id_,user_id_,expect_price_,actual_price_,create_time_,update_time_,settlement_time_,class_group_id_)
+		INSERT INTO course_schedule_student_payment (id_,group_type_,music_group_id_,course_schedule_id_,user_id_,expect_price_,
+				original_price_,actual_price_,create_time_,update_time_,settlement_time_,class_group_id_)
 		VALUE
 		<foreach collection="list" item="data" separator=",">
-			(#{data.id},#{data.groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{data.musicGroupId},#{data.courseScheduleId},#{data.userId},#{data.expectPrice},#{data.actualPrice},now(),now(),#{data.settlementTime},#{data.classGroupId})
+			(#{data.id},#{data.groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{data.musicGroupId},#{data.courseScheduleId},#{data.userId},#{data.expectPrice},
+			#{data.originalPrice},#{data.actualPrice},now(),now(),#{data.settlementTime},#{data.classGroupId},#{data.batchNo})
 		</foreach>
     </insert>
 
@@ -60,13 +67,10 @@
 		UPDATE course_schedule_student_payment 
 		<set>
 			<if test="userId != null">
-			user_id_ = #{userId},
-			</if>
-			<if test="id != null">
-			id_ = #{id},
+				user_id_ = #{userId},
 			</if>
 			<if test="courseScheduleId != null">
-			course_schedule_id_ = #{courseScheduleId},
+				course_schedule_id_ = #{courseScheduleId},
 			</if>
             <if test="groupType != null">
                 group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
@@ -74,24 +78,28 @@
             <if test="musicGroupId != null">
                 music_group_id_ = #{musicGroupId},
             </if>
-			<if test="updateTime != null">
-			update_time_ = NOW(),
-			</if>
 			<if test="settlementTime != null">
-			settlement_time_ = #{settlementTime},
+				settlement_time_ = #{settlementTime},
 			</if>
 			<if test="expectPrice != null">
-			expect_price_ = #{expectPrice},
+				expect_price_ = #{expectPrice},
 			</if>
 			<if test="actualPrice != null">
-			actual_price_ = #{actualPrice},
+				actual_price_ = #{actualPrice},
 			</if>
 			<if test="createTime != null">
-			create_time_ = #{createTime},
+				create_time_ = #{createTime},
 			</if>
 			<if test="classGroupId != null">
-			class_group_id_ = #{classGroupId},
+				class_group_id_ = #{classGroupId},
+			</if>
+			<if test="batchNo != null">
+				batch_no_ = #{batchNo},
+			</if>
+			<if test="originalPrice != null">
+				original_price_ = #{originalPrice},
 			</if>
+				update_time_ = NOW()
 		</set> WHERE id_ = #{id} 
 	</update>
 
@@ -111,7 +119,6 @@
 				<if test="courseScheduleStudentPayment.musicGroupId != null">
 					music_group_id_ = #{courseScheduleStudentPayment.musicGroupId},
 				</if>
-				update_time_ = NOW(),
 				<if test="courseScheduleStudentPayment.settlementTime != null">
 					settlement_time_ = #{courseScheduleStudentPayment.settlementTime},
 				</if>
@@ -127,6 +134,13 @@
 				<if test="courseScheduleStudentPayment.classGroupId != null">
 					class_group_id_ = #{courseScheduleStudentPayment.classGroupId},
 				</if>
+				<if test="courseScheduleStudentPayment.batchNo != null">
+					batch_no_ = #{courseScheduleStudentPayment.batchNo},
+				</if>
+				<if test="courseScheduleStudentPayment.originalPrice != null">
+					original_price_ = #{courseScheduleStudentPayment.originalPrice},
+				</if>
+				update_time_ = NOW()
 			</set> WHERE id_ = #{courseScheduleStudentPayment.id}
 		</foreach>
 	</update>
@@ -507,4 +521,8 @@
 			AND cssp.music_group_id_ = #{groupId}
 			AND CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) > NOW( )
 	</select>
+
+    <select id="findByBatchNo" resultMap="CourseScheduleStudentPayment">
+		SELECT * FROM course_schedule_student_payment WHERE batch_no_=#{batchNo}
+	</select>
 </mapper>

+ 8 - 3
mec-biz/src/main/resources/config/mybatis/GoodsMapper.xml

@@ -40,8 +40,12 @@
     </resultMap>
 
     <!-- 根据主键查询一条记录 -->
-    <select id="get" resultMap="Goods">
-		SELECT * FROM goods WHERE id_ = #{id} 
+    <select id="get" resultMap="Goods" useCache="false" flushCache="true">
+		SELECT * FROM goods WHERE id_ = #{id}
+	</select>
+
+    <select id="lock" resultMap="Goods" useCache="false" flushCache="true">
+		SELECT * FROM goods WHERE id_ = #{goodsId} LOCK IN SHARE MODE
 	</select>
 
     <!-- 全查询 -->
@@ -321,11 +325,12 @@
         </foreach>
     </select>
 
-    <select id="lockGoods" resultMap="Goods">
+    <select id="lockGoods" resultMap="Goods" useCache="false" flushCache="true">
         SELECT * FROM goods WHERE id_ IN
         <foreach collection="goodsIds" item="goodsId" open="(" close=")" separator=",">
             #{goodsId}
         </foreach>
+        FOR UPDATE
     </select>
 
     <select id="findBySn" resultMap="Goods">

+ 12 - 2
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderCourseSettingsMapper.xml

@@ -36,8 +36,18 @@
 		<!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval
 			AS ID FROM DUAL </selectKey> -->
 		INSERT INTO music_group_payment_calender_course_settings
-		(id_,music_group_payment_calender_id_,course_type_,course_total_minuties_,unit_price_,course_original_price_,course_current_price_,is_student_optional_,create_time_,update_time_)
-		VALUES(#{id},#{musicGroupPaymentCalenderId},#{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{courseTotalMinuties},#{unitPrice},#{courseOriginalPrice},#{courseCurrentPrice},#{isStudentOptional},#{createTime},#{updateTime})
+		(music_group_payment_calender_id_,course_type_,course_total_minuties_,unit_price_,course_original_price_,course_current_price_,is_student_optional_,create_time_,update_time_)
+		VALUES(#{musicGroupPaymentCalenderId},#{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{courseTotalMinuties},#{unitPrice},#{courseOriginalPrice},#{courseCurrentPrice},#{isStudentOptional},#{createTime},#{updateTime})
+	</insert>
+	
+	<insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id"
+            keyProperty="id">
+		INSERT INTO music_group_payment_calender_course_settings
+		(music_group_payment_calender_id_,course_type_,course_total_minuties_,unit_price_,course_original_price_,course_current_price_,is_student_optional_,create_time_,update_time_)
+		VALUES
+		<foreach collection="list" item="item" separator=",">
+		(#{item.musicGroupPaymentCalenderId},#{item.courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.courseTotalMinuties},#{item.unitPrice},#{item.courseOriginalPrice},#{item.courseCurrentPrice},#{item.isStudentOptional},#{item.createTime},#{item.updateTime})
+		</foreach>
 	</insert>
 
 	<!-- 根据主键查询一条记录 -->

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

@@ -23,6 +23,7 @@
 		<result column="create_time_" property="createTime" />
 		<result column="open_" property="open"/>
 		<result column="open_" property="openFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+		<result column="use_in_course_" property="useInCourse"/>
 		<association property="sysUser" javaType="com.ym.mec.auth.api.entity.SysUser">
 			<result column="username_" property="username" />
 			<result column="phone_" property="phone" />
@@ -49,20 +50,21 @@
 		useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 		INSERT INTO music_group_payment_calender_detail
 		(id_,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_)
+		user_status_,pay_time_,update_time_,create_time_,start_payment_date_,deadline_payment_date_,payment_order_id_,use_in_course_)
 		VALUES(#{id},#{musicGroupPaymentCalenderId},#{userId},#{expectAmount},#{actualAmount},#{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-		#{userStatus},#{payTime},#{updateTime},#{createTime},#{startPaymentDate},#{deadlinePaymentDate},#{paymentOrderId})
+		#{userStatus},#{payTime},#{updateTime},#{createTime},#{startPaymentDate},#{deadlinePaymentDate},#{paymentOrderId},#{useInCourse})
 	</insert>
 
-    <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail">
+    <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id"
+            keyProperty="id">
         INSERT INTO music_group_payment_calender_detail
 		(id_,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_)
+		payment_status_,user_status_,pay_time_,update_time_,create_time_,start_payment_date_,deadline_payment_date_,payment_order_id_,use_in_course_)
 		VALUES
 		<foreach collection="list" item="item" separator=",">
             (#{item.id},#{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.updateTime},#{item.createTime},#{item.startPaymentDate},#{item.deadlinePaymentDate},#{item.paymentOrderId},#{item.useInCourse})
         </foreach>
     </insert>
 
@@ -107,6 +109,9 @@
 			<if test="paymentOrderId != null">
 				payment_order_id_ = #{paymentOrderId},
 			</if>
+			<if test="useInCourse != null">
+				use_in_course_ = #{useInCourse},
+			</if>
 		</set>
 		WHERE id_ = #{id}
 	</update>
@@ -150,6 +155,9 @@
 				<if test="item.paymentOrderId != null">
 					payment_order_id_ = #{item.paymentOrderId},
 				</if>
+				<if test="item.useInCourse != null">
+					use_in_course_ = #{item.useInCourse},
+				</if>
 			</set>
 			WHERE id_ = #{item.id}
 		</foreach>
@@ -322,4 +330,16 @@
 			mgpc.music_group_id_ = #{musicGroupId}
 			AND NOT EXISTS ( SELECT id_ FROM course_schedule_student_payment WHERE batch_no_ = mgpcd.music_group_payment_calender_id_ AND music_group_id_ = #{musicGroupId} )
 	</select>
+
+    <select id="getWithCalenderIds" resultType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail">
+		SELECT
+			mgpcd.*
+		FROM
+			music_group_payment_calender_detail mgpcd
+		WHERE
+			mgpc.music_group_payment_calender_id_ IN
+			<foreach collection="calenderIds" item="calenderId" open="(" close=")" separator=",">
+				#{calenderId}
+			</foreach>
+	</select>
 </mapper>

+ 34 - 10
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml

@@ -25,6 +25,7 @@
         <result column="payment_valid_end_date_" property="paymentValidEndDate"/>
         <result column="payment_pattern_" property="paymentPattern"/>
         <result column="payment_type_" property="paymentType"/>
+        <result column="batch_no_" property="batchNo"/>
     </resultMap>
 
     <!-- 根据主键查询一条记录 -->
@@ -39,25 +40,25 @@
 
     <!-- 向数据库增加一条记录 -->
     <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender" useGeneratedKeys="true"
-            keyColumn="id" keyProperty="id">
+            keyColumn="id_" keyProperty="id">
         INSERT INTO music_group_payment_calender
         (music_group_id_,music_group_organization_course_settings_id_,pay_user_type_,reject_reason_,start_payment_date_,deadline_payment_date_,status_,expect_num_,
-        actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,payment_pattern_,payment_type_)
+        actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,payment_pattern_,payment_type_,batch_no_)
         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})
+        #{paymentValidStartDate},#{paymentValidEndDate},#{paymentPattern},#{paymentType},#{batchNo})
     </insert>
 
     <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender" useGeneratedKeys="true"
-            keyColumn="id" keyProperty="id">
+            keyColumn="id_" keyProperty="id">
         INSERT INTO music_group_payment_calender
         (music_group_id_,music_group_organization_course_settings_id_,pay_user_type_,reject_reason_,start_payment_date_,deadline_payment_date_,status_,expect_num_,
-        actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,payment_pattern_,payment_type_)
+        actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,payment_pattern_,payment_type_,batch_no_)
         VALUES
         <foreach collection="list" item="item" index="index" separator=",">
         (#{item.musicGroupId},#{item.musicGroupOrganizationCourseSettingId},#{item.payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.rejectReason},#{item.startPaymentDate},#{item.deadlinePaymentDate},#{item.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{item.expectNum},#{item.actualNum},#{item.memo},#{item.isGiveMusicNetwork},now(),now(),
-        #{item.paymentValidStartDate},#{item.paymentValidEndDate},#{item.paymentPattern},#{item.paymentType})
+        #{item.paymentValidStartDate},#{item.paymentValidEndDate},#{item.paymentPattern},#{item.paymentType},#{item.batchNo})
         </foreach>
     </insert>
 
@@ -111,6 +112,9 @@
             <if test="musicGroupId != null">
                 music_group_id_ = #{musicGroupId},
             </if>
+            <if test="batchNo != null">
+                batch_no_ = #{batchNo},
+            </if>
         </set>
         WHERE id_ = #{id}
     </update>
@@ -158,6 +162,9 @@
 	            <if test="item.musicGroupId != null">
 	                music_group_id_ = #{item.musicGroupId},
 	            </if>
+                <if test="item.batchNo != null">
+                    batch_no_ = #{item.batchNo},
+                </if>
 	        </set>
 	        WHERE id_ = #{item.id}
 		</foreach>
@@ -303,10 +310,23 @@
         DATEDIFF(mg.payment_valid_end_date_,#{format}) = #{configValue}
     </select>
     <select id="getMusicGroupUnusedFirstPaymentCalender" resultMap="MusicGroupPaymentCalender">
-        SELECT * FROM music_group_payment_calender mgpc
-        WHERE music_group_id_=#{musicGroupId}
-        AND NOT EXISTS ( SELECT id_ FROM course_schedule WHERE batch_no_ = mgpc.id_ AND music_group_id_ = #{musicGroupId} )
-        ORDER BY create_time_ LIMIT 1;
+        SELECT
+            mgpc.*
+        FROM
+            music_group_payment_calender_detail mgpcd
+            LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
+            LEFT JOIN music_group_payment_calender_course_settings mgpccs ON mgpc.id_ = mgpccs.music_group_payment_calender_id_
+        WHERE
+            mgpcd.music_group_payment_calender_id_ = mgpccs.music_group_payment_calender_id_
+            AND mgpc.music_group_id_ = #{musicGroupId}
+            AND mgpcd.use_in_course_ = 1
+            AND mgpcd.user_id_ IN
+            <foreach collection="studentIds" item="studentIds" open="(" close=")" separator=",">
+                #{studentId}
+            </foreach>
+        ORDER BY
+            mgpc.payment_valid_start_date_
+            LIMIT 1;
     </select>
     <select id="getUnusedFirstPaymentCalenderWithCalenders" resultMap="MusicGroupPaymentCalender">
         SELECT * FROM music_group_payment_calender mgpc
@@ -316,4 +336,8 @@
         </foreach>
         ORDER BY create_time_ LIMIT 1;
     </select>
+
+    <select id="findByBatchNo" resultMap="MusicGroupPaymentCalender">
+        SELECT * FROM music_group_payment_calender WHERE batch_no_=#{batchNo}
+    </select>
 </mapper>

+ 7 - 0
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderDetailMapper.xml

@@ -257,4 +257,11 @@
         </foreach>
         AND spod.goods_id_list_ IS NOT NULL
     </select>
+
+    <select id="getWithIds" resultMap="StudentPaymentOrderDetail">
+        SELECT * FROM student_payment_order_detail WHERE payment_order_id_ IN
+        <foreach collection="paymentOrderIds" item="paymentOrderId" open="(" close=")" separator=",">
+            #{paymentOrderId}
+        </foreach>
+    </select>
 </mapper>

+ 5 - 6
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java

@@ -12,7 +12,6 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderDto;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.page.MusicGroupPaymentCalenderQueryInfo;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
@@ -36,8 +35,8 @@ public class MusicGroupPaymentCalenderController extends BaseController {
     @ApiOperation(value = "新增乐团缴费日历")
     @PostMapping(value = "/add", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/add')")
-    public Object add(@RequestBody MusicGroupPaymentCalenderDto musicGroupPaymentCalenderDto) {
-        musicGroupPaymentCalenderService.create(musicGroupPaymentCalenderDto);
+    public Object add(@RequestBody MusicGroupPaymentCalender musicGroupPaymentCalender) {
+        musicGroupPaymentCalenderService.create(musicGroupPaymentCalender);
         return succeed();
     }
 
@@ -50,9 +49,9 @@ public class MusicGroupPaymentCalenderController extends BaseController {
     }
 
     @ApiOperation(value = "修改乐团缴费时间")
-    @PostMapping("/updateStartTime")
-    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/updateStartTime')")
-    public Object updateStartTime(MusicGroupPaymentCalender paymentCalender) {
+    @PostMapping("/update")
+    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/update')")
+    public Object update(MusicGroupPaymentCalender paymentCalender) {
         musicGroupPaymentCalenderService.update(paymentCalender);
         return succeed();
     }