|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
+use app\common\Enum\GoodsEnum;
|
|
|
use app\common\model\Goods as GoodsModel;
|
|
|
use app\common\model\Guarantee;
|
|
|
use app\common\model\Collect;
|
|
@@ -65,7 +66,7 @@ class Goods extends Base
|
|
|
}
|
|
|
])->order('createtime', 'desc')->limit(10);
|
|
|
}
|
|
|
- ])->where('status', '<>', 'hidden')->where('id', $id)->find();
|
|
|
+ ])->whereIn('status',[GoodsEnum::STATUS_ON_SALE,GoodsEnum::STATUS_SOLD_OUT])->where('id', $id)->find();
|
|
|
|
|
|
if (!$row) {
|
|
|
$this->error('未找到该商品');
|
|
@@ -134,7 +135,7 @@ class Goods extends Base
|
|
|
// }
|
|
|
// $row->coupon = $couponList;
|
|
|
|
|
|
- $row->visible(explode(',', 'id,title,subtitle,category_id,price,marketprice,sales,views,
|
|
|
+ $row->visible(explode(',', 'id,title,subtitle,category_ids,price,marketprice,sales,views,
|
|
|
image,content,images,sku_spec,sku,comment,is_collect,guarantee,attributes,favor_rate,coupon'));
|
|
|
$row = $row->toArray();
|
|
|
$row['content'] = \app\common\library\Service::formatTplToUniapp($row['content']);
|
|
@@ -150,7 +151,7 @@ class Goods extends Base
|
|
|
$orderway = $this->request->param('orderway', 'desc');
|
|
|
|
|
|
$list = GoodsModel::where(function ($query) use ($param) {
|
|
|
- $query->where('status', 'normal');
|
|
|
+ $query->where('status',GoodsEnum::STATUS_ON_SALE);
|
|
|
//关键词
|
|
|
if (isset($param['keyword']) && !empty($param['keyword'])) {
|
|
|
$query->where('title|keywords', 'like', '%' . $param['keyword'] . '%');
|
|
@@ -163,7 +164,12 @@ class Goods extends Base
|
|
|
}
|
|
|
//分类
|
|
|
if (isset($param['category_id']) && !empty($param['category_id'])) {
|
|
|
- $query->where('category_id', 'IN', \addons\shop\model\Category::getCategoryChildrenIds($param['category_id']));
|
|
|
+ $categoryIds = \addons\shop\model\Category::getCategoryChildrenIds($param['category_id']);
|
|
|
+ $query->where(function($q) use ($categoryIds) {
|
|
|
+ foreach ($categoryIds as $categoryId) {
|
|
|
+ $q->whereOr('category_ids', 'exp', "FIND_IN_SET('{$categoryId}', category_ids)");
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
//属性
|
|
|
if (isset($param['attributes']) && !empty($param['attributes'])) {
|