From e75b0d79535a6bcd147cca4a54632b70b42afdb9 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 29 五月 2021 18:10:18 +0800
Subject: [PATCH] 特价完善

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java |   81 ++++++++++++++++++++++++----------------
 1 files changed, 48 insertions(+), 33 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
index 1c26eb7..ea53970 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
@@ -18,7 +18,9 @@
 import javax.imageio.ImageIO;
 
 import com.yeshi.fanli.entity.SystemEnum;
+import com.yeshi.fanli.entity.SystemPIDInfo;
 import com.yeshi.fanli.exception.taobao.TaoBaoConvertLinkException;
+import com.yeshi.fanli.service.manger.PIDManager;
 import com.yeshi.fanli.service.manger.goods.TaoBaoLinkManager;
 import org.apache.commons.beanutils.PropertyUtils;
 import org.springframework.cache.annotation.CacheEvict;
@@ -32,7 +34,7 @@
 import org.yeshi.utils.tencentcloud.COSManager;
 
 import com.yeshi.fanli.dao.dynamic.GoodsEvaluateDao;
-import com.yeshi.fanli.dto.ConfigParamsDTO;
+import com.yeshi.fanli.dto.GoodsMoneyConfigParamsDTO;
 import com.yeshi.fanli.dto.jd.JDCouponInfo;
 import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
 import com.yeshi.fanli.dto.suning.SuningGoodsInfo;
@@ -49,13 +51,12 @@
 import com.yeshi.fanli.entity.dynamic.SimpleGoods;
 import com.yeshi.fanli.entity.jd.JDGoods;
 import com.yeshi.fanli.entity.system.ConfigKeyEnum;
-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.dataoke.DaTaoKeDetailV2;
+import com.yeshi.goods.facade.entity.taobao.dataoke.DaTaoKeDetailV2;
 import com.yeshi.fanli.exception.dynamic.ActivityUserException;
 import com.yeshi.fanli.exception.dynamic.GoodsEvaluateException;
 import com.yeshi.fanli.exception.goods.ConvertLinkExceptionException;
-import com.yeshi.fanli.exception.share.ShareGoodsException;
 import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
 import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.service.inter.activity.ActivityUserService;
@@ -64,15 +65,15 @@
 import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
 import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
 import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
-import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service;
+import com.yeshi.goods.facade.service.DaTaoKeGoodsDetailV2Service;
 import com.yeshi.fanli.service.manger.goods.ConvertLinkManager;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.FilePathEnum;
 import com.yeshi.fanli.util.FileUtil;
-import com.yeshi.fanli.util.MoneyBigDecimalUtil;
+import org.yeshi.utils.MoneyBigDecimalUtil;
 import com.yeshi.fanli.util.RedisManager;
 import com.yeshi.fanli.util.StringUtil;
-import com.yeshi.fanli.util.TimeUtil;
+import org.yeshi.utils.TimeUtil;
 import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
 import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
 import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
@@ -83,7 +84,7 @@
 import com.yeshi.fanli.util.taobao.TaoBaoUtil;
 import com.yeshi.fanli.vo.goods.CouponInfoVO;
 import com.yeshi.fanli.vo.goods.GoodsDetailVO;
-import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
+import com.yeshi.common.vo.ClientTextStyleVO;
 
 @Service
 public class GoodsEvaluateServiceImpl implements GoodsEvaluateService {
@@ -126,6 +127,10 @@
 
     @Resource
     private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
+
+
+    @Resource
+    private PIDManager pidManager;
 
     @Override
     public void switchState(String id) throws GoodsEvaluateException {
@@ -427,7 +432,7 @@
         GoodsDetailVO goodsDetailVO = null;
         JDGoods jdGoods = null;
         PDDGoodsDetail pddGoods = null;
-        ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
+        GoodsMoneyConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
         params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
         if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
             try {
@@ -547,7 +552,7 @@
         String commentText = "";
         if (addComment) {
             if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
-                TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(1L, Long.parseLong(goodsId), "0", null);
+                TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(system, 1L, Long.parseLong(goodsId), "0", null);
                 String template = configService.getValue(ConfigKeyEnum.quickShareTBCommentText.getKey(), system);
                 commentText = template.replace("[娣樺彛浠", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
             } else if (goodsType == Constant.SOURCE_TYPE_JD) {
@@ -557,15 +562,17 @@
                     couponUrl = couponInfo.getLink();
                 }
                 String materialId = "https://item.jd.com/" + goodsId + ".html";
-                String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl,
-                        JDApiUtil.POSITION_SHARE + "", "1");
+                String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,
+                        pidManager.getPidCache(system, Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.share), "1");
                 String template = configService.getValue(ConfigKeyEnum.quickShareJDCommentText.getKey(), system);
                 if (jumpLink == null) {
                     throw new GoodsEvaluateException(1, "璇ュ晢鍝佽浆閾惧け璐�");
                 }
                 commentText = template.replace("[閾炬帴]", jumpLink);
             } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
-                String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(Long.parseLong(goodsId), PinDuoDuoApiUtil.PID_SHARE + "", "1");
+                String sharePid = pidManager.getPidCache(system, Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.share);
+                PDDGoodsDetail goodsDetail = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(goodsId), sharePid, "1");
+                String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsDetail.getGoodsSign(), sharePid, "1");
                 if (jumpLink == null) {
                     throw new GoodsEvaluateException(1, "璇ュ晢鍝佽浆閾惧け璐�");
                 }
@@ -613,7 +620,7 @@
     private String createTokenAndLink(GoodsDetailVO goodsDetailVO, SystemEnum system) throws Exception {
         String commentText = "";
         if (goodsDetailVO.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
-            TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(1L, Long.parseLong(goodsDetailVO.getGoodsId()), "0", null);
+            TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(system, 1L, Long.parseLong(goodsDetailVO.getGoodsId()), "0", null);
             String template = configService.getValue(ConfigKeyEnum.quickShareTBCommentText.getKey(), system);
             commentText = template.replace("[娣樺彛浠", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
         } else if (goodsDetailVO.getGoodsType() == Constant.SOURCE_TYPE_JD) {
@@ -625,13 +632,19 @@
                 couponUrl = couponInfo.getLink();
             }
             String materialId = "https://item.jd.com/" + goodsDetailVO.getGoodsId() + ".html";
-            String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "",
+            String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pidManager.getPidCache(system, Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.share),
                     "1");
             String template = configService.getValue(ConfigKeyEnum.quickShareJDCommentText.getKey(), system);
             commentText = template.replace("[閾炬帴]", jumpLink);
         } else if (goodsDetailVO.getGoodsType() == Constant.SOURCE_TYPE_PDD) {
-            String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(Long.parseLong(goodsDetailVO.getGoodsId()),
-                    PinDuoDuoApiUtil.PID_SHARE + "", "1");
+
+            String sharePid = pidManager.getPidCache(system, Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.share);
+
+            PDDGoodsDetail goodsDetail = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(goodsDetailVO.getGoodsId()),
+                    sharePid, "1");
+
+            String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsDetail.getGoodsSign(),
+                    sharePid, "1");
             String template = configService.getValue(ConfigKeyEnum.quickSharePDDCommentText.getKey(), system);
             commentText = template.replace("[閾炬帴]", jumpLink);
         }
@@ -649,7 +662,7 @@
 
     public GoodsDetailVO getGoodsDetailVO(Long goodsId, Integer goodsType, SystemEnum system) throws GoodsEvaluateException {
         GoodsDetailVO goodsDetail = null;
-        ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
+        GoodsMoneyConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
         params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
         if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
             try {
@@ -908,7 +921,7 @@
                 }
             } else if (i == 0 && kind == 1) {
                 try {
-                    convertLinkManager.convertLinkFromText(content, Constant.LINK_TOKEN_VERIFY_UID, true);
+                    convertLinkManager.convertLinkFromText(system, content, Constant.LINK_TOKEN_VERIFY_UID, true, false);
                 } catch (Exception e) {
                     throw new GoodsEvaluateException(1, "涓嶅寘鍚彲杞摼鐨勫彛浠や笌閾炬帴");
                 }
@@ -933,7 +946,7 @@
     }
 
     @Override
-    public void saveCurrencyCoupon(String pid, int kind, CommentInfo commentInfo)
+    public void saveCurrencyCoupon(SystemEnum system, String pid, int kind, CommentInfo commentInfo)
             throws GoodsEvaluateException, Exception {
         if (StringUtil.isNullOrEmpty(pid)) {
             throw new GoodsEvaluateException(1, "璇蜂繚瀛樼涓�閮ㄥ垎淇℃伅");
@@ -978,7 +991,7 @@
         String content = commentInfo.getContent();
         if (!StringUtil.isNullOrEmpty(content) && commentInfo.getNeedSpin()) {
             try {
-                convertLinkManager.convertLinkFromText(content, Constant.LINK_TOKEN_VERIFY_UID, true);
+                convertLinkManager.convertLinkFromText(system, content, Constant.LINK_TOKEN_VERIFY_UID, true, false);
             } catch (ConvertLinkExceptionException e) {
                 if (ConvertLinkExceptionException.CODE_NONE != e.getCode()) {
                     throw new GoodsEvaluateException(1, "鍖呭惈涓嶅彲杞摼鐨勫彛浠や笌閾炬帴");
@@ -1701,7 +1714,7 @@
                                 List<String> activityIdList = convertLinkManager.getTaoBaoOfficialActivityId(content);
                                 for (String st : activityIdList)
                                     content = content.replace(st, "");
-
+                                content = content.replace("{relationId}", "");
                                 commentInfoNew.setContent(content);
                             }
                         }
@@ -1712,6 +1725,8 @@
                         List<String> activityIdList = convertLinkManager.getTaoBaoOfficialActivityId(content);
                         for (String st : activityIdList)
                             content = content.replace(st, "");
+                        content = content.replace("{relationId}", "");
+
                         commentInfoNew.setContent(content);
                     }
 
@@ -1823,7 +1838,7 @@
             SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
             for (GoodsEvaluate goodsEvaluate : list) {
-                ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", goodsEvaluate.getSystem());
+                GoodsMoneyConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", goodsEvaluate.getSystem());
                 params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(goodsEvaluate.getSystem()));
                 // 鏄惁2涓皬鏃朵箣鍐呭凡鏇存柊
                 Date updateTime = goodsEvaluate.getUpdateTime();
@@ -1916,7 +1931,7 @@
         }
     }
 
-    private GoodsDetailVO getGoodsNewInfo(String goodsId, int goodsType, ConfigParamsDTO paramsDTO) {
+    private GoodsDetailVO getGoodsNewInfo(String goodsId, int goodsType, GoodsMoneyConfigParamsDTO paramsDTO) {
         GoodsDetailVO vo = null;
         if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
             TaoBaoGoodsBrief goods;
@@ -1977,7 +1992,7 @@
         imgs.addAll(goodsBrief.getImgList());
 
         // 鍟嗗搧VO
-        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
+        GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
         paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
         GoodsDetailVO goodsVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, paramsDTO);
 
@@ -2102,7 +2117,7 @@
         }
 
         // 鍟嗗搧VO
-        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
+        GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
         paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
         GoodsDetailVO goodsVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, paramsDTO);
 
@@ -2143,7 +2158,7 @@
         // 鐢熸垚鍙d护
         String token = null;
         try {
-            TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(Constant.LINK_TOKEN_VERIFY_UID, goodsBrief.getAuctionId(), "1", null);
+            TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(system, Constant.LINK_TOKEN_VERIFY_UID, goodsBrief.getAuctionId(), "1", null);
             token = taoBaoLink.getTaoToken();
         } catch (TaoBaoConvertLinkException e) {
             e.printStackTrace();
@@ -2289,7 +2304,7 @@
                 return false;
             }
 
-            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
+            GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
             paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
             GoodsDetailVO goodsVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, paramsDTO);
 
@@ -2519,7 +2534,7 @@
                 if (queryExist == null || queryExist.size() == 0) {
                     continue;
                 }
-                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
+                GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
                 paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
                 GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO);
                 updateGoods(queryExist, goodsNew);
@@ -2541,7 +2556,7 @@
                 continue;
             }
 
-            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
+            GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
             paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
             GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO);
 
@@ -2560,7 +2575,7 @@
                 continue;
             }
 
-            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
+            GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
             paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
             GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertPDDGoods(pddGoods, paramsDTO);
             updateGoods(queryExist, goodsNew);
@@ -2579,7 +2594,7 @@
                 continue;
             }
 
-            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
+            GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
             paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
             GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertVIPGoods(goods, paramsDTO);
             updateGoods(queryExist, goodsNew);
@@ -2597,7 +2612,7 @@
             if (queryExist == null || queryExist.size() == 0) {
                 continue;
             }
-            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
+            GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
             paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
             GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertSuningGoods(goods, paramsDTO);
             updateGoods(queryExist, goodsNew);

--
Gitblit v1.8.0