From 3727469752a977dde6327e2c48d761b20b565d3d Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 15 七月 2022 09:19:21 +0800 Subject: [PATCH] 商品ID字符串化 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java | 425 +++++++++++++++++++++++++++++++++------------------- 1 files changed, 270 insertions(+), 155 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 69dffdf..ba6981f 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 @@ -5,25 +5,30 @@ import java.math.BigDecimal; import java.net.URLDecoder; import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import javax.annotation.Resource; 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.*; 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.util.goods.GoodsJumpUtil; import com.yeshi.fanli.vo.common.WXXCXJumpInfoVO; import com.yeshi.fanli.vo.pdd.PDDConvertLinkResultVO; import com.yeshi.fanli.vo.goods.GoodsJumpLinkVO; import com.yeshi.fanli.vo.suning.SuningConvertLinkResult; +import com.yeshi.goods.facade.dto.taobao.TaoBaoGoodsImportantInfo; import org.json.simple.JSONArray; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -84,10 +89,6 @@ import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService; import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService; import com.yeshi.goods.facade.service.DaTaoKeGoodsDetailV2Service; -import com.yeshi.fanli.service.inter.user.ShamUserService; -import com.yeshi.fanli.service.inter.user.TBPidService; -import com.yeshi.fanli.service.inter.user.UserGoodsStorageService; -import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.service.inter.user.integral.IntegralGetService; import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService; import com.yeshi.fanli.service.inter.user.vip.UserVipConfigService; @@ -128,6 +129,9 @@ @Controller @RequestMapping("api/v2/goods") public class GoodsControllerV2 { + + + Logger logger = LoggerFactory.getLogger(GoodsControllerV2.class); @Resource private BusinessSystemService businessSystemService; @@ -221,6 +225,15 @@ @Resource private GoodsLijinMnager goodsLijinMnager; + @Resource + private PIDManager pidManager; + + @Resource + private UserLijinMnager userLijinMnager; + + @Resource + private UserFunctionsLimitService userFunctionsLimitService; + private GoodsMoneyConfigParamsDTO getParamsDTO(String platform, String version, Long uid, SystemEnum system) { UserLevelEnum level = UserLevelEnum.daRen; if (uid != null && uid > 0) { @@ -236,7 +249,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 @@ -244,9 +260,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)) { @@ -278,11 +294,13 @@ * @param out */ @RequestMapping(value = "getDetailTB", method = RequestMethod.POST) - public void getDetialTB(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) { + public void getDetialTB(AcceptData acceptData, String id, Long uid, String from, PrintWriter out) { if (id == null) { out.print(JsonUtil.loadFalseResult(1, "鍟嗗搧id涓嶈兘涓虹┖")); return; } + + logger.debug("鑾峰彇鍟嗗搧璇︽儏-寮�濮嬶細{}", id + ""); BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages(), acceptData.getSystem()); @@ -321,6 +339,7 @@ TaoBaoGoodsBrief goods = null; if (!convertInServer) { + logger.debug("鑾峰彇鍟嗗搧璇︽儏-涓嶅湪鏈嶅姟绔浆閾撅細{}", id + ""); try { goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(id); if (goods == null) { @@ -399,7 +418,12 @@ }); } + logger.debug("鑾峰彇鍟嗗搧璇︽儏-鑾峰彇鍟嗗搧璇︽儏鎴愬姛锛歿}", id + ""); + TaoBaoGoodsBrief tb = goods; + + //鍒涘缓鏃堕棿璁剧疆涓虹┖锛岄槻姝㈠墠绔敤long瑙f瀽 + tb.setCreatetime(null); if (tb == null) { @@ -415,7 +439,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()); } @@ -444,15 +468,21 @@ tb.setImgList(finalImgList); + logger.debug("鑾峰彇鍟嗗搧璇︽儏-寮�濮嬪ぇ娣樺鍟嗗搧杩囨护锛歿}", id + ""); + // 澶ф窐瀹㈠晢鍝佽繃婊� try { - goods = filterDaTaoKeGoodsInfo(goods); + goods = filterDaTaoKeGoodsInfo(acceptData.getSystem(), goods); } catch (Exception e) { LogHelper.errorDetailInfo(e); } + logger.debug("鑾峰彇鍟嗗搧璇︽儏-缁撴潫澶ф窐瀹㈠晢鍝佽繃婊わ細{}", id + ""); + GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid, acceptData.getSystem()); paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem())); + + logger.debug("鑾峰彇鍟嗗搧璇︽儏-鑾峰彇鍒拌繑鍒╂瘮渚嬶細{}", id + ""); GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO); if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) { @@ -483,6 +513,8 @@ } goodsDetail.setShopInfo(ShopInfoVOFactory.convertTaoBaoShop(shop)); } + logger.debug("鑾峰彇鍟嗗搧璇︽儏-鑾峰彇搴楅摵淇℃伅缁撴潫锛歿}", id + ""); + // 鍏嶅崟鍟嗗搧 if (!StringUtil.isNullOrEmpty(from) && "miandan".equals(from)) { @@ -510,6 +542,8 @@ } extraVO.setListShareUser(listShareUser); + logger.debug("鑾峰彇鍟嗗搧璇︽儏-鍒嗕韩璧氫汉鎻愮ず缁撴潫锛歿}", id + ""); + // 棰嗗埜浜哄垪琛� List<ShamUser> listCouponUser = new ArrayList<ShamUser>(); if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && goods.getCouponAmount() != null @@ -520,13 +554,17 @@ } extraVO.setListCouponUser(listCouponUser); + logger.debug("鑾峰彇鍟嗗搧璇︽儏- 棰嗗埜浜哄垪琛ㄧ粨鏉燂細{}", id + ""); + if (uid != null) { // 鏄惁鍔犲叆鏀惰棌 CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id, Constant.SOURCE_TYPE_TAOBAO); extraVO.setCollected(collectionGoods != null ? true : false); + logger.debug("鑾峰彇鍟嗗搧璇︽儏- 鏀惰棌缁撴潫锛歿}", id + ""); // 鏄惁鍔犲叆閫夊搧搴� extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_TAOBAO)); + logger.debug("鑾峰彇鍟嗗搧璇︽儏- 閫夊搧搴撶粨鏉燂細{}", id + ""); } // 娴嬭瘯 @@ -614,9 +652,10 @@ goodsDetail.setLabels(labels); } else {// 鏅�氳喘涔� + logger.debug("鑾峰彇鍟嗗搧璇︽儏- 濂栧姳鍒稿紑濮嬶細{}", id + ""); OtherInfo otherInfo = new OtherInfo(); RewardCouponVO rewardCoupon = new RewardCouponVO(); - rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web")); + 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())); @@ -632,6 +671,7 @@ rewardCoupon.setParams(params1.toString()); otherInfo.setRewardCoupon(rewardCoupon); + logger.debug("鑾峰彇鍟嗗搧璇︽儏- 濂栧姳鍒哥粨鏉燂細{}", id + ""); if ("ios".equalsIgnoreCase(acceptData.getPlatform()) && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem())) otherInfo.setRewardCoupon(null); @@ -663,15 +703,20 @@ goodsDetail.setCouponInfoList(couponInfoList); } + logger.debug("鑾峰彇鍟嗗搧璇︽儏- 鍒嗕韩淇℃伅缁撴潫锛歿}", id + ""); - if (VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) { - getCloudInfo(acceptData, uid, goodsDetail, extraVO); // 浜戝彂鍗曟枃妗堜俊鎭� - } +//浜戝彂鍗曞叧闂� +// if (VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) { +// getCloudInfo(acceptData, uid, goodsDetail, extraVO); // 浜戝彂鍗曟枃妗堜俊鎭� +// logger.debug("鑾峰彇鍟嗗搧璇︽儏- 浜戝彂鍗曟枃妗堢粨鏉燂細{}", id + ""); +// } JSONObject object = new JSONObject(); object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO)); object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail)); out.print(JsonUtil.loadTrueResult(object.toString())); + + logger.debug("鑾峰彇鍟嗗搧璇︽儏-璇︽儏缁撴潫锛歿}", id + ""); final TaoBaoGoodsBrief goodsInfo = tb; ThreadUtil.run(new Runnable() { @@ -706,7 +751,7 @@ return; } - JDGoods jdGoods = JDApiUtil.queryGoodsDetail(id); // 楂樼骇鎺ュ彛 + JDGoods jdGoods = JDApiUtil.queryGoodsDetail( id); // 楂樼骇鎺ュ彛 if (jdGoods == null) { jdGoods = JDUtil.getGoodsDetail(id); // 鐖彇缃戦〉 // jdGoods = JDApiUtil.getGoodsDetail(id); // 鏅�氭帴鍙� @@ -773,7 +818,7 @@ // 濂栧姳鍒歌繑鍒� RewardCouponVO rewardCoupon = new RewardCouponVO(); rewardCoupon.setMaxMoneyPlus(maxMoneyPlus); - rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web")); + 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())); @@ -801,8 +846,13 @@ if (couponInfo != null) { // 鍒搁摼鎺ュ鐞� String materialId = "https://item.jd.com/" + id + ".html"; - String url = JDApiUtil.convertLinkWithSubUnionId(materialId, couponInfo.getLink(), null, - JDApiUtil.POSITION_COUPON + "", null); + String url = null; + try { + url = JDApiUtil.convertLinkWithSubUnionId(materialId, couponInfo.getLink(), null, + pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.coupon), null); + } catch (Exception e) { + logger.warn(String.format("浜笢杞摼鍑洪敊锛歮aterialId-%s couponUrl-%s", materialId, couponInfo.getLink()), e); + } couponInfo.setLink(url); } @@ -849,11 +899,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)); } // 鍥炬枃璇︽儏 @@ -934,14 +984,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) { } } @@ -968,7 +1020,7 @@ // 闄勫姞淇℃伅 OtherInfo otherInfo = new OtherInfo(); RewardCouponVO rewardCoupon = new RewardCouponVO(); - rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web")); + 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())); @@ -992,7 +1044,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()); } @@ -1051,11 +1103,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); @@ -1175,7 +1227,7 @@ // 闄勫姞淇℃伅 OtherInfo otherInfo = new OtherInfo(); RewardCouponVO rewardCoupon = new RewardCouponVO(); - rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web")); + 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())); @@ -1215,11 +1267,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); @@ -1315,7 +1367,7 @@ // 闄勫姞淇℃伅 OtherInfo otherInfo = new OtherInfo(); RewardCouponVO rewardCoupon = new RewardCouponVO(); - rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web")); + rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web", acceptData.getSystem())); JSONObject params1 = new JSONObject(); params1.put("url", userVipConfigService.getValueByKey("vip_link")); @@ -1356,11 +1408,11 @@ if (uid != null) { // 鏄惁鍔犲叆鏀惰棌 CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, - Long.parseLong(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, - Long.parseLong(suningGoodsInfo.getCommodityInfo().getCommodityCode()), + (suningGoodsInfo.getCommodityInfo().getCommodityCode()), Constant.SOURCE_TYPE_SUNING)); } @@ -1427,6 +1479,9 @@ * @param goodsDetail */ private void getCloudInfo(AcceptData acceptData, Long uid, GoodsDetailVO goodsDetail, GoodsDetailExtraVO extraVO) { + if (1 > 0) { + return; + } // 浜戝彂鍗曟槸鍚﹀紑鍚� boolean cloudOpen = configService.isRobotCloudOpen(ConfigKeyEnum.robotCloudOpenGoodsDetail.getKey(), acceptData.getPlatform(), acceptData.getVersion(), acceptData.getSystem()); if (!cloudOpen && uid != null) { @@ -1598,16 +1653,16 @@ return; } - List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(Long.parseLong(id), 10); + List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(id, 10); // 鍒濆鍖� if (goodsList == null) { - goodsList = new ArrayList<TaoBaoGoodsBrief>(); + goodsList = new ArrayList<>(); } List<GoodsDetailVO> listExtra = new ArrayList<GoodsDetailVO>(); GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), null, acceptData.getSystem()); - listExtra = goodsLijinMnager.loadTBMoneyInfo(acceptData.getSystem(), uid, goodsList, paramsDTO); + listExtra = goodsLijinMnager.loadTBMoneyInfo(acceptData.getSystem(), uid, goodsList, paramsDTO, false); List<GoodsDetailVO> listQuality = new ArrayList<GoodsDetailVO>(); // 鍙栧伓鏁颁釜鏁版嵁 @@ -1650,26 +1705,42 @@ } 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 + "", - ""); - if (jumpLink == null) { - jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null, JDApiUtil.POSITION_COUPON + "", + + try { + jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pid, ""); + } catch (Exception e) { + logger.warn(String.format("浜笢杞摼鍑洪敊锛歮aterialId-%s couponUrl-%s", materialId, couponUrl), e); + } + if (jumpLink == null) { + try { + jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null, pid, + ""); + } catch (Exception e) { + e.printStackTrace(); + logger.warn(String.format("浜笢杞摼鍑洪敊锛歮aterialId-%s ", materialId), e); + } } } else { - jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, JDApiUtil.POSITION_COUPON + "", - ""); + try { + jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pid, + ""); + } catch (Exception e) { + e.printStackTrace(); + logger.warn(String.format("浜笢杞摼鍑洪敊锛歮aterialId-%s couponUrl-%s", materialId, couponUrl), e); + } if (StringUtil.isNullOrEmpty(jumpLink)) { jumpLink = couponUrl; } } - GoodsJumpLinkVO vo = new GoodsJumpLinkVO(); + GoodsJumpLinkVO vo = GoodsJumpUtil.getJDJumpInfo(jumpLink); vo.set_native(true); vo.setJumpLink(jumpLink); vo.setNativeJumpLink(jumpLink); @@ -1710,6 +1781,11 @@ getJDLinkWithoutFanLi(acceptData, id, couponUrl, source, out); return; } + //鏈櫥褰曢鍒� + if (uid == null) { + getJDLinkWithoutFanLi(acceptData, id, couponUrl, source, out); + return; + } if (uid == null || uid <= 0) { out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛ID涓嶈兘涓虹┖")); @@ -1723,6 +1799,11 @@ return; } + if (userFunctionsLimitService.isLimit(uid, SystemFunction.fanli, new Date())) { + out.print(JsonUtil.loadFalseResult(1, "璇ュ姛鑳介檺鍒朵娇鐢�")); + return; + } + JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(id); if (goods == null) { out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧宸蹭笅鏋�")); @@ -1731,41 +1812,45 @@ 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 + "", - uid + ""); - if (jumpLink == null) { - jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null, JDApiUtil.POSITION_FANLI + "", + try { + jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pid, uid + ""); + } catch (Exception e) { + logger.warn(String.format("浜笢杞摼鍑洪敊锛歮aterialId-%s couponUrl-%s", materialId, couponUrl), e); + } + if (jumpLink == null) { + try { + jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null, pid, + uid + ""); + } catch (Exception e) { + logger.warn(String.format("浜笢杞摼鍑洪敊锛歮aterialId-%s", materialId), e); + } } } else { - jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, JDApiUtil.POSITION_FANLI + "", - uid + ""); + try { + jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pid, + uid + ""); + } catch (Exception e) { + logger.warn(String.format("浜笢杞摼鍑洪敊锛歮aterialId-%s couponUrl-%s", materialId, couponUrl), e); + } if (StringUtil.isNullOrEmpty(jumpLink)) { jumpLink = couponUrl; } } - - GoodsJumpLinkVO vo = new GoodsJumpLinkVO(); - vo.set_native(true); - vo.setJumpLink(jumpLink); - vo.setNativeJumpLink(jumpLink); - try { - String wxPage = "pages/union/proxy/proxy?spreadUrl=" + URLEncoder.encode(jumpLink, "UTF-8"); - WXXCXJumpInfoVO wxxcxJumpInfoVO = new WXXCXJumpInfoVO(); - wxxcxJumpInfoVO.setUserName("gh_45b306365c3d"); - wxxcxJumpInfoVO.setPath(wxPage); - vo.setWxxcxJumpInfo(wxxcxJumpInfoVO); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } + GoodsJumpLinkVO vo = GoodsJumpUtil.getJDJumpInfo(jumpLink); 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)); // 鑾峰緱閲戝竵 @@ -1786,7 +1871,11 @@ String jumpLink = null; String materialId = "https://item.jd.com/" + id + ".html"; - jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, JDApiUtil.POSITION_FANLI + "", null); + try { + jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.fanli), null); + } catch (Exception e) { + logger.warn(String.format("浜笢杞摼鍑洪敊锛歮aterialId-%s couponUrl-%s", materialId, couponUrl), e); + } if (StringUtil.isNullOrEmpty(jumpLink)) { jumpLink = couponUrl; } @@ -1814,21 +1903,32 @@ 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) { - 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 (uid == null) { + pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.coupon); + 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; + } } } @@ -1840,7 +1940,7 @@ return; } - String customParams = pddAuthService.getFanliCustomParams(uid); + String customParams = uid == null ? Constant.PDD_SEARCH_CUSTOMER_PARAMS : pddAuthService.getFanliCustomParams(uid); boolean auth = PinDuoDuoApiUtil.isAuth(pid, customParams); JSONObject data = new JSONObject(); PDDConvertLinkResultVO convertUrl = null; @@ -1851,18 +1951,11 @@ LogHelper.test(String.format("鎷煎澶氳浆閾�:uid:%s data:%s", uid + "", data.toString())); } - GoodsJumpLinkVO vo = new GoodsJumpLinkVO(); - vo.set_native(true); - vo.setNativeJumpLink(PinDuoDuoUtil.getAndroidNativeURI(convertUrl.getUrl())); - vo.setJumpLink(convertUrl.getUrl()); - if (convertUrl.getWe_app_info() != null) { - WXXCXJumpInfoVO wxxcxJumpInfoVO = new WXXCXJumpInfoVO(); - wxxcxJumpInfoVO.setPath(convertUrl.getWe_app_info().getPage_path()); - wxxcxJumpInfoVO.setUserName(convertUrl.getWe_app_info().getUser_name()); - vo.setWxxcxJumpInfo(wxxcxJumpInfoVO); - } + GoodsJumpLinkVO vo = GoodsJumpUtil.getPDDJumpInfo(convertUrl); 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)); // 鑾峰緱閲戝竵 @@ -1890,18 +1983,28 @@ if (!SystemInfoUtil.hasFunctions(acceptData.getSystem(), SystemFunction.fanli)) { tag = VipShopUtil.getCouponChanTag(); } else { - if (uid == null || uid <= 0) { - out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛ID涓嶈兘涓虹┖")); - return; - } + //鍙槸棰嗗埜 + if (uid == null) { + tag = VipShopUtil.getCouponChanTag(); + } 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; - } + 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; + } - tag = VipShopUtil.getBuyChanTag(uid); + if (userFunctionsLimitService.isLimit(uid, SystemFunction.fanli, new Date())) { + out.print(JsonUtil.loadFalseResult(1, "璇ュ姛鑳介檺鍒朵娇鐢�")); + return; + } + + tag = VipShopUtil.getBuyChanTag(uid); + } } VIPGoodsInfo goods = VipShopApiUtil.getGoodsDetail(id + ""); @@ -1911,20 +2014,12 @@ } VIPConvertResultDTO convertUrl = VipShopApiUtil.convertLink(id + "", tag); - - GoodsJumpLinkVO vo = new GoodsJumpLinkVO(); - vo.set_native(true); - vo.setJumpLink(convertUrl.getUrl()); - vo.setNativeJumpLink(convertUrl.getDeeplinkUrl()); - if (!StringUtil.isNullOrEmpty(convertUrl.getVipWxUrl())) { - WXXCXJumpInfoVO wxxcxJumpInfoVO = new WXXCXJumpInfoVO(); - wxxcxJumpInfoVO.setUserName("gh_8ed2afad9972"); - wxxcxJumpInfoVO.setPath(convertUrl.getVipWxUrl()); - vo.setWxxcxJumpInfo(wxxcxJumpInfoVO); - } + GoodsJumpLinkVO vo = GoodsJumpUtil.getVIPShopJumpInfo(convertUrl); 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); @@ -1937,19 +2032,29 @@ 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) { - 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 (uid == null) { + pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_SUNING, SystemPIDInfo.PidType.coupon); + 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; + } } } @@ -1970,26 +2075,12 @@ SuningConvertLinkResult link = SuningApiUtil.convertLinkNew(goodsCode, supplierCode, pid, uid + ""); - GoodsJumpLinkVO vo = new GoodsJumpLinkVO(); - vo.set_native(false); - try { - vo.setJumpLink(URLDecoder.decode(link.getWapExtendUrl(), "UTF-8")); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - if (!StringUtil.isNullOrEmpty(link.getSpPageUrl())) { - WXXCXJumpInfoVO wxxcxJumpInfoVO = new WXXCXJumpInfoVO(); - wxxcxJumpInfoVO.setUserName("gh_1d1e15e90afc"); - try { - wxxcxJumpInfoVO.setPath(URLDecoder.decode(link.getSpPageUrl(), "UTF-8")); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - vo.setWxxcxJumpInfo(wxxcxJumpInfoVO); - } + GoodsJumpLinkVO vo = GoodsJumpUtil.getSuningJumpInfo(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)); @@ -2018,7 +2109,7 @@ if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { TaoBaoGoodsBrief goods = null; try { - goods = TaoKeApiUtil.getSimpleGoodsInfo(Long.parseLong(goodsId)); + goods = TaoKeApiUtil.getSimpleGoodsInfo(goodsId); } catch (NumberFormatException e) { e.printStackTrace(); } catch (TaobaoGoodsDownException e) { @@ -2082,7 +2173,7 @@ for (int i = 0; i < array.size(); i++) { JSONObject obj = array.optJSONObject(i); CommonGoods cg = new CommonGoods(); - cg.setGoodsId(obj.optLong("goodsId")); + cg.setGoodsId(obj.optString("goodsId")); cg.setGoodsType(obj.optInt("goodsType")); commonGoodsList.add(cg); } @@ -2093,7 +2184,7 @@ } // 鍒嗙鍚勪釜骞冲彴鐨勫晢鍝佷俊鎭� - List<Long> tbGoodsList = new ArrayList<>(); + List<String> tbGoodsList = new ArrayList<>(); List<Long> jdGoodsList = new ArrayList<>(); List<Long> pddGoodsList = new ArrayList<>(); @@ -2104,9 +2195,9 @@ if (cg.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) { tbGoodsList.add(cg.getGoodsId()); } else if (cg.getGoodsType() == Constant.SOURCE_TYPE_JD) { - jdGoodsList.add(cg.getGoodsId()); + jdGoodsList.add(Long.parseLong( cg.getGoodsId())); } else if (cg.getGoodsType() == Constant.SOURCE_TYPE_PDD) { - pddGoodsList.add(cg.getGoodsId()); + pddGoodsList.add(Long.parseLong(cg.getGoodsId())); } } @@ -2175,27 +2266,51 @@ return; } - link = JDApiUtil.convertLinkWithSubUnionId(link, null, null, JDApiUtil.POSITION_FANLI + "", uid + ""); - - - GoodsJumpLinkVO vo = new GoodsJumpLinkVO(); - vo.set_native(true); - vo.setJumpLink(link); - vo.setNativeJumpLink(link); try { - String wxPage = "pages/union/proxy/proxy?spreadUrl=" + URLEncoder.encode(link, "UTF-8"); - WXXCXJumpInfoVO wxxcxJumpInfoVO = new WXXCXJumpInfoVO(); - wxxcxJumpInfoVO.setUserName("gh_45b306365c3d"); - wxxcxJumpInfoVO.setPath(wxPage); - vo.setWxxcxJumpInfo(wxxcxJumpInfoVO); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + link = JDApiUtil.convertLinkWithSubUnionId(link, null, null, pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.fanli), uid + ""); + } catch (Exception e) { + logger.warn(String.format("浜笢杞摼鍑洪敊锛歮aterialId-%s", link), e); } + GoodsJumpLinkVO vo = GoodsJumpUtil.getJDJumpInfo(link); JSONObject data = JSONObject.fromObject(new Gson().toJson(vo)); data.put("native", vo.is_native()); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); } + @RequestMapping(value = "convertPDDLink") + public void convertPDDLink(AcceptData acceptData, String resourceType, String channelType, Long uid, PrintWriter out) { + if (StringUtil.isNullOrEmpty(resourceType) && StringUtil.isNullOrEmpty(channelType)) { + out.print(JsonUtil.loadFalseResult(1, "resourceType|channelType涓虹┖")); + return; + } + String customParams = null; + if (uid != null) + customParams = pddAuthService.getFanliCustomParams(uid); + String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.fanli); + PDDConvertLinkResultVO pddConvertLinkResultVO = null; + if (!StringUtil.isNullOrEmpty(resourceType)) { + pddConvertLinkResultVO = PinDuoDuoApiUtil.convertActivity(resourceType, null, pid, customParams); + } else if (!StringUtil.isNullOrEmpty(channelType)) { + pddConvertLinkResultVO = PinDuoDuoApiUtil.convertChannel(channelType, pid, customParams); + } + + + GoodsJumpLinkVO vo = GoodsJumpUtil.getPDDJumpInfo(pddConvertLinkResultVO); + JSONObject data = JSONObject.fromObject(new Gson().toJson(vo)); + data.put("native", vo.is_native()); + out.print(JsonUtil.loadTrueResult(data)); + } + + @RequestMapping(value = "getTaoBaoGoodsDetailImgs") + public void getTaoBaoGoodsDetailImgs(AcceptData acceptData, String id, PrintWriter out) { + TaoBaoGoodsImportantInfo info = DaTaoKeApiUtil.getGoodsImportantInfo(id); + if (info == null || info.getDetailImages() == null) { + out.print(JsonUtil.loadFalseResult("")); + return; + } + out.print(JsonUtil.loadTrueResult(new Gson().toJson(info.getDetailImages()))); + } + } -- Gitblit v1.8.0