From 5737c1229b265456415a20c71f12229b941a4629 Mon Sep 17 00:00:00 2001 From: admin <2780501319@qq.com> Date: 星期五, 27 九月 2019 00:11:54 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java | 116 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 98 insertions(+), 18 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 cc30a88..d7c58aa 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 @@ -68,6 +68,7 @@ import com.yeshi.fanli.util.taobao.SearchFilterUtil; import com.yeshi.fanli.util.taobao.TaoBaoUtil; import com.yeshi.fanli.util.taobao.TaoKeApiUtil; +import com.yeshi.fanli.vo.brand.BrandInfoVO; import com.yeshi.fanli.vo.brand.TaoBaoShopVO; import com.yeshi.fanli.vo.goods.GoodsDetailVO; import com.yeshi.fanli.vo.msg.TokenVO; @@ -175,7 +176,7 @@ return; } - if (analysisTaoToken(text, out)) { + if (analysisTaoToken(acceptData, text, out)) { return; } @@ -189,6 +190,7 @@ return; } + int type = 3; CommonGoods commonGoods = null; text = matcher.group(); @@ -214,7 +216,8 @@ } tb = TaoBaoUtil.isAlimama(id); if (tb == null) { - tb = TaoBaoUtil.parsePhoneTmAndTb(id); + type = 4; + tb = TaoBaoUtil.getTmallGoodsInfo(id); } } else if (text.contains("http://zmnxbc.com")) { // 鎵嬫満绔ぉ鐚獳PP鍒嗕韩 tb = TaoBaoUtil.parsePhoneShareUrlByTM(text); @@ -225,7 +228,8 @@ id = map.get("id").replace("}", ""); tb = TaoBaoUtil.isAlimama(id); if (tb == null) { - tb = TaoBaoUtil.parsePhoneTmAndTb(id); + type = 4; + tb = TaoBaoUtil.getTmallGoodsInfo(id); } } else { tb = TaoBaoUtil.parsePhoneShareUrlByTB(text); @@ -234,8 +238,17 @@ String jdId = JDUtil.getJDGoodsId(text); if (!StringUtil.isNullOrEmpty(jdId)) { JDGoods goods = JDApiUtil.getGoodsDetail(Long.parseLong(jdId)); - if (goods != null) + if (goods != null) { commonGoods = CommonGoodsFactory.create(goods); + } else { + type = 4; + goods = JDUtil.getSimpleGoodsInfo(jdId); + if (goods != null) { + commonGoods = new CommonGoods(); + commonGoods.setTitle(goods.getSkuName()); + commonGoods.setPicture(goods.getPicUrl()); + } + } } else { String pddId = PinDuoDuoUtil.getPDDGoodsId(text); if (!StringUtil.isNullOrEmpty(pddId)) { @@ -246,14 +259,43 @@ } } } - + if (tb == null && commonGoods == null) { out.println(JsonUtil.loadFalseResult("鏆傛湭鎵惧埌璇ュ晢鍝侊紝璇风◢鍚庡啀璇曪紒")); return; } - + + if (type == 4) { + if (!VersionUtil.greaterThan_2_0_1(acceptData.getPlatform(), acceptData.getVersion())) { + out.println(JsonUtil.loadFalseResult("鏆傛湭鎵惧埌璇ュ晢鍝侊紝璇风◢鍚庡啀璇曪紒")); + return; + } + + JSONObject data = new JSONObject(); + if (tb != null) { + commonGoods = new CommonGoods(); + commonGoods.setTitle(tb.getTitle()); + commonGoods.setPicture(tb.getPictUrl()); + } + + if (StringUtil.isNullOrEmpty(commonGoods.getTitle()) || StringUtil.isNullOrEmpty(commonGoods.getPicture())) { + out.println(JsonUtil.loadFalseResult("鏆傛湭鎵惧埌璇ュ晢鍝侊紝璇风◢鍚庡啀璇曪紒")); + return; + } + + JSONObject goodsJSON = new JSONObject(); + goodsJSON.put("title", commonGoods.getTitle()); + goodsJSON.put("pictUrl", commonGoods.getPicture()); + + data.put("type", type); + data.put("desc", "璇ュ晢鍝佹棤鎺ㄥ箍淇℃伅"); + data.put("goods", goodsJSON); + out.print(JsonUtil.loadTrueResult(data)); + return; + } + + JSONObject data = new JSONObject(); - if (VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) { if (tb != null) { TaoBaoGoodsBrief goodsBrief = null; @@ -268,11 +310,12 @@ } commonGoods = CommonGoodsFactory.create(goodsBrief); } + BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); - data.put("type", 3); + data.put("type", type); data.put("goods", gson.toJson(GoodsDetailVOFactory.convertCommonGoods(commonGoods, null, fanLiRate, shareRate))); out.print(JsonUtil.loadTrueResult(data)); @@ -310,7 +353,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); @@ -323,6 +366,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()); @@ -481,18 +550,18 @@ /*--------- 浜笢鍟嗗搧 -------*/ if (goodsType.intValue() == Constant.SOURCE_TYPE_JD) { - searchJDGoods(searchkey, page, filter, order, out); + searchJDGoods(acceptData, searchkey, page, filter, order, out); return; } /*-------- 鎷煎澶氬晢鍝� -------*/ if (goodsType.intValue() == Constant.SOURCE_TYPE_PDD) { - searchPDDGoods(searchkey, page, filter, order, out); + searchPDDGoods(acceptData, searchkey, page, filter, order, out); return; } /*-------- 娣樺疂鍟嗗搧 -------*/ - searchTaoBaoGoods(searchkey, page, filter, order, out); + searchTaoBaoGoods(acceptData, searchkey, page, filter, order, out); } /** @@ -506,7 +575,7 @@ * @param endprice * @return */ - private void searchTaoBaoGoods(String key, Integer page, String filter, Integer order, PrintWriter out) { + private void searchTaoBaoGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order, PrintWriter out) { SearchFilter sf = new SearchFilter(); sf.setKey(SearchFilterUtil.filterSearchContent(key)); sf.setPage(page); @@ -600,12 +669,23 @@ data.put("result", gson.toJson(list)); data.put("count", result.getTaoBaoHead().getDocsfound()); - if (page == 1) { - // 绗竴椤佃繑鍥炲簵閾轰俊鎭� + if (page == 1) { // 绗竴椤佃繑鍥炲簵閾轰俊鎭� List<TaoBaoShopVO> listShop = taoBaoShopService.getShopByKeyV2(key); if (listShop != null && listShop.size() > 0 && listShop.get(0).getListGoodsVO() != null && listShop.get(0).getListGoodsVO().size() > 2) { - data.put("shop", JsonUtil.getApiCommonGson().toJson(listShop.get(0))); + String platform = acceptData.getPlatform(); + TaoBaoShopVO taoBaoShop = listShop.get(0); + if (("ios".equalsIgnoreCase(platform) && VersionUtil.greaterThan_2_0(platform, acceptData.getVersion())) + || ("android".equalsIgnoreCase(platform) && VersionUtil.greaterThan_2_0_1(platform, acceptData.getVersion()))) { + BrandInfoVO brandInfoVO = new BrandInfoVO(); + brandInfoVO.setId(taoBaoShop.getId()); + brandInfoVO.setName(taoBaoShop.getShopName()); + brandInfoVO.setIcon(taoBaoShop.getShopIcon()); + brandInfoVO.setListGoods(taoBaoShop.getListGoodsVO()); + data.put("shop", JsonUtil.getApiCommonGson().toJson(brandInfoVO)); + } else { + data.put("shop", JsonUtil.getApiCommonGson().toJson(taoBaoShop)); + } } } out.print(JsonUtil.loadTrueResult(data)); @@ -622,7 +702,7 @@ * @param endprice * @return */ - private void searchJDGoods(String key, Integer page, String filter, Integer order, PrintWriter out) { + private void searchJDGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order, PrintWriter out) { JDSearchResult result = null; boolean hasCoupon = false; @@ -797,7 +877,7 @@ * @param endprice * @return */ - private void searchPDDGoods(String key, Integer page, String filter, Integer order, PrintWriter out) { + private void searchPDDGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order, PrintWriter out) { PDDSearchFilter pddfilter = new PDDSearchFilter(); pddfilter.setKw(SearchFilterUtil.filterSearchContent(key)); pddfilter.setPage(page); -- Gitblit v1.8.0