From c04327c1e6271e10c6d4f13ebb53438f6edca50e Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期二, 16 七月 2019 09:06:16 +0800
Subject: [PATCH] 细节优化调整

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java |  726 +++++++++++++++++++++----------------------------------
 1 files changed, 283 insertions(+), 443 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 f659571..3cfb1ec 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
@@ -23,6 +23,7 @@
 import com.yeshi.fanli.entity.system.BusinessSystem;
 import com.yeshi.fanli.entity.system.SystemClientParams;
 import com.yeshi.fanli.entity.taobao.ClientTBPid;
+import com.yeshi.fanli.entity.taobao.TLJBuyGoods;
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
 import com.yeshi.fanli.entity.taobao.TaoBaoShop;
 import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
@@ -37,6 +38,7 @@
 import com.yeshi.fanli.service.inter.goods.ScanHistoryV2Service;
 import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
 import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
+import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
@@ -54,6 +56,7 @@
 import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.TaoBaoConstant;
 import com.yeshi.fanli.util.ThreadUtil;
+import com.yeshi.fanli.util.TimeUtil;
 import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
 import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
 import com.yeshi.fanli.util.factory.goods.ShopInfoVOFactory;
@@ -68,6 +71,7 @@
 import com.yeshi.fanli.vo.goods.OtherInfo;
 import com.yeshi.fanli.vo.goods.ShareInfoVO;
 import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
+import com.yeshi.fanli.vo.tlj.ReduceHongBao;
 import com.yeshi.fanli.vo.tlj.SpreadHongBao;
 
 import net.sf.json.JSONObject;
@@ -139,6 +143,10 @@
 	@Resource
 	private ScanHistoryV2Service scanHistoryV2Service;
 
+	@Resource
+	private TLJBuyGoodsService tljBuyGoodsService;
+	
+	
 	/**
 	 * 鑾峰彇鍟嗗搧璇︽儏
 	 * 
@@ -174,10 +182,10 @@
 			return;
 		}
 	}
-
+	
+	
 	/**
 	 * 娣樺疂鍟嗗搧璇︽儏
-	 * 
 	 * @param acceptData
 	 * @param id
 	 * @param uid
@@ -185,7 +193,11 @@
 	 * @param out
 	 */
 	public void getTaoBaoGoodsDetial(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
-		// 绯荤粺楠岃瘉
+		if (id == null) {
+			out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爄d"));
+			return;
+		}
+
 		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
 				acceptData.getPackages());
 		if (system == null) {
@@ -193,19 +205,35 @@
 			return;
 		}
 
-		// 鑾峰彇娣樺鍙傛暟
+		GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
+		extraVO.setIsNative(false);
+
+		// IOS鏄惁姝e湪涓婄嚎
+		if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
+			String version = acceptData.getVersion();
+			extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version)));
+		}
+
 		long startTime = java.lang.System.currentTimeMillis();
+
+		// 鑾峰彇娣樺鍙傛暟
 		ClientTBPid clientTBPid = null;
+
+		// 鐢ㄦ埛鏈櫥褰�
 		if (acceptData.getPlatform().equalsIgnoreCase("android")) {
 			clientTBPid = tbPidService.getAndroidDefault();
 		} else {
 			clientTBPid = tbPidService.getIOSDefault();
 		}
+
 		LogHelper.test("鑾峰彇PID鑰楁椂锛�" + (java.lang.System.currentTimeMillis() - startTime));
 
-		TaoBaoGoodsBrief goods = null;
+		final List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
 		// 鏄惁鍦ㄦ湇鍔$杩涜杞摼
 		boolean convertInServer = configService.isConvertTaoBaoLinkInServer();
+
+		TaoBaoGoodsBrief goods = null;
+
 		if (!convertInServer) {
 			try {
 				goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(id);
@@ -216,7 +244,6 @@
 					app.setPid(TaoBaoConstant.TAOBAO_COMMON_PID);
 					app.setAdzoneId(TaoBaoConstant.TAOBAO_COMMON_PID.split("_")[3]);
 					goods = TaoKeApiUtil.searchGoodsDetail(id, app);
-
 					final TaoBaoGoodsBrief finalGoods = goods;
 					if (goods != null) {
 						ThreadUtil.run(new Runnable() {
@@ -234,10 +261,11 @@
 						taoBaoGoodsUpdateService.offlineTaoBaoGoods(id);
 					}
 				});
+
 			}
 
 		} else {
-			String clientPid = clientTBPid.getPid();
+			final String clientPid = clientTBPid.getPid();
 			String appId = clientPid.split("_")[2];
 			TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
 			TaoKeAppInfo app = new TaoKeAppInfo();
@@ -269,41 +297,44 @@
 
 		}
 
-		if (goods == null) {
+		if (goods != null) {
+			goodsList.add(goods);
+			final TaoBaoGoodsBrief newGoods = goods;
+			ThreadUtil.run(new Runnable() {
+				public void run() {
+					try {
+						// 鏇存柊鍟嗗搧
+						LogHelper.test("鏇存柊鍟嗗搧璇︽儏:" + newGoods.getAuctionId());
+						taoBaoGoodsUpdateService.updateTaoBaoGoods(newGoods);
+					} catch (TaobaoGoodsUpdateException e) {
+
+					}
+				}
+			});
+		}
+
+		TaoBaoGoodsBrief tb = null;
+		if (goodsList.size() > 0) {
+			tb = goodsList.get(0);
+		}
+
+		if (tb == null) {
 			out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧涓嶅瓨鍦�"));
 			return;
 		}
-		goods.setState(0);
 
-		final TaoBaoGoodsBrief newGoods = goods;
-		ThreadUtil.run(new Runnable() {
-			public void run() {
-				try {
-					LogHelper.test("鏇存柊鍟嗗搧璇︽儏:" + newGoods.getAuctionId());
-					taoBaoGoodsUpdateService.updateTaoBaoGoods(newGoods);
-				} catch (TaobaoGoodsUpdateException e) {
-
-				}
-			}
-		});
-
-		// 鏇挎崲鐧藉簳鍥�
-		if (!StringUtil.isNullOrEmpty(goods.getPictUrlWhite())) {
-			goods.setPictUrl(goods.getPictUrlWhite());
+		if (tb.getImgList() == null) {
+			tb.setImgList(new ArrayList<>());
 		}
 
-		// 鍥剧墖锛涘垪琛ㄥ鐞�
-		List<String> imgList = goods.getImgList();
-		if (imgList == null) {
-			goods.setImgList(new ArrayList<>());
-		}
-		imgList.add(0, goods.getPictUrl());
+		tb.getImgList().add(0, tb.getPictUrl());
 
-		// 鍥剧墖澶у皬闄愬埗
 		List<String> finalImgList = new ArrayList<>();
-		for (String img : imgList) {
+		for (String img : tb.getImgList()) {
 			finalImgList.add(TbImgUtil.getTBSizeImg(img, 600));
 		}
+		if (!StringUtil.isNullOrEmpty(tb.getPictUrlWhite()))
+			finalImgList.add(0, tb.getPictUrlWhite());
 
 		// 澶ф窐瀹㈠晢鍝佽繃婊�
 		try {
@@ -311,31 +342,24 @@
 		} catch (Exception e) {
 			LogHelper.errorDetailInfo(e);
 		}
-
+		
+		
 		BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
 		BigDecimal shareRate = hongBaoManageService.getShareRate();
-		GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertTaoBao(newGoods, null, fanLiRate, shareRate);
-
+		GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertTaoBao(tb, null, fanLiRate, shareRate);
+		
 		// 搴楅摵淇℃伅
 		TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(goods.getAuctionId(), goods.getSellerId());
 		if (shop != null) {
+			String shopLink = shop.getShopLink();
+			if (StringUtil.isNullOrEmpty(shopLink)) {
+				shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId()));
+			}
 			goodsDetail.setShopInfo(ShopInfoVOFactory.convertTaoBaoShop(shop));
 		}
-
-		// 鍒镐俊鎭�
+		
+		// 鏈夊埜澶勭悊
 		if (goodsDetail.isHasCoupon()) {
-//			CouponInfoVO coupon = goodsDetail.getCouponInfo();
-//			String token = "";
-//			if (!StringUtil.isNullOrEmpty(goods.getCouponLink())) {
-//				token = redisManager.getCommonTaoToken(id);
-//				if (StringUtil.isNullOrEmpty(token)) {
-//					token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), goods.getCouponLink());
-//					redisManager.saveCommonTaoToken(goods.getAuctionId(), token);
-//				}
-//			}
-//			coupon.setToken(token);
-//			goodsInfo.setCouponInfo(coupon);
-
 			if (!StringUtil.isNullOrEmpty(from)) {
 				if ("miandan".equals(from)) { // 鍏嶅崟鍟嗗搧
 					MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
@@ -344,12 +368,197 @@
 				}
 			}
 		}
+		
+		extraVO.setTbPidInfo(clientTBPid);
+		extraVO.setDetailUrl("http://apph5.yeshitv.com/apppage/goods_img.html?id=" + id);
+		
+		// 鍒嗕韩璧氫汉鎻愮ず
+		MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
+		List<ShamUser> listShareUser = new ArrayList<ShamUser>();
+		if (moneyInfo != null) {
+			String shareMoney = moneyInfo.getShareMoney();
+			if (goods.getBiz30day() >= 1000) {
+				listShareUser = shamUserService.listRandShareUser(10, new BigDecimal(shareMoney.replaceAll("楼", "")), 1, 5);
+			}
+		}
+		extraVO.setListShareUser(listShareUser);
+		
+		
+		// 棰嗗埜浜哄垪琛�
+		List<ShamUser> listCouponUser = new ArrayList<ShamUser>();
+		if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && goods.getCouponAmount() != null
+				&& goods.getCouponAmount().compareTo(new BigDecimal(0)) > 0) {
+			if (goods.getBiz30day() >= 1000) {
+				listCouponUser = shamUserService.listRandCouponUser(5, 1, 300);
+			}
+		}
+		extraVO.setListCouponUser(listCouponUser);
+		
+		
+		if (uid != null) {
+			// 鏄惁鍔犲叆鏀惰棌
+			CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id,
+					Constant.SOURCE_TYPE_TAOBAO);
+			extraVO.setCollected(collectionGoods != null ? true : false);
+			// 鏄惁鍔犲叆閫夊搧搴�
+			extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_TAOBAO));
+		}
+
+
+		// 娴嬭瘯
+		SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system,
+				"goods_detail_jump_taobao");
+		if ("1".equalsIgnoreCase((params.getValue() + "").trim())) {
+			extraVO.setIsNative(true);
+		} 
+
+		// 鍟嗗搧閾炬帴
+		String h5Url = String.format("http://%s%s?id=%s&appType=flq", configService.getH5Host(),
+				Constant.systemCommonConfig.getShareGoodsPagePath(), id + "");
+		try {
+			extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
+		} catch (Exception e) {
+			extraVO.setH5Url(h5Url);
+		}
+
+		String helpLink = null;
+		boolean fanliValid = true;
+		boolean shareValid = true;
+		int moneyType = 1;
+		
+		// 鎺ㄥ箍绾㈠寘
+		if (from != null && from.equals("taolijin")) {
+			// 璁$畻鎺ㄥ箍绾㈠寘
+			String warningRate = configTaoLiJinService.getValueByKey("warning_value");
+			BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods);
+
+			// 鎺ㄥ箍绾㈠寘 涓嶈兘灏忎簬1
+			if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) {
+				out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧涓嶅瓨鍦�"));
+				return;
+			}
+
+			// 鏄惁涓烘柊鐢ㄦ埛
+			boolean isNewUser = userInfoExtraService.isNewUser(uid);
+			if (isNewUser) {
+				// 鍒ゅ畾涓鸿�佺敤鎴凤細 鏂颁汉鍙浣跨敤浜嗘柊浜虹孩鍖咃紝涔熷氨鏄偅1鍧楅挶锛岄偅涔堬紝浠栫湅鍒扮殑鍒嗕韩鐖嗘涓殑鍟嗗搧-灏卞彧鑳藉垎浜��
+				long countRecord = userTaoLiJinRecordService.countRecordByUid(uid);
+				if (countRecord > 0) {
+					isNewUser = false;
+				}
+			}
+
+			SpreadHongBao spreadHongBao = new SpreadHongBao();
+			if (isNewUser) {
+				spreadHongBao.setMoney("楼1");
+			} else {
+				moneyType = 2;
+				fanliValid = false;
+				spreadHongBao.setMoney("楼" + spreadMoney.toString());
+				
+				ClientTextStyleVO textStyleVO1 = new ClientTextStyleVO();
+				textStyleVO1.setContent("鍒嗕韩");
+				textStyleVO1.setColor("#666666");
+				ClientTextStyleVO textStyleVO2 = new ClientTextStyleVO();
+				textStyleVO2.setContent("璧氬閲�");
+				textStyleVO2.setColor("#F14242");
+				ClientTextStyleVO textStyleVO3 = new ClientTextStyleVO();
+				textStyleVO3.setContent("锛屽ソ鍙�");
+				textStyleVO3.setColor("#666666");
+				ClientTextStyleVO textStyleVO4 = new ClientTextStyleVO();
+				textStyleVO4.setContent("棰嗙孩鍖咃紒");
+				textStyleVO4.setColor("#F14242");
+
+				List<ClientTextStyleVO> listText = new ArrayList<ClientTextStyleVO>();
+				listText.add(textStyleVO1);
+				listText.add(textStyleVO2);
+				listText.add(textStyleVO3);
+				listText.add(textStyleVO4);
+				extraVO.setTip(listText);
+			}
+			
+			spreadHongBao.setName("鎺ㄥ箍绾㈠寘 ");
+			spreadHongBao.setTip("褰撴棩棰嗗彇锛屽綋鏃ュ唴浣跨敤锛岃繃鏈熷け鏁�");
+			OtherInfo otherInfo = new OtherInfo();
+			otherInfo.setSpreadHongBao(spreadHongBao);
+			goodsDetail.setOtherInfo(otherInfo);
+
+			// 鐢ㄦ埛娣樼ぜ閲�
+			UserMoneyExtra userMoneyExtra = userMoneyExtraService.selectByPrimaryKey(uid);
+			if (userMoneyExtra == null || userMoneyExtra.getTlj() == null) {
+				extraVO.setUserTLJ(new BigDecimal(0).setScale(2).toString());
+			} else {
+				extraVO.setUserTLJ(userMoneyExtra.getTlj().setScale(2).toString());
+			}
+			helpLink = configTaoLiJinService.getValueByKey("share_goods_help_link");
+
+		} else if (from != null && from.equals("taolijin_buy")) {
+			// 鏌ヨ鍒嗕韩搴�
+			TLJBuyGoods buyGoods = tljBuyGoodsService.selectByAuctionIdAndDay(id,
+					TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
+			if (buyGoods == null) {
+				out.print(JsonUtil.loadFalseResult(2, "鑷喘绔嬪噺绾㈠寘杩囨湡"));
+				return;
+			}
+
+			moneyType = 2;
+			fanliValid = true;
+			shareValid = false;
+			helpLink = configService.get("zigoulijian_nofanli_help");
+			
+			String tljHongBao = TaoBaoUtil.getGoodsHongBaoMoney(goods, new BigDecimal(70)).toString();
+			
+			ReduceHongBao reduceHongBao = new ReduceHongBao();
+			reduceHongBao.setLeft(buyGoods.getLeftHongBaoCount());
+			reduceHongBao.setMoney(tljHongBao);
+			reduceHongBao.setName("浠樻绔嬪噺 楼" + tljHongBao);
+			reduceHongBao.setTip("褰撴棩棰嗗彇锛屽綋鏃ュ唴浣跨敤锛岃繃鏈熷け鏁�");
+			reduceHongBao.setTotal(buyGoods.getTotalHongBaoCount());
+			
+			
+			OtherInfo otherInfo = new OtherInfo();
+			otherInfo.setReduceHongBao(reduceHongBao);
+			goodsDetail.setOtherInfo(otherInfo);
+		}
+		extraVO.setFanliValid(fanliValid);
+		extraVO.setShareValid(shareValid);
+		
+		MoneyInfoVO goodsMoney = goodsDetail.getMoneyInfo();
+		if (goodsMoney != null) {
+			goodsMoney.setMoneyType(moneyType);
+		}
+		
+		
+		// 鍒嗕韩璺緞
+		if (StringUtil.isNullOrEmpty(helpLink)) {
+			helpLink = configService.get("no_rebate_help_link");
+		}
+		
+		// 鍒嗕韩璺緞
+		String shareUrl = String.format("%s?id=" + id, Constant.systemCommonConfig.getAppShareInfoUrl());
+		ShareInfoVO shareInfoVO = new ShareInfoVO();
+		shareInfoVO.setUrl(shareUrl);
+		shareInfoVO.setHelpLink(helpLink);
+		extraVO.setShareInfo(shareInfoVO);
 
 		JSONObject object = new JSONObject();
-		object.put("code", 0);
-		object.put("data", JsonUtil.getApiCommonGson().toJson(goodsDetail));
-		out.print(object.toString());
+		object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
+		object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail));
+		out.print(JsonUtil.loadTrueResult(object.toString()));
+
+		final TaoBaoGoodsBrief goodsInfo = tb;
+		ThreadUtil.run(new Runnable() {
+			public void run() {
+				// 娣诲姞娴忚璁板綍
+				try {
+					scanHistoryV2Service.addScanHistory(uid, acceptData.getDevice(), goodsInfo);
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+			}
+		});
 	}
+
 
 	/**
 	 * 浜笢鍟嗗搧璇︽儏
@@ -383,382 +592,14 @@
 		BigDecimal shareRate = hongBaoManageService.getShareRate();
 		GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, null, fanLiRate, shareRate);
 
-		JSONObject object = new JSONObject();
-		object.put("code", 0);
-		object.put("data", JsonUtil.getApiCommonGson().toJson(goodsDetail));
-		out.print(object.toString());
-	}
-
-	/**
-	 * 浜笢鍟嗗搧璇︽儏
-	 * 
-	 * @param acceptData
-	 * @param id
-	 * @param uid
-	 * @param from
-	 * @param out
-	 */
-	public void getPDDGoodsDetial(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
-		// 绯荤粺楠岃瘉
-		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
-				acceptData.getPackages());
-		if (system == null) {
-			out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�"));
-			return;
-		}
-
-		PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(id);
-		if (pddGoods == null) {
-			out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧涓嶅瓨鍦�"));
-			return;
-		}
-
-		BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
-		BigDecimal shareRate = hongBaoManageService.getShareRate();
-		GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, null, fanLiRate, shareRate);
-
-		JSONObject object = new JSONObject();
-		object.put("code", 0);
-		object.put("data", JsonUtil.getApiCommonGson().toJson(goodsDetail));
-		out.print(object.toString());
-	}
-
-	/**
-	 * 鑾峰彇鍟嗗搧璇︽儏
-	 * 
-	 * @param acceptData
-	 * @param id
-	 * @param source
-	 * @param uid
-	 * @param from
-	 * @param out
-	 */
-	@RequestMapping(value = "getExtraDetail", method = RequestMethod.POST)
-	public void getExtraDetail(AcceptData acceptData, Long id, Integer goodsType, Long uid, String from,
-			PrintWriter out) {
-		if (id == null || goodsType == null) {
-			out.print(JsonUtil.loadFalseResult(1, "鍟嗗搧id鍜屽晢鍝佸钩鍙颁笉鑳戒负绌�"));
-			return;
-		}
-
-		// 娣樺疂鍟嗗搧
-		if (Constant.SOURCE_TYPE_TAOBAO == goodsType) {
-			getTaoBaoExtraDetial(acceptData, id, uid, from, out);
-			return;
-		}
-
-		// 浜笢鍟嗗搧
-		if (Constant.SOURCE_TYPE_JD == goodsType) {
-			getJDExtraDetial(acceptData, id, uid, from, out);
-			return;
-		}
-
-		// 鎷煎澶氬晢鍝�
-		if (Constant.SOURCE_TYPE_PDD == goodsType) {
-			getPDDExtraDetial(acceptData, id, uid, from, out);
-			return;
-		}
-	}
-
-	/**
-	 * 娣樺疂鍟嗗搧棰濆閰嶇疆淇℃伅
-	 * 
-	 * @param acceptData
-	 * @param id
-	 * @param uid
-	 * @param from
-	 * @param out
-	 */
-	public void getTaoBaoExtraDetial(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
-		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
-				acceptData.getPackages());
-		if (system == null) {
-			out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�"));
-			return;
-		}
-
+		
 		GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
+		extraVO.setIsNative(false);
 		// IOS鏄惁姝e湪涓婄嚎
 		if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
 			String version = acceptData.getVersion();
 			extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version)));
 		}
-
-		long startTime = java.lang.System.currentTimeMillis();
-		// 鑾峰彇娣樺鍙傛暟
-		ClientTBPid clientTBPid = null;
-
-		// 鐢ㄦ埛鏈櫥褰�
-		if (acceptData.getPlatform().equalsIgnoreCase("android")) {
-			clientTBPid = tbPidService.getAndroidDefault();
-		} else {
-			clientTBPid = tbPidService.getIOSDefault();
-		}
-		extraVO.setTbPidInfo(clientTBPid);
-
-		LogHelper.test("鑾峰彇PID鑰楁椂锛�" + (java.lang.System.currentTimeMillis() - startTime));
-		List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
-
-		TaoBaoGoodsBrief goods = null;
-		try {
-			goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(id);
-			if (goods == null) {
-				TaoKeAppInfo app = new TaoKeAppInfo();
-				app.setAppKey(TaoBaoConstant.TAOBAO_COMMON_APPKEY);
-				app.setAppSecret(TaoBaoConstant.TAOBAO_COMMON_APPSECRET);
-				app.setPid(TaoBaoConstant.TAOBAO_COMMON_PID);
-				app.setAdzoneId(TaoBaoConstant.TAOBAO_COMMON_PID.split("_")[3]);
-				goods = TaoKeApiUtil.searchGoodsDetail(id, app);
-				final TaoBaoGoodsBrief finalGoods = goods;
-				if (goods != null) {
-					ThreadUtil.run(new Runnable() {
-						@Override
-						public void run() {
-							taoBaoGoodsCacheUtil.saveCommonTaoBaoGoodsInfo(finalGoods);
-						}
-					});
-				}
-			}
-		} catch (TaobaoGoodsDownException e) {
-			// 鍟嗗搧涓嬫灦
-			ThreadUtil.run(new Runnable() {
-				public void run() {
-					taoBaoGoodsUpdateService.offlineTaoBaoGoods(id);
-				}
-			});
-
-		}
-
-		if (goods != null) {
-			goodsList.add(goods);
-			final TaoBaoGoodsBrief newGoods = goods;
-			ThreadUtil.run(new Runnable() {
-				public void run() {
-					try {
-						// 鏇存柊鍟嗗搧
-						LogHelper.test("鏇存柊鍟嗗搧璇︽儏:" + newGoods.getAuctionId());
-						taoBaoGoodsUpdateService.updateTaoBaoGoods(newGoods);
-					} catch (TaobaoGoodsUpdateException e) {
-
-					}
-				}
-			});
-		}
-
-		TaoBaoGoodsBrief tb = null;
-		if (goodsList.size() > 0) {
-			tb = goodsList.get(0);
-		}
-
-		if (tb == null) {
-			out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧涓嶅瓨鍦�"));
-			return;
-		}
-
-		// 澶ф窐瀹㈠晢鍝佽繃婊�
-		try {
-			goods = daTaoKeGoodsDetailService.filterTaoBaoGoods(goods);
-		} catch (Exception e) {
-			LogHelper.errorDetailInfo(e);
-		}
-
-		extraVO.setDetailUrl("http://apph5.yeshitv.com/apppage/goods_img.html?id=" + id);
-
-		// 搴楅摵淇℃伅
-		TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(goods.getAuctionId(), goods.getSellerId());
-		if (shop != null) {
-			String shopLink = shop.getShopLink();
-			if (StringUtil.isNullOrEmpty(shopLink)) {
-				shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId()));
-			}
-			extraVO.setShopInfo(ShopInfoVOFactory.convertTaoBaoShop(shop));
-		}
-
-		BigDecimal shareMoney = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb);
-		// 鍒嗕韩璧氫汉鎻愮ず
-		List<ShamUser> listShareUser = new ArrayList<ShamUser>();
-		if (tb.getBiz30day() >= 1000) {
-			listShareUser = shamUserService.listRandShareUser(10, shareMoney, 1, 5);
-		}
-		extraVO.setListShareUser(listShareUser);
-
-		// 棰嗗埜浜哄垪琛�
-		List<ShamUser> listCouponUser = new ArrayList<ShamUser>();
-		if (!StringUtil.isNullOrEmpty(tb.getCouponInfo()) && tb.getCouponAmount() != null
-				&& tb.getCouponAmount().compareTo(new BigDecimal(0)) > 0) {
-			if (tb.getBiz30day() >= 1000) {
-				listCouponUser = shamUserService.listRandCouponUser(5, 1, 300);
-			}
-		}
-		extraVO.setListCouponUser(listCouponUser);
-
-		if (uid != null) {
-			// 鏄惁鍔犲叆鏀惰棌
-			CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id,
-					Constant.SOURCE_TYPE_TAOBAO);
-			extraVO.setCollected(collectionGoods != null ? true : false);
-			// 鏄惁鍔犲叆閫夊搧搴�
-			extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_TAOBAO));
-		}
-
-		// 娴嬭瘯
-		SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system,
-				"goods_detail_jump_taobao");
-		if ("1".equalsIgnoreCase((params.getValue() + "").trim())) {
-			extraVO.setNative(true);
-		}
-
-		// 鍟嗗搧閾炬帴
-		String h5Url = String.format("http://%s%s?id=%s&appType=flq", configService.getH5Host(),
-				Constant.systemCommonConfig.getShareGoodsPagePath(), tb.getAuctionId() + "");
-		try {
-			extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
-		} catch (Exception e) {
-			extraVO.setH5Url(h5Url);
-		}
-
-		String helpLink = null;
-		// 鏄惁鏈夎繑鍒�
-		boolean fanliValid = true;
-
-		/* 鎺ㄥ箍绾㈠寘 */
-		if (from != null && from.equals("taolijin")) {
-
-			// 璁$畻鎺ㄥ箍绾㈠寘
-			String warningRate = configTaoLiJinService.getValueByKey("warning_value");
-			BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods);
-
-			// 鎺ㄥ箍绾㈠寘 涓嶈兘灏忎簬1
-			if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) {
-				out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧涓嶅瓨鍦�"));
-				return;
-			}
-
-			// 鏄惁涓烘柊鐢ㄦ埛
-			boolean isNewUser = userInfoExtraService.isNewUser(uid);
-			if (isNewUser) {
-				// 鍒ゅ畾涓鸿�佺敤鎴凤細 鏂颁汉鍙浣跨敤浜嗘柊浜虹孩鍖咃紝涔熷氨鏄偅1鍧楅挶锛岄偅涔堬紝浠栫湅鍒扮殑鍒嗕韩鐖嗘涓殑鍟嗗搧-灏卞彧鑳藉垎浜��
-				long countRecord = userTaoLiJinRecordService.countRecordByUid(uid);
-				if (countRecord > 0) {
-					isNewUser = false;
-				}
-			}
-
-			if (!isNewUser) {
-				fanliValid = false;
-				ClientTextStyleVO textStyleVO1 = new ClientTextStyleVO();
-				textStyleVO1.setContent("鍒嗕韩");
-				textStyleVO1.setColor("#666666");
-				ClientTextStyleVO textStyleVO2 = new ClientTextStyleVO();
-				textStyleVO2.setContent("璧氬閲�");
-				textStyleVO2.setColor("#F14242");
-				ClientTextStyleVO textStyleVO3 = new ClientTextStyleVO();
-				textStyleVO3.setContent("锛屽ソ鍙�");
-				textStyleVO3.setColor("#666666");
-				ClientTextStyleVO textStyleVO4 = new ClientTextStyleVO();
-				textStyleVO4.setContent("棰嗙孩鍖咃紒");
-				textStyleVO4.setColor("#F14242");
-
-				List<ClientTextStyleVO> listText = new ArrayList<ClientTextStyleVO>();
-				listText.add(textStyleVO1);
-				listText.add(textStyleVO2);
-				listText.add(textStyleVO3);
-				listText.add(textStyleVO4);
-				extraVO.setTip(listText);
-			}
-
-			SpreadHongBao spreadHongBao = new SpreadHongBao();
-			if (isNewUser) {
-				spreadHongBao.setMoney("楼1");
-			} else {
-				spreadHongBao.setMoney("楼" + spreadMoney.toString());
-			}
-			spreadHongBao.setName("鎺ㄥ箍绾㈠寘 ");
-			spreadHongBao.setTip("褰撴棩棰嗗彇锛屽綋鏃ュ唴浣跨敤锛岃繃鏈熷け鏁�");
-			OtherInfo otherInfo = new OtherInfo();
-			otherInfo.setSpreadHongBao(spreadHongBao);
-			extraVO.setOtherInfo(otherInfo);
-
-			// 鐢ㄦ埛娣樼ぜ閲�
-			UserMoneyExtra userMoneyExtra = userMoneyExtraService.selectByPrimaryKey(uid);
-			if (userMoneyExtra == null || userMoneyExtra.getTlj() == null) {
-				extraVO.setUserTLJ(new BigDecimal(0).setScale(2).toString());
-			} else {
-				extraVO.setUserTLJ(userMoneyExtra.getTlj().setScale(2).toString());
-			}
-			helpLink = configTaoLiJinService.getValueByKey("share_goods_help_link");
-		}
-
-		extraVO.setFanliValid(fanliValid);
-		extraVO.setShareValid(true);
-
-		if (StringUtil.isNullOrEmpty(helpLink)) {
-			helpLink = configService.get("no_rebate_help_link");
-		}
-		// 鍒嗕韩璺緞
-		String shareUrl = String.format("%s?id=" + tb.getAuctionId(), Constant.systemCommonConfig.getAppShareInfoUrl());
-		ShareInfoVO shareInfoVO = new ShareInfoVO();
-		shareInfoVO.setUrl(shareUrl);
-		shareInfoVO.setHelpLink(helpLink);
-		extraVO.setShareInfo(shareInfoVO);
-
-		JSONObject object = new JSONObject();
-		object.put("code", 0);
-		object.put("data", JsonUtil.getApiCommonGson().toJson(extraVO));
-		out.print(object.toString());
-
-		final TaoBaoGoodsBrief goodsInfo = tb;
-		ThreadUtil.run(new Runnable() {
-			public void run() {
-				// 娣诲姞娴忚璁板綍
-				try {
-					scanHistoryV2Service.addScanHistory(uid, acceptData.getDevice(), goodsInfo);
-				} catch (Exception e) {
-					e.printStackTrace();
-				}
-			}
-		});
-	}
-
-	/**
-	 * 浜笢鍟嗗搧棰濆閰嶇疆淇℃伅
-	 * 
-	 * @param acceptData
-	 * @param id
-	 * @param uid
-	 * @param from
-	 * @param out
-	 */
-	public void getJDExtraDetial(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
-		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
-				acceptData.getPackages());
-		if (system == null) {
-			out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�"));
-			return;
-		}
-
-		GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
-		// IOS鏄惁姝e湪涓婄嚎
-		if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
-			String version = acceptData.getVersion();
-			extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version)));
-		}
-
-		
-		JDGoods jdGoods = JDApiUtil.queryGoodsDetail(id);
-		if (jdGoods == null) {
-			jdGoods = JDApiUtil.getGoodsDetail(id);
-		}
-		
-		if (jdGoods == null) {
-			out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧涓嶅瓨鍦�"));
-			return;
-		}
-		
-
-		BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
-		BigDecimal shareRate = hongBaoManageService.getShareRate();
-		GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, null, fanLiRate, shareRate);
 
 		Long inOrderCount30Days = jdGoods.getInOrderCount30Days();
 		List<ShamUser> listShareUser = new ArrayList<ShamUser>();
@@ -801,7 +642,7 @@
 		SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system,
 				"goods_detail_jump_taobao");
 		if ("1".equalsIgnoreCase((params.getValue() + "").trim())) {
-			extraVO.setNative(true);
+			extraVO.setIsNative(true);
 		}
 
 		// 鍟嗗搧閾炬帴
@@ -829,9 +670,9 @@
 		extraVO.setShareInfo(shareInfoVO);
 
 		JSONObject object = new JSONObject();
-		object.put("code", 0);
-		object.put("data", JsonUtil.getApiCommonGson().toJson(extraVO));
-		out.print(object.toString());
+		object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
+		object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail));
+		out.print(JsonUtil.loadTrueResult(object.toString()));
 
 		final JDGoods goods = jdGoods;
 		ThreadUtil.run(new Runnable() {
@@ -839,7 +680,6 @@
 				// 娣诲姞娴忚璁板綍
 				try {
 					scanHistoryV2Service.addJDScanHistory(uid, acceptData.getDevice(), goods);
-					;
 				} catch (Exception e) {
 					e.printStackTrace();
 				}
@@ -848,7 +688,7 @@
 	}
 
 	/**
-	 * 浜笢鍟嗗搧棰濆閰嶇疆淇℃伅
+	 * 浜笢鍟嗗搧璇︽儏
 	 * 
 	 * @param acceptData
 	 * @param id
@@ -856,19 +696,13 @@
 	 * @param from
 	 * @param out
 	 */
-	public void getPDDExtraDetial(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
+	public void getPDDGoodsDetial(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
+		// 绯荤粺楠岃瘉
 		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
 				acceptData.getPackages());
 		if (system == null) {
 			out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�"));
 			return;
-		}
-
-		GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
-		// IOS鏄惁姝e湪涓婄嚎
-		if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
-			String version = acceptData.getVersion();
-			extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version)));
 		}
 
 		PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(id);
@@ -881,8 +715,14 @@
 		BigDecimal shareRate = hongBaoManageService.getShareRate();
 		GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, null, fanLiRate, shareRate);
 
-		//搴楅摵淇℃伅
-		extraVO.setShopInfo(ShopInfoVOFactory.convertPDDShop(pddGoods));
+		GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
+		extraVO.setIsNative(false);
+		// IOS鏄惁姝e湪涓婄嚎
+		if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
+			String version = acceptData.getVersion();
+			extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version)));
+		}
+
 		
 		Long inOrderCount30Days = pddGoods.getSoldQuantity();
 		List<ShamUser> listShareUser = new ArrayList<ShamUser>();
@@ -915,7 +755,7 @@
 		SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system,
 				"goods_detail_jump_taobao");
 		if ("1".equalsIgnoreCase((params.getValue() + "").trim())) {
-			extraVO.setNative(true);
+			extraVO.setIsNative(true);
 		}
 
 		// 鍟嗗搧閾炬帴
@@ -942,20 +782,20 @@
 		extraVO.setShareInfo(shareInfoVO);
 
 		JSONObject object = new JSONObject();
-		object.put("code", 0);
-		object.put("data", JsonUtil.getApiCommonGson().toJson(extraVO));
-		out.print(object.toString());
+		object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
+		object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail));
+		out.print(JsonUtil.loadTrueResult(object.toString()));
 
 		ThreadUtil.run(new Runnable() {
 			public void run() {
 				// 娣诲姞娴忚璁板綍
 				try {
 					scanHistoryV2Service.addPDDScanHistory(uid, acceptData.getDevice(), pddGoods);
-					;
 				} catch (Exception e) {
 					e.printStackTrace();
 				}
 			}
 		});
 	}
+
 }

--
Gitblit v1.8.0