From e5bd574091ac5930b2091cfdf6ffe63ec527eaac Mon Sep 17 00:00:00 2001 From: liapples Date: Sat, 11 Sep 2021 15:26:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/TestController.php | 35 ++++++++++----------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/app/Http/Controllers/Api/TestController.php b/app/Http/Controllers/Api/TestController.php index 23aa6bb..c88659e 100644 --- a/app/Http/Controllers/Api/TestController.php +++ b/app/Http/Controllers/Api/TestController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api; use App\Models\Order; use App\Models\OrderProductItem; use App\Models\Product; +use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\DB; /** @@ -14,26 +15,24 @@ use Illuminate\Support\Facades\DB; */ class TestController { - /*public function index() + public function index() { - //test - $ids = Order::orderBy('id')->get(['id AS order_id', 'product_ids', 'agent_id', 'agent_product_id']); - foreach ($ids as $v) { - $item = Product::query()->whereIn('id', explode(',', $v['product_ids'])) - ->orderBy('id')->get(['id AS product_id', 'supplier_id'])->toArray(); - foreach ($item as $v2) { - if (!OrderProductItem::query()->where(['order_id' => $v['order_id'], 'product_id' => $v2['product_id']])->exists()) { - $v2['order_id'] = $v['order_id']; - $v2['agent_id'] = $v['agent_id']; - $v2['agent_product_id'] = $v['agent_product_id']; - OrderProductItem::query()->create($v2); - } - } - } - return ''; - }*/ + return $this->login(2); + } - public function index() + /** + * 模拟登录 + * @param $user_id + * @return string + */ + private function login($user_id) + { + $token_key = md5($user_id . env('APP_KEY')); + Cache::put($token_key, $user_id); + return $token_key; + } + + public function index2() { $handle = fopen(base_path('area.txt'), 'r'); if ($handle) {