| | |
| | | |
| | | List<TaoBaoGoodsBrief> goodsBriefList = new ArrayList<>(); |
| | | int count = 0; |
| | | if (goodsId != null) { |
| | | try { |
| | | TaoBaoGoodsBrief goods = TaoKeApiUtil.searchGoodsDetail(goodsId); |
| | | goods.setCreatetime(null); |
| | | goodsBriefList.add(goods); |
| | | count = 1; |
| | | } catch (TaobaoGoodsDownException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } else { |
| | | SearchFilter sf = new SearchFilter(); |
| | | sf.setKey(SearchFilterUtil.filterSearchContent(key)); |
| | | sf.setPage(page); |
| | | sf.setPageSize(Constant.PAGE_SIZE); |
| | | |
| | | if (order != null) { |
| | | if (order == 1) { // 销量高到低 |
| | | sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW); |
| | | } else if (order == 2) { // 价格高到低 |
| | | sf.setSort(TaoBaoUtil.SORT_PRICE_HIGH_TO_LOW); |
| | | } else if (order == 3) { // 价格低到高 |
| | | sf.setSort(TaoBaoUtil.SORT_PRICE_LOW_TO_HIGH); |
| | | } 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)); |
| | | } |
| | | } |
| | | |
| | | // 搜索大淘客 |
| | | List<DaTaoKeDetailV2> daTaoKeList = null; |
| | | if (page == 1) { |
| | | daTaoKeList = daTaoKeGoodsDetailV2Service.listByDtitle(key); |
| | | } |
| | | |
| | | String specialId = null; |
| | | if (uid != null) { |
| | | specialId = userExtraTaoBaoInfoService.getSpecialIdByUid(uid); |
| | | } |
| | | |
| | | // 淘宝api搜索商品 |
| | | TaoBaoSearchResult result = taoBaoGoodsCacheUtil.getSearchResult(sf); // TaoBaoUtil.search(sf, specialId, null); |
| | | if (result == null) { |
| | | result = TaoBaoUtil.search(sf, specialId, null); |
| | | taoBaoGoodsCacheUtil.saveSearchResult(sf, result); |
| | | } |
| | | TaoBaoSearchResult finalResult = result; |
| | | // 搜索结果缓存到redis |
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null && result.getTaoBaoGoodsBriefs().size() > 0) { |
| | | ThreadUtil.run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | // 更新到緩存 |
| | | for (TaoBaoGoodsBrief goods : finalResult.getTaoBaoGoodsBriefs()) |
| | | taoBaoGoodsCacheUtil.saveCommonTaoBaoGoodsInfo(goods); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = null; |
| | | if (result != null) { |
| | | taoBaoGoodsBriefs = result.getTaoBaoGoodsBriefs(); |
| | | } |
| | | if (taoBaoGoodsBriefs == null) { |
| | | taoBaoGoodsBriefs = new ArrayList<>(); |
| | | } |
| | | |
| | | if (daTaoKeList != null && daTaoKeList.size() > 0) { |
| | | try { |
| | | if (goodsId != null) { |
| | | try { |
| | | Collections.reverse(daTaoKeList); |
| | | for (DaTaoKeDetailV2 detail : daTaoKeList) { |
| | | taoBaoGoodsBriefs.add(0, TaoBaoUtil.convert(detail)); |
| | | } |
| | | } catch (Exception e) { |
| | | TaoBaoGoodsBrief goods = TaoKeApiUtil.searchGoodsDetail(goodsId); |
| | | goods.setCreatetime(null); |
| | | goodsBriefList.add(goods); |
| | | count = 1; |
| | | } catch (TaobaoGoodsDownException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } else { |
| | | SearchFilter sf = new SearchFilter(); |
| | | sf.setKey(SearchFilterUtil.filterSearchContent(key)); |
| | | sf.setPage(page); |
| | | sf.setPageSize(Constant.PAGE_SIZE); |
| | | |
| | | count = result.getTaoBaoHead().getDocsfound(); |
| | | if (taoBaoGoodsBriefs != null) |
| | | goodsBriefList.addAll(taoBaoGoodsBriefs); |
| | | if (order != null) { |
| | | if (order == 1) { // 销量高到低 |
| | | sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW); |
| | | } else if (order == 2) { // 价格高到低 |
| | | sf.setSort(TaoBaoUtil.SORT_PRICE_HIGH_TO_LOW); |
| | | } else if (order == 3) { // 价格低到高 |
| | | sf.setSort(TaoBaoUtil.SORT_PRICE_LOW_TO_HIGH); |
| | | } 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)); |
| | | } |
| | | } |
| | | |
| | | // 搜索大淘客 |
| | | List<DaTaoKeDetailV2> daTaoKeList = null; |
| | | if (page == 1) { |
| | | daTaoKeList = daTaoKeGoodsDetailV2Service.listByDtitle(key); |
| | | } |
| | | |
| | | String specialId = null; |
| | | if (uid != null) { |
| | | specialId = userExtraTaoBaoInfoService.getSpecialIdByUid(uid); |
| | | } |
| | | |
| | | // 淘宝api搜索商品 |
| | | TaoBaoSearchResult result = taoBaoGoodsCacheUtil.getSearchResult(sf); // TaoBaoUtil.search(sf, specialId, null); |
| | | if (result == null) { |
| | | result = TaoBaoUtil.search(sf, specialId, null); |
| | | taoBaoGoodsCacheUtil.saveSearchResult(sf, result); |
| | | } |
| | | TaoBaoSearchResult finalResult = result; |
| | | // 搜索结果缓存到redis |
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null && result.getTaoBaoGoodsBriefs().size() > 0) { |
| | | ThreadUtil.run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | // 更新到緩存 |
| | | for (TaoBaoGoodsBrief goods : finalResult.getTaoBaoGoodsBriefs()) |
| | | taoBaoGoodsCacheUtil.saveCommonTaoBaoGoodsInfo(goods); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | 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); |
| | | for (DaTaoKeDetailV2 detail : daTaoKeList) { |
| | | taoBaoGoodsBriefs.add(0, TaoBaoUtil.convert(detail)); |
| | | } |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | |
| | | count = result.getTaoBaoHead().getDocsfound(); |
| | | if (taoBaoGoodsBriefs != null) |
| | | goodsBriefList.addAll(taoBaoGoodsBriefs); |
| | | } |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | |
| | | GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), |