From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/controller/h5/H5RecommendController.java | 922 +++++++++++++++++++++++++++++---------------------------- 1 files changed, 465 insertions(+), 457 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/h5/H5RecommendController.java b/fanli/src/main/java/com/yeshi/fanli/controller/h5/H5RecommendController.java index dcacbc6..cee1bcd 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/h5/H5RecommendController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/h5/H5RecommendController.java @@ -8,6 +8,9 @@ import javax.annotation.Resource; +import com.yeshi.fanli.entity.SystemPIDInfo; +import com.yeshi.fanli.entity.config.SystemConfigKeyEnum; +import com.yeshi.fanli.service.manger.PIDManager; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -68,524 +71,529 @@ @RequestMapping("api/h5/v1/webRecommend") public class H5RecommendController { - @Resource - private H5ControllerUtil h5ControllerUtil; + @Resource + private H5ControllerUtil h5ControllerUtil; - @Resource - private SuperRecommendBannerService superRecommendBannerService; + @Resource + private SuperRecommendBannerService superRecommendBannerService; - @Resource - private HongBaoManageService hongBaoManageService; + @Resource + private HongBaoManageService hongBaoManageService; - @Resource - private RedisManager redisManager; + @Resource + private RedisManager redisManager; - @Resource - private BusinessSystemService businessSystemService; + @Resource + private BusinessSystemService businessSystemService; - @Resource - private ConfigService configService; + @Resource + private ConfigService configService; - @Resource - private SystemConfigService systemConfigService; + @Resource + private SystemConfigService systemConfigService; - @Resource - private TaoBaoGoodsBriefService taoBaoGoodsBriefService; + @Resource + private TaoBaoGoodsBriefService taoBaoGoodsBriefService; - @Resource - private TBPidService tbPidService; + @Resource + private TBPidService tbPidService; - @Resource - private ShareGoodsService shareGoodsService; + @Resource + private ShareGoodsService shareGoodsService; - @Resource - private TaoBaoUnionConfigService taoBaoUnionConfigService; + @Resource + private TaoBaoUnionConfigService taoBaoUnionConfigService; - @Resource - private UserShareGoodsGroupService userShareGoodsGroupService; + @Resource + private UserShareGoodsGroupService userShareGoodsGroupService; - @Resource - private UserTaoLiJinRecordService userTaoLiJinRecordService; + @Resource + private UserTaoLiJinRecordService userTaoLiJinRecordService; - @Resource - private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; + @Resource + private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; - /** - * - * 鏂规硶璇存槑: 鎺ㄨ崘杞挱鍟嗗搧淇℃伅 - * - * @author mawurui createTime 2018骞�5鏈�11鏃� 涓婂崍11:13:47 - * @param acceptData - * @param out - */ - @RequestMapping(value = "getRecommenBanner", method = RequestMethod.GET) - public void getRecommendBanner(AcceptData acceptData, String callback, PrintWriter out) { + @Resource + private PIDManager pidManager; - BusinessSystem system = businessSystemService.getBusinessSystem("WEB", - Constant.systemCommonConfig.getH5PackageName(),acceptData.getSystem()); - JSONObject json = new JSONObject(); - if (system == null) { - out.print(JsonUtil.loadFalseResult(1, H5ControllerUtil.NOSYSTEM)); - return; - } - List<SuperRecommendBanner> superRecommendBanners = superRecommendBannerService - .getSuperRecommendBannersBySystem(system); - List<RecommendBanner> list = null; - for (SuperRecommendBanner superRecommendBanner : superRecommendBanners) { - if (list == null) { - list = new ArrayList<RecommendBanner>(); - } - RecommendBanner recommendBanner = superRecommendBanner.getRecommendBanner(); - // 娣樼壒浠锋殏鏃朵慨鏀� - if (system.getId() == 7) { - recommendBanner.getJumpDetail().setActivity(recommendBanner.getJumpDetail().getActivity() - .replace("com.yeshi.ec.rebate.myapplication", "com.yeshi.ec.taospecial")); - } + /** + * 鏂规硶璇存槑: 鎺ㄨ崘杞挱鍟嗗搧淇℃伅 + * + * @param acceptData + * @param out + * @author mawurui createTime 2018骞�5鏈�11鏃� 涓婂崍11:13:47 + */ + @RequestMapping(value = "getRecommenBanner", method = RequestMethod.GET) + public void getRecommendBanner(AcceptData acceptData, String callback, PrintWriter out) { - list.add(recommendBanner); - } + BusinessSystem system = businessSystemService.getBusinessSystem("WEB", + systemConfigService.getValueCache(SystemConfigKeyEnum.h5PackageName,acceptData.getSystem()), acceptData.getSystem()); + JSONObject json = new JSONObject(); + if (system == null) { + out.print(JsonUtil.loadFalseResult(1, H5ControllerUtil.NOSYSTEM)); + return; + } + List<SuperRecommendBanner> superRecommendBanners = superRecommendBannerService + .getSuperRecommendBannersBySystem(system); + List<RecommendBanner> list = null; + for (SuperRecommendBanner superRecommendBanner : superRecommendBanners) { + if (list == null) { + list = new ArrayList<RecommendBanner>(); + } + RecommendBanner recommendBanner = superRecommendBanner.getRecommendBanner(); + // 娣樼壒浠锋殏鏃朵慨鏀� + if (system.getId() == 7) { + recommendBanner.getJumpDetail().setActivity(recommendBanner.getJumpDetail().getActivity() + .replace("com.yeshi.ec.rebate.myapplication", "com.yeshi.ec.taospecial")); + } - if (list == null) { - json.put("code", "1"); - json.put("msg", H5ControllerUtil.NODATA); - out.print(json); - java.lang.System.out.println("json-" + json); - return; - } - json.put("code", 0); - JSONObject data = new JSONObject(); - data.put("count", list.size()); - Gson gson = new Gson(); - data.put("data", gson.toJson(list)); - json.put("data", data); - // jsonp鏂瑰紡杩斿洖 - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(json))); - return; - } + list.add(recommendBanner); + } - /** - * 澶勭悊鏉′欢 - * - * @param uid - * @param tid - * @param out - */ - private void doTaoLiJin(String callback, Long uid, Long tid, PrintWriter out) { - // 鏌ヨ鍟嗗搧娣樼ぜ閲� - UserTaoLiJinRecord record = userTaoLiJinRecordService.selectByPrimaryKey(tid); - if (record == null) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鍟嗗搧淇℃伅鑾峰彇澶辫触"))); - return; - } + if (list == null) { + json.put("code", "1"); + json.put("msg", H5ControllerUtil.NODATA); + out.print(json); + java.lang.System.out.println("json-" + json); + return; + } + json.put("code", 0); + JSONObject data = new JSONObject(); + data.put("count", list.size()); + Gson gson = new Gson(); + data.put("data", gson.toJson(list)); + json.put("data", data); + // jsonp鏂瑰紡杩斿洖 + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(json))); + return; + } - Long auctionId = record.getGoodsId(); - String tljLink = record.getSendUrl(); - BigDecimal tljMoney = record.getPerFace(); + /** + * 澶勭悊鏉′欢 + * + * @param uid + * @param tid + * @param out + */ + private void doTaoLiJin(String callback, Long uid, Long tid, PrintWriter out) { + // 鏌ヨ鍟嗗搧娣樼ぜ閲� + UserTaoLiJinRecord record = userTaoLiJinRecordService.selectByPrimaryKey(tid); + if (record == null) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鍟嗗搧淇℃伅鑾峰彇澶辫触"))); + return; + } - TaoBaoGoodsBrief goods = null; - try { - goods = redisManager.getTaoBaoGoodsBrief(auctionId); - } catch (TaobaoGoodsDownException e) { - } + String auctionId = record.getGoodsId(); + String tljLink = record.getSendUrl(); + BigDecimal tljMoney = record.getPerFace(); - if (goods == null) {// 宸茬粡涓嬬嚎 - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鍟嗗搧淇℃伅鑾峰彇澶辫触"))); - return; - } + TaoBaoGoodsBrief goods = null; + try { + goods = redisManager.getTaoBaoGoodsBrief(auctionId); + } catch (TaobaoGoodsDownException e) { + } - String token = redisManager.getTLJToken(tljLink); - if (StringUtil.isNullOrEmpty(token)) { - token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), tljLink); - } + if (goods == null) {// 宸茬粡涓嬬嚎 + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鍟嗗搧淇℃伅鑾峰彇澶辫触"))); + return; + } - // 鍒稿悗浠� - BigDecimal afterCouponPrice = TaoBaoUtil.getAfterUseCouplePrice(goods); - TaoBaoLink link = new TaoBaoLink(); - link.setTaoToken(token); + String token = redisManager.getTLJToken(tljLink); + if (StringUtil.isNullOrEmpty(token)) { + token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), tljLink); + } - JSONObject data = new JSONObject(); - data.put("title", goods.getTitle()); - if (goods.getImgList() == null) - goods.setImgList(new ArrayList<>()); - goods.getImgList().add(0, TbImgUtil.getTBSizeImg(goods.getPictUrl(), 300)); - data.put("imgs", goods.getImgList()); - data.put("couponPrice", afterCouponPrice); - // 鑰佺増鏈吋瀹� - data.put("quanPrice", afterCouponPrice); - data.put("zkPrice", goods.getZkPrice()); - data.put("shareContent", "闀挎寜澶嶅埗鏈鏂囧瓧锛屾墦寮�銆愭墜鏈烘窐瀹濄�戝嵆鍙鍙栥�愮壒鍒紭鎯犲埜銆戣喘涔颁笅鍗曪紝"); - data.put("token", TaoBaoUtil.filterTaoToken(link.getTaoToken())); - data.put("reservePrice", goods.getReservePrice()); - data.put("shopType", goods.getUserType() == 1 ? 2 : 1); - if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && !"鏃�".equalsIgnoreCase(goods.getCouponInfo())) { - data.put("couponAmount", MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount())); - data.put("coupon", true); - } else { - data.put("coupon", false); - } + // 鍒稿悗浠� + BigDecimal afterCouponPrice = TaoBaoUtil.getCouponPrice(goods); + TaoBaoLink link = new TaoBaoLink(); + link.setTaoToken(token); - data.put("tljMoney", tljMoney); + JSONObject data = new JSONObject(); + data.put("title", goods.getTitle()); + if (goods.getImgList() == null) + goods.setImgList(new ArrayList<>()); + goods.getImgList().add(0, TbImgUtil.getTBSizeImg(goods.getPictUrl(), 300)); + data.put("imgs", goods.getImgList()); + data.put("couponPrice", afterCouponPrice); + // 鑰佺増鏈吋瀹� + data.put("quanPrice", afterCouponPrice); + data.put("zkPrice", goods.getZkPrice()); + data.put("shareContent", "闀挎寜澶嶅埗鏈鏂囧瓧锛屾墦寮�銆愭墜鏈烘窐瀹濄�戝嵆鍙鍙栥�愮壒鍒紭鎯犲埜銆戣喘涔颁笅鍗曪紝"); + data.put("token", TaoBaoUtil.filterTaoToken(link.getTaoToken())); + data.put("reservePrice", goods.getReservePrice()); + data.put("shopType", goods.getUserType() == 1 ? 2 : 1); + if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && !"鏃�".equalsIgnoreCase(goods.getCouponInfo())) { + data.put("couponAmount", MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount())); + data.put("coupon", true); + } else { + data.put("coupon", false); + } - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); - } + data.put("tljMoney", tljMoney); - /** - * - * 鏂规硶璇存槑: 鑾峰彇鍟嗗搧璇︽儏 - * - * @author mawurui createTime 2018骞�5鏈�11鏃� 涓婂崍11:37:02 - * @param acceptData - * @param id - * @param uid - * @param out - */ + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); + } - @SuppressWarnings("unused") - @RequestMapping(value = "getGoodsDetail", method = RequestMethod.GET) - public void getGoodsDetail(final AcceptData acceptData, final String id, String tid, String uid, String callback, - PrintWriter out) { - if (!StringUtil.isNullOrEmpty(uid)) - uid = uid.replace(" ", "+"); + /** + * 鏂规硶璇存槑: 鑾峰彇鍟嗗搧璇︽儏 + * + * @param acceptData + * @param id + * @param uid + * @param out + * @author mawurui createTime 2018骞�5鏈�11鏃� 涓婂崍11:37:02 + */ - LogManager.getLogger(LogType.taobaoTrade) - .info(String.format("娣樺疂鍒嗕韩鍟嗗搧H5璁块棶:\n 鍟嗗搧ID:%s \n 鍘熷鐢ㄦ埛ID:%s \n", id, uid)); - - long begin = java.lang.System.currentTimeMillis(); - if (StringUtil.isNullOrEmpty(id)) { - out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爄d")); - return; - } + @SuppressWarnings("unused") + @RequestMapping(value = "getGoodsDetail", method = RequestMethod.GET) + public void getGoodsDetail(final AcceptData acceptData, final String id, String tid, String uid, String callback, + PrintWriter out) { + if (!StringUtil.isNullOrEmpty(uid)) + uid = uid.replace(" ", "+"); - if (!StringUtil.isNullOrEmpty(uid)) { - uid = AESUtil.decrypt(uid, Constant.UIDAESKEY); - } + LogManager.getLogger(LogType.taobaoTrade) + .info(String.format("娣樺疂鍒嗕韩鍟嗗搧H5璁块棶:\n 鍟嗗搧ID:%s \n 鍘熷鐢ㄦ埛ID:%s \n", id, uid)); - if (!StringUtil.isNullOrEmpty(tid)) { - tid = AESUtil.decrypt(tid, Constant.UIDAESKEY); - doTaoLiJin(callback, StringUtil.isNullOrEmpty(uid) || Long.parseLong(uid) == 0 ? null : Long.parseLong(uid), - Long.parseLong(tid), out); - return; - } + long begin = java.lang.System.currentTimeMillis(); + if (StringUtil.isNullOrEmpty(id)) { + out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爄d")); + return; + } - TaoBaoGoodsBrief goods = null; - String token = null; - if (!StringUtil.isNullOrEmpty(uid)) { - // 鏌ヨ鏄惁鏈夊垎浜褰� - UserShareGoodsHistory shareHistory = null; - try { - shareHistory = shareGoodsService.getShareGoodsHistoryDetail(Long.parseLong(uid), Long.parseLong(id)); - } catch (NumberFormatException e) { - e.printStackTrace(); - } catch (ShareGoodsException e) { - e.printStackTrace(); - } + if (!StringUtil.isNullOrEmpty(uid)) { + uid = AESUtil.decrypt(uid, Constant.UIDAESKEY); + } - if (shareHistory != null) {// 鏈夊垎浜褰� - token = shareHistory.getTkCode(); - goods = redisManager.getTaoBaoGoodsTemp(Long.parseLong(id)); - if (goods == null) - try { - goods = TaoKeApiUtil.searchGoodsDetail(Long.parseLong(id)); - } catch (NumberFormatException e) { - e.printStackTrace(); - } catch (TaobaoGoodsDownException e) { - e.printStackTrace(); - } + if (!StringUtil.isNullOrEmpty(tid)) { + tid = AESUtil.decrypt(tid, Constant.UIDAESKEY); + doTaoLiJin(callback, StringUtil.isNullOrEmpty(uid) || Long.parseLong(uid) == 0 ? null : Long.parseLong(uid), + Long.parseLong(tid), out); + return; + } - } else {// 娌℃湁鍒嗕韩璁板綍锛岄渶瑕佺洿鎺ュ垎浜� - LogHelper.test("娌℃湁鍒嗕韩璁板綍:uid:" + uid + " actionid:" + id); - // 鑾峰彇 - TaoKeAppInfo app = new TaoKeAppInfo(); - app.setPid(TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT); - app.setAdzoneId(app.getPid().split("_")[3]); - app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); - app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); + TaoBaoGoodsBrief goods = null; + String token = null; + if (!StringUtil.isNullOrEmpty(uid)) { + // 鏌ヨ鏄惁鏈夊垎浜褰� + UserShareGoodsHistory shareHistory = null; + try { + shareHistory = shareGoodsService.getShareGoodsHistoryDetail(Long.parseLong(uid), id); + } catch (NumberFormatException e) { + e.printStackTrace(); + } catch (ShareGoodsException e) { + e.printStackTrace(); + } - try { - goods = TaoKeApiUtil.searchGoodsDetail(Long.parseLong(id), app); - } catch (NumberFormatException e) { - e.printStackTrace(); - } catch (TaobaoGoodsDownException e) { - e.printStackTrace(); - } - if (goods != null) { - String url = goods.getAuctionUrl(); - if (!StringUtil.isNullOrEmpty(goods.getCouponLink())) { - url = goods.getCouponLink(); - } - String relationId = userExtraTaoBaoInfoService.getRelationIdByUid(Long.parseLong(uid)); - if (!StringUtil.isNullOrEmpty(relationId)) - url += "&relationId=" + relationId; - token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), url); - } - } + if (shareHistory != null) {// 鏈夊垎浜褰� + token = shareHistory.getTkCode(); + goods = redisManager.getTaoBaoGoodsTemp(id); + if (goods == null) + try { + goods = TaoKeApiUtil.searchGoodsDetail(id); + } catch (NumberFormatException e) { + e.printStackTrace(); + } catch (TaobaoGoodsDownException e) { + e.printStackTrace(); + } - } else { - List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService - .getConfigByTypeCache(PidUser.TYPE_SHARE_GOODS); - String pid = tbPidService.getSharePid().getPid(); - TaoKeAppInfo app = new TaoKeAppInfo(); - app.setAdzoneId(pid.split("_")[3]); - app.setAppKey(configList.get(0).getAppKey()); - app.setAppSecret(configList.get(0).getAppSecret()); - app.setPid(pid); - try { - goods = TaoKeApiUtil.searchGoodsDetail(Long.parseLong(id), app); - } catch (NumberFormatException e) { - e.printStackTrace(); - } catch (TaobaoGoodsDownException e) { - e.printStackTrace(); - } - if (goods != null) { - String url = goods.getAuctionUrl(); - if (!StringUtil.isNullOrEmpty(goods.getCouponLink())) { - url = goods.getCouponLink(); - } - if (!url.contains("uland.taobao.com") && !url.contains("s.click.taobao.com")) { - TaoBaoGoodsBrief linkInfo = TaoKeApiUtil.specialConvertCoupon(Long.parseLong(id), app,null,null); - url = linkInfo.getCouponLink(); - if (StringUtil.isNullOrEmpty(url)) - url = linkInfo.getAuctionUrl(); - } + } else {// 娌℃湁鍒嗕韩璁板綍锛岄渶瑕佺洿鎺ュ垎浜� + LogHelper.test("娌℃湁鍒嗕韩璁板綍:uid:" + uid + " actionid:" + id); + // 鑾峰彇 + TaoKeAppInfo app = new TaoKeAppInfo(); + app.setPid(pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.share)); + app.setAdzoneId(app.getPid().split("_")[3]); + app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); + app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); - token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), url); - } - } + try { + goods = TaoKeApiUtil.searchGoodsDetail(id, app); + } catch (NumberFormatException e) { + e.printStackTrace(); + } catch (TaobaoGoodsDownException e) { + e.printStackTrace(); + } + if (goods != null) { + String url = goods.getAuctionUrl(); + if (!StringUtil.isNullOrEmpty(goods.getCouponLink())) { + url = goods.getCouponLink(); + } + String relationId = userExtraTaoBaoInfoService.getRelationIdByUid(Long.parseLong(uid)); + if (!StringUtil.isNullOrEmpty(relationId)) + url += "&relationId=" + relationId; + token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), url); + } + } - if (goods == null) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鍟嗗搧淇℃伅鑾峰彇澶辫触"))); - return; - } + } else { + List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService + .getConfigByTypeCache(PidUser.TYPE_SHARE_GOODS); + String pid = tbPidService.getSharePid(acceptData.getSystem()).getPid(); + TaoKeAppInfo app = new TaoKeAppInfo(); + app.setAdzoneId(pid.split("_")[3]); + app.setAppKey(configList.get(0).getAppKey()); + app.setAppSecret(configList.get(0).getAppSecret()); + app.setPid(pid); + try { + goods = TaoKeApiUtil.searchGoodsDetail(id, app); + } catch (NumberFormatException e) { + e.printStackTrace(); + } catch (TaobaoGoodsDownException e) { + e.printStackTrace(); + } + if (goods != null) { + String url = goods.getAuctionUrl(); + if (!StringUtil.isNullOrEmpty(goods.getCouponLink())) { + url = goods.getCouponLink(); + } + if (!url.contains("uland.taobao.com") && !url.contains("s.click.taobao.com")) { + TaoBaoGoodsBrief linkInfo = TaoKeApiUtil.specialConvertCouponV2(id, app, null, null); + url = linkInfo.getCouponLink(); + if (StringUtil.isNullOrEmpty(url)) + url = linkInfo.getAuctionUrl(); + } - if (StringUtil.isNullOrEmpty(token)) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鍙d护鐢熸垚澶辫触"))); - return; - } + token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), url); + } + } - // 鍒稿悗浠� - BigDecimal afterCouponPrice = TaoBaoUtil.getAfterUseCouplePrice(goods); - TaoBaoLink link = new TaoBaoLink(); - link.setTaoToken(token); + if (goods == null) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鍟嗗搧淇℃伅鑾峰彇澶辫触"))); + return; + } - JSONObject data = new JSONObject(); - data.put("title", goods.getTitle()); - if (goods.getImgList() == null) - goods.setImgList(new ArrayList<>()); - goods.getImgList().add(0, TbImgUtil.getTBSizeImg(goods.getPictUrl(), 300)); - data.put("imgs", goods.getImgList()); - data.put("couponPrice", afterCouponPrice); - // 鑰佺増鏈吋瀹� - data.put("quanPrice", afterCouponPrice); - data.put("zkPrice", goods.getZkPrice()); - data.put("shareContent", "闀挎寜澶嶅埗鏈鏂囧瓧锛屾墦寮�銆愭墜鏈烘窐瀹濄�戝嵆鍙鍙栥�愮壒鍒紭鎯犲埜銆戣喘涔颁笅鍗曪紝"); - data.put("token", TaoBaoUtil.filterTaoToken(link.getTaoToken())); - data.put("reservePrice", goods.getReservePrice()); - data.put("shopType", goods.getUserType() == 1 ? 2 : 1); - if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && !"鏃�".equalsIgnoreCase(goods.getCouponInfo())) { - data.put("couponAmount", MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount())); - data.put("coupon", true); - // 鑰佺増鏈吋瀹� - data.put("quan", true); - } else { - data.put("coupon", false); - // 鑰佺増鏈吋瀹� - data.put("quan", true); - } + if (StringUtil.isNullOrEmpty(token)) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鍙d护鐢熸垚澶辫触"))); + return; + } - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); + // 鍒稿悗浠� + BigDecimal afterCouponPrice = TaoBaoUtil.getCouponPrice(goods); + TaoBaoLink link = new TaoBaoLink(); + link.setTaoToken(token); - final String tempUid = uid; - ThreadUtil.run(new Runnable() { + JSONObject data = new JSONObject(); + data.put("title", goods.getTitle()); + if (goods.getImgList() == null) + goods.setImgList(new ArrayList<>()); + goods.getImgList().add(0, TbImgUtil.getTBSizeImg(goods.getPictUrl(), 300)); + data.put("imgs", goods.getImgList()); + data.put("couponPrice", afterCouponPrice); + // 鑰佺増鏈吋瀹� + data.put("quanPrice", afterCouponPrice); + data.put("zkPrice", goods.getZkPrice()); + data.put("shareContent", "闀挎寜澶嶅埗鏈鏂囧瓧锛屾墦寮�銆愭墜鏈烘窐瀹濄�戝嵆鍙鍙栥�愮壒鍒紭鎯犲埜銆戣喘涔颁笅鍗曪紝"); + data.put("token", TaoBaoUtil.filterTaoToken(link.getTaoToken())); + data.put("reservePrice", goods.getReservePrice()); + data.put("shopType", goods.getUserType() == 1 ? 2 : 1); + if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && !"鏃�".equalsIgnoreCase(goods.getCouponInfo())) { + data.put("couponAmount", MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount())); + data.put("coupon", true); + // 鑰佺増鏈吋瀹� + data.put("quan", true); + } else { + data.put("coupon", false); + // 鑰佺増鏈吋瀹� + data.put("quan", true); + } - @Override - public void run() { - try { - if (!StringUtil.isNullOrEmpty(tempUid)) - userShareGoodsGroupService.updateBrowseRecord(Long.parseLong(tempUid), Long.parseLong(id), 1); - } catch (NumberFormatException e) { - e.printStackTrace(); - } catch (UserShareGoodsRecordException e) { - e.printStackTrace(); - } - } - }); - return; - } + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); - /** - * 浜笢鍒嗕韩鍟嗗搧淇℃伅 - * - * @param acceptData - * @param id - * @param uid - * @param callback - * @param out - */ - @RequestMapping(value = "getJDGoodsDetail") - public void getJDGoodsDetail(final AcceptData acceptData, final Long id, String uid, String callback, - PrintWriter out) { - if (id == null) { - out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爄d")); - return; - } + final String tempUid = uid; + ThreadUtil.run(new Runnable() { - if (!StringUtil.isNullOrEmpty(uid)) { - uid = AESUtil.decrypt(uid, Constant.UIDAESKEY); - } + @Override + public void run() { + try { + if (!StringUtil.isNullOrEmpty(tempUid)) + userShareGoodsGroupService.updateBrowseRecord(Long.parseLong(tempUid), id, 1); + } catch (NumberFormatException e) { + e.printStackTrace(); + } catch (UserShareGoodsRecordException e) { + e.printStackTrace(); + } + } + }); + return; + } - JDGoods jdGoods = JDApiUtil.queryGoodsDetail(id); - if (jdGoods == null) { - jdGoods = JDApiUtil.getGoodsDetail(id); - } + /** + * 浜笢鍒嗕韩鍟嗗搧淇℃伅 + * + * @param acceptData + * @param id + * @param uid + * @param callback + * @param out + */ + @RequestMapping(value = "getJDGoodsDetail") + public void getJDGoodsDetail(final AcceptData acceptData, final String id, String uid, String callback, + PrintWriter out) { + if (id == null) { + out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爄d")); + return; + } - if (jdGoods == null) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鍟嗗搧淇℃伅鑾峰彇澶辫触"))); - return; - } + if (!StringUtil.isNullOrEmpty(uid)) { + uid = AESUtil.decrypt(uid, Constant.UIDAESKEY); + } - List<String> imageList = jdGoods.getImageList(); - if (imageList == null) { - imageList = new ArrayList<>(); - imageList.add(jdGoods.getPicUrl()); - } + JDGoods jdGoods = JDApiUtil.queryGoodsDetail(id); + if (jdGoods == null) { + jdGoods = JDApiUtil.getGoodsDetail(id); + } - boolean hasCoupon = false; - String couponUrl = null; - BigDecimal discount = new BigDecimal(0); - JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(jdGoods); - if (couponInfo != null) { - hasCoupon = true; - discount = couponInfo.getDiscount(); - couponUrl = couponInfo.getLink(); - } + if (jdGoods == null) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鍟嗗搧淇℃伅鑾峰彇澶辫触"))); + return; + } - boolean jdzy = false; - String owner = jdGoods.getOwner(); - if (!StringUtil.isNullOrEmpty(owner) && "g".equalsIgnoreCase(owner)) { - jdzy = true; - } + List<String> imageList = jdGoods.getImageList(); + if (imageList == null) { + imageList = new ArrayList<>(); + imageList.add(jdGoods.getPicUrl()); + } - String materialId = "https://item.jd.com/" + id + ".html"; - String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_SHARE + "", - uid); + boolean hasCoupon = false; + String couponUrl = null; + BigDecimal discount = new BigDecimal(0); + JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(jdGoods); + if (couponInfo != null) { + hasCoupon = true; + discount = couponInfo.getDiscount(); + couponUrl = couponInfo.getLink(); + } - int priceType = 1; - BigDecimal price = jdGoods.getPrice(); - ; - JDPingouInfo pinGouInfo = jdGoods.getPinGouInfo(); - if (pinGouInfo != null) { - priceType = 2; // 鎷艰喘浠� - price = pinGouInfo.getPingouPrice(); - } + boolean jdzy = false; + String owner = jdGoods.getOwner(); + if (!StringUtil.isNullOrEmpty(owner) && "g".equalsIgnoreCase(owner)) { + jdzy = true; + } - JSONObject data = new JSONObject(); - data.put("jdzy", jdzy); - data.put("imgs", imageList); - data.put("title", jdGoods.getSkuName()); - data.put("zkPrice", price); - data.put("priceType", priceType); - data.put("coupon", hasCoupon); - data.put("couponAmount", discount); - data.put("couponPrice", JDUtil.getQuanPrice(jdGoods)); - data.put("helpLink", configService.getValue("jd_share_h5_help_link",acceptData.getSystem())); - data.put("jumpLink", jumpLink); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + String materialId = "https://item.jd.com/" + id + ".html"; + String jumpLink = null; + try { + jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.share), + uid); + } catch (Exception e) { + e.printStackTrace(); + } - final String tempUid = uid; - ThreadUtil.run(new Runnable() { - @Override - public void run() { - try { - if (!StringUtil.isNullOrEmpty(tempUid)) - userShareGoodsGroupService.updateBrowseNum(Long.parseLong(tempUid), id, - Constant.SOURCE_TYPE_JD); - } catch (NumberFormatException e) { - e.printStackTrace(); - } catch (UserShareGoodsRecordException e) { - e.printStackTrace(); - } - } - }); - return; - } + int priceType = 1; + BigDecimal price = jdGoods.getPrice(); + JDPingouInfo pinGouInfo = jdGoods.getPinGouInfo(); + if (pinGouInfo != null) { + priceType = 2; // 鎷艰喘浠� + price = pinGouInfo.getPingouPrice(); + } - /** - * 鎷煎澶氬垎浜晢鍝佽鎯� - * - * @param acceptData - * @param id - * @param uid - * @param callback - * @param out - */ - @RequestMapping(value = "getPDDGoodsDetail") - public void getPDDGoodsDetail(final AcceptData acceptData, final Long id, String uid, String callback, - PrintWriter out) { - if (id == null) { - out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爄d")); - return; - } + JSONObject data = new JSONObject(); + data.put("jdzy", jdzy); + data.put("imgs", imageList); + data.put("title", jdGoods.getSkuName()); + data.put("zkPrice", price); + data.put("priceType", priceType); + data.put("coupon", hasCoupon); + data.put("couponAmount", discount); + data.put("couponPrice", JDUtil.getCouponPrice(jdGoods)); + data.put("helpLink", configService.getValue("jd_share_h5_help_link", acceptData.getSystem())); + data.put("jumpLink", jumpLink); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - if (!StringUtil.isNullOrEmpty(uid)) { - uid = AESUtil.decrypt(uid, Constant.UIDAESKEY); - } + final String tempUid = uid; + ThreadUtil.run(new Runnable() { + @Override + public void run() { + try { + if (!StringUtil.isNullOrEmpty(tempUid)) + userShareGoodsGroupService.updateBrowseNum(Long.parseLong(tempUid), id+"", + Constant.SOURCE_TYPE_JD); + } catch (NumberFormatException e) { + e.printStackTrace(); + } catch (UserShareGoodsRecordException e) { + e.printStackTrace(); + } + } + }); + return; + } - PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(id); - if (pddGoods == null) { - out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鍟嗗搧淇℃伅鑾峰彇澶辫触"))); - return; - } + /** + * 鎷煎澶氬垎浜晢鍝佽鎯� + * + * @param acceptData + * @param id + * @param uid + * @param callback + * @param out + */ + @RequestMapping(value = "getPDDGoodsDetail") + public void getPDDGoodsDetail(final AcceptData acceptData, final String id, String uid, String callback, + PrintWriter out) { + if (id == null) { + out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爄d")); + return; + } - List<String> imageList = null; - String[] goodsGalleryUrls = pddGoods.getGoodsGalleryUrls(); - if (goodsGalleryUrls != null) { - imageList = Arrays.asList(goodsGalleryUrls); - } - if (imageList == null) { - imageList = new ArrayList<>(); - String goodsImageUrl = pddGoods.getGoodsImageUrl(); - if (!StringUtil.isNullOrEmpty(goodsImageUrl)) { - imageList.add(goodsImageUrl); - } - } + if (!StringUtil.isNullOrEmpty(uid)) { + uid = AESUtil.decrypt(uid, Constant.UIDAESKEY); + } - BigDecimal hundred = new BigDecimal(100); - Boolean hasCoupon = pddGoods.getHasCoupon(); - BigDecimal amount = new BigDecimal(0); - if (hasCoupon != null && hasCoupon) { - amount = MoneyBigDecimalUtil.div(new BigDecimal(pddGoods.getCouponDiscount()), hundred).setScale(2); - } else { - hasCoupon = false; - } + PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(id); + if (pddGoods == null) { + out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鍟嗗搧淇℃伅鑾峰彇澶辫触"))); + return; + } - String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(id, PinDuoDuoApiUtil.PID_SHARE + "", uid); + List<String> imageList = null; + String[] goodsGalleryUrls = pddGoods.getGoodsGalleryUrls(); + if (goodsGalleryUrls != null) { + imageList = Arrays.asList(goodsGalleryUrls); + } + if (imageList == null) { + imageList = new ArrayList<>(); + String goodsImageUrl = pddGoods.getGoodsImageUrl(); + if (!StringUtil.isNullOrEmpty(goodsImageUrl)) { + imageList.add(goodsImageUrl); + } + } - JSONObject data = new JSONObject(); - data.put("imgs", imageList); - data.put("title", pddGoods.getGoodsName()); - data.put("zkPrice", MoneyBigDecimalUtil.div(new BigDecimal(pddGoods.getMinGroupPrice()), hundred).setScale(2)); - data.put("coupon", hasCoupon); - data.put("couponAmount", amount); - data.put("couponPrice", PinDuoDuoUtil.getQuanPrice(pddGoods)); - data.put("helpLink", configService.getValue("pdd_share_h5_help_link",acceptData.getSystem())); - data.put("jumpLink", jumpLink); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + BigDecimal hundred = new BigDecimal(100); + Boolean hasCoupon = pddGoods.getHasCoupon(); + BigDecimal amount = new BigDecimal(0); + if (hasCoupon != null && hasCoupon) { + amount = MoneyBigDecimalUtil.div(new BigDecimal(pddGoods.getCouponDiscount()), hundred).setScale(2); + } else { + hasCoupon = false; + } - final String tempUid = uid; - ThreadUtil.run(new Runnable() { - @Override - public void run() { - try { - if (!StringUtil.isNullOrEmpty(tempUid)) - userShareGoodsGroupService.updateBrowseNum(Long.parseLong(tempUid), id, - Constant.SOURCE_TYPE_PDD); - } catch (NumberFormatException e) { - e.printStackTrace(); - } catch (UserShareGoodsRecordException e) { - e.printStackTrace(); - } - } - }); - return; - } + String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(pddGoods.getGoodsSign(), pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.share), uid); + + JSONObject data = new JSONObject(); + data.put("imgs", imageList); + data.put("title", pddGoods.getGoodsName()); + data.put("zkPrice", MoneyBigDecimalUtil.div(new BigDecimal(pddGoods.getMinGroupPrice()), hundred).setScale(2)); + data.put("coupon", hasCoupon); + data.put("couponAmount", amount); + data.put("couponPrice", PinDuoDuoUtil.getCouponPrice(pddGoods)); + data.put("helpLink", configService.getValue("pdd_share_h5_help_link", acceptData.getSystem())); + data.put("jumpLink", jumpLink); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + + final String tempUid = uid; + ThreadUtil.run(new Runnable() { + @Override + public void run() { + try { + if (!StringUtil.isNullOrEmpty(tempUid)) + userShareGoodsGroupService.updateBrowseNum(Long.parseLong(tempUid), id+"", + Constant.SOURCE_TYPE_PDD); + } catch (NumberFormatException e) { + e.printStackTrace(); + } catch (UserShareGoodsRecordException e) { + e.printStackTrace(); + } + } + }); + return; + } } -- Gitblit v1.8.0