zhijiezhao 3 anos atrás
pai
commit
6795b2aa9e

+ 3 - 2
src/main/java/com/caimei365/commodity/controller/SearchProductApi.java

@@ -94,6 +94,7 @@ public class SearchProductApi {
     @ApiImplicitParams({
             @ApiImplicitParam(required = true, name = "id", value = "bigTypeID/smallTypeID/tinyTypeID"),
             @ApiImplicitParam(required = true, name = "idType", value = "id类型:1一级分类,2二级分类,3三级分类"),
+            @ApiImplicitParam(required = false, name = "brandIds", value = "品牌id字符串,逗号隔开"),
             @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构"),
             @ApiImplicitParam(required = false, name = "newFlag", value = "查询新品标记,默认0,新品1"),
             @ApiImplicitParam(required = false, name = "promotionFlag", value = "查询促销标记,默认0,促销1"),
@@ -103,14 +104,14 @@ public class SearchProductApi {
             @ApiImplicitParam(required = false, name = "sortType", value = "排序规则:1降序,其他升序")
     })
     @GetMapping("/product/type")
-    public ResponseJson<String> queryProductByType(Integer id, Integer idType,
+    public ResponseJson<String> queryProductByType(Integer id, Integer idType, String brandIds,
                                                    @RequestParam(value = "identity", defaultValue = "0") Integer identity,
                                                    @RequestParam(value = "newFlag", defaultValue = "0") Integer newFlag,
                                                    @RequestParam(value = "promotionFlag", defaultValue = "0") Integer promotionFlag,
                                                    @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                    @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
                                                    String sortField, Integer sortType) {
-        return searchProductService.queryProductByType(id, idType, identity, newFlag, promotionFlag, pageNum, pageSize, sortField, sortType);
+        return searchProductService.queryProductByType(id, idType, brandIds, identity, newFlag, promotionFlag, pageNum, pageSize, sortField, sortType);
     }
 
     /**

+ 1 - 1
src/main/java/com/caimei365/commodity/service/SearchProductService.java

@@ -40,7 +40,7 @@ public interface SearchProductService {
      * @param sortType  升降序0/1
      * @return JsonStr(list)
      */
-    ResponseJson<String> queryProductByType(Integer id, Integer idType, Integer identity,Integer newFlag,Integer promotionFlag, int pageNum, int pageSize, String sortField, Integer sortType);
+    ResponseJson<String> queryProductByType(Integer id, Integer idType, String brandIds,Integer identity,Integer newFlag,Integer promotionFlag, int pageNum, int pageSize, String sortField, Integer sortType);
 
     /**
      * 根据小程序运营分类Id搜索商品

+ 11 - 1
src/main/java/com/caimei365/commodity/service/impl/SearchProductServiceImpl.java

@@ -187,7 +187,7 @@ public class SearchProductServiceImpl implements SearchProductService {
      * @return JsonStr(list)
      */
     @Override
-    public ResponseJson<String> queryProductByType(Integer id, Integer idType, Integer identity, Integer newFlag, Integer promotionFlag, int pageNum, int pageSize, String sortField, Integer sortType) {
+    public ResponseJson<String> queryProductByType(Integer id, Integer idType, String brandIds, Integer identity, Integer newFlag, Integer promotionFlag, int pageNum, int pageSize, String sortField, Integer sortType) {
         String queryStr = "";
         String filter = "";
         if (idType == 1) {
@@ -204,6 +204,16 @@ public class SearchProductServiceImpl implements SearchProductService {
         if (requestSize > SEARCH_MAX_NUM) {
             requestPageSize = (int) Math.floor(SEARCH_MAX_NUM / pageSize) * pageSize;
         }
+        if (!StringUtils.isEmpty(brandIds)) {
+            if (brandIds.contains(",")) {
+                String[] split = brandIds.split(",");
+                for (int i = 0; i < split.length; i++) {
+                    queryStr += " OR p_brand:'" + split[i] + "'";
+                }
+            } else {
+                queryStr += " AND p_brand:'" + brandIds + "'";
+            }
+        }
         if (newFlag == 1) {
             Calendar c = Calendar.getInstance();
             c.setTime(new Date());