|
|
|
@ -1,7 +1,9 @@ |
|
|
|
<?php |
|
|
|
|
|
|
|
namespace App\Http\Controllers\Api; |
|
|
|
use App\Common\ProductStatus; |
|
|
|
use App\Http\Controllers\Controller; |
|
|
|
use App\Models\AgentProduct; |
|
|
|
use App\Models\Category; |
|
|
|
|
|
|
|
class CategoryController extends Controller |
|
|
|
@ -12,6 +14,11 @@ class CategoryController extends Controller |
|
|
|
->where('agent_id', $this->agent_id) |
|
|
|
->orderBy('sort') |
|
|
|
->get(['id', 'name']); |
|
|
|
if ($list->isEmpty()) { //如果是新入驻商户,显示默认数据
|
|
|
|
if (AgentProduct::list($this->agent_id)->withTrashed()->count() === 0 && request('page', 1) <= 2) { //只获取2页数据
|
|
|
|
$list = AgentProduct::list($this->agent_id)->orWhere([['status', '=', ProductStatus::ON_SALE], ['price', '>', 500]])->orderBy('id')->simplePaginate(); |
|
|
|
} |
|
|
|
} |
|
|
|
return $this->success($list); |
|
|
|
} |
|
|
|
} |