From 7e7db2fa55a9a3af46d4fd8ede0dee147f101d64 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期六, 09 五月 2020 21:41:27 +0800 Subject: [PATCH] 2.1需求 --- fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/SearchController.java | 65 ++++++++++++++++++++++++++------ 1 files changed, 53 insertions(+), 12 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/SearchController.java b/fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/SearchController.java index a1663fc..64bf7d7 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/SearchController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/SearchController.java @@ -1,6 +1,7 @@ package com.yeshi.fanli.controller.wxmp.v1; import java.io.PrintWriter; +import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -24,11 +25,16 @@ import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; import com.yeshi.fanli.dto.pdd.PDDGoodsResult; import com.yeshi.fanli.dto.pdd.PDDSearchFilter; +import com.yeshi.fanli.entity.accept.AcceptData; +import com.yeshi.fanli.entity.bus.search.HotSearch; import com.yeshi.fanli.entity.goods.CommonGoods; import com.yeshi.fanli.entity.jd.JDGoods; +import com.yeshi.fanli.entity.system.ConfigKeyEnum; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.brand.BrandInfoService; import com.yeshi.fanli.service.inter.config.ConfigService; +import com.yeshi.fanli.service.inter.config.HotSearchService; +import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; import com.yeshi.fanli.service.manger.goods.jd.JDGoodsLinkParseManager; import com.yeshi.fanli.tag.PageEntity; @@ -56,6 +62,9 @@ @Resource private HongBaoManageService hongBaoManageService; + + @Resource + private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; @Resource(name = "taskExecutor") private TaskExecutor executor; @@ -65,7 +74,9 @@ @Resource private JDGoodsLinkParseManager jdGoodsLinkParseManager; - + + @Resource + private HotSearchService hotSearchService; /** * 绮樿创鏉夸俊鎭帹鑽� @@ -81,7 +92,7 @@ out.print(JsonUtil.loadFalseResult("鍊间负绌�")); return; } - + // 鍘婚櫎鍓嶅悗绌烘牸 int type = 1; text = text.trim(); @@ -162,7 +173,7 @@ } } } - + if (commonGoods == null) { out.println(JsonUtil.loadFalseResult("鏆傛湭鎵惧埌璇ュ晢鍝侊紝璇风◢鍚庡啀璇曪紒")); return; @@ -178,17 +189,48 @@ data.put("goods", goodsJSON); out.print(JsonUtil.loadTrueResult(data)); return; - } - + } + JSONObject data = new JSONObject(); Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); data.put("type", type); - data.put("goods", gson.toJson(GoodsDetailVOFactory.convertCommonGoods(commonGoods, hongBaoManageService.getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion())))); + data.put("goods", gson.toJson(GoodsDetailVOFactory.convertCommonGoods(commonGoods, + orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion())))); out.print(JsonUtil.loadTrueResult(data)); return; } + /** + * 鐑棬鎼滅储 + * + * @param acceptData + * @param goodsType + * @param out + */ + @RequestMapping(value = "gethotsearch", method = RequestMethod.POST) + public void getHotSearch(AcceptData acceptData, Integer goodsType, PrintWriter out) { + // 榛樿娣樺疂 + if (goodsType == null) { + goodsType = Constant.SOURCE_TYPE_TAOBAO; + } + + List<HotSearch> list = hotSearchService.getHotSearchCache(goodsType); + if (list == null || list.size() == 0) { + out.print(JsonUtil.loadFalseResult("娌℃湁鏁版嵁")); + return; + } + List<String> hotSearchList = new ArrayList<String>(); + if(list!=null) + for (HotSearch hot : list) + hotSearchList.add(hot.getName()); + + JSONObject data = new JSONObject(); + data.put("count", list.size()); + data.put("hotSearchList", hotSearchList); + data.put("helpLink", configService.get(ConfigKeyEnum.newerGonglue.getKey())); + out.print(JsonUtil.loadTrueResult(data)); + } /** * 鎼滅储鍊欓�夎瘝 @@ -252,11 +294,11 @@ out.print(JsonUtil.loadFalseResult(1, "璇疯緭鍏ユ悳绱㈠唴瀹�")); return; } - + if (page == null || page < 1) { page = 1; } - + final String searchkey = key.trim(); if (searchkey.startsWith("http://") || searchkey.startsWith("https://")) { JSONObject data = new JSONObject(); @@ -279,7 +321,6 @@ } } - /** * 浜笢 * @@ -296,7 +337,7 @@ JDSearchResult result = null; boolean hasCoupon = false; - String way = configService.get("jd_api_search_key"); + String way = configService.get(ConfigKeyEnum.jdApiSearchKey.getKey()); if ("1".equals(way)) { JDFilter filterAPI = new JDFilter(); filterAPI.setKeyword(SearchFilterUtil.filterSearchContent(key)); @@ -436,7 +477,7 @@ if (goodsList != null && goodsList.size() > 0) { Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); - ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(), + ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion()); for (JDGoods goods : goodsList) { GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO); @@ -518,7 +559,7 @@ Gson gson = JsonUtil.getApiCommonGson(); List<PDDGoodsDetail> goodsList = result.getGoodsList(); if (goodsList != null && goodsList.size() > 0) { - ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(), + ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion()); for (PDDGoodsDetail goods : goodsList) { -- Gitblit v1.8.0