From 98b1a0affd69bbe63223c21fdd2c404e8bedfccb Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 20 五月 2020 17:25:08 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into 2.1.2

---
 fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsSubClassAdminController.java |  147 +++++++++++++++++++++++++++++++------------------
 1 files changed, 93 insertions(+), 54 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsSubClassAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsSubClassAdminController.java
index b312031..1a9080c 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsSubClassAdminController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsSubClassAdminController.java
@@ -18,9 +18,14 @@
 import com.google.gson.reflect.TypeToken;
 import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
 import com.yeshi.fanli.entity.bus.clazz.GoodsSubClass;
-import com.yeshi.fanli.exception.FloatADException;
+import com.yeshi.fanli.entity.bus.clazz.GoodsSubClassLabelMap;
+import com.yeshi.fanli.entity.bus.clazz.TaoBaoClass;
+import com.yeshi.fanli.exception.goods.GoodsSubClassException;
+import com.yeshi.fanli.service.inter.clazz.GoodsSubClassLabelService;
 import com.yeshi.fanli.service.inter.goods.GoodsSubClassService;
+import com.yeshi.fanli.service.inter.goods.TaoBaoClassService;
 import com.yeshi.fanli.service.inter.lable.LabelClassService;
+import com.yeshi.fanli.util.StringUtil;
 
 import net.sf.json.JSONObject;
 
@@ -33,8 +38,12 @@
 	@Resource
 	private LabelClassService labelClassService;
 
-	
-	
+	@Resource
+	private TaoBaoClassService taoBaoClassService;
+
+	@Resource
+	private GoodsSubClassLabelService goodsSubClassLabelService;
+
 	/**
 	 * 淇濆瓨淇℃伅
 	 * 
@@ -43,25 +52,49 @@
 	 * @param out
 	 */
 	@RequestMapping(value = "save")
-	public void save(String callback, GoodsSubClass goodsSubClass, Long pid, Integer type, HttpServletRequest request,PrintWriter out) {
+	public void save(String callback, GoodsSubClass goodsSubClass, Long pid, Integer type, Long labelId,
+			HttpServletRequest request, PrintWriter out) {
+		if (goodsSubClass.getTaobaoCids() != null)
+			goodsSubClass.setTaobaoCids(goodsSubClass.getTaobaoCids().replace("锛�", ","));
+
 		try {
-			// 1. 鍏堝垽鏂環ttpRequest 鏄惁鍚湁鏂囦欢绫诲瀷 
+			// 1. 鍏堝垽鏂環ttpRequest 鏄惁鍚湁鏂囦欢绫诲瀷
 			if (request instanceof MultipartHttpServletRequest) {
-		        MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
-		        goodsSubClassService.saveObject(fileRequest.getFile("file"), goodsSubClass, type, pid);
-	        }else{
-	        	goodsSubClassService.saveObject(null, goodsSubClass, type, pid);
-	        }
-			
+				MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
+				goodsSubClassService.saveObject(fileRequest.getFile("file"), fileRequest.getFile("file2"),
+						goodsSubClass, type, pid, labelId);
+			} else {
+				goodsSubClassService.saveObject(null, null, goodsSubClass, type, pid, labelId);
+			}
+
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇濆瓨鎴愬姛"));
-		} catch (FloatADException e) {
+		} catch (GoodsSubClassException e) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
 		} catch (Exception e) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇濆瓨澶辫触"));
 			e.printStackTrace();
 		}
 	}
-
+	
+	
+	/**
+	 * 淇敼鐘舵��
+	 * @param callback
+	 * @param id
+	 * @param out
+	 */
+	@RequestMapping(value = "switchState")
+	public void switchState(String callback, Long id, PrintWriter out) {
+		try {
+			goodsSubClassService.switchState(id);
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛"));
+		} catch (GoodsSubClassException e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
+			e.printStackTrace();
+		}
+	}
 
 	/**
 	 * 鎵归噺鍒犻櫎
@@ -72,11 +105,10 @@
 	 */
 	@RequestMapping(value = "deleteBatch")
 	public void deleteBatch(String callback, String ids, PrintWriter out) {
-
 		Gson gson = new Gson();
-
 		try {
-			List<String> recordIds = gson.fromJson(ids, new TypeToken<ArrayList<String>>() {}.getType());
+			List<String> recordIds = gson.fromJson(ids, new TypeToken<ArrayList<String>>() {
+			}.getType());
 
 			if (recordIds == null || recordIds.size() == 0) {
 				out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("璇烽�夋嫨闇�鍒犻櫎鏁版嵁")));
@@ -85,13 +117,11 @@
 				goodsSubClassService.deleteByPrimaryKeyBatch(recordIds);
 				out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("鍒犻櫎鎴愬姛")));
 			}
-
 		} catch (Exception e) {
 			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")));
 			e.printStackTrace();
 		}
 	}
-
 
 	/**
 	 * 鍒犻櫎鍥剧墖
@@ -103,7 +133,6 @@
 	 */
 	@RequestMapping(value = "removePicture")
 	public void removePicture(String callback, Long id, PrintWriter out) {
-
 		try {
 			GoodsSubClass goodsSubClass = goodsSubClassService.selectByPrimaryKey(id);
 
@@ -121,12 +150,10 @@
 			} else {
 				out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鍥剧墖鍒犻櫎鎴愬姛,鏁版嵁鏇存柊澶辫触")));
 			}
-
 		} catch (Exception e) {
 			e.printStackTrace();
 			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")));
 		}
-
 	}
 
 	/**
@@ -137,20 +164,18 @@
 	 * @param out
 	 */
 	@RequestMapping(value = "querySub")
-	public void querySub(String callback, Long pid, Integer type,PrintWriter out) {
-
+	public void querySub(String callback, Long pid, Integer type, PrintWriter out) {
 		try {
-			
 			if (pid == null) {
 				out.print(JsonUtil.loadFalseResult("涓婄骇id涓虹┖"));
 				return;
 			}
-			
+
 			if (type == null) {
 				out.print(JsonUtil.loadFalseResult("绛夌骇涓嶈兘涓虹┖"));
 				return;
 			}
-			
+
 			Integer state = null;
 			List<GoodsSubClass> goodsSubClassList = new ArrayList<GoodsSubClass>();
 			if (type == 2) {
@@ -158,36 +183,58 @@
 			} else {
 				goodsSubClassList = goodsSubClassService.queryByPid(pid, state);
 			}
-			
+
 			if (goodsSubClassList == null || goodsSubClassList.size() == 0) {
 				out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁")));
 				return;
-			} 
-			
-			for (GoodsSubClass goodsSubClass:goodsSubClassList) {
+			}
+
+			for (GoodsSubClass goodsSubClass : goodsSubClassList) {
 				Long iosClick = goodsSubClass.getIosClick();
 				Long androidClick = goodsSubClass.getAndroidClick();
-				
+
 				if (iosClick != null && androidClick != null) {
-					goodsSubClass.setCountClick(iosClick+androidClick);
-				} else if(androidClick != null) {
+					goodsSubClass.setCountClick(iosClick + androidClick);
+				} else if (androidClick != null) {
 					goodsSubClass.setCountClick(androidClick);
-				} else if(iosClick != null) {
+				} else if (iosClick != null) {
 					goodsSubClass.setCountClick(iosClick);
-				} else{
+				} else {
 					goodsSubClass.setCountClick(0l);
 				}
-				
+
 				String searchJson = goodsSubClass.getSearchJson();
 				if (searchJson == null) {
 					goodsSubClass.setSearchParam("");
 				} else {
 					goodsSubClass.setSearchParam(searchJson);
 				}
-				
-				
+
 				int countlabel = labelClassService.getCountQueryBySubClassId(goodsSubClass.getId());
 				goodsSubClass.setCountlabel(countlabel);
+
+				// 鏌ヨ娣樺疂鍒嗙被
+				List<TaoBaoClass> listTB = taoBaoClassService.listBySystemSubCid(0, 10000, goodsSubClass.getId());
+				if (listTB == null || listTB.size() == 0) {
+					goodsSubClass.setTaobaoCids("");
+				} else {
+					String taobaoCids = "";
+					for (TaoBaoClass taoBaoClass : listTB) {
+						taobaoCids = taobaoCids + taoBaoClass.getCategoryName() + "-" + taoBaoClass.getCategoryId()
+								+ ",";
+					}
+
+					if (!StringUtil.isNullOrEmpty(taobaoCids)) {
+						taobaoCids = taobaoCids.substring(0, taobaoCids.length() - 1);
+					}
+					goodsSubClass.setTaobaoCids(taobaoCids);
+				}
+
+				// 鏌ヨ鏍囩
+				GoodsSubClassLabelMap map = goodsSubClassLabelService.selectBySubClassId(goodsSubClass.getId());
+				if (map != null)
+					goodsSubClass.setClassLabel(map.getLabel());
+
 			}
 
 			GsonBuilder gsonBuilder = new GsonBuilder();
@@ -197,14 +244,12 @@
 			JSONObject data = new JSONObject();
 			data.put("subClassList", gson.toJson(goodsSubClassList));
 			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
-
 		} catch (Exception e) {
 			e.printStackTrace();
 			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")));
 		}
 	}
 
-	
 	/**
 	 * 鏌ユ壘浜岀骇涓嬬殑鍏朵粬绾у垎绫�
 	 * 
@@ -213,7 +258,6 @@
 	 */
 	@RequestMapping(value = "queryOverSecond")
 	public void queryOverSecond(String callback, Long pid, PrintWriter out) {
-
 		try {
 			Integer state = null;
 			List<GoodsSubClass> goodsSubClassList = goodsSubClassService.queryByPid(pid, state);
@@ -230,14 +274,12 @@
 			JSONObject data = new JSONObject();
 			data.put("subClassList", gson.toJson(goodsSubClassList));
 			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
-
 		} catch (Exception e) {
 			e.printStackTrace();
 			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")));
 		}
 	}
-	
-	
+
 	/**
 	 * 淇敼鎺掑簭
 	 * 
@@ -248,45 +290,42 @@
 	@RequestMapping(value = "saveOrder")
 	public void saveOrder(String callback, Long id, Integer type, Integer moveType, PrintWriter out) {
 		try {
-			
 			if (moveType == null || (!moveType.equals(1) && !moveType.equals(-1))) {
 				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("浼犻�掔殑绫诲瀷涓嶆纭�"));
 				return;
 			}
-			
+
 			GoodsSubClass resultObj = goodsSubClassService.selectByPrimaryKey(id);
 			if (resultObj == null) {
 				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("涓嶅瓨鍦ㄨ绫诲埆"));
 				return;
-			} 
+			}
 
 			int resultWeight = resultObj.getWeight();
-			
+
 			List<GoodsSubClass> list = null;
 			if (type == 2) {
 				GoodsClass rootClass = resultObj.getRootClass();
-				list= goodsSubClassService.queryByRootIdAndWeight(rootClass.getId(), moveType, resultWeight);
+				list = goodsSubClassService.queryByRootIdAndWeight(rootClass.getId(), moveType, resultWeight);
 			} else {
 				GoodsSubClass parent = resultObj.getParent();
 				list = goodsSubClassService.queryByPidAndWeight(parent.getId(), moveType, resultWeight);
 			}
-			
+
 			if (list != null && list.size() > 0) {
 				GoodsSubClass changeObj = list.get(0);
 				// 浜ゆ崲鎺掑簭搴忓彿
 				resultObj.setWeight(changeObj.getWeight());
-				
+
 				changeObj.setWeight(resultWeight);
-				
+
 				changeObj.setUpdatetime(new Date());
 				goodsSubClassService.updateByPrimaryKeySelective(changeObj);
 			}
 
 			resultObj.setUpdatetime(new Date());
 			goodsSubClassService.updateByPrimaryKeySelective(resultObj);
-
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛"));
-
 		} catch (Exception e) {
 			e.printStackTrace();
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));

--
Gitblit v1.8.0