From eda623f37c3260f4b4657e34a8a39798c72432b1 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期日, 28 六月 2020 15:49:14 +0800 Subject: [PATCH] 搜索接口增加小黄条返回 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java | 84 ++++++++++++++++++++++++++++++------------ 1 files changed, 60 insertions(+), 24 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 ba4b9b5..21dc4a0 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 @@ -24,12 +24,14 @@ 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.dto.suning.SuningCommodityInfo; import com.yeshi.fanli.dto.suning.SuningGoodsInfo; import com.yeshi.fanli.dto.suning.SuningQueryModel; import com.yeshi.fanli.dto.vip.VIPSearchFilter; import com.yeshi.fanli.dto.vip.VIPSearchResult; import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo; import com.yeshi.fanli.entity.accept.AcceptData; +import com.yeshi.fanli.entity.bus.help.AppPageNotification; import com.yeshi.fanli.entity.goods.CommonGoods; import com.yeshi.fanli.entity.jd.JDGoods; import com.yeshi.fanli.entity.system.ConfigKeyEnum; @@ -44,6 +46,7 @@ import com.yeshi.fanli.service.inter.config.BusinessSystemService; import com.yeshi.fanli.service.inter.config.ConfigService; import com.yeshi.fanli.service.inter.config.SuperHotSearchService; +import com.yeshi.fanli.service.inter.help.AppPageNotificationService; import com.yeshi.fanli.service.inter.lable.QualityGoodsService; import com.yeshi.fanli.service.inter.lable.TaoKeGoodsService; import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; @@ -149,6 +152,9 @@ @Resource private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; + + @Resource + private AppPageNotificationService appPageNotificationService; /** * 绮樿创鏉夸俊鎭帹鑽� @@ -432,7 +438,7 @@ */ @RequestMapping(value = "searchGoods") public void searchGoods(AcceptData acceptData, Integer goodsType, String key, Integer page, String filter, - Integer order, Long uid, HttpSession session, PrintWriter out) { + Integer order, Long uid, String notifyType, HttpSession session, PrintWriter out) { if (goodsType == null || goodsType < 1 || goodsType > 5) { out.print(JsonUtil.loadFalseResult(1, "璇蜂紶閫掓纭钩鍙板弬鏁�")); @@ -491,33 +497,48 @@ out.print(JsonUtil.loadTrueResult(data)); return; } + AppPageNotification ap = null; + if (page == 1) { + ap = appPageNotificationService.getValidNotificationByTypeCache(notifyType, acceptData.getPlatform(), + Integer.parseInt(acceptData.getVersion())); + // 娌℃湁閫氱煡 + if (ap == null || !ap.getShow()) { + ap = null; + } + + // else {// 鏈夐�氱煡 + // Gson gson = new + // GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); + // out.print(JsonUtil.loadTrueResult(gson.toJson(ap))); + // } + } /*--------- 浜笢鍟嗗搧 -------*/ if (goodsType.intValue() == Constant.SOURCE_TYPE_JD) { - searchJDGoods(acceptData, searchkey, page, filter, order, out); + searchJDGoods(acceptData, searchkey, page, filter, order, ap, out); return; } /*-------- 鎷煎澶氬晢鍝� -------*/ if (goodsType.intValue() == Constant.SOURCE_TYPE_PDD) { - searchPDDGoods(acceptData, searchkey, page, filter, order, out); + searchPDDGoods(acceptData, searchkey, page, filter, order, ap, out); return; } /*-------- 鍞搧浼氬晢鍝� ------*/ if (goodsType.intValue() == Constant.SOURCE_TYPE_VIP) { - searchVIPGoods(acceptData, searchkey, page, filter, order, out); + searchVIPGoods(acceptData, searchkey, page, filter, order, ap, out); return; } /*-------- 鑻忓畞鍟嗗搧 ------*/ if (goodsType.intValue() == Constant.SOURCE_TYPE_SUNING) { - searchSuningGoods(acceptData, searchkey, page, filter, order, out); + searchSuningGoods(acceptData, searchkey, page, filter, order, ap, out); return; } /*-------- 娣樺疂鍟嗗搧 -------*/ - searchTaoBaoGoods(acceptData, searchkey, page, filter, order, out); + searchTaoBaoGoods(acceptData, searchkey, page, filter, order, ap, out); } @@ -533,7 +554,7 @@ * @return */ private void searchTaoBaoGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order, - PrintWriter out) { + AppPageNotification ap, PrintWriter out) { SearchFilter sf = new SearchFilter(); sf.setKey(SearchFilterUtil.filterSearchContent(key)); sf.setPage(page); @@ -663,7 +684,15 @@ } } - out.print(JsonUtil.loadTrueResult(data)); + out.print(JsonUtil.loadTrueResult(buildSearchResult(data, ap))); + } + + private JSONObject buildSearchResult(JSONObject data, AppPageNotification ap) { + if (ap != null && data != null) { + Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); + data.put("notification", gson.toJson(ap)); + } + return data; } /** @@ -678,7 +707,7 @@ * @return */ private void searchJDGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order, - PrintWriter out) { + AppPageNotification ap, PrintWriter out) { JDSearchResult result = null; boolean hasCoupon = false; @@ -839,7 +868,7 @@ data.put("result", array); data.put("count", count); - out.print(JsonUtil.loadTrueResult(data)); + out.print(JsonUtil.loadTrueResult(buildSearchResult(data, ap))); } /** @@ -854,7 +883,7 @@ * @return */ private void searchPDDGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order, - PrintWriter out) { + AppPageNotification ap, PrintWriter out) { PDDSearchFilter pddfilter = new PDDSearchFilter(); pddfilter.setKw(SearchFilterUtil.filterSearchContent(key)); pddfilter.setPage(page); @@ -916,7 +945,7 @@ data.put("result", array); data.put("count", count); - out.print(JsonUtil.loadTrueResult(data)); + out.print(JsonUtil.loadTrueResult(buildSearchResult(data, ap))); } /** @@ -933,7 +962,7 @@ * @throws */ private void searchVIPGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order, - PrintWriter out) { + AppPageNotification ap, PrintWriter out) { VIPSearchFilter searchFilter = new VIPSearchFilter(); searchFilter.setKeyword(key); searchFilter.setPage(page); @@ -994,7 +1023,7 @@ data.put("result", array); data.put("count", count); - out.print(JsonUtil.loadTrueResult(data)); + out.print(JsonUtil.loadTrueResult(buildSearchResult(data, ap))); } /** @@ -1011,11 +1040,11 @@ * @throws */ private void searchSuningGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order, - PrintWriter out) { + AppPageNotification ap, PrintWriter out) { SuningQueryModel searchFilter = new SuningQueryModel(); searchFilter.setKeyword(key); searchFilter.setPageIndex(page); - searchFilter.setSize(Constant.PAGE_SIZE); + searchFilter.setSize(10); if (order != null) { if (order == 1) { // 閿�閲忛珮鍒颁綆 @@ -1067,16 +1096,23 @@ } } - int count = 0; JSONObject data = new JSONObject(); JSONArray array = new JSONArray(); - List<SuningGoodsInfo> resultList = SuningApiUtil.searchGoods(searchFilter); + List<SuningGoodsInfo> resultList = null; + List<SuningGoodsInfo> list = SuningApiUtil.searchGoodsOld(searchFilter); + if (list != null && list.size() > 0) { + List<String> listId = new ArrayList<>(); + for (SuningGoodsInfo goodsInfo : list) { + SuningCommodityInfo info = goodsInfo.getCommodityInfo(); + if (info != null) { + listId.add(info.getCommodityCode() + "-" + info.getSupplierCode()); + } + } + resultList = SuningApiUtil.getGoodsDetailList(listId); + } + if (resultList != null) { - if (resultList.size() == 0) - count = 0; - else - count = resultList.size() + 1; Gson gson = JsonUtil.getApiCommonGson(); if (resultList != null && resultList.size() > 0) { ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), @@ -1090,8 +1126,8 @@ } data.put("result", array); - data.put("count", count); - out.print(JsonUtil.loadTrueResult(data)); + data.put("count", 1000); + out.print(JsonUtil.loadTrueResult(buildSearchResult(data, ap))); } } -- Gitblit v1.8.0