| | |
| | |
|
| | | @Resource
|
| | | private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
|
| | | |
| | |
|
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | |
|
| | | |
| | | |
| | | /**
|
| | | * 粘贴板信息推荐
|
| | | *
|
| | |
| | | out.print(JsonUtil.loadFalseResult("值过长"));
|
| | | return;
|
| | | }
|
| | |
|
| | | SearchFilter sf = new SearchFilter();
|
| | | sf.setKey(text);
|
| | | JSONObject root = new JSONObject();
|
| | |
|
| | | TaoBaoSearchResult result = TaoBaoUtil.search(sf);
|
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null && result.getTaoBaoGoodsBriefs().size() > 0)
|
| | | for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) {
|
| | | // 是属于淘宝联盟商品
|
| | | if (goods.getTitle().equalsIgnoreCase(text)) {
|
| | | root.put("type", 2);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("title", goods.getTitle());
|
| | | root.put("data", data);
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | // 查询大淘客标题
|
| | | List<DaTaoKeDetail> list = daTaoKeGoodsDetailService.listByDtitle(text);
|
| | | if (list != null && list.size() > 0) {
|
| | | root.put("type", 2);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("title", list.get(0).getdTitle());
|
| | | root.put("data", data);
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | return;
|
| | | }
|
| | |
|
| | | out.print(JsonUtil.loadFalseResult("暂不支持该类型!"));
|
| | | root.put("type", 2);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("title", text);
|
| | | root.put("data", data);
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | return;
|
| | | }
|
| | |
|
| | |
| | |
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 搜索候选词
|
| | | *
|
| | |
| | | * @param kw
|
| | | * @param page
|
| | | * @param filter
|
| | | * @param order 销量由高到低:1 、 价格从高到低:2 、 价格从低到高:3 、 推广量高到低:4(综合默认)、返利比高到低:5
|
| | | * 、返利比低到高:6 、推荐20
|
| | | * @param order
|
| | | * 销量由高到低:1 、 价格从高到低:2 、 价格从低到高:3 、 推广量高到低:4(综合默认)、返利比高到低:5
|
| | | * 、返利比低到高:6 、推荐20
|
| | | * @param startprice
|
| | | * @param endprice
|
| | | * @param fastFilter
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "searchGoods")
|
| | | public void searchGoods(AcceptData acceptData, Integer goodsType, String key, Integer page, String filter, Integer order, |
| | | PrintWriter out) {
|
| | | if (goodsType == null || goodsType < 1 || goodsType >3) {
|
| | | public void searchGoods(AcceptData acceptData, Integer goodsType, String key, Integer page, String filter,
|
| | | Integer order, PrintWriter out) {
|
| | | if (goodsType == null || goodsType < 1 || goodsType > 3) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请传递正确平台参数"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | if (page == null || page < 1) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "页码不能小于1"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | if (StringUtil.isNullOrEmpty(key)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请输入搜索内容"));
|
| | | return;
|
| | | }
|
| | | final String searchkey = key.trim();
|
| | | |
| | |
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | |
| | | String device = acceptData.getDevice();
|
| | | sb.append(platform).append(link).append(packages).append(link).append(device);
|
| | | String bid = StringUtil.Md5(sb.toString());
|
| | | |
| | |
|
| | | // 加入搜索历史记录
|
| | | historySearchService.addHistorySearch(searchkey, bid);
|
| | | }
|
| | | });
|
| | | |
| | |
|
| | | if (searchkey.startsWith("http://") || searchkey.startsWith("https://")) {
|
| | | JSONObject data = new JSONObject();
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | /*--------- 京东商品 -------*/ |
| | | /*--------- 京东商品 -------*/
|
| | | if (goodsType.intValue() == Constant.SOURCE_TYPE_JD) {
|
| | | searchJDGoods(searchkey, page, filter, order, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | /*-------- 拼多多商品 -------*/ |
| | | /*-------- 拼多多商品 -------*/
|
| | | if (goodsType.intValue() == Constant.SOURCE_TYPE_PDD) {
|
| | | searchPDDGoods(searchkey, page, filter, order, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | /*-------- 淘宝商品 -------*/ |
| | | /*-------- 淘宝商品 -------*/
|
| | | searchTaoBaoGoods(searchkey, page, filter, order, out);
|
| | | }
|
| | |
|
| | |
| | | } else if (order == 4) { // 返利比高到低
|
| | | sf.setSort(TaoBaoUtil.SORT_TKRATE_HIGH_TO_LOW);
|
| | | }
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(filter)) {
|
| | | JSONObject jsonfilter = JSONObject.fromObject(filter);
|
| | | Boolean coupon = jsonfilter.optBoolean("coupon");
|
| | | if (coupon != null && coupon) {
|
| | | sf.setQuan(1); // 有券
|
| | | }
|
| | | |
| | |
|
| | | Boolean tmall = jsonfilter.optBoolean("tmall");
|
| | | if (tmall != null && tmall) {
|
| | | sf.setTmall(true); // 天猫
|
| | | }
|
| | | |
| | |
|
| | | String minPrice = jsonfilter.optString("minPrice");
|
| | | if (!StringUtil.isNullOrEmpty(minPrice)) {
|
| | | sf.setStartPrice(new BigDecimal(minPrice));
|
| | | }
|
| | | |
| | |
|
| | | String maxPrice = jsonfilter.optString("maxPrice");
|
| | | if (!StringUtil.isNullOrEmpty(maxPrice)) {
|
| | | sf.setEndPrice(new BigDecimal(maxPrice));
|
| | |
| | | if (page == 1) {
|
| | | daTaoKeList = daTaoKeGoodsDetailService.listByDtitle(key);
|
| | | }
|
| | | |
| | |
|
| | | // 淘宝api搜索商品
|
| | | TaoBaoSearchResult result = TaoBaoUtil.search(sf);
|
| | | |
| | |
|
| | | // 搜索是否在营销主商品库
|
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null && result.getTaoBaoGoodsBriefs().size() > 0) {
|
| | | ThreadUtil.run(new Runnable() {
|
| | |
| | | }
|
| | | });
|
| | | }
|
| | | |
| | |
|
| | | List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = null;
|
| | | if (result != null) {
|
| | | taoBaoGoodsBriefs = result.getTaoBaoGoodsBriefs();
|
| | |
| | | if (taoBaoGoodsBriefs == null) {
|
| | | taoBaoGoodsBriefs = new ArrayList<>();
|
| | | }
|
| | | |
| | |
|
| | | if (daTaoKeList != null && daTaoKeList.size() > 0) {
|
| | | try {
|
| | | Collections.reverse(daTaoKeList);
|
| | |
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | List<GoodsDetailVO> list = new ArrayList<GoodsDetailVO>();
|
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | |
| | |
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().create();
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("result", gson.toJson(list));
|
| | | data.put("count", result.getTaoBaoHead().getDocsfound());
|
| | |
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 京东
|
| | | *
|
| | |
| | | * @return
|
| | | */
|
| | | private void searchJDGoods(String key, Integer page, String filter, Integer order, PrintWriter out) {
|
| | | |
| | |
|
| | | JDSearchResult result = null;
|
| | | String way = configService.get("jd_api_search_key");
|
| | | if ("1".equals(way)) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(filter)) {
|
| | | JSONObject jsonfilter = JSONObject.fromObject(filter);
|
| | | Boolean coupon = jsonfilter.optBoolean("coupon");
|
| | | if (coupon != null && coupon) {
|
| | | filterAPI.setIsCoupon(1); // 有券
|
| | | }
|
| | | |
| | |
|
| | | Boolean zy = jsonfilter.optBoolean("zy");
|
| | | if (zy != null && zy) {
|
| | | filterAPI.setOwner("g"); // 自营
|
| | | }
|
| | | |
| | | |
| | |
|
| | | String minPrice = jsonfilter.optString("minPrice");
|
| | | if (!StringUtil.isNullOrEmpty(minPrice)) {
|
| | | filterAPI.setPricefrom(Double.parseDouble(minPrice));
|
| | | }
|
| | | |
| | |
|
| | | String maxPrice = jsonfilter.optString("maxPrice");
|
| | | if (!StringUtil.isNullOrEmpty(maxPrice)) {
|
| | | filterAPI.setPriceto(Double.parseDouble(maxPrice));
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | result = JDApiUtil.queryByKey(filterAPI);
|
| | | } else {
|
| | | // 网页爬取
|
| | |
| | | if (coupon != null && coupon) {
|
| | | jdfilter.setHasCoupon(1); // 有券
|
| | | }
|
| | | |
| | |
|
| | | Boolean zy = jsonfilter.optBoolean("zy");
|
| | | if (zy != null && zy) {
|
| | | jdfilter.setIsZY(1); // 自营
|
| | | }
|
| | | |
| | |
|
| | | Boolean delivery = jsonfilter.optBoolean("delivery");
|
| | | if (delivery != null && delivery) {
|
| | | jdfilter.setDeliveryType(1); // 京东配送
|
| | | }
|
| | | |
| | |
|
| | | String minPrice = jsonfilter.optString("minPrice");
|
| | | if (!StringUtil.isNullOrEmpty(minPrice)) {
|
| | | if(minPrice.contains(".")) {
|
| | | if (minPrice.contains(".")) {
|
| | | minPrice = minPrice.replace(".", "-");
|
| | | minPrice = minPrice.split("-")[0];
|
| | | }
|
| | | jdfilter.setFromPrice(Integer.parseInt(minPrice));
|
| | | }
|
| | | |
| | |
|
| | | String maxPrice = jsonfilter.optString("maxPrice");
|
| | | if (!StringUtil.isNullOrEmpty(maxPrice)) {
|
| | | if(maxPrice.contains(".")) {
|
| | | if (maxPrice.contains(".")) {
|
| | | maxPrice = maxPrice.replace(".", "-");
|
| | | maxPrice = maxPrice.split("-")[0];
|
| | | maxPrice = maxPrice.split("-")[0];
|
| | | }
|
| | | jdfilter.setToPrice(Integer.parseInt(maxPrice));
|
| | | }
|
| | | }
|
| | | result = JDUtil.searchByKey(jdfilter);
|
| | | |
| | |
|
| | | }
|
| | | |
| | |
|
| | | long count = 0;
|
| | | JSONObject data = new JSONObject();
|
| | | JSONArray array = new JSONArray();
|
| | |
| | | break;
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | if (!StringUtil.isNullOrEmpty(filter)) {
|
| | | JSONObject jsonfilter = JSONObject.fromObject(filter);
|
| | | Boolean coupon = jsonfilter.optBoolean("coupon");
|
| | | if (coupon != null && coupon) {
|
| | | pddfilter.setHasCoupon(true); // 有券
|
| | | }
|
| | | |
| | |
|
| | | Boolean brand = jsonfilter.optBoolean("brand");
|
| | | if (brand != null && brand) {
|
| | | pddfilter.setIsBrand(true); // 是否是品牌
|
| | |
| | | if (goodsList != null && goodsList.size() > 0) {
|
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | | |
| | |
|
| | | for (PDDGoodsDetail goods : goodsList) {
|
| | | GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(goods, null, fanLiRate,
|
| | | shareRate);
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | data.put("result", array);
|
| | | data.put("count", count);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|