From d1dccd08a249b830a95eeeb04af25f87d5c056be Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期二, 03 九月 2019 11:13:04 +0800 Subject: [PATCH] 金币明细bug --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java | 35 +++++++++++++++++++++-------------- 1 files changed, 21 insertions(+), 14 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 8ff80dd..465af3a 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 @@ -35,7 +35,6 @@ import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult; import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail; -import com.yeshi.fanli.exception.integral.IntegralGetException; import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; import com.yeshi.fanli.exception.user.TokenRecordException; import com.yeshi.fanli.log.LogHelper; @@ -57,6 +56,7 @@ import com.yeshi.fanli.util.ThreadUtil; import com.yeshi.fanli.util.Utils; import com.yeshi.fanli.util.VersionUtil; +import com.yeshi.fanli.util.cache.IntegralGetCacheManager; import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil; import com.yeshi.fanli.util.factory.CommonGoodsFactory; import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; @@ -119,6 +119,9 @@ @Resource private IntegralGetService integralGetService; + + @Resource + private IntegralGetCacheManager integralGetCacheManager; /** * 绮樿创鏉夸俊鎭帹鑽� @@ -415,6 +418,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) { + if (goodsType == null || goodsType < 1 || goodsType > 3) { out.print(JsonUtil.loadFalseResult(1, "璇蜂紶閫掓纭钩鍙板弬鏁�")); return; @@ -433,24 +437,18 @@ if (uid != null) { if (page == 1) { - session.setAttribute("searchFirstTime", System.currentTimeMillis()); - } else if (page == 2) { - Long lastTime = (Long) session.getAttribute("searchFirstTime"); + integralGetCacheManager.cacheSearchGoods(acceptData.getDevice(), System.currentTimeMillis()); + } else if (page > 1) { + Long lastTime = integralGetCacheManager.getLastSearchTime(acceptData.getDevice()); if (lastTime != null && System.currentTimeMillis() - lastTime >= 15 * 1000L) {// 瓒呰繃15s娴忚 - + integralGetCacheManager.clearSearchTime(acceptData.getDevice()); ThreadUtil.run(new Runnable() { - @Override public void run() { - try { - // 澧炲姞閲戝竵 - integralGetService.addSearchResultScan(uid,key); - } catch (IntegralGetException e) { - e.printStackTrace(); - } + // 澧炲姞閲戝竵 + integralGetService.addSearchResultScan(uid, key); } }); - } } } @@ -625,6 +623,7 @@ private void searchJDGoods(String key, Integer page, String filter, Integer order, PrintWriter out) { JDSearchResult result = null; + boolean hasCoupon = false; String way = configService.get("jd_api_search_key"); if ("1".equals(way)) { JDFilter filterAPI = new JDFilter(); @@ -660,6 +659,7 @@ JSONObject jsonfilter = JSONObject.fromObject(filter); Boolean coupon = jsonfilter.optBoolean("coupon"); if (coupon != null && coupon) { + hasCoupon = true; filterAPI.setIsCoupon(1); // 鏈夊埜 } @@ -715,6 +715,7 @@ JSONObject jsonfilter = JSONObject.fromObject(filter); Boolean coupon = jsonfilter.optBoolean("coupon"); if (coupon != null && coupon) { + hasCoupon = true; jdfilter.setHasCoupon(1); // 鏈夊埜 } @@ -767,7 +768,13 @@ .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); for (JDGoods goods : goodsList) { GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, fanLiRate, shareRate); - array.add(gson.toJson(goodsDetailVO)); + if (hasCoupon) { + if (goodsDetailVO.isHasCoupon()) { + array.add(gson.toJson(goodsDetailVO)); + } + } else { + array.add(gson.toJson(goodsDetailVO)); + } } } } -- Gitblit v1.8.0