Bläddra i källkod

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

yonge 4 år sedan
förälder
incheckning
cc56477109
17 ändrade filer med 272 tillägg och 79 borttagningar
  1. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/GoodsDao.java
  2. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDao.java
  3. 3 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDetailDao.java
  4. 20 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/TeacherClassCourseSchudeleDto.java
  5. 21 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CourseScheduleStudentPayment.java
  6. 13 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalender.java
  7. 11 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderDetail.java
  8. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleStudentPaymentService.java
  9. 88 34
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java
  10. 5 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java
  11. 1 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java
  12. 10 2
      mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  13. 31 17
      mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml
  14. 8 3
      mec-biz/src/main/resources/config/mybatis/GoodsMapper.xml
  15. 11 4
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml
  16. 30 10
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml
  17. 7 0
      mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderDetailMapper.xml

+ 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);
+
     /**
      * 通过科目编号查询商品(教材、辅件)列表
      *

+ 2 - 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 获取指定缴费日历中下未使用的最早的缴费记录

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

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

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

@@ -97,11 +97,15 @@ public class MusicGroupPaymentCalender {
 	private java.util.Date createTime;
 
 	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;
@@ -263,6 +267,14 @@ public class MusicGroupPaymentCalender {
 		this.musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalenderCourseSettingsList;
 	}
 
+	public String getBatchNo() {
+		return batchNo;
+	}
+
+	public void setBatchNo(String batchNo) {
+		this.batchNo = batchNo;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

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

@@ -62,6 +62,8 @@ public class MusicGroupPaymentCalenderDetail {
 	/**  */
 	private java.util.Date createTime;
 
+	private Integer useInCourse;
+
 	private SysUser sysUser = new SysUser();
 
 	public YesOrNoEnum getOpenFlag() {
@@ -209,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);
+
 }

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

@@ -10,6 +10,8 @@ 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.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -275,59 +277,78 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 
 	@Override
 	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);
+		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)));
 		}
 
+		List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
+
 		for (Integer studentId : studentIds) {
 			List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetails = studentPaymentCalenderMap.get(studentId);
 			if(CollectionUtils.isEmpty(musicGroupPaymentCalenderDetails)){
@@ -337,9 +358,42 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 			if(!musicGroupPaymentCalenderDetail.getMusicGroupPaymentCalenderId().equals(musicGroupUnusedFirstPaymentCalender.getId())){
 				throw new BizException("缴费信息异常");
 			}
-			for (CourseSchedule courseSchedule : courseSchedules) {
 
+			List<StudentPaymentOrderDetail> studentPaymentOrderDetails = orderIdOrderDetailMap.get(musicGroupPaymentCalenderDetail.getPaymentOrderId());
+			for (CourseSchedule courseSchedule : courseSchedules) {
+				MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings = courseTypeCourseSettingMap.get(courseSchedule.getType());
+
+				//课程每分钟原价
+				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);
+				//课程现价
+				BigDecimal courseCurrentPrice = unitMinuteCurrentPrice.multiply(new BigDecimal(courseDuration)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
+
+				CourseScheduleStudentPayment cssp = new CourseScheduleStudentPayment();
+				cssp.setGroupType(courseSchedule.getGroupType());
+				cssp.setMusicGroupId(courseSchedule.getMusicGroupId());
+				cssp.setCourseScheduleId(courseSchedule.getId());
+				cssp.setClassGroupId(courseSchedule.getClassGroupId());
+				cssp.setUserId(studentId);
+				cssp.setBatchNo(musicGroupUnusedFirstPaymentCalender.getBatchNo());
+				cssp.setOriginalPrice(courseOriginalPrice);
+				cssp.setExpectPrice(courseCurrentPrice);
+				cssp.setActualPrice(BigDecimal.ZERO);
+				courseScheduleStudentPayments.add(cssp);
 			}
 		}
+		courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
+	}
+
+	@Override
+	public void updateForMusicGroupWithPaymentCalender(String batchNo) {
+
 	}
 }

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

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

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

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

+ 11 - 4
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,21 +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="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>
 
@@ -108,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>
@@ -151,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>

+ 30 - 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>
 
     <!-- 根据主键查询一条记录 -->
@@ -41,23 +42,23 @@
     <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender" useGeneratedKeys="true"
             keyColumn="id_" keyProperty="id">
         INSERT INTO music_group_payment_calender
-        (id_,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_)
-        VALUES(#{id},#{musicGroupId},#{musicGroupOrganizationCourseSettingId},#{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{rejectReason},#{startPaymentDate},#{deadlinePaymentDate},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+        (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_,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">
         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

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