From 88b54772dbcf5ecab1e2316e4e4626ac901b8908 Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期二, 22 一月 2019 15:58:24 +0800
Subject: [PATCH] 邀请码添加返回状态

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/GoodsClassController.java |  226 ++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 146 insertions(+), 80 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/GoodsClassController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/GoodsClassController.java
index 9f878fa..0fe5e63 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/GoodsClassController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/GoodsClassController.java
@@ -8,13 +8,12 @@
 import java.util.Map;
 
 import javax.annotation.Resource;
-
-import net.sf.json.JSONArray;
-import net.sf.json.JSONObject;
+import javax.servlet.http.HttpServletRequest;
 
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
+import org.yeshi.utils.JsonUtil;
 
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
@@ -46,14 +45,18 @@
 import com.yeshi.fanli.service.inter.lable.QualityFactoryService;
 import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
 import com.yeshi.fanli.service.inter.lable.TaoKeGoodsService;
+import com.yeshi.fanli.service.inter.monitor.MonitorService;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.RedisManager;
 import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.TimeUtil;
 import com.yeshi.fanli.util.Utils;
+import com.yeshi.fanli.util.factory.MonitorFactory;
 import com.yeshi.fanli.util.taobao.TaoBaoUtil;
 import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
-import org.yeshi.utils.JsonUtil;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
 
 @Controller
 @RequestMapping("api/v1/class")
@@ -102,6 +105,9 @@
 
 	@Resource
 	private QualityGoodsService qualityGoodsService;
+
+	@Resource
+	private MonitorService monitorService;
 
 	/**
 	 * 鑾峰彇涓荤被鐩�
@@ -320,9 +326,7 @@
 				.excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
 		JSONArray array = new JSONArray();
 		List<TaoBaoGoodsBrief> taobaoList = taoKeGoodsService.searchWuLiaoList(sf);
-		Map<String, String> map = manageService.convertMap();
-		String proportion = map.get("hongbao_goods_proportion");
-		String fcRate = map.get("hongbao_fc_ratio");
+		BigDecimal proportion = manageService.getFanLiRate();
 		for (TaoBaoGoodsBrief taoBaoGoodsBrief : taobaoList) {
 			int biz30day = taoBaoGoodsBrief.getBiz30day();
 			if (biz30day >= 10000) {
@@ -332,7 +336,7 @@
 			} else {
 				taoBaoGoodsBrief.setSalesCount(biz30day + "");
 			}
-			array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, fcRate, null)));
+			array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
 		}
 		JSONObject data = new JSONObject();
 		data.put("nav", new JSONArray());
@@ -348,9 +352,11 @@
 	 * @param page
 	 * @param scid
 	 * @param filter
-	 * @param order  鏉ユ簮锛氥�愭帹鑽愶細0  | 缁煎悎锛�4  銆佺患鍚堝彧鐪嬫湁鍒� 1  銆佺患鍚堝彧鐪嬪ぉ鐚� 1  | 浠锋牸锛氫綆鍒伴珮3  楂樺埌浣�2  |  閿�閲忥細1銆�
-	 *               鎺掑簭鍊硷細銆愰攢閲忕敱楂樺埌浣�: 1 锛� 閿�閲忕敱浣庡埌楂� 5锛�  浠锋牸浠庨珮鍒颁綆: 2 锛� 浠锋牸浠庝綆鍒伴珮:3  锛�  鎺ㄥ箍閲忛珮鍒颁綆:4    锛� 鍏朵粬榛樿锛� 閿�閲忕敱楂樺埌浣庛��
-	 *            
+	 * @param order
+	 *            鏉ユ簮锛氥�愭帹鑽愶細0 | 缁煎悎锛�4 銆佺患鍚堝彧鐪嬫湁鍒� 1 銆佺患鍚堝彧鐪嬪ぉ鐚� 1 | 浠锋牸锛氫綆鍒伴珮3 楂樺埌浣�2 | 閿�閲忥細1銆�
+	 *            鎺掑簭鍊硷細銆愰攢閲忕敱楂樺埌浣�: 1 锛� 閿�閲忕敱浣庡埌楂� 5锛� 浠锋牸浠庨珮鍒颁綆: 2 锛� 浠锋牸浠庝綆鍒伴珮:3 锛� 鎺ㄥ箍閲忛珮鍒颁綆:4 锛�
+	 *            鍏朵粬榛樿锛� 閿�閲忕敱楂樺埌浣庛��
+	 * 
 	 * @param startprice
 	 *            璧峰浠锋牸
 	 * @param endprice
@@ -371,71 +377,69 @@
 		}
 
 		try {
-			
+
 			GoodsSubClass goodsSubClass = goodsSubClassService.getSubClassByPrimaryKeyCache(scid);
 			if (goodsSubClass == null) {
 				out.print(JsonUtil.loadFalseResult("涓嶅瓨鍦ㄨ鍒嗙被"));
 				return;
 			}
-			
+
 			if (page == 0) {
 				// 缁熻鐐瑰嚮閲�
 				goodsSubClassService.countClick(acceptData, goodsSubClass);
 			}
-			
+
 			/* 鎼滅储鍏抽敭璇� */
 			String searchKey = goodsSubClass.getName();
 			String key = goodsSubClass.getKey();
 			if (key != null && !"".equals(key.trim())) {
 				searchKey = key;
 			}
-			
+
 			/* 鍟嗗搧绯荤粺鍒嗙被id */
 			Long systemCid = null;
 			GoodsClass rootClass = goodsSubClass.getRootClass();
 			if (rootClass != null) {
 				systemCid = rootClass.getId();
 			}
-			
-			
+
 			// page浠�1寮�濮�
 			page += 1;
 			// 璇锋眰娣樺疂鎺ュ彛椤电爜
-			int pageNo = page; 
-			
+			int pageNo = page;
+
 			int pageSize = Constant.PAGE_SIZE;
-			
-			/*  鏌ヨ鎺ㄨ崘妯″潡  娓呯┖鍏朵粬闈炲繀瑕佺瓫閫夐」鍜屾帓搴忛」   */
+
+			/* 鏌ヨ鎺ㄨ崘妯″潡 娓呯┖鍏朵粬闈炲繀瑕佺瓫閫夐」鍜屾帓搴忛」 */
 			if (!StringUtil.isNullOrEmpty(order) && Integer.parseInt(order) == 0) {
-				
+
 				// 鍒嗙被鍏宠仈鏍囩id闆嗗悎
-				List<Long> listLabId = 
-						labelClassService.getRelationLabIds((page - 1) * pageSize, pageSize, goodsSubClass.getId());
-				
+				List<Long> listLabId = labelClassService.getRelationLabIds((page - 1) * pageSize, pageSize,
+						goodsSubClass.getId());
+
 				/* 璁$畻绮鹃�夊簱鏁版嵁 鎬婚〉鏁� */
 				long incount = taoKeGoodsService.countByQuality(searchKey, systemCid, listLabId);
 
 				int totalPage = (int) (incount % pageSize == 0 ? incount / pageSize : incount / pageSize + 1);
-				
+
 				pageNo = page - totalPage;
-				
-				
+
 				/* 鏌ヨ绮鹃�夊簱鏁版嵁 */
-				if (pageNo <= 0 ) {
-					
-					List<QualityFactory> listQuality = taoKeGoodsService.queryByQuality((page - 1) * pageSize,
-							pageSize,searchKey, systemCid, listLabId);
-					
+				if (pageNo <= 0) {
+
+					List<QualityFactory> listQuality = taoKeGoodsService.queryByQuality((page - 1) * pageSize, pageSize,
+							searchKey, systemCid, listLabId);
+
 					List<TaoBaoGoodsBrief> searchWuLiaoList = null;
-					
-					/*  绮鹃�夊簱鏁版嵁涓嶈冻10鏉�  */
+
+					/* 绮鹃�夊簱鏁版嵁涓嶈冻10鏉� */
 					if (listQuality != null && listQuality.size() != 0 && listQuality.size() < 10) {
-						
+
 						String searchParam = goodsSubClass.getSearchJson();
-						
+
 						Gson gs = new Gson();
 						SearchFilter searchfilter = gs.fromJson(searchParam, SearchFilter.class);
-						
+
 						int quanfilter = searchfilter.getQuan();
 						if (quanfilter != 1) {
 							searchfilter.setQuan(1);
@@ -445,53 +449,51 @@
 						if (endPricefilter == null) {
 							searchfilter.setEndPrice(new BigDecimal(220));
 						}
-						
+
 						boolean includeGoodRate = searchfilter.isIncludeGoodRate();
 						if (!includeGoodRate) {
 							searchfilter.setIncludeGoodRate(true);
 						}
-						
-						//璇锋眰绗竴椤垫暟鎹�
+
+						// 璇锋眰绗竴椤垫暟鎹�
 						searchfilter.setPage(1);
 						searchfilter.setPageSize(pageSize);
 						searchfilter.setKey(searchKey);
 						searchfilter.setMaterialId("6707");
-						
+
 						searchWuLiaoList = taoKeGoodsService.searchWuLiaoList(searchfilter);
 					}
 
 					Map<String, String> map = manageService.convertMap();
-					
+
 					JSONObject data = taoKeGoodsService.listQualityGoods(listQuality, searchWuLiaoList, map);
-					
+
 					out.print(JsonUtil.loadTrueResult(data));
-					
+
 					return;
 				}
-				
-				
-				if (pageNo > 0  && totalPage > 0) {
-					List<QualityFactory>  list = taoKeGoodsService.queryByQuality((totalPage - 1) * pageSize,
-							pageSize, searchKey, systemCid, listLabId);
-					
+
+				if (pageNo > 0 && totalPage > 0) {
+					List<QualityFactory> list = taoKeGoodsService.queryByQuality((totalPage - 1) * pageSize, pageSize,
+							searchKey, systemCid, listLabId);
+
 					if (list != null && list.size() != 0 && list.size() < 10) {
 						// 椤电爜+ 1 宸茶姹備竴娆℃窐瀹濇帴鍙�
-						pageNo += 1 ;
+						pageNo += 1;
 					}
 				}
 			}
-			
-	
-			/* 缃戠粶璇锋眰  */
+
+			/* 缃戠粶璇锋眰 */
 			SearchFilter searchfilter = null;
 			String searchParam = goodsSubClass.getSearchJson();
-			
-			if (!StringUtil.isNullOrEmpty(searchParam) && !StringUtil.isNullOrEmpty(order) 
+
+			if (!StringUtil.isNullOrEmpty(searchParam) && !StringUtil.isNullOrEmpty(order)
 					&& Integer.parseInt(order) == 0) {
 				// 鎺ㄨ崘 浣跨敤瀛愬垎绫婚粯璁ゆ煡璇㈡潯浠�
 				Gson gs = new Gson();
 				searchfilter = gs.fromJson(searchParam, SearchFilter.class);
-				
+
 				int quanfilter = searchfilter.getQuan();
 				if (quanfilter != 1) {
 					searchfilter.setQuan(1);
@@ -501,26 +503,32 @@
 				if (endPricefilter == null) {
 					searchfilter.setEndPrice(new BigDecimal(220));
 				}
-				
+
 				boolean includeGoodRate = searchfilter.isIncludeGoodRate();
 				if (!includeGoodRate) {
 					searchfilter.setIncludeGoodRate(true);
 				}
-				
+
 			} else {
 				searchfilter = new SearchFilter();
 				// 璁剧疆SearchFilter
-				taoKeGoodsService.setSearchFilter(searchfilter, filter, order, startprice, endprice, fastFilter, totalSales);
+				taoKeGoodsService.setSearchFilter(searchfilter, filter, order, startprice, endprice, fastFilter,
+						totalSales);
+				
+				// 鐢ㄦ埛鏈緭鍏ユ渶楂樹环鏍兼椂    鏈�楂樹环鏍奸檺鍒�99999
+				if (searchfilter.getEndPrice() == null) {
+					searchfilter.setEndPrice(new BigDecimal(99999));
+				}
 			}
 
 			searchfilter.setPage(pageNo);
 			searchfilter.setPageSize(pageSize);
 			searchfilter.setKey(searchKey);
-			
-			if (!StringUtil.isNullOrEmpty(order) && Integer.parseInt(order) != 4 ) {
+
+			if (!StringUtil.isNullOrEmpty(order) && Integer.parseInt(order) != 4) {
 				searchfilter.setMaterialId("6707");
 			}
-			
+
 			// 鏌ヨ鐗╂枡鎺ュ彛
 			JSONObject result = taoKeGoodsService.searchWuLiao(searchfilter);
 			out.print(JsonUtil.loadTrueResult(result));
@@ -600,9 +608,7 @@
 		Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
 				.excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
 
-		Map<String, String> map = manageService.convertMap();
-		String proportion = map.get("hongbao_goods_proportion");
-		String fcRate = map.get("hongbao_fc_ratio");
+		BigDecimal proportion = manageService.getFanLiRate();
 
 		// 閬嶅巻鍒楄〃鏁版嵁
 		for (QualityFactory selectionGoods : listQuery) {
@@ -622,7 +628,7 @@
 				taoBaoGoodsBrief.setSalesCount(biz30day + "");
 			}
 
-			array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, fcRate, null)));
+			array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
 		}
 
 		JSONObject data = new JSONObject();
@@ -673,18 +679,16 @@
 	}
 
 	@RequestMapping("getCouponList")
-	public void getCouponList(AcceptData acceptData, int page, PrintWriter out) {
+	public void getCouponList(AcceptData acceptData, int page, HttpServletRequest request, PrintWriter out) {
 		page = page > 0 ? page : 1;
 		List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = taoBaoCouponService.getTaoBaoCouponList(page);
-		Map<String, String> map = manageService.convertMap();
-		String proportion = map.get("hongbao_goods_proportion");
-		String fcRate = map.get("hongbao_fc_ratio");
+		BigDecimal proportion = manageService.getFanLiRate();
 		JSONArray array = new JSONArray();
 		TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra;
 		Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
 
 		for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) {
-			taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, fcRate, "");
+			taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), "");
 			array.add(gson.toJson(taoBaoGoodsBriefExtra));
 		}
 		int count = 10000;
@@ -692,6 +696,12 @@
 		data.put("taoBaoCoupons", array);
 		data.put("count", count);
 		out.print(JsonUtil.loadTrueResult(data));
+
+		try {
+			monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, 0, null));
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
 	}
 
 	/**
@@ -759,12 +769,10 @@
 		data.put("nav", gson.toJson(navList));
 		List<TaoBaoGoodsBriefExtra> re = new ArrayList<TaoBaoGoodsBriefExtra>();
 		List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = result.getTaoBaoGoodsBriefs();
-		Map<String, String> map = manageService.convertMap();
-		String proportion = map.get("hongbao_goods_proportion");
-		String fcRate = map.get("hongbao_fc_ratio");
+		BigDecimal proportion = manageService.getFanLiRate();
 		TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra;
 		for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) {
-			taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, fcRate, "");
+			taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), "");
 			re.add(taoBaoGoodsBriefExtra);
 		}
 
@@ -789,12 +797,70 @@
 	 */
 	private void setTaoBaoCouponHongBao(List<TaoBaoCoupon> taoBaoCoupons) {
 		if (taoBaoCoupons.size() > 0) {
-			String proportion = hongBaoManageService.get(Constant.HONGBAO_GOODS_PROPORTION);
+			BigDecimal proportion= hongBaoManageService.getFanLiRate();
+			
 			for (TaoBaoCoupon taoBaoCoupon : taoBaoCoupons) {
-				BigDecimal hb = TaoBaoUtil.getCouponHongBaoInfo(taoBaoCoupon, new BigDecimal(proportion));
+				BigDecimal hb = TaoBaoUtil.getCouponHongBaoInfo(taoBaoCoupon,proportion);
 				taoBaoCoupon.setHongbao(hb);
 			}
 		}
 	}
-	
+
+	@RequestMapping(value = { "getcategory" }, method = { org.springframework.web.bind.annotation.RequestMethod.POST })
+	public void getcategory(AcceptData acceptData, PrintWriter out) {
+		com.yeshi.fanli.entity.system.System system = this.systemService.getSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
+		if (system == null) {
+			out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
+			return;
+		}
+
+		List<SuperGoodsClass> superGoodsClassList = this.superGoodsClassService
+				.getSuperGoodsClassBySystemId(system.getId().longValue());
+		if ((superGoodsClassList == null) || (superGoodsClassList.size() == 0)) {
+			out.print(JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
+			return;
+		}
+
+		List<GoodsClass> goodsClassList = new ArrayList<GoodsClass>();
+		for (SuperGoodsClass superGoodsClass : superGoodsClassList) {
+			GoodsClass goodsClass = superGoodsClass.getGoodsClass();
+			goodsClassList.add(goodsClass);
+		}
+
+		JSONArray array = new JSONArray();
+
+		Gson gson = new GsonBuilder().create();
+
+		if (goodsClassList.size() > 0) {
+			for (GoodsClass goodsClass : goodsClassList) {
+				goodsClass.setKey(null);
+				goodsClass.setCreatetime(0L);
+				goodsClass.setSearchParam(null);
+				goodsClass.setIosClick(null);
+				goodsClass.setAndroidClick(null);
+
+				JSONObject data = new JSONObject();
+				data.put("gclass", goodsClass);
+				long gcid = goodsClass.getId();
+				try {
+					List<GoodsSubClass> subClassList = this.goodsSubClassService.getSubClassCache(Long.valueOf(gcid),
+							Integer.valueOf(1));
+					if ((subClassList == null) || (subClassList.size() == 0)) {
+						subClassList = new ArrayList<GoodsSubClass>();
+					}
+					data.put("subList", gson.toJson(subClassList));
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+
+				array.add(data);
+			}
+		}
+
+		JSONObject data = new JSONObject();
+		data.put("categoryList", array);
+
+		out.print(JsonUtil.loadTrueResult(data));
+	}
 }

--
Gitblit v1.8.0