From b6c37e4bc38db88a360d0f2c6099183f9bb75bdc Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期一, 22 四月 2019 14:31:59 +0800
Subject: [PATCH] 券推送插入

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java |   73 +++++++++++++++++++-----------------
 1 files changed, 38 insertions(+), 35 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java
index 111fa3f..1696376 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java
@@ -7,7 +7,6 @@
 import java.util.Calendar;
 import java.util.Collections;
 import java.util.Date;
-import java.util.Iterator;
 import java.util.List;
 
 import javax.annotation.Resource;
@@ -1572,24 +1571,33 @@
 	@RequestMapping(value = "getRecommendIndex")
 	public void getRecommendIndex(AcceptData acceptData, Long uid, PrintWriter out) {
 		try {
-			// 涓撻妯″潡
-			JSONObject root = specialService.listCacheSpecialToIndex();
+			//  1銆佷笓棰樻ā鍧�
+			JSONObject root = specialService.listCacheSpecialToIndex(acceptData);
 
-			// 椤堕儴杞挱鍥�
+			// 2銆侀《閮ㄨ疆鎾浘
 			List<SwiperPicture> topPicList = getSwiperByCard("index_top");
 			if (topPicList == null) {
 				topPicList = new ArrayList<SwiperPicture>();
 			}
 			root.put("topPicList", JsonUtil.getApiCommonGson().toJson(topPicList));
 			
-			// 閭�璇枫�佸垎浜疆鎾浘
-			List<SwiperPicture> invitePicList = getInvitePicList(uid, acceptData);
+			
+			// 3銆侀個璇锋湁濂�
+			List<SwiperPicture> invitePicList = null;
+			if ("ios".equalsIgnoreCase(acceptData.getPlatform())
+					&& configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) {
+				// 濡傛灉IOS褰撳墠鐗堟湰澶勪簬瀹℃牳鐘舵�佸氨涓嶈繑鍥�
+			} else {
+				invitePicList = getSwiperByCard("index_invite");	
+			}
+			
 			if (invitePicList == null) {
 				invitePicList = new ArrayList<SwiperPicture>();
-			}
+			} 
 			root.put("invitePicList", JsonUtil.getApiCommonGson().toJson(invitePicList));
 			
-			// 搴曢儴缃戦〉閾炬帴
+			
+			// 4銆両OS鐨勫簳閮ㄧ綉椤甸摼鎺�
 			String platform = acceptData.getPlatform();
 			if ("ios".equalsIgnoreCase(platform)) {
 				root.put("htmlLink", configService.get("index_html_link_ios"));
@@ -1621,25 +1629,7 @@
 		
 		List<SwiperPicture> invitePicList = getSwiperByCard("index_invite");	
 		
-		if (uid != null) {
-			try {
-				// 鐢ㄦ埛鑷畾涔夛細涓嶇湅閭�璇锋湁濂�
-				UserSettingsVO vo = userCustomSettingsService.getMySettings(uid);
-				if (vo != null  && vo.getNoInvitationBonus() != null && vo.getNoInvitationBonus() == 1 
-						&& invitePicList != null && invitePicList.size() > 0) {
-					Iterator<SwiperPicture> iterator = invitePicList.iterator();
-					while (iterator.hasNext()) {
-						SwiperPicture swiperPicture = iterator.next();
-						JumpDetailV2 jumpDetail = swiperPicture.getJumpDetail();
-						if (jumpDetail != null && "invite".equals(jumpDetail.getType())) {
-							iterator.remove();
-						}
-					}
-				}
-			} catch (UserCustomSettingsException e) {
-				e.printStackTrace();
-			}
-		}
+		
 		
 		return invitePicList;
 	}
@@ -1705,16 +1695,24 @@
 		nextTime.set(Calendar.SECOND, 0);
 		nextTime.set(Calendar.MILLISECOND, 0);
 		
-		JSONObject root = new JSONObject();
-		root.put("time", nextTime.getTimeInMillis());
+	
+		JSONArray array = null;
+		String timekey = "spikeGoods_hour";
+		String cachekey = "spikeGoodsList";
 		
-		
-		JSONArray array = new JSONArray();
-		String cachekey = "spikeGoodsList" ;
-		String cacheValue = redisManager.getCommonString(cachekey);
-		if (!StringUtil.isNullOrEmpty(cacheValue)) {
-			array = JSONArray.fromObject(cacheValue);
+		String timeValue = redisManager.getCommonString(timekey);
+		if (timeValue == null || !timeValue.equals(hour+"")) {
+			redisManager.cacheCommonString(timekey, hour+"", 60 * 30);
 		} else {
+			String cacheValue = redisManager.getCommonString(cachekey);
+			if (!StringUtil.isNullOrEmpty(cacheValue)) {
+				array = JSONArray.fromObject(cacheValue);
+			}
+		}
+		
+		if (array == null) {
+			array = new JSONArray();
+			
 			BigDecimal proportion = manageService.getFanLiRate();
 			Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
 					.excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
@@ -1724,6 +1722,7 @@
 			if (listGoods == null) {
 				listGoods = new ArrayList<QualityFactory>();
 			}
+			
 			/* 閬嶅巻鍒楄〃鏁版嵁 */
 			for (QualityFactory qualityFactory : listGoods) {
 					
@@ -1733,9 +1732,13 @@
 				}
 				array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
 			}
+			
 			// 缂撳瓨鍗婁釜灏忔椂
 			redisManager.cacheCommonString(cachekey, array.toString(), 60 * 30);
 		}
+		
+		JSONObject root = new JSONObject();
+		root.put("time", nextTime.getTimeInMillis());
 		root.put("listgoods", array);
 		out.print(JsonUtil.loadTrueResult(root));
 	}

--
Gitblit v1.8.0