From 41aedac31eb4c5b9f7b98bacec18c45b3926d69c Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期五, 27 九月 2019 16:57:54 +0800 Subject: [PATCH] 京东商品 券bug --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java | 42 ++++++++++++++++++++++++++++++++++++++---- 1 files changed, 38 insertions(+), 4 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java index fe2098a..98395d6 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java @@ -176,12 +176,11 @@ return; } - if (analysisTaoToken(text, out)) { + if (analysisTaoToken(acceptData, text, out)) { return; } JSONObject root = new JSONObject(); - root.put("type", 2); JSONObject data = new JSONObject(); data.put("title", text); @@ -253,8 +252,17 @@ String pddId = PinDuoDuoUtil.getPDDGoodsId(text); if (!StringUtil.isNullOrEmpty(pddId)) { PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(pddId)); - if (goods != null) + if (goods != null) { commonGoods = CommonGoodsFactory.create(goods); + } else { + type = 4; + goods = PinDuoDuoUtil.getPDDGoodsInfo(pddId); + if(goods != null) { + commonGoods = new CommonGoods(); + commonGoods.setTitle(goods.getGoodsName()); + commonGoods.setPicture(goods.getGoodsThumbnailUrl()); + } + } } } } @@ -353,7 +361,7 @@ out.print(JsonUtil.loadTrueResult(root)); } - private boolean analysisTaoToken(String text, PrintWriter out) { + private boolean analysisTaoToken(AcceptData acceptData, String text, PrintWriter out) { String token = StringUtil.picUpTaoToken(text); if (!StringUtil.isNullOrEmpty(token)) { Long auctionId = TaoKeApiUtil.tokenConvertAuctionId(token); @@ -366,6 +374,32 @@ } if (tb != null) { + if (VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) { + TaoBaoGoodsBrief goodsBrief = null; + try { + goodsBrief = TaoKeApiUtil.searchGoodsDetail(tb.getAuctionId()); + } catch (TaobaoGoodsDownException e) { + e.printStackTrace(); + } + + if (goodsBrief == null) { + out.println(JsonUtil.loadFalseResult("鏆傛湭鎵惧埌璇ュ晢鍝侊紝璇风◢鍚庡啀璇曪紒")); + return false; + } + + BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); + BigDecimal shareRate = hongBaoManageService.getShareRate(); + Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) + .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); + + JSONObject data = new JSONObject(); + data.put("type", 3); + data.put("goods", gson.toJson(GoodsDetailVOFactory.convertTaoBao(goodsBrief, null, fanLiRate, shareRate))); + out.print(JsonUtil.loadTrueResult(data)); + return true; + } + + JSONObject data = new JSONObject(); JSONObject taoBaoGoodsJSON = new JSONObject(); taoBaoGoodsJSON.put("title", tb.getTitle()); -- Gitblit v1.8.0