文件地址:app/services/user/UserSearchServices.php
方法名称:vicSearch
替换此方法,代码如下:
public function vicSearch(int $uid, string $keyword, array $where)
{
$vicWordArr = [$keyword];
if ($vicWordArr) {
$vicword = $vicWordArr;
$where['keyword'] = $vicWordArr;
}
$result = $this->dao->getKeywordResult(0, $keyword);
$ids = [];
if ($result && isset($result['result']) && $result['result']) {//之前查询结果记录
$ids = $result['result'];
} else {//分词查询
}
//搜索没有记录
if (!$ids && $where) {
//查出所有结果ids存搜索记录表
/** @var StoreProductServices $services */
$services = app()->make(StoreProductServices::class);
$idsArr = $services->getSearchList($where, 0, 0, ['id']);
if ($idsArr) {
$ids = array_column($idsArr, 'id');
}
}
$vicword = is_string($vicword) ? [$vicword] : $vicword;
$this->saveUserSearch($uid, $keyword, $vicword, $ids);
return $ids;
}
如下图: