Explorar o código

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

zouxuan %!s(int64=4) %!d(string=hai) anos
pai
achega
85d49bf4e4

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

@@ -0,0 +1,176 @@
+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.PayUserType;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
+
+public class MusicGroupPaymentCalenderDto {
+
+	private String musicGroupId;
+
+	private Integer musicGroupOrganizationCourseSettingId;
+
+	private PayUserType payUserType;
+
+	private Integer paymentPattern;
+
+	private PaymentType paymentType;
+
+	private String memo;
+
+	private Boolean isGiveMusicNetwork;
+
+	private String attribute1;
+
+	private String attribute2;
+
+	private String studentIds;
+
+	private List<MusicGroupPaymentDateRange> musicGroupPaymentDateRangeList = new ArrayList<MusicGroupPaymentDateRange>();
+
+	private List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = new ArrayList<MusicGroupPaymentCalenderCourseSettings>();
+
+	public String getMusicGroupId() {
+		return musicGroupId;
+	}
+
+	public void setMusicGroupId(String musicGroupId) {
+		this.musicGroupId = musicGroupId;
+	}
+
+	public Integer getMusicGroupOrganizationCourseSettingId() {
+		return musicGroupOrganizationCourseSettingId;
+	}
+
+	public void setMusicGroupOrganizationCourseSettingId(Integer musicGroupOrganizationCourseSettingId) {
+		this.musicGroupOrganizationCourseSettingId = musicGroupOrganizationCourseSettingId;
+	}
+
+	public PayUserType getPayUserType() {
+		return payUserType;
+	}
+
+	public void setPayUserType(PayUserType payUserType) {
+		this.payUserType = payUserType;
+	}
+
+	public Integer getPaymentPattern() {
+		return paymentPattern;
+	}
+
+	public void setPaymentPattern(Integer paymentPattern) {
+		this.paymentPattern = paymentPattern;
+	}
+
+	public PaymentType getPaymentType() {
+		return paymentType;
+	}
+
+	public void setPaymentType(PaymentType paymentType) {
+		this.paymentType = paymentType;
+	}
+
+	public String getMemo() {
+		return memo;
+	}
+
+	public void setMemo(String memo) {
+		this.memo = memo;
+	}
+
+	public Boolean getIsGiveMusicNetwork() {
+		return isGiveMusicNetwork;
+	}
+
+	public void setIsGiveMusicNetwork(Boolean isGiveMusicNetwork) {
+		this.isGiveMusicNetwork = isGiveMusicNetwork;
+	}
+
+	public String getAttribute1() {
+		return attribute1;
+	}
+
+	public void setAttribute1(String attribute1) {
+		this.attribute1 = attribute1;
+	}
+
+	public String getAttribute2() {
+		return attribute2;
+	}
+
+	public void setAttribute2(String attribute2) {
+		this.attribute2 = attribute2;
+	}
+
+	public String getStudentIds() {
+		return studentIds;
+	}
+
+	public void setStudentIds(String studentIds) {
+		this.studentIds = studentIds;
+	}
+
+	public List<MusicGroupPaymentDateRange> getMusicGroupPaymentDateRangeList() {
+		return musicGroupPaymentDateRangeList;
+	}
+
+	public void setMusicGroupPaymentDateRangeList(List<MusicGroupPaymentDateRange> musicGroupPaymentDateRangeList) {
+		this.musicGroupPaymentDateRangeList = musicGroupPaymentDateRangeList;
+	}
+
+	public List<MusicGroupPaymentCalenderCourseSettings> getMusicGroupPaymentCalenderCourseSettingsList() {
+		return musicGroupPaymentCalenderCourseSettingsList;
+	}
+
+	public void setMusicGroupPaymentCalenderCourseSettingsList(List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList) {
+		this.musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalenderCourseSettingsList;
+	}
+
+	public class MusicGroupPaymentDateRange {
+
+		private java.util.Date startPaymentDate;
+
+		private Date deadlinePaymentDate;
+
+		private Date paymentValidStartDate;
+
+		private Date paymentValidEndDate;
+
+		public java.util.Date getStartPaymentDate() {
+			return startPaymentDate;
+		}
+
+		public void setStartPaymentDate(java.util.Date startPaymentDate) {
+			this.startPaymentDate = startPaymentDate;
+		}
+
+		public Date getDeadlinePaymentDate() {
+			return deadlinePaymentDate;
+		}
+
+		public void setDeadlinePaymentDate(Date deadlinePaymentDate) {
+			this.deadlinePaymentDate = deadlinePaymentDate;
+		}
+
+		public Date getPaymentValidStartDate() {
+			return paymentValidStartDate;
+		}
+
+		public void setPaymentValidStartDate(Date paymentValidStartDate) {
+			this.paymentValidStartDate = paymentValidStartDate;
+		}
+
+		public Date getPaymentValidEndDate() {
+			return paymentValidEndDate;
+		}
+
+		public void setPaymentValidEndDate(Date paymentValidEndDate) {
+			this.paymentValidEndDate = paymentValidEndDate;
+		}
+	}
+
+}

+ 3 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java

@@ -1,11 +1,10 @@
 package com.ym.mec.biz.service;
 
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
 import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDetailDto;
 import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDto;
+import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderDto;
 import com.ym.mec.biz.dal.entity.MusicGroup;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
@@ -13,16 +12,14 @@ import com.ym.mec.biz.dal.page.MusicGroupPaymentCalenderQueryInfo;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 
-import org.apache.ibatis.annotations.Param;
-
 public interface MusicGroupPaymentCalenderService extends BaseService<Long, MusicGroupPaymentCalender> {
 
 	/**
 	 * 创建缴费信息
-	 * @param musicGroupPaymentCalender
+	 * @param musicGroupPaymentCalenderDto
 	 * @return
 	 */
-	Long create(MusicGroupPaymentCalender musicGroupPaymentCalender);
+	String create(MusicGroupPaymentCalenderDto musicGroupPaymentCalenderDto);
 	
 	/**
 	 * 获取明细

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

@@ -5286,8 +5286,6 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
 		List<CourseSchedule> courseSchedules=new ArrayList<>();
 		courseSchedules.add(courseMergeInfo);
-		courseAdjust(courseSchedules);
-
 		List<CourseScheduleModifyLog> insertCourseScheduleModifyLogList = new ArrayList<>();
 
 		List<CourseSchedule> mergeCourses = allCourses.stream().filter(c->courseMergeInfo.getMergeCourseIds().contains(c.getId())&&!c.getId().equals(courseMergeInfo.getId())).collect(Collectors.toList());
@@ -5317,6 +5315,8 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		}
 		courseScheduleStudentPaymentDao.batchUpdate(courseScheduleStudentPayments);
 
+		courseAdjust(courseSchedules);
+
 		if (insertCourseScheduleModifyLogList.size() > 0) {
 			courseScheduleModifyLogDao.batchInsert(insertCourseScheduleModifyLogList);
 		}

+ 220 - 96
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -1,22 +1,73 @@
 package com.ym.mec.biz.service.impl;
 
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType.SCHOOL;
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType.STUDENT;
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.ADD_STUDENT;
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.MUSIC_APPLY;
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.MUSIC_RENEW;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.lang3.StringUtils;
+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 com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.auth.api.entity.SysUserRole;
-import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.dao.MusicGroupBuildLogDao;
+import com.ym.mec.biz.dal.dao.MusicGroupDao;
+import com.ym.mec.biz.dal.dao.MusicGroupOrganizationCourseSettingsDao;
+import com.ym.mec.biz.dal.dao.MusicGroupOrganizationCourseSettingsDetailDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderCourseSettingsDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentStudentCourseDetailDao;
+import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
+import com.ym.mec.biz.dal.dao.OrganizationCourseUnitPriceSettingsDao;
+import com.ym.mec.biz.dal.dao.OrganizationDao;
+import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
+import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.CalenderPushDto;
 import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDetailDto;
 import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDto;
+import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderDto;
+import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderDto.MusicGroupPaymentDateRange;
 import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
-import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.MusicGroupBuildLog;
+import com.ym.mec.biz.dal.entity.MusicGroupOrganizationCourseSettings;
+import com.ym.mec.biz.dal.entity.MusicGroupOrganizationCourseSettingsDetail;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
+import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
+import com.ym.mec.biz.dal.entity.Organization;
+import com.ym.mec.biz.dal.entity.OrganizationCourseUnitPriceSettings;
+import com.ym.mec.biz.dal.entity.StudentRegistration;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
 import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
-import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
 import com.ym.mec.biz.dal.page.MusicGroupPaymentCalenderQueryInfo;
 import com.ym.mec.biz.service.ClassGroupService;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
@@ -32,21 +83,6 @@ import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
 
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Isolation;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.math.BigDecimal;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.stream.Collectors;
-
-import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType.SCHOOL;
-import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType.STUDENT;
-import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.*;
-
 @Service
 public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalender> implements MusicGroupPaymentCalenderService {
 
@@ -102,9 +138,19 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public Long create(MusicGroupPaymentCalender musicGroupPaymentCalender) {
+	public String create(MusicGroupPaymentCalenderDto musicGroupPaymentCalenderDto) {
 
-		String musicGroupId = musicGroupPaymentCalender.getMusicGroupId();
+		String musicGroupId = musicGroupPaymentCalenderDto.getMusicGroupId();
+
+		PaymentType paymentType = musicGroupPaymentCalenderDto.getPaymentType();
+
+		PayUserType payUserType = musicGroupPaymentCalenderDto.getPayUserType();
+
+		List<MusicGroupPaymentDateRange> musicGroupPaymentDateRangeList = musicGroupPaymentCalenderDto.getMusicGroupPaymentDateRangeList();
+
+		if ((paymentType == PaymentType.ADD_COURSE || payUserType == PayUserType.SCHOOL) && musicGroupPaymentDateRangeList.size() > 1) {
+			throw new BizException("临时加课和学校缴费不支持多周期缴费");
+		}
 
 		MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
 
@@ -115,48 +161,44 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		if (sysUser == null) {
 			throw new BizException("请登录");
 		}
-		//不是进行中,只能创建一次缴费
-		if(musicGroup.getStatus() != MusicGroupStatusEnum.PROGRESS){
+		// 所有缴费项目已完成排课才能创建下一个缴费项目
+		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = musicGroupPaymentCalenderDetailDao
+				.getUnusedPaymentCalenderWithMusicGroup(musicGroupId);
+		if (musicGroupPaymentCalenderDetailList != null && musicGroupPaymentCalenderDetailList.size() > 0) {
+			throw new BizException("当前乐团存在未排课的缴费项目,请先完成排课再操作");
+		}
+
+		// 不是进行中,只能创建一次缴费
+		if (musicGroup.getStatus() != MusicGroupStatusEnum.PROGRESS) {
 			List<MusicGroupPaymentCalender> list = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
-			if(list.size() > 0){
+			if (list.size() > 0) {
 				throw new BizException("创建失败,已经存在缴费信息");
 			}
 		}
-		
+
+		PaymentCalenderStatusEnum status = PaymentCalenderStatusEnum.NO;
+
 		Date date = new Date();
-		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<>();
-		musicGroupPaymentCalender.setOperator(sysUser.getId());
-		musicGroupPaymentCalender.setCreateTime(date);
-		musicGroupPaymentCalender.setUpdateTime(date);
-		musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
+		String batchNo = idGeneratorService.generatorId() + "";
 
-		if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null && musicGroupPaymentCalender.getPayUserType() == PayUserType.STUDENT) {
-			musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
-		}
-		if(musicGroupPaymentCalender.getPaymentType() != ADD_STUDENT){
-			int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPayUserType(), musicGroupPaymentCalender.getPaymentValidStartDate(),
-					musicGroupPaymentCalender.getPaymentValidEndDate(), null);
-			if (count > 0) {
-				throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
-			}
-		}
 		// 获取设置的课程
-		List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalender
+		List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalenderDto
 				.getMusicGroupPaymentCalenderCourseSettingsList();
 		if (musicGroupPaymentCalenderCourseSettingsList == null) {
 			musicGroupPaymentCalenderCourseSettingsList = new ArrayList<>();
 		}
-		if (musicGroupPaymentCalender.getPayUserType() == SCHOOL) {
-			musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
+
+		if (payUserType == SCHOOL) {
+			status = PaymentCalenderStatusEnum.AUDITING;
 		} else {
-			if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY || musicGroupPaymentCalender.getPaymentType() == MUSIC_RENEW) {
+			if (paymentType == MUSIC_APPLY || paymentType == MUSIC_RENEW) {
 				// 当前缴费的课程费用
 				Map<CourseScheduleType, BigDecimal> currentCoursePrice = musicGroupPaymentCalenderCourseSettingsList.stream().collect(
 						Collectors
 								.toMap(MusicGroupPaymentCalenderCourseSettings::getCourseType, MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice));
 
 				// 查询默认课程费用
-				Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalender.getMusicGroupOrganizationCourseSettingId();
+				Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId();
 				Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao
 						.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId)
 						.stream()
@@ -167,12 +209,11 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				// 相同类型的课程如果修改了课程费用,需要走审批
 				for (Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()) {
 					if (defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0) {
-						musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
+						status = PaymentCalenderStatusEnum.AUDITING;
 						break;
 					}
 				}
-			} else if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_COURSE || musicGroupPaymentCalender.getPaymentType() == PaymentType
-					.ADD_STUDENT) {
+			} else if (paymentType == PaymentType.ADD_COURSE || paymentType == PaymentType.ADD_STUDENT) {
 				// 如果是临时加课,是否审核是根据单价判断
 				for (MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList) {
 					OrganizationCourseUnitPriceSettings defaultUnitPrice = organizationCourseUnitPriceSettingsDao.queryByOrganIdAndCourseTypeAndChargeType(
@@ -180,48 +221,147 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 					if (defaultUnitPrice == null) {
 						throw new BizException("请先设置分部课程类型单价");
 					}
-					if (courseSettings.getCourseCurrentPrice().divide(new BigDecimal(courseSettings.getCourseTotalMinuties()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN)
+					if (courseSettings.getCourseCurrentPrice()
+							.divide(new BigDecimal(courseSettings.getCourseTotalMinuties()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN)
 							.compareTo(defaultUnitPrice.getUnitPrice()) != 0) {
-						musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
+						status = PaymentCalenderStatusEnum.AUDITING;
 						break;
 					}
 				}
 			}
 		}
-		if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
-			musicGroupPaymentCalender.setPayUserType(STUDENT);
-			musicGroupPaymentCalender.setIsGiveMusicNetwork(false);
-			if(musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING){
-				musicGroupPaymentCalender.setExpectNum(1);
+
+		int times = musicGroupPaymentDateRangeList.size();
+
+		// 排序
+		Collections.sort(musicGroupPaymentDateRangeList, new Comparator<MusicGroupPaymentDateRange>() {
+
+			@Override
+			public int compare(MusicGroupPaymentDateRange o1, MusicGroupPaymentDateRange o2) {
+				return o1.getPaymentValidStartDate().compareTo(o2.getPaymentValidStartDate());
 			}
-		}
-		if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
-			if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
-				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
-			}else if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
-				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
-			}else {
-				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
+		});
+
+		for (int i = 0; i < musicGroupPaymentDateRangeList.size(); i++) {
+
+			MusicGroupPaymentDateRange musicGroupPaymentDateRange = musicGroupPaymentDateRangeList.get(i);
+
+			MusicGroupPaymentCalender musicGroupPaymentCalender = new MusicGroupPaymentCalender();
+			musicGroupPaymentCalender.setAttribute1(musicGroupPaymentCalenderDto.getAttribute1());
+			musicGroupPaymentCalender.setAttribute2(musicGroupPaymentCalenderDto.getAttribute2());
+			musicGroupPaymentCalender.setDeadlinePaymentDate(musicGroupPaymentDateRange.getDeadlinePaymentDate());
+			musicGroupPaymentCalender.setIsGiveMusicNetwork(musicGroupPaymentCalenderDto.getIsGiveMusicNetwork());
+			musicGroupPaymentCalender.setMemo(musicGroupPaymentCalenderDto.getMemo());
+			musicGroupPaymentCalender.setMusicGroupId(musicGroupId);
+			musicGroupPaymentCalender.setMusicGroupOrganizationCourseSettingId(musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId());
+
+			List<MusicGroupPaymentCalenderCourseSettings> newCSList = new ArrayList<MusicGroupPaymentCalenderCourseSettings>(
+					musicGroupPaymentCalenderCourseSettingsList.size());
+
+			for (MusicGroupPaymentCalenderCourseSettings pccs : musicGroupPaymentCalenderCourseSettingsList) {
+
+				MusicGroupPaymentCalenderCourseSettings tempPccs = new MusicGroupPaymentCalenderCourseSettings();
+				try {
+					BeanUtils.copyProperties(tempPccs, pccs);
+				} catch (Exception e) {
+					throw new BizException("克隆对象出错", e);
+				}
+				if (i == 0) {
+					tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice().subtract(
+							pccs.getCourseCurrentPrice().divide(new BigDecimal(times)).setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))));
+					tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().subtract(
+							pccs.getCourseOriginalPrice().divide(new BigDecimal(times)).setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))));
+					tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() - pccs.getCourseTotalMinuties() / times * (times - 1));
+				} else {
+					tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice().divide(new BigDecimal(times)).setScale(2, BigDecimal.ROUND_DOWN));
+					tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().divide(new BigDecimal(times)).setScale(2, BigDecimal.ROUND_DOWN));
+					tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() / times);
+				}
+				newCSList.add(tempPccs);
+			}
+			musicGroupPaymentCalender.setMusicGroupPaymentCalenderCourseSettingsList(newCSList);
+
+			musicGroupPaymentCalender.setPaymentPattern(musicGroupPaymentCalenderDto.getPaymentPattern());
+			musicGroupPaymentCalender.setPaymentValidEndDate(musicGroupPaymentDateRange.getPaymentValidEndDate());
+			musicGroupPaymentCalender.setPaymentValidStartDate(musicGroupPaymentDateRange.getPaymentValidStartDate());
+			musicGroupPaymentCalender.setPaymentType(musicGroupPaymentCalenderDto.getPaymentType());
+			musicGroupPaymentCalender.setPayUserType(musicGroupPaymentCalenderDto.getPayUserType());
+			musicGroupPaymentCalender.setStartPaymentDate(musicGroupPaymentDateRange.getStartPaymentDate());
+			musicGroupPaymentCalender.setStudentIds(musicGroupPaymentCalenderDto.getStudentIds());
+			musicGroupPaymentCalender.setOperator(sysUser.getId());
+			musicGroupPaymentCalender.setCreateTime(date);
+			musicGroupPaymentCalender.setUpdateTime(date);
+			musicGroupPaymentCalender.setStatus(status);
+
+			if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null && payUserType == PayUserType.STUDENT) {
+				musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
+			}
+			if (paymentType != ADD_STUDENT) {
+				int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPayUserType(),
+						musicGroupPaymentCalender.getPaymentValidStartDate(), musicGroupPaymentCalender.getPaymentValidEndDate(), null);
+				if (count > 0) {
+					throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
+				}
+			}
+
+			if (paymentType == PaymentType.ADD_STUDENT) {
+				musicGroupPaymentCalender.setPayUserType(STUDENT);
+				musicGroupPaymentCalender.setIsGiveMusicNetwork(false);
+				if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
+					musicGroupPaymentCalender.setExpectNum(1);
+				}
+			}
+			if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
+				if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
+					musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
+				} else if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
+					musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
+				} else {
+					musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
+				}
+			}
+
+			status = musicGroupPaymentCalender.getStatus();
+
+			// 设置批次号
+			musicGroupPaymentCalender.setBatchNo(batchNo);
+			musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
+
+			List<MusicGroupPaymentCalenderCourseSettings> currentMusicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalender
+					.getMusicGroupPaymentCalenderCourseSettingsList();
+
+			if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
+				// 如果是进行中加学生
+				if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
+					addStudent(musicGroupPaymentCalender, currentMusicGroupPaymentCalenderCourseSettings);
+				}
+			}
+
+			if (currentMusicGroupPaymentCalenderCourseSettings.size() > 0) {
+				MusicGroupOrganizationCourseSettings courseSettings = musicGroupOrganizationCourseSettingsDao.get(musicGroupPaymentCalender
+						.getMusicGroupOrganizationCourseSettingId());
+				for (MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings : currentMusicGroupPaymentCalenderCourseSettings) {
+					musicGroupPaymentCalenderCourseSettings.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
+					if (courseSettings != null) {
+						musicGroupPaymentCalenderCourseSettings.setName(courseSettings.getName());
+					}
+				}
+				musicGroupPaymentCalenderCourseSettingsDao.batchInsert(currentMusicGroupPaymentCalenderCourseSettings);
 			}
-		}else {
-            Set<Integer> roleIds = new HashSet<>(1);
-            roleIds.add(SysUserRole.ADMINISTRATOR);
-            Organization organization = organizationDao.get(musicGroup.getOrganId());
-            sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()), MessageTypeEnum.BACKSTAGE_PAYMENT_CALENDER_AUDIT, "", organization.getName(),musicGroup.getName());
 		}
 
 		// 如果是报名,需要修改乐团状态
-		if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY) {
-			int countAuditReject = musicGroupPaymentCalenderDao.countAuditReject(musicGroupPaymentCalender.getMusicGroupId(),null);
-			if(countAuditReject == 0){
+		if (paymentType == MUSIC_APPLY) {
+			int countAuditReject = musicGroupPaymentCalenderDao.countAuditReject(musicGroupId, null);
+			if (countAuditReject == 0) {
 				if (musicGroup.getStatus() != MusicGroupStatusEnum.DRAFT) {
 					throw new BizException("创建失败:缴费项目类型不匹配");
 				}
-				if(musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING){
+				if (status != PaymentCalenderStatusEnum.AUDITING) {
 					musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
 					// 记录操作日志
 					musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "报名缴费项目创建成功(草稿 -> 基础信息审核中)", sysUser.getId(), ""));
-				}else{
+				} else {
 					musicGroup.setStatus(MusicGroupStatusEnum.FEE_AUDIT);
 					// 记录操作日志
 					musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "报名缴费项目创建成功(草稿 -> 费用审核中)", sysUser.getId(), ""));
@@ -230,33 +370,17 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				musicGroupDao.update(musicGroup);
 			}
 		}
-		// 设置批次号
-		musicGroupPaymentCalender.setBatchNo(idGeneratorService.generatorId() + "");
-		musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
-		
-		if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
-			// 如果是进行中加学生
-			if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
-				addStudent(musicGroupPaymentCalender, musicGroupPaymentCalenderCourseSettingsList);
-			}
-		}
 
-		if (musicGroupPaymentCalenderCourseSettingsList.size() > 0) {
-			MusicGroupOrganizationCourseSettings courseSettings = musicGroupOrganizationCourseSettingsDao.get(musicGroupPaymentCalender
-					.getMusicGroupOrganizationCourseSettingId());
-			for (MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings : musicGroupPaymentCalenderCourseSettingsList) {
-				musicGroupPaymentCalenderCourseSettings.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
-				if (courseSettings != null) {
-					musicGroupPaymentCalenderCourseSettings.setName(courseSettings.getName());
-				}
-			}
-			musicGroupPaymentCalenderCourseSettingsDao.batchInsert(musicGroupPaymentCalenderCourseSettingsList);
+		if (status == PaymentCalenderStatusEnum.AUDITING) {
+			// 如果是审核中
+			Set<Integer> roleIds = new HashSet<>(1);
+			roleIds.add(SysUserRole.ADMINISTRATOR);
+			Organization organization = organizationDao.get(musicGroup.getOrganId());
+			sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()),
+					MessageTypeEnum.BACKSTAGE_PAYMENT_CALENDER_AUDIT, "", organization.getName(), musicGroup.getName());
 		}
 
-		if (musicGroupPaymentCalenderDetailList.size() > 0) {
-			musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
-		}
-		return musicGroupPaymentCalender.getId();
+		return batchNo;
 	}
 
 	@Override

+ 0 - 8
mec-biz/src/main/resources/config/mybatis/StudentPaymentRouteOrderMapper.xml

@@ -94,9 +94,7 @@
             <if test="feeFlag != null">
                 fee_flag_ = #{feeFlag},
             </if>
-            <if test="userId != null">
                 user_id_ = #{userId},
-            </if>
             <if test="schoolId != null">
                 school_id_ = #{schoolId},
             </if>
@@ -106,18 +104,12 @@
             <if test="payTime != null">
                 pay_time_ = #{payTime},
             </if>
-            <if test="saleAmount != null">
                 sale_amount_ = #{saleAmount},
-            </if>
-            <if test="serviceAmount != null">
                 service_amount_ = #{serviceAmount},
-            </if>
             <if test="memo != null">
                 memo_ = #{memo},
             </if>
-            <if test="goodsJson != null">
                 goods_json_ = #{goodsJson},
-            </if>
             <if test="auditStatus != null">
                 audit_status_ = #{auditStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             </if>

+ 4 - 3
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java

@@ -26,6 +26,7 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
+import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderDto;
 import com.ym.mec.biz.dal.entity.Employee;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.StudentRegistration;
@@ -70,10 +71,10 @@ 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 MusicGroupPaymentCalender musicGroupPaymentCalender) {
-        Long musicGroupPaymentCalenderId = musicGroupPaymentCalenderService.create(musicGroupPaymentCalender);
+    public Object add(@RequestBody MusicGroupPaymentCalenderDto musicGroupPaymentCalenderDto) {
+    	String batchNo = musicGroupPaymentCalenderService.create(musicGroupPaymentCalenderDto);
         ModelMap map = new ModelMap();
-        map.put("musicGroupPaymentCalenderId", musicGroupPaymentCalenderId);
+        map.put("musicGroupPaymentCalenderBatchNo", batchNo);
         return succeed(map);
     }