Browse Source

Merge branch 'feature-201819-wangdy' into release-201819-wangcz

wangdy 7 years ago
parent
commit
7b652fd95c

+ 3 - 0
src/main/java/com/uas/platform/b2c/common/account/dao/EnterpriseDao.java

@@ -21,6 +21,9 @@ public interface EnterpriseDao extends JpaSpecificationExecutor<Enterprise>, Jpa
 	@Query(value="select e.uu from Enterprise e where e.enName like %?1%")
 	@Query(value="select e.uu from Enterprise e where e.enName like %?1%")
 	public List<Long> findEnuuByName(String name);
 	public List<Long> findEnuuByName(String name);
 
 
+	@Query(value="select e.enName from Enterprise e where e.enName like %?1%")
+	public List<String> findEnNameByName(String name);
+
 	/**
 	/**
 	 * 企业资料初始化
 	 * 企业资料初始化
 	 *
 	 *

+ 11 - 0
src/main/java/com/uas/platform/b2c/common/search/constant/SearchUrl.java

@@ -38,6 +38,12 @@ public class SearchUrl {
      */
      */
     public static final String KIND_INFO_URL = "/search/kinds?keyword={keyword}&page={page}&size={size}";
     public static final String KIND_INFO_URL = "/search/kinds?keyword={keyword}&page={page}&size={size}";
 
 
+    /**
+     * 根据类目获取供应商数据
+     *
+     */
+    public static final String KIND_SELLER_URL = "/search/kindsAndSellers?keyword={keyword}&page={page}&size={size}";
+
     /**
     /**
      * 搜索品牌的id
      * 搜索品牌的id
      */
      */
@@ -48,6 +54,11 @@ public class SearchUrl {
      */
      */
     public static final String BRAND_INFO_URL = "/search/brands?keyword={keyword}&page={page}&size={size}";
     public static final String BRAND_INFO_URL = "/search/brands?keyword={keyword}&page={page}&size={size}";
 
 
+    /**
+     * 主搜索页搜索品牌带出供应商
+     */
+    public static final String BRAND_SELLERS_URL = "/search/brandsAndSellers?keyword={keyword}&page={page}&size={size}";
+
 
 
     /**
     /**
      * 搜索器件的id
      * 搜索器件的id

+ 49 - 2
src/main/java/com/uas/platform/b2c/common/search/controller/SearcherController.java

@@ -303,8 +303,54 @@ public class SearcherController {
 	 */
 	 */
 	@RequestMapping(value = "/similarKeywords", method = RequestMethod.GET)
 	@RequestMapping(value = "/similarKeywords", method = RequestMethod.GET)
 	@ResponseBody
 	@ResponseBody
-	public Map<String,Object> getSimilarKeywords(String keyword) {
-		return  searcherService.getSimilarKeywords(keyword);
+	public Map<String,Object> getSimilarKeywords(String keyword, String type) {
+		return  searcherService.getSimilarKeywords(keyword, type);
+	}
+
+	/**
+	 * 2018.19期搜索接口
+	 *
+	 * @param keyword 关键词
+	 * @return
+	 */
+	@RequestMapping(value = "/201819", method = RequestMethod.GET, params = "type=component")
+	@ResponseBody
+	public ModelMap getCompGoodsBySearch(PageParams params, String keyword, HttpServletRequest request) {
+		return searcherService.searchComponentGoods(keyword, params, request);
+	}
+
+	/**
+	 * 2018.19期搜索接口
+	 *
+	 * @param keyword 关键词
+	 * @return
+	 */
+	@RequestMapping(value = "/201819", method = RequestMethod.GET, params = "type=kind")
+	@ResponseBody
+	public ModelMap getEnterpriseBySearchProduct(PageParams params, String keyword, HttpServletRequest request) {
+		return searcherService.getEnterpriseBySearchKind(keyword, params);
+	}
+	/**
+	 * 2018.19期搜索接口
+	 *
+	 * @param keyword 关键词
+	 * @return
+	 */
+	@RequestMapping(value = "/201819", method = RequestMethod.GET, params = "type=store")
+	@ResponseBody
+	public ModelMap getEnterpriseBySearchStore(PageParams params, String keyword, HttpServletRequest request) {
+		return searcherService.getEnterpriseBySearchStore(keyword, params, request);
+	}
+	/**
+	 * 2018.19期搜索接口
+	 *
+	 * @param keyword 关键词
+	 * @return
+	 */
+	@RequestMapping(value = "/201819", method = RequestMethod.GET, params = "type=brand")
+	@ResponseBody
+	public ModelMap getEnterpriseBySearchBrand(PageParams params, String keyword, HttpServletRequest request) {
+		return searcherService.getEnterpriseBySearchBrand(keyword, params);
 	}
 	}
 
 
 	/**
 	/**
@@ -377,6 +423,7 @@ public class SearcherController {
 	 * @param types			店铺类型
 	 * @param types			店铺类型
 	 * @param keyword		查询关键字
 	 * @param keyword		查询关键字
 	 */
 	 */
+	@Deprecated
 	@RequestMapping(value = "/stores", method = RequestMethod.GET, params = "op=pageByType")
 	@RequestMapping(value = "/stores", method = RequestMethod.GET, params = "op=pageByType")
 	@ResponseBody
 	@ResponseBody
 	public List<Map<String, Object>> pageStoresByTypesAndKeyword(PageParams params, String types,HttpServletRequest request, @RequestParam(required = false) String keyword) {
 	public List<Map<String, Object>> pageStoresByTypesAndKeyword(PageParams params, String types,HttpServletRequest request, @RequestParam(required = false) String keyword) {

+ 74 - 15
src/main/java/com/uas/platform/b2c/common/search/rpc/service/Impl/SearchServiceImpl.java

@@ -3,6 +3,7 @@ package com.uas.platform.b2c.common.search.rpc.service.Impl;
 
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
+import com.uas.platform.b2c.common.account.dao.EnterpriseDao;
 import com.uas.platform.b2c.common.search.constant.SearchUrl;
 import com.uas.platform.b2c.common.search.constant.SearchUrl;
 import com.uas.platform.b2c.common.search.rpc.service.SearchService;
 import com.uas.platform.b2c.common.search.rpc.service.SearchService;
 import com.uas.platform.b2c.common.search.util.CollectField;
 import com.uas.platform.b2c.common.search.util.CollectField;
@@ -18,9 +19,11 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 import org.springframework.util.StringUtils;
 import org.springframework.web.client.RestTemplate;
 import org.springframework.web.client.RestTemplate;
 
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.Set;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 
 /**
 /**
  * 通过resttemplate调用搜索接口的实现方法
  * 通过resttemplate调用搜索接口的实现方法
@@ -34,10 +37,20 @@ public class SearchServiceImpl implements SearchService{
 
 
     private final SysConf sysConf;
     private final SysConf sysConf;
 
 
+    private final EnterpriseDao enterpriseDao;
+
+    private static final String ALL = "all";
+    private static final String COMPONENT = "component";
+    private static final String KIND = "kind";
+    private static final String BRAND = "brand";
+    private static final String STORE = "store";
+
+
     @Autowired
     @Autowired
-    public SearchServiceImpl(RestTemplate restTemplate, SysConf sysConf) {
+    public SearchServiceImpl(RestTemplate restTemplate, SysConf sysConf, EnterpriseDao enterpriseDao) {
         this.restTemplate = restTemplate;
         this.restTemplate = restTemplate;
         this.sysConf = sysConf;
         this.sysConf = sysConf;
+        this.enterpriseDao = enterpriseDao;
     }
     }
 
 
     @Override
     @Override
@@ -74,6 +87,23 @@ public class SearchServiceImpl implements SearchService{
         }
         }
     }
     }
 
 
+    @Override
+    public Map<String, Object> getKindsAndSellers(String keyword, Integer page, Integer size) throws SearchException {
+        Map<String, Object> map = initSearchMap(keyword, page, size);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.KIND_SELLER_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                Map<String, Object> sPage = FastjsonUtils.fromJson(str, Map.class);
+                return sPage;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+
     @Override
     @Override
     public SPage<Long> getProducts(Long enUU, String keyword, Integer page, Integer size, String type) throws SearchException {
     public SPage<Long> getProducts(Long enUU, String keyword, Integer page, Integer size, String type) throws SearchException {
         Map<String, Object> map = initSearchMap(keyword, page, size);
         Map<String, Object> map = initSearchMap(keyword, page, size);
@@ -142,6 +172,23 @@ public class SearchServiceImpl implements SearchService{
         }
         }
     }
     }
 
 
+    @Override
+    public SPage<Map<String, Object>> getbrandsAndSellers(String keyword, Integer page, Integer size) throws SearchException {
+        Map<String, Object> map = initSearchMap(keyword, page, size);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.BRAND_SELLERS_URL, String.class, map);
+        if(StringUtils.isEmpty(str)) {
+            return null;
+        }else {
+            try {
+                SPage<Map<String, Object>> sPage = FastjsonUtils.fromJson(str, SPage.class);
+                return sPage;
+            }catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+    }
+
     @Override
     @Override
     public Map<String, Object> getComponentIds(String keyword, PageParams var2) throws SearchException {
     public Map<String, Object> getComponentIds(String keyword, PageParams var2) throws SearchException {
         Map<String, Object> map = new HashedMap();
         Map<String, Object> map = new HashedMap();
@@ -238,26 +285,38 @@ public class SearchServiceImpl implements SearchService{
     }
     }
 
 
     @Override
     @Override
-    public Map<String,Object> getSimilarKeywords(String keyword) throws SearchException {
+    public Map<String,Object> getSimilarKeywords(String keyword, String type) throws SearchException {
         Map<String, Object> map = new HashedMap();
         Map<String, Object> map = new HashedMap();
         map.put("keyword", keyword);
         map.put("keyword", keyword);
-        String strA = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.SIMILAR_KEYWORD_URL, String.class, map);
-        String strC = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.SIMILAR_COMPONENT_URL, String.class, map);
-        String strB = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.SIMILAR_BRAND_URL, String.class, map);
-        String strK = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.SIMILAR_KIND_URL, String.class, map);
-        if(StringUtils.isEmpty(strC) && StringUtils.isEmpty(strB) && StringUtils.isEmpty(strK)) {
+        String result;
+        switch (type) {
+            case COMPONENT:
+                result = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.SIMILAR_COMPONENT_URL, String.class, map);
+                break;
+            case BRAND:
+                result = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.SIMILAR_BRAND_URL, String.class, map);
+                break;
+            case KIND:
+                result = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.SIMILAR_KIND_URL, String.class, map);
+                break;
+            case STORE:
+                // 店铺(供应商)联想词
+                List<String> ens = enterpriseDao.findEnNameByName(keyword);
+                result = JSON.toJSONString(ens.stream().map(en -> {Map s = new HashMap ();s.put("name", en);return s;}).collect(Collectors.toList())
+                            );
+                break;
+            default:
+                result = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.SIMILAR_KEYWORD_URL, String.class, map);
+                break;
+        }
+
+        if(StringUtils.isEmpty(result)) {
             return null;
             return null;
         }else {
         }else {
             try {
             try {
-                List<String> reMapA = FastjsonUtils.fromJson(strA, List.class);
-                List<Object> reMapC = FastjsonUtils.fromJsonArray(strC);
-                List<Object> reMapB = FastjsonUtils.fromJsonArray(strB);
-                List<Object> reMapK = FastjsonUtils.fromJsonArray(strK);
+                List<Object> resultMap = FastjsonUtils.fromJsonArray(result);
                 map.clear();
                 map.clear();
-                map.put("all",reMapA);
-                map.put("kind",reMapK);
-                map.put("component",reMapC);
-                map.put("brand",reMapB);
+                map.put("result",resultMap);
                 return map;
                 return map;
             }catch (Exception e) {
             }catch (Exception e) {
                 e.printStackTrace();
                 e.printStackTrace();

+ 5 - 1
src/main/java/com/uas/platform/b2c/common/search/rpc/service/SearchService.java

@@ -19,12 +19,16 @@ public interface SearchService {
 
 
     SPage<Map<String, Object>> getKinds(String keyword, Integer page, Integer size) throws SearchException;
     SPage<Map<String, Object>> getKinds(String keyword, Integer page, Integer size) throws SearchException;
 
 
+    Map<String, Object> getKindsAndSellers(String keyword, Integer page, Integer size) throws SearchException;
+
     SPage<Long> getProducts(Long enUU, String keyword, Integer page, Integer size, String type) throws SearchException;
     SPage<Long> getProducts(Long enUU, String keyword, Integer page, Integer size, String type) throws SearchException;
 
 
     SPage<Long> getBrandIds(String keyword, Integer page, Integer size) throws SearchException;
     SPage<Long> getBrandIds(String keyword, Integer page, Integer size) throws SearchException;
 
 
     SPage<Map<String, Object>> getBrands(String keyword, Integer page, Integer size) throws SearchException;
     SPage<Map<String, Object>> getBrands(String keyword, Integer page, Integer size) throws SearchException;
 
 
+    SPage<Map<String, Object>> getbrandsAndSellers(String keyword, Integer page, Integer size) throws SearchException;
+
     Map<String, Object> getComponentIds(String keyword, PageParams var2) throws SearchException;
     Map<String, Object> getComponentIds(String keyword, PageParams var2) throws SearchException;
 
 
     Set<Long> getKindIdsBySearchComponent(String keyword, String brandId) throws SearchException;
     Set<Long> getKindIdsBySearchComponent(String keyword, String brandId) throws SearchException;
@@ -35,7 +39,7 @@ public interface SearchService {
 
 
     List<Map<String, Object>> getBrandsBySearchComponent(String keyword, String kindId) throws SearchException;
     List<Map<String, Object>> getBrandsBySearchComponent(String keyword, String kindId) throws SearchException;
 
 
-    Map<String,Object> getSimilarKeywords(String keyword) throws SearchException;
+    Map<String,Object> getSimilarKeywords(String keyword, String type) throws SearchException;
 
 
     Map<String,Object> getProductSimilarKeywords(String keyword) throws SearchException;
     Map<String,Object> getProductSimilarKeywords(String keyword) throws SearchException;
 
 

+ 12 - 2
src/main/java/com/uas/platform/b2c/common/search/service/SearcherService.java

@@ -81,7 +81,16 @@ public interface SearcherService {
 	 * @throws IOException
 	 * @throws IOException
 	 */
 	 */
 	public ModelMap searchComponentGoods(String keyword, PageParams page , HttpServletRequest request);
 	public ModelMap searchComponentGoods(String keyword, PageParams page , HttpServletRequest request);
-    /**
+
+
+	/**
+	 * 201819期搜索接口调整
+	 */
+	public ModelMap getEnterpriseBySearchKind(String keyword, PageParams page);
+	public ModelMap getEnterpriseBySearchStore(String keyword, PageParams page, HttpServletRequest request);
+	public ModelMap getEnterpriseBySearchBrand(String keyword, PageParams page);
+
+	/**
      * 批次搜索数量统计
      * 批次搜索数量统计
      *
      *
      * @param keyword 关键词
      * @param keyword 关键词
@@ -132,9 +141,10 @@ public interface SearcherService {
 	 * 根据输入获取联想词(包括器件、类目、品牌,按顺序获取,数量不足,才会获取下一个)
 	 * 根据输入获取联想词(包括器件、类目、品牌,按顺序获取,数量不足,才会获取下一个)
 	 * 
 	 * 
 	 * @param keyword 关键词
 	 * @param keyword 关键词
+	 * @param type  搜索类型(component,product,store,brand)
 	 * @return 联想词
 	 * @return 联想词
 	 */
 	 */
-	public Map<String,Object> getSimilarKeywords(String keyword);
+	public Map<String,Object> getSimilarKeywords(String keyword, String type);
 
 
 	/**
 	/**
 	 * 根据输入获取联想词(包括器件、类目、品牌,按顺序获取)
 	 * 根据输入获取联想词(包括器件、类目、品牌,按顺序获取)

+ 247 - 55
src/main/java/com/uas/platform/b2c/common/search/service/impl/SearcherServiceImpl.java

@@ -1,7 +1,9 @@
 package com.uas.platform.b2c.common.search.service.impl;
 package com.uas.platform.b2c.common.search.service.impl;
 
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
+import com.uas.platform.b2c.common.account.dao.EnterpriseDao;
 import com.uas.platform.b2c.common.account.model.User;
 import com.uas.platform.b2c.common.account.model.User;
 import com.uas.platform.b2c.common.search.dao.SearchHistoryDao;
 import com.uas.platform.b2c.common.search.dao.SearchHistoryDao;
 import com.uas.platform.b2c.common.search.model.SearchHistory;
 import com.uas.platform.b2c.common.search.model.SearchHistory;
@@ -18,16 +20,24 @@ import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
 import com.uas.platform.b2c.prod.commodity.dao.PCBDao;
 import com.uas.platform.b2c.prod.commodity.dao.PCBDao;
 import com.uas.platform.b2c.prod.commodity.dao.ProductDao;
 import com.uas.platform.b2c.prod.commodity.dao.ProductDao;
 import com.uas.platform.b2c.prod.commodity.model.Goods;
 import com.uas.platform.b2c.prod.commodity.model.Goods;
+import com.uas.platform.b2c.prod.commodity.model.Product;
 import com.uas.platform.b2c.prod.product.brand.dao.BrandDao;
 import com.uas.platform.b2c.prod.product.brand.dao.BrandDao;
+import com.uas.platform.b2c.prod.product.brand.modal.Brand;
 import com.uas.platform.b2c.prod.product.component.dao.ComponentDao;
 import com.uas.platform.b2c.prod.product.component.dao.ComponentDao;
 import com.uas.platform.b2c.prod.product.component.dao.ComponentGoodsDao;
 import com.uas.platform.b2c.prod.product.component.dao.ComponentGoodsDao;
 import com.uas.platform.b2c.prod.product.component.dao.ComponentInfoDao;
 import com.uas.platform.b2c.prod.product.component.dao.ComponentInfoDao;
-import com.uas.platform.b2c.prod.product.component.modal.ComponentGoods;
 import com.uas.platform.b2c.prod.product.component.modal.ComponentInfo;
 import com.uas.platform.b2c.prod.product.component.modal.ComponentInfo;
+import com.uas.platform.b2c.prod.store.dao.StoreInDao;
+import com.uas.platform.b2c.prod.store.model.StoreIn;
+import com.uas.platform.b2c.prod.store.model.StoreStatus;
+
 import com.uas.platform.b2c.trade.order.dao.OrderDetailDao;
 import com.uas.platform.b2c.trade.order.dao.OrderDetailDao;
+import com.uas.platform.b2c.trade.vendor.model.VendorIntroduction;
+import com.uas.platform.b2c.trade.vendor.service.VendorIntroductionService;
 import com.uas.platform.core.exception.SystemException;
 import com.uas.platform.core.exception.SystemException;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageParams;
 import com.uas.platform.core.model.PageParams;
+import com.uas.platform.core.persistence.criteria.PredicateUtils;
 import com.uas.search.exception.SearchException;
 import com.uas.search.exception.SearchException;
 import java.io.IOException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.ArrayList;
@@ -39,12 +49,17 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.Set;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.domain.Specification;
 import org.springframework.mobile.device.DeviceResolver;
 import org.springframework.mobile.device.DeviceResolver;
 import org.springframework.mobile.device.LiteDeviceResolver;
 import org.springframework.mobile.device.LiteDeviceResolver;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -91,6 +106,18 @@ public class SearcherServiceImpl implements SearcherService {
 	@Autowired
 	@Autowired
     private OrderDetailDao orderDetailDao;
     private OrderDetailDao orderDetailDao;
 
 
+    @Autowired
+    private VendorIntroductionService vendorIntroductionService;
+
+    @Autowired
+    private StoreInDao storeInDao;
+
+    @Autowired
+    private EnterpriseDao enterpriseDao;
+
+    // private StoreInService storeInService;
+
+
 	private Logger logger = LoggerFactory.getLogger(getClass());
 	private Logger logger = LoggerFactory.getLogger(getClass());
 	private final DeviceResolver deviceResolver = new LiteDeviceResolver();
 	private final DeviceResolver deviceResolver = new LiteDeviceResolver();
 
 
@@ -223,67 +250,228 @@ public class SearcherServiceImpl implements SearcherService {
 				}
 				}
 			}
 			}
 		}
 		}
-		ModelMap map = new ModelMap();
+
 		Map<String,Object> results = null;
 		Map<String,Object> results = null;
 		//Map<String, Object> results = new HashMap<>();
 		//Map<String, Object> results = new HashMap<>();
+        com.uas.platform.b2c.common.search.util.PageParams pageParams = new com.uas.platform.b2c.common.search.util.PageParams();
+        pageParams.setPage(page.getPage());
+        pageParams.setSize(page.getCount());
 		try {
 		try {
-			results = searchService.getGoodsIds(keyword, convertPageParams(page));
+			results = searchService.getGoodsIds(keyword, pageParams);
 		} catch (SearchException e) {
 		} catch (SearchException e) {
 			throwSystemException(e);
 			throwSystemException(e);
 		}
 		}
-		//统计精准匹配到品牌的数量(便于展示唯一的品牌)
-		ModelMap brandMap = searchBrand(keyword,null);
-		List<Map<String, Object>> brands = (List)brandMap.get("brands");
-		if (!CollectionUtils.isEmpty(brands)) {
-			for (Map<String, Object> brand : brands){
-				if (keyword.equalsIgnoreCase(brand.get("nameCn").toString()) || keyword.equalsIgnoreCase(brand.get("nameEn").toString())){
-					map.put("brands",brand);
-					brandDao.addSearchCount(brand.get("uuid").toString());
-				}
-			}
-		}
-		if ((int)results.get("total") == 0){
-			map.put("total", results.get("total"));// 搜索结果总数
-			map.put("page", results.get("page"));// 当前页面
-			map.put("size", results.get("size"));// 每页个数
-			map.put("components", new ArrayList<>());// 当前页器件内容
-			return map;
-		}
-		List<Integer> componentIds = (List<Integer>)results.get("componentIds");
-		List<Integer> goodsIds = (List<Integer>)results.get("goodsIds");
-		List<ComponentGoods> components = new ArrayList<>();
-		if (!CollectionUtils.isEmpty(componentIds)) {
-			for (int i = 0 ;i < componentIds.size() ; i++){
-				Long cid = null;
-				if(!StringUtils.isEmpty
-						(componentIds.get(i)))  {
-					cid = Long.valueOf(componentIds.get(i).toString());
-				}
-				Long gid = goodsIds.get(i) == null ? 0L : Long.valueOf(goodsIds.get(i).toString());
-				if((cid == null) && (gid != 0L)) {
-					Goods goods = goodsDao.findOne(gid);
-					if(goods != null) {
-						components.add(new ComponentGoods(goods));
-					}
-				}else if(cid != null){
-					ComponentGoods componentGoods = componentGoodsDao.findByCmpIdAndGoId(cid, gid);
-					if (componentGoods != null){
-						components.add(componentGoods);
-					}
-				}
-			}
-			map.put("components", components);// 当前页器件内容
-            // 假如第一个结果与器件型号一致,则该型号增加一次 搜索量
-            if (components.get(0).getCode().equals(keyword)) {
-                componentDao.addSearchCount(components.get(0).getUuid());
+        ModelMap resultMap = new ModelMap();
+        List<Goods> goodsList = new ArrayList<>();
+        Map stockMap = new HashMap();
+        List<Product> productList = new ArrayList<>();
+        Map futuresMap = new HashMap();
+
+        SPage<Long> stockPage = (SPage<Long>) ((JSONObject)results.get("stock")).toJavaObject(SPage.class);
+        SPage<Long> futuresPage = (SPage<Long>) ((JSONObject)results.get("futures")).toJavaObject(SPage.class);
+        for (Long goodsId : stockPage.getContent()) {
+            goodsList.add(goodsDao.findOne(goodsId));
+        }
+
+        for (Object PrId : futuresPage.getContent()) {
+            productList.add(productDao.findOne(Long.valueOf(PrId.toString())));
+        }
+
+        stockMap.put("content", goodsList);
+        stockMap.put("total",stockPage.getTotalElement());
+        stockMap.put("page",stockPage.getPage());
+        stockMap.put("size",stockPage.getSize());
+
+        futuresMap.put("content", productList);
+        futuresMap.put("total",futuresPage.getTotalElement());
+        futuresMap.put("page",futuresPage.getPage());
+        futuresMap.put("size",futuresPage.getSize());
+
+        resultMap.put("stock", stockMap); // 现货
+        resultMap.put("futures",futuresMap); // 期货
+
+        return resultMap;
+    }
+
+    @Override
+    public ModelMap getEnterpriseBySearchKind(String keyword, PageParams page) {
+        ModelMap resultMap = new ModelMap();
+        Map<String, Object> kindsMap = null;
+        try {
+            kindsMap = searchService.getKindsAndSellers(keyword, page.getPage(), page.getCount());
+        } catch (SearchException e) {
+            throwSystemException(e);
+        }
+
+        List<String> storeIds = ((SPage<String>) ((JSONObject)kindsMap.get("stock")).toJavaObject(SPage.class)).getContent();
+        List<Object> enUUs = ((SPage<Object>) ((JSONObject)kindsMap.get("futures")).toJavaObject(SPage.class)).getContent();
+
+        List<VendorIntroduction> vendorIntroductionsStocks = new ArrayList<>();
+        List<VendorIntroduction> vendorIntroductionsFutures = new ArrayList<>();
+
+        for (String storeId : storeIds) {
+            vendorIntroductionsStocks.add(VendorIntroduction.convertFromStoreIn(storeInDao.findByUuid(storeId)));
+        }
+
+        for (Object enuu : enUUs) {
+            vendorIntroductionsFutures.add(VendorIntroduction.convertFromEnterprise(enterpriseDao.findByUu(Long.valueOf(enuu.toString()))));
+        }
+
+        HashMap stock = new HashMap();
+        stock.put("content", vendorIntroductionsStocks);
+        stock.put("page",((SPage<Object>) ((JSONObject)kindsMap.get("stock")).toJavaObject(SPage.class)).getPage());
+        stock.put("size",((SPage<Object>) ((JSONObject)kindsMap.get("stock")).toJavaObject(SPage.class)).getSize());
+        stock.put("total", ((SPage<Object>) ((JSONObject)kindsMap.get("stock")).toJavaObject(SPage.class)).getTotalElement());
+
+        HashMap futures = new HashMap();
+        futures.put("content", vendorIntroductionsFutures);
+        futures.put("page",((SPage<Object>) ((JSONObject)kindsMap.get("futures")).toJavaObject(SPage.class)).getPage());
+        futures.put("size",((SPage<Object>) ((JSONObject)kindsMap.get("futures")).toJavaObject(SPage.class)).getSize());
+        futures.put("total",((SPage<Object>) ((JSONObject)kindsMap.get("futures")).toJavaObject(SPage.class)).getTotalElement());
+
+        resultMap.put("stock", stock); // 现货
+        resultMap.put("futures", futures); // 期货
+
+        return resultMap;
+    }
+
+    @Override
+    public ModelMap getEnterpriseBySearchStore(String keyword, PageParams page, HttpServletRequest request) {
+        ModelMap resultMap = new ModelMap();
+        Map stock = new HashMap();
+        Map futures = new HashMap();
+        com.uas.sso.support.Page<VendorIntroduction> vendorIntroductionPage = vendorIntroductionService.getVendorIntroduction(page.getPage(),page.getCount(),keyword,null);
+        futures.put("content",vendorIntroductionPage.getContent());
+        futures.put("page",vendorIntroductionPage.getNumber());
+        futures.put("total",vendorIntroductionPage.getTotalElements());
+        futures.put("size",vendorIntroductionPage.getSize());
+
+        User user = (User)request.getSession().getAttribute("user");
+        SystemSession.setUser(user);
+        PageInfo pageInfo = new PageInfo(page);
+        Page<StoreIn> stores = pageStoresByTypesAndKeyword(pageInfo, keyword, request);
+        List<VendorIntroduction> vendorIntroductions = new ArrayList<>();
+        for (StoreIn storeIn : stores) {
+            vendorIntroductions.add(VendorIntroduction.convertFromStoreIn(storeIn));
+        }
+
+        stock.put("content",vendorIntroductions);
+        stock.put("page",stores.getNumber());
+        stock.put("total",stores.getTotalElements());
+        stock.put("size",stores.getSize());
+
+        resultMap.put("stock", stock); // 现货
+        resultMap.put("futures", futures); // 期货
+
+        return resultMap;
+    }
+
+    public Page<StoreIn> pageStoresByTypesAndKeyword(final PageInfo pageInfo, String keyword, HttpServletRequest request) {
+        if (!StringUtils.isEmpty(keyword)) {
+            // keyword 只过滤店铺名称,可以使用此方法,否则,搜索多个字段需要生成查询条件
+            pageInfo.filter("storeName", keyword);
+        }
+        // 添加过滤条件为店铺已开店的
+        pageInfo.expression(PredicateUtils.eq("status", StoreStatus.OPENED, false));
+
+        // 设置排序
+        pageInfo.sorting(org.springframework.data.domain.Sort.Direction.DESC, "totalReserve", "createTime");
+
+        Page<StoreIn> storeInPage =  storeInDao.findAll(new Specification<StoreIn>() {
+            @Override
+            public Predicate toPredicate(Root<StoreIn> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
+                query.where(pageInfo.getPredicates(root, query, builder));
+                return null;
             }
             }
-		}
+        }, pageInfo);
 
 
-        map.put("total", results.get("total"));// 搜索结果总数
-        map.put("page", results.get("page"));// 当前页面
-        map.put("size", results.get("size"));// 每页个数
+        if (this.deviceResolver.resolveDevice(request).isMobile()) {
+            SystemSession.setUser((User)request.getSession().getAttribute("user"));
+            if (null != SystemSession.getUser() && null!= SystemSession.getUser().getUserUU()){
+                SearchHistory searchHistory = null;
+                List<SearchHistory> searchHistories = searchHistoryDao.findByKeywordAndUserUUAndUserEnuu(keyword,SystemSession.getUser().getUserUU(),SystemSession.getUser().getEnterprise() != null ?SystemSession.getUser().getEnterprise().getUu():null);
+                if (searchHistories.size()>0){
+                    searchHistory = searchHistories.get(0);
+                }else {
+                    searchHistory = new SearchHistory();
+                }
+                searchHistory.setKeyword(keyword);
+                searchHistory.setSearchTime(new Date(System.currentTimeMillis()));
+                searchHistory.setUserUU(SystemSession.getUser().getUserUU());
+                searchHistory.setUserEnuu(SystemSession.getUser().getEnterprise() != null ?SystemSession.getUser().getEnterprise().getUu():null);
+                searchHistory.setType(Type.SEARCH_STORE.name());
+                searchHistoryDao.save(searchHistory);
+                searchHistories = searchHistoryDao.findByUserUUAndUserEnuuOrderBySearchTimeDesc(SystemSession.getUser().getUserUU(),SystemSession.getUser().getEnterprise() != null ?SystemSession.getUser().getEnterprise().getUu():null);
+                if (searchHistories.size()>10){
+                    searchHistoryDao.delete(searchHistories.subList(10,searchHistories.size()));
+                }
+            }
+        }
 
 
-        return map;
+        return storeInPage;
+    }
+
+    @Override
+    public ModelMap getEnterpriseBySearchBrand(String keyword, PageParams page) {
+
+        ModelMap resultMap = new ModelMap();
+        SPage<Map<String, Object>> brandsMap = null;
+        try {
+            brandsMap = searchService.getbrandsAndSellers(keyword, page.getPage(), page.getCount());
+        } catch (SearchException e) {
+            throwSystemException(e);
+        }
+
+        if (brandsMap.getTotalElement() < 1) {
+            resultMap.put("total", 0);
+            return resultMap;
+        } else {
+            if (brandsMap.getContent().get(0).containsKey("futures")) {
+                // 精准匹配
+                brandDao.addSearchCount(Long.valueOf(((List)brandsMap.getContent().get(0).get("brandIds")).get(0).toString()));
+                List<String> storeIds = ((SPage<String>) ((JSONObject)brandsMap.getContent().get(0).get("stock")).toJavaObject(SPage.class)).getContent();
+                List<Object> enUUs = ((SPage<Object>) ((JSONObject)brandsMap.getContent().get(0).get("futures")).toJavaObject(SPage.class)).getContent();
+
+                List<VendorIntroduction> vendorIntroductionsStocks = new ArrayList<>();
+                List<VendorIntroduction> vendorIntroductionsFutures = new ArrayList<>();
+
+                for (String storeId : storeIds) {
+                    vendorIntroductionsStocks.add(VendorIntroduction.convertFromStoreIn(storeInDao.findByUuid(storeId)));
+                }
+
+                for (Object enuu : enUUs) {
+                    vendorIntroductionsFutures.add(VendorIntroduction.convertFromEnterprise(enterpriseDao.findByUu(Long.valueOf(enuu.toString()))));
+                }
+
+                HashMap stock = new HashMap();
+                stock.put("content", vendorIntroductionsStocks);
+                stock.put("page",((SPage<Object>) ((JSONObject)brandsMap.getContent().get(0).get("stock")).toJavaObject(SPage.class)).getPage());
+                stock.put("size",((SPage<Object>) ((JSONObject)brandsMap.getContent().get(0).get("stock")).toJavaObject(SPage.class)).getSize());
+                stock.put("total",((SPage<Object>) ((JSONObject)brandsMap.getContent().get(0).get("stock")).toJavaObject(SPage.class)).getTotalElement());
+
+                HashMap futures = new HashMap();
+                futures.put("content", vendorIntroductionsFutures);
+                futures.put("page",((SPage<Object>) ((JSONObject)brandsMap.getContent().get(0).get("futures")).toJavaObject(SPage.class)).getPage());
+                futures.put("size",((SPage<Object>) ((JSONObject)brandsMap.getContent().get(0).get("futures")).toJavaObject(SPage.class)).getSize());
+                futures.put("total",((SPage<Object>) ((JSONObject)brandsMap.getContent().get(0).get("futures")).toJavaObject(SPage.class)).getTotalElement());
+
+                resultMap.put("stock", stock); // 现货
+                resultMap.put("futures", futures); // 期货
+                resultMap.put("brand", brandDao.findOne(Long.valueOf(((List)brandsMap.getContent().get(0).get("brandIds")).get(0).toString())));
+                return resultMap;
+            } else {
+
+                resultMap.put("page",brandsMap.getPage());
+                resultMap.put("size",brandsMap.getSize());
+                resultMap.put("total",brandsMap.getTotalElement());
+                List<Brand> brandList = new ArrayList<>();
+                for (Object brId : (JSONArray)brandsMap.getContent().get(0).get("brandIds")) {
+                    brandList.add(brandDao.findOne(Long.valueOf(brId.toString())));
+                }
+                resultMap.put("content", brandList);
+                return resultMap;
+            }
+        }
     }
     }
 
 
     /**
     /**
@@ -406,10 +594,13 @@ public class SearcherServiceImpl implements SearcherService {
     }
     }
 
 
     @Override
     @Override
-    public Map<String, Object> getSimilarKeywords(String keyword) {
+    public Map<String, Object> getSimilarKeywords(String keyword, String type) {
         Map<String, Object> result = null;
         Map<String, Object> result = null;
+        if (StringUtils.isEmpty(type)) {
+            type = "all";
+        }
         try {
         try {
-            result = searchService.getSimilarKeywords(keyword);
+            result = searchService.getSimilarKeywords(keyword, type);
         } catch (SearchException e) {
         } catch (SearchException e) {
             throwSystemException(e);
             throwSystemException(e);
         }
         }
@@ -595,4 +786,5 @@ public class SearcherServiceImpl implements SearcherService {
         map.put("size", results.get("size"));// 每页个数
         map.put("size", results.get("size"));// 每页个数
 	    return map;
 	    return map;
     }
     }
+
 }
 }

+ 2 - 2
src/main/java/com/uas/platform/b2c/prod/product/brand/dao/BrandDao.java

@@ -88,8 +88,8 @@ public interface BrandDao extends JpaSpecificationExecutor<Brand>, JpaRepository
 	 */
 	 */
 	@Modifying
 	@Modifying
 	@Transactional
 	@Transactional
-	@Query( nativeQuery = true, value = "update product$brand b set b.br_search_count = ifnull(b.br_search_count, 0) + 1 where b.br_uuid = :uuid")
-	public void addSearchCount(@Param("uuid") String uuid);
+	@Query( nativeQuery = true, value = "update product$brand b set b.br_search_count = ifnull(b.br_search_count, 0) + 1 where b.br_id = :id")
+	public void addSearchCount(@Param("id") Long id);
 
 
     /**
     /**
      * 分页根据首字母获取品牌信息
      * 分页根据首字母获取品牌信息

+ 13 - 0
src/main/java/com/uas/platform/b2c/prod/store/model/EnterpriseSimple.java

@@ -99,6 +99,11 @@ public class EnterpriseSimple {
 	 */
 	 */
 	private String description;
 	private String description;
 
 
+	/**
+	 * 店铺UUID
+	 */
+	private String storeUuid;
+
 	public String getDescription() {
 	public String getDescription() {
 		return description;
 		return description;
 	}
 	}
@@ -238,6 +243,14 @@ public class EnterpriseSimple {
 		this.enQQ = enQQ;
 		this.enQQ = enQQ;
 	}
 	}
 
 
+	public String getStoreUuid() {
+		return storeUuid;
+	}
+
+	public void setStoreUuid(String storeUuid) {
+		this.storeUuid = storeUuid;
+	}
+
 	public static EnterpriseSimple translateSimple(Enterprise enterprise) {
 	public static EnterpriseSimple translateSimple(Enterprise enterprise) {
 		EnterpriseSimple simple = new EnterpriseSimple();
 		EnterpriseSimple simple = new EnterpriseSimple();
 		simple.uu = enterprise.getUu();
 		simple.uu = enterprise.getUu();

+ 49 - 0
src/main/java/com/uas/platform/b2c/trade/vendor/model/VendorIntroduction.java

@@ -1,5 +1,8 @@
 package com.uas.platform.b2c.trade.vendor.model;
 package com.uas.platform.b2c.trade.vendor.model;
 
 
+import com.uas.platform.b2c.common.account.model.Enterprise;
+import com.uas.platform.b2c.prod.store.model.StoreIn;
+
 /**
 /**
  * 供应商推荐实体
  * 供应商推荐实体
  * Created by dongbw
  * Created by dongbw
@@ -82,6 +85,11 @@ public class VendorIntroduction {
      */
      */
     private String storeLogoUrl;
     private String storeLogoUrl;
 
 
+    /**
+     * 店铺uuid
+     */
+    private String storeUuid;
+
     /**
     /**
      * 企业 logo Url
      * 企业 logo Url
      */
      */
@@ -207,6 +215,14 @@ public class VendorIntroduction {
         this.storeLogoUrl = storeLogoUrl;
         this.storeLogoUrl = storeLogoUrl;
     }
     }
 
 
+    public String getStoreUuid() {
+        return storeUuid;
+    }
+
+    public void setStoreUuid(String storeUuid) {
+        this.storeUuid = storeUuid;
+    }
+
     public String getEnLogoUrl() {
     public String getEnLogoUrl() {
         return enLogoUrl;
         return enLogoUrl;
     }
     }
@@ -214,4 +230,37 @@ public class VendorIntroduction {
     public void setEnLogoUrl(String enLogoUrl) {
     public void setEnLogoUrl(String enLogoUrl) {
         this.enLogoUrl = enLogoUrl;
         this.enLogoUrl = enLogoUrl;
     }
     }
+
+    public static VendorIntroduction convertFromStoreIn(StoreIn storeIn) {
+        VendorIntroduction vendorIntroduction  = new VendorIntroduction();
+        vendorIntroduction.setStoreUuid(storeIn.getUuid());
+        vendorIntroduction.setEnAddress(storeIn.getEnterprise().getEnAddress());
+        vendorIntroduction.setEnBusinesscode(storeIn.getEnterprise().getEnBusinessCode());
+        vendorIntroduction.setEnEmail(storeIn.getEnterprise().getEnEmail());
+        vendorIntroduction.setEnIndustry(storeIn.getEnterpriseInfo().getEnIndustry());
+        vendorIntroduction.setEnUU(storeIn.getEnterpriseInfo().getUu());
+        vendorIntroduction.setEnName(storeIn.getEnterpriseInfo().getEnName());
+        vendorIntroduction.setEnShortname(storeIn.getEnterpriseInfo().getEnShortname());
+        vendorIntroduction.setEnTel(storeIn.getEnterpriseInfo().getEnTel());
+        vendorIntroduction.setEnCorporation(storeIn.getEnterpriseInfo().getEnCorporation());
+        vendorIntroduction.setEnLogoUrl(storeIn.getEnterpriseInfo().getEnLogoUrl());
+        vendorIntroduction.setStoreLogoUrl(storeIn.getLogoUrl());
+        return vendorIntroduction;
+    }
+
+    public static VendorIntroduction convertFromEnterprise(Enterprise enterprise) {
+        VendorIntroduction vendorIntroduction  = new VendorIntroduction();
+        vendorIntroduction.setEnAddress(enterprise.getEnAddress());
+        vendorIntroduction.setEnBusinesscode(enterprise.getEnBussinessCode());
+        vendorIntroduction.setEnEmail(enterprise.getEnEmail());
+        vendorIntroduction.setEnIndustry(enterprise.getEnIndustry());
+        vendorIntroduction.setEnUU(enterprise.getUu());
+        vendorIntroduction.setEnName(enterprise.getEnName());
+        vendorIntroduction.setEnShortname(enterprise.getEnShortname());
+        vendorIntroduction.setEnTel(enterprise.getEnTel());
+        vendorIntroduction.setEnCorporation(enterprise.getEnCorporation());
+        vendorIntroduction.setEnLogoUrl(enterprise.getEnLogoUrl());
+        vendorIntroduction.setIsStore(enterprise.getEnMallVendorStatus().intValue() ==  313 ? new Short("1") : 0);
+        return vendorIntroduction;
+    }
 }
 }