| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace App\Module\Test\Commands;
- use App\Module\UrsPromotion\Logics\UrsReferralSyncLogic;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\Log;
- /**
- * 测试URS推荐关系同步机制重构
- */
- class TestUrsReferralSyncCommand extends Command
- {
- /**
- * 命令签名
- */
- protected $signature = 'test:urs-referral-sync {urs_user_id} {farm_user_id}';
- /**
- * 命令描述
- */
- protected $description = '测试重构后的URS推荐关系同步机制';
- /**
- * 执行命令
- */
- public function handle(): int
- {
- $ursUserId = (int) $this->argument('urs_user_id');
- $farmUserId = (int) $this->argument('farm_user_id');
- $this->info("开始测试URS推荐关系同步机制");
- $this->info("URS用户ID: {$ursUserId}");
- $this->info("农场用户ID: {$farmUserId}");
- try {
- // 使用重构后的同步逻辑
- $syncLogic = new UrsReferralSyncLogic();
- $result = $syncLogic->syncReferralRelations($ursUserId, $farmUserId);
- $this->info("同步结果: " . ($result ? '成功(首次进入)' : '失败或非首次进入'));
- // 显示详细的节点执行情况
- $this->info("\n=== 节点执行详情 ===");
- $this->info("1. 创建用户映射 - 已执行");
- $this->info("2. 请求URS获取上级关系 - 已执行");
- $this->info("3. 验证和创建推荐关系 - 已执行");
- $this->info("4. 生成关系缓存 - 由UrsReferralService自动处理");
- $this->info("5. 更新团队统计 - 由UrsReferralService自动处理");
- $this->info("6. 触发事件 - 由UrsReferralService自动处理");
- $this->info("\n测试完成!");
- return 0;
- } catch (\Exception $e) {
- $this->error("测试失败: " . $e->getMessage());
- $this->error("错误详情: " . $e->getTraceAsString());
- return 1;
- }
- }
- }
|