From 3340ed122e19e3943ce4f93eb52103b623a3fc2c Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 27 四月 2022 15:43:58 +0800
Subject: [PATCH] 订单消息bug修改

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java |  125 ++++++++++++++++++++++++++++++-----------
 1 files changed, 90 insertions(+), 35 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 24589e4..7707486 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
@@ -1,7 +1,9 @@
 package com.yeshi.fanli.controller.client.v2;
 
 import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
+import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
@@ -11,7 +13,12 @@
 import javax.servlet.http.HttpServletRequest;
 
 import com.yeshi.fanli.entity.SystemEnum;
+import com.yeshi.fanli.entity.SystemFunction;
+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.inter.user.*;
+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;
@@ -23,7 +30,7 @@
 
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
-import com.yeshi.fanli.dto.ConfigParamsDTO;
+import com.yeshi.fanli.dto.GoodsMoneyConfigParamsDTO;
 import com.yeshi.fanli.dto.jd.JDCouponInfo;
 import com.yeshi.fanli.dto.jd.JDPingouInfo;
 import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
@@ -60,10 +67,6 @@
 import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
 import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService;
 import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinRecordService;
-import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
-import com.yeshi.fanli.service.inter.user.UserInfoService;
-import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
-import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
 import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
 import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
 import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
@@ -145,6 +148,15 @@
     @Resource
     private UserTaoLiJinRecordService userTaoLiJinRecordService;
 
+    @Resource
+    private PDDAuthService pddAuthService;
+
+    @Resource
+    private PIDManager pidManager;
+
+    @Resource
+    private UserFunctionsLimitService userFunctionsLimitService;
+
     private List<ShareGoodsCommentChoiceInfo> getCommentChoiceList(String token, String link, String inviteCode,
                                                                    BigDecimal fanliMoney) {
         List<ShareGoodsCommentChoiceInfo> list = new ArrayList<>();
@@ -208,6 +220,11 @@
             return;
         }
 
+        if (userFunctionsLimitService.isLimit(uid, SystemFunction.share, new Date())) {
+            out.print(JsonUtil.loadFalseResult(1, "璇ュ姛鑳介檺鍒朵娇鐢�"));
+            return;
+        }
+
         // 娣樺疂
         if (goodsType == null || goodsType == Constant.SOURCE_TYPE_TAOBAO) {
             createTaoBaoShare(acceptData, uid, Long.parseLong(goodsId), totalNum, source, needGoods, request, out);
@@ -241,13 +258,30 @@
     }
 
     public static String getERCodeContentNew(String template, TaoBaoGoodsBrief goods, String token) {
+        String tempToken = "";
+        String[] sts = token.split(" ");
+        if (sts.length > 1) {
+            for (int i = 0; i < sts.length - 1; i++) {
+                tempToken += sts[i] + " ";
+            }
+        } else {
+            tempToken = token;
+        }
+        tempToken = tempToken.trim();
+
+        try {
+            tempToken = URLEncoder.encode(tempToken, "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
         String commentText = template.replace("[鍘熶环]", goods.getZkPrice().toString());
-        commentText = commentText.replace("[娣樺彛浠", token);
+        commentText = commentText.replace("[娣樺彛浠", tempToken);
         if (StringUtil.isNullOrEmpty(goods.getCouponInfo())) {
             commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘");
             commentText = commentText.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", "");
         } else {
-            commentText = commentText.replace("[鍒稿悗浠穄", TaoBaoUtil.getAfterUseCouplePrice(goods) + "");
+            commentText = commentText.replace("[鍒稿悗浠穄", TaoBaoUtil.getCouponPrice(goods) + "");
         }
 
         commentText = commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n");
@@ -414,7 +448,7 @@
                         .replace("{鍟嗗搧鍘熶环}", MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + "")
                         .replace("{浼樻儬鍒搁潰棰潁", MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount()).toString())
                         .replace("{娣樼ぜ閲戦潰棰潁", MoneyBigDecimalUtil.getWithNoZera(spreadMoney).toString())
-                        .replace("{浼樻儬鍒镐环}", TaoBaoUtil.getAfterUseCouplePrice(goods) + "");
+                        .replace("{浼樻儬鍒镐环}", TaoBaoUtil.getCouponPrice(goods) + "");
             }
 
             shareText = shareText.replace("{搴楅摵绫诲瀷}", shopType)
@@ -497,10 +531,10 @@
         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) {
-                ConfigParamsDTO dto = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version, acceptData.getSystem());
+                GoodsMoneyConfigParamsDTO dto = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version, acceptData.getSystem());
                 GoodsDetailVO goodsInfo = GoodsDetailVOFactory.convertTaoBao(taoBaoLink.getGoods(), dto);
                 shareInfo.setGoodsInfo(goodsInfo);
             }
@@ -645,7 +679,7 @@
                     commentText = commentText.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", "");
                 } else {
                     commentText = commentText.replace("[鍒稿悗浠穄",
-                            TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + "");
+                            TaoBaoUtil.getCouponPrice(taoBaoLink.getGoods()) + "");
                 }
 
                 if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
@@ -734,9 +768,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();
@@ -825,7 +860,7 @@
                 recommendText = recommendText.replace("[鍒搁潰棰漖",
                         BigDecimalUtil.getWithNoZera(couponInfo.getDiscount()).toString());
                 commentText = commentText.replace("[鍒稿悗浠穄",
-                        BigDecimalUtil.getWithNoZera(JDUtil.getQuanPrice(jdGoods)).toString());
+                        BigDecimalUtil.getWithNoZera(JDUtil.getCouponPrice(jdGoods)).toString());
             }
             commentText = commentText.replace("[閾炬帴]", jumpLink);
         } else {
@@ -888,6 +923,24 @@
      */
     public void createPDDShare(AcceptData acceptData, Long uid, Long goodsId, String source, boolean needGoods,
                                PrintWriter out) {
+
+        //鏌ヨ褰撳墠鐢ㄦ埛鏄惁鎺堟潈
+
+        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(pid, pddAuthService.getFanliCustomParams(uid))) {
+                out.print(JsonUtil.loadFalseResult(20001, "灏氭湭澶囨,璇峰厛澶囨"));
+                return;
+            }
+        } else {
+            if (System.currentTimeMillis() > TimeUtil.convertToTimeTemp("2021-05-01", "yyyy-MM-dd") && !PinDuoDuoApiUtil.isAuth(pid, pddAuthService.getFanliCustomParams(uid))) {
+                out.print(JsonUtil.loadFalseResult(20001, "璇峰崌绾у埌鏈�鏂扮増"));
+                return;
+            }
+        }
+
+
         PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
         if (goods == null) {
             out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佸凡涓嬫灦"));
@@ -900,7 +953,7 @@
         // AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
         // goodsId + "");
 
-        String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goods.getGoodsSign(), PinDuoDuoApiUtil.PID_SHARE + "", uid + "");
+        String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goods.getGoodsSign(), pid, pddAuthService.getFanliCustomParams(uid) + "");
 
         SystemEnum system = SystemInfoUtil.getSystem(acceptData);
 
@@ -913,7 +966,7 @@
         if (needGoods) {
             shareInfo
                     .setGoodsInfo(GoodsDetailVOFactory.convertPDDGoods(goods,
-                            new ConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()),
+                            new GoodsMoneyConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()),
                                     hongBaoManageService.getShareRate(acceptData.getSystem()), Constant.MAX_REWARD_RATE,
                                     hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP, acceptData.getSystem()))));
         }
@@ -997,7 +1050,7 @@
                 recommendText = recommendText.replace("浼樻儬鍒�:[鍒搁潰棰漖鍏�", "");
             } else {
                 commentText = commentText.replace("[鍒稿悗浠穄",
-                        BigDecimalUtil.getWithNoZera(PinDuoDuoUtil.getQuanPrice(goods)).toString());
+                        BigDecimalUtil.getWithNoZera(PinDuoDuoUtil.getCouponPrice(goods)).toString());
 
                 BigDecimal hundred = new BigDecimal(100);
                 BigDecimal amount = MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponDiscount()), hundred);
@@ -1081,7 +1134,7 @@
         if (needGoods) {
             shareInfo
                     .setGoodsInfo(GoodsDetailVOFactory.convertVIPGoods(goods,
-                            new ConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()),
+                            new GoodsMoneyConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()),
                                     hongBaoManageService.getShareRate(acceptData.getSystem()), Constant.MAX_REWARD_RATE,
                                     hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP, acceptData.getSystem()))));
         }
@@ -1204,7 +1257,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);
@@ -1216,7 +1269,7 @@
         if (needGoods) {
             shareInfo
                     .setGoodsInfo(GoodsDetailVOFactory.convertSuningGoods(goods,
-                            new ConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()),
+                            new GoodsMoneyConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()),
                                     hongBaoManageService.getShareRate(acceptData.getSystem()), Constant.MAX_REWARD_RATE,
                                     hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP, acceptData.getSystem()))));
         }
@@ -1381,17 +1434,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;
         }
 
@@ -1401,7 +1454,7 @@
         }
 
         if (goodsType == Constant.SOURCE_TYPE_SUNING) {
-            createSuNingViewText(goodsType, uid, template, goodsId, hasCoupon, out);
+            createSuNingViewText(acceptData.getSystem(), goodsType, uid, template, goodsId, hasCoupon, out);
             return;
         }
     }
@@ -1417,7 +1470,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)
@@ -1452,11 +1505,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(),
@@ -1479,7 +1533,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) {
@@ -1505,7 +1559,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);
@@ -1524,7 +1578,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) {
@@ -1552,7 +1606,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);
@@ -1606,7 +1660,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]);
@@ -1629,7 +1683,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);
@@ -1842,7 +1896,7 @@
             }
         }
 
-        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
+        GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                 acceptData.getVersion(), acceptData.getSystem());
 
         Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
@@ -1884,6 +1938,7 @@
             dataObject.put("totalMoney", "楼" + goodsGroup.getTotalMoney());
 
             GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, paramsDTO);
+            detailVO.setCreatetime(null);
             detailVO.setId(commonGoods.getId());
             dataObject.put("goods", gson.toJson(detailVO));
             array.add(dataObject);
@@ -1914,7 +1969,7 @@
         }
 
         GoodsDetailVO goodsDetail = null;
-        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
+        GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                 acceptData.getVersion(), acceptData.getSystem());
         paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem()));
 

--
Gitblit v1.8.0