diff --git a/app/Controller/v3/GoodsController.php b/app/Controller/v3/GoodsController.php index 7e8bb5c..92b2493 100644 --- a/app/Controller/v3/GoodsController.php +++ b/app/Controller/v3/GoodsController.php @@ -2,7 +2,9 @@ namespace App\Controller\v3; +use App\Constants\v3\ErrorCode; use App\Controller\BaseController; +use App\Exception\ErrorCodeException; use App\Model\v3\Category; use App\Model\v3\GoodsCategory; use App\Request\v3\GoodsEditorRequest; @@ -62,6 +64,10 @@ class GoodsController extends BaseController $res['banner'] = $this->goodsService->getBanner($goodsId); } + //搜索不到商品 + if(is_null($res['detail']['id'])){ + throw new ErrorCodeException(ErrorCode::GOODS_ACTIVITY_ON_SALE_NO); + } //如果没有banner数据,使用商品cover图 if(count($res['banner']) == 0){ // $res['banner'] = [$res['detail']['cover_img']];