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;
@@ -30,7 +34,7 @@
import org.yeshi.utils.taobao.TbImgUtil;
import com.google.gson.Gson;
import com.yeshi.fanli.dto.ConfigParamsDTO;
import com.yeshi.fanli.dto.GoodsMoneyConfigParamsDTO;
import com.yeshi.fanli.dto.jd.JDCategoryInfo;
import com.yeshi.fanli.dto.jd.JDCouponInfo;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
@@ -217,7 +221,16 @@
    @Resource
    private PDDAuthService pddAuthService;
    private ConfigParamsDTO getParamsDTO(String platform, String version, Long uid, SystemEnum system) {
    @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) {
            level = userLevelManager.getUserLevel(uid);
@@ -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,12 +458,12 @@
        // 大淘客商品过滤
        try {
            goods = filterDaTaoKeGoodsInfo(goods);
            goods = filterDaTaoKeGoodsInfo(acceptData.getSystem(), goods);
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid, acceptData.getSystem());
        GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid, acceptData.getSystem());
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem()));
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO);
@@ -722,7 +738,7 @@
        // 保存缓存
        jdGoodsCacheUtil.saveGoodsInfo(jdGoods);
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid, acceptData.getSystem());
        GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid, acceptData.getSystem());
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem()));
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO);
        if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
@@ -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) {
                }
            }
@@ -947,7 +965,7 @@
            return;
        }
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid, acceptData.getSystem());
        GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid, acceptData.getSystem());
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem()));
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, paramsDTO);
@@ -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());
        }
@@ -1154,7 +1172,7 @@
            return;
        }
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid, acceptData.getSystem());
        GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid, acceptData.getSystem());
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem()));
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertVIPGoods(vipGoodsInfo, paramsDTO);
@@ -1294,7 +1312,7 @@
            return;
        }
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid, acceptData.getSystem());
        GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid, acceptData.getSystem());
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem()));
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertSuningGoods(suningGoodsInfo, paramsDTO);
@@ -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;
        }
@@ -1500,12 +1518,8 @@
                    list = list.subList(0, 10);
                }
                ConfigParamsDTO 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));
                }
                GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), null, acceptData.getSystem());
                List<GoodsDetailVO> listDetailVO = goodsLijinMnager.loadOtherMoneyInfo(acceptData.getSystem(), uid, list, paramsDTO); //new ArrayList<GoodsDetailVO>();
                // 取偶数个数据
                if (listDetailVO.size() % 2 != 0) {
@@ -1541,11 +1555,9 @@
                                goodsList = goodsList.subList(0, 10);
                            }
                            ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(),
                            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);
                        }
                    }
                }
@@ -1587,13 +1599,9 @@
                List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
                if (resultList != null) {
                    if (resultList != null && resultList.size() > 0) {
                        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        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);
                    }
                }
@@ -1611,12 +1619,9 @@
            }
            List<GoodsDetailVO> listExtra = new ArrayList<GoodsDetailVO>();
            ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), null, acceptData.getSystem());
            goodsList.parallelStream().forEach(goods -> {
                if (goods != null) {
                    listExtra.add(GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO));
                }
            });
            GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), null, acceptData.getSystem());
            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));
@@ -2121,7 +2136,7 @@
        Map<String, GoodsDetailVO> tempGoodsList = new HashMap<>();
        ConfigParamsDTO params = new ConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()),
        GoodsMoneyConfigParamsDTO params = new GoodsMoneyConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()),
                hongBaoManageService.getShareRate(acceptData.getSystem()), new BigDecimal(80),
                hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP, acceptData.getSystem()));
@@ -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();