From d146e7bca73c7605af6b718b5df0b757e0034f0e Mon Sep 17 00:00:00 2001 From: Administrator <Administrator@Admin> Date: 星期二, 18 十二月 2018 11:17:41 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- fanli/src/main/java/com/yeshi/fanli/controller/client/SearchController.java | 198 ++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 153 insertions(+), 45 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/SearchController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/SearchController.java index 6251ed3..05cfc92 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/SearchController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/SearchController.java @@ -38,6 +38,7 @@ 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.service.inter.config.ConfigService; import com.yeshi.fanli.service.inter.config.SuperHotSearchService; import com.yeshi.fanli.service.inter.config.SystemService; import com.yeshi.fanli.service.inter.goods.HonestService; @@ -58,6 +59,9 @@ @Resource private SystemService systemService; + + @Resource + private ConfigService configService; @Resource private SuperHotSearchService superHotSearchSerivce; @@ -136,11 +140,9 @@ data.put("nav", gson.toJson(navList)); List<TaoBaoGoodsBriefExtra> re = new ArrayList<TaoBaoGoodsBriefExtra>(); List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = result.getTaoBaoGoodsBriefs(); - Map<String, String> map = manageService.convertMap(); - String proportion = map.get("hongbao_goods_proportion"); - String fcRate = map.get("hongbao_fc_ratio"); + BigDecimal proportion = manageService.getFanLiRate(); for (TaoBaoGoodsBrief bf : taoBaoGoodsBriefs) { - re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion, fcRate, "")); + re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion.toString(), "")); } Gson gson2 = JsonUtil.getApiCommonGson(); data.put("result", gson2.toJson(re)); @@ -311,9 +313,7 @@ int fq = sf.getQuan(); int fh = sf.getHongbao(); boolean ft = sf.isTmall(); - Map<String, String> map = manageService.convertMap(); - String proportion = map.get("hongbao_goods_proportion"); - String fcRate = map.get("hongbao_fc_ratio"); + BigDecimal proportion = manageService.getFanLiRate(); if (fq == 0 && fh == 0 && !ft) { if (result != null && result.getTaoBaoGoodsBriefs() != null) for (TaoBaoGoodsBrief bf : result.getTaoBaoGoodsBriefs()) { @@ -322,10 +322,10 @@ double sales = count; String salesCountMidea = String.format("%.1f", sales / 10000); bf.setSalesCount(salesCountMidea + "涓�"); - re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion, fcRate, "")); + re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion.toString(), "")); } else { bf.setSalesCount(count + ""); - re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion, fcRate, "")); + re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion.toString(), "")); } } } else { @@ -337,13 +337,13 @@ double sales = count; String salesCountMidea = String.format("%.1f", sales / 10000); taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�"); - taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, - fcRate, ""); + taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, + proportion.toString(), ""); re.add(taoBaoGoodsBriefExtra); } else { taoBaoGoodsBrief.setSalesCount(count + ""); - taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, - fcRate, ""); + taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, + proportion.toString(), ""); re.add(taoBaoGoodsBriefExtra); } } @@ -467,10 +467,10 @@ JSONObject data = null; if (!recommend) { // 娣樺疂鎺ュ彛璇锋眰 - data = searchGoods(kw, page, filter, order, startprice, endprice, startTkRate, endTkRate); + data = searchGoods(kw, page, filter, order, startprice, endprice); } else { // 鎺ㄨ崘锛氱簿閫夊簱 - data = searchQualityGoods(kw, page, filter, order, startprice, endprice, startTkRate, endTkRate); + data = searchQualityGoods(kw, page, filter, order, startprice, endprice); } // 鑾峰彇鎺ㄨ崘璇� @@ -501,7 +501,7 @@ * @return */ private JSONObject searchGoods(String kw, int page, String filter, String order, String startprice, - String endprice, Double startTkRate, Double endTkRate) { + String endprice) { page = page + 1; SearchFilter sf = new SearchFilter(); @@ -515,20 +515,6 @@ if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(endprice)) { sf.setEndPrice(new BigDecimal(endprice)); - } - - if (startTkRate != null && startTkRate != 0 && !startTkRate.equals(0)) { - BigDecimal b = new BigDecimal(startTkRate/2); - double df = b.setScale(2, BigDecimal.ROUND_FLOOR).doubleValue(); - int tkRate = (int) (df * 100); - sf.setStartTkRate(tkRate); - } - - if (endTkRate != null && endTkRate != 0 && !endTkRate.equals(0)) { - BigDecimal b = new BigDecimal(endTkRate/2); - double df = b.setScale(2, BigDecimal.ROUND_FLOOR).doubleValue(); - int tkRate = (int) (df * 100); - sf.setEndTkRate(tkRate); } if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(order)) { @@ -617,10 +603,21 @@ } else if ("materialId".equalsIgnoreCase(ty)) { int id = array.optJSONObject(i).optInt("id"); sf.setProvinceId(id); + } else if ("tkRate1".equalsIgnoreCase(ty)) { + setSearchTkRate(0, sf); + } else if ("tkRate2".equalsIgnoreCase(ty)) { + setSearchTkRate(1, sf); + } else if ("tkRate3".equalsIgnoreCase(ty)) { + setSearchTkRate(2, sf); + } else if ("tkRate4".equalsIgnoreCase(ty)) { + setSearchTkRate(3, sf); + } else if ("tkRate5".equalsIgnoreCase(ty)) { + setSearchTkRate(4, sf); } } sf.setParams(params); } + TaoBaoSearchResult result = TaoBaoUtil.search(sf); if (result == null) { return null; @@ -638,8 +635,7 @@ int fh = sf.getHongbao(); boolean ft = sf.isTmall(); Map<String, String> map = manageService.convertMap(); - String proportion = map.get("hongbao_goods_proportion"); - String fcRate = map.get("hongbao_fc_ratio"); + BigDecimal proportion = manageService.getFanLiRate(); if (fq == 0 && fh == 0 && !ft) { if (result != null && result.getTaoBaoGoodsBriefs() != null) for (TaoBaoGoodsBrief bf : result.getTaoBaoGoodsBriefs()) { @@ -648,10 +644,10 @@ double sales = count; String salesCountMidea = String.format("%.1f", sales / 10000); bf.setSalesCount(salesCountMidea + "涓�"); - re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion, fcRate, "")); + re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion.toString(), "")); } else { bf.setSalesCount(count + ""); - re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion, fcRate, "")); + re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion.toString(), "")); } } } else { @@ -663,13 +659,13 @@ double sales = count; String salesCountMidea = String.format("%.1f", sales / 10000); taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�"); - taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, - fcRate, ""); + taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, + proportion.toString(), ""); re.add(taoBaoGoodsBriefExtra); } else { taoBaoGoodsBrief.setSalesCount(count + ""); - taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, - fcRate, ""); + taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, + proportion.toString(), ""); re.add(taoBaoGoodsBriefExtra); } } @@ -693,13 +689,15 @@ * @return */ private JSONObject searchQualityGoods(String key, int page, String filter, String order, String startprice, - String endprice, Double startTkRate, Double endTkRate) { + String endprice) { Integer hasQuan = null; Integer userType = null; Double start_Price = null; Double end_Price = null; Integer sort = null; + Double startTkRate = null; + Double endTkRate = null; int provinceId = -100; @@ -738,6 +736,86 @@ } else if ("fahuodi".equalsIgnoreCase(ty)) { provinceId = array.optJSONObject(i).optInt("id"); + } else if ("tkRate1".equalsIgnoreCase(ty)) { + // 鑾峰彇瀵瑰簲鍙傛暟 + String value = configService.get("tkRate_range"); + if (!StringUtil.isNullOrEmpty(value)) { + JSONArray tkRatearray = JSONArray.fromObject(value); + if (tkRatearray != null) { + String start = tkRatearray.optJSONObject(0).optString("start"); + if (!StringUtil.isNullOrEmpty(start)) { + startTkRate = Double.parseDouble(start); + } + String end = tkRatearray.optJSONObject(0).optString("end"); + if (!StringUtil.isNullOrEmpty(end)) { + endTkRate = Double.parseDouble(end); + } + } + } + } else if ("tkRate2".equalsIgnoreCase(ty)) { + // 鑾峰彇瀵瑰簲鍙傛暟 + String value = configService.get("tkRate_range"); + if (!StringUtil.isNullOrEmpty(value)) { + JSONArray tkRatearray = JSONArray.fromObject(value); + if (tkRatearray != null) { + String start = tkRatearray.optJSONObject(1).optString("start"); + if (!StringUtil.isNullOrEmpty(start)) { + startTkRate = Double.parseDouble(start); + } + String end = tkRatearray.optJSONObject(1).optString("end"); + if (!StringUtil.isNullOrEmpty(end)) { + endTkRate = Double.parseDouble(end); + } + } + } + } else if ("tkRate3".equalsIgnoreCase(ty)) { + // 鑾峰彇瀵瑰簲鍙傛暟 + String value = configService.get("tkRate_range"); + if (!StringUtil.isNullOrEmpty(value)) { + JSONArray tkRatearray = JSONArray.fromObject(value); + if (tkRatearray != null) { + String start = tkRatearray.optJSONObject(2).optString("start"); + if (!StringUtil.isNullOrEmpty(start)) { + startTkRate = Double.parseDouble(start); + } + String end = tkRatearray.optJSONObject(2).optString("end"); + if (!StringUtil.isNullOrEmpty(end)) { + endTkRate = Double.parseDouble(end); + } + } + } + } else if ("tkRate4".equalsIgnoreCase(ty)) { + // 鑾峰彇瀵瑰簲鍙傛暟 + String value = configService.get("tkRate_range"); + if (!StringUtil.isNullOrEmpty(value)) { + JSONArray tkRatearray = JSONArray.fromObject(value); + if (tkRatearray != null) { + String start = tkRatearray.optJSONObject(3).optString("start"); + if (!StringUtil.isNullOrEmpty(start)) { + startTkRate = Double.parseDouble(start); + } + String end = tkRatearray.optJSONObject(3).optString("end"); + if (!StringUtil.isNullOrEmpty(end)) { + endTkRate = Double.parseDouble(end); + } + } + } + } else if ("tkRate5".equalsIgnoreCase(ty)) { + // 鑾峰彇瀵瑰簲鍙傛暟 + String value = configService.get("tkRate_range"); + if (!StringUtil.isNullOrEmpty(value)) { + JSONArray tkRatearray = JSONArray.fromObject(value); + if (tkRatearray != null) { + String start = tkRatearray.optJSONObject(4).optString("start"); + if (!StringUtil.isNullOrEmpty(start)) { + startTkRate = Double.parseDouble(start); + } + String end = tkRatearray.optJSONObject(4).optString("end"); + if (!StringUtil.isNullOrEmpty(end)) { + endTkRate = Double.parseDouble(end); + } + } + } } } } @@ -748,10 +826,7 @@ userType, start_Price, end_Price, startTkRate, endTkRate, sort); List<TaoBaoGoodsBriefExtra> listExtra = new ArrayList<TaoBaoGoodsBriefExtra>(); - Map<String, String> map = manageService.convertMap(); - String proportion = map.get("hongbao_goods_proportion"); - String fcRate = map.get("hongbao_fc_ratio"); - + BigDecimal proportion = manageService.getFanLiRate(); /* 閬嶅巻鍒楄〃鏁版嵁 */ if (listQuery != null && listQuery.size() > 0) { for (QualityFactory selectionGoods : listQuery) { @@ -777,11 +852,12 @@ taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl)); } - listExtra.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, fcRate, null)); + listExtra.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)); } } - long count = qualityGoodsService.countRecommendBykey(key, hasQuan, userType, start_Price, end_Price, startTkRate, endTkRate); + long count = qualityGoodsService.countRecommendBykey(key, hasQuan, userType, start_Price, end_Price, + startTkRate, endTkRate); // 璁剧疆鍙戣揣鍦板潃 TaoBaoSearchNav nav = new TaoBaoSearchNav(); @@ -819,4 +895,36 @@ return data; } + /** + * 璁剧疆鏌ヨ浣i噾姣斾緥鑼冨洿 + * + * @param i + * @param sf + */ + public void setSearchTkRate(int i, SearchFilter sf) { + // 鑾峰彇瀵瑰簲鍙傛暟 + String value = configService.get("tkRate_range"); + + if (!StringUtil.isNullOrEmpty(value)) { + + JSONArray tkRatearray = JSONArray.fromObject(value); + + if (tkRatearray != null) { + + String start = tkRatearray.optJSONObject(i).optString("start"); + + if (!StringUtil.isNullOrEmpty(start)) { + int tkRate = (int) (Float.parseFloat(start) * 100); + sf.setStartTkRate(tkRate); + } + + String end = tkRatearray.optJSONObject(i).optString("end"); + if (!StringUtil.isNullOrEmpty(end)) { + int tkRate = (int) (Float.parseFloat(end) * 100); + sf.setEndTkRate(tkRate); + } + } + + } + } } -- Gitblit v1.8.0