| | |
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Collections;
|
| | | import java.util.HashMap;
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.taobao.TaoBaoAuthUtil;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dto.dataoke.DaTaoKeGoodsResult;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.lable.QualityFactory;
|
| | | import com.yeshi.fanli.entity.bus.recommend.Honest;
|
| | |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
|
| | | 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.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
|
| | | import com.yeshi.fanli.service.inter.lable.TaoKeGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.HistorySearchService;
|
| | |
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
|
| | | import com.yeshi.fanli.util.dataoke.DaTaoKeApiUtil;
|
| | | import com.yeshi.fanli.util.taobao.SearchFilterUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.vo.brand.TaoBaoShopVO;
|
| | |
|
| | | import net.sf.ehcache.Element;
|
| | | import net.sf.json.JSONArray;
|
| | |
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoShopService taoBaoShopService;
|
| | |
|
| | | @Resource
|
| | | private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
|
| | |
| | |
|
| | | historySearchService.addHistorySearch(kw, bid);
|
| | |
|
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(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("无法搜索链接"));
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("result", new JSONArray());
|
| | | data.put("count", 0);
|
| | | data.put("nav", new JSONArray());
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
|
| | |
| | | data = searchGoods(kw, page, filter, order, startprice, endprice);
|
| | | } else {
|
| | | // 推荐:精选库
|
| | | data = searchQualityGoods(kw, page, filter, order, startprice, endprice);
|
| | | // data = searchQualityGoods(kw, page, filter, order, startprice,
|
| | | // endprice);
|
| | | data = searchDaTaoKeGoods(kw, page, filter, order, startprice, endprice);
|
| | | }
|
| | |
|
| | | // 获取推荐词
|
| | |
| | | listRecommendWords = TaoBaoUtil.getSuguestSearch(kw);
|
| | | if (listRecommendWords == null || listRecommendWords.size() == 0) {
|
| | | listRecommendWords = new ArrayList<String>();
|
| | | }
|
| | |
|
| | | List<TaoBaoShopVO> listShop =null; //taoBaoShopService.getShopByKey(kw);
|
| | | if (listShop != null && listShop.size() > 0 && listShop.get(0).getListGoods() != null
|
| | | && listShop.get(0).getListGoods().size() > 2) {
|
| | | data.put("shop", JsonUtil.getApiCommonGson().toJson(listShop.get(0)));
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | if (daTaoKeList != null && daTaoKeList.size() > 0) {
|
| | | Collections.reverse(daTaoKeList);
|
| | | for (DaTaoKeDetail detail : daTaoKeList) {
|
| | | taoBaoGoodsBriefs.add(0,TaoBaoUtil.convert(detail));
|
| | | taoBaoGoodsBriefs.add(0, TaoBaoUtil.convert(detail));
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | |
| | | return data;
|
| | | }
|
| | |
|
| | | private JSONObject searchDaTaoKeGoods(String key, int page, String filter, String order, String startprice,
|
| | | String endprice) {
|
| | | page = page + 1;
|
| | | int sort = DaTaoKeApiUtil.SORT_DEFAULT;
|
| | | if ("5".equalsIgnoreCase(order)) {
|
| | | sort = DaTaoKeApiUtil.SORT_COMMISSION;
|
| | | } else if ("1".equalsIgnoreCase(order)) {
|
| | | sort = DaTaoKeApiUtil.SORT_SALES;
|
| | | } else if ("2".equalsIgnoreCase(order)) {
|
| | | sort = DaTaoKeApiUtil.SORT_PRICE_HIGH_TO_LOW;
|
| | | } else if ("3".equalsIgnoreCase(order)) {
|
| | | sort = DaTaoKeApiUtil.SORT_PRICE_LOW_TO_HIGH;
|
| | | }
|
| | |
|
| | | List<TaoBaoGoodsBriefExtra> listExtra = new ArrayList<TaoBaoGoodsBriefExtra>();
|
| | | BigDecimal proportion = manageService.getFanLiRate();
|
| | |
|
| | | DaTaoKeGoodsResult result = DaTaoKeApiUtil.search(key, null, null, null, page, 20, sort);
|
| | | if (result != null && result.getGoodsList() != null)
|
| | | for (DaTaoKeDetailV2 goods : result.getGoodsList()) {
|
| | | listExtra.add(
|
| | | TaoBaoUtil.getTaoBaoGoodsBriefExtra(TaoBaoUtil.convert(goods), proportion.toString(), null));
|
| | | }
|
| | |
|
| | | List<TaoBaoSearchNav> navList = new ArrayList<>();
|
| | | Gson gson = new GsonBuilder().create();
|
| | | Gson gson2 = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("nav", gson.toJson(navList));
|
| | | data.put("result", gson2.toJson(listExtra));
|
| | | data.put("count", result.getTotalCount());
|
| | |
|
| | | return data;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 设置查询佣金比例范围
|
| | | *
|