diff --git a/app/common/model/Goods.php b/app/common/model/Goods.php index 07a1dbf1..eacb0f00 100644 --- a/app/common/model/Goods.php +++ b/app/common/model/Goods.php @@ -26,6 +26,7 @@ use think\model\relation\HasMany; use think\model\relation\HasOne; use think\Paginator; use app\common\model\Channel; + /** * 商品模型 * Class Goods @@ -167,6 +168,7 @@ class Goods extends BaseModel { return $this->hasMany('Comment'); } + /** * 获取商品列表 * @param array $param 查询条件 @@ -187,7 +189,7 @@ class Goods extends BaseModel $sort = request()->get()['sort'] ?? ''; if ($order && $sort) { $sort = [ - $sort=> $order, + $sort => $order, ]; } else { $sort = [ @@ -196,7 +198,6 @@ class Goods extends BaseModel } - $field = $this->getAliasFields($this->name, ['content']); $field[] = 'selling_point'; // 执行查询 @@ -210,6 +211,7 @@ class Goods extends BaseModel // 整理列表数据并返回 return $this->setGoodsListData($list); } + /** * 获取商品列表 * @param array $param 查询条件 @@ -344,9 +346,12 @@ class Goods extends BaseModel } // 商品名称 - foreach ($params['keywords'] ?? [] as $val){ - $filter[] = ['goods_name', 'like', "%{$val}%"]; + if (is_array($params['keywords'])) { + foreach ($params['keywords'] as $val) { + $filter[] = ['goods_name', 'like', "%{$val}%"]; + } } + // 商品名称 !empty($params['goodsName']) && $filter[] = ['goods_name', 'like', "%{$params['goodsName']}%"]; // 商品编码