ReceiveController.php 837 字节
<?php
/**
 * Created by PhpStorm.
 * User: zhl
 * Date: 2022/11/2
 * Time: 16:21
 */
namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\BtEvents;
use Illuminate\Http\Request;

/**
 * Class ReceiveControllers
 * @package App\Http\Controllers\Api
 */
class ReceiveController extends Controller
{
    /**
     * 接收异步事件
     * @param Request $request
     * @return string
     */
    public function createEvent(Request $request)
    {
        try {
            $type = intval($request->input('type', 0));
            $param = $request->all();

            $event_id = BtEvents::createBtEvent($type, json_encode($param));
            return $event_id ? $this->success() : $this->error();
        } catch (\Exception $e) {
            return $this->error($e->getMessage());
        }
    }
}