From aeae4b32ba980c7701b6870611462a4095453e72 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 21 五月 2021 18:35:33 +0800
Subject: [PATCH] PID管理

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java |   49 +++++++++++++++++++++++++++++--------------------
 1 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java
index 0457f70..01e4e5f 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java
@@ -11,8 +11,10 @@
 import javax.servlet.http.HttpServletRequest;
 
 import com.yeshi.fanli.entity.SystemEnum;
+import com.yeshi.fanli.entity.SystemPIDInfo;
 import com.yeshi.fanli.exception.taobao.TaoBaoConvertLinkException;
 import com.yeshi.fanli.service.inter.pdd.PDDAuthService;
+import com.yeshi.fanli.service.manger.PIDManager;
 import com.yeshi.fanli.service.manger.goods.TaoBaoLinkManager;
 import com.yeshi.fanli.util.*;
 import com.yeshi.fanli.util.StringUtil;
@@ -148,6 +150,9 @@
 
     @Resource
     private PDDAuthService pddAuthService;
+
+    @Resource
+    private PIDManager pidManager;
 
     private List<ShareGoodsCommentChoiceInfo> getCommentChoiceList(String token, String link, String inviteCode,
                                                                    BigDecimal fanliMoney) {
@@ -501,7 +506,7 @@
         try {
             ShareInfoVO shareInfo = new ShareInfoVO();
 
-            TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(uid, goodsId, relationId, null);
+            TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(acceptData.getSystem(), uid, goodsId, relationId, null);
 
             if (taoBaoLink != null && taoBaoLink.getGoods() != null && needGoods) {
                 GoodsMoneyConfigParamsDTO dto = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version, acceptData.getSystem());
@@ -738,9 +743,10 @@
             couponUrl = couponInfo.getLink();
         }
         String materialId = "https://item.jd.com/" + goodsId + ".html";
-        String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, JDApiUtil.POSITION_SHARE + "", uid + "");
+        String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.share);
+        String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pid, uid + "");
         if (StringUtil.isNullOrEmpty(jumpLink)) {
-            jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null, JDApiUtil.POSITION_SHARE + "", uid + "");
+            jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null, pid, uid + "");
         }
 
         ShareInfoVO shareInfo = new ShareInfoVO();
@@ -895,13 +901,15 @@
 
         //鏌ヨ褰撳墠鐢ㄦ埛鏄惁鎺堟潈
 
+        String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.share);
+
         if (VersionUtil.greaterThan_2_1_5(acceptData.getPlatform(), acceptData.getVersion())) {
-            if (!PinDuoDuoApiUtil.isAuth(PinDuoDuoApiUtil.PID_SHARE, pddAuthService.getFanliCustomParams(uid))) {
+            if (!PinDuoDuoApiUtil.isAuth(pid, pddAuthService.getFanliCustomParams(uid))) {
                 out.print(JsonUtil.loadFalseResult(20001, "灏氭湭澶囨,璇峰厛澶囨"));
                 return;
             }
         } else {
-            if (System.currentTimeMillis() > TimeUtil.convertToTimeTemp("2021-05-01", "yyyy-MM-dd") && !PinDuoDuoApiUtil.isAuth(PinDuoDuoApiUtil.PID_SHARE, pddAuthService.getFanliCustomParams(uid))) {
+            if (System.currentTimeMillis() > TimeUtil.convertToTimeTemp("2021-05-01", "yyyy-MM-dd") && !PinDuoDuoApiUtil.isAuth(pid, pddAuthService.getFanliCustomParams(uid))) {
                 out.print(JsonUtil.loadFalseResult(20001, "璇峰崌绾у埌鏈�鏂扮増"));
                 return;
             }
@@ -920,7 +928,7 @@
         // AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
         // goodsId + "");
 
-        String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goods.getGoodsSign(), PinDuoDuoApiUtil.PID_SHARE + "", uid + "");
+        String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goods.getGoodsSign(), pid, uid + "");
 
         SystemEnum system = SystemInfoUtil.getSystem(acceptData);
 
@@ -1224,7 +1232,7 @@
         String couponLink = goods.getCouponInfo().getCouponUrl();
 
         String jumpLink = SuningApiUtil.convertLink(SuningUtil.getProductUrl(sts[0], sts[1]),
-                StringUtil.isNullOrEmpty(couponLink) ? null : couponLink, SuningApiUtil.PID_SHARE, uid + "");
+                StringUtil.isNullOrEmpty(couponLink) ? null : couponLink, pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_SUNING, SystemPIDInfo.PidType.share), uid + "");
 
         ShareInfoVO shareInfo = new ShareInfoVO();
         shareInfo.setClickUrl(jumpLink);
@@ -1401,17 +1409,17 @@
         }
 
         if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
-            createTaoBaoViewText(goodsType, uid, template, Long.parseLong(goodsId), tljId, hasCoupon, out);
+            createTaoBaoViewText(acceptData.getSystem(), goodsType, uid, template, Long.parseLong(goodsId), tljId, hasCoupon, out);
             return;
         }
 
         if (goodsType == Constant.SOURCE_TYPE_JD) {
-            createJDViewText(goodsType, uid, template, Long.parseLong(goodsId), hasCoupon, out);
+            createJDViewText(acceptData.getSystem(), goodsType, uid, template, Long.parseLong(goodsId), hasCoupon, out);
             return;
         }
 
         if (goodsType == Constant.SOURCE_TYPE_PDD) {
-            createPDDViewText(goodsType, uid, template, Long.parseLong(goodsId), hasCoupon, out);
+            createPDDViewText(acceptData.getSystem(), goodsType, uid, template, Long.parseLong(goodsId), hasCoupon, out);
             return;
         }
 
@@ -1421,7 +1429,7 @@
         }
 
         if (goodsType == Constant.SOURCE_TYPE_SUNING) {
-            createSuNingViewText(goodsType, uid, template, goodsId, hasCoupon, out);
+            createSuNingViewText(acceptData.getSystem(), goodsType, uid, template, goodsId, hasCoupon, out);
             return;
         }
     }
@@ -1437,7 +1445,7 @@
      * @param hasCoupon
      * @param out
      */
-    private void createTaoBaoViewText(Integer goodsType, Long uid, String template, Long goodsId, Long tljId,
+    private void createTaoBaoViewText(SystemEnum system, Integer goodsType, Long uid, String template, Long goodsId, Long tljId,
                                       Boolean hasCoupon, PrintWriter out) {
         TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goodsId);
         if (goods == null)
@@ -1472,11 +1480,12 @@
         }
 
         if (StringUtil.isNullOrEmpty(token)) {
+            String pid = pidManager.getPidCache(system, Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.share);
             TaoKeAppInfo app = new TaoKeAppInfo();
-            app.setAdzoneId(TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT.split("_")[3]);
+            app.setAdzoneId(pid.split("_")[3]);
             app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
             app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
-            app.setPid(TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT);
+            app.setPid(pid);
             TaoBaoGoodsBrief goodsLink = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app, null, null);
             if (goodsLink != null)
                 token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(),
@@ -1499,7 +1508,7 @@
      * @param hasCoupon
      * @param out
      */
-    private void createJDViewText(Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon,
+    private void createJDViewText(SystemEnum system, Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon,
                                   PrintWriter out) {
         JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(goodsId);
         if (goods == null) {
@@ -1525,7 +1534,7 @@
             couponUrl = couponInfo.getLink();
         }
         String materialId = "https://item.jd.com/" + goodsId + ".html";
-        String shortLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, JDApiUtil.POSITION_SHARE + "",
+        String shortLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pidManager.getPidCache(system, Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.share),
                 uid + "");
 
         String content = shareGoodsTextTemplateService.createContentJD(template, goods, shortLink, hasCoupon);
@@ -1544,7 +1553,7 @@
      * @param hasCoupon
      * @param out
      */
-    private void createPDDViewText(Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon,
+    private void createPDDViewText(SystemEnum system, Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon,
                                    PrintWriter out) {
         PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
         if (goods == null) {
@@ -1572,7 +1581,7 @@
         // goodsId + "");
         // String shortLink = HttpUtil.getShortLink(url);
 
-        String shortLink = PinDuoDuoApiUtil.getPromotionUrl(goods.getGoodsSign(), PinDuoDuoApiUtil.PID_SHARE + "", uid + "");
+        String shortLink = PinDuoDuoApiUtil.getPromotionUrl(goods.getGoodsSign(), pidManager.getPidCache(system, Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.share), uid + "");
 
         // // 鍒涘缓鍙d护
         // String token = PinDuoDuoApiUtil.createGenerate(goodsId);
@@ -1626,7 +1635,7 @@
     }
 
 
-    private void createSuNingViewText(Integer goodsType, Long uid, String template, String goodsId, Boolean hasCoupon,
+    private void createSuNingViewText(SystemEnum system, Integer goodsType, Long uid, String template, String goodsId, Boolean hasCoupon,
                                       PrintWriter out) {
         String[] ids = SuningUtil.getGoodsIdDetail(goodsId);
         SuningGoodsInfo goods = SuningApiUtil.getGoodsDetail(ids[1], ids[0]);
@@ -1649,7 +1658,7 @@
 
         String couponLink = goods.getCouponInfo().getCouponUrl();
         String jumpLink = SuningApiUtil.convertLink(SuningUtil.getProductUrl(ids[0], ids[1]),
-                StringUtil.isNullOrEmpty(couponLink) ? null : couponLink, SuningApiUtil.PID_SHARE, uid + "");
+                StringUtil.isNullOrEmpty(couponLink) ? null : couponLink, pidManager.getPidCache(system, Constant.SOURCE_TYPE_SUNING, SystemPIDInfo.PidType.share), uid + "");
 
         // 鐢熸垚鏅�氬垎浜唴瀹�
         String content = shareGoodsTextTemplateService.createCommonShareTextSuNing(template, goods, jumpLink);

--
Gitblit v1.8.0