| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace ThirdParty\Urs;
- use App\Module\ThirdParty\Services\WebhookDispatchService;
- use Illuminate\Support\ServiceProvider;
- use ThirdParty\Urs\Request\UrsRequest;
- use ThirdParty\Urs\Webhook\UrsCheckWebhook;
- use ThirdParty\Urs\Webhook\UrsDepositWebhook;
- use ThirdParty\Urs\Webhook\UrsRegisterWebhook;
- use ThirdParty\Urs\Webhook\UrsWithdrawWebhook;
- /**
- * URS包服务提供者
- *
- * 负责注册URS包的Webhook处理器到ThirdParty模块
- */
- class UrsServiceProvider extends ServiceProvider
- {
- /**
- * 注册服务
- *
- * @return void
- */
- public function register()
- {
- // 注册URS请求服务
- $this->app->singleton('thirdparty.urs.request', function () {
- return new UrsRequest();
- });
- }
- /**
- * 启动服务
- *
- * @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.request',
- ];
- }
- }
|