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());
map.put("id", goods.getId());
map.put("name", goods.getName());
map.put("pyname", goods.getName());
map.put("sales", goods.getActualSales() + goods.getVirtualSales());
map.put("isHot", goods.getIsHot());
map.put("isNew", goods.getIsNew());

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

@ -65,7 +65,7 @@ public class SearchController extends BaseController {
@GetMapping("sugguest")
public R sugguest(SearchVO searchVO) throws IOException {
String keyword = searchVO.getKeyword();
String suggestField = "name.suggest";
String suggestField = "name.py";
String suggestName = "my-suggest";
SuggestionBuilder<CompletionSuggestionBuilder> termSuggestionBuilder = SuggestBuilders.completionSuggestion(suggestField)
.prefix(keyword)
@ -89,20 +89,19 @@ public class SearchController extends BaseController {
Boolean isPrice = searchVO.getIsPrice();
Boolean isSales = searchVO.getIsSales();
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();
// 查询包含关键字、已上架商品
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
MatchQueryBuilder matchFiler = QueryBuilders.matchQuery("isOnSale", true);
MatchQueryBuilder matchQuery = QueryBuilders.matchQuery("name", keyword);
MatchQueryBuilder pymatchQuery = QueryBuilders.matchQuery("pyname", 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));
// 按是否新品排序
if (isNew) {
@ -153,8 +152,14 @@ public class SearchController extends BaseController {
AsyncManager.me().execute(new TimerTask() {
@Override
public void run() {
searchHistory.setHasGoods(true);
iSearchHistoryService.save(searchHistory);
SearchHistory searchHistory = new SearchHistory();
if (memberId != null && StringUtils.isNotEmpty(keyword)) {
searchHistory.setCreateTime(LocalDateTime.now());
searchHistory.setUserId(memberId);
searchHistory.setKeyword(keyword);
searchHistory.setHasGoods(true);
iSearchHistoryService.save(searchHistory);
}
}
});
}

Loading…
Cancel
Save