Browse Source

搜索不到商品处理

master
Lemon 5 years ago
parent
commit
9671ec5a6d
  1. 6
      app/Controller/v3/GoodsController.php

6
app/Controller/v3/GoodsController.php

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

Loading…
Cancel
Save