77 lines
1.7 KiB
PHP
77 lines
1.7 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Controllers\Tests;
|
||
|
|
|
||
|
|
use App\Http\Controllers\Controller;
|
||
|
|
use App\Models\ExpressNo;
|
||
|
|
use Illuminate\Support\Facades\Artisan;
|
||
|
|
|
||
|
|
class TestController extends Controller
|
||
|
|
{
|
||
|
|
|
||
|
|
public const ALLOW_LISTS = [
|
||
|
|
'express',
|
||
|
|
'express_update',
|
||
|
|
];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* TestController constructor.
|
||
|
|
*/
|
||
|
|
public function __construct()
|
||
|
|
{
|
||
|
|
if (!app()->isLocal() && in_array(__FUNCTION__, self::ALLOW_LISTS)) {
|
||
|
|
abort(404);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public function t($fun = '')
|
||
|
|
{
|
||
|
|
if (0 == strlen($fun)) {
|
||
|
|
$fun = 'a';
|
||
|
|
}
|
||
|
|
$result = $this->$fun();
|
||
|
|
if (!empty($result)) {
|
||
|
|
return $result;
|
||
|
|
}
|
||
|
|
dd('结束运行方法:' . $fun);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function express()
|
||
|
|
{
|
||
|
|
$expressNo = ExpressNo::where('express_no', request('no'))->first();
|
||
|
|
if (!$expressNo) {
|
||
|
|
dda('单号对应数据库不存在');
|
||
|
|
}
|
||
|
|
$response = app('express')->track($expressNo->express_no, $expressNo->express_company_code, ['phone' => $expressNo->mobile]);
|
||
|
|
$result = json_decode($response, true);
|
||
|
|
dda($expressNo, $result);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function express_update()
|
||
|
|
{
|
||
|
|
$id = request('id');
|
||
|
|
$parameters = [
|
||
|
|
'type' => 'update',
|
||
|
|
];
|
||
|
|
if ($id) {
|
||
|
|
$parameters['--id'] = $id;
|
||
|
|
$expressNo = ExpressNo::where('id', $id)->first();
|
||
|
|
if (!$expressNo) {
|
||
|
|
json_error("{$id}数据不存在");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
Artisan::call('express', $parameters);
|
||
|
|
json_success("{$id}更新完成");
|
||
|
|
}
|
||
|
|
|
||
|
|
// public function a()
|
||
|
|
// {
|
||
|
|
// //
|
||
|
|
// }
|
||
|
|
|
||
|
|
public function a()
|
||
|
|
{
|
||
|
|
//
|
||
|
|
}
|
||
|
|
}
|