zouxuan 5 năm trước cách đây
mục cha
commit
1d8cebccab

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

@@ -61,4 +61,18 @@ public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicG
 	 */
 	MusicGroupPaymentCalenderDetail getUserLastCalenderDetail(@Param("musicGroupId") String musicGroupId, @Param("userId") Integer userId);
 
+	/**
+	 * 获取可开启缴费的数据集
+	 * @param ids
+	 * @return
+	 */
+	List<MusicGroupPaymentCalenderDetail> queryCanOpenList(@Param("ids") String ids);
+
+	/**
+	 * 当前用户所在乐团
+	 * @param musicGroupId
+	 * @param userId
+	 * @return
+	 */
+	int queryIntersectionByPaymentDate(@Param("musicGroupId") String musicGroupId, @Param("userId") Integer userId);
 }

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

@@ -33,6 +33,9 @@ public class MusicGroupPaymentCalenderDetail {
 	/**  */
 	private String userStatus;
 
+	/**  */
+	private String musicGroupId;
+
 	/**1是0否  */
 	private Integer open;
 	
@@ -55,6 +58,14 @@ public class MusicGroupPaymentCalenderDetail {
 
 	private StudentRegistration studentRegistration = new StudentRegistration();
 
+	public String getMusicGroupId() {
+		return musicGroupId;
+	}
+
+	public void setMusicGroupId(String musicGroupId) {
+		this.musicGroupId = musicGroupId;
+	}
+
 	public Date getStartPaymentDate() {
 		return startPaymentDate;
 	}

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

@@ -1,22 +1,24 @@
 package com.ym.mec.biz.service.impl;
 
+import com.ym.mec.biz.dal.dao.MusicGroupDao;
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
 import com.ym.mec.biz.dal.dto.SimpleUserDto;
+import com.ym.mec.biz.dal.entity.MusicGroup;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
+import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderDetailService;
+import com.ym.mec.biz.service.SysMessageService;
 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;
 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.Date;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 
 import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.NON_PAYMENT;
@@ -27,6 +29,10 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 	
 	@Autowired
 	private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
+	@Autowired
+	private MusicGroupDao musicGroupDao;
+	@Autowired
+	private SysMessageService sysMessageService;
 
 	@Override
 	public BaseDAO<Long, MusicGroupPaymentCalenderDetail> getDAO() {
@@ -62,22 +68,42 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 		if(StringUtils.isEmpty(ids)){
 			throw new BizException("参数校验失败");
 		}
-		//获取缴费列表
-		List<MusicGroupPaymentCalenderDetail> calenderDetails = musicGroupPaymentCalenderDetailDao.queryListByIds(ids);
+		//获取可开启缴费列表
+		List<MusicGroupPaymentCalenderDetail> calenderDetails = musicGroupPaymentCalenderDetailDao.queryCanOpenList(ids);
 		if(calenderDetails.size() == 0){
-			throw new BizException("缴费记录不存在");
+			return;
 		}
 		Date date = new Date();
-		calenderDetails.forEach(e->{
-			if(e.getPaymentStatus() == null || e.getPaymentStatus() != NON_PAYMENT){
-				throw new BizException("修改失败,缴费状态不匹配");
+		/*Iterator<MusicGroupPaymentCalenderDetail> iterator = calenderDetails.iterator();
+		MusicGroupPaymentCalenderDetail next;
+		while(iterator.hasNext()){
+			next = iterator.next();
+			int count = musicGroupPaymentCalenderDetailDao.queryIntersectionByPaymentDate(next.getMusicGroupId(),next.getUserId());
+			if(count > 0){
+				iterator.remove();
 			}
+		}*/
+		String musicGroupId = calenderDetails.get(0).getMusicGroupId();
+		calenderDetails.forEach(e->{
 			e.setUpdateTime(date);
+			e.setOpen(1);
 			e.setPaymentStatus(PROCESSING);
+			e.setStartPaymentDate(date);
+			e.setDeadlinePaymentDate(date);
 		});
 		musicGroupPaymentCalenderDetailDao.batchUpdate(calenderDetails);
 		Set<Integer> studentIds = calenderDetails.stream().map(e -> e.getUserId()).collect(Collectors.toSet());
 		//推送消息
+		if (studentIds.size() > 0) {
+			Map<Integer, String> push = new HashMap<>();
+			for (Integer userId : studentIds) {
+				push.put(userId, userId + "");
+			}
+			MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
+			String memo = "4?http://mstudev.dayaedu.com/#/renew?musicGroupId=" + musicGroupId;
+			// 发送续费通知
+			sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_WAIT_RENEW_MESSAGE, push, null, 0, memo,"STUDENT",musicGroup.getName());
+		}
 	}
 
 	@Override

+ 15 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml

@@ -12,6 +12,7 @@
 		<result column="actual_amount_" property="actualAmount" />
 		<result column="payment_status_" property="paymentStatus" />
 		<result column="user_status_" property="userStatus" />
+		<result column="music_group_id_" property="musicGroupId" />
 		<result column="pay_time_" property="payTime" />
 		<result column="start_payment_date_" property="startPaymentDate" />
 		<result column="deadline_payment_date_" property="deadlinePaymentDate" />
@@ -221,4 +222,18 @@
 		WHERE mgpc.music_group_id_=#{musicGroupId} AND mgpcd.user_id_=#{userId} AND mgpcd.payment_status_ = 'PROCESSING'
 		ORDER BY mgpc.start_payment_date_ DESC
 	</select>
+	<select id="queryCanOpenList" resultMap="MusicGroupPaymentCalenderDetail">
+		SELECT mgpcd.*,mgpc.music_group_id_ FROM music_group_payment_calender_detail mgpcd
+		LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
+		LEFT JOIN student_registration sr ON sr.music_group_id_ = mgpc.music_group_id_
+		WHERE mgpcd.payment_status_ = 'NON_PAYMENT' AND mgpcd.open_ = 0 AND sr.music_group_status_ != 'QUIT'
+		AND FIND_IN_SET(mgpcd.id_,#{ids})
+	</select>
+	<select id="queryIntersectionByPaymentDate" resultType="java.lang.Integer">
+		SELECT COUNT(mgpcd.id_) 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.start_payment_date_ BETWEEN NOW() AND NOW()
+		OR mgpcd.deadline_payment_date_ BETWEEN NOW() AND NOW())
+	</select>
 </mapper>

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

@@ -173,6 +173,7 @@
     <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})
+        and (start_payment_date_ between #{startPaymentDate} and #{deadlinePaymentDate}
+        or deadline_payment_date_ between #{startPaymentDate} and #{deadlinePaymentDate})
     </select>
 </mapper>