Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderCourseSettingsDao.java
#	mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderCourseSettingsMapper.xml
周箭河 5 years ago
parent
commit
465fb4b2f7
15 changed files with 430 additions and 319 deletions
  1. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupOrganizationCourseSettingsDetailDao.java
  2. 1 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderCourseSettingsDao.java
  3. 9 16
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDao.java
  4. 6 13
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDetailDao.java
  5. 12 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalender.java
  6. 5 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderCourseSettings.java
  7. 0 15
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/MusicCalenderQueryInfo.java
  8. 38 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/MusicGroupPaymentCalenderQueryInfo.java
  9. 5 16
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java
  10. 208 101
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  11. 4 0
      mec-biz/src/main/resources/config/mybatis/MusicGroupOrganizationCourseSettingsDetailMapper.xml
  12. 88 100
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderCourseSettingsMapper.xml
  13. 1 6
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml
  14. 36 20
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml
  15. 15 29
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java

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

@@ -11,4 +11,6 @@ public interface MusicGroupOrganizationCourseSettingsDetailDao extends BaseDAO<I
     int batchInsert(@Param("settingDetails") List<MusicGroupOrganizationCourseSettingsDetail> settingDetails);
     int batchInsert(@Param("settingDetails") List<MusicGroupOrganizationCourseSettingsDetail> settingDetails);
 
 
     int deleteBySettingId(@Param("settingId") Integer settingId);
     int deleteBySettingId(@Param("settingId") Integer settingId);
+    
+    List<MusicGroupOrganizationCourseSettingsDetail> queryByMusicGroupOrganizationCourseSettingsId(Integer musicGroupOrganizationCourseSettingsId);
 }
 }

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderCourseSettingsDao.java

@@ -8,6 +8,7 @@ import java.util.List;
 
 
 public interface MusicGroupPaymentCalenderCourseSettingsDao extends BaseDAO<Integer, MusicGroupPaymentCalenderCourseSettings> {
 public interface MusicGroupPaymentCalenderCourseSettingsDao extends BaseDAO<Integer, MusicGroupPaymentCalenderCourseSettings> {
 
 
+	int deleteByMusicGroupPaymentCalenderId(Long musicGroupPaymentCalenderId);
 
 
     /**
     /**
      * 获取乐团的缴费课程
      * 获取乐团的缴费课程

+ 9 - 16
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDao.java

@@ -34,6 +34,15 @@ public interface MusicGroupPaymentCalenderDao extends BaseDAO<Long, MusicGroupPa
      */
      */
     int batchUpdate(List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList);
     int batchUpdate(List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList);
 
 
+
+    /**
+     * 批量插入
+     *
+     * @param musicGroupPaymentCalenderList
+     * @return
+     */
+    int batchInsert(List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList);
+
     /**
     /**
      * 查询指定状态的记录
      * 查询指定状态的记录
      *
      *
@@ -62,22 +71,6 @@ public interface MusicGroupPaymentCalenderDao extends BaseDAO<Long, MusicGroupPa
                                        @Param("deadlinePaymentDate") Date deadlinePaymentDate,@Param("calenderId") Long calenderId);
                                        @Param("deadlinePaymentDate") Date deadlinePaymentDate,@Param("calenderId") Long calenderId);
 
 
     /**
     /**
-     * 统计预计缴费人数
-     *
-     * @param collect
-     * @return
-     */
-    List<Map<Long, Long>> countExpectNum(@Param("collect") Set<Long> collect);
-
-    /**
-     * 统计预计缴费人数
-     *
-     * @param collect
-     * @return
-     */
-    List<Map<Long, Long>> countActualNum(@Param("collect") Set<Long> collect);
-
-    /**
      * 乐团最后一次交费信息
      * 乐团最后一次交费信息
      * @param musicGroupId
      * @param musicGroupId
      * @return
      * @return

+ 6 - 13
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDetailDao.java

@@ -1,15 +1,15 @@
 package com.ym.mec.biz.dal.dao;
 package com.ym.mec.biz.dal.dao;
 
 
-import com.ym.mec.biz.dal.dto.SimpleUserDto;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
-import com.ym.mec.common.dal.BaseDAO;
-import org.apache.ibatis.annotations.Param;
-
-import java.math.BigDecimal;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.Set;
 import java.util.Set;
 
 
+import org.apache.ibatis.annotations.Param;
+
+import com.ym.mec.biz.dal.dto.SimpleUserDto;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
+import com.ym.mec.common.dal.BaseDAO;
+
 public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicGroupPaymentCalenderDetail> {
 public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicGroupPaymentCalenderDetail> {
 
 
 	/**
 	/**
@@ -49,13 +49,6 @@ public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicG
 														 @Param("subjectId") Integer subjectId);
 														 @Param("subjectId") Integer subjectId);
 
 
 	/**
 	/**
-	 * 统计实际收款金额
-	 * @param id
-	 * @return
-	 */
-	BigDecimal sumActualAmount(@Param("id") Long id);
-
-	/**
 	 * 获取学生最后一期续费记录
 	 * 获取学生最后一期续费记录
 	 * @param musicGroupId
 	 * @param musicGroupId
 	 * @param userId
 	 * @param userId

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

@@ -2,7 +2,9 @@ package com.ym.mec.biz.dal.entity;
 
 
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.Date;
+import java.util.List;
 
 
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 
@@ -97,6 +99,8 @@ public class MusicGroupPaymentCalender {
 	private java.util.Date updateTime;
 	private java.util.Date updateTime;
 
 
 	private String studentIds;
 	private String studentIds;
+	
+	private List<MusicGroupPaymentCalenderCourseSettings> MusicGroupPaymentCalenderCourseSettingsList = new ArrayList<MusicGroupPaymentCalenderCourseSettings>();
 
 
 	public Integer getPaymentType() {
 	public Integer getPaymentType() {
 		return paymentType;
 		return paymentType;
@@ -250,6 +254,14 @@ public class MusicGroupPaymentCalender {
 		this.payUserType = payUserType;
 		this.payUserType = payUserType;
 	}
 	}
 
 
+	public List<MusicGroupPaymentCalenderCourseSettings> getMusicGroupPaymentCalenderCourseSettingsList() {
+		return MusicGroupPaymentCalenderCourseSettingsList;
+	}
+
+	public void setMusicGroupPaymentCalenderCourseSettingsList(List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList) {
+		MusicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalenderCourseSettingsList;
+	}
+
 	@Override
 	@Override
 	public String toString() {
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);
 		return ToStringBuilder.reflectionToString(this);

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

@@ -2,6 +2,8 @@ package com.ym.mec.biz.dal.entity;
 
 
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 
+import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
+
 /**
 /**
  * 对应数据库表(music_group_payment_calender_course_settings):
  * 对应数据库表(music_group_payment_calender_course_settings):
  */
  */
@@ -14,7 +16,7 @@ public class MusicGroupPaymentCalenderCourseSettings {
 	private Integer musicGroupPaymentCalenderId;
 	private Integer musicGroupPaymentCalenderId;
 	
 	
 	/** 课程类型 */
 	/** 课程类型 */
-	private String courseType;
+	private CourseScheduleType courseType;
 	
 	
 	/** 课程总时间 */
 	/** 课程总时间 */
 	private String courseTotalMinuties;
 	private String courseTotalMinuties;
@@ -53,11 +55,11 @@ public class MusicGroupPaymentCalenderCourseSettings {
 		return this.musicGroupPaymentCalenderId;
 		return this.musicGroupPaymentCalenderId;
 	}
 	}
 			
 			
-	public void setCourseType(String courseType){
+	public void setCourseType(CourseScheduleType courseType){
 		this.courseType = courseType;
 		this.courseType = courseType;
 	}
 	}
 	
 	
-	public String getCourseType(){
+	public CourseScheduleType getCourseType(){
 		return this.courseType;
 		return this.courseType;
 	}
 	}
 			
 			

+ 0 - 15
mec-biz/src/main/java/com/ym/mec/biz/dal/page/MusicCalenderQueryInfo.java

@@ -1,15 +0,0 @@
-package com.ym.mec.biz.dal.page;
-
-import com.ym.mec.common.page.QueryInfo;
-
-public class MusicCalenderQueryInfo extends QueryInfo {
-	private String musicGroupId;
-
-	public String getMusicGroupId() {
-		return musicGroupId;
-	}
-
-	public void setMusicGroupId(String musicGroupId) {
-		this.musicGroupId = musicGroupId;
-	}
-}

+ 38 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/MusicGroupPaymentCalenderQueryInfo.java

@@ -0,0 +1,38 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
+import com.ym.mec.common.page.QueryInfo;
+
+public class MusicGroupPaymentCalenderQueryInfo extends QueryInfo {
+	
+	private String musicGroupId;
+	
+	private PayUserType payUserType;
+	
+	private PaymentCalenderStatusEnum status;
+
+	public String getMusicGroupId() {
+		return musicGroupId;
+	}
+
+	public void setMusicGroupId(String musicGroupId) {
+		this.musicGroupId = musicGroupId;
+	}
+
+	public PayUserType getPayUserType() {
+		return payUserType;
+	}
+
+	public void setPayUserType(PayUserType payUserType) {
+		this.payUserType = payUserType;
+	}
+
+	public PaymentCalenderStatusEnum getStatus() {
+		return status;
+	}
+
+	public void setStatus(PaymentCalenderStatusEnum status) {
+		this.status = status;
+	}
+}

+ 5 - 16
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java

@@ -3,25 +3,21 @@ package com.ym.mec.biz.service;
 import java.util.List;
 import java.util.List;
 
 
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
-import com.ym.mec.biz.dal.page.MusicCalenderQueryInfo;
-import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 import com.ym.mec.common.service.BaseService;
 
 
 public interface MusicGroupPaymentCalenderService extends BaseService<Long, MusicGroupPaymentCalender> {
 public interface MusicGroupPaymentCalenderService extends BaseService<Long, MusicGroupPaymentCalender> {
 
 
 	/**
 	/**
-	 * 获取列表
-	 * @param queryInfo
+	 * 创建缴费信息
+	 * @param musicGroupPaymentCalenderList
 	 * @return
 	 * @return
 	 */
 	 */
-	PageInfo<MusicGroupPaymentCalender> queryDetailPage(MusicCalenderQueryInfo queryInfo);
+	boolean create(List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList);
 	
 	
 	/**
 	/**
-	 * 创建缴费信息
-	 * @param musicGroupPaymentCalender
-	 * @return
+	 * 更新缴费信息
 	 */
 	 */
-	boolean create(MusicGroupPaymentCalender musicGroupPaymentCalender);
+	int update(MusicGroupPaymentCalender musicGroupPaymentCalender);
 	
 	
 	/**
 	/**
 	 * 自动更新付款日历记录状态
 	 * 自动更新付款日历记录状态
@@ -48,13 +44,6 @@ public interface MusicGroupPaymentCalenderService extends BaseService<Long, Musi
 	void del(Long id);
 	void del(Long id);
 
 
 	/**
 	/**
-	 * 获取明细
-	 * @param id
-	 * @return
-	 */
-    Object getDetail(Long id);
-
-	/**
 	 * 推送乐团缴费提醒
 	 * 推送乐团缴费提醒
 	 * @param id
 	 * @param id
 	 * @param userIds
 	 * @param userIds

+ 208 - 101
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -8,6 +8,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.HashSet;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
@@ -17,26 +18,30 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 
 
 import com.ym.mec.biz.dal.dao.MusicGroupDao;
 import com.ym.mec.biz.dal.dao.MusicGroupDao;
+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.MusicGroupPaymentCalenderDao;
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
 import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
 import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.CalenderPushDto;
 import com.ym.mec.biz.dal.dto.CalenderPushDto;
+import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
 import com.ym.mec.biz.dal.entity.MusicGroup;
 import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.MusicGroupOrganizationCourseSettingsDetail;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 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.PaymentStatusEnum;
-import com.ym.mec.biz.dal.page.MusicCalenderQueryInfo;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
 import com.ym.mec.biz.service.SysConfigService;
 import com.ym.mec.biz.service.SysConfigService;
 import com.ym.mec.biz.service.SysMessageService;
 import com.ym.mec.biz.service.SysMessageService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.exception.BizException;
-import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.collection.MapUtil;
@@ -51,6 +56,13 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
 	private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
 	@Autowired
 	@Autowired
 	private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
 	private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
+	
+	@Autowired
+	private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
+	
+	@Autowired
+	private MusicGroupOrganizationCourseSettingsDetailDao musicGroupOrganizationCourseSettingsDetailDao;
+	
 	@Autowired
 	@Autowired
 	private MusicGroupDao musicGroupDao;
 	private MusicGroupDao musicGroupDao;
 	@Autowired
 	@Autowired
@@ -64,120 +76,219 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	}
 	}
 
 
 	@Override
 	@Override
-	public PageInfo<MusicGroupPaymentCalender> queryDetailPage(MusicCalenderQueryInfo queryInfo) {
-		PageInfo<MusicGroupPaymentCalender> pageInfo = queryPage(queryInfo);
-		List<MusicGroupPaymentCalender> rows = pageInfo.getRows();
-		if (rows.size() == 0) {
-			return pageInfo;
-		}
-		Set<Long> collect = rows.stream().map(e -> e.getId()).collect(Collectors.toSet());
-		Map<Long, Long> expectNumMap = MapUtil.convertIntegerMap(musicGroupPaymentCalenderDao.countExpectNum(collect));
-		Map<Long, Long> actualNumMap = MapUtil.convertIntegerMap(musicGroupPaymentCalenderDao.countActualNum(collect));
-		rows.forEach(e -> {
-			e.setActualNum(actualNumMap.get(e.getId()) == null ? 0 : actualNumMap.get(e.getId()).intValue());
-			e.setExpectNum(expectNumMap.get(e.getId()) == null ? 0 : expectNumMap.get(e.getId()).intValue());
-		});
-		return pageInfo;
+	@Transactional(rollbackFor = Exception.class)
+	public boolean create(List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList) {
+		if(musicGroupPaymentCalenderList == null || musicGroupPaymentCalenderList.size() == 0){
+			throw new BizException("请重新创建缴费记录");
+		}
+		
+		String musicGroupId = musicGroupPaymentCalenderList.get(0).getMusicGroupId();
+
+		MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
+		
+		if(musicGroup == null){
+			throw new BizException("乐团查询失败,请检查参数");
+		}
+
+		Date date = new Date();
+		Map<Integer, String> pushUserMap = new HashMap<Integer, String>();
+		MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
+		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
+
+		for(MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenderList){
+			musicGroupPaymentCalender.setCreateTime(date);
+			musicGroupPaymentCalender.setUpdateTime(date);
+			if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null) {
+				musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
+			}
+			int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPaymentValidStartDate(),
+					musicGroupPaymentCalender.getPaymentValidEndDate(), null);
+			if (count > 0) {
+				throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
+			}
+			
+			//查询默认课程费用
+			Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalender.getMusicGroupOrganizationCourseSettingId();
+			Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId).stream().collect(Collectors.toMap(MusicGroupOrganizationCourseSettingsDetail :: getCourseType, MusicGroupOrganizationCourseSettingsDetail :: getCourseCurrentPrice));
+			
+			//当前缴费的课程费用
+			Map<CourseScheduleType,BigDecimal> currentCoursePrice = musicGroupPaymentCalender.getMusicGroupPaymentCalenderCourseSettingsList().stream().collect(Collectors.toMap(MusicGroupPaymentCalenderCourseSettings :: getCourseType, MusicGroupPaymentCalenderCourseSettings :: getCourseCurrentPrice));
+			
+			BigDecimal totalPrice = new BigDecimal(0);
+			//相同类型的课程如果修改了课程费用,需要走审批
+			for(Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()){
+				if(defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0){
+					musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
+				}
+				totalPrice.add(entry.getValue());
+			}
+			
+			if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
+				if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
+					musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
+				} else if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
+					musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
+				} else {
+					musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
+				}
+				
+				//如果是报名,需要修改乐团状态
+				if (musicGroupPaymentCalender.getPaymentType() == 1) {
+					musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
+					musicGroup.setUpdateTime(date);
+					musicGroupDao.update(musicGroup);
+				}
+			}
+
+			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);
+					}
+				}
+				
+				//创建缴费明细
+				for(String studentId : sutdentIdList){
+					musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
+					musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
+					musicGroupPaymentCalenderDetail.setCreateTime(date);
+					musicGroupPaymentCalenderDetail.setExpectAmount(totalPrice);
+					musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
+					musicGroupPaymentCalenderDetail.setUpdateTime(date);
+					musicGroupPaymentCalenderDetail.setUserId(Integer.parseInt(studentId));
+					
+					musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
+				}
+			}
+		}
+
+		if (musicGroupPaymentCalenderDetailList.size() > 0) {
+			musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
+		}
+		
+		if(musicGroupPaymentCalenderList.size() > 0){
+			musicGroupPaymentCalenderDao.batchInsert(musicGroupPaymentCalenderList);
+		}
+		
+		// 发送续费通知
+		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 true;
 	}
 	}
 
 
 	@Override
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	@Transactional(rollbackFor = Exception.class)
-	public boolean create(MusicGroupPaymentCalender musicGroupPaymentCalender) {
+	public int update(MusicGroupPaymentCalender musicGroupPaymentCalender) {
 		String musicGroupId = musicGroupPaymentCalender.getMusicGroupId();
 		String musicGroupId = musicGroupPaymentCalender.getMusicGroupId();
 
 
-		musicGroupDao.getLocked(musicGroupId);
-
+		MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
+		
+		if(musicGroup == null){
+			throw new BizException("乐团查询失败,请检查参数");
+		}
+		
 		Date date = new Date();
 		Date date = new Date();
-		List<MusicGroupStudentFee> musicGroupStudentFeeList = null;
-
-		musicGroupPaymentCalender.setCreateTime(date);
+		
 		musicGroupPaymentCalender.setUpdateTime(date);
 		musicGroupPaymentCalender.setUpdateTime(date);
 		if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null) {
 		if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null) {
 			musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
 			musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
 		}
 		}
-		// 判断缴费开始时间、结束时间是否被其他缴费记录占用
-		int count = musicGroupPaymentCalenderDao.queryIntersectionByPaymentDate(musicGroupId, musicGroupPaymentCalender.getStartPaymentDate(),
-				musicGroupPaymentCalender.getDeadlinePaymentDate(), null);
-
-		// String format = DateUtil.format(musicGroupPaymentCalender.getStartPaymentDate(), DateUtil.DEFAULT_PATTERN);
-		// String format1 = DateUtil.format(musicGroupPaymentCalender.getDeadlinePaymentDate(), DateUtil.DEFAULT_PATTERN);
-		// int count = musicGroupPaymentCalenderDao.queryIntersectionByDate(musicGroupId, format,format1);
-		if (count > 0) {
-			throw new BizException("缴费日期存在冲突,请修改缴费日期");
-		}
-		count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPaymentValidStartDate(),
+		int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPaymentValidStartDate(),
 				musicGroupPaymentCalender.getPaymentValidEndDate(), null);
 				musicGroupPaymentCalender.getPaymentValidEndDate(), null);
 		if (count > 0) {
 		if (count > 0) {
 			throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
 			throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
 		}
 		}
-		if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
-			musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
-		} else if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
-			musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
-		} else {
-			musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
+		
+		//查询默认课程费用
+		Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalender.getMusicGroupOrganizationCourseSettingId();
+		Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId).stream().collect(Collectors.toMap(MusicGroupOrganizationCourseSettingsDetail :: getCourseType, MusicGroupOrganizationCourseSettingsDetail :: getCourseCurrentPrice));
+		
+		//当前缴费的课程费用
+		Map<CourseScheduleType,BigDecimal> currentCoursePrice = musicGroupPaymentCalender.getMusicGroupPaymentCalenderCourseSettingsList().stream().collect(Collectors.toMap(MusicGroupPaymentCalenderCourseSettings :: getCourseType, MusicGroupPaymentCalenderCourseSettings :: getCourseCurrentPrice));
+		
+		BigDecimal totalPrice = new BigDecimal(0);
+		//相同类型的课程如果修改了课程费用,需要走审批
+		for(Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()){
+			if(defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0){
+				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
+			}
+			totalPrice.add(entry.getValue());
 		}
 		}
-		// 统计缴费人数
-		musicGroupStudentFeeList = musicGroupStudentFeeDao.queryByMusicGroupId(musicGroupId, musicGroupPaymentCalender.getStudentIds());
-		if (musicGroupStudentFeeList == null) {
-			musicGroupStudentFeeList = new ArrayList<>();
+		
+		if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
+			if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
+				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
+			} else if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
+				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
+			} else {
+				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
+			}
+			
+			//如果是报名,需要修改乐团状态
+			if (musicGroupPaymentCalender.getPaymentType() == 1) {
+				musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
+				musicGroup.setUpdateTime(date);
+				musicGroupDao.update(musicGroup);
+			}
 		}
 		}
-		musicGroupPaymentCalender.setExpectNum(musicGroupStudentFeeList.size());
-
-		this.insert(musicGroupPaymentCalender);
-
-		List<MusicGroupStudentFee> updateMusicGroupStudentFeeList = new ArrayList<MusicGroupStudentFee>();
-
 		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
 		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
+		Map<Integer, String> pushUserMap = new HashMap<Integer, String>();
 
 
-		if (musicGroupStudentFeeList != null && musicGroupStudentFeeList.size() > 0) {
-			Set<Integer> studentIds = new HashSet<>();
+		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;
 			MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
-			// 创建缴费明细
-			for (MusicGroupStudentFee mgsf : musicGroupStudentFeeList) {
+			for(String studentId : sutdentIdList){
 				musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
 				musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
 				musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
 				musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
 				musicGroupPaymentCalenderDetail.setCreateTime(date);
 				musicGroupPaymentCalenderDetail.setCreateTime(date);
-				musicGroupPaymentCalenderDetail.setExpectAmount(mgsf.getCourseFee());
+				musicGroupPaymentCalenderDetail.setExpectAmount(totalPrice);
 				musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
 				musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
-				if (mgsf.getCourseFee().doubleValue() != 0) {
-					studentIds.add(mgsf.getUserId());
-				}
 				musicGroupPaymentCalenderDetail.setUpdateTime(date);
 				musicGroupPaymentCalenderDetail.setUpdateTime(date);
-				musicGroupPaymentCalenderDetail.setUserId(mgsf.getUserId());
+				musicGroupPaymentCalenderDetail.setUserId(Integer.parseInt(studentId));
+				
 				musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
 				musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
 			}
 			}
-			if (musicGroupPaymentCalender.getStatus() == PaymentCalenderStatusEnum.OPEN) {
-				// 更新学员缴费状态
-				for (MusicGroupStudentFee mgsf : musicGroupStudentFeeList) {
-					mgsf.setPaymentStatus(PaymentStatus.NON_PAYMENT);
-					mgsf.setUpdateTime(date);
-					updateMusicGroupStudentFeeList.add(mgsf);
-				}
-				if (studentIds.size() > 0) {
-					Map<Integer, String> push = new HashMap<>();
-					for (Integer userId : studentIds) {
-						push.put(userId, userId + "");
-					}
-					MusicGroup musicGroup = musicGroupDao.get(musicGroupPaymentCalender.getMusicGroupId());
-					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, push,
-							null, 0, memo, "STUDENT", musicGroup.getName());
-				}
-			}
 		}
 		}
+		
+		musicGroupPaymentCalenderDao.update(musicGroupPaymentCalender);
 
 
 		if (musicGroupPaymentCalenderDetailList.size() > 0) {
 		if (musicGroupPaymentCalenderDetailList.size() > 0) {
 			musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
 			musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
 		}
 		}
-
-		if (updateMusicGroupStudentFeeList.size() > 0) {
-			musicGroupStudentFeeDao.batchUpdate(updateMusicGroupStudentFeeList);
+		
+		// 发送续费通知
+		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 true;
+		
+		return 1;
 	}
 	}
 
 
 	@Override
 	@Override
@@ -439,27 +550,23 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		if (calender == null) {
 		if (calender == null) {
 			throw new BizException("缴费信息不存在");
 			throw new BizException("缴费信息不存在");
 		}
 		}
-		if (calender.getStatus() == null || calender.getStatus() != PaymentCalenderStatusEnum.NO) {
-			throw new BizException("删除失败,缴费状态不匹配");
+		if (calender.getStatus() != PaymentCalenderStatusEnum.NO || calender.getStatus() != PaymentCalenderStatusEnum.REJECT) {
+			throw new BizException("删除失败,只有“拒绝”或“未开启缴费”状态才能删除");
+		}
+
+		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = musicGroupPaymentCalenderDetailDao.queryByCalenderId(id);
+		if (musicGroupPaymentCalenderDetailList != null && musicGroupPaymentCalenderDetailList.size() > 0) {
+			List<MusicGroupPaymentCalenderDetail> paidList = musicGroupPaymentCalenderDetailList.stream()
+					.filter(MusicGroupPaymentCalenderDetail -> MusicGroupPaymentCalenderDetail.getPaymentStatus() != PaymentStatus.NON_PAYMENT)
+					.collect(Collectors.toList());
+			if (paidList.size() > 0) {
+				throw new BizException("存在已缴费的学生不能删除");
+			}
 		}
 		}
+
 		musicGroupPaymentCalenderDao.delete(id);
 		musicGroupPaymentCalenderDao.delete(id);
 		musicGroupPaymentCalenderDetailDao.deleteByCalenderId(id);
 		musicGroupPaymentCalenderDetailDao.deleteByCalenderId(id);
-	}
-
-	@Override
-	public Object getDetail(Long id) {
-		MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(id);
-		Set<Long> set = new HashSet<>();
-		set.add(id);
-		Map<Long, Long> expectNumMap = MapUtil.convertIntegerMap(musicGroupPaymentCalenderDao.countExpectNum(set));
-		Map<Long, Long> actualNumMap = MapUtil.convertIntegerMap(musicGroupPaymentCalenderDao.countActualNum(set));
-		calender.setActualNum(actualNumMap.get(id) == null ? 0 : actualNumMap.get(id).intValue());
-		calender.setExpectNum(expectNumMap.get(id) == null ? 0 : expectNumMap.get(id).intValue());
-		BigDecimal sumActualAmount = musicGroupPaymentCalenderDetailDao.sumActualAmount(id);
-		Map<String, Object> result = new HashMap<>(2);
-		result.put("calender", calender);
-		result.put("sumActualAmount", sumActualAmount);
-		return result;
+		musicGroupPaymentCalenderCourseSettingsDao.deleteByMusicGroupPaymentCalenderId(id);
 	}
 	}
 
 
 	@Override
 	@Override

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupOrganizationCourseSettingsDetailMapper.xml

@@ -112,4 +112,8 @@
     <delete id="deleteBySettingId" parameterType="java.lang.Integer">
     <delete id="deleteBySettingId" parameterType="java.lang.Integer">
         DELETE FROM music_group_organization_course_settings_detail WHERE music_group_organization_course_settings_id_ = #{settingId}
         DELETE FROM music_group_organization_course_settings_detail WHERE music_group_organization_course_settings_id_ = #{settingId}
     </delete>
     </delete>
+
+    <select id="queryByMusicGroupOrganizationCourseSettingsId" resultMap="MusicGroupOrganizationCourseSettingsDetail">
+        SELECT * FROM music_group_organization_course_settings_detail where music_group_organization_course_settings_id_ = #{musicGroupOrganizationCourseSettingsId}
+    </select>
 </mapper>
 </mapper>

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

@@ -2,113 +2,101 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!-- 这个文件是自动生成的。 不要修改此文件。所有改动将在下次重新自动生成时丢失。 -->
 <!-- 这个文件是自动生成的。 不要修改此文件。所有改动将在下次重新自动生成时丢失。 -->
 <mapper
 <mapper
-        namespace="com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderCourseSettingsDao">
+	namespace="com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderCourseSettingsDao">
 
 
-    <resultMap
-            type="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings"
-            id="MusicGroupPaymentCalenderCourseSettings">
-        <result column="id_" property="id"/>
-        <result column="music_group_payment_calender_id_" property="musicGroupPaymentCalenderId"/>
-        <result column="course_type_" property="courseType"/>
-        <result column="course_total_minuties_" property="courseTotalMinuties"/>
-        <result column="unit_price_" property="unitPrice"/>
-        <result column="course_original_price_" property="courseOriginalPrice"/>
-        <result column="course_current_price_" property="courseCurrentPrice"/>
-        <result column="is_student_optional_" property="isStudentOptional"/>
-        <result column="create_time_" property="createTime"/>
-        <result column="update_time_" property="updateTime"/>
-    </resultMap>
+	<resultMap
+		type="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings"
+		id="MusicGroupPaymentCalenderCourseSettings">
+		<result column="id_" property="id" />
+		<result column="music_group_payment_calender_id_" property="musicGroupPaymentCalenderId" />
+		<result column="course_type_" property="courseType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
+		<result column="course_total_minuties_" property="courseTotalMinuties" />
+		<result column="unit_price_" property="unitPrice" />
+		<result column="course_original_price_" property="courseOriginalPrice" />
+		<result column="course_current_price_" property="courseCurrentPrice" />
+		<result column="is_student_optional_" property="isStudentOptional" />
+		<result column="create_time_" property="createTime" />
+		<result column="update_time_" property="updateTime" />
+	</resultMap>
 
 
-    <!-- 根据主键查询一条记录 -->
-    <select id="get" resultMap="MusicGroupPaymentCalenderCourseSettings">
-        SELECT *
-        FROM music_group_payment_calender_course_settings
-        WHERE id_ = #{id}
-    </select>
+	<!-- 根据主键查询一条记录 -->
+	<select id="get" resultMap="MusicGroupPaymentCalenderCourseSettings">
+		SELECT * FROM music_group_payment_calender_course_settings WHERE id_ = #{id}
+	</select>
 
 
-    <!-- 全查询 -->
-    <select id="findAll" resultMap="MusicGroupPaymentCalenderCourseSettings">
-        SELECT *
-        FROM music_group_payment_calender_course_settings
-        ORDER BY id_
-    </select>
+	<!-- 全查询 -->
+	<select id="findAll" resultMap="MusicGroupPaymentCalenderCourseSettings">
+		SELECT * FROM music_group_payment_calender_course_settings ORDER BY id_
+	</select>
 
 
-    <!-- 向数据库增加一条记录 -->
-    <insert id="insert"
-            parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings"
-            useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-        <!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval
-            AS ID FROM DUAL </selectKey> -->
-        INSERT INTO music_group_payment_calender_course_settings
-        (id_,music_group_payment_calender_id_,course_type_,course_total_minuties_,unit_price_,course_original_price_,course_current_price_,is_student_optional_,create_time_,update_time_)
-        VALUES(#{id},#{musicGroupPaymentCalenderId},#{courseType},#{courseTotalMinuties},#{unitPrice},#{courseOriginalPrice},#{courseCurrentPrice},#{isStudentOptional},#{createTime},#{updateTime})
-    </insert>
+	<!-- 向数据库增加一条记录 -->
+	<insert id="insert"
+		parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings"
+		useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+		<!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval 
+			AS ID FROM DUAL </selectKey> -->
+		INSERT INTO music_group_payment_calender_course_settings
+		(id_,music_group_payment_calender_id_,course_type_,course_total_minuties_,unit_price_,course_original_price_,course_current_price_,is_student_optional_,create_time_,update_time_)
+		VALUES(#{id},#{musicGroupPaymentCalenderId},#{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{courseTotalMinuties},#{unitPrice},#{courseOriginalPrice},#{courseCurrentPrice},#{isStudentOptional},#{createTime},#{updateTime})
+	</insert>
 
 
-    <!-- 根据主键查询一条记录 -->
-    <update id="update"
-            parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings">
-        UPDATE music_group_payment_calender_course_settings
-        <set>
-            <if test="isStudentOptional != null">
-                is_student_optional_ = #{isStudentOptional},
-            </if>
-            <if test="id != null">
-                id_ = #{id},
-            </if>
-            <if test="unitPrice != null">
-                unit_price_ = #{unitPrice},
-            </if>
-            <if test="updateTime != null">
-                update_time_ = #{updateTime},
-            </if>
-            <if test="courseCurrentPrice != null">
-                course_current_price_ = #{courseCurrentPrice},
-            </if>
-            <if test="musicGroupPaymentCalenderId != null">
-                music_group_payment_calender_id_ = #{musicGroupPaymentCalenderId},
-            </if>
-            <if test="courseType != null">
-                course_type_ = #{courseType},
-            </if>
-            <if test="courseOriginalPrice != null">
-                course_original_price_ = #{courseOriginalPrice},
-            </if>
-            <if test="courseTotalMinuties != null">
-                course_total_minuties_ = #{courseTotalMinuties},
-            </if>
-            <if test="createTime != null">
-                create_time_ = #{createTime},
-            </if>
-        </set>
-        WHERE id_ = #{id}
-    </update>
+	<!-- 根据主键查询一条记录 -->
+	<update id="update"
+		parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings">
+		UPDATE music_group_payment_calender_course_settings
+		<set>
+			<if test="isStudentOptional != null">
+				is_student_optional_ = #{isStudentOptional},
+			</if>
+			<if test="id != null">
+				id_ = #{id},
+			</if>
+			<if test="unitPrice != null">
+				unit_price_ = #{unitPrice},
+			</if>
+			<if test="updateTime != null">
+				update_time_ = #{updateTime},
+			</if>
+			<if test="courseCurrentPrice != null">
+				course_current_price_ = #{courseCurrentPrice},
+			</if>
+			<if test="musicGroupPaymentCalenderId != null">
+				music_group_payment_calender_id_ = #{musicGroupPaymentCalenderId},
+			</if>
+			<if test="courseType != null">
+				course_type_ = #{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+			</if>
+			<if test="courseOriginalPrice != null">
+				course_original_price_ = #{courseOriginalPrice},
+			</if>
+			<if test="courseTotalMinuties != null">
+				course_total_minuties_ = #{courseTotalMinuties},
+			</if>
+			<if test="createTime != null">
+				create_time_ = #{createTime},
+			</if>
+		</set>
+		WHERE id_ = #{id}
+	</update>
 
 
-    <!-- 根据主键删除一条记录 -->
-    <delete id="delete">
-        DELETE
-        FROM music_group_payment_calender_course_settings
-        WHERE id_ = #{id}
-    </delete>
+	<!-- 根据主键删除一条记录 -->
+	<delete id="delete">
+		DELETE FROM music_group_payment_calender_course_settings WHERE id_ = #{id}
+	</delete>
 
 
-    <!-- 分页查询 -->
-    <select id="queryPage" resultMap="MusicGroupPaymentCalenderCourseSettings"
-            parameterType="map">
-        SELECT * FROM music_group_payment_calender_course_settings ORDER BY id_
-        <include refid="global.limit"/>
-    </select>
+	<!-- 分页查询 -->
+	<select id="queryPage" resultMap="MusicGroupPaymentCalenderCourseSettings"
+		parameterType="map">
+		SELECT * FROM music_group_payment_calender_course_settings ORDER BY id_
+		<include refid="global.limit" />
+	</select>
 
 
-    <!-- 查询当前表的总记录数 -->
-    <select id="queryCount" resultType="int">
-        SELECT COUNT(*)
-        FROM music_group_payment_calender_course_settings
-    </select>
+	<!-- 查询当前表的总记录数 -->
+	<select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM music_group_payment_calender_course_settings
+	</select>
 
 
-    <select id="getMusicGroupRegCalenderCourseSettings" resultMap="MusicGroupPaymentCalenderCourseSettings">
-        SELECT mgpccs.*
-        FROM music_group_payment_calender mgpc
-                 LEFT JOIN music_group_payment_calender_course_settings mgpccs
-                           ON mgpccs.music_group_payment_calender_id_ = mgpc.id_
-        WHERE mgpc.music_group_id_ = #{musicGroupId}
-          AND mgpc.payment_type_ = 1
-    </select>
+	<delete id="deleteByMusicGroupPaymentCalenderId">
+		DELETE FROM music_group_payment_calender_course_settings WHERE music_group_payment_calender_id_ = #{musicGroupPaymentCalenderId}
+	</delete>
 </mapper>
 </mapper>

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

@@ -167,8 +167,7 @@
 		AND user_id_ = #{userId} AND payment_status_ = 'NON_PAYMENT'
 		AND user_id_ = #{userId} AND payment_status_ = 'NON_PAYMENT'
 	</delete>
 	</delete>
     <delete id="deleteByCalenderId">
     <delete id="deleteByCalenderId">
-		DELETE FROM music_group_payment_calender_detail
-		WHERE music_group_payment_calender_id_ = #{id} AND payment_status_ = 'NON_PAYMENT'
+		DELETE FROM music_group_payment_calender_detail WHERE music_group_payment_calender_id_ = #{id}
 	</delete>
 	</delete>
 
 
     <!-- 分页查询 -->
     <!-- 分页查询 -->
@@ -248,10 +247,6 @@
 		AND mgstf.remain_network_class_times_>0
 		AND mgstf.remain_network_class_times_>0
 		ORDER BY su.id_
 		ORDER BY su.id_
 	</select>
 	</select>
-	<select id="sumActualAmount" resultType="java.math.BigDecimal">
-		SELECT SUM(mgpcd.actual_amount_) FROM music_group_payment_calender_detail mgpcd
-		WHERE mgpcd.music_group_payment_calender_id_ = #{id}
-	</select>
 
 
 	<select id="getUserLastCalenderDetail" resultMap="MusicGroupPaymentCalenderDetail">
 	<select id="getUserLastCalenderDetail" resultMap="MusicGroupPaymentCalenderDetail">
 		SELECT * FROM music_group_payment_calender_detail mgpcd
 		SELECT * FROM music_group_payment_calender_detail mgpcd

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

@@ -48,6 +48,19 @@
         #{paymentValidStartDate},#{paymentValidEndDate},#{paymentPattern},#{paymentType})
         #{paymentValidStartDate},#{paymentValidEndDate},#{paymentPattern},#{paymentType})
     </insert>
     </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_)
+        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})
+        </foreach>
+    </insert>
+
     <!-- 根据主键查询一条记录 -->
     <!-- 根据主键查询一条记录 -->
     <update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender">
     <update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender">
         UPDATE music_group_payment_calender
         UPDATE music_group_payment_calender
@@ -162,15 +175,35 @@
     <!-- 分页查询 -->
     <!-- 分页查询 -->
     <select id="queryPage" resultMap="MusicGroupPaymentCalender" parameterType="map">
     <select id="queryPage" resultMap="MusicGroupPaymentCalender" parameterType="map">
         SELECT * FROM music_group_payment_calender mgpc
         SELECT * FROM music_group_payment_calender mgpc
-        WHERE mgpc.music_group_id_ = #{musicGroupId}
-        ORDER BY mgpc.update_time_ DESC
+        <where>
+        	<if test="musicGroupId != null">
+        		and mgpc.music_group_id_ = #{musicGroupId}
+        	</if>
+        	<if test="musicGroupId != null">
+        		and mgpc.pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        	</if>
+        	<if test="musicGroupId != null">
+        		and mgpc.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        	</if>
+        </where>
+        ORDER BY mgpc.payment_valid_start_date_ DESC
         <include refid="global.limit"/>
         <include refid="global.limit"/>
     </select>
     </select>
 
 
     <!-- 查询当前表的总记录数 -->
     <!-- 查询当前表的总记录数 -->
     <select id="queryCount" resultType="int">
     <select id="queryCount" resultType="int">
 		SELECT COUNT(mgpc.id_) FROM music_group_payment_calender mgpc
 		SELECT COUNT(mgpc.id_) FROM music_group_payment_calender mgpc
-        WHERE mgpc.music_group_id_ = #{musicGroupId}
+        <where>
+        	<if test="musicGroupId != null">
+        		and mgpc.music_group_id_ = #{musicGroupId}
+        	</if>
+        	<if test="musicGroupId != null">
+        		and mgpc.pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        	</if>
+        	<if test="musicGroupId != null">
+        		and mgpc.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        	</if>
+        </where>
 	</select>
 	</select>
 	
 	
     <select id="findByMusicGroupId" resultMap="MusicGroupPaymentCalender">
     <select id="findByMusicGroupId" resultMap="MusicGroupPaymentCalender">
@@ -204,23 +237,6 @@
             AND mgpc.id_ != #{calenderId}
             AND mgpc.id_ != #{calenderId}
         </if>
         </if>
     </select>
     </select>
-    <select id="countExpectNum" resultType="java.util.Map">
-        SELECT mgpcd.music_group_payment_calender_id_ 'key',COUNT(DISTINCT mgpcd.user_id_) 'value' FROM music_group_payment_calender_detail mgpcd
-        WHERE mgpcd.music_group_payment_calender_id_ IN
-        <foreach collection="collect" item="item" open="(" close=")" separator=",">
-            #{item}
-        </foreach>
-        GROUP BY mgpcd.music_group_payment_calender_id_
-    </select>
-    <select id="countActualNum" resultType="java.util.Map">
-        SELECT mgpcd.music_group_payment_calender_id_ 'key',COUNT(DISTINCT mgpcd.user_id_) 'value' FROM music_group_payment_calender_detail mgpcd
-        WHERE mgpcd.music_group_payment_calender_id_ IN
-        <foreach collection="collect" item="item" open="(" close=")" separator=",">
-            #{item}
-        </foreach>
-        AND mgpcd.payment_status_ = 'PAID_COMPLETED'
-        GROUP BY mgpcd.music_group_payment_calender_id_
-    </select>
     
     
     <select id="getLastStartOne" resultMap="MusicGroupPaymentCalender">
     <select id="getLastStartOne" resultMap="MusicGroupPaymentCalender">
         SELECT * FROM music_group_payment_calender WHERE music_group_id_ = #{musicGroupId} ORDER BY start_payment_date_ DESC LIMIT 1
         SELECT * FROM music_group_payment_calender WHERE music_group_id_ = #{musicGroupId} ORDER BY start_payment_date_ DESC LIMIT 1

+ 15 - 29
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java

@@ -1,11 +1,12 @@
 package com.ym.mec.web.controller;
 package com.ym.mec.web.controller;
 
 
+import java.util.List;
+
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 
 
-import java.util.List;
-
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -14,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
-import com.ym.mec.biz.dal.page.MusicCalenderQueryInfo;
+import com.ym.mec.biz.dal.page.MusicGroupPaymentCalenderQueryInfo;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.controller.BaseController;
 
 
@@ -26,19 +27,18 @@ public class MusicGroupPaymentCalenderController extends BaseController {
     @Autowired
     @Autowired
     private MusicGroupPaymentCalenderService musicGroupPaymentCalenderService;
     private MusicGroupPaymentCalenderService musicGroupPaymentCalenderService;
 
 
-    @ApiOperation(value = "新增乐团缴费日历")
-    @PostMapping("/add")
-    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/add')")
-    public Object add(MusicGroupPaymentCalender musicGroupPaymentCalender) {
-        musicGroupPaymentCalenderService.create(musicGroupPaymentCalender);
-        return succeed();
+    @ApiOperation(value = "分页查询乐团缴费日历列表")
+    @GetMapping(value = "/queryPage", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/queryPage')")
+    public Object queryPage(MusicGroupPaymentCalenderQueryInfo queryInfo) {
+        return succeed(musicGroupPaymentCalenderService.queryPage(queryInfo));
     }
     }
 
 
-    @ApiOperation(value = "批量新增、修改乐团缴费周期")
-    @PostMapping("/batchAdd")
-    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/batchAdd')")
-    public Object batchAdd(@RequestBody List<MusicGroupPaymentCalender> musicGroupPaymentCalenders) {
-        musicGroupPaymentCalenderService.batchInsert(musicGroupPaymentCalenders);
+    @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 List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList) {
+        musicGroupPaymentCalenderService.create(musicGroupPaymentCalenderList);
         return succeed();
         return succeed();
     }
     }
 
 
@@ -54,24 +54,10 @@ public class MusicGroupPaymentCalenderController extends BaseController {
     @PostMapping("/updateStartTime")
     @PostMapping("/updateStartTime")
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/updateStartTime')")
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/updateStartTime')")
     public Object updateStartTime(MusicGroupPaymentCalender paymentCalender) {
     public Object updateStartTime(MusicGroupPaymentCalender paymentCalender) {
-        musicGroupPaymentCalenderService.updateStartTime(paymentCalender);
+        musicGroupPaymentCalenderService.update(paymentCalender);
         return succeed();
         return succeed();
     }
     }
 
 
-    @ApiOperation(value = "分页查询乐团缴费日历列表")
-    @GetMapping("/queryPage")
-    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/queryPage')")
-    public Object queryPage(MusicCalenderQueryInfo queryInfo) {
-        return succeed(musicGroupPaymentCalenderService.queryDetailPage(queryInfo));
-    }
-
-    @ApiOperation(value = "获取缴费信息")
-    @GetMapping("/getDetail")
-    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/getDetail')")
-    public Object getDetail(Long id) {
-        return succeed(musicGroupPaymentCalenderService.getDetail(id));
-    }
-
     @ApiOperation(value = "开启缴费的推送(暂时不用,没写完)")
     @ApiOperation(value = "开启缴费的推送(暂时不用,没写完)")
     @GetMapping("/paymentPush")
     @GetMapping("/paymentPush")
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/paymentPush')")
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/paymentPush')")