app->singleton('thirdparty.urs.service', function () { return new UrsService(); }); } /** * 启动服务 * * @return void */ public function boot() { // 注册URS包的Webhook处理器 $this->registerWebhookHandlers(); } /** * 注册Webhook处理器 * * @return void */ protected function registerWebhookHandlers() { // 一对一映射:每个路由对应一个专门的处理器 // 每个处理器只处理一种特定的Webhook请求 WebhookDispatchService::registerPackageHandlers('urs', [ 'register' => UrsRegisterWebhook::class, // 注册通知 - 专门处理用户注册 'deposit' => UrsDepositWebhook::class, // 充值通知 - 专门处理充值操作 'withdraw' => UrsWithdrawWebhook::class, // 提取通知 - 专门处理提取操作 'check' => UrsCheckWebhook::class, // 余额检查 - 专门处理余额检查 ]); } /** * 获取提供的服务 * * @return array */ public function provides() { return [ 'thirdparty.urs.service', ]; } }