[ CropHarvestedListener::class, ], FeeCalculatingEvent::class => [ UrsTransferFeeListener::class, ], UrsUserEnteredFarmEvent::class => [ UrsUserEnteredFarmListener::class, ], UrsReferralCreatedEvent::class => [ UrsReferralCreatedListener::class, ], ]; /** * 注册服务 */ public function register(): void { // 注册命令 if ($this->app->runningInConsole()) { $this->commands([ \App\Module\UrsPromotion\Commands\UrsPartnerDividendCommand::class, \App\Module\UrsPromotion\Commands\UrsRebuildRelationCacheCommand::class, \App\Module\UrsPromotion\Commands\UrsTestRelationCacheCommand::class, \App\Module\UrsPromotion\Commands\UrsReferralSyncCommand::class, \App\Module\UrsPromotion\Commands\UrsUpdateTalentLevelCommand::class, \App\Module\UrsPromotion\Commands\TestRelationCacheFixCommand::class, \App\Module\UrsPromotion\Commands\UrsUpdateActiveStatusCommand::class, ]); } } /** * 启动服务 */ public function boot(): void { // 注册事件监听器 $events = $this->app['events']; foreach ($this->listen as $event => $listeners) { foreach ($listeners as $listener) { $events->listen($event, $listener); } } // 后台路由通过注解自动注册 // 注册定时任务 $this->app->booted(function () { $schedule = $this->app->make(Schedule::class); // 每天00:30执行合伙人分红(处理昨天的数据) $schedule->command('urs-promotion:partner-dividend') ->dailyAt('00:30') ->description('URS合伙人分红 - 顶级达人享受手续费分红') ->withoutOverlapping() // 防止重复执行 ->runInBackground(); // 后台运行 // 每天01:05执行用户活跃状态更新 $schedule->command('urs:update-active-status') ->dailyAt('01:05') ->description('URS用户活跃状态更新 - 基于最近15天活动时间更新用户活跃状态') ->withoutOverlapping() // 防止重复执行 ->runInBackground(); // 后台运行 }); } }