console.php 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. use App\Commands\ConfirmarPagamento;
  3. use App\Commands\CreateCrud;
  4. use App\Commands\RefreshPagarmeEntities;
  5. use App\Commands\RefreshPermissions;
  6. use App\Commands\SyncDiditSessions;
  7. use App\Commands\TestWebsocketEvent;
  8. use App\Models\Provider;
  9. use App\Services\Pagarme\PagarmeTransferService;
  10. use App\Services\ProviderWithdrawalService;
  11. use Illuminate\Foundation\Inspiring;
  12. use Illuminate\Support\Facades\Artisan;
  13. use App\Jobs\InvalidateExpiredSchedules;
  14. use Illuminate\Support\Facades\Schedule;
  15. Artisan::command('inspire', function () {
  16. $this->comment(Inspiring::quote());
  17. })->purpose('Display an inspiring quote');
  18. Artisan::command('create:crud {name} {--m|model} {--s|service} {--c|controller} {--r|request} {--e|resource} {--t|route} {--g|migration} {--all}', function () {
  19. $this->call(CreateCrud::class, [
  20. 'name' => $this->argument('name'),
  21. '--model' => $this->option('model'),
  22. '--service' => $this->option('service'),
  23. '--controller' => $this->option('controller'),
  24. '--request' => $this->option('request'),
  25. '--resource' => $this->option('resource'),
  26. '--route' => $this->option('route'),
  27. '--migration' => $this->option('migration'),
  28. '--all' => $this->option('all'),
  29. ]);
  30. })->purpose('Create CRUD operations with typed Models');
  31. Artisan::command('permissions:refresh', function () {
  32. $this->call(RefreshPermissions::class);
  33. })->purpose('Refresh all permissions and user type permissions');
  34. Artisan::command('pagarme:refresh-entities', function () {
  35. $this->call(RefreshPagarmeEntities::class);
  36. })->purpose('Limpa os recipients e clients locais e os recria no Pagar.me');
  37. Artisan::command('websocket:test {room} {--event=test-event} {--data=}', function () {
  38. $this->call(TestWebsocketEvent::class, [
  39. 'room' => $this->argument('room'),
  40. '--event' => $this->option('event'),
  41. '--data' => $this->option('data'),
  42. ]);
  43. })->purpose('Test websocket broadcasting by emitting an event');
  44. Artisan::command('confirma_pagamento {payment_id?}', function () {
  45. $this->call(ConfirmarPagamento::class, [
  46. 'payment_id' => $this->argument('payment_id'),
  47. ]);
  48. })->purpose('[LOCAL] Simula a confirmacao de pagamento do ultimo agendamento solicitado');
  49. //
  50. Artisan::command('pagarme:recipient-balance {recipient_id} {--skip-local}', function (
  51. PagarmeTransferService $pagarmeTransfer,
  52. ProviderWithdrawalService $withdrawals,
  53. ) {
  54. $recipientId = $this->argument('recipient_id');
  55. if (! $this->option('skip-local')) {
  56. $provider = Provider::query()
  57. ->where('recipient_id', $recipientId)
  58. ->first();
  59. if ($provider) {
  60. $this->info('Saldo calculado localmente:');
  61. $this->line(sprintf(' available: R$ %s', number_format($withdrawals->getAvailableBalance($provider), 2, ',', '.')));
  62. $this->line(sprintf(' pending: R$ %s', number_format($withdrawals->getPendingBalance($provider), 2, ',', '.')));
  63. $this->newLine();
  64. } else {
  65. $this->warn('Nenhum provider local encontrado para esse recipient_id.');
  66. $this->newLine();
  67. }
  68. }
  69. $this->info('Saldo retornado pelo Pagar.me:');
  70. $this->line(json_encode($pagarmeTransfer->getRecipientBalance($recipientId), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
  71. })->purpose('Consult Pagar.me recipient balance and compare it with local withdrawal balance');
  72. Artisan::command('didit:sync {session_id?} {--stale-hours=6} {--limit=50} {--dry-run}', function () {
  73. $this->call(SyncDiditSessions::class, [
  74. 'session_id' => $this->argument('session_id'),
  75. '--stale-hours' => $this->option('stale-hours'),
  76. '--limit' => $this->option('limit'),
  77. '--dry-run' => $this->option('dry-run'),
  78. ]);
  79. })->purpose('Reconcilia verificacoes de identidade cujo webhook do Didit nao chegou');
  80. Schedule::job(new InvalidateExpiredSchedules)->dailyAt('05:00');