TestMultiCurrencyCommand.php 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace App\Module\Mex\Commands;
  3. use App\Module\Mex\Tests\MultiCurrencyTest;
  4. use Illuminate\Console\Command;
  5. /**
  6. * 测试Mex模块多币种适配功能
  7. */
  8. class TestMultiCurrencyCommand extends Command
  9. {
  10. /**
  11. * 命令签名
  12. *
  13. * @var string
  14. */
  15. protected $signature = 'mex:test-multi-currency';
  16. /**
  17. * 命令描述
  18. *
  19. * @var string
  20. */
  21. protected $description = '测试Mex模块多币种适配功能';
  22. /**
  23. * 执行命令
  24. *
  25. * @return int
  26. */
  27. public function handle(): int
  28. {
  29. $this->info('开始测试Mex模块多币种适配功能...');
  30. $this->newLine();
  31. try {
  32. // 运行所有测试
  33. $results = MultiCurrencyTest::runAllTests();
  34. // 显示FundLogic映射测试结果
  35. $this->info('=== FundLogic币种映射测试 ===');
  36. $fundLogicResults = $results['fund_logic_mapping'];
  37. $this->line("默认币种: {$fundLogicResults['default_currency']} ({$fundLogicResults['default_currency_name']})");
  38. $this->line("钻石币种映射 - 可用账户: {$fundLogicResults['diamond_mapping']['available']}, 冻结账户: {$fundLogicResults['diamond_mapping']['frozen']}");
  39. $this->line("金币币种映射 - 可用账户: {$fundLogicResults['gold_mapping']['available']}, 冻结账户: {$fundLogicResults['gold_mapping']['frozen']}");
  40. $this->line("支持的币种: " . implode(', ', $fundLogicResults['supported_currencies']));
  41. $this->line("币种支持检查 - 钻石: " . ($fundLogicResults['currency_support']['diamond'] ? '是' : '否') . ", 金币: " . ($fundLogicResults['currency_support']['gold'] ? '是' : '否'));
  42. $this->newLine();
  43. // 显示订单创建测试结果
  44. $this->info('=== 订单创建币种支持测试 ===');
  45. $orderResults = $results['order_creation'];
  46. $this->line("钻石币种卖出订单:");
  47. $this->line(" 成功: " . ($orderResults['diamond_sell_order']['success'] ? '是' : '否'));
  48. $this->line(" 消息: {$orderResults['diamond_sell_order']['message']}");
  49. if ($orderResults['diamond_sell_order']['order_id']) {
  50. $this->line(" 订单ID: {$orderResults['diamond_sell_order']['order_id']}");
  51. }
  52. $this->line("金币币种买入订单:");
  53. $this->line(" 成功: " . ($orderResults['gold_buy_order']['success'] ? '是' : '否'));
  54. $this->line(" 消息: {$orderResults['gold_buy_order']['message']}");
  55. if ($orderResults['gold_buy_order']['order_id']) {
  56. $this->line(" 订单ID: {$orderResults['gold_buy_order']['order_id']}");
  57. }
  58. $this->line("默认币种订单:");
  59. $this->line(" 成功: " . ($orderResults['default_currency_order']['success'] ? '是' : '否'));
  60. $this->line(" 消息: {$orderResults['default_currency_order']['message']}");
  61. if ($orderResults['default_currency_order']['order_id']) {
  62. $this->line(" 订单ID: {$orderResults['default_currency_order']['order_id']}");
  63. }
  64. $this->newLine();
  65. // 显示账户余额测试结果
  66. $this->info('=== 账户余额币种支持测试 ===');
  67. $balanceResults = $results['account_balance'];
  68. $this->line("钻石币种仓库余额: {$balanceResults['diamond_warehouse_balance']}");
  69. $this->line("金币币种仓库余额: {$balanceResults['gold_warehouse_balance']}");
  70. $this->line("默认币种仓库余额: {$balanceResults['default_warehouse_balance']}");
  71. $this->newLine();
  72. $this->info("测试完成时间: {$results['test_time']}");
  73. $this->info('✅ Mex模块多币种适配功能测试完成');
  74. return Command::SUCCESS;
  75. } catch (\Exception $e) {
  76. $this->error('❌ 测试执行失败: ' . $e->getMessage());
  77. $this->error('错误堆栈: ' . $e->getTraceAsString());
  78. return Command::FAILURE;
  79. }
  80. }
  81. }