RechargeSyncMember.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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'],
  36. [[
  37. $result['member_id'],
  38. $result['address'],
  39. $result['synced'],
  40. $result['checked'],
  41. $result['confirmed'],
  42. $result['remaining_pending'],
  43. ]]
  44. );
  45. if (!empty($result['confirmed_txids'])) {
  46. $this->line('已确认交易:');
  47. foreach ($result['confirmed_txids'] as $txid) {
  48. $this->line($txid);
  49. }
  50. }
  51. $this->info('处理完成');
  52. return Command::SUCCESS;
  53. }
  54. }