From 8cb7ec4a35a38ae91d0eed17cde711e81d2b2bbf Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期二, 14 五月 2019 11:37:49 +0800 Subject: [PATCH] 合并 --- fanli/src/main/java/com/yeshi/fanli/controller/client/GoodsController.java | 141 +++++++++++++++++++++++++++++++++++++--------- 1 files changed, 112 insertions(+), 29 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/GoodsController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/GoodsController.java index 1dba1d3..da592a8 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/GoodsController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/GoodsController.java @@ -22,12 +22,14 @@ import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.goods.ShareGoodsService; import com.yeshi.fanli.service.inter.monitor.MonitorService; +import com.yeshi.fanli.service.inter.taobao.TaoBaoBuyRelationMapService; import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService; import com.yeshi.fanli.service.inter.user.TBPidService; import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService; import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.StringUtil; +import com.yeshi.fanli.util.TaoBaoConstant; import com.yeshi.fanli.util.factory.MonitorFactory; import com.yeshi.fanli.util.taobao.TaoKeApiUtil; @@ -55,6 +57,9 @@ @Resource private UserInfoService userInfoService; + @Resource + private TaoBaoBuyRelationMapService taoBaoBuyRelationMapService; + /** * 鑾峰彇娣樺疂鐨勫垎浜摼鎺� * @@ -65,7 +70,7 @@ * @param out */ @RequestMapping(value = "gettaobaolink") - public void getTaobaoShareLink(AcceptData acceptData, Long uid, Long auctionId, HttpServletRequest request, + public void getTaoBaoLink(AcceptData acceptData, Long uid, Long auctionId,String from, HttpServletRequest request, PrintWriter out) { if (uid == null || uid <= 0) { out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛ID涓嶈兘涓虹┖")); @@ -83,64 +88,95 @@ return; } + TaoBaoGoodsBrief goods = null; + + try { + goods = TaoKeApiUtil.getSimpleGoodsInfo(auctionId); + } catch (TaobaoGoodsDownException e) { + out.print(JsonUtil.loadFalseResult(3, "鍟嗗搧宸蹭笅鏋�")); + return; + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e, "鑾峰彇鍟嗗搧绠�鐗堣鎯呭嚭閿�", auctionId + ""); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + JSONObject data = new JSONObject(); boolean isNative = false; String pid = null; boolean specialConvert = false; + if (goods.getMaterialLibType() != null && goods.getMaterialLibType() == 1) { + specialConvert = true; + } else + specialConvert = false; + String specialId = null; + String relationId = null; // 鏌ヨ鐢ㄦ埛ID鏄惁缁戝畾浜嗕細鍛樿繍钀D UserExtraTaoBaoInfo userInfo = userExtraTaoBaoInfoService.getByUid(uid); if (userInfo != null && !StringUtil.isNullOrEmpty(userInfo.getSpecialId()) && userInfo.getSpecialValid() != null && userInfo.getSpecialValid() == true) { specialId = userInfo.getSpecialId(); + relationId = userInfo.getRelationId(); // 宸茬粡缁戝畾 - try { - TaoBaoGoodsBrief goods = TaoKeApiUtil.getSimpleGoodsInfo(auctionId); - if (goods.getMaterialLibType() != null && goods.getMaterialLibType() == 1) { - isNative = true; - specialConvert = true; - } else - isNative = false; - } catch (TaobaoGoodsDownException e) { - out.print(JsonUtil.loadFalseResult(3, "鍟嗗搧宸蹭笅鏋�")); - return; - } catch (Exception e) { - try { - LogHelper.errorDetailInfo(e, "鑾峰彇鍟嗗搧绠�鐗堣鎯呭嚭閿�", auctionId + ""); - } catch (Exception e1) { - e1.printStackTrace(); - } - } + if (specialConvert) { + isNative = true; + } else + isNative = false; - pid = Constant.TAOBAO_SPECIAL_PID_DEFAULT; + pid = TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT; } else {// 灏氭湭缁戝畾 isNative = true; } data.put("native", isNative); + + int pidType = PidUser.TYPE_FANLI_ANDROID; + if (acceptData.getPlatform().equalsIgnoreCase("ios")) + pidType = PidUser.TYPE_FANLI_IOS; try { - int pidType = PidUser.TYPE_FANLI_ANDROID; - if (acceptData.getPlatform().equalsIgnoreCase("ios")) - pidType = PidUser.TYPE_FANLI_IOS; TaoBaoLink taoBaoLink = null; - if (!StringUtil.isNullOrEmpty(specialId) && specialConvert) { - taoBaoLink = shareGoodsService.getTaoBaoLinkForBuyWithSpecial(uid, specialId, auctionId); - } else { - if (!specialConvert && !isNative) { + // 鏄繑鍒╁晢鍝佸簱鐨勫晢鍝� + if (specialConvert) { + if (!StringUtil.isNullOrEmpty(specialId)) { + taoBaoLink = shareGoodsService.getTaoBaoLinkForBuyWithSpecial(uid, specialId, auctionId); + data.put("native", true); + } else { + if (!specialConvert && !isNative) { + if (pidType == PidUser.TYPE_FANLI_ANDROID) + taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId, + tbPidService.getAndroidDefault().getPid()); + else + taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId, + tbPidService.getIOSDefault().getPid()); + } else + taoBaoLink = shareGoodsService.getTaoBaoLinkForBuy(uid, auctionId, pidType); + } + } else {// 涓嶆槸杩斿埄搴撶殑鍟嗗搧锛岀敤鐗规畩PID鏇夸唬 + try { + relationId = taoBaoBuyRelationMapService.getRelationId(uid); + } catch (Exception e) { + LogHelper.errorDetailInfo(e, "uid:" + uid, null); + } + if (!StringUtil.isNullOrEmpty(relationId)) {// + taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId, + TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID); + data.put("native", true); + } else { if (pidType == PidUser.TYPE_FANLI_ANDROID) taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId, tbPidService.getAndroidDefault().getPid()); else taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId, tbPidService.getIOSDefault().getPid()); - } else - taoBaoLink = shareGoodsService.getTaoBaoLinkForBuy(uid, auctionId, pidType); + } } - JSONObject link = new JSONObject(); link.put("clickUrl", taoBaoLink.getClickUrl()); link.put("couponUrl", taoBaoLink.getCouponLink()); @@ -180,4 +216,51 @@ } + /** + * 鏄惁鍦ㄥ弬涓庢帹骞� + */ + + /** + * 鏄惁鍦ㄥ弬涓庢帹骞� + * + * @param goodsId + * -鍟嗗搧ID + * @param goodsType + * -TB/JD + * @param out + */ + @RequestMapping(value = "isGoodsExtend") + public void isGoodsExtend(AcceptData acceptData, String goodsId, String goodsType, PrintWriter out) { + if (StringUtil.isNullOrEmpty(goodsId)) { + out.print(JsonUtil.loadFalseResult(1, "鏈弬涓庢帹骞�")); + return; + } + if (StringUtil.isNullOrEmpty(goodsType)) { + out.print(JsonUtil.loadFalseResult(2, "缂哄皯goodsType")); + return; + } + if ("TB".equalsIgnoreCase(goodsType)) { + TaoBaoGoodsBrief goods = null; + try { + goods = TaoKeApiUtil.getSimpleGoodsInfo(Long.parseLong(goodsId)); + } catch (NumberFormatException e) { + e.printStackTrace(); + } catch (TaobaoGoodsDownException e) { + e.printStackTrace(); + } + + JSONObject data = new JSONObject(); + + if (goods == null) { + data.put("extend", false); + data.put("url", "https://h5.m.taobao.com/awp/core/detail.htm?id=" + goodsId); + } else { + data.put("extend", true); + } + out.print(JsonUtil.loadTrueResult(data)); + } else { + out.print(JsonUtil.loadFalseResult(3, "鏆備笉鏀寔鍏朵粬鍟嗗搧绫诲瀷")); + } + } + } -- Gitblit v1.8.0