From a1175313094799efcdbbecf2840a90350d3159a7 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期一, 29 七月 2019 18:02:30 +0800
Subject: [PATCH] 首页加入缓存

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java |   99 ++++++++++++++++++++++++++++---------------------
 1 files changed, 57 insertions(+), 42 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
index 6ad6d98..38a3175 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
@@ -75,6 +75,7 @@
 import com.yeshi.fanli.util.taobao.TaoBaoUtil;
 import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
 import com.yeshi.fanli.util.taobao.TaoLiJinUtil;
+import com.yeshi.fanli.vo.goods.CouponInfoVO;
 import com.yeshi.fanli.vo.goods.GoodsDetailExtraVO;
 import com.yeshi.fanli.vo.goods.GoodsDetailVO;
 import com.yeshi.fanli.vo.goods.MoneyInfoVO;
@@ -396,9 +397,8 @@
 			extraVO.setIsNative(true);
 		} 
 
-		// 鍟嗗搧閾炬帴
-		String h5Url = String.format("http://%s%s?id=%s&appType=flq", configService.getH5Host(),
-				Constant.systemCommonConfig.getShareGoodsPagePath(), id + "");
+		String h5Url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
+				Constant.systemCommonConfig.getShareGoodsPagePath(), "", id + "");
 		try {
 			extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
 		} catch (Exception e) {
@@ -519,9 +519,7 @@
 		}
 		
 		// 鍒嗕韩璺緞
-		String shareUrl = String.format("%s?id=" + id, Constant.systemCommonConfig.getAppShareInfoUrl());
 		ShareVO shareInfoVO = new ShareVO();
-		shareInfoVO.setUrl(shareUrl);
 		shareInfoVO.setHelpLink(helpLink);
 		extraVO.setShare(shareInfoVO);
 
@@ -585,8 +583,16 @@
 
 		BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
 		BigDecimal shareRate = hongBaoManageService.getShareRate();
-		GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, null, fanLiRate, shareRate);
+		GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, fanLiRate, shareRate);
 
+		CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
+		if (couponInfo != null) {
+			// 鍒搁摼鎺ュ鐞�
+			String materialId = "https://item.jd.com/" + id + ".html";
+			String url = JDApiUtil.convertShortLink(materialId, couponInfo.getLink(), JDApiUtil.POSITION_COUPON+"", null);
+			couponInfo.setLink(url);
+		}
+		
 		ShopInfoVO shopInfo = goodsDetail.getShopInfo();
 		if (shopInfo != null) {
 			if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
@@ -649,8 +655,8 @@
 		}
 
 		// 鍟嗗搧閾炬帴
-		String h5Url = String.format("http://%s%s?id=%s&appType=flq&goodsType=%s", configService.getH5Host(),
-				Constant.systemCommonConfig.getShareGoodsPagePath(), jdGoods.getSkuId() + "", Constant.SOURCE_TYPE_JD);
+		String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
+				Constant.systemCommonConfig.getShareGoodsPagePathJD(), "", id + "");
 		try {
 			extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
 		} catch (Exception e) {
@@ -664,11 +670,7 @@
 			helpLink = configService.get("no_rebate_help_link");
 		}
 
-		// 鍒嗕韩璺緞
-		String shareUrl = String.format("%s?id=" + jdGoods.getSkuId(),
-				Constant.systemCommonConfig.getAppShareInfoUrl());
 		ShareVO shareInfoVO = new ShareVO();
-		shareInfoVO.setUrl(shareUrl);
 		shareInfoVO.setHelpLink(helpLink);
 		extraVO.setShare(shareInfoVO);
 
@@ -717,8 +719,13 @@
 
 		BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
 		BigDecimal shareRate = hongBaoManageService.getShareRate();
-		GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, null, fanLiRate, shareRate);
-
+		GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, fanLiRate, shareRate);
+		CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
+		if (couponInfo != null) {
+			String url = PinDuoDuoApiUtil.convert(id, PinDuoDuoApiUtil.PID_COUPON + "", null);
+			couponInfo.setLink(url);
+		}
+		
 		ShopInfoVO shopInfo = goodsDetail.getShopInfo();
 		if (shopInfo != null) {
 			if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
@@ -738,24 +745,34 @@
 		// 鍥炬枃璇︽儏
 		extraVO.setDetailUrl("http://apph5.yeshitv.com/apppage/goods_img_pdd.html?id="+ id);
 		
-		Long inOrderCount30Days = pddGoods.getSoldQuantity();
-		List<ShamUser> listShareUser = new ArrayList<ShamUser>();
-		MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
-		if (moneyInfo != null) {
-			String shareMoney = moneyInfo.getShareMoney().replaceAll("楼", "");
-			if (Integer.parseInt(inOrderCount30Days.toString()) >= 50000) {
-				listShareUser = shamUserService.listRandShareUser(10, new BigDecimal(shareMoney), 1, 5);
+		String salesTip = pddGoods.getSalesTip();
+		if (!StringUtil.isNullOrEmpty(salesTip)) {
+			int totalSales = 0;
+			if (salesTip.contains("涓�")) {
+				salesTip = salesTip.substring(0, salesTip.indexOf("涓�"));
+				totalSales= (int) (Float.parseFloat(salesTip) * 10000);
+			} else {
+				totalSales = Integer.parseInt(salesTip);
 			}
-		}
-		extraVO.setListShareUser(listShareUser);
+			
+			List<ShamUser> listShareUser = new ArrayList<ShamUser>();
+			MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
+			if (moneyInfo != null) {
+				String shareMoney = moneyInfo.getShareMoney().replaceAll("楼", "");
+				if (totalSales >= 50000) {
+					listShareUser = shamUserService.listRandShareUser(10, new BigDecimal(shareMoney), 1, 5);
+				}
+			}
+			extraVO.setListShareUser(listShareUser);
 
-		// 棰嗗埜浜哄垪琛�
-		List<ShamUser> listCouponUser = new ArrayList<ShamUser>();
-		if (goodsDetail.isHasCoupon() && Integer.parseInt(inOrderCount30Days.toString()) >= 50000) {
-			listCouponUser = shamUserService.listRandCouponUser(5, 1, 300);
+			// 棰嗗埜浜哄垪琛�
+			List<ShamUser> listCouponUser = new ArrayList<ShamUser>();
+			if (goodsDetail.isHasCoupon() && totalSales >= 50000) {
+				listCouponUser = shamUserService.listRandCouponUser(5, 1, 300);
+			}
+			extraVO.setListCouponUser(listCouponUser);
 		}
-		extraVO.setListCouponUser(listCouponUser);
-
+		
 		if (uid != null) {
 			// 鏄惁鍔犲叆鏀惰棌
 			CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id,
@@ -772,9 +789,9 @@
 			extraVO.setIsNative(true);
 		}
 
-		// 鍟嗗搧閾炬帴
-		String h5Url = String.format("http://%s%s?id=%s&appType=flq&goodsType=%s", configService.getH5Host(),
-				Constant.systemCommonConfig.getShareGoodsPagePath(), id + "", Constant.SOURCE_TYPE_PDD);
+		// 鍒嗕韩璺緞
+		String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
+				Constant.systemCommonConfig.getShareGoodsPagePathPDD(), "",	id + "");
 		try {
 			extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
 		} catch (Exception e) {
@@ -788,10 +805,8 @@
 		if (StringUtil.isNullOrEmpty(helpLink)) {
 			helpLink = configService.get("no_rebate_help_link");
 		}
-		// 鍒嗕韩璺緞
-		String shareUrl = String.format("%s?id=" + id, Constant.systemCommonConfig.getAppShareInfoUrl());
+		
 		ShareVO shareInfoVO = new ShareVO();
-		shareInfoVO.setUrl(shareUrl);
 		shareInfoVO.setHelpLink(helpLink);
 		extraVO.setShare(shareInfoVO);
 
@@ -829,7 +844,7 @@
 		// 浜笢
 		if (goodsType == Constant.SOURCE_TYPE_JD) {
 			JSONObject data = new JSONObject();
-			data.put("listQuality", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
+			data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
 		
 			List<JDGoods> list = JDUtil.getRecommendGoodsById(id);
 			if (list == null) {
@@ -843,7 +858,7 @@
 			List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
 			
 			for (JDGoods goods: list) {
-				listDetailVO.add(GoodsDetailVOFactory.convertJDGoods(goods, null, fanLiRate, shareRate));
+				listDetailVO.add(GoodsDetailVOFactory.convertJDGoods(goods, fanLiRate, shareRate));
 			}
 			
 			// 鍙栧伓鏁颁釜鏁版嵁
@@ -851,7 +866,7 @@
 				listDetailVO.remove(listDetailVO.size() - 1);
 			}
 						
-			data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listDetailVO));
+			data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
 			out.print(JsonUtil.loadTrueResult(data));
 			return;
 		}
@@ -859,7 +874,7 @@
 		// 鎷煎澶�
 		if (goodsType == Constant.SOURCE_TYPE_PDD) {
 			JSONObject data = new JSONObject();
-			data.put("listQuality", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
+			data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
 			
 			List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
 			
@@ -883,7 +898,7 @@
 						BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
 						BigDecimal shareRate = hongBaoManageService.getShareRate();
 						for (PDDGoodsDetail goods : goodsList) {
-							listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, null, fanLiRate, shareRate));
+							listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, fanLiRate, shareRate));
 						}
 					}
 				}
@@ -894,7 +909,7 @@
 				listDetailVO.remove(listDetailVO.size() - 1);
 			}
 			
-			data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listDetailVO));
+			data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
 			out.print(JsonUtil.loadTrueResult(data));
 			return;
 		}
@@ -1014,7 +1029,7 @@
 		if (couponInfo != null) {
 			couponUrl = couponInfo.getLink();
 		}
-		String jumpLink = JDApiUtil.convertLink(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", id + "");
+		String jumpLink = JDApiUtil.convertShortLink(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", uid + "");
 		
 		JSONObject data = new JSONObject();
 		data.put("native", true);

--
Gitblit v1.8.0