From db88b87df461820152d68d3d55a28f30c2da83e6 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 20 九月 2019 17:54:42 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div

---
 fanli/src/main/java/com/yeshi/fanli/job/TaoLiJinJob.java |   62 ++++++++++++++++++++++++++++++-
 1 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/job/TaoLiJinJob.java b/fanli/src/main/java/com/yeshi/fanli/job/TaoLiJinJob.java
index d4a207a..be0f9ea 100644
--- a/fanli/src/main/java/com/yeshi/fanli/job/TaoLiJinJob.java
+++ b/fanli/src/main/java/com/yeshi/fanli/job/TaoLiJinJob.java
@@ -10,6 +10,7 @@
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
+import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinGiveRecord;
 import com.yeshi.fanli.entity.taobao.ShareHotGoods;
 import com.yeshi.fanli.entity.taobao.TLJBuyGoods;
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
@@ -21,6 +22,8 @@
 import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
 import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
+import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinGiveRecordService;
+import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService;
 import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinReportService;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.TaoBaoConstant;
@@ -45,6 +48,12 @@
 
 	@Resource
 	private TaoBaoUnionConfigService taoBaoUnionConfigService;
+
+	@Resource
+	private UserTaoLiJinGiveRecordService userTaoLiJinGiveRecordService;
+
+	@Resource
+	private UserTaoLiJinOriginService userTaoLiJinOriginService;
 
 	/**
 	 * 鏇存柊鎶ュ憡
@@ -114,19 +123,22 @@
 		String day = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd");
 		List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService
 				.getConfigByTypeCache(TaoBaoUnionConfig.TYPE_TLJ_BUY);
+		int totalCount = 0;
 		for (TaoBaoUnionConfig app : configList) {
 			List<TLJBuyGoods> list = tljBuyGoodsService.listByDay(app.getAppKey(), day, 15);// 鑾峰彇鏈�澶�15涓晢鍝�
 			int count = 0;
 			for (int i = 0; i < list.size(); i++) {
 				if (count >= 10)
 					break;
-				boolean success = shareHotGoodsService.verifyCanCreateTLJ(list.get(i).getGoods().getAuctionId(),
+				boolean success = tljBuyGoodsService.verifyCanCreateTLJ(list.get(i).getGoods().getAuctionId(),
 						new TaoKeAppInfo(app.getAppKey(), app.getAppSecret(), app.getDefaultPid()));
 				if (success) {
 					count++;
 				}
 			}
+			totalCount += count;
 		}
+		LogHelper.test("鑷喘绔嬪噺鍟嗗搧楠岃瘉閫氳繃鐨勬暟閲�:" + totalCount);
 	}
 
 	private void addTLJBuyGoods(List<TaoBaoGoodsBrief> list, String day) {
@@ -158,8 +170,26 @@
 	public void autoAddTLJBuyGoods2() {
 		if (!Constant.IS_TASK)
 			return;
+		LogHelper.test("鑷喘绔嬪噺寮�濮嬮�夊搧");
 		String day = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd");
-		List<TaoBaoGoodsBrief> list = tljBuyGoodsService.listPreGoods(1);
+		// 閲嶈瘯3娆�
+		List<TaoBaoGoodsBrief> list = null;
+		try {
+			list = tljBuyGoodsService.listPreGoods(1);
+		} catch (Exception e) {
+		}
+		if (list == null || list.size() == 0)
+			try {
+				list = tljBuyGoodsService.listPreGoods(1);
+			} catch (Exception e) {
+			}
+		if (list == null || list.size() == 0)
+			try {
+				list = tljBuyGoodsService.listPreGoods(1);
+			} catch (Exception e) {
+			}
+
+		LogHelper.test("鑷喘绔嬪噺澶囬�夊晢鍝佹暟閲�:" + list.size());
 		Collections.shuffle(list);
 		List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService
 				.getConfigByTypeCache(TaoBaoUnionConfig.TYPE_TLJ_BUY);
@@ -169,4 +199,32 @@
 		addTLJBuyGoods(list, day);
 	}
 
+	/**
+	 * 姣�2涓皬鏃� 璧犻�侀��鍥炲凡杩囨湡娣樼ぜ閲�
+	 */
+	@Scheduled(cron = "0 0 0/2 * * ? ")
+	public void giveSendBack() {
+		if (!Constant.IS_TASK)
+			return;
+
+		for (int i = 0; i < 100; i++) {
+			List<UserTaoLiJinGiveRecord> overdueList = userTaoLiJinGiveRecordService.overdueList(500);
+			if (overdueList == null || overdueList.size() == 0) {
+				break;
+			}
+
+			for (UserTaoLiJinGiveRecord record : overdueList) {
+				try {
+					userTaoLiJinOriginService.giveSendBack(record.getGiveUid(), record);
+					// 鏇存柊璁板綍
+					UserTaoLiJinGiveRecord updateRecord = new UserTaoLiJinGiveRecord();
+					updateRecord.setId(record.getId());
+					updateRecord.setState(UserTaoLiJinGiveRecord.STATE_OVERDUE);
+					userTaoLiJinGiveRecordService.updateByPrimaryKeySelective(updateRecord);
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+			}
+		}
+	}
 }

--
Gitblit v1.8.0