From af66f9797b42ae81f831d1fbf91a59463a569956 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 17 十一月 2022 19:29:36 +0800
Subject: [PATCH] 拼多多接口修改

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java |  255 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 241 insertions(+), 14 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
index 3c2b107..dff923a 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
@@ -3,7 +3,6 @@
 import java.io.PrintWriter;
 import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
-import java.net.URLDecoder;
 import java.net.URLEncoder;
 import java.util.*;
 
@@ -21,6 +20,9 @@
 import com.yeshi.fanli.service.manger.PIDManager;
 import com.yeshi.fanli.util.*;
 import com.yeshi.fanli.util.goods.GoodsJumpUtil;
+import com.yeshi.fanli.util.goods.douyin.CSJCPSApiUtil;
+import com.yeshi.fanli.util.goods.douyin.DYUtil;
+import com.yeshi.fanli.util.goods.douyin.vo.*;
 import com.yeshi.fanli.vo.common.WXXCXJumpInfoVO;
 import com.yeshi.fanli.vo.pdd.PDDConvertLinkResultVO;
 import com.yeshi.fanli.vo.goods.GoodsJumpLinkVO;
@@ -269,7 +271,7 @@
                     // result.getGoods().setCouponLink(link);
                     return result.getGoods();
                 } else {
-                    link = DaTaoKeApiUtil.convertLink(goods.getAuctionId(), dpid,false);
+                    link = DaTaoKeApiUtil.convertLink(goods.getAuctionId(), dpid, false);
                     if (!StringUtil.isNullOrEmpty(link)) {
                         // result.getGoods().setCouponLink(link);
                         taoBaoGoodsCacheUtil.cacheBaseConvertLink(goods.getAuctionId(), dpid, link);
@@ -751,7 +753,7 @@
             return;
         }
 
-        JDGoods jdGoods = JDApiUtil.queryGoodsDetail( id); // 楂樼骇鎺ュ彛
+        JDGoods jdGoods = JDApiUtil.queryGoodsDetail(id); // 楂樼骇鎺ュ彛
         if (jdGoods == null) {
             jdGoods = JDUtil.getGoodsDetail(id); // 鐖彇缃戦〉
             // jdGoods = JDApiUtil.getGoodsDetail(id); // 鏅�氭帴鍙�
@@ -899,11 +901,11 @@
 
         if (uid != null) {
             // 鏄惁鍔犲叆鏀惰棌
-            CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid,  id+"",
+            CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id + "",
                     Constant.SOURCE_TYPE_JD);
             extraVO.setCollected(collectionGoods != null ? true : false);
             // 鏄惁鍔犲叆閫夊搧搴�
-            extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id+"", Constant.SOURCE_TYPE_JD));
+            extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id + "", Constant.SOURCE_TYPE_JD));
         }
 
         // 鍥炬枃璇︽儏
@@ -1103,11 +1105,11 @@
 
         if (uid != null) {
             // 鏄惁鍔犲叆鏀惰棌
-            CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id+"",
+            CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id + "",
                     Constant.SOURCE_TYPE_PDD);
             extraVO.setCollected(collectionGoods != null ? true : false);
             // 鏄惁鍔犲叆閫夊搧搴�
-            extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id+"", Constant.SOURCE_TYPE_PDD));
+            extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id + "", Constant.SOURCE_TYPE_PDD));
         }
 
         extraVO.setIsNative(true);
@@ -1267,11 +1269,11 @@
 
         if (uid != null) {
             // 鏄惁鍔犲叆鏀惰棌
-            CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id+"",
+            CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id + "",
                     Constant.SOURCE_TYPE_VIP);
             extraVO.setCollected(collectionGoods != null ? true : false);
             // 鏄惁鍔犲叆閫夊搧搴�
-            extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id+"", Constant.SOURCE_TYPE_VIP));
+            extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id + "", Constant.SOURCE_TYPE_VIP));
         }
 
         extraVO.setIsNative(true);
@@ -1408,11 +1410,11 @@
         if (uid != null) {
             // 鏄惁鍔犲叆鏀惰棌
             CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid,
-                   (suningGoodsInfo.getCommodityInfo().getCommodityCode()), Constant.SOURCE_TYPE_SUNING);
+                    (suningGoodsInfo.getCommodityInfo().getCommodityCode()), Constant.SOURCE_TYPE_SUNING);
             extraVO.setCollected(collectionGoods != null ? true : false);
             // 鏄惁鍔犲叆閫夊搧搴�
             extraVO.setStorage(userGoodsStorageService.isExistStorage(uid,
-                 (suningGoodsInfo.getCommodityInfo().getCommodityCode()),
+                    (suningGoodsInfo.getCommodityInfo().getCommodityCode()),
                     Constant.SOURCE_TYPE_SUNING));
         }
 
@@ -1472,6 +1474,145 @@
             }
         });
     }
+
+
+    @RequestMapping(value = "getDetailDY", method = RequestMethod.POST)
+    public void getDetailDY(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
+        // 绯荤粺楠岃瘉
+        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+                acceptData.getPackages(), acceptData.getSystem());
+        if (system == null) {
+            out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�"));
+            return;
+        }
+
+        DYGoodsDetail dyGoodsDetail = CSJCPSApiUtil.goodsDetail(id);
+        if (dyGoodsDetail == null) {
+            out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧涓嶅瓨鍦�"));
+            return;
+        }
+
+        GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid, acceptData.getSystem());
+        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem()));
+
+        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertDYGoods(dyGoodsDetail, paramsDTO);
+        if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
+            goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
+            goodsDetail.getMoneyInfo().setShareMoney("楼" + DYUtil.getGoodsFanLiMoney(dyGoodsDetail,
+                    hongBaoManageService.getShareRate(UserLevelEnum.superVIP, acceptData.getSystem())));
+            goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
+            goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
+        }
+        goodsDetail.getMoneyInfo()
+                .setRateInfoHelpUrl(configService.getValue(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey(), acceptData.getSystem()));
+
+        // 闄勫姞淇℃伅
+        OtherInfo otherInfo = new OtherInfo();
+        RewardCouponVO rewardCoupon = new RewardCouponVO();
+        rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web", acceptData.getSystem()));
+        JSONObject params1 = new JSONObject();
+        if (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
+            params1.put("url", configService.getValue(ConfigKeyEnum.specialGuideRewardCouponLink.getKey(), acceptData.getSystem()));
+        else
+            params1.put("url", userVipConfigService.getValueByKey("vip_link"));
+
+        rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney());
+        rewardCoupon.setDesc("杩�");
+        params1.put("url", userVipConfigService.getValueByKey("vip_link"));
+        rewardCoupon.getJumpDetail().setNeedLogin(true);
+
+        rewardCoupon.setParams(params1.toString());
+        otherInfo.setRewardCoupon(rewardCoupon);
+        if ("ios".equalsIgnoreCase(acceptData.getPlatform())
+                && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem()))
+            otherInfo.setRewardCoupon(null);
+        goodsDetail.setOtherInfo(otherInfo);
+
+        ShopInfoVO shopInfo = goodsDetail.getShopInfo();
+        if (shopInfo != null) {
+            if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
+                    || shopInfo.getScoreSeller() == null) {
+                goodsDetail.setShopInfo(null);
+            }
+        }
+
+        GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
+        extraVO.setIsNative(false);
+        // IOS鏄惁姝e湪涓婄嚎
+        if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
+            String version = acceptData.getVersion();
+            extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version), acceptData.getSystem()));
+        }
+
+        // TODO 鍥炬枃璇︽儏
+        extraVO.setDetailUrl("");
+
+        if (uid != null) {
+            // 鏄惁鍔犲叆鏀惰棌
+            CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id + "",
+                    Constant.SOURCE_TYPE_DY);
+            extraVO.setCollected(collectionGoods != null ? true : false);
+            // 鏄惁鍔犲叆閫夊搧搴�
+            extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id + "", Constant.SOURCE_TYPE_DY));
+        }
+
+        extraVO.setIsNative(true);
+
+        // 鍒嗕韩璺緞
+        String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(acceptData.getSystem()),
+                Constant.systemCommonConfig.getShareGoodsPagePathPDD(), "", id + "");
+        // try {
+        // extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
+        // } catch (Exception e) {
+        extraVO.setH5Url(h5Url);
+        // }
+
+        String helpLink = null;
+        extraVO.setFanliValid(true);
+        extraVO.setShareValid(true);
+
+        if (StringUtil.isNullOrEmpty(helpLink)) {
+            helpLink = configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(), acceptData.getSystem());
+        }
+
+        ShareVO shareInfoVO = new ShareVO();
+        shareInfoVO.setHelpLink(helpLink);
+        extraVO.setShare(shareInfoVO);
+
+        if (extraVO.getListShareUser() == null) {
+            extraVO.setListShareUser(new ArrayList<>());
+        }
+
+        if (extraVO.getListCouponUser() == null) {
+            extraVO.setListCouponUser(new ArrayList<>());
+        }
+
+        // 浜戝彂鍗曟枃妗堜俊鎭�
+        getCloudInfo(acceptData, uid, goodsDetail, extraVO);
+
+        JSONObject object = new JSONObject();
+        object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
+        object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail));
+        out.print(JsonUtil.loadTrueResult(object.toString()));
+
+        ThreadUtil.run(new Runnable() {
+            public void run() {
+                // 娣诲姞娴忚璁板綍
+                try {
+                    scanHistoryV2Service.addDYScanHistory(uid, acceptData.getDevice(), dyGoodsDetail);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+
+                try {
+                    goodsEvaluateService.updateDYGoods(dyGoodsDetail);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        });
+    }
+
 
     /**
      * // 浜戝彂鍗曟枃妗堜俊鎭�
@@ -1554,7 +1695,7 @@
 
                 List<JDGoods> list = JDUtil.getRecommendGoodsById(Long.parseLong(id));
                 if (list == null) {
-                    list = new ArrayList<JDGoods>();
+                    list = new ArrayList<>();
                 } else if (list.size() > 10) {
                     list = list.subList(0, 10);
                 }
@@ -1653,13 +1794,45 @@
                 return;
             }
 
+            if (goodsType == Constant.SOURCE_TYPE_DY) {
+                DYGoodsDetail goods = CSJCPSApiUtil.goodsDetail(Long.parseLong(id));
+                //goods.getThird_cid()
+                DYGoodsSearchFilter searchFilter = new DYGoodsSearchFilter();
+                searchFilter.setPageSize(10);
+                searchFilter.setPage(1);
+                searchFilter.setThird_cids(Arrays.asList(new Integer[]{goods.getThird_cid()}));
+                ListResult listResult = CSJCPSApiUtil.searchGoods(searchFilter);
+
+
+
+                List<GoodsDetailVO> listDetailVO = new ArrayList<>();
+                if (listResult != null) {
+                    if (listResult.getDataList() != null && listResult.getDataList() .size() > 0) {
+                        List<DYGoods> dyGoodsList=new ArrayList<>();
+                        for(Object o:listResult.getDataList()){
+                            dyGoodsList.add((DYGoods)o);
+                        }
+
+                        GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
+                                acceptData.getVersion(), acceptData.getSystem());
+                        listDetailVO = goodsLijinMnager.loadOtherMoneyInfo(acceptData.getSystem(), uid, dyGoodsList, paramsDTO);
+                    }
+                }
+
+                JSONObject data = new JSONObject();
+                data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
+                data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
+                out.print(JsonUtil.loadTrueResult(data));
+                return;
+            }
+
             List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(id, 10);
             // 鍒濆鍖�
             if (goodsList == null) {
                 goodsList = new ArrayList<>();
             }
 
-            List<GoodsDetailVO> listExtra = new ArrayList<GoodsDetailVO>();
+            List<GoodsDetailVO> listExtra = new ArrayList<>();
             GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), null, acceptData.getSystem());
 
             listExtra = goodsLijinMnager.loadTBMoneyInfo(acceptData.getSystem(), uid, goodsList, paramsDTO, false);
@@ -2088,6 +2261,60 @@
         integralGetService.addCouponRebate(uid);
     }
 
+
+    @RequestMapping(value = "getDYLink")
+    public void getDYLink(AcceptData acceptData, Long uid, String id, String source, PrintWriter out) {
+        if (StringUtil.isNullOrEmpty(id)) {
+            out.print(JsonUtil.loadFalseResult(1, "鍟嗗搧ID涓嶈兘涓虹┖"));
+            return;
+        }
+
+        if (!SystemInfoUtil.hasFunctions(acceptData.getSystem(), SystemFunction.fanli)) {
+            uid = null;
+        } else {
+            if (uid == null) {
+                uid = null;
+            } else {
+                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;
+                }
+
+                if (userFunctionsLimitService.isLimit(uid, SystemFunction.fanli, new Date())) {
+                    out.print(JsonUtil.loadFalseResult(1, "璇ュ姛鑳介檺鍒朵娇鐢�"));
+                    return;
+                }
+            }
+        }
+
+
+        DYGoodsDetail goods = CSJCPSApiUtil.goodsDetail(Long.parseLong(id));
+        if (goods == null) {
+            out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧宸蹭笅鏋�"));
+            return;
+        }
+
+        DYConvertResult link = CSJCPSApiUtil.goodsConvert(goods.getDetail_url(), DYUtil.createFanLiExtraInfo(uid),
+                "");
+
+        GoodsJumpLinkVO vo = GoodsJumpUtil.getDYJumpInfo(link);
+
+        JSONObject data = JSONObject.fromObject(new Gson().toJson(vo));
+        data.put("native", vo.is_native());
+        if (uid != null)
+            data.put("userLevel", userLijinMnager.getUserLevelInfo(uid, acceptData.getSystem()));
+        out.print(JsonUtil.loadTrueResult(data));
+
+
+        // 鑾峰緱閲戝竵
+        integralGetService.addCouponRebate(uid);
+    }
+
     /**
      * 鏄惁鍦ㄥ弬涓庢帹骞�
      *
@@ -2195,7 +2422,7 @@
             if (cg.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
                 tbGoodsList.add(cg.getGoodsId());
             } else if (cg.getGoodsType() == Constant.SOURCE_TYPE_JD) {
-                jdGoodsList.add(Long.parseLong( cg.getGoodsId()));
+                jdGoodsList.add(Long.parseLong(cg.getGoodsId()));
             } else if (cg.getGoodsType() == Constant.SOURCE_TYPE_PDD) {
                 pddGoodsList.add(Long.parseLong(cg.getGoodsId()));
             }

--
Gitblit v1.8.0