feat(order): wait for colleague callback before settling wallet

Keep cover orders pending until colleague sts 2/4/6 via callback or 35s poll. Nightly prices:prune also drops old log tables.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-02 15:55:03 +03:30
co-authored by Cursor
parent e9674d6571
commit 0b1e5c687b
13 changed files with 1093 additions and 105 deletions
@@ -0,0 +1,23 @@
<?php
namespace App\Console\Commands;
use App\Services\ColleagueOrderCallbackService;
use Illuminate\Console\Command;
class PollPendingColleagueOrdersCommand extends Command
{
protected $signature = 'colleague:poll-pending-orders';
protected $description = 'Poll colleague for pending cover orders every 35s when callback is on';
public function handle(ColleagueOrderCallbackService $service): int
{
$first = $service->pollDueOrders();
sleep(ColleagueOrderCallbackService::POLL_SECONDS);
$second = $service->pollDueOrders();
$this->info(json_encode(['first' => $first, 'second' => $second], JSON_UNESCAPED_UNICODE));
return self::SUCCESS;
}
}
@@ -2,6 +2,7 @@
namespace App\Console\Commands;
use App\Services\DatabaseLogPruneService;
use App\Services\PriceSnapshotService;
use Illuminate\Console\Command;
@@ -9,11 +10,14 @@ class PrunePriceSnapshotsCommand extends Command
{
protected $signature = 'prices:prune';
protected $description = 'Downsample and prune price history (daily at midnight)';
protected $description = 'Nightly prune: price history + bloating logs (31-day retention)';
public function handle(PriceSnapshotService $snapshots): int
public function handle(PriceSnapshotService $snapshots, DatabaseLogPruneService $logs): int
{
$stats = $snapshots->pruneHistory();
$stats = [
'prices' => $snapshots->pruneHistory(),
'logs' => $logs->pruneHistory(),
];
$this->info(json_encode($stats, JSON_UNESCAPED_UNICODE));
return self::SUCCESS;
+8 -2
View File
@@ -31,10 +31,11 @@ class Kernel extends ConsoleKernel
->name('refresh_zaarbox_prices')
->withoutOverlapping();
// پاک‌سازی و downsample تاریخچه — ساعت ۱۲ شب
// پاک‌سازی و downsample تاریخچه قیمت + لاگ‌های حجیم (۳۱ روز) — ساعت ۱۲ شب
$schedule->command('prices:prune')
->dailyAt('00:00')
->name('prune_price_snapshots');
->name('prune_price_snapshots')
->withoutOverlapping();
// ترمیم اسناد ریالی جاافتادهٔ پرگار — سریع برای موارد تازه
$schedule->command('pargar:requeue-wallet-documents --execute --days=14')
@@ -52,6 +53,11 @@ class Kernel extends ConsoleKernel
->everyMinute()
->name('automations_run')
->withoutOverlapping(50);
$schedule->command('colleague:poll-pending-orders')
->everyMinute()
->name('colleague_poll_pending_orders')
->withoutOverlapping(58);
}
protected function commands()