From 28cf328a098334b51a3e9d2d56f983fb8c862211 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期六, 23 五月 2020 09:54:38 +0800
Subject: [PATCH] 足迹、收藏订单兼容新需求

---
 fanli/src/main/java/com/yeshi/fanli/job/UserSystemCouponJob.java |   60 +++++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 45 insertions(+), 15 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/job/UserSystemCouponJob.java b/fanli/src/main/java/com/yeshi/fanli/job/UserSystemCouponJob.java
index 0aab34a..eb42451 100644
--- a/fanli/src/main/java/com/yeshi/fanli/job/UserSystemCouponJob.java
+++ b/fanli/src/main/java/com/yeshi/fanli/job/UserSystemCouponJob.java
@@ -7,8 +7,11 @@
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
+import com.yeshi.fanli.entity.bus.user.UserSystemCoupon;
 import com.yeshi.fanli.entity.bus.user.UserSystemCouponGiveRecord;
+import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.service.inter.user.UserSystemCouponGiveRecordService;
+import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
 import com.yeshi.fanli.util.Constant;
 
 @Component
@@ -16,29 +19,56 @@
 
 	@Resource
 	private UserSystemCouponGiveRecordService userSystemCouponGiveRecordService;
-
+	
+	@Resource
+	private UserSystemCouponService userSystemCouponService;
 	
 	/**
-	 * 姣忓ぉ00:10  璧犻�侀��鍥炲凡杩囨湡娣樼ぜ閲�
+	 * 姣忓ぉ涓�涓皬鏃舵洿鏂板埜
 	 */
-	@Scheduled(cron = "0 10 0 * * ? ")
-	public void giveSendBack() {
+	@Scheduled(cron = "0 0 0/1 * * ? ")
+	public void updateCouponInfo() {
 		if (!Constant.IS_TASK)
 			return;
 		
-		for (int i = 0; i < 100; i++) {
-			List<UserSystemCouponGiveRecord> overdueList = userSystemCouponGiveRecordService.overdueList(500);
-			if (overdueList == null || overdueList.size() == 0) {
-				break;
+		// 1銆佽禒閫侀��鍥炲埜
+		giveSendBack();
+		
+		// 2銆佸埜澶辨晥
+		updateInvalid();
+	}
+	
+	/**
+	 * 璧犻�侀��鍥炲埜
+	 */
+	public void giveSendBack() {
+		try {
+			for (int i = 0; i < 100; i++) {
+				List<UserSystemCouponGiveRecord> overdueList = userSystemCouponGiveRecordService.overdueList(500);
+				if (overdueList == null || overdueList.size() == 0) {
+					break;
+				}
+				userSystemCouponService.sendBackGiveCoupon(overdueList);
 			}
-			
-			for (UserSystemCouponGiveRecord record: overdueList) {
-				
-				UserSystemCouponGiveRecord updateRecord = new UserSystemCouponGiveRecord();
-				updateRecord.setId(record.getId());
-				updateRecord.setState(UserSystemCouponGiveRecord.STATE_OVERDUE);
-				userSystemCouponGiveRecordService.updateByPrimaryKeySelective(updateRecord);
+		} catch (Exception e) {
+			LogHelper.errorDetailInfo(e);
+		}
+	}
+	
+	/**
+	 * 鏇存柊鍒稿け鏁�
+	 */
+	public void updateInvalid() {
+		try {
+			for (int i = 0; i < 100; i++) {
+				List<UserSystemCoupon> list = userSystemCouponService.getCounponNowInvalid(500);
+				if (list == null || list.size() == 0) {
+					break;
+				}
+				userSystemCouponService.updateCounponInvalid(list);
 			}
+		} catch (Exception e) {
+			LogHelper.errorDetailInfo(e);
 		}
 	}
 }

--
Gitblit v1.8.0