mergeConfigFrom( __DIR__ . '/Config/transfer.php', 'transfer' ); // 注册服务绑定 $this->registerServices(); } /** * 启动服务 */ public function boot(): void { // 发布配置文件 $this->publishes([ __DIR__ . '/Config/transfer.php' => config_path('transfer.php'), ], 'transfer-config'); // 注册命令 $this->registerCommands(); // 注册定时任务 $this->registerSchedules(); // 注册事件监听器 $this->registerEventListeners(); // 注册中间件 $this->registerMiddleware(); } /** * 不注册服务 * @deprecated 不注册服务 */ protected function registerServices(): void { } /** * 注册命令 */ protected function registerCommands(): void { if ($this->app->runningInConsole()) { $this->commands([ TransferProcessCommand::class, TransferStatsCommand::class, TransferCallbackCommand::class, TransferCleanCommand::class, InsertTransferAdminMenuCommand::class, FeeStatisticsCommand::class, TestFeeTransferCommand::class, ]); } } /** * 注册定时任务 */ protected function registerSchedules(): void { // 在应用完全启动后注册定时任务 $this->app->booted(function () { // 每天22:00执行手续费统计 Schedule::command('transfer:fee-statistics') ->dailyAt('00:10') ->description('Transfer模块手续费每日统计') ->withoutOverlapping() // 防止重复执行 ->runInBackground(); // 后台运行 }); } /** * 注册事件监听器 */ protected function registerEventListeners(): void { // Transfer模块使用事件驱动架构 // 事件监听器将在需要时自动注册 } /** * 注册中间件 */ protected function registerMiddleware(): void { // Transfer模块不直接提供外部API // 通过OpenAPI模块进行对外开放和集成 } /** * 获取提供的服务 */ public function provides(): array { return [ 'transfer', 'transfer.api', ]; } }