搜索记录优化、仅保留商品id

This commit is contained in:
gongfuxiang 2022-07-13 11:28:25 +08:00
parent e6afc9bac2
commit 41aa64b55a
2 changed files with 13 additions and 4 deletions

View File

@ -77,15 +77,18 @@ class Search extends Common
*/
public function DataList()
{
// 搜索记录
$this->data_post['user_id'] = isset($this->user['id']) ? $this->user['id'] : 0;
SearchService::SearchAdd($this->data_post);
// 搜素条件
$map = SearchService::SearchWhereHandle($this->data_post);
// 获取数据
$ret = SearchService::GoodsList($map, $this->data_post);
// 搜索记录
$this->data_post['user_id'] = isset($this->user['id']) ? $this->user['id'] : 0;
$this->data_post['search_result_data'] = $ret['data'];
SearchService::SearchAdd($this->data_post);
// 返回数据
return ApiService::ApiDataReturn(SystemBaseService::DataReturn($ret['data']));
}
}

View File

@ -512,6 +512,12 @@ class SearchService
$ov_arr = [$params['order_by_field'], $params['order_by_type']];
}
// 结果仅保留商品id
if(!empty($params['search_result_data']) && is_array($params['search_result_data']) && !empty($params['search_result_data']['data']))
{
$params['search_result_data']['data'] = array_column($params['search_result_data']['data'], 'id');
}
// 日志数据
$data = [
'user_id' => isset($params['user_id']) ? intval($params['user_id']) : 0,