Browse Source

Merge remote-tracking branch 'origin/master'

Joe 5 years ago
parent
commit
8579b6e46b
17 changed files with 305 additions and 58 deletions
  1. 23 5
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDao.java
  2. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDetailDao.java
  3. 7 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupStudentFeeDao.java
  4. 32 8
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderDetail.java
  5. 30 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupStudentFee.java
  6. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/MusicCalenderDetailQueryInfo.java
  7. 2 2
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderDetailService.java
  8. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupStudentFeeService.java
  9. 3 3
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java
  10. 5 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  11. 26 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  12. 10 6
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupStudentFeeServiceImpl.java
  13. 44 24
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml
  14. 10 0
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml
  15. 42 3
      mec-biz/src/main/resources/config/mybatis/MusicGroupStudentFeeMapper.xml
  16. 4 4
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderDetailController.java
  17. 40 0
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupStudentFeeController.java

+ 23 - 5
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDao.java

@@ -1,12 +1,13 @@
 package com.ym.mec.biz.dal.dao;
 
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
-import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
-import com.ym.mec.common.dal.BaseDAO;
+import java.util.Date;
+import java.util.List;
 
 import org.apache.ibatis.annotations.Param;
 
-import java.util.List;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
+import com.ym.mec.common.dal.BaseDAO;
 
 public interface MusicGroupPaymentCalenderDao extends BaseDAO<Long, MusicGroupPaymentCalender> {
 
@@ -29,7 +30,7 @@ public interface MusicGroupPaymentCalenderDao extends BaseDAO<Long, MusicGroupPa
 	 * @param musicGroupId
 	 */
 	void batchAdd(@Param("calender") List<Integer> calender, @Param("musicGroupId") String musicGroupId);
-	
+
 	/**
 	 * 批量修改
 	 * @param musicGroupPaymentCalenderList
@@ -43,4 +44,21 @@ public interface MusicGroupPaymentCalenderDao extends BaseDAO<Long, MusicGroupPa
 	 * @return
 	 */
 	List<MusicGroupPaymentCalender> queryByPaymentStatus(List<PaymentStatusEnum> status);
+	
+	/**
+	 * 获取缴费信息锁
+	 * @param id
+	 * @return
+	 */
+	MusicGroupPaymentCalender getForLock(@Param("id") Long id);
+
+	/**
+	 * 根据指定乐团的缴费日期查询交集
+	 * @param musicGroupId 乐团编号
+	 * @param startPaymentDate 开始缴费日期
+	 * @param deadlinePaymentDate 截止缴费日期
+	 * @return
+	 */
+	int queryIntersectionByPaymentDate(@Param("musicGroupId") String musicGroupId, @Param("startPaymentDate") Date startPaymentDate,
+			@Param("deadlinePaymentDate") Date deadlinePaymentDate);
 }

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

@@ -52,4 +52,13 @@ public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicG
 	 * @return
 	 */
 	BigDecimal sumActualAmount(@Param("id") Long id);
+
+	/**
+	 * 获取学生最后一期续费记录
+	 * @param musicGroupId
+	 * @param userId
+	 * @return
+	 */
+	MusicGroupPaymentCalenderDetail getUserLastCalenderDetail(@Param("musicGroupId") String musicGroupId, @Param("userId") Integer userId);
+
 }

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupStudentFeeDao.java

@@ -168,4 +168,11 @@ public interface MusicGroupStudentFeeDao extends BaseDAO<Long, MusicGroupStudent
 	 * @param musicGroupId
 	 */
 	void updateCalender(@Param("userId") Integer userId, @Param("musicGroupId") String musicGroupId);
+
+	/**
+	 * 修改课程费用
+	 * @param ids
+	 * @param courseFee
+	 */
+    void batchUpdateCourseFee(@Param("ids") String ids, @Param("courseFee") BigDecimal courseFee);
 }

+ 32 - 8
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderDetail.java

@@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
 
+import java.util.Date;
+
 /**
  * 对应数据库表(music_group_payment_calender_detail):
  */
@@ -36,6 +38,12 @@ public class MusicGroupPaymentCalenderDetail {
 	
 	/**  */
 	private java.util.Date payTime;
+
+	/**  */
+	private java.util.Date startPaymentDate;
+
+	/**  */
+	private java.util.Date deadlinePaymentDate;
 	
 	/**  */
 	private java.util.Date updateTime;
@@ -43,6 +51,26 @@ public class MusicGroupPaymentCalenderDetail {
 	/**  */
 	private java.util.Date createTime;
 
+	private SysUser sysUser = new SysUser();
+
+	private StudentRegistration studentRegistration = new StudentRegistration();
+
+	public Date getStartPaymentDate() {
+		return startPaymentDate;
+	}
+
+	public void setStartPaymentDate(Date startPaymentDate) {
+		this.startPaymentDate = startPaymentDate;
+	}
+
+	public Date getDeadlinePaymentDate() {
+		return deadlinePaymentDate;
+	}
+
+	public void setDeadlinePaymentDate(Date deadlinePaymentDate) {
+		this.deadlinePaymentDate = deadlinePaymentDate;
+	}
+
 	public Integer getOpen() {
 		return open;
 	}
@@ -51,16 +79,12 @@ public class MusicGroupPaymentCalenderDetail {
 		this.open = open;
 	}
 
-	private SysUser sysUser = new SysUser();
-
-	private Student student = new Student();
-
-	public Student getStudent() {
-		return student;
+	public StudentRegistration getStudentRegistration() {
+		return studentRegistration;
 	}
 
-	public void setStudent(Student student) {
-		this.student = student;
+	public void setStudentRegistration(StudentRegistration studentRegistration) {
+		this.studentRegistration = studentRegistration;
 	}
 
 	public SysUser getSysUser() {

+ 30 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupStudentFee.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.entity;
 
+import com.ym.mec.auth.api.entity.SysUser;
 import io.swagger.annotations.ApiModelProperty;
 import java.math.BigDecimal;
 import java.util.Date;
@@ -76,6 +77,12 @@ public class MusicGroupStudentFee {
 	/**  */
 	private java.util.Date updateTime;
 
+	private SysUser sysUser;
+
+	private String subjectName;
+
+	private Integer remainNetworkClassTimes;
+
 	public MusicGroupStudentFee(String musicGroupId, Integer userId, Integer subjectId,
 								BigDecimal courseFee, Date nextPaymentDate, BigDecimal temporaryCourseFee,PaymentStatus paymentStatus) {
 		this.musicGroupId = musicGroupId;
@@ -91,6 +98,22 @@ public class MusicGroupStudentFee {
 	public MusicGroupStudentFee() {
 	}
 
+	public SysUser getSysUser() {
+		return sysUser;
+	}
+
+	public void setSysUser(SysUser sysUser) {
+		this.sysUser = sysUser;
+	}
+
+	public String getSubjectName() {
+		return subjectName;
+	}
+
+	public void setSubjectName(String subjectName) {
+		this.subjectName = subjectName;
+	}
+
 	public Integer getIsLock() {
 		return isLock;
 	}
@@ -203,6 +226,13 @@ public class MusicGroupStudentFee {
 		this.temporaryCourseFee = temporaryCourseFee;
 	}
 
+	public Integer getRemainNetworkClassTimes() {
+		return remainNetworkClassTimes;
+	}
+
+	public void setRemainNetworkClassTimes(Integer remainNetworkClassTimes) {
+		this.remainNetworkClassTimes = remainNetworkClassTimes;
+	}
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/MusicCalenderDetailQueryInfo.java

@@ -11,8 +11,18 @@ public class MusicCalenderDetailQueryInfo extends QueryInfo {
 
 	private Integer subjectId;
 
+	private String musicGroupId;
+
 	private Long id;
 
+	public String getMusicGroupId() {
+		return musicGroupId;
+	}
+
+	public void setMusicGroupId(String musicGroupId) {
+		this.musicGroupId = musicGroupId;
+	}
+
 	public Integer getSubjectId() {
 		return subjectId;
 	}

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

@@ -11,11 +11,11 @@ public interface MusicGroupPaymentCalenderDetailService extends BaseService<Long
 
     /**
      * 修改学员预计缴费金额
-     * @param actualAmount
+     * @param expectAmount
      * @param ids
      * @return
      */
-    void updateActualAmount(BigDecimal actualAmount,String ids);
+    void updateExpectAmount(BigDecimal expectAmount,String ids);
 
     /**
      * 开启缴费

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupStudentFeeService.java

@@ -4,6 +4,8 @@ import com.ym.mec.biz.dal.dto.UpdateStudentFeeDto;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
 import com.ym.mec.common.service.BaseService;
 
+import java.math.BigDecimal;
+
 public interface MusicGroupStudentFeeService extends BaseService<Long, MusicGroupStudentFee> {
 
 	/**
@@ -33,4 +35,10 @@ public interface MusicGroupStudentFeeService extends BaseService<Long, MusicGrou
 	void updateStudentFeeIsLock(UpdateStudentFeeDto studentFeeDto);
 
 
+	/**
+	 * 批量修改课程费用
+	 * @param ids
+	 * @param courseFee
+	 */
+    void batchUpdateCourseFee(String ids, BigDecimal courseFee);
 }

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

@@ -35,8 +35,8 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public void updateActualAmount(BigDecimal actualAmount,String ids) {
-		if(actualAmount == null || StringUtils.isEmpty(ids)){
+	public void updateExpectAmount(BigDecimal expectAmount,String ids) {
+		if(expectAmount == null || StringUtils.isEmpty(ids)){
 			throw new BizException("参数校验失败");
 		}
 		String[] split = ids.split(",");
@@ -51,7 +51,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 				throw new BizException("修改失败,缴费状态不匹配");
 			}
 			e.setUpdateTime(date);
-			e.setActualAmount(actualAmount);
+			e.setExpectAmount(expectAmount);
 		});
 		musicGroupPaymentCalenderDetailDao.batchUpdate(calenderDetails);
 	}

+ 5 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -45,7 +45,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public boolean create(MusicGroupPaymentCalender musicGroupPaymentCalender) {
-		//判断缴费开始时间、结束时间是否被其他缴费记录占用
 		
 		Date date = new Date();
 		List<MusicGroupStudentFee> list = null;
@@ -53,6 +52,11 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		musicGroupPaymentCalender.setCreateTime(date);
 		musicGroupPaymentCalender.setUpdateTime(date);
 		musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
+		//判断缴费开始时间、结束时间是否被其他缴费记录占用
+		int count = musicGroupPaymentCalenderDao.queryIntersectionByPaymentDate(musicGroupPaymentCalender.getMusicGroupId(), musicGroupPaymentCalender.getStartPaymentDate(), musicGroupPaymentCalender.getDeadlinePaymentDate());
+		if(count > 0){
+			throw new BizException("缴费时间存在冲突,请修改缴费开始日期");
+		}
 		if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
 			musicGroupPaymentCalender.setPaymentStatus(PaymentStatusEnum.YES);
 		} else if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {

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

@@ -148,6 +148,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     private GoodsService goodsService;
     @Autowired
     private ClassGroupStudentMapperService classGroupStudentMapperService;
+    @Autowired
+    private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
 
     @Autowired
     private ImFeignService imFeignService;
@@ -1658,8 +1660,10 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     public boolean renewForCallback(StudentPaymentOrder studentPaymentOrder) throws IOException {
 
-        studentPaymentOrderService.update(studentPaymentOrder);
-
+        int updateNum = studentPaymentOrderService.update(studentPaymentOrder);
+        if(updateNum <= 0){
+            throw new BizException("订单更新失败");
+        }
         Integer userId = studentPaymentOrder.getUserId();
         String musicGroupId = studentPaymentOrder.getMusicGroupId();
 
@@ -1680,9 +1684,29 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             musicGroupStudentFee.setLatestPaidTime(date);
             musicGroupStudentFee.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
             musicGroupStudentFee.setTemporaryCourseFee(new BigDecimal(0));
+            Integer getRemainNetworkClassTimes = musicGroupStudentFee.getRemainNetworkClassTimes() == null ? 0 : musicGroupStudentFee.getRemainNetworkClassTimes();
+            musicGroupStudentFee.setRemainNetworkClassTimes(getRemainNetworkClassTimes+1);
 //            musicGroupStudentFee.setNextPaymentDate(musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, musicGroupStudentFee.getNextPaymentDate(), musicGroupStudentFee));
             musicGroupStudentFeeDao.update(musicGroupStudentFee);
 
+            MusicGroupPaymentCalenderDetail userLastCalenderDetail = musicGroupPaymentCalenderDetailDao.getUserLastCalenderDetail(musicGroupId, userId);
+            if(userLastCalenderDetail == null){
+                throw new BizException("学生没有续费中的记录");
+            }
+            //更新学生的缴费记录状态
+            userLastCalenderDetail.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
+            userLastCalenderDetail.setActualAmount(userLastCalenderDetail.getExpectAmount());
+            userLastCalenderDetail.setPayTime(date);
+            userLastCalenderDetail.setUpdateTime(date);
+            musicGroupPaymentCalenderDetailDao.update(userLastCalenderDetail);
+
+            //更新实际缴费人数
+            MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderDao.getForLock(userLastCalenderDetail.getMusicGroupPaymentCalenderId());
+            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();

+ 10 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupStudentFeeServiceImpl.java

@@ -1,7 +1,6 @@
 package com.ym.mec.biz.service.impl;
 
 import com.ym.mec.biz.dal.dao.MusicGroupDao;
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
 import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.UpdateStudentFeeDto;
@@ -9,7 +8,6 @@ import com.ym.mec.biz.dal.entity.MusicGroup;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
-import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
 import com.ym.mec.biz.service.MusicGroupStudentFeeService;
 import com.ym.mec.biz.service.SysConfigService;
 import com.ym.mec.biz.service.SysMessageService;
@@ -17,13 +15,13 @@ import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext.MessageSender;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.util.*;
-import java.util.stream.Collectors;
 
 @Service
 public class MusicGroupStudentFeeServiceImpl extends BaseServiceImpl<Long, MusicGroupStudentFee> implements MusicGroupStudentFeeService {
@@ -40,9 +38,6 @@ public class MusicGroupStudentFeeServiceImpl extends BaseServiceImpl<Long, Music
 	@Autowired
 	private SysMessageService sysMessageService;
 
-	@Autowired
-	private MusicGroupPaymentCalenderService musicGroupPaymentCalenderService;
-
 	@Override
 	public BaseDAO<Long, MusicGroupStudentFee> getDAO() {
 		return musicGroupStudentFeeDao;
@@ -109,4 +104,13 @@ public class MusicGroupStudentFeeServiceImpl extends BaseServiceImpl<Long, Music
 		musicGroupStudentFeeDao.updateStudentFeeIsLock(studentFeeDto);
 	}
 
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void batchUpdateCourseFee(String ids, BigDecimal courseFee) {
+		if(StringUtils.isEmpty(ids) || courseFee == null){
+			throw new BizException("参数校验失败");
+		}
+		musicGroupStudentFeeDao.batchUpdateCourseFee(ids,courseFee);
+	}
+
 }

+ 44 - 24
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml

@@ -13,14 +13,17 @@
 		<result column="payment_status_" property="paymentStatus" />
 		<result column="user_status_" property="userStatus" />
 		<result column="pay_time_" property="payTime" />
+		<result column="start_payment_date_" property="startPaymentDate" />
+		<result column="deadline_payment_date_" property="deadlinePaymentDate" />
 		<result column="update_time_" property="updateTime" />
 		<result column="create_time_" property="createTime" />
 		<result column="open_" property="open" />
 		<association property="sysUser" javaType="com.ym.mec.auth.api.entity.SysUser">
 			<result column="username_" property="username" />
 		</association>
-		<association property="student" javaType="com.ym.mec.biz.dal.entity.Student">
-			<result column="subject_names_" property="subjectNames" />
+		<association property="studentRegistration" javaType="com.ym.mec.biz.dal.entity.StudentRegistration">
+			<result column="subject_names_" property="subjectName" />
+			<result column="music_group_status_" property="musicGroupStatus" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
 		</association>
 	</resultMap>
 
@@ -38,20 +41,22 @@
 	<insert id="insert"
 		parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail"
 		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_detail
-		(id_,music_group_payment_calender_id_,user_id_,expect_amount_,actual_amount_,payment_status_,user_status_,pay_time_,update_time_,create_time_,open_)
-		VALUES(#{id},#{musicGroupPaymentCalenderId},#{userId},#{expectAmount},#{actualAmount},#{paymentStatus},#{userStatus},#{payTime},#{updateTime},#{createTime},#{open})
+		(id_,music_group_payment_calender_id_,user_id_,expect_amount_,actual_amount_,payment_status_,
+		user_status_,pay_time_,update_time_,create_time_,open_,start_payment_date_,deadline_payment_date_)
+		VALUES(#{id},#{musicGroupPaymentCalenderId},#{userId},#{expectAmount},#{actualAmount},#{paymentStatus},
+		#{userStatus},#{payTime},#{updateTime},#{createTime},#{open},#{startPaymentDate},#{deadlinePaymentDate})
 	</insert>
 
     <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail">
         INSERT INTO music_group_payment_calender_detail
-		(id_,music_group_payment_calender_id_,user_id_,expect_amount_,actual_amount_,payment_status_,user_status_,pay_time_,update_time_,create_time_,open_)
+		(id_,music_group_payment_calender_id_,user_id_,expect_amount_,actual_amount_,
+		payment_status_,user_status_,pay_time_,update_time_,create_time_,open_,start_payment_date_,deadline_payment_date_)
 		VALUES
 		<foreach collection="list" item="item" separator=",">
             (#{item.id},#{item.musicGroupPaymentCalenderId},#{item.userId},#{item.expectAmount},
-            #{item.actualAmount},#{item.paymentStatus},#{item.userStatus},#{item.payTime},#{item.updateTime},#{item.createTime},#{item.open})
+            #{item.actualAmount},#{item.paymentStatus},#{item.userStatus},#{item.payTime},
+            #{item.updateTime},#{item.createTime},#{item.open},#{item.startPaymentDate},#{item.deadlinePaymentDate})
         </foreach>
     </insert>
 
@@ -60,6 +65,12 @@
 		parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail">
 		UPDATE music_group_payment_calender_detail
 		<set>
+			<if test="startPaymentDate != null">
+				start_payment_date_ = #{startPaymentDate},
+			</if>
+			<if test="deadlinePaymentDate != null">
+				deadline_payment_date_ = #{deadlinePaymentDate},
+			</if>
 			<if test="open != null">
 				open_ = #{open},
 			</if>
@@ -134,23 +145,25 @@
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="MusicGroupPaymentCalenderDetail"
 		parameterType="map">
-		SELECT mgpc.*,su.username_,st.name_ subject_names_
-		FROM music_group_payment_calender_detail mgpc
-		LEFT JOIN sys_user su ON su.id_ = mgpc.user_id_
-		LEFT JOIN student s ON s.user_id_ = mgpc.user_id_
-		LEFT JOIN `subject` st ON FIND_IN_SET(st.id_,s.subject_id_list_)
+		SELECT mgpcd.*,su.username_,st.name_ subject_names_,sr.music_group_status_
+		FROM music_group_payment_calender_detail mgpcd
+		LEFT JOIN sys_user su ON su.id_ = mgpcd.user_id_
+		LEFT JOIN student_registration sr ON sr.user_id_ = mgpcd.user_id_
+		LEFT JOIN `subject` st ON st.id_ = sr.actual_subject_id_
+		LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
 		<where>
+			mgpc.music_group_id_ = sr.music_group_id_
 			<if test="userId != null">
-				mgpc.user_id_ = #{userId}
+				AND mgpcd.user_id_ = #{userId}
 			</if>
 			<if test="id != null">
-				mgpc.music_group_payment_calender_id_ = #{id}
+				AND mgpcd.music_group_payment_calender_id_ = #{id}
 			</if>
 			<if test="paymentStatus != null">
-				mgpc.payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+				AND mgpcd.payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 			</if>
 			<if test="subjectId != null">
-				FIND_IN_SET(#{subjectId},s.subject_id_list_)
+				AND #{subjectId} = sr.actual_subject_id_
 			</if>
 		</where>
 		ORDER BY mgpc.create_time_
@@ -159,21 +172,21 @@
 
 	<!-- 查询当前表的总记录数 -->
 	<select id="queryCount" resultType="int">
-		SELECT COUNT(mgpc.id_) FROM music_group_payment_calender_detail mgpc
-		LEFT JOIN student s ON s.user_id_ = mgpc.user_id_
-		LEFT JOIN `subject` st ON FIND_IN_SET(st.id_,s.subject_id_list_)
+		SELECT COUNT(DISTINCT mgpcd.id_) FROM music_group_payment_calender_detail mgpcd
+		LEFT JOIN student_registration sr ON sr.user_id_ = mgpcd.user_id_
+		LEFT JOIN `subject` st ON st.id_ = sr.actual_subject_id_
 		<where>
 			<if test="userId != null">
-				AND mgpc.user_id_ = #{userId}
+				AND mgpcd.user_id_ = #{userId}
 			</if>
 			<if test="id != null">
-				AND mgpc.music_group_payment_calender_id_ = #{id}
+				AND mgpcd.music_group_payment_calender_id_ = #{id}
 			</if>
 			<if test="subjectId != null">
-				AND FIND_IN_SET(#{subjectId},s.subject_id_list_)
+				AND #{subjectId} = sr.actual_subject_id_
 			</if>
 			<if test="paymentStatus != null">
-				AND mgpc.payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+				AND mgpcd.payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 			</if>
 		</where>
 	</select>
@@ -196,4 +209,11 @@
 		SELECT SUM(mgpcd.actual_amount_) FROM music_group_payment_calender_detail mgpcd
 		WHERE mgpcd.music_group_payment_calender_id_ = #{id} AND mgpcd.payment_status_ = "PAID_COMPLETED"
 	</select>
+
+	<select id="getUserLastCalenderDetail" resultMap="MusicGroupPaymentCalenderDetail">
+		SELECT * FROM music_group_payment_calender_detail mgpcd
+		LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
+		WHERE mgpc.music_group_id_=#{musicGroupId} AND mgpcd.user_id_=#{userId} AND mgpcd.payment_status_ = 'PROCESSING'
+		ORDER BY mgpc.start_payment_date_ DESC
+	</select>
 </mapper>

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

@@ -165,4 +165,14 @@
         	</if>
         </where>
     </select>
+
+    <select id="getForLock" resultMap="MusicGroupPaymentCalender">
+        SELECT * FROM music_group_payment_calender WHERE id_ = #{id} FOR UPDATE
+    </select>
+	
+    <select id="queryIntersectionByPaymentDate" resultType="int" parameterType="map">
+        SELECT count(*) FROM music_group_payment_calender mgpc
+        WHERE music_group_id_ = #{musicGroupId} 
+        and (start_payment_date_ between #{startPaymentDate} and #{deadlinePaymentDate} or deadline_payment_date_ between #{startPaymentDate} and #{deadlinePaymentDate})
+    </select>
 </mapper>

+ 42 - 3
mec-biz/src/main/resources/config/mybatis/MusicGroupStudentFeeMapper.xml

@@ -11,6 +11,7 @@
         <result column="music_group_id_" property="musicGroupId"/>
         <result column="user_id_" property="userId"/>
         <result column="subject_id_" property="subjectId"/>
+        <result column="subject_name_" property="subjectName"/>
         <result column="course_fee_" property="courseFee"/>
         <result column="next_payment_date_" property="nextPaymentDate"/>
         <result column="latest_paid_time_" property="latestPaidTime"/>
@@ -21,6 +22,11 @@
         <result column="temporary_course_fee_" property="temporaryCourseFee"/>
         <result column="is_lock_" property="isLock"/>
         <result column="payment_period_list_" property="paymentPeriodList"/>
+        <result column="remain_network_class_times_" property="remainNetworkClassTimes" />
+        <association property="sysUser" javaType="com.ym.mec.auth.api.entity.SysUser">
+            <result column="username_" property="username" />
+            <result column="phone_" property="phone" />
+        </association>
     </resultMap>
 
     <!-- 根据主键查询一条记录 -->
@@ -82,6 +88,9 @@
             <if test="temporaryCourseFee != null">
                 temporary_course_fee_ = #{temporaryCourseFee},
             </if>
+            <if test="remainNetworkClassTimes != null">
+                remain_network_class_times_ = #{remainNetworkClassTimes},
+            </if>
             <if test="isLock != null">
                 is_lock_ = #{isLock},
             </if>
@@ -121,17 +130,43 @@
 
     <!-- 分页查询 -->
     <select id="queryPage" resultMap="MusicGroupStudentFee" parameterType="map">
-        SELECT * FROM music_group_student_fee_ ORDER BY id_
+        SELECT mgsf.*,su.username_,su.phone_,s.name_ subject_name_ FROM music_group_student_fee_ mgsf
+        LEFT JOIN sys_user su ON su.id_ = mgsf.user_id_
+        LEFT JOIN `subject` s ON s.id_ = mgsf.subject_id_
+        <where>
+            mgsf.music_group_id_ = #{musicGroupId}
+            <if test="search != null and search != ''">
+                AND (mgsf.user_id_ = #{search}
+                OR su.username_ LIKE CONCAT('%',#{search},'%')
+                OR su.phone_ LIKE CONCAT('%',#{search},'%'))
+            </if>
+            <if test="subjectId != null">
+                AND mgsf.subject_id_ = #{subjectId}
+            </if>
+        </where>
+        ORDER BY mgsf.update_time_ DESC
         <include refid="global.limit"/>
     </select>
 
     <!-- 查询当前表的总记录数 -->
     <select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM music_group_student_fee_
+        SELECT COUNT(mgsf.id_) FROM music_group_student_fee_ mgsf
+        LEFT JOIN sys_user su ON su.id_ = mgsf.user_id_
+        <where>
+            mgsf.music_group_id_ = #{musicGroupId}
+            <if test="search != null and search != ''">
+                AND (mgsf.user_id_ = #{search}
+                OR su.username_ LIKE CONCAT('%',#{search},'%')
+                OR su.phone_ LIKE CONCAT('%',#{search},'%'))
+            </if>
+            <if test="subjectId != null">
+                AND mgsf.subject_id_ = #{subjectId}
+            </if>
+        </where>
 	</select>
 
     <select id="findByUser" resultMap="MusicGroupStudentFee">
-        SELECT * FROM music_group_student_fee_ WHERE music_group_id_ = #{musicGroupId} AND user_id_ = #{userId}
+        SELECT * FROM music_group_student_fee_ WHERE music_group_id_ = #{musicGroupId} AND user_id_ = #{userId} FOR UPDATE
     </select>
     
     <update id="updateNextPaymentDate" parameterType="map">
@@ -235,4 +270,8 @@
         SELECT GROUP_CONCAT(mgpc.payment_month_) FROM music_group_payment_calender mgpc WHERE mgpc.music_group_id_ = mgsf.music_group_id_)
         WHERE mgsf.music_group_id_ = #{musicGroupId} AND mgsf.user_id_ = #{userId}
     </update>
+    <update id="batchUpdateCourseFee">
+        UPDATE music_group_student_fee_ mgsf SET mgsf.course_fee_ = #{courseFee}
+        WHERE FIND_IN_SET(mgsf.id_,#{ids})
+    </update>
 </mapper>

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

@@ -30,10 +30,10 @@ public class MusicGroupPaymentCalenderDetailController extends BaseController {
     }
 
     @ApiOperation(value = "修改学员预计缴费金额")
-    @PostMapping("/updateActualAmount")
-    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalenderDetail/updateActualAmount')")
-    public Object updateActualAmount(BigDecimal actualAmount,String ids) {
-        musicGroupPaymentCalenderDetailService.updateActualAmount(actualAmount,ids);
+    @PostMapping("/updateExpectAmount")
+    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalenderDetail/updateExpectAmount')")
+    public Object updateExpectAmount(BigDecimal expectAmount,String ids) {
+        musicGroupPaymentCalenderDetailService.updateExpectAmount(expectAmount,ids);
         return succeed();
     }
 

+ 40 - 0
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupStudentFeeController.java

@@ -0,0 +1,40 @@
+package com.ym.mec.web.controller;
+
+import com.ym.mec.biz.dal.page.MusicCalenderDetailQueryInfo;
+import com.ym.mec.biz.service.MusicGroupStudentFeeService;
+import com.ym.mec.common.controller.BaseController;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+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.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.math.BigDecimal;
+
+@RequestMapping("musicGroupStudentFee")
+@Api(tags = "乐团学生费用")
+@RestController
+public class MusicGroupStudentFeeController extends BaseController {
+
+    @Autowired
+    private MusicGroupStudentFeeService musicGroupStudentFeeService;
+
+    @ApiOperation(value = "列表查询")
+    @GetMapping("/queryPage")
+    @PreAuthorize("@pcs.hasPermissions('musicGroupStudentFee/queryPage')")
+    public Object queryPage(MusicCalenderDetailQueryInfo queryInfo) {
+        return succeed(musicGroupStudentFeeService.queryPage(queryInfo));
+    }
+
+    @ApiOperation(value = "批量修改课程费用")
+    @PostMapping("/batchUpdateCourseFee")
+    @PreAuthorize("@pcs.hasPermissions('musicGroupStudentFee/batchUpdateCourseFee')")
+    public Object batchUpdateCourseFee(String ids, BigDecimal courseFee) {
+        musicGroupStudentFeeService.batchUpdateCourseFee(ids,courseFee);
+        return succeed();
+    }
+
+}