Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| ReconcileNuvemshopOrdersCommand | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
| handle | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Console\Commands; |
| 4 | |
| 5 | use App\Jobs\ReconcileNuvemshopOrdersJob; |
| 6 | use App\Models\StoreIntegration; |
| 7 | use Illuminate\Console\Command; |
| 8 | |
| 9 | class ReconcileNuvemshopOrdersCommand extends Command |
| 10 | { |
| 11 | protected $signature = 'orvox:nuvemshop:reconcile-orders {--days=30}'; |
| 12 | protected $description = 'Reconcilia os pedidos recentes da Nuvemshop como fallback dos webhooks.'; |
| 13 | |
| 14 | public function handle(): int |
| 15 | { |
| 16 | StoreIntegration::query() |
| 17 | ->whereHas('provider', fn ($q) => $q->where('slug', 'nuvemshop')) |
| 18 | ->where('status', 'connected') |
| 19 | ->each(function (StoreIntegration $integration) { |
| 20 | ReconcileNuvemshopOrdersJob::dispatch($integration->id, (int) $this->option('days')); |
| 21 | $this->info('Reconciliação enviada: integração #'.$integration->id); |
| 22 | }); |
| 23 | |
| 24 | return self::SUCCESS; |
| 25 | } |
| 26 | } |