| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <?php
- namespace App\Module\AppGame\Commands;
- use App\Module\AppGame\Handler\Promotion\InfoHandler;
- use App\Module\UrsPromotion\Services\UrsUserMappingService;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\Log;
- use Uraus\Kku\Request\RequestPromotionInfo;
- use Uraus\Kku\Response;
- /**
- * 测试推广信息重构后的功能
- */
- class TestPromotionInfoRefactorCommand extends Command
- {
- /**
- * 命令名称和参数
- *
- * @var string
- */
- protected $signature = 'test:promotion-info-refactor {user_id : 农场用户ID}';
- /**
- * 命令描述
- *
- * @var string
- */
- protected $description = '测试推广信息重构后的功能';
- /**
- * 执行命令
- */
- public function handle()
- {
- $userId = (int)$this->argument('user_id');
-
- $this->info("开始测试推广信息重构功能...");
- $this->info("测试用户ID: {$userId}");
-
- try {
- // 检查用户映射关系
- $ursUserId = UrsUserMappingService::getUrsUserId($userId);
- if (!$ursUserId) {
- $this->error("用户 {$userId} 未映射到URS系统");
- return 1;
- }
-
- $this->info("URS用户ID: {$ursUserId}");
-
- // 创建模拟响应对象
- $response = new Response();
- // 创建Handler实例并设置用户ID
- $handler = new InfoHandler($response);
- $handler->user_id = $userId;
- // 创建请求对象
- $request = new RequestPromotionInfo();
- $request->setTimes(time());
- // 调用处理方法
- $result = $handler->handle($request);
-
- // 输出结果
- $this->info("=== 推广团队信息 ===");
- $this->info("总人数: " . $result->getTotalCount());
- $this->info("直推人数: " . $result->getDirectCount());
- $this->info("间推人数: " . $result->getIndirectCount());
- $this->info("今日新增: " . $result->getDayRecentCount());
- $this->info("今日直推: " . $result->getDayDirectCount());
- $this->info("活跃人数: " . $result->getActiveCount());
- $this->info("直推活跃: " . $result->getDirectActiveCount());
- $this->info("达人等级: " . $result->getStarLevel());
-
- // 输出收益信息
- $this->info("=== 收益信息 ===");
- $todayReward = $result->getTodayReward();
- if ($todayReward) {
- $coins = $todayReward->getCoins();
- $items = $todayReward->getItems();
- if (!empty($coins)) {
- foreach ($coins as $coin) {
- $this->info("今日收益(代币): {$coin->getQuantity()} (类型: {$coin->getType()})");
- }
- }
- if (!empty($items)) {
- foreach ($items as $item) {
- $this->info("今日收益(物品): 物品ID {$item->getItemId()} x{$item->getQuantity()}");
- }
- }
- if (empty($coins) && empty($items)) {
- $this->info("今日收益: 无");
- }
- } else {
- $this->info("今日收益: 无");
- }
- $totalReward = $result->getTotalReward();
- if ($totalReward) {
- $coins = $totalReward->getCoins();
- $items = $totalReward->getItems();
- if (!empty($coins)) {
- foreach ($coins as $coin) {
- $this->info("总收益(代币): {$coin->getQuantity()} (类型: {$coin->getType()})");
- }
- }
- if (!empty($items)) {
- foreach ($items as $item) {
- $this->info("总收益(物品): 物品ID {$item->getItemId()} x{$item->getQuantity()}");
- }
- }
- if (empty($coins) && empty($items)) {
- $this->info("总收益: 无");
- }
- } else {
- $this->info("总收益: 无");
- }
-
- $this->info("✅ 推广信息重构功能测试完成!");
-
- } catch (\Exception $e) {
- $this->error("测试失败: " . $e->getMessage());
- $this->error("错误堆栈: " . $e->getTraceAsString());
- return 1;
- }
-
- return 0;
- }
- }
|