UrsServiceProvider.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace ThirdParty\Urs;
  3. use Illuminate\Support\ServiceProvider;
  4. use App\Module\ThirdParty\Services\WebhookDispatchService;
  5. /**
  6. * URS包服务提供者
  7. *
  8. * 负责注册URS包的Webhook处理器到ThirdParty模块
  9. */
  10. class UrsServiceProvider extends ServiceProvider
  11. {
  12. /**
  13. * 注册服务
  14. *
  15. * @return void
  16. */
  17. public function register()
  18. {
  19. // 注册URS请求服务
  20. $this->app->singleton('thirdparty.urs.request', function () {
  21. return new UrsRequest();
  22. });
  23. }
  24. /**
  25. * 启动服务
  26. *
  27. * @return void
  28. */
  29. public function boot()
  30. {
  31. // 注册URS包的Webhook处理器
  32. $this->registerWebhookHandlers();
  33. }
  34. /**
  35. * 注册Webhook处理器
  36. *
  37. * @return void
  38. */
  39. protected function registerWebhookHandlers()
  40. {
  41. // 注册URS包的所有Webhook处理器
  42. WebhookDispatchService::registerPackageHandlers('urs', [
  43. 'register' => UrsWebhook::class,
  44. 'deposit' => UrsWebhook::class,
  45. 'withdraw' => UrsWebhook::class,
  46. 'check' => UrsWebhook::class,
  47. ]);
  48. }
  49. /**
  50. * 获取提供的服务
  51. *
  52. * @return array
  53. */
  54. public function provides()
  55. {
  56. return [
  57. 'thirdparty.urs.request',
  58. ];
  59. }
  60. }