RechargeSyncMember.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Services\RechargeService;
  4. use Illuminate\Console\Command;
  5. class RechargeSyncMember extends Command
  6. {
  7. /**
  8. * The name and signature of the console command.
  9. *
  10. * @var string
  11. */
  12. protected $signature = 'recharge:sync-member {member_id : 用户 member_id} {--confirm-only : 只确认已有待确认记录,不重新拉链上充值}';
  13. /**
  14. * The console command description.
  15. *
  16. * @var string
  17. */
  18. protected $description = '按指定用户重新同步并确认 USDT 自动充值';
  19. /**
  20. * Execute the console command.
  21. *
  22. * @return int
  23. */
  24. public function handle()
  25. {
  26. $memberId = $this->argument('member_id');
  27. $confirmOnly = (bool) $this->option('confirm-only');
  28. $this->info("开始处理用户 {$memberId} 的充值记录...");
  29. $result = RechargeService::syncAndConfirmMemberRecharge($memberId, !$confirmOnly, true);
  30. if (empty($result['success'])) {
  31. $this->error($result['message'] ?? '处理失败');
  32. return Command::FAILURE;
  33. }
  34. $this->table(
  35. ['member_id', 'address', 'synced', 'checked', 'confirmed', 'remaining_pending', 'collect_ensured'],
  36. [[
  37. $result['member_id'],
  38. $result['address'],
  39. $result['synced'],
  40. $result['checked'],
  41. $result['confirmed'],
  42. $result['remaining_pending'],
  43. $result['collect_ensured'],
  44. ]]
  45. );
  46. if (!empty($result['confirmed_txids'])) {
  47. $this->line('已确认交易:');
  48. foreach ($result['confirmed_txids'] as $txid) {
  49. $this->line($txid);
  50. }
  51. }
  52. if (!empty($result['collect_addresses'])) {
  53. $this->line('已补建待归集地址:');
  54. foreach ($result['collect_addresses'] as $address) {
  55. $this->line($address);
  56. }
  57. }
  58. $this->info('处理完成');
  59. return Command::SUCCESS;
  60. }
  61. }