Commit 468e5b92 by 杨树贤

加上缓存

parent 6e931880
...@@ -12,6 +12,7 @@ use App\Model\BigData\DataManageModel; ...@@ -12,6 +12,7 @@ use App\Model\BigData\DataManageModel;
use App\Model\SupplierAccountModel; use App\Model\SupplierAccountModel;
use App\Model\SupplierChannelModel; use App\Model\SupplierChannelModel;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
...@@ -19,9 +20,7 @@ use Illuminate\Support\Facades\Validator; ...@@ -19,9 +20,7 @@ use Illuminate\Support\Facades\Validator;
class ExternalApiController extends Controller class ExternalApiController extends Controller
{ {
public function __construct() public function __construct() {}
{
}
public function searchSupplier(Request $request) public function searchSupplier(Request $request)
{ {
...@@ -103,8 +102,12 @@ class ExternalApiController extends Controller ...@@ -103,8 +102,12 @@ class ExternalApiController extends Controller
if (empty($supplierId)) { if (empty($supplierId)) {
$this->externalResponse(-1, '供应商ID不能为空'); $this->externalResponse(-1, '供应商ID不能为空');
} }
$supplierAccount = SupplierAccountModel::where('supplier_id', $supplierId)->where('a_status', 1)->first();
if ($supplierAccount) { $cacheKey = "supplier:account_exist:" . $supplierId;
$exist = Cache::remember($cacheKey, 300, function () use ($supplierId) {
return SupplierAccountModel::where('supplier_id', $supplierId)->where('a_status', 1)->exists();
});
if ($exist) {
$this->externalResponse(0, 'ok', '有芯链账号'); $this->externalResponse(0, 'ok', '有芯链账号');
} }
$this->externalResponse(-1, '没有找到芯链账号'); $this->externalResponse(-1, '没有找到芯链账号');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment