admin
2021-05-29 e75b0d79535a6bcd147cca4a54632b70b42afdb9
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
@@ -14,9 +14,13 @@
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.entity.SystemFunction;
import com.yeshi.fanli.entity.SystemPIDInfo;
import com.yeshi.fanli.exception.pdd.PDDApiException;
import com.yeshi.fanli.lijin.manager.GoodsLijinMnager;
import com.yeshi.fanli.lijin.manager.UserLijinMnager;
import com.yeshi.fanli.service.inter.pdd.PDDAuthService;
import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
import com.yeshi.fanli.service.manger.PIDManager;
import com.yeshi.fanli.util.*;
import com.yeshi.fanli.vo.common.WXXCXJumpInfoVO;
import com.yeshi.fanli.vo.pdd.PDDConvertLinkResultVO;
@@ -217,6 +221,15 @@
    @Resource
    private PDDAuthService pddAuthService;
    @Resource
    private GoodsLijinMnager goodsLijinMnager;
    @Resource
    private PIDManager pidManager;
    @Resource
    private UserLijinMnager userLijinMnager;
    private GoodsMoneyConfigParamsDTO getParamsDTO(String platform, String version, Long uid, SystemEnum system) {
        UserLevelEnum level = UserLevelEnum.daRen;
        if (uid != null && uid > 0) {
@@ -232,7 +245,10 @@
        return orderHongBaoMoneyComputeService.getShowComputeRate(platform, version, level, system);
    }
    private TaoBaoGoodsBrief filterDaTaoKeGoodsInfo(TaoBaoGoodsBrief goods) {
    private TaoBaoGoodsBrief filterDaTaoKeGoodsInfo(SystemEnum system, TaoBaoGoodsBrief goods) {
        String specialPid = pidManager.getPidCache(system, Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.fanli);
        String relationPid = pidManager.getPidCache(system, Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.fanliChannel);
        try {
            DaTaoKeFilterResult result = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(goods);
            if (result.getFilterType() == DaTaoKeFilterResult.FILTER_TYPE_COUPON
@@ -240,9 +256,9 @@
                // 缓存基础链接
                String dpid = null;
                if (TaoBaoUtil.isSpecialGoods(goods.getMaterialLibType())) {
                    dpid = TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT;
                    dpid = specialPid;
                } else {
                    dpid = TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID;
                    dpid = relationPid;
                }
                String link = taoBaoGoodsCacheUtil.getBaseConvertLink(goods.getAuctionId(), dpid);
                if (!StringUtil.isNullOrEmpty(link)) {
@@ -411,7 +427,7 @@
        if (uid != null && uid > 0) {
            String specialId = userExtraTaoBaoInfoService.getSpecialIdByUid(uid);
            //获取最新的比例
            TaoBaoGoodsBrief rateGoods = TaoKeApiUtil.specialConvertCoupon(tb.getAuctionId(), TaoBaoConstant.getSpecialAuthAppInfo(), specialId, null);
            TaoBaoGoodsBrief rateGoods = TaoKeApiUtil.specialConvertCoupon(tb.getAuctionId(), TaoBaoConstant.getSpecialAuthAppInfo(pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.fanli)), specialId, null);
            if (rateGoods != null)
                tb.setMinTkRate(rateGoods.getTkRate());
        }
@@ -442,7 +458,7 @@
        // 大淘客商品过滤
        try {
            goods = filterDaTaoKeGoodsInfo(goods);
            goods = filterDaTaoKeGoodsInfo(acceptData.getSystem(), goods);
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
@@ -798,7 +814,7 @@
            // 券链接处理
            String materialId = "https://item.jd.com/" + id + ".html";
            String url = JDApiUtil.convertLinkWithSubUnionId(materialId, couponInfo.getLink(), null,
                    JDApiUtil.POSITION_COUPON + "", null);
                    pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.coupon), null);
            couponInfo.setLink(url);
        }
@@ -930,14 +946,16 @@
            return;
        }
        String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.fanli);
        PDDGoodsDetail pddGoods = null;
        try {
            pddGoods = PinDuoDuoApiUtil.getGoodsDetail(id, PinDuoDuoApiUtil.PID_FANLI, pddAuthService.getFanliCustomParams(uid));
            pddGoods = PinDuoDuoApiUtil.getGoodsDetail(id, pid, pddAuthService.getFanliCustomParams(uid));
        } catch (PDDApiException e) {
            e.printStackTrace();
            if (e.getCode() == PDDApiException.CODE_NOT_AUTH) {
                try {
                    pddGoods = PinDuoDuoApiUtil.getGoodsDetail(id, PinDuoDuoApiUtil.PID_FANLI, Constant.PDD_SEARCH_CUSTOMER_PARAMS);
                    pddGoods = PinDuoDuoApiUtil.getGoodsDetail(id, pid, Constant.PDD_SEARCH_CUSTOMER_PARAMS);
                } catch (PDDApiException e1) {
                }
            }
@@ -988,7 +1006,7 @@
        CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
        PDDConvertLinkResultVO convertUrl = null;
        if (couponInfo != null) {
            convertUrl = PinDuoDuoApiUtil.convert(pddGoods.getGoodsSign(), PinDuoDuoApiUtil.PID_COUPON + "", null, false);
            convertUrl = PinDuoDuoApiUtil.convert(pddGoods.getGoodsSign(), pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.coupon), null, false);
            if (convertUrl != null)
                couponInfo.setLink(convertUrl.getUrl());
        }
@@ -1482,7 +1500,7 @@
     * @param out
     */
    @RequestMapping(value = "getRecommendGoods", method = RequestMethod.POST)
    public void getRecommendGoods(AcceptData acceptData, String id, Integer goodsType, PrintWriter out) {
    public void getRecommendGoods(AcceptData acceptData, String id, Long uid, Integer goodsType, PrintWriter out) {
        if (goodsType == null) {
            goodsType = Constant.SOURCE_TYPE_TAOBAO;
        }
@@ -1501,11 +1519,7 @@
                }
                GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), null, acceptData.getSystem());
                List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
                for (JDGoods goods : list) {
                    listDetailVO.add(GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO));
                }
                List<GoodsDetailVO> listDetailVO = goodsLijinMnager.loadOtherMoneyInfo(acceptData.getSystem(), uid, list, paramsDTO); //new ArrayList<GoodsDetailVO>();
                // 取偶数个数据
                if (listDetailVO.size() % 2 != 0) {
@@ -1543,9 +1557,7 @@
                            GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(),
                                    null, acceptData.getSystem());
                            for (PDDGoodsDetail goods : goodsList) {
                                listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO));
                            }
                            listDetailVO = goodsLijinMnager.loadOtherMoneyInfo(acceptData.getSystem(), uid, goodsList, paramsDTO);
                        }
                    }
                }
@@ -1589,11 +1601,7 @@
                    if (resultList != null && resultList.size() > 0) {
                        GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                                acceptData.getVersion(), acceptData.getSystem());
                        for (SuningGoodsInfo goods : resultList) {
                            GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertSuningGoods(goods, paramsDTO);
                            listDetailVO.add(goodsDetailVO);
                        }
                        listDetailVO = goodsLijinMnager.loadOtherMoneyInfo(acceptData.getSystem(), uid, resultList, paramsDTO);
                    }
                }
@@ -1612,11 +1620,8 @@
            List<GoodsDetailVO> listExtra = new ArrayList<GoodsDetailVO>();
            GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), null, acceptData.getSystem());
            goodsList.parallelStream().forEach(goods -> {
                if (goods != null) {
                    listExtra.add(GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO));
                }
            });
            listExtra = goodsLijinMnager.loadTBMoneyInfo(acceptData.getSystem(), uid, goodsList, paramsDTO);
            List<GoodsDetailVO> listQuality = new ArrayList<GoodsDetailVO>();
            // 取偶数个数据
@@ -1659,19 +1664,22 @@
        }
        String jumpLink = null;
        String materialId = "https://item.jd.com/" + id + ".html";
        String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.coupon);
        if (StringUtil.isNullOrEmpty(couponUrl)) {
            JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(goods.getCouponInfoList(), goods.getPrice());
            if (couponInfo != null) {
                couponUrl = couponInfo.getLink();
            }
            jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, JDApiUtil.POSITION_COUPON + "",
            jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pid,
                    "");
            if (jumpLink == null) {
                jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null, JDApiUtil.POSITION_COUPON + "",
                jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null, pid,
                        "");
            }
        } else {
            jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, JDApiUtil.POSITION_COUPON + "",
            jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pid,
                    "");
            if (StringUtil.isNullOrEmpty(jumpLink)) {
                jumpLink = couponUrl;
@@ -1740,19 +1748,22 @@
        String jumpLink = null;
        String materialId = "https://item.jd.com/" + id + ".html";
        String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.fanli);
        if (StringUtil.isNullOrEmpty(couponUrl)) {
            JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(goods.getCouponInfoList(), goods.getPrice());
            if (couponInfo != null) {
                couponUrl = couponInfo.getLink();
            }
            jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, JDApiUtil.POSITION_FANLI + "",
            jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pid,
                    uid + "");
            if (jumpLink == null) {
                jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null, JDApiUtil.POSITION_FANLI + "",
                jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null, pid,
                        uid + "");
            }
        } else {
            jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, JDApiUtil.POSITION_FANLI + "",
            jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pid,
                    uid + "");
            if (StringUtil.isNullOrEmpty(jumpLink)) {
                jumpLink = couponUrl;
@@ -1775,6 +1786,7 @@
        }
        JSONObject data = JSONObject.fromObject(new Gson().toJson(vo));
        data.put("native", vo.is_native());
        data.put("userLevel", userLijinMnager.getUserLevelInfo(uid, acceptData.getSystem()));
        out.print(JsonUtil.loadTrueResult(data));
        // 获得金币
@@ -1795,7 +1807,7 @@
        String jumpLink = null;
        String materialId = "https://item.jd.com/" + id + ".html";
        jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, JDApiUtil.POSITION_FANLI + "", null);
        jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.fanli), null);
        if (StringUtil.isNullOrEmpty(jumpLink)) {
            jumpLink = couponUrl;
        }
@@ -1823,10 +1835,10 @@
            return;
        }
        String pid = PinDuoDuoApiUtil.PID_FANLI;
        String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.fanli);
        //只是领券
        if (!SystemInfoUtil.hasFunctions(acceptData.getSystem(), SystemFunction.fanli)) {
            pid = PinDuoDuoApiUtil.PID_COUPON;
            pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.coupon);
            uid = null;
        } else {
            if (uid == null || uid <= 0) {
@@ -1872,6 +1884,7 @@
        }
        data = JSONObject.fromObject(new Gson().toJson(vo));
        data.put("native", vo.is_native());
        data.put("userLevel", userLijinMnager.getUserLevelInfo(uid, acceptData.getSystem()));
        out.print(JsonUtil.loadTrueResult(data));
        // 获得金币
@@ -1934,6 +1947,7 @@
        JSONObject data = JSONObject.fromObject(new Gson().toJson(vo));
        data.put("native", vo.is_native());
        data.put("userLevel", userLijinMnager.getUserLevelInfo(uid, acceptData.getSystem()));
        out.print(JsonUtil.loadTrueResult(data));
        // 获得金币
        integralGetService.addCouponRebate(uid);
@@ -1946,9 +1960,9 @@
            return;
        }
        String pid = SuningApiUtil.PID_BUY;
        String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_SUNING, SystemPIDInfo.PidType.fanli);
        if (!SystemInfoUtil.hasFunctions(acceptData.getSystem(), SystemFunction.fanli)) {
            pid = SuningApiUtil.PID_COUPON;
            pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_SUNING, SystemPIDInfo.PidType.coupon);
            uid = null;
        } else {
            if (uid == null || uid <= 0) {
@@ -1999,6 +2013,7 @@
        JSONObject data = JSONObject.fromObject(new Gson().toJson(vo));
        data.put("native", vo.is_native());
        data.put("userLevel", userLijinMnager.getUserLevelInfo(uid, acceptData.getSystem()));
        out.print(JsonUtil.loadTrueResult(data));
@@ -2184,7 +2199,7 @@
            return;
        }
        link = JDApiUtil.convertLinkWithSubUnionId(link, null, null, JDApiUtil.POSITION_FANLI + "", uid + "");
        link = JDApiUtil.convertLinkWithSubUnionId(link, null, null, pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.fanli), uid + "");
        GoodsJumpLinkVO vo = new GoodsJumpLinkVO();