feat(商城): 1.4.0 版本发布,更新内容如下

1. 商城搜索栏,新增搜索建议,支持拼音搜索
2. 标签栏购物车新增商品数量为微标
3. 商城购物车新增商品失效处理
4. 购物车页面、订单详情页面样式优化
5. 标签栏切换bug修复
master
wayn 12 months ago
parent afd46d5e06
commit dd1444bcea

@ -96,6 +96,7 @@ public class GoodsController extends BaseController {
elasticEntity.setId(goods.getId().toString()); elasticEntity.setId(goods.getId().toString());
map.put("id", goods.getId()); map.put("id", goods.getId());
map.put("name", goods.getName()); map.put("name", goods.getName());
map.put("pyname", goods.getName());
map.put("sales", goods.getActualSales() + goods.getVirtualSales()); map.put("sales", goods.getActualSales() + goods.getVirtualSales());
map.put("isHot", goods.getIsHot()); map.put("isHot", goods.getIsHot());
map.put("isNew", goods.getIsNew()); map.put("isNew", goods.getIsNew());

@ -7,12 +7,20 @@
"type": "text", "type": "text",
"analyzer": "ik_max_word", "analyzer": "ik_max_word",
"fields": { "fields": {
"suggest": { "kw": {
"type": "completion", "type": "completion",
"analyzer": "ik_max_word" "analyzer": "keyword"
},
"py": {
"type": "completion",
"analyzer": "pinyin"
} }
} }
}, },
"pyname": {
"type": "text",
"analyzer": "pinyin"
},
"sales": { "sales": {
"type": "integer" "type": "integer"
}, },

@ -65,7 +65,7 @@ public class SearchController extends BaseController {
@GetMapping("sugguest") @GetMapping("sugguest")
public R sugguest(SearchVO searchVO) throws IOException { public R sugguest(SearchVO searchVO) throws IOException {
String keyword = searchVO.getKeyword(); String keyword = searchVO.getKeyword();
String suggestField = "name.suggest"; String suggestField = "name.py";
String suggestName = "my-suggest"; String suggestName = "my-suggest";
SuggestionBuilder<CompletionSuggestionBuilder> termSuggestionBuilder = SuggestBuilders.completionSuggestion(suggestField) SuggestionBuilder<CompletionSuggestionBuilder> termSuggestionBuilder = SuggestBuilders.completionSuggestion(suggestField)
.prefix(keyword) .prefix(keyword)
@ -89,20 +89,19 @@ public class SearchController extends BaseController {
Boolean isPrice = searchVO.getIsPrice(); Boolean isPrice = searchVO.getIsPrice();
Boolean isSales = searchVO.getIsSales(); Boolean isSales = searchVO.getIsSales();
String orderBy = searchVO.getOrderBy(); String orderBy = searchVO.getOrderBy();
SearchHistory searchHistory = new SearchHistory();
if (memberId != null && StringUtils.isNotEmpty(keyword)) {
searchHistory.setCreateTime(LocalDateTime.now());
searchHistory.setUserId(memberId);
searchHistory.setKeyword(keyword);
}
Page<SearchVO> page = getPage(); Page<SearchVO> page = getPage();
// 查询包含关键字、已上架商品 // 查询包含关键字、已上架商品
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
MatchQueryBuilder matchFiler = QueryBuilders.matchQuery("isOnSale", true); MatchQueryBuilder matchFiler = QueryBuilders.matchQuery("isOnSale", true);
MatchQueryBuilder matchQuery = QueryBuilders.matchQuery("name", keyword); MatchQueryBuilder matchQuery = QueryBuilders.matchQuery("name", keyword);
MatchQueryBuilder pymatchQuery = QueryBuilders.matchQuery("pyname", keyword);
MatchPhraseQueryBuilder matchPhraseQueryBuilder = QueryBuilders.matchPhraseQuery("keyword", keyword); MatchPhraseQueryBuilder matchPhraseQueryBuilder = QueryBuilders.matchPhraseQuery("keyword", keyword);
boolQueryBuilder.filter(matchFiler).should(matchQuery).should(matchPhraseQueryBuilder).minimumShouldMatch(1); boolQueryBuilder.filter(matchFiler).should(matchQuery)
.should(pymatchQuery)
.should(matchPhraseQueryBuilder)
.minimumShouldMatch(1);
searchSourceBuilder.timeout(new TimeValue(10, TimeUnit.SECONDS)); searchSourceBuilder.timeout(new TimeValue(10, TimeUnit.SECONDS));
// 按是否新品排序 // 按是否新品排序
if (isNew) { if (isNew) {
@ -153,9 +152,15 @@ public class SearchController extends BaseController {
AsyncManager.me().execute(new TimerTask() { AsyncManager.me().execute(new TimerTask() {
@Override @Override
public void run() { public void run() {
SearchHistory searchHistory = new SearchHistory();
if (memberId != null && StringUtils.isNotEmpty(keyword)) {
searchHistory.setCreateTime(LocalDateTime.now());
searchHistory.setUserId(memberId);
searchHistory.setKeyword(keyword);
searchHistory.setHasGoods(true); searchHistory.setHasGoods(true);
iSearchHistoryService.save(searchHistory); iSearchHistoryService.save(searchHistory);
} }
}
}); });
} }
return R.success().add("goods", returnGoodsList); return R.success().add("goods", returnGoodsList);

Loading…
Cancel
Save