52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Platform;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\YiiModels\Platform;
|
|
use Illuminate\Http\Request;
|
|
|
|
/**
|
|
* 平台通讯API
|
|
*/
|
|
class PlatformApi extends Controller
|
|
{
|
|
private ?Platform $platform = null;
|
|
|
|
/**
|
|
* 同步
|
|
*
|
|
* @param Request $request
|
|
* @return void
|
|
*/
|
|
public function handle(Request $request)
|
|
{
|
|
$platform_token = $request->input('platform_token');
|
|
$this->platform = Platform::where('token', $platform_token)->first();
|
|
log_i($platform_token, 'token', 'sync');
|
|
if (!$this->platform) {
|
|
log_i($platform_token . ' 未找到', 'token', 'sync');
|
|
json_error('通讯错误');
|
|
}
|
|
if ($this->platform->status != Platform::STATUS_PASS) {
|
|
log_i($platform_token . ' 无权限', 'token', 'sync');
|
|
json_error('无权限');
|
|
}
|
|
|
|
$type = $request->input('type');
|
|
if (method_exists($this, $type)) {
|
|
log_i($platform_token . ' 开始执行:' . $type, 'token', 'sync');
|
|
log_i(json_encode(request()->all()), $type, 'sync');
|
|
$this->{$type}();
|
|
} else {
|
|
log_i($platform_token . '同步数据错误 ' . $type, 'token', 'sync');
|
|
json_error('同步数据错误 ' . $type);
|
|
}
|
|
}
|
|
|
|
private function prescriptionSync()
|
|
{
|
|
$data = request('data');
|
|
}
|
|
}
|