From cdd852f8e8eff7eb2e8f7c3fceaa955b9fc3f9d3 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期一, 29 七月 2019 10:46:32 +0800
Subject: [PATCH] 订单商品类型处理

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java |  414 +++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 344 insertions(+), 70 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 3cfb1ec..353236d 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
@@ -14,9 +14,13 @@
 import org.yeshi.utils.JsonUtil;
 import org.yeshi.utils.taobao.TbImgUtil;
 
+import com.yeshi.fanli.dto.jd.JDCouponInfo;
 import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
+import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
+import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
 import com.yeshi.fanli.entity.accept.AcceptData;
 import com.yeshi.fanli.entity.bus.user.ShamUser;
+import com.yeshi.fanli.entity.bus.user.UserInfo;
 import com.yeshi.fanli.entity.bus.user.UserMoneyExtra;
 import com.yeshi.fanli.entity.goods.CollectionGoodsV2;
 import com.yeshi.fanli.entity.jd.JDGoods;
@@ -28,6 +32,7 @@
 import com.yeshi.fanli.entity.taobao.TaoBaoShop;
 import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
 import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
+import com.yeshi.fanli.exception.taobao.TaoKeApiException;
 import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
 import com.yeshi.fanli.exception.taobao.TaobaoGoodsUpdateException;
 import com.yeshi.fanli.log.LogHelper;
@@ -50,6 +55,7 @@
 import com.yeshi.fanli.service.inter.user.TBPidService;
 import com.yeshi.fanli.service.inter.user.UserGoodsStorageService;
 import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
+import com.yeshi.fanli.service.inter.user.UserInfoService;
 import com.yeshi.fanli.service.inter.user.UserMoneyExtraService;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.RedisManager;
@@ -57,11 +63,15 @@
 import com.yeshi.fanli.util.TaoBaoConstant;
 import com.yeshi.fanli.util.ThreadUtil;
 import com.yeshi.fanli.util.TimeUtil;
+import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
+import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
 import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
 import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
 import com.yeshi.fanli.util.factory.goods.ShopInfoVOFactory;
 import com.yeshi.fanli.util.jd.JDApiUtil;
+import com.yeshi.fanli.util.jd.JDUtil;
 import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
+import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
 import com.yeshi.fanli.util.taobao.TaoBaoUtil;
 import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
 import com.yeshi.fanli.util.taobao.TaoLiJinUtil;
@@ -69,7 +79,8 @@
 import com.yeshi.fanli.vo.goods.GoodsDetailVO;
 import com.yeshi.fanli.vo.goods.MoneyInfoVO;
 import com.yeshi.fanli.vo.goods.OtherInfo;
-import com.yeshi.fanli.vo.goods.ShareInfoVO;
+import com.yeshi.fanli.vo.goods.ShareVO;
+import com.yeshi.fanli.vo.goods.ShopInfoVO;
 import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
 import com.yeshi.fanli.vo.tlj.ReduceHongBao;
 import com.yeshi.fanli.vo.tlj.SpreadHongBao;
@@ -146,43 +157,15 @@
 	@Resource
 	private TLJBuyGoodsService tljBuyGoodsService;
 	
+	@Resource
+	private UserInfoService userInfoService;
 	
-	/**
-	 * 鑾峰彇鍟嗗搧璇︽儏
-	 * 
-	 * @param acceptData
-	 * @param id
-	 * @param source
-	 * @param uid
-	 * @param from
-	 * @param out
-	 */
-	@RequestMapping(value = "getDetail", method = RequestMethod.POST)
-	public void getDetail(AcceptData acceptData, Long id, Integer goodsType, Long uid, String from, PrintWriter out) {
-		if (id == null || goodsType == null) {
-			out.print(JsonUtil.loadFalseResult(1, "鍟嗗搧id鍜屽晢鍝佸钩鍙颁笉鑳戒负绌�"));
-			return;
-		}
+	@Resource
+	private JDGoodsCacheUtil jdGoodsCacheUtil;
 
-		// 娣樺疂鍟嗗搧
-		if (Constant.SOURCE_TYPE_TAOBAO == goodsType) {
-			getTaoBaoGoodsDetial(acceptData, id, uid, from, out);
-			return;
-		}
+	@Resource
+	private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
 
-		// 浜笢鍟嗗搧
-		if (Constant.SOURCE_TYPE_JD == goodsType) {
-			getJDGoodsDetial(acceptData, id, uid, from, out);
-			return;
-		}
-
-		// 鎷煎澶氬晢鍝�
-		if (Constant.SOURCE_TYPE_PDD == goodsType) {
-			getPDDGoodsDetial(acceptData, id, uid, from, out);
-			return;
-		}
-	}
-	
 	
 	/**
 	 * 娣樺疂鍟嗗搧璇︽儏
@@ -192,12 +175,13 @@
 	 * @param from
 	 * @param out
 	 */
-	public void getTaoBaoGoodsDetial(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
+	@RequestMapping(value = "getDetailTB", method = RequestMethod.POST)
+	public void getDetialTB(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
 		if (id == null) {
-			out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爄d"));
+			out.print(JsonUtil.loadFalseResult(1, "鍟嗗搧id涓嶈兘涓虹┖"));
 			return;
 		}
-
+		
 		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
 				acceptData.getPackages());
 		if (system == null) {
@@ -346,10 +330,10 @@
 		
 		BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
 		BigDecimal shareRate = hongBaoManageService.getShareRate();
-		GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertTaoBao(tb, null, fanLiRate, shareRate);
+		GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertTaoBao(goods, null, fanLiRate, shareRate);
 		
 		// 搴楅摵淇℃伅
-		TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(goods.getAuctionId(), goods.getSellerId());
+		TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(id, goods.getSellerId());
 		if (shop != null) {
 			String shopLink = shop.getShopLink();
 			if (StringUtil.isNullOrEmpty(shopLink)) {
@@ -450,11 +434,11 @@
 
 			SpreadHongBao spreadHongBao = new SpreadHongBao();
 			if (isNewUser) {
-				spreadHongBao.setMoney("楼1");
+				spreadHongBao.setMoney("1");
 			} else {
 				moneyType = 2;
 				fanliValid = false;
-				spreadHongBao.setMoney("楼" + spreadMoney.toString());
+				spreadHongBao.setMoney(spreadMoney.toString());
 				
 				ClientTextStyleVO textStyleVO1 = new ClientTextStyleVO();
 				textStyleVO1.setContent("鍒嗕韩");
@@ -511,7 +495,7 @@
 			ReduceHongBao reduceHongBao = new ReduceHongBao();
 			reduceHongBao.setLeft(buyGoods.getLeftHongBaoCount());
 			reduceHongBao.setMoney(tljHongBao);
-			reduceHongBao.setName("浠樻绔嬪噺 楼" + tljHongBao);
+			reduceHongBao.setName("浠樻绔嬪噺 ");
 			reduceHongBao.setTip("褰撴棩棰嗗彇锛屽綋鏃ュ唴浣跨敤锛岃繃鏈熷け鏁�");
 			reduceHongBao.setTotal(buyGoods.getTotalHongBaoCount());
 			
@@ -536,10 +520,10 @@
 		
 		// 鍒嗕韩璺緞
 		String shareUrl = String.format("%s?id=" + id, Constant.systemCommonConfig.getAppShareInfoUrl());
-		ShareInfoVO shareInfoVO = new ShareInfoVO();
+		ShareVO shareInfoVO = new ShareVO();
 		shareInfoVO.setUrl(shareUrl);
 		shareInfoVO.setHelpLink(helpLink);
-		extraVO.setShareInfo(shareInfoVO);
+		extraVO.setShare(shareInfoVO);
 
 		JSONObject object = new JSONObject();
 		object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
@@ -569,7 +553,8 @@
 	 * @param from
 	 * @param out
 	 */
-	public void getJDGoodsDetial(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
+	@RequestMapping(value = "getDetailJD", method = RequestMethod.POST)
+	public void getDetialJD(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
 		// 绯荤粺楠岃瘉
 		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
 				acceptData.getPackages());
@@ -578,20 +563,38 @@
 			return;
 		}
 
-		JDGoods jdGoods = JDApiUtil.queryGoodsDetail(id);
+		JDGoods jdGoods = JDApiUtil.queryGoodsDetail(id); // 楂樼骇鎺ュ彛
 		if (jdGoods == null) {
-			jdGoods = JDApiUtil.getGoodsDetail(id);
+			jdGoods = JDUtil.getGoodsDetail(id); // 鐖彇缃戦〉
+			//jdGoods = JDApiUtil.getGoodsDetail(id); // 鏅�氭帴鍙�
 		}
 		
 		if (jdGoods == null) {
 			out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧涓嶅瓨鍦�"));
 			return;
 		}
+		
+		List<String> imageList = jdGoods.getImageList();
+		if (imageList == null) {
+			imageList = new ArrayList<String>();
+			imageList.add(jdGoods.getPicUrl());
+		}
+		
+		// 淇濆瓨缂撳瓨
+		jdGoodsCacheUtil.saveGoodsInfo(jdGoods);
 
 		BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
 		BigDecimal shareRate = hongBaoManageService.getShareRate();
 		GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, null, fanLiRate, shareRate);
 
+		ShopInfoVO shopInfo = goodsDetail.getShopInfo();
+		if (shopInfo != null) {
+			if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
+					|| shopInfo.getScoreSeller() == null) {
+				goodsDetail.setShopInfo(null);
+			}
+		}
+		
 		
 		GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
 		extraVO.setIsNative(false);
@@ -664,10 +667,10 @@
 		// 鍒嗕韩璺緞
 		String shareUrl = String.format("%s?id=" + jdGoods.getSkuId(),
 				Constant.systemCommonConfig.getAppShareInfoUrl());
-		ShareInfoVO shareInfoVO = new ShareInfoVO();
+		ShareVO shareInfoVO = new ShareVO();
 		shareInfoVO.setUrl(shareUrl);
 		shareInfoVO.setHelpLink(helpLink);
-		extraVO.setShareInfo(shareInfoVO);
+		extraVO.setShare(shareInfoVO);
 
 		JSONObject object = new JSONObject();
 		object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
@@ -688,7 +691,7 @@
 	}
 
 	/**
-	 * 浜笢鍟嗗搧璇︽儏
+	 * 鎷煎澶氬晢鍝佽鎯�
 	 * 
 	 * @param acceptData
 	 * @param id
@@ -696,7 +699,8 @@
 	 * @param from
 	 * @param out
 	 */
-	public void getPDDGoodsDetial(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
+	@RequestMapping(value = "getDetailPDD", method = RequestMethod.POST)
+	public void getDetialPDD(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
 		// 绯荤粺楠岃瘉
 		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
 				acceptData.getPackages());
@@ -715,6 +719,14 @@
 		BigDecimal shareRate = hongBaoManageService.getShareRate();
 		GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, null, fanLiRate, shareRate);
 
+		ShopInfoVO shopInfo = goodsDetail.getShopInfo();
+		if (shopInfo != null) {
+			if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
+					|| shopInfo.getScoreSeller() == null) {
+				goodsDetail.setShopInfo(null);
+			}
+		}
+		
 		GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
 		extraVO.setIsNative(false);
 		// IOS鏄惁姝e湪涓婄嚎
@@ -722,26 +734,38 @@
 			String version = acceptData.getVersion();
 			extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version)));
 		}
-
 		
-		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);
+		// 鍥炬枃璇︽儏
+		extraVO.setDetailUrl("http://apph5.yeshitv.com/apppage/goods_img_pdd.html?id="+ id);
+		
+		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,
@@ -776,10 +800,10 @@
 		}
 		// 鍒嗕韩璺緞
 		String shareUrl = String.format("%s?id=" + id, Constant.systemCommonConfig.getAppShareInfoUrl());
-		ShareInfoVO shareInfoVO = new ShareInfoVO();
+		ShareVO shareInfoVO = new ShareVO();
 		shareInfoVO.setUrl(shareUrl);
 		shareInfoVO.setHelpLink(helpLink);
-		extraVO.setShareInfo(shareInfoVO);
+		extraVO.setShare(shareInfoVO);
 
 		JSONObject object = new JSONObject();
 		object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
@@ -797,5 +821,255 @@
 			}
 		});
 	}
+	
+	
+	/**
+	 * 鍟嗗搧璇︽儏鎺ㄨ崘锛堢寽浣犲枩娆�  +  鎺ㄨ崘锛�
+	 * 
+	 * @param acceptData
+	 * @param id
+	 * @param out
+	 */
+	@RequestMapping(value = "getRecommendGoods", method = RequestMethod.POST)
+	public void getRecommendGoods(AcceptData acceptData, long id, Integer goodsType, PrintWriter out) {
+		if (goodsType == null) {
+			goodsType = Constant.SOURCE_TYPE_TAOBAO;
+		}
+		
+		// 浜笢
+		if (goodsType == Constant.SOURCE_TYPE_JD) {
+			JSONObject data = new JSONObject();
+			data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
+		
+			List<JDGoods> list = JDUtil.getRecommendGoodsById(id);
+			if (list == null) {
+				list = new ArrayList<JDGoods>();
+			} else if (list.size() > 10) {
+				list = list.subList(0, 10);
+			}
+			
+			BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
+			BigDecimal shareRate = hongBaoManageService.getShareRate();
+			List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
+			
+			for (JDGoods goods: list) {
+				listDetailVO.add(GoodsDetailVOFactory.convertJDGoods(goods, null, fanLiRate, shareRate));
+			}
+			
+			// 鍙栧伓鏁颁釜鏁版嵁
+			if (listDetailVO.size() % 2 != 0) {
+				listDetailVO.remove(listDetailVO.size() - 1);
+			}
+						
+			data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
+			out.print(JsonUtil.loadTrueResult(data));
+			return;
+		}
+		
+		// 鎷煎澶�
+		if (goodsType == Constant.SOURCE_TYPE_PDD) {
+			JSONObject data = new JSONObject();
+			data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
+			
+			List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
+			
+			List<Long> goodsIdList = PinDuoDuoUtil.getRecommendGoodsId(id);
+			if (goodsIdList != null && goodsIdList.size() > 0) {
+				PDDSearchFilter pddfilter = new PDDSearchFilter();
+				pddfilter.setPage(1);
+				pddfilter.setPageSize(Constant.PAGE_SIZE);
+				Long[] strings = new Long[goodsIdList.size()];
+				pddfilter.setGoodsIdList(goodsIdList.toArray(strings));
+				
+				PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
+				if (result != null) {
+					List<PDDGoodsDetail> goodsList = result.getGoodsList();
+					if (goodsList != null && goodsList.size() > 0) {
+						
+						if (goodsList.size() > 10) {
+							goodsList = goodsList.subList(0, 10);
+						}
+						
+						BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
+						BigDecimal shareRate = hongBaoManageService.getShareRate();
+						for (PDDGoodsDetail goods : goodsList) {
+							listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, null, fanLiRate, shareRate));
+						}
+					}
+				}
+			}
+			
+			// 鍙栧伓鏁颁釜鏁版嵁
+			if (listDetailVO.size() % 2 != 0) {
+				listDetailVO.remove(listDetailVO.size() - 1);
+			}
+			
+			data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
+			out.print(JsonUtil.loadTrueResult(data));
+			return;
+		}
 
+		
+		List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.getRelationGoodsRecommend(id, 10);
+		// 鍒濆鍖�
+		if (goodsList == null) {
+			goodsList = new ArrayList<TaoBaoGoodsBrief>();
+		}
+
+
+		List<GoodsDetailVO> listExtra = new ArrayList<GoodsDetailVO>();
+		TaoKeAppInfo app = new TaoKeAppInfo();
+		app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
+		app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
+		app.setAdzoneId(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT.split("_")[3]);
+		app.setPid(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT);
+
+		List<Long> ids = new ArrayList<>();
+		for (TaoBaoGoodsBrief goods : goodsList)
+			ids.add(goods.getAuctionId());
+
+		try {
+			goodsList = TaoKeApiUtil.getBatchGoodsInfo(ids);
+		} catch (TaoKeApiException e1) {
+			e1.printStackTrace();
+		} catch (TaobaoGoodsDownException e1) {
+			e1.printStackTrace();
+		}
+
+		if (goodsList != null && goodsList.size() > 0) {
+			
+			BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
+			BigDecimal shareRate = hongBaoManageService.getShareRate();
+			
+			goodsList.parallelStream().forEach(goods -> {
+				if (goods != null) {
+					// 鑾峰彇璇︽儏
+					TaoBaoGoodsBrief taoBaoGoodsBrief = null;
+					try {
+						taoBaoGoodsBrief = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goods.getAuctionId());
+					} catch (Exception e) {
+						e.printStackTrace();
+					}
+
+					if (taoBaoGoodsBrief == null) {
+						TaoBaoGoodsBrief newGoods = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app);
+						goods.setCouponInfo(newGoods.getCouponInfo());
+						goods.setCouponLink(newGoods.getCouponLink());
+						goods.setTkRate(newGoods.getTkRate());
+						taoBaoGoodsBrief = goods;
+					}
+
+					if (taoBaoGoodsBrief != null) {
+						listExtra.add(GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, fanLiRate, shareRate));
+					}
+				}
+			});
+		}
+		
+		
+		List<GoodsDetailVO> listQuality = new ArrayList<GoodsDetailVO>();
+		// 鍙栧伓鏁颁釜鏁版嵁
+		if (listExtra.size() % 2 != 0) {
+			listExtra.remove(listExtra.size() - 1);
+		}
+
+		if (listQuality.size() % 2 != 0) {
+			listQuality.remove(listQuality.size() - 1);
+		}
+
+		JSONObject data = new JSONObject();
+		data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listExtra));
+		data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listQuality));
+		out.print(JsonUtil.loadTrueResult(data));
+	}
+
+	
+	
+	/**
+	 * 浜笢璐拱閾炬帴
+	 * @param acceptData
+	 * @param uid
+	 * @param id
+	 * @param source
+	 * @param request
+	 * @param out
+	 */
+	@RequestMapping(value = "getJDLink")
+	public void getJDLink(AcceptData acceptData, Long uid, Long id, String source, PrintWriter out) {
+		if (uid == null || uid <= 0) {
+			out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛ID涓嶈兘涓虹┖"));
+			return;
+		}
+
+		if (id == null || id <= 0) {
+			out.print(JsonUtil.loadFalseResult(1, "鍟嗗搧ID涓嶈兘涓虹┖"));
+			return;
+		}
+		
+		UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
+		if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
+			out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
+			return;
+		}
+
+		JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(id);
+		if (goods == null) {
+			out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧宸蹭笅鏋�"));
+			return;
+		}
+
+		String couponUrl = null;
+		String materialId = "https://item.jd.com/" + id + ".html";
+		JDCouponInfo couponInfo = goods.getCouponInfo();
+		if (couponInfo != null) {
+			couponUrl = couponInfo.getLink();
+		}
+		String jumpLink = JDApiUtil.convertLink(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", id + "");
+		
+		JSONObject data = new JSONObject();
+		data.put("native", true);
+		data.put("jumpLink", jumpLink);
+		out.print(JsonUtil.loadTrueResult(data));
+	}
+
+	
+	/**
+	 * 鎷煎澶氳喘涔伴摼鎺�
+	 * @param acceptData
+	 * @param uid
+	 * @param id
+	 * @param source
+	 * @param request
+	 * @param out
+	 */
+	@RequestMapping(value = "getPDDLink")
+	public void getPDDLink(AcceptData acceptData, Long uid, Long id, String source, PrintWriter out) {
+		if (uid == null || uid <= 0) {
+			out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛ID涓嶈兘涓虹┖"));
+			return;
+		}
+
+		if (id == null || id <= 0) {
+			out.print(JsonUtil.loadFalseResult(1, "鍟嗗搧ID涓嶈兘涓虹┖"));
+			return;
+		}
+		
+		UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
+		if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
+			out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
+			return;
+		}
+
+		PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(id);
+		if (goods == null) {
+			out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧宸蹭笅鏋�"));
+			return;
+		}
+
+		String jumpLink = PinDuoDuoApiUtil.convert(id, PinDuoDuoApiUtil.PID_FANLI + "", uid + "");
+		JSONObject data = new JSONObject();
+		data.put("native", true);
+		data.put("jumpLink", jumpLink);
+		out.print(JsonUtil.loadTrueResult(data));
+	}
 }

--
Gitblit v1.8.0