瀏覽代碼

修改定时取消订单时间

wangxiaoming 5 年之前
父節點
當前提交
b6ee8fcade

+ 1 - 1
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/memberMapper.xml

@@ -397,7 +397,7 @@
 		WHERE date_format(user_birth_date,'%m-%d') = date_format(now(),'%m-%d')
 	</select>
 
-	<!-- 查询今日生日的用户 -->
+	<!-- 获取关注一个月但未注册的用户-用于推送-定时任务 -->
 	<select id="getNoRegister" resultType="Member">
 		SELECT
 		<include refid="allField"/>

+ 15 - 15
iamberry-wechat-web/src/main/java/com/iamberry/wechat/handles/mq/MQTask.java

@@ -80,14 +80,14 @@ public class MQTask implements InitializingBean {
 		logger.info("------------task start-----------");
 		// If the timer has not stopped, then the next time the timer can not start.
 		lock.lock();
-		
+
 		try {
 			// step 1, Gets the message that is not executed in the database.
 			List<MQMessage> messages = mQSerivce.selectWaitHandlerMessage();
 			if (messages == null || messages.size() <= 0) {
 				return;
 			}
-			
+
 			// step 2, Handle 10 messages at a time.
 			for (MQMessage mqMessage : messages) {
 				try {
@@ -122,10 +122,10 @@ public class MQTask implements InitializingBean {
 					mqMessage.setServiceIsSend(1);
 				}
 			}
-			
+
 			// step 3, update Message status and serviceIsSend.
 			mQSerivce.updateBatchMessage(messages);
-			
+
 			// step 4, is next ?
 			/*if (messages.size() >= 10) {
 				StaticCacheMemory.isStartTask = true;
@@ -199,10 +199,10 @@ public class MQTask implements InitializingBean {
 	 */
 	public void subscribeMessageQueue() {
 	}
-	
+
 	// 强迫线程可见
 	private volatile boolean oldState = true;
-	
+
 	/**
 	 * 微信定期任务奖励-上个月的定时器
 	 */
@@ -219,14 +219,14 @@ public class MQTask implements InitializingBean {
 			logger.info("上一个月的定时奖励任务奖励...");
 			// 当前时间
 			Date nowDate = new Date();
-			
+
 			// 回到上一个月
 			nowDate.setMonth(nowDate.getMonth() - 1);
 			// 上一个月的结束时间  类似 :2016-02-29 23:59:59
 			Date oldMonthLastDay = DateTimeUtil.getLastDayOfYear(nowDate);
 			// 上一个月的开始时间  类似 :2016-02-01 00:00:00
 			Date oldMonthFirstDay = DateTimeUtil.getFirstDayOfYear(nowDate);
-			
+
 			List<WechatTask> tasks = wechatTaskService.getRunTask(oldMonthFirstDay, oldMonthLastDay);
 			if (tasks == null || tasks.size() == 0) {
 				logger.info("暂时没有上一个月的任务奖励...");
@@ -278,18 +278,18 @@ public class MQTask implements InitializingBean {
 			return;
 		}
 		nowState = false;
-		
+
 		try {
 			// 判断本月是否有奖励数据
 			logger.info("本月的定时奖励任务奖励...");
 			// 当前时间
 			Date nowDate = new Date();
-			
+
 			// 上一个月的结束时间  类似 :2016-02-29 23:59:59
 			Date oldMonthLastDay = DateTimeUtil.getLastDayOfYear(nowDate);
 			// 上一个月的开始时间  类似 :2016-02-01 00:00:00
 			Date oldMonthFirstDay = DateTimeUtil.getFirstDayOfYear(nowDate);
-			
+
 			List<WechatTask> tasks = wechatTaskService.getRunTask(oldMonthFirstDay, oldMonthLastDay);
 			if (tasks == null || tasks.size() == 0) {
 				logger.info("暂时没有本月的任务奖励...");
@@ -328,7 +328,7 @@ public class MQTask implements InitializingBean {
 			nowState = true;
 		}
 	}
-	
+
 	public void afterPropertiesSet() throws Exception {
 	}
 
@@ -450,10 +450,9 @@ public class MQTask implements InitializingBean {
 	 * @throws Exception
 	 */
 //	@Scheduled(cron = "0 0/2 * * * ?")//每2分钟执行一次
-	@Scheduled(cron = "0 0/20 * * * ?")//每20分钟执行一次
+	@Scheduled(cron = "0 0/5 * * * ?")//每5分钟执行一次
 	public void cancelOrder() throws Exception {
 		logger.info("---------------- 超过20分钟取消订单-开始 ---------------");
-
 		Calendar calendar = Calendar.getInstance();
 		calendar.setTime(new Date());
 		calendar.add(Calendar.MINUTE, -20);//20分钟前的时间
@@ -530,6 +529,7 @@ public class MQTask implements InitializingBean {
 		calendar.add(Calendar.DATE, -45);//45天前
 		CouponItem couponItem = new CouponItem();
 		couponItem.setCouponId(40001);
+		couponItem.setCouponReceiveDate(calendar.getTime());
 		List<CouponItemDto> couponItemDtoList = couponItemService.getNoUseCouponList(couponItem);
 		if(couponItemDtoList!=null && couponItemDtoList.size()>0){
 			logger.info("---------------- 45天未使用优惠券的券 - 前当前任务处理数量-"+ couponItemDtoList.size() +" ---------------");
@@ -553,7 +553,7 @@ public class MQTask implements InitializingBean {
 		//85天未使用优惠券的券
 		Calendar nowcalendar = Calendar.getInstance();
 		nowcalendar.setTime(new Date());
-		nowcalendar.add(Calendar.DATE, -85);//85天前
+		nowcalendar.add(Calendar.DATE, -85);//45天前
 		CouponItem nowcouponItem = new CouponItem();
 		nowcouponItem.setCouponId(40001);
 		nowcouponItem.setCouponReceiveDate(nowcalendar.getTime());