浏览代码

Merge remote-tracking branch 'origin/master'

Joburgess 4 年之前
父节点
当前提交
afad044f06
共有 19 个文件被更改,包括 346 次插入187 次删除
  1. 12 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDetailDao.java
  2. 4 2
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/OrganizationCourseUnitPriceSettingsDao.java
  3. 26 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupPaymentCalenderAddStudentDto.java
  4. 12 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/OrganizationCourseUnitPriceSettingsQueryInfo.java
  5. 14 1
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java
  6. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/service/OrganizationCourseUnitPriceSettingsService.java
  7. 15 5
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java
  8. 163 118
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  9. 11 27
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  10. 2 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/OrganizationCourseUnitPriceSettingsServiceImpl.java
  11. 53 14
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  12. 1 1
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderCourseSettingsMapper.xml
  13. 7 1
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml
  14. 1 1
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml
  15. 8 1
      mec-biz/src/main/resources/config/mybatis/OrganizationCourseUnitPriceSettingsMapper.xml
  16. 2 3
      mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java
  17. 3 1
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java
  18. 7 5
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderDetailController.java
  19. 3 2
      mec-web/src/main/java/com/ym/mec/web/controller/OrganizationCourseUnitPriceSettingsController.java

+ 12 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDetailDao.java

@@ -38,7 +38,7 @@ public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicG
 	 * @param musicGroupPaymentCalenderId
 	 * @return
 	 */
-	List<MusicGroupPaymentCalenderDetail> queryByCalenderId(Long musicGroupPaymentCalenderId);
+	List<MusicGroupPaymentCalenderDetail> queryByCalenderId(@Param("musicGroupPaymentCalenderId") Long musicGroupPaymentCalenderId, @Param("paymentStatus") String paymentStatus);
 
 	/**
 	 * 根据声部获取乐团下完成缴费的学员
@@ -187,4 +187,15 @@ public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicG
 	 * @return com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail
 	 */
 	MusicGroupPaymentCalenderDetail findByCalenderIdAndUserId(@Param("calenderId") Long calenderId, @Param("userId") Integer userId);
+
+	/**
+	 * @describe 根据订单编号获取缴费详情
+	 * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+	 * @author zouxuan
+	 * @date 2020/11/3
+	 * @time 15:41
+	 * @param orderNo:
+	 * @return com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail
+	 */
+	MusicGroupPaymentCalenderDetail findByOrderNo(@Param("orderNo") String orderNo);
 }

+ 4 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/OrganizationCourseUnitPriceSettingsDao.java

@@ -14,10 +14,12 @@ public interface OrganizationCourseUnitPriceSettingsDao extends BaseDAO<Integer,
 	 * 根据分部编号以及课程类型查询对象
 	 * @param organId 分部编号
 	 * @param courseType 课程类型
+	 * @param chargeTypeId 收费类型编号
 	 * @return
 	 */
-	OrganizationCourseUnitPriceSettings queryByOrganIdAndCourseType(@Param("organId") Integer organId, @Param("courseScheduleType") CourseScheduleType courseType);
-	
+	OrganizationCourseUnitPriceSettings queryByOrganIdAndCourseTypeAndChargeType(@Param("organId") Integer organId,
+			@Param("courseScheduleType") CourseScheduleType courseType, @Param("chargeTypeId") Integer chargeTypeId);
+
 	/**
 	 * 批量新增
 	 * @param organizationCourseUnitPriceSettingsList

+ 26 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupPaymentCalenderAddStudentDto.java

@@ -0,0 +1,26 @@
+package com.ym.mec.biz.dal.dto;
+
+import java.util.List;
+
+public class MusicGroupPaymentCalenderAddStudentDto {
+
+	private Long musicGroupPaymentCalenderId;
+
+	private List<Integer> userIdList;
+
+	public Long getMusicGroupPaymentCalenderId() {
+		return musicGroupPaymentCalenderId;
+	}
+
+	public void setMusicGroupPaymentCalenderId(Long musicGroupPaymentCalenderId) {
+		this.musicGroupPaymentCalenderId = musicGroupPaymentCalenderId;
+	}
+
+	public List<Integer> getUserIdList() {
+		return userIdList;
+	}
+
+	public void setUserIdList(List<Integer> userIdList) {
+		this.userIdList = userIdList;
+	}
+}

+ 12 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/page/OrganizationCourseUnitPriceSettingsQueryInfo.java

@@ -9,10 +9,13 @@ public class OrganizationCourseUnitPriceSettingsQueryInfo extends QueryInfo {
 
 	@ApiModelProperty(value = "分部编号", required = false)
 	private Integer organId;
-	
+
 	@ApiModelProperty(value = "课程类型", required = false)
 	private CourseScheduleType courseScheduleType;
 
+	@ApiModelProperty(value = "乐团收费类型编号", required = false)
+	private Integer chargeTypeId;
+
 	public Integer getOrganId() {
 		return organId;
 	}
@@ -28,4 +31,12 @@ public class OrganizationCourseUnitPriceSettingsQueryInfo extends QueryInfo {
 	public void setCourseScheduleType(CourseScheduleType courseScheduleType) {
 		this.courseScheduleType = courseScheduleType;
 	}
+
+	public Integer getChargeTypeId() {
+		return chargeTypeId;
+	}
+
+	public void setChargeTypeId(Integer chargeTypeId) {
+		this.chargeTypeId = chargeTypeId;
+	}
 }

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

@@ -5,6 +5,7 @@ import java.util.List;
 import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDetailDto;
 import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDto;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
 import com.ym.mec.biz.dal.page.MusicGroupPaymentCalenderQueryInfo;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
@@ -28,7 +29,7 @@ public interface MusicGroupPaymentCalenderService extends BaseService<Long, Musi
 	/**
 	 * 更新缴费信息
 	 */
-	int update(MusicGroupPaymentCalender musicGroupPaymentCalender);
+	Long merge(MusicGroupPaymentCalender musicGroupPaymentCalender);
 	
 	/**
 	 * 自动更新付款日历记录状态
@@ -123,4 +124,16 @@ public interface MusicGroupPaymentCalenderService extends BaseService<Long, Musi
 	 * @return
 	 */
 	MusicGroupPaymentCalender findByMusicGroupRegCalender(String musicGroupId);
+
+	/**
+	 * @describe 缴费成功后更新calender
+	 * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+	 * @author zouxuan
+	 * @date 2020/11/3
+	 * @time 17:04
+	 * @param detailId:
+	 * @param userId:
+	 * @return com.ym.mec.biz.dal.entity.MusicGroupStudentFee
+	 */
+    MusicGroupStudentFee updateCalender(Long detailId, Integer userId);
 }

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

@@ -19,7 +19,8 @@ public interface OrganizationCourseUnitPriceSettingsService extends BaseService<
 	 * 根据分部编号以及课程类型查询对象
 	 * @param organId 分部编号
 	 * @param courseType 课程类型
+	 * @param chargeTypeId 收费类型编号
 	 * @return
 	 */
-	OrganizationCourseUnitPriceSettings queryByOrganIdAndCourseType(Integer organId, CourseScheduleType courseType);
+	OrganizationCourseUnitPriceSettings queryByOrganIdAndCourseTypeAndChargeType(Integer organId, CourseScheduleType courseType, Integer chargeTypeId);
 }

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

@@ -215,16 +215,16 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 		if(calender == null){
 			throw new BizException("缴费信息不存在");
 		}
-		MusicGroupPaymentCalenderDetail userLastCalenderDetail = musicGroupPaymentCalenderDetailDao.getUserLastCalenderDetail(calender.getMusicGroupId(), userId);
+		/*MusicGroupPaymentCalenderDetail userLastCalenderDetail = musicGroupPaymentCalenderDetailDao.getUserLastCalenderDetail(calender.getMusicGroupId(), userId);
 		if(userLastCalenderDetail != null){
 			throw new BizException("缴费信息已存在");
-		}
+		}*/
 		Date date = new Date();
-		Integer countOpenPayment = musicGroupPaymentCalenderDetailDao.countOpenPayment(calender.getMusicGroupId(), userId);
+//		Integer countOpenPayment = musicGroupPaymentCalenderDetailDao.countOpenPayment(calender.getMusicGroupId(), userId);
 		MusicGroupStudentFee studentFee = musicGroupStudentFeeDao.findByUser(userId, calender.getMusicGroupId());
-		if(countOpenPayment > 0){
+		/*if(countOpenPayment > 0){
 			throw new BizException("操作失败: 学员有未完成的缴费");
-		}
+		}*/
 		calender.setUpdateTime(date);
 		//生成详情
 		MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
@@ -253,6 +253,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public void batchAdd(Long musicGroupPaymentCalenderId, List<Integer> userIdList) {
 		
 		MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(musicGroupPaymentCalenderId);
@@ -260,6 +261,11 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 			throw new BizException("查询缴费信息失败");
 		}
 		
+		if (musicGroupPaymentCalender.getStatus() == PaymentCalenderStatusEnum.AUDITING
+				|| musicGroupPaymentCalender.getStatus() == PaymentCalenderStatusEnum.REJECT) {
+			throw new BizException("当前缴费状态不能添加学生");
+		}
+		
 		List<MusicGroupPaymentCalenderCourseSettings> courseSettingsList = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalender(musicGroupPaymentCalenderId);
 		
 		BigDecimal totalPrice = new BigDecimal(0);
@@ -289,6 +295,10 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 		if (musicGroupPaymentCalenderDetailList.size() > 0) {
 			musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
 		}
+		//更新预计缴费人数
+		musicGroupPaymentCalender.setExpectNum(userIdList.size());
+		musicGroupPaymentCalender.setUpdateTime(date);
+		musicGroupPaymentCalenderDetailDao.update(musicGroupPaymentCalenderDetail);
 	}
 
 	@Override

+ 163 - 118
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -10,6 +10,7 @@ import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
 import com.ym.mec.biz.dal.entity.*;
 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.MusicGroupStudentFee.PaymentStatus;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
@@ -26,6 +27,7 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
 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;
@@ -60,6 +62,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	private MusicGroupOrganizationCourseSettingsDao musicGroupOrganizationCourseSettingsDao;
 	
 	@Autowired
+	private OrganizationCourseUnitPriceSettingsDao organizationCourseUnitPriceSettingsDao;
+	
+	@Autowired
 	private IdGeneratorService idGeneratorService;
 	
 	@Autowired
@@ -83,20 +88,27 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public Long create(MusicGroupPaymentCalender musicGroupPaymentCalender) {
-		
+
 		String musicGroupId = musicGroupPaymentCalender.getMusicGroupId();
 
 		MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
-		
-		if(musicGroup == null){
+
+		if (musicGroup == null) {
 			throw new BizException("乐团查询失败,请检查参数");
 		}
 		SysUser sysUser = sysUserFeignService.queryUserInfo();
-		if(sysUser == null){
+		if (sysUser == null) {
 			throw new BizException("请登录");
 		}
+		//不是进行中,只能创建一次缴费
+		if(musicGroup.getStatus() != MusicGroupStatusEnum.PROGRESS){
+			List<MusicGroupPaymentCalender> list = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
+			if(list.size() > 0){
+				throw new BizException("创建失败,已经存在缴费信息");
+			}
+		}
+		
 		Date date = new Date();
-		Map<Integer, String> pushUserMap = new HashMap<>();
 		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<>();
 		musicGroupPaymentCalender.setOperator(sysUser.getId());
 		musicGroupPaymentCalender.setCreateTime(date);
@@ -111,29 +123,52 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		if (count > 0) {
 			throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
 		}
-		//获取设置的课程
-		List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalender.getMusicGroupPaymentCalenderCourseSettingsList();
-		if(musicGroupPaymentCalenderCourseSettingsList == null){
+		// 获取设置的课程
+		List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalender
+				.getMusicGroupPaymentCalenderCourseSettingsList();
+		if (musicGroupPaymentCalenderCourseSettingsList == null) {
 			musicGroupPaymentCalenderCourseSettingsList = new ArrayList<>();
 		}
-		//当前缴费的课程费用
-		Map<CourseScheduleType,BigDecimal> currentCoursePrice = musicGroupPaymentCalenderCourseSettingsList.stream().
-				collect(Collectors.toMap(MusicGroupPaymentCalenderCourseSettings :: getCourseType, MusicGroupPaymentCalenderCourseSettings :: getCourseCurrentPrice));
-
-		if(musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY || musicGroupPaymentCalender.getPaymentType() == MUSIC_RENEW){
-			//查询默认课程费用
-			Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalender.getMusicGroupOrganizationCourseSettingId();
-			Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId).stream().
-					collect(Collectors.toMap(MusicGroupOrganizationCourseSettingsDetail :: getCourseType, MusicGroupOrganizationCourseSettingsDetail :: getCourseCurrentPrice));
-
-			//相同类型的课程如果修改了课程费用,需要走审批
-			for(Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()){
-				if(defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0){
-					musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
+		if (musicGroupPaymentCalender.getPayUserType() == PayUserType.SCHOOL) {
+			musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
+		} else {
+			if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY || musicGroupPaymentCalender.getPaymentType() == MUSIC_RENEW) {
+				// 当前缴费的课程费用
+				Map<CourseScheduleType, BigDecimal> currentCoursePrice = musicGroupPaymentCalenderCourseSettingsList.stream().collect(
+						Collectors
+								.toMap(MusicGroupPaymentCalenderCourseSettings::getCourseType, MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice));
+
+				// 查询默认课程费用
+				Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalender.getMusicGroupOrganizationCourseSettingId();
+				Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao
+						.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId)
+						.stream()
+						.collect(
+								Collectors.toMap(MusicGroupOrganizationCourseSettingsDetail::getCourseType,
+										MusicGroupOrganizationCourseSettingsDetail::getCourseCurrentPrice));
+
+				// 相同类型的课程如果修改了课程费用,需要走审批
+				for (Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()) {
+					if (defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0) {
+						musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
+						break;
+					}
+				}
+			} else if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_COURSE) {
+				// 如果是临时加课,是否审核是根据单价判断
+				for (MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList) {
+					OrganizationCourseUnitPriceSettings defaultUnitPrice = organizationCourseUnitPriceSettingsDao.queryByOrganIdAndCourseTypeAndChargeType(
+							musicGroup.getOrganId(), courseSettings.getCourseType(), musicGroup.getChargeTypeId());
+					if (defaultUnitPrice == null) {
+						throw new BizException("请先设置分部课程类型单价");
+					}
+					if (courseSettings.getCourseCurrentPrice().divide(new BigDecimal(courseSettings.getCourseTotalMinuties()))
+							.compareTo(defaultUnitPrice.getUnitPrice()) != 0) {
+						musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
+						break;
+					}
 				}
 			}
-		}else {
-			musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
 		}
 
 		if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
@@ -144,28 +179,29 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			} else {
 				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
 			}
-			
-			//如果是报名,需要修改乐团状态
+
+			// 如果是报名,需要修改乐团状态
 			if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY) {
-				if(musicGroup.getStatus() != MusicGroupStatusEnum.DRAFT){
+				if (musicGroup.getStatus() != MusicGroupStatusEnum.DRAFT) {
 					throw new BizException("创建失败:缴费项目类型不匹配");
 				}
 				musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
 				musicGroup.setUpdateTime(date);
-				//记录操作日志
+				// 记录操作日志
 				musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "报名缴费项目创建成功(草稿 -> 审核中)", sysUser.getId(), ""));
 				musicGroupDao.update(musicGroup);
 			}
 		}
 
 		musicGroupPaymentCalender.setExpectNum(0);
-		//设置批次号
-		musicGroupPaymentCalender.setBatchNo(idGeneratorService.generatorId()+"");
+		// 设置批次号
+		musicGroupPaymentCalender.setBatchNo(idGeneratorService.generatorId() + "");
 		musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
 
-		if(musicGroupPaymentCalenderCourseSettingsList.size() > 0){
-			MusicGroupOrganizationCourseSettings courseSettings = musicGroupOrganizationCourseSettingsDao.get(musicGroupPaymentCalender.getMusicGroupOrganizationCourseSettingId());
-			for(MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings : musicGroupPaymentCalenderCourseSettingsList){
+		if (musicGroupPaymentCalenderCourseSettingsList.size() > 0) {
+			MusicGroupOrganizationCourseSettings courseSettings = musicGroupOrganizationCourseSettingsDao.get(musicGroupPaymentCalender
+					.getMusicGroupOrganizationCourseSettingId());
+			for (MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings : musicGroupPaymentCalenderCourseSettingsList) {
 				musicGroupPaymentCalenderCourseSettings.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
 				musicGroupPaymentCalenderCourseSettings.setName(courseSettings.getName());
 			}
@@ -175,14 +211,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		if (musicGroupPaymentCalenderDetailList.size() > 0) {
 			musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
 		}
-		// 发送续费通知
-		if (pushUserMap.size() > 0) {
-			String configValue = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
-			String memo = "4?" + configValue + "/#/renew?musicGroupId=" + musicGroup.getId();
-
-			sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_WAIT_RENEW_MESSAGE,
-					pushUserMap, null, 0, memo, "STUDENT", musicGroup.getName());
-		}
 		return musicGroupPaymentCalender.getId();
 	}
 
@@ -202,14 +230,18 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public int update(MusicGroupPaymentCalender musicGroupPaymentCalender) {
+	public Long merge(MusicGroupPaymentCalender musicGroupPaymentCalender) {
 		
-		MusicGroupPaymentCalender orginMusicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(musicGroupPaymentCalender.getId());
-		if(orginMusicGroupPaymentCalender == null){
+		MusicGroupPaymentCalender originMusicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(musicGroupPaymentCalender.getId());
+		if(originMusicGroupPaymentCalender == null){
 			throw new BizException("查询不到缴费记录");
 		}
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if (sysUser == null) {
+			throw new BizException("请登录");
+		}
 		//只有“拒绝”才能修改
-		if(orginMusicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.REJECT){
+		if(originMusicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.REJECT){
 			throw new BizException("缴费记录只有被“审核拒绝”才能修改");
 		}
 		
@@ -224,7 +256,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		Date date = new Date();
 		
 		musicGroupPaymentCalender.setUpdateTime(date);
-		if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null) {
+		if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null && musicGroupPaymentCalender.getPayUserType() == PayUserType.STUDENT) {
 			musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
 		}
 		int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPaymentValidStartDate(),
@@ -234,27 +266,53 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		}
 		
 		//获取设置的课程
-		List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalender.getMusicGroupPaymentCalenderCourseSettingsList();
-		if(musicGroupPaymentCalenderCourseSettingsList == null){
-			musicGroupPaymentCalenderCourseSettingsList = new ArrayList<MusicGroupPaymentCalenderCourseSettings>();
+		List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalender
+				.getMusicGroupPaymentCalenderCourseSettingsList();
+		if (musicGroupPaymentCalenderCourseSettingsList == null) {
+			musicGroupPaymentCalenderCourseSettingsList = new ArrayList<>();
 		}
-		
-		//查询默认课程费用
-		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);
+		if (musicGroupPaymentCalender.getPayUserType() == PayUserType.SCHOOL) {
+			musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
+		} else {
+			if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY || musicGroupPaymentCalender.getPaymentType() == MUSIC_RENEW) {
+				// 当前缴费的课程费用
+				Map<CourseScheduleType, BigDecimal> currentCoursePrice = musicGroupPaymentCalenderCourseSettingsList.stream().collect(
+						Collectors
+								.toMap(MusicGroupPaymentCalenderCourseSettings::getCourseType, MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice));
+
+				// 查询默认课程费用
+				Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalender.getMusicGroupOrganizationCourseSettingId();
+				Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao
+						.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId)
+						.stream()
+						.collect(
+								Collectors.toMap(MusicGroupOrganizationCourseSettingsDetail::getCourseType,
+										MusicGroupOrganizationCourseSettingsDetail::getCourseCurrentPrice));
+
+				// 相同类型的课程如果修改了课程费用,需要走审批
+				for (Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()) {
+					if (defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0) {
+						musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
+						break;
+					}
+				}
+			} else if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_COURSE) {
+				// 如果是临时加课,是否审核是根据单价判断
+				for (MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList) {
+					OrganizationCourseUnitPriceSettings defaultUnitPrice = organizationCourseUnitPriceSettingsDao.queryByOrganIdAndCourseTypeAndChargeType(
+							musicGroup.getOrganId(), courseSettings.getCourseType(), musicGroup.getChargeTypeId());
+					if (defaultUnitPrice == null) {
+						throw new BizException("请先设置分部课程类型单价");
+					}
+					if (courseSettings.getCourseCurrentPrice().divide(new BigDecimal(courseSettings.getCourseTotalMinuties()))
+							.compareTo(defaultUnitPrice.getUnitPrice()) != 0) {
+						musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
+						break;
+					}
+				}
 			}
-			totalPrice.add(entry.getValue());
 		}
-		
+
 		if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
 			if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
 				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
@@ -263,70 +321,29 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			} else {
 				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
 			}
-			
-			//如果是报名,需要修改乐团状态
+
+			// 如果是报名,需要修改乐团状态
 			if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY) {
+				if (musicGroup.getStatus() != MusicGroupStatusEnum.DRAFT) {
+					throw new BizException("创建失败:缴费项目类型不匹配");
+				}
 				musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
 				musicGroup.setUpdateTime(date);
+				// 记录操作日志
+				musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "报名缴费项目创建成功(草稿 -> 审核中)", sysUser.getId(), ""));
 				musicGroupDao.update(musicGroup);
 			}
 		}
-		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
-		Map<Integer, String> pushUserMap = new HashMap<Integer, String>();
-
-		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){
-					pushUserMap.put(Integer.parseInt(studentId), studentId);
-				}
-			}
-			
-			//删除历史数据
-			musicGroupPaymentCalenderDetailDao.deleteByCalenderId(musicGroupPaymentCalender.getId());
-			
-			//创建缴费明细
-			MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
-			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.update(musicGroupPaymentCalender);
 
-		if (musicGroupPaymentCalenderDetailList.size() > 0) {
-			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);
-			String memo = "4?" + configValue + "/#/renew?musicGroupId=" + musicGroup.getId();
-
-			sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_WAIT_RENEW_MESSAGE,
-					pushUserMap, null, 0, memo, "STUDENT", musicGroup.getName());
-		}
-		
-		return 1;
+		return musicGroupPaymentCalender.getId();
 	}
 
 	@Override
@@ -480,7 +497,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				}
 				Map<Integer, String> push = new HashMap<>(1);
 				push.put(detail.getUserId(), detail.getUserId() + "");
-				// MusicGroup musicGroup = musicGroupDao.get(detail.getMusicGroupId());
 				String baseUrl = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
 				String memo = "4?" + baseUrl + "/#/renew?musicGroupId=" + detail.getMusicGroupId();
 				// 发送续费通知
@@ -517,7 +533,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				updateMusicGroupPaymentCalenderList.add(mgpc);
 
 				// 0元学生改成“已缴费”
-				List<MusicGroupPaymentCalenderDetail> list = musicGroupPaymentCalenderDetailDao.queryByCalenderId(mgpc.getId());
+				List<MusicGroupPaymentCalenderDetail> list = musicGroupPaymentCalenderDetailDao.queryByCalenderId(mgpc.getId(),PaymentStatus.NON_PAYMENT.getCode());
 				for (MusicGroupPaymentCalenderDetail mgpcd : list) {
 					if (mgpcd.getExpectAmount().doubleValue() == 0) {
 						mgpcd.setActualAmount(BigDecimal.ZERO);
@@ -539,6 +555,11 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				}
 
 			} else if (mgpc.getStartPaymentDate() != null && date.after(mgpc.getStartPaymentDate()) && mgpc.getStatus() == PaymentCalenderStatusEnum.NO) {
+				MusicGroup musicGroup = musicGroupDao.get(mgpc.getMusicGroupId());
+				//如果乐团还在审核中
+				if(musicGroup.getStatus() == MusicGroupStatusEnum.DRAFT || musicGroup.getStatus() == MusicGroupStatusEnum.AUDIT|| musicGroup.getStatus() == MusicGroupStatusEnum.AUDIT_FAILED){
+					continue;
+				}
 				// “未开始”更新至“进行中”
 				mgpc.setUpdateTime(date);
 				mgpc.setStatus(PaymentCalenderStatusEnum.OPEN);
@@ -570,7 +591,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 					for (Integer userId : studentIds) {
 						push.put(userId, userId + "");
 					}
-					MusicGroup musicGroup = musicGroupDao.get(mgpc.getMusicGroupId());
 					String baseUrl = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
 					String memo = "4?" + baseUrl + "/#/renew?musicGroupId=" + musicGroup.getId();
 					// 发送续费通知
@@ -650,7 +670,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			calender.setStatus(PaymentCalenderStatusEnum.OPEN);
 			// 修改Fee缴费状态为未缴费
 			musicGroupStudentFeeDao.updatePaymentStatus(calender.getId(), "NON_PAYMENT");
-			List<MusicGroupPaymentCalenderDetail> details = musicGroupPaymentCalenderDetailDao.queryByCalenderId(calender.getId());
+			List<MusicGroupPaymentCalenderDetail> details = musicGroupPaymentCalenderDetailDao.queryByCalenderId(calender.getId(),null);
 			Set<Integer> studentIds = details.stream().map(e -> e.getUserId()).collect(Collectors.toSet());
 			if (studentIds.size() > 0) {
 				Map<Integer, String> push = new HashMap<>();
@@ -684,7 +704,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			throw new BizException("删除失败,只有“拒绝”或“未开启缴费”状态才能删除");
 		}
 
-		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = musicGroupPaymentCalenderDetailDao.queryByCalenderId(id);
+		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = musicGroupPaymentCalenderDetailDao.queryByCalenderId(id,null);
 		if (musicGroupPaymentCalenderDetailList != null && musicGroupPaymentCalenderDetailList.size() > 0) {
 			List<MusicGroupPaymentCalenderDetail> paidList = musicGroupPaymentCalenderDetailList.stream()
 					.filter(MusicGroupPaymentCalenderDetail -> MusicGroupPaymentCalenderDetail.getPaymentStatus() != PaymentStatus.NON_PAYMENT)
@@ -747,4 +767,29 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		return musicGroupPaymentCalenderDao.findByMusicGroupRegCalender(musicGroupId);
 	}
 
+	@Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED)
+	public MusicGroupStudentFee updateCalender(Long calenderDetailId,Integer userId){
+		Date date = new Date();
+		MusicGroupPaymentCalenderDetail calenderDetail = musicGroupPaymentCalenderDetailDao.get(calenderDetailId);
+		MusicGroupPaymentCalender calender = this.get(calenderDetail.getMusicGroupPaymentCalenderId());
+		MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(userId, calender.getMusicGroupId());
+		if(calender.getIsGiveMusicNetwork()){
+			//赠送网管课
+			musicGroupStudentFee.setRemainNetworkClassTimes(musicGroupStudentFee.getRemainNetworkClassTimes() + 1);
+		}
+		//更新学生的缴费记录状态
+		calenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED);
+		calenderDetail.setActualAmount(calenderDetail.getExpectAmount());
+		calenderDetail.setPayTime(date);
+		calenderDetail.setUpdateTime(date);
+		musicGroupPaymentCalenderDetailDao.update(calenderDetail);
+
+		//更新实际缴费人数
+		Integer actualNum = calender.getActualNum() == null ? 0 : calender.getActualNum();
+		calender.setActualNum(actualNum + 1);
+		calender.setUpdateTime(date);
+		musicGroupPaymentCalenderDao.update(calender);
+		return musicGroupStudentFee;
+	}
+
 }

+ 11 - 27
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -515,6 +515,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
                 Map<String, BigDecimal> groupType = JSONObject.parseObject(goodsGroup.getKitGroupPurchaseTypeJson(), new TypeReference<Map<String, BigDecimal>>() {
                 });
+
                 Map<String, BigDecimal> coursePurchase = JSONObject.parseObject(goodsGroup.getCoursePurchaseTypeJson(), new TypeReference<Map<String, BigDecimal>>() {
                 });
                 if (goodsGroup.getType().equals(GoodsType.INSTRUMENT)) {
@@ -527,7 +528,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                     }
                     goodsGroup.setKitGroupPurchaseType(KitGroupPurchaseTypeEnum.valueOf(kitGroupPurchaseType));
                     remitFee = groupType.get(kitGroupPurchaseType) == null ? BigDecimal.ZERO : groupType.get(kitGroupPurchaseType);
-                    courseRemitFee = coursePurchase.get(kitGroupPurchaseType) == null ? BigDecimal.ZERO : coursePurchase.get(kitGroupPurchaseType);
+                    if (coursePurchase != null){
+                        courseRemitFee = coursePurchase.get(kitGroupPurchaseType) == null ? BigDecimal.ZERO : coursePurchase.get(kitGroupPurchaseType);
+                    }
                 }
                 orderAmount = orderAmount.add(goodsGroup.getPrice());
                 goodsGroup.setGoodsList(goodsService.findGoodsByIds(goodsGroup.getGoodsIdList()));
@@ -623,6 +626,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         studentPaymentOrder.setVersion(studentPaymentOrder.getVersion() + 1);
 
         if (amount.compareTo(BigDecimal.ZERO) == 0) {
+            //如果赠送网管课
             studentPaymentRouteOrderService.addRouteOrder(orderNo, musicGroup.getOrganId(), balance);
             Map<String, String> notifyMap = new HashMap<>();
             notifyMap.put("tradeState", "1");
@@ -742,7 +746,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                     }
                     goodsGroup.setKitGroupPurchaseType(KitGroupPurchaseTypeEnum.valueOf(kitGroupPurchaseType));
                     remitFee = groupType.get(kitGroupPurchaseType);
-                    courseRemitFee = coursePurchase.get(kitGroupPurchaseType) == null ? BigDecimal.ZERO : coursePurchase.get(kitGroupPurchaseType);
+                    if (coursePurchase != null) {
+                        courseRemitFee = coursePurchase.get(kitGroupPurchaseType) == null ? BigDecimal.ZERO : coursePurchase.get(kitGroupPurchaseType);
+                    }
                 }
                 orderAmount = orderAmount.add(goodsGroup.getPrice());
                 goodsGroup.setGoodsList(goodsService.findGoodsByIds(goodsGroup.getGoodsIdList()));
@@ -1848,12 +1854,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         Integer userId = studentPaymentOrder.getUserId();
         String musicGroupId = studentPaymentOrder.getMusicGroupId();
 
-        //更新下次续费时间
-        MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(userId, musicGroupId);
-
-        if (musicGroupStudentFee == null) {
-            throw new BizException("系统数据异常,找不到学员预缴费信息");
-        }
         Date date = new Date();
         StudentRegistration studentRegistration = studentRegistrationDao.queryByUserIdAndMusicGroupId(userId, musicGroupId);
         Map<Integer, String> yimei = new HashMap<>(1);
@@ -1861,12 +1861,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         push.put(userId, userId.toString());
         yimei.put(userId, studentRegistration.getParentsPhone());
         if (studentPaymentOrder.getStatus() == DealStatusEnum.SUCCESS) {
-            MusicGroupPaymentCalenderDetail userLastCalenderDetail = musicGroupPaymentCalenderDetailDao.getUserLastCalenderDetail(musicGroupId, userId);
-            if (userLastCalenderDetail == null) {
-                throw new BizException("学生没有续费中的记录");
-            }
-
-            MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(userLastCalenderDetail.getMusicGroupPaymentCalenderId());
+            //当前乐团报名是否赠送乐团网管课
+            MusicGroupPaymentCalenderDetail calenderDetail = musicGroupPaymentCalenderDetailDao.findByOrderNo(studentPaymentOrder.getOrderNo());
+            MusicGroupStudentFee musicGroupStudentFee = musicGroupPaymentCalenderService.updateCalender(calenderDetail.getId(),studentRegistration.getUserId());
 
             musicGroupStudentFee.setUpdateTime(date);
             musicGroupStudentFee.setLatestPaidTime(date);
@@ -1879,19 +1876,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 //            musicGroupStudentFee.setNextPaymentDate(musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, musicGroupStudentFee.getNextPaymentDate(), musicGroupStudentFee));
             musicGroupStudentFeeDao.update(musicGroupStudentFee);
 
-            //更新学生的缴费记录状态
-            userLastCalenderDetail.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
-            userLastCalenderDetail.setActualAmount(userLastCalenderDetail.getExpectAmount());
-            userLastCalenderDetail.setPayTime(date);
-            userLastCalenderDetail.setUpdateTime(date);
-            musicGroupPaymentCalenderDetailDao.update(userLastCalenderDetail);
-
-            //更新实际缴费人数
-            Integer actualNum = musicGroupPaymentCalender.getActualNum() == null ? 0 : musicGroupPaymentCalender.getActualNum();
-            musicGroupPaymentCalender.setActualNum(actualNum + 1);
-            musicGroupPaymentCalender.setUpdateTime(date);
-            musicGroupPaymentCalenderDao.update(musicGroupPaymentCalender);
-
             //插入交易明细
             SysUserCashAccount cashAccount = sysUserCashAccountService.get(userId);
             BigDecimal amount = studentPaymentOrder.getActualAmount();

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

@@ -30,8 +30,8 @@ public class OrganizationCourseUnitPriceSettingsServiceImpl extends BaseServiceI
 	}
 
 	@Override
-	public OrganizationCourseUnitPriceSettings queryByOrganIdAndCourseType(Integer organId, CourseScheduleType courseType) {
-		return organizationCourseUnitPriceSettingsDao.queryByOrganIdAndCourseType(organId, courseType);
+	public OrganizationCourseUnitPriceSettings queryByOrganIdAndCourseTypeAndChargeType(Integer organId, CourseScheduleType courseType, Integer chargeTypeId) {
+		return organizationCourseUnitPriceSettingsDao.queryByOrganIdAndCourseTypeAndChargeType(organId, courseType, chargeTypeId);
 	}
 	
 }

+ 53 - 14
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -22,16 +22,14 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.im.ImFeignService;
 import com.ym.mec.thirdparty.eseal.ESealPlugin;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
-import com.ym.mec.thirdparty.user.realname.RealnameAuthenticationPluginContext;
-import com.ym.mec.thirdparty.user.realname.provider.LinkfaceRealnameAuthenticationPlugin;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.http.HttpUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
@@ -106,9 +104,9 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     @Autowired
     private GoodsDao goodsDao;
     @Autowired
-    private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
-    @Autowired
     private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
+    @Autowired
+    private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
 
     @Override
     public BaseDAO<Long, StudentRegistration> getDAO() {
@@ -840,6 +838,30 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         return classGroupStuList;
     }
 
+    @Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED)
+    public void updateCalender(Long calenderDetailId,Integer userId){
+        Date date = new Date();
+        MusicGroupPaymentCalenderDetail calenderDetail = musicGroupPaymentCalenderDetailDao.get(calenderDetailId);
+        MusicGroupPaymentCalender calender = musicGroupPaymentCalenderService.get(calenderDetail.getMusicGroupPaymentCalenderId());
+        MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(userId, calender.getMusicGroupId());
+        if(calender.getIsGiveMusicNetwork()){
+            //赠送网管课
+            musicGroupStudentFee.setRemainNetworkClassTimes(musicGroupStudentFee.getRemainNetworkClassTimes() + 1);
+        }
+        //更新学生的缴费记录状态
+        calenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED);
+        calenderDetail.setActualAmount(calenderDetail.getExpectAmount());
+        calenderDetail.setPayTime(date);
+        calenderDetail.setUpdateTime(date);
+        musicGroupPaymentCalenderDetailDao.update(calenderDetail);
+
+        //更新实际缴费人数
+        Integer actualNum = calender.getActualNum() == null ? 0 : calender.getActualNum();
+        calender.setActualNum(actualNum + 1);
+        calender.setUpdateTime(date);
+        musicGroupPaymentCalenderDao.update(calender);
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public StudentPaymentOrder updateApplyOrder(StudentPaymentOrder studentPaymentOrder) throws Exception {
@@ -859,7 +881,6 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getActualSubjectId());
 
         if (studentPaymentOrder.getStatus().equals(DealStatusEnum.SUCCESS)) {
-
             MusicGroup musicGroup = musicGroupDao.get(studentRegistration.getMusicGroupId());
 
             if (studentRegistration.getTemporaryCourseFee() != null) {
@@ -869,25 +890,33 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
             studentRegistrationDao.update(studentRegistration);
 
+            //当前乐团报名是否赠送乐团网管课
+
+            MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(studentRegistration.getUserId(), studentRegistration.getMusicGroupId());
             //进行中乐团加入学生缴费
             if (studentRegistration.getTemporaryCourseFee() != null) {
                 //关闭待支付订单
                 StudentPaymentOrder waitPayOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(studentRegistration.getUserId(), studentRegistration.getMusicGroupId(), DealStatusEnum.WAIT_PAY);
                 waitPayOrder.setStatus(DealStatusEnum.CLOSE);
                 studentPaymentOrderService.update(waitPayOrder);
-                MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(studentRegistration.getUserId(), studentRegistration.getMusicGroupId());
                 musicGroupStudentFee.setLatestPaidTime(nowDate);
                 musicGroupStudentFee.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED);
                 musicGroupStudentFee.setTemporaryCourseFee(BigDecimal.ZERO);
-                /*if (musicGroup.getFeeType() != null && musicGroup.getFeeType() != MusicGroupPaymentCalender.FeeType.OFFLINE) {
-                    musicGroupStudentFee.setRemainNetworkClassTimes(musicGroupStudentFee.getRemainNetworkClassTimes() + 1);
-                }*/
                 musicGroupStudentFee.setUpdateTime(nowDate);
-                musicGroupStudentFeeDao.update(musicGroupStudentFee);
-                //添加学生
-                //classGroupStudentMapperService.addStudents(waitPayOrder.getClassGroupId(), studentRegistration.getUserId().toString(), GroupType.MUSIC);
+            }else {
+                musicGroupStudentFee = new MusicGroupStudentFee();
+                musicGroupStudentFee.setRemainNetworkClassTimes(0);
+                musicGroupStudentFee.setLatestPaidTime(nowDate);
+                musicGroupStudentFee.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED);
+                musicGroupStudentFee.setTemporaryCourseFee(BigDecimal.ZERO);
+                musicGroupStudentFee.setUpdateTime(nowDate);
+                musicGroupStudentFee.setContinuousAbsenteeismTimes(0);
+                musicGroupStudentFee.setSubjectId(studentRegistration.getActualSubjectId());
+                musicGroupStudentFee.setIsLock(0);
+                musicGroupStudentFee.setMusicGroupId(musicGroup.getId());
+                musicGroupStudentFee.setUserId(studentRegistration.getUserId());
+                musicGroupStudentFeeDao.insert(musicGroupStudentFee);
             }
-
             //插入交易明细
             BigDecimal amount = studentPaymentOrder.getActualAmount();
             SysUserCashAccount cashAccount = sysUserCashAccountService.get(studentRegistration.getUserId());
@@ -933,6 +962,16 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
             //缴费详情 calender detail
             MusicGroupPaymentCalender musicGroupRegCalender = musicGroupPaymentCalenderService.findByMusicGroupRegCalender(musicGroup.getId());
+//            if(musicGroupRegCalender.getIsGiveMusicNetwork()){
+//                //赠送网管课
+//                musicGroupStudentFee.setRemainNetworkClassTimes(musicGroupStudentFee.getRemainNetworkClassTimes() + 1);
+//            }
+//            musicGroupStudentFeeDao.update(musicGroupStudentFee);
+//            //更新实际缴费人数
+//            Integer actualNum = musicGroupRegCalender.getActualNum() == null ? 0 : musicGroupRegCalender.getActualNum();
+//            musicGroupRegCalender.setActualNum(actualNum + 1);
+//            musicGroupRegCalender.setUpdateTime(nowDate);
+//            musicGroupPaymentCalenderDao.update(musicGroupRegCalender);
             MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
             musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupRegCalender.getId());
             musicGroupPaymentCalenderDetail.setUserId(studentPaymentOrder.getUserId());

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

@@ -124,7 +124,7 @@
 	</select>
 
     <select id="getCalenderCourseSettings" resultMap="MusicGroupPaymentCalenderCourseSettings">
-		SELECT * FROM music_group_organization_course_settings WHERE id_ IN
+		SELECT * FROM music_group_payment_calender_course_settings WHERE id_ IN
 		<foreach collection="ids" item="id" open="(" close=")" separator=",">
 			#{id}
 		</foreach>

+ 7 - 1
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml

@@ -251,7 +251,10 @@
 	</select>
 	
 	<select id="queryByCalenderId" resultMap="MusicGroupPaymentCalenderDetail">
-		SELECT * FROM music_group_payment_calender_detail where music_group_payment_calender_id_ = #{calenderId}
+		SELECT * FROM music_group_payment_calender_detail WHERE music_group_payment_calender_id_ = #{calenderId}
+		<if test="paymentStatus != null">
+			AND psyment_status_ = #{paymentStatus}
+		</if>
 	</select>
     <select id="findMusicGroupStudentWithSubject" resultType="com.ym.mec.biz.dal.dto.SimpleUserDto">
 		SELECT DISTINCT su.id_ userId,su.username_ userName, su.avatar_ avatar, su.phone_ phone
@@ -363,4 +366,7 @@
 	<select id="findByCalenderIdAndUserId" resultMap="MusicGroupPaymentCalenderDetail">
 		SELECT * FROM music_group_payment_calender_detail WHERE music_group_payment_calender_id_ = #{calenderId} AND user_id_ = #{userId} LIMIT 1
 	</select>
+	<select id="findByOrderNo" resultMap="MusicGroupPaymentCalenderDetail">
+		SELECT * FROM music_group_payment_calender_detail WHERE payment_order_id_ = #{orderNo} LIMIT 1
+	</select>
 </mapper>

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

@@ -240,7 +240,7 @@
         SELECT * FROM music_group_payment_calender mgpc
         <where>
         	<if test="status != null">
-        		payment_status_ in
+        		status_ in
         		<foreach collection="status" item="item" open="(" close=")" separator=",">
 		            #{item,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 		        </foreach>

+ 8 - 1
mec-biz/src/main/resources/config/mybatis/OrganizationCourseUnitPriceSettingsMapper.xml

@@ -88,6 +88,9 @@
 			<if test="courseScheduleType != null">
 				and ups.course_type_ = #{courseScheduleType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 			</if>
+			<if test="chargeTypeId != null">
+				and ups.charge_type_id_ = #{chargeTypeId}
+			</if>
 		</where>
 		ORDER BY ups.id_ desc
 		<include refid="global.limit" />
@@ -103,10 +106,14 @@
 			<if test="courseScheduleType != null">
 				and ups.course_type_ = #{courseScheduleType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 			</if>
+			<if test="chargeTypeId != null">
+				and ups.charge_type_id_ = #{chargeTypeId}
+			</if>
 		</where>
 	</select>
 	
-	<select id="queryByOrganIdAndCourseType" resultMap="OrganizationCourseUnitPriceSettings" parameterType="map">
+	<select id="queryByOrganIdAndCourseTypeAndChargeType" resultMap="OrganizationCourseUnitPriceSettings" parameterType="map">
 		SELECT * FROM organization_course_unit_price_settings WHERE organ_id_ = #{organId} and course_type_ = #{courseScheduleType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+		and charge_type_id_ = #{chargeTypeId}
 	</select>
 </mapper>

+ 2 - 3
mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java

@@ -123,7 +123,6 @@ public class MusicGroupController extends BaseController {
                 return succeed(musicGroupSubjectPlanService.getStudentGoodsAndInfo(musicGroupId, subjectId, studentRegistration));
             }
         }
-
         return succeed(musicGroupSubjectPlanService.getSubjectGoodsAndInfo(musicGroupId, subjectId));
     }
 
@@ -256,7 +255,7 @@ public class MusicGroupController extends BaseController {
 
     @ApiOperation(value = "乐团报名支付")
     @PostMapping("/pay")
-    @ApiImplicitParams({@ApiImplicitParam(name = "registerPayDto", value = "支付信息", required = true, dataType = "Integer")})
+    @ApiImplicitParams({@ApiImplicitParam(name = "registerPayDto", value = "支付信息", required = true, dataType = "RegisterPayDto")})
     public HttpResponseResult pay(@RequestBody RegisterPayDto registerPayDto) throws Exception {
 
         StudentRegistration studentRegistration = studentRegistrationService.get(registerPayDto.getRegisterId().longValue());
@@ -287,7 +286,7 @@ public class MusicGroupController extends BaseController {
 
     @ApiOperation(value = "乐团报名重新支付")
     @PostMapping("/rePay")
-    @ApiImplicitParams({@ApiImplicitParam(name = "registerPayDto", value = "支付信息", required = true, dataType = "Integer")})
+    @ApiImplicitParams({@ApiImplicitParam(name = "registerPayDto", value = "支付信息", required = true, dataType = "RegisterPayDto")})
     public HttpResponseResult rePay(@RequestBody RegisterPayDto registerPayDto) throws Exception {
         StudentRegistration studentRegistration = studentRegistrationService.get(registerPayDto.getRegisterId().longValue());
         if (studentRegistration == null) {

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

@@ -76,7 +76,9 @@ public class MusicGroupPaymentCalenderController extends BaseController {
     @PostMapping("/update")
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/update')")
     public Object update(MusicGroupPaymentCalender paymentCalender) {
-        musicGroupPaymentCalenderService.update(paymentCalender);
+    	Long musicGroupPaymentCalenderId = musicGroupPaymentCalenderService.merge(paymentCalender);
+        ModelMap map = new ModelMap();
+        map.put("musicGroupPaymentCalenderId", musicGroupPaymentCalenderId);
         return succeed();
     }
 

+ 7 - 5
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderDetailController.java

@@ -4,15 +4,16 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
 import java.math.BigDecimal;
-import java.util.List;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAddStudentDto;
 import com.ym.mec.biz.dal.page.MusicCalenderDetailQueryInfo;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderDetailService;
 import com.ym.mec.common.controller.BaseController;
@@ -59,10 +60,11 @@ public class MusicGroupPaymentCalenderDetailController extends BaseController {
     @ApiOperation(value = "乐团缴费记录新增学员")
     @PostMapping("/batchAdd")
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalenderDetail/batchAdd')")
-    public Object batchAdd(Long musicGroupPaymentCalenderId,List<Integer> userIdList) {
-        musicGroupPaymentCalenderDetailService.batchAdd(musicGroupPaymentCalenderId,userIdList);
-        return succeed();
-    }
+	public Object batchAdd(@RequestBody MusicGroupPaymentCalenderAddStudentDto musicGroupPaymentCalenderAddStudentDto) {
+		musicGroupPaymentCalenderDetailService.batchAdd(musicGroupPaymentCalenderAddStudentDto.getMusicGroupPaymentCalenderId(),
+				musicGroupPaymentCalenderAddStudentDto.getUserIdList());
+		return succeed();
+	}
 
     @ApiOperation(value = "批量删除缴费信息")
     @PostMapping("/batchDel")

+ 3 - 2
mec-web/src/main/java/com/ym/mec/web/controller/OrganizationCourseUnitPriceSettingsController.java

@@ -42,8 +42,9 @@ public class OrganizationCourseUnitPriceSettingsController extends BaseControlle
 	@PreAuthorize("@pcs.hasPermissions('organizationCourseUnitPriceSettings/insert')")
 	public Object insert(@RequestBody List<OrganizationCourseUnitPriceSettings> organizationCourseUnitPriceSettingsList) {
 		for (OrganizationCourseUnitPriceSettings organizationCourseUnitPriceSettings : organizationCourseUnitPriceSettingsList) {
-			OrganizationCourseUnitPriceSettings originalObj = organizationCourseUnitPriceSettingsService.queryByOrganIdAndCourseType(
-					organizationCourseUnitPriceSettings.getOrganId(), organizationCourseUnitPriceSettings.getCourseType());
+			OrganizationCourseUnitPriceSettings originalObj = organizationCourseUnitPriceSettingsService.queryByOrganIdAndCourseTypeAndChargeType(
+					organizationCourseUnitPriceSettings.getOrganId(), organizationCourseUnitPriceSettings.getCourseType(),
+					organizationCourseUnitPriceSettings.getChargeTypeId());
 			if (originalObj != null) {
 				return failed("当前分部已经存在该课程类型的单价");
 			}