From f71ae35c5b20e51c5fba91284cc436076c9c73df Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 03 十一月 2020 19:28:19 +0800
Subject: [PATCH] 淘宝订单备份
---
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsController.java | 698 ++++++++++++++++++++++++++++++---------------------------
1 files changed, 370 insertions(+), 328 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..b521f5c 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
@@ -5,6 +5,10 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
+import com.yeshi.fanli.entity.SystemFunction;
+import com.yeshi.fanli.exception.taobao.TaoBaoConvertLinkException;
+import com.yeshi.fanli.service.manger.goods.TaoBaoLinkManager;
+import com.yeshi.fanli.util.SystemInfoUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
@@ -17,14 +21,15 @@
import com.yeshi.fanli.entity.taobao.PidUser;
import com.yeshi.fanli.entity.taobao.TBPid;
import com.yeshi.fanli.entity.taobao.TLJBuyGoods;
-import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
+import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoLink;
import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
-import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
+import com.yeshi.common.entity.taobao.TaoKeAppInfo;
import com.yeshi.fanli.exception.share.ShareGoodsException;
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;
@@ -32,17 +37,16 @@
import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
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.UserInfoExtraService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.integral.IntegralGetService;
import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TaoBaoConstant;
-import com.yeshi.fanli.util.TimeUtil;
+import org.yeshi.utils.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;
@@ -51,381 +55,419 @@
@RequestMapping(value = "api/v1/goods")
public class GoodsController {
- @Resource
- private ShareGoodsService shareGoodsService;
+ @Resource
+ private ShareGoodsService shareGoodsService;
- @Resource
- private TBPidService tbPidService;
+ @Resource
+ private TBPidService tbPidService;
- @Resource
- private TaoBaoUnionConfigService taoBaoUnionConfigService;
+ @Resource
+ private TaoBaoUnionConfigService taoBaoUnionConfigService;
- @Resource
- private MonitorService monitorService;
+ @Resource
+ private MonitorService monitorService;
- @Resource
- private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
+ @Resource
+ private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
- @Resource
- private UserInfoService userInfoService;
+ @Resource
+ private UserInfoService userInfoService;
- @Resource
- private TaoBaoBuyRelationMapService taoBaoBuyRelationMapService;
+ @Resource
+ private TaoBaoBuyRelationMapService taoBaoBuyRelationMapService;
- @Resource
- private BusinessEmergent110Service businessEmergent110Service;
+ @Resource
+ private BusinessEmergent110Service businessEmergent110Service;
- @Resource
- private RecommendGoodsDeleteHistoryService recommendGoodsDeleteHistoryService;
+ @Resource
+ private RecommendGoodsDeleteHistoryService recommendGoodsDeleteHistoryService;
- @Resource
- private UserInfoExtraService userInfoExtraService;
- @Resource
- private UserTaoLiJinRecordService userTaoLiJinRecordService;
+ @Resource
+ private TLJBuyGoodsService tljBuyGoodsService;
- @Resource
- private TLJBuyGoodsService tljBuyGoodsService;
+ @Resource
+ private IntegralGetService integralGetService;
- @Resource
- private IntegralGetService integralGetService;
+ @Resource
+ private TaoBaoLinkManager taoBaoLinkManager;
- private void doTaoLiJinBuy(AcceptData acceptData, Long uid, Long auctionId, PrintWriter out) {
- JSONObject data = new JSONObject();
- TaoBaoLink taoBaoLink = null;
- try {
- // 鏍规嵁鏃ユ湡涓庡晢鍝両D鏌ヨ
- TLJBuyGoods tljBuyGoods = tljBuyGoodsService.selectByAuctionIdAndDay(auctionId,
- TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
- if (tljBuyGoods == null) {
- out.print(JsonUtil.loadFalseResult(1, "鍟嗗搧涓嶅瓨鍦�"));
- return;
- }
- String appKey = tljBuyGoods.getAppKey();
- TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppKeyCache(appKey);
- if (config == null) {
- out.print(JsonUtil.loadFalseResult(2, "鐢熸垚鎺ㄥ箍閾炬帴澶辫触"));
- return;
- }
- TaoKeAppInfo app = new TaoKeAppInfo(config.getAppKey(), config.getAppSecret(), config.getDefaultPid());
- taoBaoLink = shareGoodsService.getTaoLiJinLinkForBuyWithOutFanLi(uid, auctionId, app);
- } catch (TaoLiJinCreateException e1) {
- out.print(JsonUtil.loadFalseResult(e1.getCode(), "娣樼ぜ閲戠孩鍖呭垱寤哄け璐�"));
- return;
- } 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));
+ private void doTaoLiJinBuy(AcceptData acceptData, Long uid, Long auctionId, PrintWriter out) {
+ JSONObject data = new JSONObject();
+ TaoBaoLink taoBaoLink = null;
+ try {
+ // 鏍规嵁鏃ユ湡涓庡晢鍝両D鏌ヨ
+ TLJBuyGoods tljBuyGoods = tljBuyGoodsService.selectByAuctionIdAndDay(auctionId,
+ TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
+ if (tljBuyGoods == null) {
+ out.print(JsonUtil.loadFalseResult(1, "鍟嗗搧涓嶅瓨鍦�"));
+ return;
+ }
+ String appKey = tljBuyGoods.getAppKey();
+ TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppKeyCache(appKey);
+ if (config == null) {
+ out.print(JsonUtil.loadFalseResult(2, "鐢熸垚鎺ㄥ箍閾炬帴澶辫触"));
+ return;
+ }
+ TaoKeAppInfo app = new TaoKeAppInfo(config.getAppKey(), config.getAppSecret(), config.getDefaultPid());
+ taoBaoLink = shareGoodsService.getTaoLiJinLinkForBuyWithOutFanLi(uid, auctionId, app);
+ } catch (TaoLiJinCreateException e1) {
+ out.print(JsonUtil.loadFalseResult(e1.getCode(), "娣樼ぜ閲戠孩鍖呭垱寤哄け璐�"));
+ return;
+ } 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));
- integralGetService.addTaoLiJinBuy(uid, auctionId);
- }
+ integralGetService.addTaoLiJinBuy(uid, auctionId);
+ }
- /**
- * 鑾峰彇娣樺疂鐨勫垎浜摼鎺�
- *
- * @param acceptData
- * @param uid
- * -鐢ㄦ埛ID
- * @param auctionId-鍟嗗搧ID
- * @param out
- */
- @RequestMapping(value = "gettaobaolink")
- 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;
- }
- 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;
- }
+ private void getTaoBaoLinkWithoutFanLi(AcceptData acceptData, Long auctionId, String from, String source,
+ HttpServletRequest request, PrintWriter out) {
+ try {
+ TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForRecieveCoupon(auctionId, null, TaoBaoConstant.TAOBAO_COUPON_PID);
+ JSONObject data = new JSONObject();
+ JSONObject link = new JSONObject();
+ link.put("clickUrl", taoBaoLink.getClickUrl());
+ link.put("couponUrl", taoBaoLink.getCouponLink());
+ data.put("type", 1);
+ data.put("link", link);
+ data.put("native", true);
+ out.print(JsonUtil.loadTrueResult(data));
+ } catch (TaoBaoConvertLinkException e) {
+ e.printStackTrace();
+ out.print(JsonUtil.loadFalseResult("棰嗗埜鍑洪敊"));
+ }
+ }
- if (auctionId == null || auctionId <= 0) {
- out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧ID涓嶈兘涓虹┖"));
- return;
- }
+ /**
+ * 鑾峰彇娣樺疂鐨勫垎浜摼鎺�
+ *
+ * @param acceptData
+ * @param uid -鐢ㄦ埛ID
+ * @param auctionId-鍟嗗搧ID
+ * @param out
+ */
+ @RequestMapping(value = "gettaobaolink")
+ public void getTaoBaoLink(AcceptData acceptData, Long uid, Long auctionId, String from, String source,
+ HttpServletRequest request, PrintWriter out) {
- TaoBaoGoodsBrief goods = null;
+ if (auctionId == null || auctionId <= 0) {
+ out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧ID涓嶈兘涓虹┖"));
+ return;
+ }
- try {
- goods = TaoKeApiUtil.getSimpleGoodsInfo(auctionId);
- } catch (TaobaoGoodsDownException e) {
- out.print(JsonUtil.loadFalseResult(3, "鍟嗗搧宸蹭笅鏋�"));
- return;
- } catch (Exception e) {
- try {
- LogHelper.errorDetailInfo(e, "鑾峰彇鍟嗗搧绠�鐗堣鎯呭嚭閿�", auctionId + "");
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
+ if (!SystemInfoUtil.hasFunctions(acceptData.getSystem(), SystemFunction.fanli)) {
+ getTaoBaoLinkWithoutFanLi(acceptData, auctionId, from, source, request, out);
+ return;
+ }
- if ("taolijin_buy".equalsIgnoreCase(source)) {
- doTaoLiJinBuy(acceptData, uid, auctionId, out);
- return;
- }
+ if (uid == null || uid <= 0) {
+ out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛ID涓嶈兘涓虹┖"));
+ return;
+ }
- JSONObject data = new JSONObject();
- boolean isNative = false;
- String pid = null;
- boolean specialConvert = false;
+ 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;
+ }
- if (goods.getMaterialLibType() != null && goods.getMaterialLibType() == 1) {
- specialConvert = true;
- } else
- specialConvert = false;
+ 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) {
+ }
- String specialId = null;
- String relationId = null;
- // 鏌ヨ鐢ㄦ埛ID鏄惁缁戝畾浜嗕細鍛樿繍钀D
- UserExtraTaoBaoInfo userInfo = userExtraTaoBaoInfoService.getByUid(uid);
- if (userInfo != null && !StringUtil.isNullOrEmpty(userInfo.getSpecialId()) && userInfo.getSpecialValid() != null
- && userInfo.getSpecialValid() == true) {
- specialId = userInfo.getSpecialId();
- relationId = userInfo.getRelationId();
- // 宸茬粡缁戝畾
- if (specialConvert) {
- isNative = true;
- } else
- isNative = false;
+ TaoBaoGoodsBrief goods = null;
- pid = TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT;
+ try {
+ goods = TaoKeApiUtil.getSimpleGoodsInfo(auctionId);
+ } catch (TaobaoGoodsDownException e) {
+ out.print(JsonUtil.loadFalseResult(3, "鍟嗗搧宸蹭笅鏋�"));
+ return;
+ } catch (Exception e) {
+ try {
+ LogHelper.errorDetailInfo(e, "鑾峰彇鍟嗗搧绠�鐗堣鎯呭嚭閿�", auctionId + "");
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ }
- } else {// 灏氭湭缁戝畾
- isNative = true;
- }
+ if ("taolijin_buy".equalsIgnoreCase(source)) {
+ doTaoLiJinBuy(acceptData, uid, auctionId, out);
+ return;
+ }
- data.put("native", isNative);
+ ClientTBPid clientTBPid = null;
- int pidType = PidUser.TYPE_FANLI_ANDROID;
- if (acceptData.getPlatform().equalsIgnoreCase("ios"))
- pidType = PidUser.TYPE_FANLI_IOS;
- try {
- TaoBaoLink taoBaoLink = 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);
- // 鏄繑鍒╁晢鍝佸簱鐨勫晢鍝�
- 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);
- }
- }
- }
+ JSONObject data = new JSONObject();
+ boolean isNative = false;
+ String pid = null;
- if (taoBaoLink == null) {
- taoBaoLink = shareGoodsService.getTaoBaoLinkForBuyWithSpecial(uid, specialId, auctionId);
- }
+ boolean specialConvert = false;
- data.put("native", true);
- } else {
- if (!specialConvert && !isNative) {
- if (pidType == PidUser.TYPE_FANLI_ANDROID)
- taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
- tbPidService.getAndroidDefault().getPid());
- else
- taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
- tbPidService.getIOSDefault().getPid());
+ if (TaoBaoUtil.isSpecialGoods(goods.getMaterialLibType())) {
+ specialConvert = true;
+ } else
+ specialConvert = false;
- } else
- taoBaoLink = shareGoodsService.getTaoBaoLinkForBuy(uid, auctionId, pidType);
- LogHelper.test("璐拱杞摼:榛樿PID杞摼-" + uid + "锛�" + auctionId);
- }
- } else {// 涓嶆槸杩斿埄搴撶殑鍟嗗搧锛岀敤鐗规畩PID鏇夸唬
- try {
- relationId = taoBaoBuyRelationMapService.getRelationId(uid);
- } catch (Exception e) {
- 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);
- }
- }
- } else {
- taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId,
- TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
- }
+ String specialId = null;
+ String relationId = null;
+ // 鏌ヨ鐢ㄦ埛ID鏄惁缁戝畾浜嗕細鍛樿繍钀D
+ UserExtraTaoBaoInfo userInfo = userExtraTaoBaoInfoService.getByUid(uid);
+ if (userInfo != null && !StringUtil.isNullOrEmpty(userInfo.getSpecialId()) && userInfo.getSpecialValid() != null
+ && userInfo.getSpecialValid() == true) {
+ specialId = userInfo.getSpecialId();
+ relationId = userInfo.getRelationId();
+ // 宸茬粡缁戝畾
+ if (specialConvert) {
+ isNative = true;
+ } else
+ isNative = false;
- data.put("native", true);
- } else {
- if (pidType == PidUser.TYPE_FANLI_ANDROID)
- taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
- tbPidService.getAndroidDefault().getPid());
- else
- taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
- tbPidService.getIOSDefault().getPid());
+ pid = TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT;
- LogHelper.test("璐拱杞摼:榛樿PID杞摼-闈炶繑鍒╁簱鍟嗗搧-" + uid + "锛�" + auctionId);
- }
- }
- 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));
+ } else {// 灏氭湭缁戝畾
+ isNative = true;
+ }
- // 鑾峰緱閲戝竵
- integralGetService.addCouponRebate(uid);
+ data.put("native", isNative);
- } catch (Exception e) {
+ int pidType = PidUser.TYPE_FANLI_ANDROID;
+ if (acceptData.getPlatform().equalsIgnoreCase("ios"))
+ pidType = PidUser.TYPE_FANLI_IOS;
+ try {
+ TaoBaoLink taoBaoLink = null;
- LogHelper.errorDetailInfo(e);
+ // 鏄繑鍒╁晢鍝佸簱鐨勫晢鍝�
+ if (specialConvert) {
+ if (!StringUtil.isNullOrEmpty(specialId)) {
+ if (source != null && "taolijin_free_buy".equals(source)) {
+ taoBaoLink = taoBaoLinkManager.getTaoLiJinLinkForBuy(uid, auctionId, null);
+ }
- isNative = false;
- try {
- monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, 0, "璐拱娣樺疂鍟嗗搧杞摼鍑洪敊"));
- } catch (Exception e1) {
- e1.printStackTrace();
- }
+ if (taoBaoLink == null) {
+ taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForBuy(uid, auctionId, specialId, null);
+ if (taoBaoLink != null)
+ clientTBPid = null;
+ }
- TBPid tbPid = null;
- if (acceptData.getPlatform().equalsIgnoreCase("android")) {
- tbPid = tbPidService.getTBPid(uid, PidUser.TYPE_FANLI_ANDROID);
- } else {
- tbPid = tbPidService.getTBPid(uid, PidUser.TYPE_FANLI_IOS);
- }
+ data.put("native", true);
+ } else {
+ if (!specialConvert && !isNative) {
+ if (pidType == PidUser.TYPE_FANLI_ANDROID)
+ taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
+ tbPidService.getAndroidDefault().getPid());
+ else
+ taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
+ tbPidService.getIOSDefault().getPid());
+ } else
+ taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForBuy(uid, auctionId, specialId, null);
+ LogHelper.test("璐拱杞摼:榛樿PID杞摼-" + uid + "锛�" + auctionId);
+ }
+ } else {// 涓嶆槸杩斿埄搴撶殑鍟嗗搧锛岀敤鐗规畩PID鏇夸唬
+ try {
+ relationId = taoBaoBuyRelationMapService.getRelationId(uid);
+ } catch (Exception e) {
+ LogHelper.errorDetailInfo(e, "uid:" + uid, null);
+ }
+ if (!StringUtil.isNullOrEmpty(relationId)) {//
+ if (source != null && "taolijin_free_buy".equals(source)) {
+ taoBaoLink = taoBaoLinkManager.getTaoLiJinLinkForBuy(uid, auctionId,
+ TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
+ } else {
+ taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(uid, auctionId, relationId,
+ TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
+ }
- LogHelper.test("璐拱杞摼:榛樿PID杞摼-寮傚父鍟嗗搧-" + uid + "锛�" + auctionId);
+ data.put("native", true);
+ } else {
+ if (pidType == PidUser.TYPE_FANLI_ANDROID)
+ taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
+ tbPidService.getAndroidDefault().getPid());
+ else
+ taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
+ tbPidService.getIOSDefault().getPid());
- data.put("native", isNative);
+ LogHelper.test("璐拱杞摼:榛樿PID杞摼-闈炶繑鍒╁簱鍟嗗搧-" + uid + "锛�" + auctionId);
+ }
+ }
+ JSONObject link = new JSONObject();
+ link.put("clickUrl", taoBaoLink.getClickUrl());
+ 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));
- if (tbPid != null) {
+ TaoKeLogHelper.convertLinkInfo(
+ String.format("uid:%s auctionId:%s 杈撳嚭缁撴灉:", uid, auctionId + "") + data.toString());
- try {
- TaoBaoLink taoBaoLink = null;
- if (pidType == PidUser.TYPE_FANLI_ANDROID)
- taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
- tbPidService.getAndroidDefault().getPid());
- else
- taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
- tbPidService.getIOSDefault().getPid());
+ // 鑾峰緱閲戝竵
+ integralGetService.addCouponRebate(uid);
- JSONObject link = new JSONObject();
- link.put("clickUrl", taoBaoLink.getClickUrl());
- link.put("couponUrl", taoBaoLink.getCouponLink());
- 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];
- TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(siteId);
- ClientTBPid clientTBPid = new ClientTBPid(config.getAppKey(), tbPid.getPid(), siteId, adzoneId);
- data.put("type", 2);
- data.put("tbPidInfo", clientTBPid);
- data.put("native", true);
- }
+ } 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) {
- out.print(JsonUtil.loadTrueResult(data));
- } else {
- out.print(JsonUtil.loadFalseResult(1, "璇锋眰澶辫触"));
- }
+ LogHelper.errorDetailInfo(e);
- businessEmergent110Service.buyTaoBaoGoodsError(StringUtil.Md5(auctionId + ""));
- }
- }
+ isNative = false;
+ try {
+ monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, 0, "璐拱娣樺疂鍟嗗搧杞摼鍑洪敊"));
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
- /**
- * 鏄惁鍦ㄥ弬涓庢帹骞�
- */
+ TBPid tbPid = null;
+ if (acceptData.getPlatform().equalsIgnoreCase("android")) {
+ tbPid = tbPidService.getTBPid(uid, PidUser.TYPE_FANLI_ANDROID);
+ } else {
+ tbPid = tbPidService.getTBPid(uid, PidUser.TYPE_FANLI_IOS);
+ }
- /**
- * 鏄惁鍦ㄥ弬涓庢帹骞�
- *
- * @param goodsId
- * -鍟嗗搧ID
- * @param goodsType
- * -TB/JD
- * @param out
- */
- @RequestMapping(value = "isGoodsExtend")
- public void isGoodsExtend(AcceptData acceptData, String goodsId, String goodsType, PrintWriter out) {
- if (StringUtil.isNullOrEmpty(goodsId)) {
- out.print(JsonUtil.loadFalseResult(1, "鏈弬涓庢帹骞�"));
- return;
- }
- if (StringUtil.isNullOrEmpty(goodsType)) {
- out.print(JsonUtil.loadFalseResult(2, "缂哄皯goodsType"));
- return;
- }
- if ("TB".equalsIgnoreCase(goodsType)) {
- TaoBaoGoodsBrief goods = null;
- try {
- goods = TaoKeApiUtil.getSimpleGoodsInfo(Long.parseLong(goodsId));
- } catch (NumberFormatException e) {
- e.printStackTrace();
- } catch (TaobaoGoodsDownException e) {
- e.printStackTrace();
- }
+ LogHelper.test("璐拱杞摼:榛樿PID杞摼-寮傚父鍟嗗搧-" + uid + "锛�" + auctionId);
- JSONObject data = new JSONObject();
+ data.put("native", isNative);
- if (goods == null) {
- data.put("extend", false);
- data.put("url", "https://h5.m.taobao.com/awp/core/detail.htm?id=" + goodsId);
- } else {
- data.put("extend", true);
- }
- out.print(JsonUtil.loadTrueResult(data));
- } else {
- out.print(JsonUtil.loadFalseResult(3, "鏆備笉鏀寔鍏朵粬鍟嗗搧绫诲瀷"));
- }
- }
+ if (tbPid != null) {
- /**
- * 鍒犻櫎鎺ㄨ崘鍟嗗搧
- *
- * @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;
- }
+ try {
+ TaoBaoLink taoBaoLink = null;
+ if (pidType == PidUser.TYPE_FANLI_ANDROID)
+ taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
+ tbPidService.getAndroidDefault().getPid());
+ else
+ taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
+ tbPidService.getIOSDefault().getPid());
- 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(""));
+ JSONObject link = new JSONObject();
+ link.put("clickUrl", taoBaoLink.getClickUrl());
+ link.put("couponUrl", taoBaoLink.getCouponLink());
+ 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];
+ TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(siteId);
+ ClientTBPid clientTBPid1 = new ClientTBPid(config.getAppKey(), tbPid.getPid(), siteId, adzoneId);
+ data.put("type", 2);
+ data.put("tbPidInfo", clientTBPid1);
+ data.put("native", true);
+ }
- // 鑾峰緱閲戝竵
- integralGetService.addCloseRecommendGoods(uid);
- }
+ out.print(JsonUtil.loadTrueResult(data));
+ } else {
+ out.print(JsonUtil.loadFalseResult(1, "璇锋眰澶辫触"));
+ }
+
+ businessEmergent110Service.buyTaoBaoGoodsError(StringUtil.Md5(auctionId + ""), acceptData.getSystem());
+ }
+ }
+
+ /**
+ * 鏄惁鍦ㄥ弬涓庢帹骞�
+ */
+
+ /**
+ * 鏄惁鍦ㄥ弬涓庢帹骞�
+ *
+ * @param goodsId -鍟嗗搧ID
+ * @param goodsType -TB/JD
+ * @param out
+ */
+ @RequestMapping(value = "isGoodsExtend")
+ public void isGoodsExtend(AcceptData acceptData, String goodsId, String goodsType, PrintWriter out) {
+ if (StringUtil.isNullOrEmpty(goodsId)) {
+ out.print(JsonUtil.loadFalseResult(1, "鏈弬涓庢帹骞�"));
+ return;
+ }
+ if (StringUtil.isNullOrEmpty(goodsType)) {
+ out.print(JsonUtil.loadFalseResult(2, "缂哄皯goodsType"));
+ return;
+ }
+ if ("TB".equalsIgnoreCase(goodsType)) {
+ TaoBaoGoodsBrief goods = null;
+ try {
+ goods = TaoKeApiUtil.getSimpleGoodsInfo(Long.parseLong(goodsId));
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ } catch (TaobaoGoodsDownException e) {
+ e.printStackTrace();
+ }
+
+ JSONObject data = new JSONObject();
+
+ if (goods == null) {
+ data.put("extend", false);
+ data.put("url", "https://h5.m.taobao.com/awp/core/detail.htm?id=" + goodsId);
+ } else {
+ data.put("extend", true);
+ }
+ out.print(JsonUtil.loadTrueResult(data));
+ } else {
+ out.print(JsonUtil.loadFalseResult(3, "鏆備笉鏀寔鍏朵粬鍟嗗搧绫诲瀷"));
+ }
+ }
+
+ /**
+ * 鍒犻櫎鎺ㄨ崘鍟嗗搧
+ *
+ * @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(""));
+
+ // 鑾峰緱閲戝竵
+ integralGetService.addCloseRecommendGoods(uid);
+ }
}
--
Gitblit v1.8.0