|
@@ -67,7 +67,7 @@ public class SearchProductServiceImpl implements SearchProductService {
|
|
|
public ResponseJson<String> queryProductByKeyword(String keyword, String brandIds, Integer identity, Integer newFlag, Integer promotionFlag,
|
|
|
int pageNum, int pageSize, String sortField, Integer sortType) {
|
|
|
String queryStr = "product:'" + keyword + "'";
|
|
|
- String filter = "";
|
|
|
+ StringBuilder filter = new StringBuilder();
|
|
|
if (StringUtils.isEmpty(keyword)) {
|
|
|
queryStr = "p_all:'1'";
|
|
|
}
|
|
@@ -75,10 +75,14 @@ public class SearchProductServiceImpl implements SearchProductService {
|
|
|
if (brandIds.contains(",")) {
|
|
|
String[] split = brandIds.split(",");
|
|
|
for (int i = 0; i < split.length; i++) {
|
|
|
- queryStr += " OR p_brand:'" + split[i] + "'";
|
|
|
+ if (i == 0) {
|
|
|
+ filter.append("p_brand:'").append(split[i]).append("'");
|
|
|
+ } else {
|
|
|
+ filter.append(" OR p_brand:'").append(split[i]).append("'");
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
- queryStr += " AND p_brand:'" + brandIds + "'";
|
|
|
+ filter.append("p_brand:'").append(brandIds).append("'");
|
|
|
}
|
|
|
}
|
|
|
if (newFlag == 1) {
|
|
@@ -87,17 +91,17 @@ public class SearchProductServiceImpl implements SearchProductService {
|
|
|
c.setTime(new Date());
|
|
|
c.add(Calendar.YEAR, -1);
|
|
|
String time = new SimpleDateFormat("yyyyMMdd").format(c.getTime());
|
|
|
- filter += "p_time > " + time;
|
|
|
+ filter.append("p_time > ").append(time);
|
|
|
}
|
|
|
if (promotionFlag == 1) {
|
|
|
if (newFlag == 1) {
|
|
|
- filter += "AND p_promotions_id > 0";
|
|
|
+ filter.append("AND p_promotions_id > 0");
|
|
|
} else {
|
|
|
- filter += "p_promotions_id > 0";
|
|
|
+ filter.append("p_promotions_id > 0");
|
|
|
}
|
|
|
}
|
|
|
// 阿里云搜索
|
|
|
- ResponseJson<String> result = queryProduct(queryStr, filter, identity, pageNum, pageSize, sortField, sortType);
|
|
|
+ ResponseJson<String> result = queryProduct(queryStr, filter.toString(), identity, pageNum, pageSize, sortField, sortType);
|
|
|
if (0 == result.getCode()) {
|
|
|
return result;
|
|
|
} else {
|
|
@@ -199,7 +203,7 @@ public class SearchProductServiceImpl implements SearchProductService {
|
|
|
@Override
|
|
|
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 = "";
|
|
|
+ StringBuilder filter = new StringBuilder();
|
|
|
if (idType == 1) {
|
|
|
queryStr = "p_bigtype:'" + id + "'";
|
|
|
} else if (idType == 2) {
|
|
@@ -218,10 +222,14 @@ public class SearchProductServiceImpl implements SearchProductService {
|
|
|
if (brandIds.contains(",")) {
|
|
|
String[] split = brandIds.split(",");
|
|
|
for (int i = 0; i < split.length; i++) {
|
|
|
- queryStr += " OR p_brand:'" + split[i] + "'";
|
|
|
+ if (i == 0) {
|
|
|
+ filter.append("p_brand:'").append(split[i]).append("'");
|
|
|
+ } else {
|
|
|
+ filter.append(" OR p_brand:'").append(split[i]).append("'");
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
- queryStr += " AND p_brand:'" + brandIds + "'";
|
|
|
+ filter.append("p_brand:'").append(brandIds).append("'");
|
|
|
}
|
|
|
}
|
|
|
if (newFlag == 1) {
|
|
@@ -229,19 +237,18 @@ public class SearchProductServiceImpl implements SearchProductService {
|
|
|
c.setTime(new Date());
|
|
|
c.add(Calendar.YEAR, -1);
|
|
|
String time = new SimpleDateFormat("yyyyMMdd").format(c.getTime());
|
|
|
- filter += "p_time > " + time;
|
|
|
+ filter.append("p_time > ").append(time);
|
|
|
}
|
|
|
if (promotionFlag == 1) {
|
|
|
if (newFlag == 1) {
|
|
|
- filter += "AND p_promotions_id > 0";
|
|
|
+ filter.append("AND p_promotions_id > 0");
|
|
|
} else {
|
|
|
- filter += "p_promotions_id > 0";
|
|
|
+ filter.append("p_promotions_id > 0");
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
SearchParams searchParams = searchOpenService.getScrollProductParams(queryStr, identity, requestPageSize, sortField, sortType);
|
|
|
String thisFilter = searchParams.getFilter();
|
|
|
- if (StringUtils.isNotEmpty(filter)) {
|
|
|
+ if (StringUtils.isNotEmpty(String.valueOf(filter))) {
|
|
|
thisFilter = thisFilter + " AND " + filter;
|
|
|
}
|
|
|
searchParams.setFilter(thisFilter);
|