From 31d6bd3dd8163a5d6c182110dcf21e94b4770dac Mon Sep 17 00:00:00 2001
From: Administrator <Administrator@S0ZHK00LKCA6OYY>
Date: 星期一, 26 十一月 2018 14:17:02 +0800
Subject: [PATCH] 收藏信息更新

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/SearchController.java |  146 +++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 137 insertions(+), 9 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/SearchController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/SearchController.java
index 85d9bde..6288178 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/SearchController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/SearchController.java
@@ -38,6 +38,7 @@
 import com.yeshi.fanli.entity.taobao.TaoBaoSearchNav;
 import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
 import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
+import com.yeshi.fanli.service.inter.config.ConfigService;
 import com.yeshi.fanli.service.inter.config.SuperHotSearchService;
 import com.yeshi.fanli.service.inter.config.SystemService;
 import com.yeshi.fanli.service.inter.goods.HonestService;
@@ -58,7 +59,10 @@
 
 	@Resource
 	private SystemService systemService;
-
+	
+	@Resource
+	private ConfigService configService;
+	
 	@Resource
 	private SuperHotSearchService superHotSearchSerivce;
 
@@ -422,7 +426,7 @@
 	 */
 	@RequestMapping(value = "searchgoods")
 	public void searchgoods(AcceptData acceptData, String kw, int page, String filter, String order, String startprice,
-			String endprice, String fastFilter, PrintWriter out) {
+			String endprice, Double startTkRate, Double endTkRate, String fastFilter, PrintWriter out) {
 
 		String bid = getHistorySearchBid(acceptData);
 
@@ -516,7 +520,7 @@
 		if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(endprice)) {
 			sf.setEndPrice(new BigDecimal(endprice));
 		}
-
+		
 		if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(order)) {
 			if (Integer.parseInt(order) == 1) {
 				sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW);
@@ -603,10 +607,21 @@
 				} else if ("materialId".equalsIgnoreCase(ty)) {
 					int id = array.optJSONObject(i).optInt("id");
 					sf.setProvinceId(id);
-				}
+				} else if ("tkRate1".equalsIgnoreCase(ty)) {
+					setSearchTkRate(0, sf);
+				} else if ("tkRate2".equalsIgnoreCase(ty)) {
+					setSearchTkRate(1, sf);
+				} else if ("tkRate3".equalsIgnoreCase(ty)) {
+					setSearchTkRate(2, sf);
+				} else if ("tkRate4".equalsIgnoreCase(ty)) {
+					setSearchTkRate(3, sf);
+				} else if ("tkRate5".equalsIgnoreCase(ty)) {
+					setSearchTkRate(4, sf);
+				} 
 			}
 			sf.setParams(params);
 		}
+		
 		TaoBaoSearchResult result = TaoBaoUtil.search(sf);
 		if (result == null) {
 			return null;
@@ -679,14 +694,16 @@
 	 * @return
 	 */
 	private JSONObject searchQualityGoods(String key, int page, String filter, String order, String startprice,
-			String endprice) {
+			String endprice ) {
 
 		Integer hasQuan = null;
 		Integer userType = null;
 		Double start_Price = null;
 		Double end_Price = null;
 		Integer sort = null;
-
+		Double startTkRate = null;
+		Double endTkRate = null;
+		
 		int provinceId = -100;
 
 		// 璧峰浠锋牸
@@ -724,14 +741,94 @@
 
 				} else if ("fahuodi".equalsIgnoreCase(ty)) {
 					provinceId = array.optJSONObject(i).optInt("id");
-				}
+				} else if ("tkRate1".equalsIgnoreCase(ty)) {
+					// 鑾峰彇瀵瑰簲鍙傛暟
+					String value = configService.get("tkRate_range");
+					if (!StringUtil.isNullOrEmpty(value)) {
+						JSONArray tkRatearray = JSONArray.fromObject(value);
+						if (tkRatearray != null) {
+							String start = tkRatearray.optJSONObject(0).optString("start");
+							if (!StringUtil.isNullOrEmpty(start)) {
+								startTkRate = Double.parseDouble(start);
+							}
+							String end = tkRatearray.optJSONObject(0).optString("end");
+							if (!StringUtil.isNullOrEmpty(end)) {
+								endTkRate = Double.parseDouble(end);
+							}
+						}
+					}
+				} else if ("tkRate2".equalsIgnoreCase(ty)) {
+					// 鑾峰彇瀵瑰簲鍙傛暟
+					String value = configService.get("tkRate_range");
+					if (!StringUtil.isNullOrEmpty(value)) {
+						JSONArray tkRatearray = JSONArray.fromObject(value);
+						if (tkRatearray != null) {
+							String start = tkRatearray.optJSONObject(1).optString("start");
+							if (!StringUtil.isNullOrEmpty(start)) {
+								startTkRate = Double.parseDouble(start);
+							}
+							String end = tkRatearray.optJSONObject(1).optString("end");
+							if (!StringUtil.isNullOrEmpty(end)) {
+								endTkRate = Double.parseDouble(end);
+							}
+						}
+					}
+				} else if ("tkRate3".equalsIgnoreCase(ty)) {
+					// 鑾峰彇瀵瑰簲鍙傛暟
+					String value = configService.get("tkRate_range");
+					if (!StringUtil.isNullOrEmpty(value)) {
+						JSONArray tkRatearray = JSONArray.fromObject(value);
+						if (tkRatearray != null) {
+							String start = tkRatearray.optJSONObject(2).optString("start");
+							if (!StringUtil.isNullOrEmpty(start)) {
+								startTkRate = Double.parseDouble(start);
+							}
+							String end = tkRatearray.optJSONObject(2).optString("end");
+							if (!StringUtil.isNullOrEmpty(end)) {
+								endTkRate = Double.parseDouble(end);
+							}
+						}
+					}
+				} else if ("tkRate4".equalsIgnoreCase(ty)) {
+					// 鑾峰彇瀵瑰簲鍙傛暟
+					String value = configService.get("tkRate_range");
+					if (!StringUtil.isNullOrEmpty(value)) {
+						JSONArray tkRatearray = JSONArray.fromObject(value);
+						if (tkRatearray != null) {
+							String start = tkRatearray.optJSONObject(3).optString("start");
+							if (!StringUtil.isNullOrEmpty(start)) {
+								startTkRate = Double.parseDouble(start);
+							}
+							String end = tkRatearray.optJSONObject(3).optString("end");
+							if (!StringUtil.isNullOrEmpty(end)) {
+								endTkRate = Double.parseDouble(end);
+							}
+						}
+					}
+				} else if ("tkRate5".equalsIgnoreCase(ty)) {
+					// 鑾峰彇瀵瑰簲鍙傛暟
+					String value = configService.get("tkRate_range");
+					if (!StringUtil.isNullOrEmpty(value)) {
+						JSONArray tkRatearray = JSONArray.fromObject(value);
+						if (tkRatearray != null) {
+							String start = tkRatearray.optJSONObject(4).optString("start");
+							if (!StringUtil.isNullOrEmpty(start)) {
+								startTkRate = Double.parseDouble(start);
+							}
+							String end = tkRatearray.optJSONObject(4).optString("end");
+							if (!StringUtil.isNullOrEmpty(end)) {
+								endTkRate = Double.parseDouble(end);
+							}
+						}
+					}
+				} 
 			}
 		}
 
 		int pageSize = Constant.PAGE_SIZE;
 
 		List<QualityFactory> listQuery = qualityGoodsService.listRecommendBykey(page * pageSize, pageSize, key, hasQuan,
-				userType, start_Price, end_Price, sort);
+				userType, start_Price, end_Price, startTkRate, endTkRate, sort);
 
 		List<TaoBaoGoodsBriefExtra> listExtra = new ArrayList<TaoBaoGoodsBriefExtra>();
 		Map<String, String> map = manageService.convertMap();
@@ -767,7 +864,7 @@
 			}
 		}
 
-		long count = qualityGoodsService.countRecommendBykey(key, hasQuan, userType, start_Price, end_Price);
+		long count = qualityGoodsService.countRecommendBykey(key, hasQuan, userType, start_Price, end_Price, startTkRate, endTkRate);
 
 		// 璁剧疆鍙戣揣鍦板潃
 		TaoBaoSearchNav nav = new TaoBaoSearchNav();
@@ -805,4 +902,35 @@
 		return data;
 	}
 
+	/**
+	 * 璁剧疆鏌ヨ浣i噾姣斾緥鑼冨洿
+	 * @param i
+	 * @param sf
+	 */
+	public void setSearchTkRate(int i, SearchFilter sf) {
+		// 鑾峰彇瀵瑰簲鍙傛暟
+		String value = configService.get("tkRate_range");
+		
+		if (!StringUtil.isNullOrEmpty(value)) {
+			
+			JSONArray tkRatearray = JSONArray.fromObject(value);
+			
+			if (tkRatearray != null) {
+				
+				String start = tkRatearray.optJSONObject(i).optString("start");
+				
+				if (!StringUtil.isNullOrEmpty(start)) {
+					int tkRate = (int) (Float.parseFloat(start) * 100);
+					sf.setStartTkRate(tkRate);
+				}
+				
+				String end = tkRatearray.optJSONObject(i).optString("end");
+				if (!StringUtil.isNullOrEmpty(end)) {
+					int tkRate = (int) (Float.parseFloat(end) * 100);
+					sf.setEndTkRate(tkRate);
+				}
+			}
+			
+		}
+	}
 }

--
Gitblit v1.8.0