admin
2019-08-01 62d6c26176a6aaac033dfb9e26fb3f691ef19a0a
跳转拼多多原生APP兼容
3个文件已修改
113 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoUtil.java 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/goods/GoodsDetailExtraVO.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
@@ -17,6 +17,7 @@
import com.yeshi.fanli.dto.jd.JDCouponInfo;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
import com.yeshi.fanli.dto.pdd.PDDPromotionUrl;
import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.user.ShamUser;
@@ -583,8 +584,7 @@
        if (couponInfo != null) {
            // 券链接处理
            String materialId = "https://item.jd.com/" + id + ".html";
            String url = JDApiUtil.convertLink(materialId, couponInfo.getLink(), JDApiUtil.POSITION_COUPON + "",
                    null);
            String url = JDApiUtil.convertLink(materialId, couponInfo.getLink(), JDApiUtil.POSITION_COUPON + "", null);
            couponInfo.setLink(url);
        }
@@ -715,9 +715,11 @@
        BigDecimal shareRate = hongBaoManageService.getShareRate();
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, fanLiRate, shareRate);
        CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
        PDDPromotionUrl convertUrl = null;
        if (couponInfo != null) {
            String url = PinDuoDuoApiUtil.getPromotionUrl(id, PinDuoDuoApiUtil.PID_COUPON + "", null);
            couponInfo.setLink(url);
            convertUrl = PinDuoDuoApiUtil.convert(id, PinDuoDuoApiUtil.PID_COUPON + "", null);
            if (convertUrl != null)
                couponInfo.setLink(convertUrl.getShortUrl());
        }
        ShopInfoVO shopInfo = goodsDetail.getShopInfo();
@@ -776,12 +778,7 @@
            extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_PDD));
        }
        // 测试
        SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system,
                "goods_detail_jump_taobao");
        if ("1".equalsIgnoreCase((params.getValue() + "").trim())) {
            extraVO.setIsNative(true);
        }
        extraVO.setIsNative(true);
        // 分享路径
        String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
@@ -803,6 +800,11 @@
        ShareVO shareInfoVO = new ShareVO();
        shareInfoVO.setHelpLink(helpLink);
        extraVO.setShare(shareInfoVO);
        if (convertUrl != null) {
            extraVO.setCouponJumpLink(convertUrl.getShortUrl());
            extraVO.setNativeCouponJumpLink(PinDuoDuoUtil.getAndroidNativeURI(convertUrl.getUrl()));
        }
        JSONObject object = new JSONObject();
        object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
@@ -1060,10 +1062,11 @@
            return;
        }
        String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(id, PinDuoDuoApiUtil.PID_FANLI + "", uid + "");
        PDDPromotionUrl convertUrl = PinDuoDuoApiUtil.convert(id, PinDuoDuoApiUtil.PID_FANLI + "", uid + "");
        JSONObject data = new JSONObject();
        data.put("native", true);
        data.put("jumpLink", jumpLink);
        data.put("jumpLink", convertUrl.getShortUrl());
        data.put("nativeJumpLink", PinDuoDuoUtil.getAndroidNativeURI(convertUrl.getUrl()));
        out.print(JsonUtil.loadTrueResult(data));
    }
fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoUtil.java
@@ -87,8 +87,9 @@
    public static List<String> getDetailImages(Long id) {
        List<String> imgList = new ArrayList<>();
        try {
            Document doc = Jsoup.connect("http://yangkeduo.com/goods.html?goods_id=" + id).userAgent(
                    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36")
            Document doc = Jsoup.connect("http://yangkeduo.com/goods.html?goods_id=" + id)
                    .userAgent(
                            "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36")
                    .get();
            Elements els = doc.getElementsByTag("script");
            for (int i = 0; i < els.size(); i++) {
@@ -191,9 +192,9 @@
        return list;
    }
    /**
     * 多多进宝爬取数据-品牌好货
     *
     * @param sf
     * @return
     */
@@ -225,7 +226,7 @@
        }
        System.out.println(params.toString());
        HttpClient client = new HttpClient();
        PostMethod pm = new PostMethod("https://jinbao.pinduoduo.com/network/api/common/brand/goodsList");
        pm.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko");
@@ -239,7 +240,7 @@
            client.executeMethod(pm);
            String result = pm.getResponseBodyAsString();
            System.out.println(result);
            JSONObject json = JSONObject.fromObject(result);
            Boolean code = json.optBoolean("success");
            if (code != null && code) {
@@ -251,7 +252,7 @@
                if (array == null) {
                    return null;
                }
                List<PDDGoodsDetail> goodsList = new ArrayList<PDDGoodsDetail>();
                for (int i = 0; i < array.size(); i++) {
                    PDDGoodsDetail parseGoods = parseGoods(array.getJSONObject(i));
@@ -260,7 +261,7 @@
                    }
                }
                int totalCount = root.optInt("total");
                goodsResult = new PDDGoodsResult();
                goodsResult.setGoodsList(goodsList);
                goodsResult.setTotalCount(totalCount);
@@ -271,9 +272,7 @@
        return goodsResult;
    }
    private static PDDGoodsDetail parseGoods(JSONObject json) {
        PDDGoodsDetail goods = new PDDGoodsDetail();
        goods.setMallName(json.optString("mallName"));
@@ -282,59 +281,70 @@
        goods.setGoodsName(json.optString("goodsName"));
        goods.setGoodsDesc(json.optString("goodsDesc"));
        goods.setSalesTip(json.optString("salesTip"));
        if (json.optString("goodsImageUrl") != null) {
            goods.setGoodsImageUrl("http:" + json.optString("goodsImageUrl"));
        }
        if (json.optString("goodsThumbnailUrl") != null) {
            goods.setGoodsThumbnailUrl("http:" + json.optString("goodsThumbnailUrl"));
        }
        if (json.optString("minGroupPrice") != null) {
            goods.setMinGroupPrice(json.getLong("minGroupPrice")/10);
            goods.setMinGroupPrice(json.getLong("minGroupPrice") / 10);
        }
        if (json.optString("categoryId") != null) {
            goods.setCategoryId(json.getLong("categoryId"));
        }
        goods.setCategoryName(json.optString("categoryName"));
        goods.setHasCoupon(json.optBoolean("hasCoupon"));
        if (json.optString("couponMinOrderAmount") != null) {
            goods.setCouponMinOrderAmount(json.getLong("couponMinOrderAmount")/10);
            goods.setCouponMinOrderAmount(json.getLong("couponMinOrderAmount") / 10);
        }
        if (json.optString("couponDiscount") != null) {
            goods.setCouponDiscount(json.getLong("couponDiscount")/10);
            goods.setCouponDiscount(json.getLong("couponDiscount") / 10);
        }
        if (json.optString("couponTotalQuantity") != null) {
            goods.setCouponTotalQuantity(json.getLong("couponTotalQuantity"));
        }
        if (json.optString("couponRemainQuantity") != null) {
            goods.setCouponRemainQuantity(json.getLong("couponRemainQuantity"));
        }
        if (json.optString("couponStartTime") != null) {
            goods.setCouponStartTime(json.getLong("couponStartTime"));
        }
        if (json.optString("couponEndTime") != null) {
            goods.setCouponEndTime(json.getLong("couponEndTime"));
        }
        if (json.optString("promotionRate") != null) {
            goods.setPromotionRate(json.getLong("promotionRate"));
        }
        if (json.optString("optId") != null) {
            goods.setOptId(json.getLong("optId"));
        }
        return goods;
    }
    // 获取Android打开原生APP的uri
    public static String getAndroidNativeURI(String url) {
        if (url.contains("duo_coupon_landing.html?")) {
            int index = url.indexOf("duo_coupon_landing.html?");
            if (index >= 0) {
                return "pinduoduo://com.xunmeng.pinduoduo/" + url.substring(index, url.length());
            }
        }
        return null;
    }
}
fanli/src/main/java/com/yeshi/fanli/vo/goods/GoodsDetailExtraVO.java
@@ -67,6 +67,26 @@
    // 领取人
    @Expose
    private List<ShamUser> listCouponUser;
    @Expose
    private String couponJumpLink;//券跳转链接,拼多多专用
    @Expose
    private String nativeCouponJumpLink;//原生券跳转链接,拼多多专用
    public String getCouponJumpLink() {
        return couponJumpLink;
    }
    public void setCouponJumpLink(String couponJumpLink) {
        this.couponJumpLink = couponJumpLink;
    }
    public String getNativeCouponJumpLink() {
        return nativeCouponJumpLink;
    }
    public void setNativeCouponJumpLink(String nativeCouponJumpLink) {
        this.nativeCouponJumpLink = nativeCouponJumpLink;
    }
    public ClientTBPid getTbPidInfo() {
        return tbPidInfo;