admin
2019-07-31 f253c6f0ce5e708850f8e3c84a6a9008fc37df5f
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/SearchController.java
@@ -15,7 +15,6 @@
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;
@@ -43,6 +42,7 @@
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;
@@ -54,6 +54,7 @@
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;
@@ -91,18 +92,27 @@
   private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
   @Resource
   private TaoBaoShopService taoBaoShopService;
   @Resource
   private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
   @RequestMapping(value = "gethotsearch", method = RequestMethod.POST)
   public void getHotSearch(AcceptData acceptData, PrintWriter out) {
   public void getHotSearch(AcceptData acceptData, Integer goodsType, PrintWriter out) {
      BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
            acceptData.getPackages());
      if (system == null) {
         out.print(JsonUtil.loadFalseResult("系统不存在"));
         return;
      }
      // 默认淘宝
      if (goodsType == null) {
         goodsType = Constant.SOURCE_TYPE_TAOBAO;
      }
      List<SuperHotSearch> superHotSearchList = superHotSearchSerivce
            .getSuperHotSearchBySystemIdCache(system.getId());
            .getSuperHotSearchBySystemIdCache(system.getId(), goodsType);
      if (superHotSearchList == null || superHotSearchList.size() == 0) {
         out.print(JsonUtil.loadFalseResult("没有数据"));
         return;
@@ -414,15 +424,20 @@
      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;
      }
@@ -470,6 +485,12 @@
         listRecommendWords = TaoBaoUtil.getSuguestSearch(kw);
         if (listRecommendWords == null || listRecommendWords.size() == 0) {
            listRecommendWords = new ArrayList<String>();
         }
         List<TaoBaoShopVO> listShop =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)));
         }
      }
@@ -936,7 +957,7 @@
   private JSONObject searchDaTaoKeGoods(String key, int page, String filter, String order, String startprice,
         String endprice) {
      page=page+1;
      page = page + 1;
      int sort = DaTaoKeApiUtil.SORT_DEFAULT;
      if ("5".equalsIgnoreCase(order)) {
         sort = DaTaoKeApiUtil.SORT_COMMISSION;
@@ -951,7 +972,7 @@
      List<TaoBaoGoodsBriefExtra> listExtra = new ArrayList<TaoBaoGoodsBriefExtra>();
      BigDecimal proportion = manageService.getFanLiRate();
      DaTaoKeGoodsResult result = DaTaoKeApiUtil.search(key, null, page, 20, sort);
      DaTaoKeGoodsResult result = DaTaoKeApiUtil.search(key, null, null, null, page, 20, sort);
      if (result != null && result.getGoodsList() != null)
         for (DaTaoKeDetailV2 goods : result.getGoodsList()) {
            listExtra.add(