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/client/v2/BrandControllerV2.java |  853 +++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 719 insertions(+), 134 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/BrandControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/BrandControllerV2.java
index b6d8b20..40f77c2 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/BrandControllerV2.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/BrandControllerV2.java
@@ -1,7 +1,6 @@
 package com.yeshi.fanli.controller.client.v2;
 
 import java.io.PrintWriter;
-import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -14,25 +13,44 @@
 
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
+import com.yeshi.fanli.dto.ConfigParamsDTO;
+import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
 import com.yeshi.fanli.entity.accept.AcceptData;
+import com.yeshi.fanli.entity.brand.BrandGoodsCahe;
+import com.yeshi.fanli.entity.brand.BrandInfo;
+import com.yeshi.fanli.entity.brand.BrandInfoRecord;
+import com.yeshi.fanli.entity.brand.BrandShopCahe;
+import com.yeshi.fanli.entity.brand.TaoBaoShopHistory;
+import com.yeshi.fanli.entity.jd.JDGoods;
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
 import com.yeshi.fanli.entity.taobao.TaoBaoShop;
-import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
+import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
 import com.yeshi.fanli.exception.taobao.TaoKeApiException;
 import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
 import com.yeshi.fanli.service.inter.brand.BrandClassService;
 import com.yeshi.fanli.service.inter.brand.BrandClassShopService;
+import com.yeshi.fanli.service.inter.brand.BrandGoodsCaheService;
+import com.yeshi.fanli.service.inter.brand.BrandInfoRecordService;
+import com.yeshi.fanli.service.inter.brand.BrandInfoService;
+import com.yeshi.fanli.service.inter.brand.BrandShopCaheService;
 import com.yeshi.fanli.service.inter.brand.TaoBaoShopHistoryService;
 import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
-import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
+import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
+import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
+import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
-import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsService;
+import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service;
+import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.ThreadUtil;
+import com.yeshi.fanli.util.VersionUtil;
 import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
 import com.yeshi.fanli.util.taobao.TaoBaoUtil;
 import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
+import com.yeshi.fanli.vo.brand.BrandInfoVO;
 import com.yeshi.fanli.vo.goods.GoodsDetailVO;
+import com.yeshi.fanli.vo.goods.ShopInfoVO;
+import com.yeshi.fanli.vo.homemodule.BannerVO;
 
 import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
@@ -54,17 +72,32 @@
 	private TaoBaoShopHistoryService taoBaoShopHistoryService;
 
 	@Resource
-	private HongBaoManageService hongBaoManageService;
+	private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
 
-	
 	@Resource
 	private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
 
 	@Resource
-	private DaTaoKeGoodsService daTaoKeGoodsService;
+	private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
 
-
-
+	@Resource
+	private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
+	
+	@Resource
+	private BrandInfoService brandInfoService;
+	
+	@Resource
+	private SwiperPictureService swiperPictureService;
+	
+	@Resource
+	private BrandInfoRecordService brandInfoRecordService;
+	
+	@Resource
+	private BrandGoodsCaheService brandGoodsCaheService;
+	
+	@Resource
+	private BrandShopCaheService brandShopCaheService;
+	
 
 	/**
 	 * 搴楅摵鍒楄〃
@@ -74,16 +107,91 @@
 	 */
 	@RequestMapping(value = "getShopList", method = RequestMethod.POST)
 	public void getShopList(AcceptData acceptData, Integer page, Long cid, PrintWriter out) {
-		try {
-			if (page == null || page < 1) {
-				page = 1;
-			}
-			JSONObject data = brandClassShopService.listEffectiveCacheV2(page, cid);
-			out.print(JsonUtil.loadTrueResult(data));
-		} catch (Exception e) {
-			e.printStackTrace();
-			out.print(JsonUtil.loadFalseResult("鏌ヨ澶辫触"));
+		if (page == null || page < 1) {
+			page = 1;
 		}
+		JSONObject data = brandClassShopService.listEffectiveCacheV2(page, cid,acceptData.getPlatform(),acceptData.getVersion());
+		out.print(JsonUtil.loadTrueResult(data));
+	}
+
+	/**
+	 * 搴楅摵瓒宠抗
+	 * 
+	 * @param acceptData
+	 * @param type
+	 *            绮鹃��1锛� 瓒宠抗鍒楄〃2
+	 * @param out
+	 */
+	@RequestMapping(value = "getHistory", method = RequestMethod.POST)
+	public void getHistory(AcceptData acceptData, Integer page, Long uid, Integer type, PrintWriter out) {
+		if (type == null) {
+			out.print(JsonUtil.loadFalseResult("绫诲瀷涓嶆纭�"));
+			return;
+		}
+
+		if (page == null || page < 1) {
+			page = 1;
+		}
+
+		int pageSize;
+		if (type == 1) {
+			pageSize = 4;
+		} else {
+			pageSize = Constant.PAGE_SIZE;
+		}
+
+		long count = 0;
+		List<TaoBaoShopHistory> listHistory = null;
+		if (uid == null || uid == 0) {
+			String device = acceptData.getDevice();
+			count = taoBaoShopHistoryService.countByDevice(device);
+			if (count > 0) {
+				listHistory = taoBaoShopHistoryService.listByDevice((page - 1) * pageSize, pageSize, device);
+			}
+		} else {
+			count = taoBaoShopHistoryService.countByUid(uid);
+			if (count > 0) {
+				listHistory = taoBaoShopHistoryService.listByUid((page - 1) * pageSize, pageSize, uid);
+			}
+		}
+
+		List<TaoBaoShop> list = new ArrayList<TaoBaoShop>();
+		if (listHistory != null && listHistory.size() > 0) {
+			for (TaoBaoShopHistory history : listHistory) {
+				TaoBaoShop taoBaoShop = history.getTaoBaoShop();
+				if (taoBaoShop != null) {
+
+					Integer userType = taoBaoShop.getUserType();
+					if (userType == null || userType == 0) {
+						taoBaoShop.setUserType(10);
+					} else {
+						taoBaoShop.setUserType(11);
+					}
+
+					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", count);
+		data.put("list", JsonUtil.getApiCommonGson().toJson(list));
+		out.print(JsonUtil.loadTrueResult(data));
 	}
 
 	/**
@@ -94,24 +202,429 @@
 	 */
 	@RequestMapping(value = "getShopInfo", method = RequestMethod.POST)
 	public void getShopInfo(AcceptData acceptData, Integer page, Long sid, Long uid, PrintWriter out) {
-		try {
-			if (sid == null) {
-				out.print(JsonUtil.loadFalseResult("缂哄け搴楅摵id"));
+		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;
 			}
-			
-			JSONObject data = new JSONObject();
-			if (page == 1) {
-				TaoBaoShop taoBaoShop = taoBaoShopService.selectByPrimaryKey(sid);
-				if (taoBaoShop == null) {
-					out.print(JsonUtil.loadFalseResult("搴楅摵淇℃伅鑾峰彇澶辫触"));
-					return;
+			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);
+			}
+
+			Integer userType = taoBaoShop.getUserType();
+			if (userType == null || userType == 0) {
+				taoBaoShop.setUserType(10);
+			} else {
+				taoBaoShop.setUserType(11);
+			}
+
+			data.put("shop", JsonUtil.getApiCommonGson().toJson(taoBaoShop));
+
+			ThreadUtil.run(new Runnable() {
+				public void run() {
+					// 娣诲姞瓒宠抗
+					taoBaoShopHistoryService.addHistory(sid, uid, acceptData.getDevice());
 				}
-				String shopLink = taoBaoShop.getShopLink();
-				if (StringUtil.isNullOrEmpty(shopLink)) {
-					taoBaoShop.setShopLink(TaoBaoUtil.getShopLink(taoBaoShop.getId()));
+			});
+		}
+
+		// 鍟嗗搧鍒楄〃淇℃伅
+		int pageSize = 50;
+		List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
+
+		// 鍏堟煡璇㈠ぇ娣樺鏁版嵁
+		List<DaTaoKeDetailV2> listDaTaoKe = daTaoKeGoodsDetailV2Service.listBySellerId(0, pageSize, sid);
+		if (listDaTaoKe != null && listDaTaoKe.size() > 0) {
+			for (DaTaoKeDetailV2 daTaoKe : listDaTaoKe) {
+				listGoodsBrief.add(TaoBaoUtil.convert(daTaoKe));
+			}
+		}
+
+		// 涓嶈冻50鏉℃暟鎹�佹煡璇㈢簿閫夊簱
+		if (listGoodsBrief.size() < pageSize) {
+			int needCount = pageSize - listGoodsBrief.size();
+			List<TaoBaoGoodsBrief> listGoods = taoBaoGoodsBriefService.listByShopId(0, needCount, sid);
+			if (listGoods != null && listGoods.size() > 0) {
+
+				if (listGoodsBrief.size() > 0) {
+					for (int i = 0; i < listGoods.size(); i++) {
+						long id = listGoods.get(i).getAuctionId();
+						boolean isRepeat = false;
+						for (TaoBaoGoodsBrief goodsBrief : listGoodsBrief) {
+							long auctionId = goodsBrief.getAuctionId();
+							if (auctionId == id) {
+								isRepeat = true;
+								break;
+							}
+						}
+						if (isRepeat) {
+							listGoods.remove(i);
+							i--;
+						}
+					}
 				}
-				
+
+				listGoodsBrief.addAll(listGoods);
+			}
+		}
+
+		JSONArray array = new JSONArray();
+		if (listGoodsBrief.size() > 0) {
+			List<Long> listGid = new ArrayList<Long>();
+			for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) {
+				listGid.add(taoBaoGoodsBrief.getAuctionId());
+			}
+			// API缃戠粶鎺ュ彛楠岃瘉鏄惁鍦ㄥ敭
+			List<TaoBaoGoodsBrief> listTaoKeGoods = null;
+			try {
+				listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
+			} catch (TaoKeApiException e) {
+				e.printStackTrace();
+			} catch (TaobaoGoodsDownException e) {
+				e.printStackTrace();
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+
+			Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
+					.excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
+
+			ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
+					acceptData.getVersion());
+			// 鍟嗗搧淇℃伅杩囨护
+			listGoodsBrief = taoBaoGoodsUpdateService.filterImportantTaoBaoGoods(listGoodsBrief);
+
+			for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) {
+				if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) {
+					boolean stateSale = false; // 榛樿鍋滃敭
+					Long goodsId = taoBaoGoodsBrief.getAuctionId();
+					for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
+						Long auctionId = taoKeGoods.getAuctionId();
+						if (goodsId == auctionId || goodsId.equals(auctionId)) {
+							stateSale = true; // 鍦ㄥ敭
+							break;
+						}
+					}
+					if (!stateSale) {
+						continue;
+					}
+				}
+				GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO);
+				array.add(gson.toJson(goodsDetailVO));
+			}
+		}
+
+		data.put("count", array.size());
+		data.put("list", array);
+		out.print(JsonUtil.loadTrueResult(data));
+		// 娣诲姞鍒版洿鏂板垪琛�
+		taoBaoGoodsUpdateService.addUpdateQueueAsync(listGoodsBrief);
+	}
+
+	
+	
+	
+	/**
+	 * 鍝佺墝鍒楄〃鍒楄〃
+	 * 
+	 * @param acceptData
+	 * @param out
+	 */
+	@RequestMapping(value = "getList", method = RequestMethod.POST)
+	public void getList(AcceptData acceptData, Integer page, Long cid, Long uid, PrintWriter out) {
+		if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
+			if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) {
+				getListV3(acceptData, page, cid, uid, out);
+				return;
+			}
+		} else {
+			if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
+				getListV3(acceptData, page, cid, uid, out);
+				return;
+			}
+		}
+		
+		if (page == null || page < 1) {
+			out.print(JsonUtil.loadFalseResult("椤电爜涓嶆纭�"));
+			return;
+		}
+		
+		if (cid != null && cid == 0) {
+			cid = null;
+		}
+		
+		JSONObject data = new JSONObject();
+		if (page == 1 && cid != null) {
+			List<BrandInfo> brandlist = brandInfoService.listValidBrandInfoCache(cid);
+			if(brandlist == null)
+				brandlist = new ArrayList<BrandInfo>();
+			data.put("brandlist", JsonUtil.getApiCommonGson().toJson(brandlist));
+		}
+		
+		
+		long count = brandInfoService.countBrandInfo(cid);
+		
+		List<BrandInfoVO> list = brandInfoService.listBrandInfoCache((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, cid,acceptData.getPlatform(),acceptData.getVersion());
+		if (list == null)
+			list = new ArrayList<BrandInfoVO>();
+		
+		GsonBuilder gb = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder());
+		gb.excludeFieldsWithoutExposeAnnotation();
+		Gson gson = gb.create();
+		
+		data.put("count", count);
+		data.put("list", gson.toJson(list));
+		out.print(JsonUtil.loadTrueResult(data));
+	}
+	
+	
+	/**
+	 * 搴楅摵璇︽儏杩囨浮椤�
+	 * 
+	 * @param acceptData
+	 * @param out
+	 */
+	@RequestMapping(value = "getShopInfoV2", method = RequestMethod.POST)
+	public void getShopInfoV2(AcceptData acceptData, Integer page, Long id, Long uid, PrintWriter out) {
+		
+		if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
+			if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) {
+				getShopInfoV3(acceptData, page, id, uid, out);
+				return;
+			}
+		} else {
+			if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
+				getShopInfoV3(acceptData, page, id, uid, out);
+				return;
+			}
+		}
+		
+		if (id == null) {
+			out.print(JsonUtil.loadFalseResult("缂哄け搴楅摵id"));
+			return;
+		}
+		
+		List<TaoBaoShop> shopList = new ArrayList<TaoBaoShop>();
+		List<BannerVO> topPicList = new ArrayList<>();
+		
+		JSONObject data = new JSONObject();
+		if (page == 1) {
+			// 2銆侀《閮ㄨ疆鎾浘
+			List<BannerVO> oldtopPicList = swiperPictureService.getByBannerCardAndVersion("brand_picture",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
+			if (oldtopPicList != null && oldtopPicList.size() > 0)
+				topPicList.addAll(oldtopPicList);
+			TaoBaoShop taoBaoShop = taoBaoShopService.selectByPrimaryKey(id);
+			if (taoBaoShop == null) {
+				out.print(JsonUtil.loadFalseResult("搴楅摵淇℃伅鑾峰彇澶辫触"));
+				return;
+			}
+			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);
+			}
+
+			Integer userType = taoBaoShop.getUserType();
+			if (userType == null || userType == 0) {
+				taoBaoShop.setUserType(10);
+			} else {
+				taoBaoShop.setUserType(11);
+			}
+
+			shopList.add(taoBaoShop);
+			ThreadUtil.run(new Runnable() {
+				public void run() {
+					// 娣诲姞瓒宠抗
+					taoBaoShopHistoryService.addHistory(id, uid, acceptData.getDevice());
+				}
+			});
+		}
+		data.put("picList", JsonUtil.getApiCommonGson().toJson(topPicList));
+		data.put("shopList", JsonUtil.getApiCommonGson().toJson(shopList));
+		
+
+		// 鍟嗗搧鍒楄〃淇℃伅
+		int pageSize = 50;
+		List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
+
+		// 鍏堟煡璇㈠ぇ娣樺鏁版嵁
+		List<DaTaoKeDetailV2> listDaTaoKe = daTaoKeGoodsDetailV2Service.listBySellerId(0, pageSize, id);
+		if (listDaTaoKe != null && listDaTaoKe.size() > 0) {
+			for (DaTaoKeDetailV2 daTaoKe : listDaTaoKe) {
+				listGoodsBrief.add(TaoBaoUtil.convert(daTaoKe));
+			}
+		}
+
+		// 涓嶈冻50鏉℃暟鎹�佹煡璇㈢簿閫夊簱
+		if (listGoodsBrief.size() < pageSize) {
+			int needCount = pageSize - listGoodsBrief.size();
+			List<TaoBaoGoodsBrief> listGoods = taoBaoGoodsBriefService.listByShopId(0, needCount, id);
+			if (listGoods != null && listGoods.size() > 0) {
+
+				if (listGoodsBrief.size() > 0) {
+					for (int i = 0; i < listGoods.size(); i++) {
+						long aid = listGoods.get(i).getAuctionId();
+						boolean isRepeat = false;
+						for (TaoBaoGoodsBrief goodsBrief : listGoodsBrief) {
+							long auctionId = goodsBrief.getAuctionId();
+							if (auctionId == aid) {
+								isRepeat = true;
+								break;
+							}
+						}
+						if (isRepeat) {
+							listGoods.remove(i);
+							i--;
+						}
+					}
+				}
+
+				listGoodsBrief.addAll(listGoods);
+			}
+		}
+
+		JSONArray array = new JSONArray();
+		if (listGoodsBrief.size() > 0) {
+			List<Long> listGid = new ArrayList<Long>();
+			for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) {
+				listGid.add(taoBaoGoodsBrief.getAuctionId());
+			}
+			// API缃戠粶鎺ュ彛楠岃瘉鏄惁鍦ㄥ敭
+			List<TaoBaoGoodsBrief> listTaoKeGoods = null;
+			try {
+				listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
+			} catch (TaoKeApiException e) {
+				e.printStackTrace();
+			} catch (TaobaoGoodsDownException e) {
+				e.printStackTrace();
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+
+			Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
+					.excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
+
+			ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
+					acceptData.getVersion());
+			// 鍟嗗搧淇℃伅杩囨护
+			listGoodsBrief = taoBaoGoodsUpdateService.filterImportantTaoBaoGoods(listGoodsBrief);
+
+			for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) {
+				if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) {
+					boolean stateSale = false; // 榛樿鍋滃敭
+					Long goodsId = taoBaoGoodsBrief.getAuctionId();
+					for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
+						Long auctionId = taoKeGoods.getAuctionId();
+						if (goodsId == auctionId || goodsId.equals(auctionId)) {
+							stateSale = true; // 鍦ㄥ敭
+							break;
+						}
+					}
+					if (!stateSale) {
+						continue;
+					}
+				}
+				GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO);
+				array.add(gson.toJson(goodsDetailVO));
+			}
+		}
+
+		data.put("count", array.size());
+		data.put("list", array);
+		out.print(JsonUtil.loadTrueResult(data));
+		// 娣诲姞鍒版洿鏂板垪琛�
+		taoBaoGoodsUpdateService.addUpdateQueueAsync(listGoodsBrief);
+	}
+	
+	
+	/**
+	 * 搴楅摵瓒宠抗
+	 * 
+	 * @param acceptData
+	 * @param type
+	 *            绮鹃��1锛� 瓒宠抗鍒楄〃2
+	 * @param out
+	 */
+	@RequestMapping(value = "getHistoryV2", method = RequestMethod.POST)
+	public void getHistoryV2(AcceptData acceptData, Integer page, Long uid, Integer type, PrintWriter out) {
+		if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
+			if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) {
+				getHistoryV3(acceptData, page, uid, type, out);
+				return;
+			}
+		} else {
+			if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
+				getHistoryV3(acceptData, page, uid, type, out);
+				return;
+			}
+		}
+		
+		if (type == null) {
+			out.print(JsonUtil.loadFalseResult("绫诲瀷涓嶆纭�"));
+			return;
+		}
+
+		if (page == null || page < 1) {
+			out.print(JsonUtil.loadFalseResult("椤电爜涓嶆纭�"));
+			return;
+		}
+
+		int pageSize;
+		if (type == 1) {
+			pageSize = 4;
+		} else {
+			pageSize = Constant.PAGE_SIZE;
+		}
+		
+		long count = 0;
+		List<TaoBaoShopHistory> listHistory = null;
+		if (uid == null || uid == 0) {
+			String device = acceptData.getDevice();
+			count = taoBaoShopHistoryService.countByDevice(device);
+			if (count > 0) {
+				listHistory = taoBaoShopHistoryService.listByDevice((page - 1) * pageSize, pageSize, device);
+			}
+		} else {
+			count = taoBaoShopHistoryService.countByUid(uid);
+			if (count > 0) {
+				listHistory = taoBaoShopHistoryService.listByUid((page - 1) * pageSize, pageSize, uid);
+			}
+		}
+		
+		List<BrandInfo> list = new ArrayList<BrandInfo>();
+		if (listHistory != null && listHistory.size() > 0) {
+			for (TaoBaoShopHistory history : listHistory) {
+				TaoBaoShop taoBaoShop = history.getTaoBaoShop();
+				if (taoBaoShop == null)
+					continue;
+					
 				String shopNameCustom = taoBaoShop.getShopNameCustom();
 				if (!StringUtil.isNullOrEmpty(shopNameCustom)) {
 					taoBaoShop.setShopName(shopNameCustom);
@@ -121,111 +634,183 @@
 				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());
-					}
-				});
+				BrandInfo brandInfo = new BrandInfo();
+				brandInfo.setId(taoBaoShop.getId());
+				brandInfo.setName(taoBaoShop.getShopName());
+				brandInfo.setIcon(taoBaoShop.getShopIcon());
+			    list.add(brandInfo);
 			}
-
-			
-			// 鍟嗗搧鍒楄〃淇℃伅
-			int pageSize = 50;
-			List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
-			
-			// 鍏堟煡璇㈠ぇ娣樺鏁版嵁
-			List<DaTaoKeDetail> listDaTaoKe = daTaoKeGoodsService.listBySellerId(0, pageSize, sid);
-			if (listDaTaoKe != null && listDaTaoKe.size() > 0) {
-				for (DaTaoKeDetail daTaoKe: listDaTaoKe) {
-					listGoodsBrief.add(TaoBaoUtil.convert(daTaoKe));
-				}
-			}
-			
-			// 涓嶈冻50鏉℃暟鎹�佹煡璇㈢簿閫夊簱
-			if (listGoodsBrief.size() < pageSize) {
-				int needCount = pageSize- listGoodsBrief.size();
-				List<TaoBaoGoodsBrief> listGoods = taoBaoGoodsBriefService.listByShopId(0, needCount, sid);
-				if (listGoods != null && listGoods.size() > 0) {
-					
-					if (listGoodsBrief.size() > 0) {
-						for (int i = 0; i< listGoods.size(); i ++) {
-							long id = listGoods.get(i).getAuctionId();
-							boolean isRepeat = false;
-							for (TaoBaoGoodsBrief goodsBrief: listGoodsBrief) {
-								long auctionId = goodsBrief.getAuctionId();
-								if (auctionId == id) {
-									isRepeat = true;
-									break;
-								}
-							}
-							if(isRepeat) {
-								listGoods.remove(i);
-								i--;
-							}
-						}
-					}
-					
-					listGoodsBrief.addAll(listGoods);
-				}
-			}
-			
-
-			JSONArray array = new JSONArray();
-			if (listGoodsBrief.size() > 0) {
-				List<Long> listGid = new ArrayList<Long>();
-				for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) {
-					listGid.add(taoBaoGoodsBrief.getAuctionId());
-				}
-				// API缃戠粶鎺ュ彛楠岃瘉鏄惁鍦ㄥ敭
-				List<TaoBaoGoodsBrief> listTaoKeGoods = null;
-				try {
-					listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
-				} catch (TaoKeApiException e) {
-					e.printStackTrace();
-				} catch (TaobaoGoodsDownException e) {
-					e.printStackTrace();
-				} catch (Exception e) {
-					e.printStackTrace();
-				}
-				
-
-				Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
-						.excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
-				
-				BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
-				BigDecimal shareRate = hongBaoManageService.getShareRate();
-				
-				for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) {
-					if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) {
-						boolean stateSale = false; // 榛樿鍋滃敭
-						Long goodsId = taoBaoGoodsBrief.getAuctionId();
-						for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
-							Long auctionId = taoKeGoods.getAuctionId();
-							if (goodsId == auctionId || goodsId.equals(auctionId)) {
-								stateSale = true; // 鍦ㄥ敭
-								break;
-							}
-						}
-						if (!stateSale) {
-							continue;
-						}
-					}
-					GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, fanLiRate, shareRate);
-					array.add(gson.toJson(goodsDetailVO));
-				}
-			}
-			
-			data.put("count", array.size());
-			data.put("list", array);
-			out.print(JsonUtil.loadTrueResult(data));
-		} catch (Exception e) {
-			e.printStackTrace();
-			out.print(JsonUtil.loadFalseResult("鏌ヨ澶辫触"));
 		}
+		
+		JSONObject data = new JSONObject();
+		data.put("count", count);
+		data.put("list", JsonUtil.getApiCommonGson().toJson(list));
+		out.print(JsonUtil.loadTrueResult(data));
 	}
+	
+	
+	/**
+	 * 鍝佺墝鍒楄〃鍒楄〃
+	 * 
+	 * @param acceptData
+	 * @param out
+	 */
+//	@RequestMapping(value = "getList", method = RequestMethod.POST)
+	public void getListV3(AcceptData acceptData, Integer page, Long cid, Long uid, PrintWriter out) {
+		if (page == null || page < 1) {
+			out.print(JsonUtil.loadFalseResult("椤电爜涓嶆纭�"));
+			return;
+		}
+		if (cid != null && cid == 0) {
+			cid = null;
+		}
+		
+		
+		JSONObject data = new JSONObject();
+		if (page == 1  && cid == null) { // 绮鹃�夐〉banner
+			List<BannerVO> banners = swiperPictureService.getByBannerCardAndVersion("brand_banners",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
+			if (banners == null)
+				banners = new ArrayList<>();
+			data.put("banners", JsonUtil.getApiCommonGson().toJson(banners));
+		}
+		
+		if (page == 1 && cid != null) {
+			List<BrandInfo> brandlist = brandInfoService.listValidByCidToApp(cid);
+			if(brandlist == null)
+				brandlist = new ArrayList<BrandInfo>();
+			data.put("brandlist", JsonUtil.getApiCommonGson().toJson(brandlist));
+		}
+		
+		long count = brandInfoService.countValidByCidToApp(cid);
+		
+		List<BrandInfoVO> list = brandInfoService.listValidToApp((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, cid,acceptData.getPlatform(),acceptData.getVersion());
+		if (list == null)
+			list = new ArrayList<BrandInfoVO>();
+		
+		GsonBuilder gb = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder());
+		gb.excludeFieldsWithoutExposeAnnotation();
+		Gson gson = gb.create();
+		
+		data.put("count", count);
+		data.put("list", gson.toJson(list));
+		out.print(JsonUtil.loadTrueResult(data));
+	}
+	
+	
+	
+	/**
+	 * 搴楅摵璇︽儏杩囨浮椤�
+	 * 
+	 * @param acceptData
+	 * @param out
+	 */
+//	@RequestMapping(value = "getShopInfoV2", method = RequestMethod.POST)
+	public void getShopInfoV3(AcceptData acceptData, Integer page, Long id, Long uid, PrintWriter out) {
+		if (id == null) {
+			out.print(JsonUtil.loadFalseResult("缂哄け搴楅摵id"));
+			return;
+		}
+		
+		// 娣诲姞瓒宠抗
+		if (page == 1) {
+			brandInfoRecordService.addRecord(id, uid, acceptData.getDevice());
+		}
+		
 
+		Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
+				.excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
+		
+		ConfigParamsDTO paramsDTO =  orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
+				acceptData.getVersion());
+		JSONArray array = new JSONArray();
+		
+		List<BrandGoodsCahe> listGoods = brandGoodsCaheService.getByBrandId((page - 1) * 50, 50,id);
+		for (BrandGoodsCahe brandGoods: listGoods) {
+			JDGoods goodsJD = brandGoods.getGoodsJD();
+			if (goodsJD != null) {
+				array.add(gson.toJson(GoodsDetailVOFactory.convertJDGoods(goodsJD, paramsDTO)));
+				continue;
+			}
+			
+			TaoBaoGoodsBrief goodsTB = brandGoods.getGoodsTB();
+			if (goodsTB != null) {
+				array.add(gson.toJson(GoodsDetailVOFactory.convertTaoBao(goodsTB, paramsDTO)));
+				continue;
+			}
+			
+			PDDGoodsDetail goodsPDD = brandGoods.getGoodsPDD();
+			if (goodsPDD != null) {
+				array.add(gson.toJson(GoodsDetailVOFactory.convertPDDGoods(goodsPDD, paramsDTO)));
+				continue;
+			}
+		}
+		
+		JSONObject data = new JSONObject();
+		if (page == 1 && array.size() > 0) {
+			// 2銆侀《閮ㄨ疆鎾浘
+			List<BannerVO> topPicList = new ArrayList<>();
+			List<BannerVO> oldtopPicList = swiperPictureService.getByBannerCardAndVersion("brand_picture",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
+			if (oldtopPicList != null && oldtopPicList.size() > 0)
+				topPicList.addAll(oldtopPicList);
+			
+			List<ShopInfoVO> shopList = new ArrayList<ShopInfoVO>();
+			List<BrandShopCahe> listshopCahe = brandShopCaheService.getByBrandId(id);
+			if (listshopCahe != null && listshopCahe.size() > 0) {
+				for (BrandShopCahe brandShopCahe: listshopCahe) {
+					shopList.add(brandShopCahe.getShop());
+				}
+			}
+			data.put("picList", JsonUtil.getApiCommonGson().toJson(topPicList));
+			data.put("shopList", JsonUtil.getApiCommonGson().toJson(shopList));
+		}
+		
+		data.put("count", array.size());
+		data.put("list", array);
+		out.print(JsonUtil.loadTrueResult(data));
+	}
+	
+	
+	
+	/**
+	 * 搴楅摵瓒宠抗
+	 * 
+	 * @param acceptData
+	 * @param type
+	 *            绮鹃��1锛� 瓒宠抗鍒楄〃2
+	 * @param out
+	 */
+//	@RequestMapping(value = "getHistoryV2", method = RequestMethod.POST)
+	public void getHistoryV3(AcceptData acceptData, Integer page, Long uid, Integer type, PrintWriter out) {
+		if (type == null) {
+			out.print(JsonUtil.loadFalseResult("绫诲瀷涓嶆纭�"));
+			return;
+		}
+
+		if (page == null || page < 1) {
+			out.print(JsonUtil.loadFalseResult("椤电爜涓嶆纭�"));
+			return;
+		}
+
+		int pageSize;
+		if (type == 1) {
+			pageSize = 4;
+		} else {
+			pageSize = Constant.PAGE_SIZE;
+		}
+		
+		List<BrandInfoRecord> listRecord = brandInfoRecordService.listRecord((page - 1) * pageSize, pageSize, uid, acceptData.getDevice());
+		List<BrandInfo> list = new ArrayList<BrandInfo>();
+		if (listRecord != null && listRecord.size() > 0) {
+			for (BrandInfoRecord history : listRecord) {
+				if (history.getBrandInfo() != null) 
+					list.add(history.getBrandInfo());
+			}
+		}
+		
+		JSONObject data = new JSONObject();
+		data.put("count", brandInfoRecordService.countRecord(uid, acceptData.getDevice()));
+		data.put("list", JsonUtil.getApiCommonGson().toJson(list));
+		out.print(JsonUtil.loadTrueResult(data));
+	}
 }

--
Gitblit v1.8.0