| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace App\Module\Game\Commands;
- use App\Module\Game\Services\ConditionService;
- use Illuminate\Console\Command;
- /**
- * 测试条件组功能的命令
- */
- class TestConditionCommand extends Command
- {
- /**
- * 命令名称
- *
- * @var string
- */
- protected $signature = 'game:test-condition {user_id} {condition_group}';
- /**
- * 命令描述
- *
- * @var string
- */
- protected $description = '测试条件组功能';
- /**
- * 执行命令
- *
- * @return int
- */
- public function handle()
- {
- $userId = (int) $this->argument('user_id');
- $conditionGroup = $this->argument('condition_group');
- $this->info("测试条件组功能");
- $this->info("用户ID: {$userId}");
- $this->info("条件组: {$conditionGroup}");
- // 检查条件
- $result = ConditionService::checkCondition($userId, $conditionGroup);
- if ($result['success']) {
- $this->info("结果: 成功");
- $this->info("消息: {$result['message']}");
- } else {
- $this->error("结果: 失败");
- $this->error("消息: {$result['message']}");
- }
- // 输出详细信息
- $this->line('');
- $this->line('详细信息:');
- unset($result['success']);
- unset($result['message']);
-
- foreach ($result as $key => $value) {
- if (is_array($value)) {
- $this->line("{$key}: " . json_encode($value, JSON_UNESCAPED_UNICODE));
- } else {
- $this->line("{$key}: {$value}");
- }
- }
- return 0;
- }
- }
|