Browse Source

模拟登录

develop
李可松 4 years ago
parent
commit
e5bd574091
  1. 35
      app/Http/Controllers/Api/TestController.php

35
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) {

Loading…
Cancel
Save