| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import net.sf.ehcache.Element;
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | |
| | | import com.yeshi.fanli.entity.bus.search.HistorySearch;
|
| | | import com.yeshi.fanli.entity.bus.search.HotSearch;
|
| | | import com.yeshi.fanli.entity.bus.su.search.SuperHotSearch;
|
| | | import com.yeshi.fanli.entity.system.System;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.entity.taobao.PidUser;
|
| | | import com.yeshi.fanli.entity.taobao.SearchFilter;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | |
| | | 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.BusinessSystemService;
|
| | | 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;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
|
| | | import com.yeshi.fanli.service.inter.lable.TaoKeGoodsService;
|
| | |
| | | import com.yeshi.fanli.util.taobao.SearchFilterUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
|
| | | import net.sf.ehcache.Element;
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("api/v1/search")
|
| | | public class SearchController {
|
| | |
|
| | | @Resource
|
| | | private SystemService systemService;
|
| | | |
| | | private BusinessSystemService businessSystemService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private SuperHotSearchService superHotSearchSerivce;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private HongBaoManageService manageService;
|
| | |
|
| | | @Resource
|
| | | private HonestService honestService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService;
|
| | |
| | |
|
| | | @RequestMapping(value = "gethotsearch", method = RequestMethod.POST)
|
| | | public void getHotSearch(AcceptData acceptData, PrintWriter out) {
|
| | | System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
|
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages());
|
| | | if (system == null) {
|
| | | out.print(JsonUtil.loadFalseResult("系统不存在"));
|
| | | return;
|
| | |
| | |
|
| | | @RequestMapping("specialSearch")
|
| | | public void specialSearch(AcceptData acceptData, long hid, int page, PrintWriter out) {
|
| | | Honest honest = honestService.getOne(hid);
|
| | | Honest honest = null;
|
| | | if (honest == null) {
|
| | | out.print(JsonUtil.loadFalseResult(""));
|
| | | return;
|
| | |
| | | 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));
|
| | |
| | | String endprice, String fastFilter, PrintWriter out) {
|
| | | String bid = getHistorySearchBid(acceptData);
|
| | | historySearchService.addHistorySearch(kw, bid);
|
| | | System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
|
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages());
|
| | | if (system == null) {
|
| | | out.print(JsonUtil.loadFalseResult("系统不存在"));
|
| | | return;
|
| | |
| | | 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()) {
|
| | |
| | | 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 {
|
| | |
| | | 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);
|
| | | }
|
| | | }
|
| | |
| | | data.put("result", gson2.toJson(re));
|
| | | data.put("count", result.getTaoBaoHead().getDocsfound());
|
| | | return data;
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "gethistorysearch", method = RequestMethod.POST)
|
| | | public void getHistorySearch(AcceptData acceptData, PrintWriter out) {
|
| | | String bid = getHistorySearchBid(acceptData);
|
| | | List<HistorySearch> historySearchList = historySearchService.getHistorySearch(bid);
|
| | | if (historySearchList == null || historySearchList.size() == 0) {
|
| | | out.print(JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", historySearchList.size());
|
| | | Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
| | | data.put("historySearchList", gson.toJson(historySearchList));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "clearhistorysearch", method = RequestMethod.POST)
|
| | | public void clearHistorySearch(AcceptData acceptData, PrintWriter out) {
|
| | | String bid = getHistorySearchBid(acceptData);
|
| | | long count = historySearchService.clearHistorySearch(bid);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", count);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "suggestsearch", method = RequestMethod.POST)
|
| | |
| | |
|
| | | historySearchService.addHistorySearch(kw, bid);
|
| | |
|
| | | // System system = systemService.getSystemCache(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("无法搜索链接"));
|
| | |
| | | }
|
| | |
|
| | | Gson gson = new GsonBuilder().create();
|
| | | data.put("words", gson.toJson(listRecommendWords));
|
| | | if (data != null)
|
| | | data.put("words", gson.toJson(listRecommendWords));
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
| | | if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(endprice)) {
|
| | | sf.setEndPrice(new BigDecimal(endprice));
|
| | | }
|
| | | |
| | |
|
| | | if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(order)) {
|
| | | if (Integer.parseInt(order) == 1) {
|
| | | sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW);
|
| | |
| | | setSearchTkRate(3, sf);
|
| | | } else if ("tkRate5".equalsIgnoreCase(ty)) {
|
| | | setSearchTkRate(4, sf);
|
| | | } |
| | | }
|
| | | }
|
| | | sf.setParams(params);
|
| | | }
|
| | | |
| | |
|
| | | TaoBaoSearchResult result = TaoBaoUtil.search(sf);
|
| | | if (result == null) {
|
| | | return null;
|
| | |
| | | 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()) {
|
| | |
| | | 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 {
|
| | |
| | | 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);
|
| | | }
|
| | | }
|
| | |
| | | * @return
|
| | | */
|
| | | private JSONObject searchQualityGoods(String key, int page, String filter, String order, String startprice,
|
| | | String endprice ) {
|
| | | String endprice) {
|
| | |
|
| | | Integer hasQuan = null;
|
| | | Integer userType = null;
|
| | |
| | | Integer sort = null;
|
| | | Double startTkRate = null;
|
| | | Double endTkRate = null;
|
| | | |
| | |
|
| | | int provinceId = -100;
|
| | |
|
| | | // 起始价格
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | } |
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | 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) {
|
| | |
| | | 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();
|
| | |
| | |
|
| | | /**
|
| | | * 设置查询佣金比例范围
|
| | | * |
| | | * @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);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | | }
|
| | | }
|