From 626d711cb15896055c13fe344eb7fcc824589715 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期四, 19 十二月 2019 15:38:42 +0800
Subject: [PATCH] 帮助中心

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v2/BrandControllerV2.java |  226 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 217 insertions(+), 9 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 35178bf..e347e07 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
@@ -14,10 +14,16 @@
 
 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.bus.homemodule.SwiperPicture;
+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;
@@ -25,23 +31,27 @@
 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.homemodule.SwiperPictureService;
-import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
+import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
 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.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 net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
@@ -82,6 +92,12 @@
 	
 	@Resource
 	private BrandInfoRecordService brandInfoRecordService;
+	
+	@Resource
+	private BrandGoodsCaheService brandGoodsCaheService;
+	
+	@Resource
+	private BrandShopCaheService brandShopCaheService;
 	
 
 	/**
@@ -294,7 +310,7 @@
 
 			BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
 			BigDecimal shareRate = hongBaoManageService.getShareRate();
-
+			ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,	hongBaoManageService.getVIPFanLiRate());
 			// 鍟嗗搧淇℃伅杩囨护
 			listGoodsBrief = taoBaoGoodsUpdateService.filterImportantTaoBaoGoods(listGoodsBrief);
 
@@ -313,8 +329,7 @@
 						continue;
 					}
 				}
-				GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, fanLiRate,
-						shareRate);
+				GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO);
 				array.add(gson.toJson(goodsDetailVO));
 			}
 		}
@@ -337,6 +352,18 @@
 	 */
 	@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_1(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;
@@ -380,6 +407,18 @@
 	@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_1(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;
@@ -391,7 +430,7 @@
 		JSONObject data = new JSONObject();
 		if (page == 1) {
 			// 2銆侀《閮ㄨ疆鎾浘
-			List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCard("index_top");
+			List<SwiperPicture> 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);
@@ -496,7 +535,7 @@
 
 			BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
 			BigDecimal shareRate = hongBaoManageService.getShareRate();
-
+			ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,	hongBaoManageService.getVIPFanLiRate());
 			// 鍟嗗搧淇℃伅杩囨护
 			listGoodsBrief = taoBaoGoodsUpdateService.filterImportantTaoBaoGoods(listGoodsBrief);
 
@@ -515,8 +554,7 @@
 						continue;
 					}
 				}
-				GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, fanLiRate,
-						shareRate);
+				GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO);
 				array.add(gson.toJson(goodsDetailVO));
 			}
 		}
@@ -529,7 +567,6 @@
 	}
 	
 	
-	
 	/**
 	 * 搴楅摵瓒宠抗
 	 * 
@@ -540,6 +577,18 @@
 	 */
 	@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_1(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;
@@ -602,4 +651,163 @@
 		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) {
+			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);
+		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());
+		}
+		
+		BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
+		BigDecimal shareRate = hongBaoManageService.getShareRate();
+		Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
+				.excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
+		
+		ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,	hongBaoManageService.getVIPFanLiRate());
+		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<SwiperPicture> topPicList = new ArrayList<>();
+			List<SwiperPicture> 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