| | |
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | 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 javax.print.attribute.standard.NumberUp;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.stereotype.Controller;
|
| | |
| | | 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.exception.taobao.TaobaoGoodsDownException;
|
| | | 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.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
|
| | | import com.yeshi.fanli.service.inter.lable.TaoKeGoodsService;
|
| | |
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.EhcacheUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
|
| | | import com.yeshi.fanli.util.taobao.SearchFilterUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | import net.sf.ehcache.Element;
|
| | | import net.sf.json.JSONArray;
|
| | |
| | | public class SearchController {
|
| | |
|
| | | @Resource
|
| | | private SystemService systemService;
|
| | | private BusinessSystemService businessSystemService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
| | | @Resource
|
| | | private QualityGoodsService qualityGoodsService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
|
| | |
|
| | | @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;
|
| | |
| | | List<HotSearch> hotSearchList = new ArrayList<HotSearch>();
|
| | | for (SuperHotSearch superHotSearch : superHotSearchList) {
|
| | | HotSearch hotSearch = superHotSearch.getHotSearch();
|
| | | hotSearchList.add(hotSearch);
|
| | | if (hotSearch != null)
|
| | | hotSearchList.add(hotSearch);
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | |
| | | 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;
|
| | |
| | | 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)
|
| | | public void getSugguestSearch(AcceptData acceptData, String kw, PrintWriter out) {
|
| | | List<String> list = TaoBaoUtil.getSuguestSearch(kw);
|
| | |
| | |
|
| | | 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;
|
| | |
| | | if (result == null) {
|
| | | return null;
|
| | | }
|
| | | // 搜索是否在营销主商品库
|
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null && result.getTaoBaoGoodsBriefs().size() > 0) {
|
| | | String numIds = "";
|
| | | for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) {
|
| | | numIds += goods.getAuctionId() + ",";
|
| | | }
|
| | | if (numIds.endsWith(","))
|
| | | numIds = numIds.substring(0, numIds.length() - 1);
|
| | | try {
|
| | | List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.getBatchGoodsInfos(numIds);
|
| | | Map<Long, Integer> map = new HashMap<>();
|
| | | for (TaoBaoGoodsBrief g : goodsList)
|
| | | map.put(g.getAuctionId(), g.getMaterialLibType());
|
| | | for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs())
|
| | | goods.setMaterialLibType(map.get(goods.getAuctionId()));
|
| | |
|
| | | ThreadUtil.run(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | // 更新到緩存
|
| | | for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs())
|
| | | taoBaoGoodsCacheUtil.saveCommonTaoBaoGoodsInfo(goods);
|
| | | }
|
| | | });
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | List<TaoBaoSearchNav> navList = TaoBaoUtil.getBaseNav();
|
| | | if (result.getNavList() != null)
|