From 744594ef1a2f530fc3e86ea9dc48b62247f79420 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 19 五月 2020 17:13:23 +0800
Subject: [PATCH] 饿了么绘图,添加口碑

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsController.java |   72 ++++++++++++++++++++++++------------
 1 files changed, 48 insertions(+), 24 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsController.java
index e492da6..f4a167e 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsController.java
@@ -25,11 +25,13 @@
 import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
 import com.yeshi.fanli.exception.tlj.TaoLiJinCreateException;
 import com.yeshi.fanli.log.LogHelper;
+import com.yeshi.fanli.log.TaoKeLogHelper;
 import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
 import com.yeshi.fanli.service.inter.goods.recommend.RecommendGoodsDeleteHistoryService;
 import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service;
 import com.yeshi.fanli.service.inter.monitor.MonitorService;
 import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
+import com.yeshi.fanli.service.inter.taobao.TLJFreeBuyGoodsService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoBuyRelationMapService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
 import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinRecordService;
@@ -43,6 +45,7 @@
 import com.yeshi.fanli.util.TaoBaoConstant;
 import com.yeshi.fanli.util.TimeUtil;
 import com.yeshi.fanli.util.factory.MonitorFactory;
+import com.yeshi.fanli.util.taobao.TaoBaoUtil;
 import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
 
 import net.sf.json.JSONObject;
@@ -89,6 +92,9 @@
 
 	@Resource
 	private IntegralGetService integralGetService;
+
+	@Resource
+	private TLJFreeBuyGoodsService tljFreeBuyGoodsService;
 
 	private void doTaoLiJinBuy(AcceptData acceptData, Long uid, Long auctionId, PrintWriter out) {
 		JSONObject data = new JSONObject();
@@ -155,6 +161,14 @@
 			return;
 		}
 
+		try {
+			// 鏃ュ織璁板綍
+			String info = String.format("type=buy&uid=%s&goodsId=%s&source=%s&goodsType=%s", uid, auctionId, source,
+					Constant.SOURCE_TYPE_TAOBAO);
+			LogHelper.orderInfo(info);
+		} catch (Exception e) {
+		}
+
 		TaoBaoGoodsBrief goods = null;
 
 		try {
@@ -175,13 +189,26 @@
 			return;
 		}
 
+		ClientTBPid clientTBPid = null;
+
+		String dpid = null;
+		if (TaoBaoUtil.isSpecialGoods(goods.getMaterialLibType())) {
+			dpid = TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT;
+		} else {
+			dpid = TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID;
+		}
+		String psiteId = dpid.split("_")[2];
+		String padzoneId = dpid.split("_")[3];
+		TaoBaoUnionConfig config1 = taoBaoUnionConfigService.getConfigByAppIdCache(psiteId);
+		clientTBPid = new ClientTBPid(config1.getAppKey(), dpid, psiteId, padzoneId);
+
 		JSONObject data = new JSONObject();
 		boolean isNative = false;
 		String pid = null;
 
 		boolean specialConvert = false;
 
-		if (goods.getMaterialLibType() != null && goods.getMaterialLibType() == 1) {
+		if (TaoBaoUtil.isSpecialGoods(goods.getMaterialLibType())) {
 			specialConvert = true;
 		} else
 			specialConvert = false;
@@ -217,20 +244,14 @@
 			// 鏄繑鍒╁晢鍝佸簱鐨勫晢鍝�
 			if (specialConvert) {
 				if (!StringUtil.isNullOrEmpty(specialId)) {
-					if (source != null && "taolijin".equals(source)) {
-						boolean isNewUser = userInfoExtraService.isNewUser(uid);
-						if (isNewUser) {
-							// 鍒ゅ畾涓鸿�佺敤鎴凤細
-							// 鏂颁汉鍙浣跨敤浜嗘柊浜虹孩鍖咃紝涔熷氨鏄偅1鍧楅挶锛岄偅涔堬紝浠栫湅鍒扮殑鍒嗕韩鐖嗘涓殑鍟嗗搧-灏卞彧鑳藉垎浜��
-							long countRecord = userTaoLiJinRecordService.countRecordByUid(uid);
-							if (countRecord == 0) {
-								taoBaoLink = shareGoodsService.getTaoLiJinLinkForBuy(uid, specialId, auctionId, null);
-							}
-						}
+					if (source != null && "taolijin_free_buy".equals(source)) {
+						taoBaoLink = shareGoodsService.getTaoLiJinLinkForBuy(uid, specialId, auctionId, null);
 					}
 
 					if (taoBaoLink == null) {
 						taoBaoLink = shareGoodsService.getTaoBaoLinkForBuyWithSpecial(uid, specialId, auctionId);
+						if(taoBaoLink!=null)
+							clientTBPid=null;
 					}
 
 					data.put("native", true);
@@ -254,17 +275,9 @@
 					LogHelper.errorDetailInfo(e, "uid:" + uid, null);
 				}
 				if (!StringUtil.isNullOrEmpty(relationId)) {//
-					if (source != null && "taolijin".equals(source)) {
-						boolean isNewUser = userInfoExtraService.isNewUser(uid);
-						if (isNewUser) {
-							// 鍒ゅ畾涓鸿�佺敤鎴凤細
-							// 鏂颁汉鍙浣跨敤浜嗘柊浜虹孩鍖咃紝涔熷氨鏄偅1鍧楅挶锛岄偅涔堬紝浠栫湅鍒扮殑鍒嗕韩鐖嗘涓殑鍟嗗搧-灏卞彧鑳藉垎浜��
-							long countRecord = userTaoLiJinRecordService.countRecordByUid(uid);
-							if (countRecord == 0) {
-								taoBaoLink = shareGoodsService.getTaoLiJinLinkForBuy(uid, specialId, auctionId,
-										TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
-							}
-						}
+					if (source != null && "taolijin_free_buy".equals(source)) {
+						taoBaoLink = shareGoodsService.getTaoLiJinLinkForBuy(uid, specialId, auctionId,
+								TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
 					} else {
 						taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId,
 								TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
@@ -287,11 +300,22 @@
 			link.put("couponUrl", taoBaoLink.getCouponLink());
 			data.put("type", 1);
 			data.put("link", link);
+			if (clientTBPid != null)
+				data.put("tbPidInfo", clientTBPid);
 			out.print(JsonUtil.loadTrueResult(data));
+
+			TaoKeLogHelper.convertLinkInfo(
+					String.format("uid:%s  auctionId:%s 杈撳嚭缁撴灉:", uid, auctionId + "") + data.toString());
 
 			// 鑾峰緱閲戝竵
 			integralGetService.addCouponRebate(uid);
 
+		} catch (ShareGoodsException e) {
+			if (e.getCode() == 1001 || e.getCode() == 1002) {
+				out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
+			} else {
+				out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
+			}
 		} catch (Exception e) {
 
 			LogHelper.errorDetailInfo(e);
@@ -335,9 +359,9 @@
 					String siteId = tbPid.getPid().split("_")[2];
 					String adzoneId = tbPid.getPid().split("_")[3];
 					TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(siteId);
-					ClientTBPid clientTBPid = new ClientTBPid(config.getAppKey(), tbPid.getPid(), siteId, adzoneId);
+					ClientTBPid clientTBPid1 = new ClientTBPid(config.getAppKey(), tbPid.getPid(), siteId, adzoneId);
 					data.put("type", 2);
-					data.put("tbPidInfo", clientTBPid);
+					data.put("tbPidInfo", clientTBPid1);
 					data.put("native", true);
 				}
 

--
Gitblit v1.8.0