CheckTempDataCommand.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Module\Game\Services\LandTempService;
  4. use App\Module\Game\Services\HouseTempService;
  5. use Illuminate\Console\Command;
  6. /**
  7. * 检查暂存区数据命令
  8. */
  9. class CheckTempDataCommand extends Command
  10. {
  11. /**
  12. * 命令签名
  13. *
  14. * @var string
  15. */
  16. protected $signature = 'test:check-temp {user_id}';
  17. /**
  18. * 命令描述
  19. *
  20. * @var string
  21. */
  22. protected $description = '检查用户的暂存区数据';
  23. /**
  24. * 执行命令
  25. *
  26. * @return int
  27. */
  28. public function handle()
  29. {
  30. $userId = (int) $this->argument('user_id');
  31. $this->info("检查用户 {$userId} 的暂存区数据");
  32. // 检查土地暂存数据
  33. $this->info("\n=== 土地暂存数据 ===");
  34. try {
  35. $landChanges = LandTempService::getUserLandChanges($userId);
  36. if (empty($landChanges)) {
  37. $this->warn("没有土地变更暂存数据");
  38. } else {
  39. $this->info("找到 " . count($landChanges) . " 条土地变更记录:");
  40. foreach ($landChanges as $landId => $change) {
  41. $this->line("土地ID: {$landId}");
  42. $this->line(" - 变更类型: " . ($change->changeType ?? 'N/A'));
  43. $this->line(" - 土地类型: " . ($change->landType ?? 'N/A'));
  44. $this->line(" - 更新时间: " . ($change->updatedAt ?? 'N/A'));
  45. }
  46. }
  47. } catch (\Exception $e) {
  48. $this->error("获取土地暂存数据失败: " . $e->getMessage());
  49. }
  50. // 检查房屋暂存数据
  51. $this->info("\n=== 房屋暂存数据 ===");
  52. try {
  53. $houseChange = HouseTempService::getUserHouseChange($userId);
  54. if (!$houseChange) {
  55. $this->warn("没有房屋变更暂存数据");
  56. } else {
  57. $this->info("找到房屋变更记录:");
  58. $this->line(" - 旧等级: " . ($houseChange->oldLevel ?? 'N/A'));
  59. $this->line(" - 新等级: " . ($houseChange->newLevel ?? 'N/A'));
  60. $this->line(" - 是否升级: " . ($houseChange->isUpgrade ? '是' : '否'));
  61. $this->line(" - 产出加成: " . ($houseChange->outputBonus ?? 'N/A'));
  62. $this->line(" - 特殊土地上限: " . ($houseChange->specialLandLimit ?? 'N/A'));
  63. $this->line(" - 更新时间: " . ($houseChange->updatedAt ?? 'N/A'));
  64. }
  65. } catch (\Exception $e) {
  66. $this->error("获取房屋暂存数据失败: " . $e->getMessage());
  67. }
  68. return 0;
  69. }
  70. }