From e04f81915e100107eca5fe16ba44898f3a0dbd55 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 04 七月 2020 18:48:06 +0800
Subject: [PATCH] redis指定数据库
---
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/SearchController.java | 174 +++++++++++++++++++++++++++++++++++----------------------
1 files changed, 107 insertions(+), 67 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/SearchController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/SearchController.java
index 22a2cff..dc2ef31 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/SearchController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/SearchController.java
@@ -10,6 +10,7 @@
import javax.annotation.Resource;
+import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -19,12 +20,13 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import com.yeshi.fanli.dto.dataoke.DaTaoKeGoodsResult;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.lable.QualityFactory;
import com.yeshi.fanli.entity.bus.recommend.Honest;
import com.yeshi.fanli.entity.bus.search.HotSearch;
-import com.yeshi.fanli.entity.bus.su.search.SuperHotSearch;
import com.yeshi.fanli.entity.system.BusinessSystem;
+import com.yeshi.fanli.entity.system.ConfigKeyEnum;
import com.yeshi.fanli.entity.taobao.PidUser;
import com.yeshi.fanli.entity.taobao.SearchFilter;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
@@ -33,22 +35,23 @@
import com.yeshi.fanli.entity.taobao.TaoBaoSearchNav;
import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
-import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
+import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
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.hongbao.HongBaoManageService;
+import com.yeshi.fanli.service.inter.config.HotSearchService;
import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
import com.yeshi.fanli.service.inter.lable.TaoKeGoodsService;
+import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
-import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
+import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service;
import com.yeshi.fanli.service.inter.user.HistorySearchService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.EhcacheUtil;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.ThreadUtil;
import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
+import com.yeshi.fanli.util.dataoke.DaTaoKeApiUtil;
import com.yeshi.fanli.util.taobao.SearchFilterUtil;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.vo.brand.TaoBaoShopVO;
@@ -68,10 +71,10 @@
private ConfigService configService;
@Resource
- private SuperHotSearchService superHotSearchSerivce;
-
+ private HotSearchService hotSearchService;
+
@Resource
- private HistorySearchService historySearchService;
+ private HistorySearchService historySearchService;
@Resource
private HongBaoManageService manageService;
@@ -80,48 +83,41 @@
private TaoBaoUnionConfigService taoBaoUnionConfigService;
@Resource
- private TaoKeGoodsService taoKeGoodsService;
-
- @Resource
private QualityGoodsService qualityGoodsService;
@Resource
private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
-
+
@Resource
private TaoBaoShopService taoBaoShopService;
-
@Resource
- private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
+ private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
+
+ /**
+ * 鐑棬鎼滅储
+ * @param acceptData
+ * @param goodsType
+ * @param out
+ */
@RequestMapping(value = "gethotsearch", method = RequestMethod.POST)
- public void getHotSearch(AcceptData acceptData, PrintWriter out) {
- BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
- acceptData.getPackages());
- if (system == null) {
- out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
- return;
+ public void getHotSearch(AcceptData acceptData, Integer goodsType, PrintWriter out) {
+ // 榛樿娣樺疂
+ if (goodsType == null) {
+ goodsType = Constant.SOURCE_TYPE_TAOBAO;
}
- List<SuperHotSearch> superHotSearchList = superHotSearchSerivce
- .getSuperHotSearchBySystemIdCache(system.getId());
- if (superHotSearchList == null || superHotSearchList.size() == 0) {
+
+ List<HotSearch> list = hotSearchService.getHotSearchCache(goodsType,acceptData.getSystem());
+ if (list == null || list.size() == 0) {
out.print(JsonUtil.loadFalseResult("娌℃湁鏁版嵁"));
return;
}
- List<HotSearch> hotSearchList = new ArrayList<HotSearch>();
- for (SuperHotSearch superHotSearch : superHotSearchList) {
- HotSearch hotSearch = superHotSearch.getHotSearch();
- if (hotSearch != null)
- hotSearchList.add(hotSearch);
- }
-
+
JSONObject data = new JSONObject();
- data.put("count", hotSearchList.size());
- data.put("hotSearchList", hotSearchList);
- String result = JsonUtil.loadTrueResult(data);
- out.print(result);
- return;
+ data.put("count", list.size());
+ data.put("hotSearchList", list);
+ out.print(JsonUtil.loadTrueResult(data));
}
@RequestMapping("specialSearch")
@@ -416,15 +412,20 @@
historySearchService.addHistorySearch(kw, bid);
-// BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
-// acceptData.getPackages());
-// if (system == null) {
-// out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
-// return;
-// }
+ // BusinessSystem system =
+ // businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+ // acceptData.getPackages());
+ // if (system == null) {
+ // out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
+ // return;
+ // }
if (!StringUtil.isNullOrEmpty(kw) && (kw.startsWith("http://") || kw.startsWith("https://"))) {
- out.print(JsonUtil.loadFalseResult("鏃犳硶鎼滅储閾炬帴"));
+ JSONObject data = new JSONObject();
+ data.put("result", new JSONArray());
+ data.put("count", 0);
+ data.put("nav", new JSONArray());
+ out.print(JsonUtil.loadTrueResult(data));
return;
}
@@ -455,12 +456,13 @@
JSONObject data = null;
if (!recommend) {
-
// 娣樺疂鎺ュ彛璇锋眰
- data = searchGoods(kw, page, filter, order, startprice, endprice);
+ data = searchGoods(kw, page, filter, order, startprice, endprice,acceptData.getSystem());
} else {
// 鎺ㄨ崘锛氱簿閫夊簱
- data = searchQualityGoods(kw, page, filter, order, startprice, endprice);
+ // data = searchQualityGoods(kw, page, filter, order, startprice,
+ // endprice);
+ data = searchDaTaoKeGoods(kw, page, filter, order, startprice, endprice);
}
// 鑾峰彇鎺ㄨ崘璇�
@@ -471,9 +473,10 @@
if (listRecommendWords == null || listRecommendWords.size() == 0) {
listRecommendWords = new ArrayList<String>();
}
-
- List<TaoBaoShopVO> listShop = taoBaoShopService.getShopByKey(kw);
- if (listShop != null && listShop.size() > 0) {
+
+ List<TaoBaoShopVO> listShop =taoBaoShopService.getShopByKey(kw);
+ if (listShop != null && listShop.size() > 0 && listShop.get(0).getListGoods() != null
+ && listShop.get(0).getListGoods().size() > 2) {
data.put("shop", JsonUtil.getApiCommonGson().toJson(listShop.get(0)));
}
}
@@ -497,7 +500,7 @@
* @return
*/
private JSONObject searchGoods(String kw, int page, String filter, String order, String startprice,
- String endprice) {
+ String endprice,SystemEnum system) {
page = page + 1;
SearchFilter sf = new SearchFilter();
@@ -600,24 +603,24 @@
int id = array.optJSONObject(i).optInt("id");
sf.setProvinceId(id);
} else if ("tkRate1".equalsIgnoreCase(ty)) {
- setSearchTkRate(0, sf);
+ setSearchTkRate(0, sf,system);
} else if ("tkRate2".equalsIgnoreCase(ty)) {
- setSearchTkRate(1, sf);
+ setSearchTkRate(1, sf,system);
} else if ("tkRate3".equalsIgnoreCase(ty)) {
- setSearchTkRate(2, sf);
+ setSearchTkRate(2, sf,system);
} else if ("tkRate4".equalsIgnoreCase(ty)) {
- setSearchTkRate(3, sf);
+ setSearchTkRate(3, sf,system);
} else if ("tkRate5".equalsIgnoreCase(ty)) {
- setSearchTkRate(4, sf);
+ setSearchTkRate(4, sf,system);
}
}
sf.setParams(params);
}
// 鎼滅储澶ф窐瀹�
- List<DaTaoKeDetail> daTaoKeList = null;
+ List<DaTaoKeDetailV2> daTaoKeList = null;
if (page == 1)
- daTaoKeList = daTaoKeGoodsDetailService.listByDtitle(kw);
+ daTaoKeList = daTaoKeGoodsDetailV2Service.listByDtitle(kw);
TaoBaoSearchResult result = TaoBaoUtil.search(sf);
if (result == null) {
@@ -669,8 +672,8 @@
try {
if (daTaoKeList != null && daTaoKeList.size() > 0) {
Collections.reverse(daTaoKeList);
- for (DaTaoKeDetail detail : daTaoKeList) {
- taoBaoGoodsBriefs.add(0,TaoBaoUtil.convert(detail));
+ for (DaTaoKeDetailV2 detail : daTaoKeList) {
+ taoBaoGoodsBriefs.add(0, TaoBaoUtil.convert(detail));
}
}
} catch (Exception e) {
@@ -724,7 +727,7 @@
/**
* 鎵ц鎼滅储绮鹃�夊簱
*
- * @param kw
+ * @param key
* @param page
* @param filter
* @param order
@@ -733,7 +736,7 @@
* @return
*/
private JSONObject searchQualityGoods(String key, int page, String filter, String order, String startprice,
- String endprice) {
+ String endprice, SystemEnum system) {
Integer hasQuan = null;
Integer userType = null;
@@ -782,7 +785,7 @@
provinceId = array.optJSONObject(i).optInt("id");
} else if ("tkRate1".equalsIgnoreCase(ty)) {
// 鑾峰彇瀵瑰簲鍙傛暟
- String value = configService.get("tkRate_range");
+ String value = configService.getValue(ConfigKeyEnum.tkRateRange.getKey(),system);
if (!StringUtil.isNullOrEmpty(value)) {
JSONArray tkRatearray = JSONArray.fromObject(value);
if (tkRatearray != null) {
@@ -798,7 +801,7 @@
}
} else if ("tkRate2".equalsIgnoreCase(ty)) {
// 鑾峰彇瀵瑰簲鍙傛暟
- String value = configService.get("tkRate_range");
+ String value = configService.getValue(ConfigKeyEnum.tkRateRange.getKey(),system);
if (!StringUtil.isNullOrEmpty(value)) {
JSONArray tkRatearray = JSONArray.fromObject(value);
if (tkRatearray != null) {
@@ -814,7 +817,7 @@
}
} else if ("tkRate3".equalsIgnoreCase(ty)) {
// 鑾峰彇瀵瑰簲鍙傛暟
- String value = configService.get("tkRate_range");
+ String value = configService.getValue(ConfigKeyEnum.tkRateRange.getKey(),system);
if (!StringUtil.isNullOrEmpty(value)) {
JSONArray tkRatearray = JSONArray.fromObject(value);
if (tkRatearray != null) {
@@ -830,7 +833,7 @@
}
} else if ("tkRate4".equalsIgnoreCase(ty)) {
// 鑾峰彇瀵瑰簲鍙傛暟
- String value = configService.get("tkRate_range");
+ String value = configService.getValue(ConfigKeyEnum.tkRateRange.getKey(),system);
if (!StringUtil.isNullOrEmpty(value)) {
JSONArray tkRatearray = JSONArray.fromObject(value);
if (tkRatearray != null) {
@@ -846,7 +849,7 @@
}
} else if ("tkRate5".equalsIgnoreCase(ty)) {
// 鑾峰彇瀵瑰簲鍙傛暟
- String value = configService.get("tkRate_range");
+ String value = configService.getValue(ConfigKeyEnum.tkRateRange.getKey(),system);
if (!StringUtil.isNullOrEmpty(value)) {
JSONArray tkRatearray = JSONArray.fromObject(value);
if (tkRatearray != null) {
@@ -939,15 +942,52 @@
return data;
}
+ private JSONObject searchDaTaoKeGoods(String key, int page, String filter, String order, String startprice,
+ String endprice) {
+ page = page + 1;
+ int sort = DaTaoKeApiUtil.SORT_DEFAULT;
+ if ("5".equalsIgnoreCase(order)) {
+ sort = DaTaoKeApiUtil.SORT_COMMISSION;
+ } else if ("1".equalsIgnoreCase(order)) {
+ sort = DaTaoKeApiUtil.SORT_SALES;
+ } else if ("2".equalsIgnoreCase(order)) {
+ sort = DaTaoKeApiUtil.SORT_PRICE_HIGH_TO_LOW;
+ } else if ("3".equalsIgnoreCase(order)) {
+ sort = DaTaoKeApiUtil.SORT_PRICE_LOW_TO_HIGH;
+ }
+
+ List<TaoBaoGoodsBriefExtra> listExtra = new ArrayList<TaoBaoGoodsBriefExtra>();
+ BigDecimal proportion = manageService.getFanLiRate();
+
+ DaTaoKeGoodsResult result = DaTaoKeApiUtil.search(key, null, null, null, page, 20, sort);
+ if (result != null && result.getGoodsList() != null)
+ for (DaTaoKeDetailV2 goods : result.getGoodsList()) {
+ listExtra.add(
+ TaoBaoUtil.getTaoBaoGoodsBriefExtra(TaoBaoUtil.convert(goods), proportion.toString(), null));
+ }
+
+ List<TaoBaoSearchNav> navList = new ArrayList<>();
+ Gson gson = new GsonBuilder().create();
+ Gson gson2 = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
+ .excludeFieldsWithoutExposeAnnotation().create();
+
+ JSONObject data = new JSONObject();
+ data.put("nav", gson.toJson(navList));
+ data.put("result", gson2.toJson(listExtra));
+ data.put("count", result.getTotalCount());
+
+ return data;
+ }
+
/**
* 璁剧疆鏌ヨ浣i噾姣斾緥鑼冨洿
*
* @param i
* @param sf
*/
- public void setSearchTkRate(int i, SearchFilter sf) {
+ public void setSearchTkRate(int i, SearchFilter sf,SystemEnum system) {
// 鑾峰彇瀵瑰簲鍙傛暟
- String value = configService.get("tkRate_range");
+ String value = configService.getValue(ConfigKeyEnum.tkRateRange.getKey(),system);
if (!StringUtil.isNullOrEmpty(value)) {
--
Gitblit v1.8.0