Ver Fonte

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

yonge há 5 anos atrás
pai
commit
73cbb3fc5a

+ 74 - 57
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDao.java

@@ -13,67 +13,84 @@ import com.ym.mec.common.dal.BaseDAO;
 
 public interface MusicGroupPaymentCalenderDao extends BaseDAO<Long, MusicGroupPaymentCalender> {
 
-	/**
-	 * 根据乐团编号删除乐团缴费周期
-	 * @param musicGroupId
-	 */
-	void delByGroupId(String musicGroupId);
+    /**
+     * 根据乐团编号删除乐团缴费周期
+     *
+     * @param musicGroupId
+     */
+    void delByGroupId(String musicGroupId);
 
-	/**
-	 * 根据乐团编号获取乐团缴费日历
-	 * @param musicGroupId
-	 * @return
-	 */
-	List<MusicGroupPaymentCalender> findByMusicGroupId(String musicGroupId);
+    /**
+     * 根据乐团编号获取乐团缴费日历
+     *
+     * @param musicGroupId
+     * @return
+     */
+    List<MusicGroupPaymentCalender> findByMusicGroupId(String musicGroupId);
 
-	/**
-	 * 批量新增乐团缴费周期
-	 * @param calender
-	 * @param musicGroupId
-	 */
-	void batchAdd(@Param("calender") List<Integer> calender, @Param("musicGroupId") String musicGroupId);
+    /**
+     * 批量新增乐团缴费周期
+     *
+     * @param calender
+     * @param musicGroupId
+     */
+    void batchAdd(@Param("calender") List<Integer> calender, @Param("musicGroupId") String musicGroupId);
 
-	/**
-	 * 批量修改
-	 * @param musicGroupPaymentCalenderList
-	 * @return
-	 */
-	int batchUpdate(List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList);
+    /**
+     * 批量修改
+     *
+     * @param musicGroupPaymentCalenderList
+     * @return
+     */
+    int batchUpdate(List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList);
 
-	/**
-	 * 查询指定状态的记录
-	 * @param status
-	 * @return
-	 */
-	List<MusicGroupPaymentCalender> queryByPaymentStatus(@Param("status") List<PaymentStatusEnum> status);
-	
-	/**
-	 * 获取缴费信息锁
-	 * @param id
-	 * @return
-	 */
-	MusicGroupPaymentCalender getForLock(@Param("id") Long id);
+    /**
+     * 查询指定状态的记录
+     *
+     * @param status
+     * @return
+     */
+    List<MusicGroupPaymentCalender> queryByPaymentStatus(@Param("status") List<PaymentStatusEnum> status);
 
-	/**
-	 * 根据指定乐团的缴费日期查询交集
-	 * @param musicGroupId 乐团编号
-	 * @param startPaymentDate 开始缴费日期
-	 * @param deadlinePaymentDate 截止缴费日期
-	 * @return
-	 */
-	int queryIntersectionByPaymentDate(@Param("musicGroupId") String musicGroupId, @Param("startPaymentDate") Date startPaymentDate,
-			@Param("deadlinePaymentDate") Date deadlinePaymentDate);
+    /**
+     * 获取缴费信息锁
+     *
+     * @param id
+     * @return
+     */
+    MusicGroupPaymentCalender getForLock(@Param("id") Long id);
 
-	/**
-	 * 统计预计缴费人数
-	 * @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 startPaymentDate    开始缴费日期
+     * @param deadlinePaymentDate 截止缴费日期
+     * @return
+     */
+    int queryIntersectionByPaymentDate(@Param("musicGroupId") String musicGroupId, @Param("startPaymentDate") Date startPaymentDate,
+                                       @Param("deadlinePaymentDate") Date deadlinePaymentDate);
+
+    /**
+     * 统计预计缴费人数
+     *
+     * @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
+     * @return
+     */
+    MusicGroupPaymentCalender getLastStartOne(@Param("musicGroupId") String musicGroupId);
 }

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

@@ -81,4 +81,17 @@ public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicG
 	 */
 	void refreshUserMusicGroupPaymentStatusTask();
 
+	/**
+	 * 获取可以推送缴费提醒的列表
+	 * @param musicGroupPaymentCalenderId
+	 * @return
+	 */
+	List<MusicGroupPaymentCalenderDetail> queryCanPushList(@Param("musicGroupPaymentCalenderId") Long musicGroupPaymentCalenderId);
+
+	/**
+	 * 获取当天创建,已开启缴费,并且未缴费的用户列表
+	 * @return
+	 */
+	List<MusicGroupPaymentCalenderDetail> queryNoPaymentCanPushList();
+
 }

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

@@ -63,4 +63,12 @@ public interface MusicGroupPaymentCalenderService extends BaseService<Long, Musi
 	 * @return
 	 */
 	Object queryDetailPage(MusicCalenderQueryInfo queryInfo);
+
+	/**
+	 * 推送乐团缴费提醒
+	 * @param id
+	 * @param userIds
+	 * @return
+	 */
+	void paymentPush(Long id, String userIds);
 }

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

@@ -287,7 +287,7 @@ public class ExtracurricularExercisesReplyServiceImpl extends BaseServiceImpl<Lo
 		LocalDate nowDate = LocalDateTime.now(DateUtil.zoneId).toLocalDate();
 
 		if(nowDate.getDayOfWeek()==DayOfWeek.MONDAY){
-			int lastWeekTodayUpdateNum = studentExtracurricularExercisesSituationDao.findLastWeekTodayUpdateNum(nowDate.toString());
+			int lastWeekTodayUpdateNum = studentExtracurricularExercisesSituationDao.findLastWeekTodayUpdateNum(nowDate.plusDays(-1).toString());
 			if(lastWeekTodayUpdateNum<=0){
 				nowDate = nowDate.plusDays(-1);
 			}

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

@@ -115,7 +115,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 			e.setOpen(1);
 //			e.setPaymentStatus(PROCESSING);
 			e.setStartPaymentDate(date);
-			e.setDeadlinePaymentDate(DateUtil.addDays(date,2));
+			e.setDeadlinePaymentDate(DateUtil.addDays(date,3));
 		});
 		musicGroupPaymentCalenderDetailDao.batchUpdate(calenderDetails);
 		//修改学员缴费状态为未缴费

+ 60 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -157,6 +157,25 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public boolean autoUpdateMusicGroupPaymentCalenderStatus() {
+		//获取当天创建且未缴费的数据,并推送
+		List<MusicGroupPaymentCalenderDetail> details = musicGroupPaymentCalenderDetailDao.queryNoPaymentCanPushList();
+		if(details != null && details.size() > 0){
+			Set<Integer> studentIds = details.stream().map(e -> e.getUserId()).collect(Collectors.toSet());
+			String musicGroupId = details.get(0).getMusicGroupId();
+			if (studentIds.size() > 0) {
+				Map<Integer, String> push = new HashMap<>();
+				for (Integer userId : studentIds) {
+					push.put(userId, userId + "");
+				}
+				MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
+				String baseUrl = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
+				String memo = "4?" + baseUrl + "/#/renew?musicGroupId=" + musicGroup.getId();
+				// 发送续费通知
+				sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_WAIT_RENEW_MESSAGE, push,
+						null, 0, memo, "STUDENT", musicGroup.getName());
+			}
+		}
+
 		Date date = new Date();
 		List<PaymentStatusEnum> statusList = new ArrayList<PaymentStatusEnum>();
 		statusList.add(PaymentStatusEnum.NO);
@@ -372,4 +391,45 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		});
 		return pageInfo;
 	}
+
+	@Override
+	public void paymentPush(Long id, String userIds) {
+		//推送所有
+		if(StringUtils.isEmpty(userIds)){
+			List<MusicGroupPaymentCalenderDetail> details = musicGroupPaymentCalenderDetailDao.queryCanPushList(id);
+			if(details == null || details.size() == 0){
+				return;
+			}
+			String musicGroupId = details.get(0).getMusicGroupId();
+			Set<Integer> studentIds = details.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 baseUrl = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
+				String memo = "4?" + baseUrl + "/#/renew?musicGroupId=" + musicGroupId;
+				// 发送续费通知
+				sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_WAIT_RENEW_MESSAGE, push, null, 0, memo,"STUDENT",musicGroup.getName());
+			}
+		}else {
+			//获取课推送列表
+			//批量推送
+			MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(id);
+			Set<String> studentIds = new HashSet<>(Arrays.asList(userIds.split(",")));
+			if (studentIds.size() > 0) {
+				Map<Integer, String> push = new HashMap<>();
+				for (String userId : studentIds) {
+					push.put(Integer.parseInt(userId), userId + "");
+				}
+				MusicGroup musicGroup = musicGroupDao.get(calender.getMusicGroupId());
+				String baseUrl = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
+				String memo = "4?" + baseUrl + "/#/renew?musicGroupId=" + calender.getMusicGroupId();
+				// 发送续费通知
+				sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_WAIT_RENEW_MESSAGE, push, null, 0, memo,"STUDENT",musicGroup.getName());
+			}
+		}
+	}
 }

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

@@ -257,4 +257,16 @@
 		WHERE mgpc.music_group_id_ = #{musicGroupId} AND mgpcd.user_id_ = #{userId}
 		AND  mgpcd.open_ = 1
 	</select>
+	<select id="queryCanPushList" 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 sr.music_group_status_ != 'QUIT' AND mgpc.id_ = #{musicGroupPaymentCalenderId}
+		GROUP BY mgpcd.id_
+	</select>
+	<select id="queryNoPaymentCanPushList" resultMap="MusicGroupPaymentCalenderDetail">
+		SELECT mgpcd.*,mgpc.music_group_id_ FROM music_group_payment_calender mgpc
+		LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
+		WHERE mgpc.create_time_ = DATE_FORMAT(NOW(),'%Y-%m-%d') AND mgpc.payment_status_ = 1 AND mgpcd.payment_status_ = 'NON_PAYMENT'
+	</select>
 </mapper>

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

@@ -193,4 +193,8 @@
         AND mgpcd.payment_status_ = 'PAID_COMPLETED'
         GROUP BY mgpcd.music_group_payment_calender_id_
     </select>
+    
+    <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>
 </mapper>

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

@@ -2,6 +2,7 @@ package com.ym.mec.student.controller;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
 import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
 import com.ym.mec.biz.dal.dto.RegisterPayDto;
@@ -53,6 +54,8 @@ public class MusicGroupController extends BaseController {
     private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
     @Autowired
     private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
+    @Autowired
+    private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
 
     @ApiOperation("获取学生所在乐团列表")
     @GetMapping(value = "/queryUserMusicGroups")
@@ -158,7 +161,9 @@ public class MusicGroupController extends BaseController {
         }
         MusicGroupPaymentCalenderDetail userLastCalenderDetail = musicGroupPaymentCalenderDetailDao.getUserLastCalenderDetail(musicGroupId, userId);
         if(userLastCalenderDetail == null){
-            throw new BizException("当前续费时间已截止,请联系指导老师");
+            MusicGroupPaymentCalender lastCalender = musicGroupPaymentCalenderDao.getLastStartOne(musicGroupId);
+           String tips =  (lastCalender != null && lastCalender.getPaymentStatus().equals(PaymentStatusEnum.YES))?"当前续费时间已截止,如有问题请联系指导老师":"当前续费未开始,如有问题请联系指导老师";
+            throw new BizException(tips);
         }
 
         BigDecimal amount = userLastCalenderDetail.getExpectAmount();
@@ -200,7 +205,9 @@ public class MusicGroupController extends BaseController {
 		}
         MusicGroupPaymentCalenderDetail userLastCalenderDetail = musicGroupPaymentCalenderDetailDao.getUserLastCalenderDetail(musicGroupId, userId);
         if(userLastCalenderDetail == null){
-            throw new BizException("当前续费时间已截止,请联系指导老师");
+            MusicGroupPaymentCalender lastCalender = musicGroupPaymentCalenderDao.getLastStartOne(musicGroupId);
+            String tips =  (lastCalender != null && lastCalender.getPaymentStatus().equals(PaymentStatusEnum.YES))?"当前续费时间已截止,如有问题请联系指导老师":"当前续费未开始,如有问题请联系指导老师";
+            throw new BizException(tips);
         }
         return succeed(musicGroupService.renew(musicGroupId, userId, isUseBalancePayment));
 	}

+ 8 - 0
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java

@@ -71,4 +71,12 @@ public class MusicGroupPaymentCalenderController extends BaseController {
     public Object getDetail(Long id) {
         return succeed(musicGroupPaymentCalenderService.getDetail(id));
     }
+
+    @ApiOperation(value = "开启缴费的推送(暂时不用,没写完)")
+    @GetMapping("/paymentPush")
+    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/paymentPush')")
+    public Object paymentPush(Long id,String userIds) {
+        musicGroupPaymentCalenderService.paymentPush(id,userIds);
+        return succeed();
+    }
 }