From 573c491b4a1ba60e12a5678a01c1546c0077c1ee Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 30 七月 2019 09:07:42 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsController.java |  118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 110 insertions(+), 8 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 18ea5b9..ed7f834 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
@@ -12,20 +12,26 @@
 import com.yeshi.fanli.entity.accept.AcceptData;
 import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
 import com.yeshi.fanli.entity.bus.user.UserInfo;
+import com.yeshi.fanli.entity.goods.recommend.RecommendGoodsDeleteHistory;
 import com.yeshi.fanli.entity.taobao.ClientTBPid;
 import com.yeshi.fanli.entity.taobao.PidUser;
 import com.yeshi.fanli.entity.taobao.TBPid;
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
 import com.yeshi.fanli.entity.taobao.TaoBaoLink;
 import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
+import com.yeshi.fanli.exception.ShareGoodsException;
 import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
 import com.yeshi.fanli.log.LogHelper;
 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.TaoBaoBuyRelationMapService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
+import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinRecordService;
 import com.yeshi.fanli.service.inter.user.TBPidService;
 import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
+import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
 import com.yeshi.fanli.service.inter.user.UserInfoService;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.StringUtil;
@@ -60,6 +66,36 @@
 	@Resource
 	private TaoBaoBuyRelationMapService taoBaoBuyRelationMapService;
 
+	@Resource
+	private BusinessEmergent110Service businessEmergent110Service;
+
+	@Resource
+	private RecommendGoodsDeleteHistoryService recommendGoodsDeleteHistoryService;
+
+	@Resource
+	private UserInfoExtraService userInfoExtraService;
+
+	@Resource
+	private UserTaoLiJinRecordService userTaoLiJinRecordService;
+
+	private void doTaoLiJinBuy(Long uid, Long auctionId, PrintWriter out) {
+		JSONObject data = new JSONObject();
+		TaoBaoLink taoBaoLink;
+		try {
+			taoBaoLink = shareGoodsService.getTaoLiJinLinkForBuyWithOutFanLi(uid, auctionId);
+		} catch (ShareGoodsException e) {
+			out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
+			return;
+		}
+		data.put("native", true);
+		JSONObject link = new JSONObject();
+		link.put("clickUrl", taoBaoLink.getClickUrl());
+		link.put("couponUrl", taoBaoLink.getCouponLink());
+		data.put("type", 1);
+		data.put("link", link);
+		out.print(JsonUtil.loadTrueResult(data));
+	}
+
 	/**
 	 * 鑾峰彇娣樺疂鐨勫垎浜摼鎺�
 	 * 
@@ -70,8 +106,8 @@
 	 * @param out
 	 */
 	@RequestMapping(value = "gettaobaolink")
-	public void getTaoBaoLink(AcceptData acceptData, Long uid, Long auctionId, String from, HttpServletRequest request,
-			PrintWriter out) {
+	public void getTaoBaoLink(AcceptData acceptData, Long uid, Long auctionId, String from, String source,
+			HttpServletRequest request, PrintWriter out) {
 		if (uid == null || uid <= 0) {
 			out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛ID涓嶈兘涓虹┖"));
 			return;
@@ -101,6 +137,11 @@
 			} catch (Exception e1) {
 				e1.printStackTrace();
 			}
+		}
+
+		if ("taolijin_buy".equalsIgnoreCase(source)) {
+			doTaoLiJinBuy(uid, auctionId, out);
+			return;
 		}
 
 		JSONObject data = new JSONObject();
@@ -141,10 +182,26 @@
 			pidType = PidUser.TYPE_FANLI_IOS;
 		try {
 			TaoBaoLink taoBaoLink = null;
+
 			// 鏄繑鍒╁晢鍝佸簱鐨勫晢鍝�
 			if (specialConvert) {
 				if (!StringUtil.isNullOrEmpty(specialId)) {
-					taoBaoLink = shareGoodsService.getTaoBaoLinkForBuyWithSpecial(uid, specialId, auctionId);
+					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 (taoBaoLink == null) {
+						taoBaoLink = shareGoodsService.getTaoBaoLinkForBuyWithSpecial(uid, specialId, auctionId);
+					}
+
 					data.put("native", true);
 				} else {
 					if (!specialConvert && !isNative) {
@@ -166,8 +223,22 @@
 					LogHelper.errorDetailInfo(e, "uid:" + uid, null);
 				}
 				if (!StringUtil.isNullOrEmpty(relationId)) {//
-					taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId,
-							TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
+					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);
+							}
+						}
+					} else {
+						taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId,
+								TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
+					}
+
 					data.put("native", true);
 				} else {
 					if (pidType == PidUser.TYPE_FANLI_ANDROID)
@@ -188,6 +259,9 @@
 			out.print(JsonUtil.loadTrueResult(data));
 
 		} catch (Exception e) {
+
+			LogHelper.errorDetailInfo(e);
+
 			isNative = false;
 			try {
 				monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, 0, "璐拱娣樺疂鍟嗗搧杞摼鍑洪敊"));
@@ -223,7 +297,6 @@
 					data.put("type", 1);
 					data.put("link", link);
 					data.put("native", true);
-
 				} catch (Exception e1) {
 					String siteId = tbPid.getPid().split("_")[2];
 					String adzoneId = tbPid.getPid().split("_")[3];
@@ -233,13 +306,14 @@
 					data.put("tbPidInfo", clientTBPid);
 					data.put("native", true);
 				}
-				
+
 				out.print(JsonUtil.loadTrueResult(data));
 			} else {
 				out.print(JsonUtil.loadFalseResult(1, "璇锋眰澶辫触"));
 			}
-		}
 
+			businessEmergent110Service.buyTaoBaoGoodsError(StringUtil.Md5(auctionId + ""));
+		}
 	}
 
 	/**
@@ -289,4 +363,32 @@
 		}
 	}
 
+	/**
+	 * 鍒犻櫎鎺ㄨ崘鍟嗗搧
+	 * 
+	 * @param acceptData
+	 * @param goodsId
+	 * @param source
+	 * @param uid
+	 * @param reason
+	 * @param out
+	 */
+	@RequestMapping(value = "deleteRecommendGoods")
+	public void deleteRecommendGoods(AcceptData acceptData, Long goodsId, Integer source, Long uid, String reason,
+			PrintWriter out) {
+		if (goodsId == null) {
+			out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼犲晢鍝�"));
+			return;
+		}
+
+		RecommendGoodsDeleteHistory history = new RecommendGoodsDeleteHistory();
+		history.setDevice(acceptData.getDevice());
+		history.setReason(reason);
+		history.setUid(uid);
+		history.setGoodsSource(source == null ? Constant.SOURCE_TYPE_TAOBAO : source);
+		history.setGoodsId(goodsId);
+		recommendGoodsDeleteHistoryService.addRecommendGoodsDeleteHistory(history);
+		out.print(JsonUtil.loadTrueResult(""));
+	}
+
 }

--
Gitblit v1.8.0