From 8cb7ec4a35a38ae91d0eed17cde711e81d2b2bbf Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期二, 14 五月 2019 11:37:49 +0800
Subject: [PATCH] 合并

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/BrandController.java |   64 +++++++++++++++++++++++++++++--
 1 files changed, 59 insertions(+), 5 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/BrandController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/BrandController.java
index 63ca51b..e24c7ce 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/BrandController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/BrandController.java
@@ -31,6 +31,7 @@
 import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.ThreadUtil;
 import com.yeshi.fanli.util.taobao.TaoBaoUtil;
 import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
 
@@ -97,7 +98,7 @@
 				out.print(JsonUtil.loadFalseResult("搴楅摵id涓虹┖"));
 				return;
 			}
-			taoBaoShopHistoryService.addHistory(sid, uid, acceptData.getDevice());
+			
 			out.print(JsonUtil.loadTrueResult("璁板綍鎴愬姛"));
 		} catch (Exception e) {
 			out.print(JsonUtil.loadFalseResult("璁板綍澶辫触"));
@@ -137,6 +138,15 @@
 	@RequestMapping(value = "getHistory", method = RequestMethod.POST)
 	public void getHistory(AcceptData acceptData, Integer page, Long uid, Integer type, PrintWriter out) {
 		try {
+			if (type == null) {
+				out.print(JsonUtil.loadFalseResult("绫诲瀷涓嶆纭�"));
+				return;
+			}
+
+			if (page == null || page < 1) {
+				page = 1;
+			}
+			
 			int pageSize;
 			if (type == 1) {
 				pageSize = 4;
@@ -164,13 +174,29 @@
 				for (TaoBaoShopHistory history : listHistory) {
 					TaoBaoShop taoBaoShop = history.getTaoBaoShop();
 					if (taoBaoShop != null) {
+						
+						String shopLink = taoBaoShop.getShopLink();
+						if (StringUtil.isNullOrEmpty(shopLink)) {
+							taoBaoShop.setShopLink(TaoBaoUtil.getShopLink(taoBaoShop.getId()));
+						}
+						
+						String shopNameCustom = taoBaoShop.getShopNameCustom();
+						if (!StringUtil.isNullOrEmpty(shopNameCustom)) {
+							taoBaoShop.setShopName(shopNameCustom);
+						}
+						
+						String shopIconCustom = taoBaoShop.getShopIconCustom();
+						if (!StringUtil.isNullOrEmpty(shopIconCustom)) {
+							taoBaoShop.setShopIcon(shopIconCustom);
+						}
+						
 						list.add(taoBaoShop);
 					}
 				}
 			}
 
 			JSONObject data = new JSONObject();
-			data.put("count", list.size());
+			data.put("count", count);
 			data.put("list", JsonUtil.getApiCommonGson().toJson(list));
 
 			out.print(JsonUtil.loadTrueResult(data));
@@ -207,16 +233,44 @@
 	 * @param out
 	 */
 	@RequestMapping(value = "getShopInfo", method = RequestMethod.POST)
-	public void getShopInfo(AcceptData acceptData, Integer page, Long sid, PrintWriter out) {
+	public void getShopInfo(AcceptData acceptData, Integer page, Long sid, Long uid, PrintWriter out) {
 		try {
+			if (sid == null) {
+				out.print(JsonUtil.loadFalseResult("缂哄け搴楅摵id"));
+				return;
+			}
+			
 			JSONObject data = new JSONObject();
 			if (page == 1) {
 				TaoBaoShop taoBaoShop = taoBaoShopService.selectByPrimaryKey(sid);
 				if (taoBaoShop == null) {
 					out.print(JsonUtil.loadFalseResult("搴楅摵淇℃伅鑾峰彇澶辫触"));
+					return;
 				}
-				taoBaoShop.setShopLink(TaoBaoUtil.getShopLink(taoBaoShop.getId()));
-				data.put("shop", taoBaoShop);
+				String shopLink = taoBaoShop.getShopLink();
+				if (StringUtil.isNullOrEmpty(shopLink)) {
+					taoBaoShop.setShopLink(TaoBaoUtil.getShopLink(taoBaoShop.getId()));
+				}
+				
+				String shopNameCustom = taoBaoShop.getShopNameCustom();
+				if (!StringUtil.isNullOrEmpty(shopNameCustom)) {
+					taoBaoShop.setShopName(shopNameCustom);
+				}
+				
+				String shopIconCustom = taoBaoShop.getShopIconCustom();
+				if (!StringUtil.isNullOrEmpty(shopIconCustom)) {
+					taoBaoShop.setShopIcon(shopIconCustom);
+				}
+				data.put("shop", JsonUtil.getApiCommonGson().toJson(taoBaoShop));
+				
+				
+				ThreadUtil.run(new Runnable() {
+					public void run() {
+						// 娣诲姞瓒宠抗
+						taoBaoShopHistoryService.addHistory(sid, uid, acceptData.getDevice());
+					}
+				});
+				
 			}
 
 			int pageSize = Constant.PAGE_SIZE;

--
Gitblit v1.8.0