From 81da61b828e29b7745e1382dfbbaeb685dc083ef Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 23 一月 2024 17:17:55 +0800 Subject: [PATCH] 抖音转链修改 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java | 405 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 354 insertions(+), 51 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 9e566ec..cd4dc41 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,12 +20,17 @@ 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; 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; @@ -127,6 +131,9 @@ @Controller @RequestMapping("api/v2/goods") public class GoodsControllerV2 { + + + Logger logger = LoggerFactory.getLogger(GoodsControllerV2.class); @Resource private BusinessSystemService businessSystemService; @@ -264,7 +271,7 @@ // result.getGoods().setCouponLink(link); return result.getGoods(); } else { - link = DaTaoKeApiUtil.convertLink(goods.getAuctionId(), dpid); + link = DaTaoKeApiUtil.convertLink(goods.getAuctionId(), dpid, false); if (!StringUtil.isNullOrEmpty(link)) { // result.getGoods().setCouponLink(link); taoBaoGoodsCacheUtil.cacheBaseConvertLink(goods.getAuctionId(), dpid, link); @@ -289,11 +296,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()); @@ -332,6 +341,7 @@ TaoBaoGoodsBrief goods = null; if (!convertInServer) { + logger.debug("鑾峰彇鍟嗗搧璇︽儏-涓嶅湪鏈嶅姟绔浆閾撅細{}", id + ""); try { goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(id); if (goods == null) { @@ -410,6 +420,8 @@ }); } + logger.debug("鑾峰彇鍟嗗搧璇︽儏-鑾峰彇鍟嗗搧璇︽儏鎴愬姛锛歿}", id + ""); + TaoBaoGoodsBrief tb = goods; //鍒涘缓鏃堕棿璁剧疆涓虹┖锛岄槻姝㈠墠绔敤long瑙f瀽 @@ -458,6 +470,8 @@ tb.setImgList(finalImgList); + logger.debug("鑾峰彇鍟嗗搧璇︽儏-寮�濮嬪ぇ娣樺鍟嗗搧杩囨护锛歿}", id + ""); + // 澶ф窐瀹㈠晢鍝佽繃婊� try { goods = filterDaTaoKeGoodsInfo(acceptData.getSystem(), goods); @@ -465,8 +479,12 @@ 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)) { @@ -497,6 +515,8 @@ } goodsDetail.setShopInfo(ShopInfoVOFactory.convertTaoBaoShop(shop)); } + logger.debug("鑾峰彇鍟嗗搧璇︽儏-鑾峰彇搴楅摵淇℃伅缁撴潫锛歿}", id + ""); + // 鍏嶅崟鍟嗗搧 if (!StringUtil.isNullOrEmpty(from) && "miandan".equals(from)) { @@ -524,6 +544,8 @@ } extraVO.setListShareUser(listShareUser); + logger.debug("鑾峰彇鍟嗗搧璇︽儏-鍒嗕韩璧氫汉鎻愮ず缁撴潫锛歿}", id + ""); + // 棰嗗埜浜哄垪琛� List<ShamUser> listCouponUser = new ArrayList<ShamUser>(); if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && goods.getCouponAmount() != null @@ -534,13 +556,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 + ""); } // 娴嬭瘯 @@ -628,9 +654,10 @@ goodsDetail.setLabels(labels); } else {// 鏅�氳喘涔� + logger.debug("鑾峰彇鍟嗗搧璇︽儏- 濂栧姳鍒稿紑濮嬶細{}", id + ""); OtherInfo otherInfo = new OtherInfo(); RewardCouponVO rewardCoupon = new RewardCouponVO(); - rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web",acceptData.getSystem())); + 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())); @@ -646,10 +673,10 @@ 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); - goodsDetail.setOtherInfo(otherInfo); } extraVO.setFanliValid(fanliValid); @@ -677,15 +704,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() { @@ -787,7 +819,7 @@ // 濂栧姳鍒歌繑鍒� RewardCouponVO rewardCoupon = new RewardCouponVO(); rewardCoupon.setMaxMoneyPlus(maxMoneyPlus); - rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web",acceptData.getSystem())); + 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())); @@ -815,8 +847,13 @@ if (couponInfo != null) { // 鍒搁摼鎺ュ鐞� String materialId = "https://item.jd.com/" + id + ".html"; - String url = JDApiUtil.convertLinkWithSubUnionId(materialId, couponInfo.getLink(), null, - pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.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); } @@ -863,11 +900,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)); } // 鍥炬枃璇︽儏 @@ -984,7 +1021,7 @@ // 闄勫姞淇℃伅 OtherInfo otherInfo = new OtherInfo(); RewardCouponVO rewardCoupon = new RewardCouponVO(); - rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web",acceptData.getSystem())); + 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())); @@ -1067,11 +1104,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); @@ -1191,7 +1228,7 @@ // 闄勫姞淇℃伅 OtherInfo otherInfo = new OtherInfo(); RewardCouponVO rewardCoupon = new RewardCouponVO(); - rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web",acceptData.getSystem())); + 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())); @@ -1231,11 +1268,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); @@ -1331,7 +1368,7 @@ // 闄勫姞淇℃伅 OtherInfo otherInfo = new OtherInfo(); RewardCouponVO rewardCoupon = new RewardCouponVO(); - rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web",acceptData.getSystem())); + rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web", acceptData.getSystem())); JSONObject params1 = new JSONObject(); params1.put("url", userVipConfigService.getValueByKey("vip_link")); @@ -1372,11 +1409,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)); } @@ -1437,12 +1474,154 @@ }); } + + @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(); + } + } + }); + } + + /** * // 浜戝彂鍗曟枃妗堜俊鎭� * * @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) { @@ -1515,7 +1694,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); } @@ -1614,16 +1793,48 @@ return; } - List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(Long.parseLong(id), 10); - // 鍒濆鍖� - if (goodsList == null) { - goodsList = new ArrayList<TaoBaoGoodsBrief>(); + 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<GoodsDetailVO> listExtra = new ArrayList<GoodsDetailVO>(); + List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(id, 10); + // 鍒濆鍖� + if (goodsList == null) { + goodsList = new ArrayList<>(); + } + + List<GoodsDetailVO> listExtra = new ArrayList<>(); GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), null, acceptData.getSystem()); - listExtra = goodsLijinMnager.loadTBMoneyInfo(acceptData.getSystem(), uid, goodsList, paramsDTO,false); + listExtra = goodsLijinMnager.loadTBMoneyInfo(acceptData.getSystem(), uid, goodsList, paramsDTO, false); List<GoodsDetailVO> listQuality = new ArrayList<GoodsDetailVO>(); // 鍙栧伓鏁颁釜鏁版嵁 @@ -1673,16 +1884,29 @@ couponUrl = couponInfo.getLink(); } - - jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pid, - ""); - if (jumpLink == null) { - jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null, pid, + 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, pid, - ""); + 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; } @@ -1768,15 +1992,27 @@ if (couponInfo != null) { couponUrl = couponInfo.getLink(); } - jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pid, - uid + ""); - if (jumpLink == null) { - jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null, pid, + 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, pid, - 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; } @@ -1807,7 +2043,11 @@ String jumpLink = null; String materialId = "https://item.jd.com/" + id + ".html"; - jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.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; } @@ -2020,6 +2260,65 @@ 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 = null; + try { + link = CSJCPSApiUtil.goodsConvert(goods.getDetail_url(), DYUtil.createFanLiExtraInfo(uid), + ""); + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧杞摼澶辫触")); + } + + 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); + } + /** * 鏄惁鍦ㄥ弬涓庢帹骞� * @@ -2041,7 +2340,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) { @@ -2105,7 +2404,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); } @@ -2116,7 +2415,7 @@ } // 鍒嗙鍚勪釜骞冲彴鐨勫晢鍝佷俊鎭� - List<Long> tbGoodsList = new ArrayList<>(); + List<String> tbGoodsList = new ArrayList<>(); List<Long> jdGoodsList = new ArrayList<>(); List<Long> pddGoodsList = new ArrayList<>(); @@ -2127,9 +2426,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())); } } @@ -2198,7 +2497,11 @@ return; } - link = JDApiUtil.convertLinkWithSubUnionId(link, null, null, pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.fanli), uid + ""); + try { + 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); @@ -2209,7 +2512,7 @@ @RequestMapping(value = "convertPDDLink") public void convertPDDLink(AcceptData acceptData, String resourceType, String channelType, Long uid, PrintWriter out) { - if (StringUtil.isNullOrEmpty(resourceType)&&StringUtil.isNullOrEmpty(channelType)) { + if (StringUtil.isNullOrEmpty(resourceType) && StringUtil.isNullOrEmpty(channelType)) { out.print(JsonUtil.loadFalseResult(1, "resourceType|channelType涓虹┖")); return; } @@ -2232,7 +2535,7 @@ } @RequestMapping(value = "getTaoBaoGoodsDetailImgs") - public void getTaoBaoGoodsDetailImgs(AcceptData acceptData, Long id, PrintWriter out) { + public void getTaoBaoGoodsDetailImgs(AcceptData acceptData, String id, PrintWriter out) { TaoBaoGoodsImportantInfo info = DaTaoKeApiUtil.getGoodsImportantInfo(id); if (info == null || info.getDetailImages() == null) { out.print(JsonUtil.loadFalseResult("")); -- Gitblit v1.8.0