From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 25 二月 2025 16:41:22 +0800
Subject: [PATCH] 淘宝转链接口更新

---
 fanli/src/main/java/com/yeshi/fanli/controller/admin/BrandShopAdminController.java | 1156 ++++++++++++++++++++++++++++++--------------------------
 1 files changed, 617 insertions(+), 539 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/BrandShopAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/BrandShopAdminController.java
index 5748f06..f810ae1 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/BrandShopAdminController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/BrandShopAdminController.java
@@ -1,539 +1,617 @@
-package com.yeshi.fanli.controller.admin;
-
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.multipart.MultipartHttpServletRequest;
-import org.yeshi.utils.JsonUtil;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.reflect.TypeToken;
-import com.yeshi.fanli.dto.taobao.TaoBaoShopInfoDTO;
-import com.yeshi.fanli.entity.brand.BrandClass;
-import com.yeshi.fanli.entity.brand.BrandClassShop;
-import com.yeshi.fanli.entity.brand.BrandInfo;
-import com.yeshi.fanli.entity.taobao.TaoBaoShop;
-import com.yeshi.fanli.entity.taobao.TaoBaoShopInfo;
-import com.yeshi.fanli.exception.brand.BrandClassException;
-import com.yeshi.fanli.exception.brand.BrandClassShopException;
-import com.yeshi.fanli.exception.brand.BrandInfoException;
-import com.yeshi.fanli.service.inter.brand.BrandClassService;
-import com.yeshi.fanli.service.inter.brand.BrandClassShopService;
-import com.yeshi.fanli.service.inter.brand.BrandInfoService;
-import com.yeshi.fanli.tag.PageEntity;
-import com.yeshi.fanli.util.Constant;
-import com.yeshi.fanli.util.StringUtil;
-import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
-
-import net.sf.json.JSONArray;
-import net.sf.json.JSONObject;
-
-@Controller
-@RequestMapping("admin/new/api/v1/brand")
-public class BrandShopAdminController {
-
-	@Resource
-	private BrandClassService brandClassService;
-
-	@Resource
-	private BrandClassShopService brandClassShopService;
-	
-	@Resource
-	private BrandInfoService brandInfoService;
-
-	/**
-	 * 淇濆瓨淇℃伅
-	 * 
-	 * @param callback
-	 * @param special
-	 * @param out
-	 */
-	@RequestMapping(value = "save")
-	public void save(String callback, BrandClass brandClass, PrintWriter out) {
-		try {
-			brandClassService.saveObject(brandClass);
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇濆瓨鎴愬姛"));
-		} catch (BrandClassException e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
-		} catch (Exception e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇濆瓨澶辫触"));
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * 淇敼鎺掑簭
-	 * 
-	 * @param callback
-	 * @param goodsClass
-	 * @param out
-	 */
-	@RequestMapping(value = "updateOrder")
-	public void updateOrder(String callback, Long id, Integer moveType, PrintWriter out) {
-		try {
-			brandClassService.updateOrder(id, moveType);
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛"));
-		} catch (BrandClassException e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
-		} catch (Exception e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * 鏌ヨ
-	 * 
-	 * @param callback
-	 * @param pageIndex
-	 * @param pageSize
-	 * @param key
-	 *            妯$硦鏌ヨ锛氳鏄庛�佹爣璇�
-	 * @param out
-	 */
-	@RequestMapping(value = "query")
-	public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer state,
-			PrintWriter out) {
-
-		if (pageIndex == null || pageIndex < 1) {
-			pageIndex = 1;
-		}
-
-		if (pageSize == null || pageSize < 1) {
-			pageSize = Constant.PAGE_SIZE;
-		}
-
-		try {
-			List<BrandClass> list = brandClassService.listQuery((pageIndex - 1) * pageSize, pageSize, key, state);
-
-			if (list == null || list.size() == 0) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
-				return;
-			}
-
-			long count = brandClassService.countQuery(key, state);
-
-			int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
-			PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
-
-			GsonBuilder gsonBuilder = new GsonBuilder();
-			gsonBuilder.serializeNulls();
-			Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
-
-			JSONObject data = new JSONObject();
-			data.put("pe", pe);
-			data.put("result_list", gson.toJson(list));
-
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
-
-		} catch (Exception e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * 鍒犻櫎
-	 * 
-	 * @param callback
-	 * @param idArray
-	 * @param out
-	 */
-	@RequestMapping(value = "delete")
-	public void delete(String callback, String idArray, PrintWriter out) {
-
-		try {
-			if (StringUtil.isNullOrEmpty(idArray)) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨鎿嶄綔鐨勬暟鎹�"));
-				return;
-			}
-			Gson gson = new Gson();
-			List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
-			}.getType());
-
-			if (list == null || list.size() == 0) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈娴嬪埌鍒犻櫎鐨勬暟鎹�"));
-				return;
-			}
-			int count = brandClassService.deleteBatchByPrimaryKey(list);
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎴愬姛鍒犻櫎[" + count + "]鏉℃暟鎹�"));
-		} catch (Exception e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍒犻櫎澶辫触"));
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * 绛涢�夊垪琛�
-	 * 
-	 * @param callback
-	 * @param out
-	 */
-	@RequestMapping(value = "getOptions")
-	public void getOptions(String callback, PrintWriter out) {
-		try {
-			List<BrandClass> list = brandClassService.listEffective();
-			if (list == null || list.size() == 0) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
-				return;
-			}
-
-			List<Object> result_list = new ArrayList<Object>();
-			if (list != null && list.size() > 0) {
-				for (BrandClass record : list) {
-					Map<String, Object> map = new HashMap<String, Object>();
-					map.put("key", record.getId());
-					map.put("value", record.getName());
-					result_list.add(map);
-				}
-			}
-
-			JSONObject data = new JSONObject();
-			data.put("result_list", result_list);
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
-		} catch (Exception e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * 鏌ヨ
-	 * 
-	 * @param callback
-	 * @param pageIndex
-	 * @param pageSize
-	 * @param key
-	 *            妯$硦鏌ヨ锛氳鏄庛�佹爣璇�
-	 * @param out
-	 */
-	@RequestMapping(value = "queryTaoBaoShop")
-	public void queryTaoBaoShop(String callback, Integer pageIndex, Integer pageSize, String key, PrintWriter out) {
-
-		if (pageIndex == null || pageIndex < 1) {
-			pageIndex = 1;
-		}
-
-		if (pageSize == null || pageSize < 1) {
-			pageSize = Constant.PAGE_SIZE;
-		}
-
-		try {
-			TaoBaoShopInfoDTO taoBaoShopInfoDTO = TaoKeApiUtil.searchShop(key, pageIndex, pageSize);
-
-			List<TaoBaoShopInfo> listInfo = taoBaoShopInfoDTO.getListInfo();
-			if (listInfo == null || listInfo.size() == 0) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
-				return;
-			}
-
-			List<Long> listShopId = new ArrayList<Long>();
-			for (TaoBaoShopInfo taoBaoShopInfo : listInfo) {
-				listShopId.add(taoBaoShopInfo.getUserId());
-			}
-
-			// 宸插瓨鍦ㄦ暟鎹簱涓�
-			List<BrandClassShop> listExist = brandClassShopService.getExistByShopIds(listShopId);
-
-			JSONArray array = new JSONArray();
-			for (TaoBaoShopInfo taoBaoShopInfo : listInfo) {
-				String name = "";
-				if (listExist != null && listExist.size() > 0) {
-					Long userId = taoBaoShopInfo.getUserId();
-					for (BrandClassShop brandClassShop : listExist) {
-						TaoBaoShop shop = brandClassShop.getShop();
-						if (shop != null && userId == shop.getId() || userId.equals(shop.getId())) {
-							BrandClass brandClass = brandClassShop.getBrandClass();
-							name = brandClass.getName();
-						}
-					}
-				}
-
-				JSONObject innerData = new JSONObject();
-				innerData.put("cname", name);
-				innerData.put("shopInfo", taoBaoShopInfo);
-				array.add(innerData);
-			}
-
-			JSONObject data = new JSONObject();
-			data.put("pe", taoBaoShopInfoDTO.getPage());
-			data.put("result_list", array);
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
-		} catch (Exception e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * 娣诲姞搴楅摵鍏ュ簱
-	 * 
-	 * @param callback
-	 * @param special
-	 * @param out
-	 */
-	@RequestMapping(value = "saveShopInfo")
-	public void saveShopInfo(String callback, Long cid, String idArray, PrintWriter out) {
-		try {
-			if (StringUtil.isNullOrEmpty(idArray)) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨鎿嶄綔鐨勬暟鎹�"));
-				return;
-			}
-			Gson gson = new Gson();
-			List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
-			}.getType());
-
-			String shopIds = brandClassShopService.saveShopInfo(cid, list);
-			if (StringUtil.isNullOrEmpty(shopIds)) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇濆瓨鎴愬姛"));
-			} else {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("浠ヤ笅搴楅摵ID:" + shopIds + ",鏈坊鍔犳垚鍔�"));
-			}
-		} catch (BrandClassShopException e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
-		} catch (Exception e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇濆瓨澶辫触"));
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * 鏌ヨ
-	 * 
-	 * @param callback
-	 * @param pageIndex
-	 * @param pageSize
-	 * @param key
-	 *            妯$硦鏌ヨ锛氳鏄庛�佹爣璇�
-	 * @param out
-	 */
-	@RequestMapping(value = "queryClassShop")
-	public void queryClassShop(String callback, Integer pageIndex, Integer pageSize, String key, Long cid,
-			Integer state, PrintWriter out) {
-
-		if (pageIndex == null || pageIndex < 1) {
-			pageIndex = 1;
-		}
-
-		if (pageSize == null || pageSize < 1) {
-			pageSize = Constant.PAGE_SIZE;
-		}
-
-		try {
-			List<BrandClassShop> list = brandClassShopService.listQuery((pageIndex - 1) * pageSize, pageSize, key, cid,
-					state);
-
-			if (list == null || list.size() == 0) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
-				return;
-			}
-
-			long count = brandClassShopService.countQuery(key, cid, state);
-
-			int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
-			PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
-
-			GsonBuilder gsonBuilder = new GsonBuilder();
-			gsonBuilder.serializeNulls();
-			Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
-
-			JSONObject data = new JSONObject();
-			data.put("pe", pe);
-			data.put("result_list", gson.toJson(list));
-
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
-
-		} catch (Exception e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * 淇濆瓨淇℃伅
-	 * 
-	 * @param callback
-	 * @param special
-	 * @param out
-	 */
-	@RequestMapping(value = "saveClassShop")
-	public void saveClassShop(String callback, Long id, Long cid, String shopName, Integer state, Integer top,
-			String key, HttpServletRequest request, PrintWriter out) {
-		try {
-			if (request instanceof MultipartHttpServletRequest) {
-				MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
-				brandClassShopService.changeShopInfo(fileRequest.getFile("file"), id, cid, shopName, state, top, key);
-			} else {
-				brandClassShopService.changeShopInfo(null, id, cid, shopName, state, top, key);
-			}
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇濆瓨鎴愬姛"));
-		} catch (BrandClassShopException e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
-		} catch (Exception e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇濆瓨澶辫触"));
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * 淇敼鎺掑簭
-	 * 
-	 * @param callback
-	 * @param goodsClass
-	 * @param out
-	 */
-	@RequestMapping(value = "updateOrderClassShop")
-	public void updateOrderClassShop(String callback, Long id, Integer moveType, PrintWriter out) {
-		try {
-			brandClassShopService.updateOrder(id, moveType);
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛"));
-		} catch (BrandClassShopException e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
-		} catch (Exception e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * 鍒犻櫎
-	 * 
-	 * @param callback
-	 * @param idArray
-	 * @param out
-	 */
-	@RequestMapping(value = "deleteClassShop")
-	public void deleteClassShop(String callback, String idArray, PrintWriter out) {
-		try {
-			if (StringUtil.isNullOrEmpty(idArray)) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨鎿嶄綔鐨勬暟鎹�"));
-				return;
-			}
-			Gson gson = new Gson();
-			List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
-			}.getType());
-
-			if (list == null || list.size() == 0) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈娴嬪埌鍒犻櫎鐨勬暟鎹�"));
-				return;
-			}
-
-			brandClassShopService.deleteBatchByPrimaryKey(list);
-
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鍒犻櫎鎴愬姛"));
-		} catch (Exception e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍒犻櫎澶辫触"));
-			e.printStackTrace();
-		}
-	}
-	
-	
-	
-	/**
-	 * 鍝佺墝淇℃伅淇濆瓨
-	 * @param callback
-	 * @param brandInfo
-	 * @param out
-	 */
-	@RequestMapping(value = "saveBrand")
-	public void saveBrand(String callback, BrandInfo brandInfo, PrintWriter out) {
-		try {
-			brandInfoService.saveObject(brandInfo);
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇濆瓨鎴愬姛"));
-		} catch (BrandInfoException e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
-		} catch (Exception e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇濆瓨澶辫触"));
-			e.printStackTrace();
-		}
-	}
-	
-	
-	/**
-	 * 鍒犻櫎
-	 * 
-	 * @param callback
-	 * @param idArray
-	 * @param out
-	 */
-	@RequestMapping(value = "deleteBrand")
-	public void deleteBrand(String callback, String idArray, PrintWriter out) {
-		try {
-			if (StringUtil.isNullOrEmpty(idArray)) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨鎿嶄綔鐨勬暟鎹�"));
-				return;
-			}
-			Gson gson = new Gson();
-			List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
-			}.getType());
-
-			if (list == null || list.size() == 0) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈娴嬪埌鍒犻櫎鐨勬暟鎹�"));
-				return;
-			}
-			int count = brandInfoService.deleteBatchByPrimaryKey(list);
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎴愬姛鍒犻櫎[" + count + "]鏉℃暟鎹�"));
-		} catch (Exception e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍒犻櫎澶辫触"));
-			e.printStackTrace();
-		}
-	}
-	
-	/**
-	 * 鍝佺墝淇℃伅鏌ヨ
-	 * @param callback
-	 * @param pageIndex
-	 * @param pageSize
-	 * @param key
-	 * @param cid
-	 * @param state
-	 * @param out
-	 */
-	@RequestMapping(value = "queryBrand")
-	public void query(String callback, Integer pageIndex, Integer pageSize, String key, Long cid, Integer state,
-			PrintWriter out) {
-
-		if (pageIndex == null || pageIndex < 1) {
-			pageIndex = 1;
-		}
-
-		if (pageSize == null || pageSize < 1) {
-			pageSize = Constant.PAGE_SIZE;
-		}
-
-		try {
-			List<BrandInfo> list = brandInfoService.listQuery((pageIndex - 1) * pageSize, pageSize, key, cid, state);
-
-			if (list == null || list.size() == 0) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
-				return;
-			}
-
-			long count = brandInfoService.countQuery(key, cid, state);
-			int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
-			PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
-
-			GsonBuilder gsonBuilder = new GsonBuilder();
-			gsonBuilder.serializeNulls();
-			Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
-
-			JSONObject data = new JSONObject();
-			data.put("pe", pe);
-			data.put("result_list", gson.toJson(list));
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
-		} catch (Exception e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
-			e.printStackTrace();
-		}
-	}
-
-}
+package com.yeshi.fanli.controller.admin;
+
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+import com.yeshi.fanli.entity.SystemEnum;
+import com.yeshi.fanli.entity.accept.AdminAcceptData;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.yeshi.utils.JsonUtil;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.reflect.TypeToken;
+import com.yeshi.goods.facade.dto.taobao.TaoBaoShopInfoDTO;
+import com.yeshi.fanli.entity.brand.BrandClass;
+import com.yeshi.fanli.entity.brand.BrandClassShop;
+import com.yeshi.fanli.entity.brand.BrandInfo;
+import com.yeshi.common.entity.taobao.TaoBaoShop;
+import com.yeshi.common.entity.taobao.TaoBaoShopInfo;
+import com.yeshi.fanli.exception.brand.BrandClassException;
+import com.yeshi.fanli.exception.brand.BrandClassShopException;
+import com.yeshi.fanli.exception.brand.BrandInfoException;
+import com.yeshi.fanli.service.inter.brand.BrandClassService;
+import com.yeshi.fanli.service.inter.brand.BrandClassShopService;
+import com.yeshi.fanli.service.inter.brand.BrandInfoService;
+import com.yeshi.common.entity.PageEntity;
+import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+@Controller
+@RequestMapping("admin/new/api/v1/brand")
+public class BrandShopAdminController {
+
+	@Resource
+	private BrandClassService brandClassService;
+
+	@Resource
+	private BrandClassShopService brandClassShopService;
+	
+	@Resource
+	private BrandInfoService brandInfoService;
+
+	/**
+	 * 淇濆瓨淇℃伅
+	 * 
+	 * @param callback
+	 * @param out
+	 */
+	@RequestMapping(value = "save")
+	public void save(AdminAcceptData acceptData, String callback, BrandClass brandClass, PrintWriter out) {
+		try {
+			List<SystemEnum> systemList=new ArrayList<>();
+			systemList.add(acceptData.getSystem());
+			brandClassService.saveObject(brandClass,systemList);
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇濆瓨鎴愬姛"));
+		} catch (BrandClassException e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇濆瓨澶辫触"));
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 淇敼鎺掑簭
+	 * 
+	 * @param callback
+	 * @param out
+	 */
+	@RequestMapping(value = "updateOrder")
+	public void updateOrder(AdminAcceptData acceptData,String callback, Long id, Integer moveType, PrintWriter out) {
+		try {
+			brandClassService.updateOrder(id, moveType,acceptData.getSystem());
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛"));
+		} catch (BrandClassException e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 鏌ヨ
+	 * 
+	 * @param callback
+	 * @param pageIndex
+	 * @param pageSize
+	 * @param key
+	 *            妯$硦鏌ヨ锛氳鏄庛�佹爣璇�
+	 * @param out
+	 */
+	@RequestMapping(value = "query")
+	public void query(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, String key, Integer state,
+			PrintWriter out) {
+		if (pageIndex == null || pageIndex < 1) {
+			pageIndex = 1;
+		}
+
+		if (pageSize == null || pageSize < 1) {
+			pageSize = Constant.PAGE_SIZE;
+		}
+
+		try {
+			List<BrandClass> list = brandClassService.listQuery((pageIndex - 1) * pageSize, pageSize, key, state,acceptData.getSystem());
+			if (list == null || list.size() == 0) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
+				return;
+			}
+
+			long count = brandClassService.countQuery(key, state,acceptData.getSystem());
+
+			int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
+			PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
+
+			GsonBuilder gsonBuilder = new GsonBuilder();
+			gsonBuilder.serializeNulls();
+			Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
+
+			JSONObject data = new JSONObject();
+			data.put("pe", pe);
+			data.put("result_list", gson.toJson(list));
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * 淇敼鐘舵��
+	 * @param callback
+	 * @param id
+	 * @param out
+	 */
+	@RequestMapping(value = "switchStateClass")
+	public void switchStateClass(AdminAcceptData acceptData,String callback, Long id, PrintWriter out) {
+		try {
+			brandClassService.switchState(id);
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛"));
+		} catch (BrandClassException e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 鍒犻櫎
+	 * 
+	 * @param callback
+	 * @param idArray
+	 * @param out
+	 */
+	@RequestMapping(value = "delete")
+	public void delete(AdminAcceptData acceptData,String callback, String idArray, PrintWriter out) {
+		try {
+			if (StringUtil.isNullOrEmpty(idArray)) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨鎿嶄綔鐨勬暟鎹�"));
+				return;
+			}
+			Gson gson = new Gson();
+			List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
+			}.getType());
+
+			if (list == null || list.size() == 0) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈娴嬪埌鍒犻櫎鐨勬暟鎹�"));
+				return;
+			}
+			int count = brandClassService.deleteBatchByPrimaryKey(list);
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎴愬姛鍒犻櫎[" + count + "]鏉℃暟鎹�"));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍒犻櫎澶辫触"));
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 绛涢�夊垪琛�
+	 * 
+	 * @param callback
+	 * @param out
+	 */
+	@RequestMapping(value = "getOptions")
+	public void getOptions(AdminAcceptData acceptData, String callback, PrintWriter out) {
+		try {
+			List<BrandClass> list = brandClassService.listEffective(acceptData.getSystem());
+			if (list == null || list.size() == 0) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
+				return;
+			}
+
+			List<Object> result_list = new ArrayList<Object>();
+			if (list != null && list.size() > 0) {
+				for (BrandClass record : list) {
+					Map<String, Object> map = new HashMap<String, Object>();
+					map.put("key", record.getId());
+					map.put("value", record.getName());
+					result_list.add(map);
+				}
+			}
+
+			JSONObject data = new JSONObject();
+			data.put("result_list", result_list);
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 鏌ヨ
+	 * 
+	 * @param callback
+	 * @param pageIndex
+	 * @param pageSize
+	 * @param key
+	 *            妯$硦鏌ヨ锛氳鏄庛�佹爣璇�
+	 * @param out
+	 */
+	@RequestMapping(value = "queryTaoBaoShop")
+	public void queryTaoBaoShop(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, String key, PrintWriter out) {
+
+		if (pageIndex == null || pageIndex < 1) {
+			pageIndex = 1;
+		}
+
+		if (pageSize == null || pageSize < 1) {
+			pageSize = Constant.PAGE_SIZE;
+		}
+
+		try {
+			TaoBaoShopInfoDTO taoBaoShopInfoDTO = TaoKeApiUtil.searchShop(key, pageIndex, pageSize);
+
+			List<TaoBaoShopInfo> listInfo = taoBaoShopInfoDTO.getListInfo();
+			if (listInfo == null || listInfo.size() == 0) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
+				return;
+			}
+
+			List<Long> listShopId = new ArrayList<Long>();
+			for (TaoBaoShopInfo taoBaoShopInfo : listInfo) {
+				listShopId.add(taoBaoShopInfo.getUserId());
+			}
+
+			// 宸插瓨鍦ㄦ暟鎹簱涓�
+			List<BrandClassShop> listExist = brandClassShopService.getExistByShopIds(listShopId);
+
+			JSONArray array = new JSONArray();
+			for (TaoBaoShopInfo taoBaoShopInfo : listInfo) {
+				String name = "";
+				if (listExist != null && listExist.size() > 0) {
+					Long userId = taoBaoShopInfo.getUserId();
+					for (BrandClassShop brandClassShop : listExist) {
+						TaoBaoShop shop = brandClassShop.getShop();
+						if (shop != null && userId == shop.getId() || userId.equals(shop.getId())) {
+							BrandClass brandClass = brandClassShop.getBrandClass();
+							name = brandClass.getName();
+						}
+					}
+				}
+
+				JSONObject innerData = new JSONObject();
+				innerData.put("cname", name);
+				innerData.put("shopInfo", taoBaoShopInfo);
+				array.add(innerData);
+			}
+
+			JSONObject data = new JSONObject();
+			data.put("pe", taoBaoShopInfoDTO.getPage());
+			data.put("result_list", array);
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 娣诲姞搴楅摵鍏ュ簱
+	 * 
+	 * @param callback
+	 * @param out
+	 */
+	@RequestMapping(value = "saveShopInfo")
+	public void saveShopInfo(AdminAcceptData acceptData,String callback, Long cid, String idArray, PrintWriter out) {
+		try {
+			if (StringUtil.isNullOrEmpty(idArray)) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨鎿嶄綔鐨勬暟鎹�"));
+				return;
+			}
+			Gson gson = new Gson();
+			List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
+			}.getType());
+
+			String shopIds = brandClassShopService.saveShopInfo(cid, list);
+			if (StringUtil.isNullOrEmpty(shopIds)) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇濆瓨鎴愬姛"));
+			} else {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("浠ヤ笅搴楅摵ID:" + shopIds + ",鏈坊鍔犳垚鍔�"));
+			}
+		} catch (BrandClassShopException e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇濆瓨澶辫触"));
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 鏌ヨ
+	 * 
+	 * @param callback
+	 * @param pageIndex
+	 * @param pageSize
+	 * @param key
+	 *            妯$硦鏌ヨ锛氳鏄庛�佹爣璇�
+	 * @param out
+	 */
+	@RequestMapping(value = "queryClassShop")
+	public void queryClassShop(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, String key, Long cid,
+			Integer state, PrintWriter out) {
+
+		if (pageIndex == null || pageIndex < 1) {
+			pageIndex = 1;
+		}
+
+		if (pageSize == null || pageSize < 1) {
+			pageSize = Constant.PAGE_SIZE;
+		}
+
+		try {
+			List<BrandClassShop> list = brandClassShopService.listQuery((pageIndex - 1) * pageSize, pageSize, key, cid,
+					state);
+
+			if (list == null || list.size() == 0) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
+				return;
+			}
+
+			long count = brandClassShopService.countQuery(key, cid, state);
+
+			int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
+			PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
+
+			GsonBuilder gsonBuilder = new GsonBuilder();
+			gsonBuilder.serializeNulls();
+			Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
+
+			JSONObject data = new JSONObject();
+			data.put("pe", pe);
+			data.put("result_list", gson.toJson(list));
+
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 淇濆瓨淇℃伅
+	 * 
+	 * @param callback
+	 * @param out
+	 */
+	@RequestMapping(value = "saveClassShop")
+	public void saveClassShop(AdminAcceptData acceptData,String callback, Long id, Long cid, String shopName, Integer state, Integer top,
+			String key, HttpServletRequest request, PrintWriter out) {
+		try {
+			if (request instanceof MultipartHttpServletRequest) {
+				MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
+				brandClassShopService.changeShopInfo(fileRequest.getFile("file"), id, cid, shopName, state, top, key);
+			} else {
+				brandClassShopService.changeShopInfo(null, id, cid, shopName, state, top, key);
+			}
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇濆瓨鎴愬姛"));
+		} catch (BrandClassShopException e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇濆瓨澶辫触"));
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 淇敼鎺掑簭
+	 * 
+	 * @param callback
+	 * @param out
+	 */
+	@RequestMapping(value = "updateOrderClassShop")
+	public void updateOrderClassShop(AdminAcceptData acceptData,String callback, Long id, Integer moveType, PrintWriter out) {
+		try {
+			brandClassShopService.updateOrder(id, moveType);
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛"));
+		} catch (BrandClassShopException e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 鍒犻櫎
+	 * 
+	 * @param callback
+	 * @param idArray
+	 * @param out
+	 */
+	@RequestMapping(value = "deleteClassShop")
+	public void deleteClassShop(AdminAcceptData acceptData,String callback, String idArray, PrintWriter out) {
+		try {
+			if (StringUtil.isNullOrEmpty(idArray)) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨鎿嶄綔鐨勬暟鎹�"));
+				return;
+			}
+			Gson gson = new Gson();
+			List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
+			}.getType());
+
+			if (list == null || list.size() == 0) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈娴嬪埌鍒犻櫎鐨勬暟鎹�"));
+				return;
+			}
+
+			brandClassShopService.deleteBatchByPrimaryKey(list);
+
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鍒犻櫎鎴愬姛"));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍒犻櫎澶辫触"));
+			e.printStackTrace();
+		}
+	}
+	
+	
+	
+	/**
+	 * 鍝佺墝淇℃伅淇濆瓨
+	 * @param callback
+	 * @param brandInfo
+	 * @param out
+	 */
+	@RequestMapping(value = "saveBrand")
+	public void saveBrand(AdminAcceptData acceptData,String callback, BrandInfo brandInfo, HttpServletRequest request, PrintWriter out) {
+		try {
+			// 1. 鍏堝垽鏂環ttpRequest 鏄惁鍚湁鏂囦欢绫诲瀷 
+			if (request instanceof MultipartHttpServletRequest) {
+		        MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
+		        brandInfoService.saveObject(fileRequest.getFile("file"), brandInfo);
+	        }else{
+	        	brandInfoService.saveObject(null, brandInfo);
+	        }
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇濆瓨鎴愬姛"));
+		} catch (BrandInfoException 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 = "switchStateBrand")
+	public void switchStateBrand(AdminAcceptData acceptData,String callback, Long id, PrintWriter out) {
+		try {
+			brandInfoService.switchState(id);
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛"));
+		} catch (BrandInfoException e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * 鍒犻櫎
+	 * 
+	 * @param callback
+	 * @param idArray
+	 * @param out
+	 */
+	@RequestMapping(value = "deleteBrand")
+	public void deleteBrand(AdminAcceptData acceptData,String callback, String idArray, PrintWriter out) {
+		try {
+			if (StringUtil.isNullOrEmpty(idArray)) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨鎿嶄綔鐨勬暟鎹�"));
+				return;
+			}
+			Gson gson = new Gson();
+			List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
+			}.getType());
+
+			if (list == null || list.size() == 0) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈娴嬪埌鍒犻櫎鐨勬暟鎹�"));
+				return;
+			}
+			int count = brandInfoService.deleteBatchByPrimaryKey(list);
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎴愬姛鍒犻櫎[" + count + "]鏉℃暟鎹�"));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍒犻櫎澶辫触"));
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * 淇敼鎺掑簭
+	 * 
+	 * @param callback
+	 * @param out
+	 */
+	@RequestMapping(value = "updateOrderBrand")
+	public void updateOrderBrand(AdminAcceptData acceptData,String callback, Long id, Integer moveType, PrintWriter out) {
+		try {
+			brandInfoService.updateOrder(id, moveType);
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛"));
+		} catch (BrandInfoException e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * 鍝佺墝淇℃伅鏌ヨ
+	 * @param callback
+	 * @param pageIndex
+	 * @param pageSize
+	 * @param key
+	 * @param cid
+	 * @param state
+	 * @param out
+	 */
+	@RequestMapping(value = "queryBrand")
+	public void queryBrand(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, String key, Long cid, Integer state,
+			Integer showState, PrintWriter out) {
+
+		if (pageIndex == null || pageIndex < 1) {
+			pageIndex = 1;
+		}
+
+		if (pageSize == null || pageSize < 1) {
+			pageSize = Constant.PAGE_SIZE;
+		}
+		
+		List<String> keys = null;
+		if (!StringUtil.isNullOrEmpty(key)) {
+			String[] array = key.split("\\s+");
+			if (array != null && array.length > 0) {
+				keys = new ArrayList<String>();
+				for (int i= 0; i < array.length; i++) {
+					keys.add(array[i].toString());
+				}
+			}
+		}
+		
+		try {
+			List<BrandInfo> list = brandInfoService.listQuery((pageIndex - 1) * pageSize, pageSize, keys, cid, state, showState);
+
+			if (list == null || list.size() == 0) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
+				return;
+			}
+			
+			for (BrandInfo brandInfo: list) {
+				BrandClass brandClass = brandInfo.getBrandClass();
+				if (brandClass != null && StringUtil.isNullOrEmpty(brandClass.getName())) {
+					BrandClass bclass = brandClassService.selectByPrimaryKey(brandClass.getId());
+					if (bclass != null) {
+						brandInfo.setBrandClass(bclass);
+					}
+				}
+			}
+
+			long count = brandInfoService.countQuery(keys, cid, state, showState);
+			int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
+			PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
+
+			GsonBuilder gsonBuilder = new GsonBuilder();
+			gsonBuilder.serializeNulls();
+			Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
+
+			JSONObject data = new JSONObject();
+			data.put("pe", pe);
+			data.put("result_list", gson.toJson(list));
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			e.printStackTrace();
+		}
+	}
+
+}

--
Gitblit v1.8.0