From a7454d8a6325566753358b37ffabfae2faa0ca7f Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 28 四月 2021 19:46:49 +0800
Subject: [PATCH] 拼多多授权调整,支持小程序跳转

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java |   97 ++++++++++++++++++++++++++----------------------
 1 files changed, 53 insertions(+), 44 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 cee1790..9d61096 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
@@ -49,13 +49,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 +63,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 +82,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 {
@@ -427,8 +426,8 @@
         GoodsDetailVO goodsDetailVO = null;
         JDGoods jdGoods = null;
         PDDGoodsDetail pddGoods = null;
-        ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
-        params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
+        ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
+        params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
         if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
             try {
                 TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(Long.parseLong(goodsId));
@@ -557,7 +556,7 @@
                     couponUrl = couponInfo.getLink();
                 }
                 String materialId = "https://item.jd.com/" + goodsId + ".html";
-                String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl,
+                String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,
                         JDApiUtil.POSITION_SHARE + "", "1");
                 String template = configService.getValue(ConfigKeyEnum.quickShareJDCommentText.getKey(), system);
                 if (jumpLink == null) {
@@ -565,7 +564,8 @@
                 }
                 commentText = template.replace("[閾炬帴]", jumpLink);
             } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
-                String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(Long.parseLong(goodsId), PinDuoDuoApiUtil.PID_SHARE + "", "1");
+                PDDGoodsDetail goodsDetail = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(goodsId), PinDuoDuoApiUtil.PID_SHARE + "", "1");
+                String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsDetail.getGoodsSign(), PinDuoDuoApiUtil.PID_SHARE + "", "1");
                 if (jumpLink == null) {
                     throw new GoodsEvaluateException(1, "璇ュ晢鍝佽浆閾惧け璐�");
                 }
@@ -625,12 +625,15 @@
                 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, JDApiUtil.POSITION_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()),
+            PDDGoodsDetail goodsDetail = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(goodsDetailVO.getGoodsId()),
+                    PinDuoDuoApiUtil.PID_SHARE + "", "1");
+
+            String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsDetail.getGoodsSign(),
                     PinDuoDuoApiUtil.PID_SHARE + "", "1");
             String template = configService.getValue(ConfigKeyEnum.quickSharePDDCommentText.getKey(), system);
             commentText = template.replace("[閾炬帴]", jumpLink);
@@ -647,10 +650,10 @@
         return commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n");
     }
 
-    public GoodsDetailVO getGoodsDetailVO(Long goodsId, Integer goodsType) throws GoodsEvaluateException {
+    public GoodsDetailVO getGoodsDetailVO(Long goodsId, Integer goodsType, SystemEnum system) throws GoodsEvaluateException {
         GoodsDetailVO goodsDetail = null;
-        ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
-        params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
+        ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
+        params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
         if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
             try {
                 TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(goodsId);
@@ -758,7 +761,7 @@
                 for (int i = 0; i < goodsArray.length && i < 9; i++) {
                     String goodsids = goodsArray[i];
                     String[] g = goodsids.split("-");
-                    GoodsDetailVO goodsDetailVO = getGoodsDetailVO(Long.parseLong(g[0]), Integer.parseInt(g[1]));
+                    GoodsDetailVO goodsDetailVO = getGoodsDetailVO(Long.parseLong(g[0]), Integer.parseInt(g[1]), resultObj.getSystem());
                     if (goodsDetailVO == null) {
                         continue;
                     }
@@ -908,7 +911,7 @@
                 }
             } else if (i == 0 && kind == 1) {
                 try {
-                    convertLinkManager.convertLinkFromText(content, Constant.LINK_TOKEN_VERIFY_UID, true);
+                    convertLinkManager.convertLinkFromText(content, Constant.LINK_TOKEN_VERIFY_UID, true, false);
                 } catch (Exception e) {
                     throw new GoodsEvaluateException(1, "涓嶅寘鍚彲杞摼鐨勫彛浠や笌閾炬帴");
                 }
@@ -978,7 +981,7 @@
         String content = commentInfo.getContent();
         if (!StringUtil.isNullOrEmpty(content) && commentInfo.getNeedSpin()) {
             try {
-                convertLinkManager.convertLinkFromText(content, Constant.LINK_TOKEN_VERIFY_UID, true);
+                convertLinkManager.convertLinkFromText(content, Constant.LINK_TOKEN_VERIFY_UID, true, false);
             } catch (ConvertLinkExceptionException e) {
                 if (ConvertLinkExceptionException.CODE_NONE != e.getCode()) {
                     throw new GoodsEvaluateException(1, "鍖呭惈涓嶅彲杞摼鐨勫彛浠や笌閾炬帴");
@@ -1638,7 +1641,7 @@
     }
 
     @Override
-    @Cacheable(value = "dynamicCache", key = "'queryMaterialsCache-'+#start+'-'+#type")
+    @Cacheable(value = "dynamicCache", key = "'queryMaterialsCache-'+#start+'-'+#type+'-'+#system")
     public List<GoodsEvaluate> queryMaterialsCache(int start, int count, int type, SystemEnum system) throws Exception {
         List<GoodsEvaluate> list = goodsEvaluateDao.queryValid(start, count, type, system);
         if (list == null) {
@@ -1701,7 +1704,7 @@
                                 List<String> activityIdList = convertLinkManager.getTaoBaoOfficialActivityId(content);
                                 for (String st : activityIdList)
                                     content = content.replace(st, "");
-
+                                content = content.replace("{relationId}", "");
                                 commentInfoNew.setContent(content);
                             }
                         }
@@ -1712,6 +1715,8 @@
                         List<String> activityIdList = convertLinkManager.getTaoBaoOfficialActivityId(content);
                         for (String st : activityIdList)
                             content = content.replace(st, "");
+                        content = content.replace("{relationId}", "");
+
                         commentInfoNew.setContent(content);
                     }
 
@@ -1821,9 +1826,10 @@
         try {
             Date now = new Date();
             SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
-            params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
+
             for (GoodsEvaluate goodsEvaluate : list) {
+                ConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", goodsEvaluate.getSystem());
+                params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(goodsEvaluate.getSystem()));
                 // 鏄惁2涓皬鏃朵箣鍐呭凡鏇存柊
                 Date updateTime = goodsEvaluate.getUpdateTime();
                 if (updateTime != null) {
@@ -1976,8 +1982,8 @@
         imgs.addAll(goodsBrief.getImgList());
 
         // 鍟嗗搧VO
-        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
-        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
+        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
+        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
         GoodsDetailVO goodsVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, paramsDTO);
 
         // 鍟嗗搧鍥剧墖淇℃伅
@@ -2076,6 +2082,7 @@
         goodsEvaluate.setLineNum(lineNum);
         goodsEvaluate.setImgList(imgList);
         goodsEvaluate.setComments(commentsNew);
+        goodsEvaluate.setSystem(system);
         goodsEvaluateDao.save(goodsEvaluate);
     }
 
@@ -2100,8 +2107,8 @@
         }
 
         // 鍟嗗搧VO
-        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
-        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
+        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
+        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
         GoodsDetailVO goodsVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, paramsDTO);
 
         // 鍟嗗搧鍥剧墖淇℃伅
@@ -2230,6 +2237,7 @@
         goodsEvaluate.setLineNum(lineNum);
         goodsEvaluate.setImgList(imgList);
         goodsEvaluate.setComments(commentsNew);
+        goodsEvaluate.setSystem(system);
         goodsEvaluateDao.save(goodsEvaluate);
         return result;
     }
@@ -2286,8 +2294,8 @@
                 return false;
             }
 
-            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
-            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
+            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
+            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
             GoodsDetailVO goodsVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, paramsDTO);
 
             ActivityUser user = null;
@@ -2347,6 +2355,7 @@
             goodsEvaluate.setPublishTime(new Date());
             goodsEvaluate.setCreateTime(new Date());
             goodsEvaluate.setUpdateTime(new Date());
+            goodsEvaluate.setSystem(system);
 
             List<String> goodsimgs = goodsBrief.getImgList();
 
@@ -2515,8 +2524,8 @@
                 if (queryExist == null || queryExist.size() == 0) {
                     continue;
                 }
-                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
-                paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
+                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
+                paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
                 GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO);
                 updateGoods(queryExist, goodsNew);
             }
@@ -2537,8 +2546,8 @@
                 continue;
             }
 
-            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
-            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
+            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
+            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
             GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO);
 
             updateGoods(queryExist, goodsNew);
@@ -2556,8 +2565,8 @@
                 continue;
             }
 
-            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
-            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
+            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
+            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
             GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertPDDGoods(pddGoods, paramsDTO);
             updateGoods(queryExist, goodsNew);
         }
@@ -2575,8 +2584,8 @@
                 continue;
             }
 
-            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
-            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
+            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
+            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
             GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertVIPGoods(goods, paramsDTO);
             updateGoods(queryExist, goodsNew);
         }
@@ -2593,18 +2602,18 @@
             if (queryExist == null || queryExist.size() == 0) {
                 continue;
             }
-
-            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
-            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
+            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system);
+            paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(system));
             GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertSuningGoods(goods, paramsDTO);
             updateGoods(queryExist, goodsNew);
         }
     }
 
     private void updateGoods(List<GoodsEvaluate> listExist, GoodsDetailVO goodsNew) {
-        String goodsId = goodsNew.getGoodsId();
-        int goodsType = goodsNew.getGoodsType();
         for (GoodsEvaluate goodsEvaluate : listExist) {
+            String goodsId = goodsNew.getGoodsId();
+            int goodsType = goodsNew.getGoodsType();
+
             GoodsDetailVO goodsDetailVO = goodsEvaluate.getGoods();
             if (goodsDetailVO != null && goodsDetailVO.getGoodsId() != null && goodsDetailVO.getGoodsId().equalsIgnoreCase(goodsId)
                     && goodsDetailVO.getGoodsType() == goodsType) {
@@ -2748,8 +2757,8 @@
 
 
     @Override
-    public GoodsEvaluate queryExistSingle(String goodsId, int goodsType,SystemEnum system) {
-        List<GoodsEvaluate> list = goodsEvaluateDao.queryExistSingle(goodsType, goodsId,system);
+    public GoodsEvaluate queryExistSingle(String goodsId, int goodsType, SystemEnum system) {
+        List<GoodsEvaluate> list = goodsEvaluateDao.queryExistSingle(goodsType, goodsId, system);
         if (list != null && list.size() > 0)
             return list.get(0);
         return null;

--
Gitblit v1.8.0