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,70 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
if (Schema::hasTable('orders')) {
if (! Schema::hasColumn('orders', 'colleague_callback_payload')) {
Schema::table('orders', function ($table) {
$table->json('colleague_callback_payload')->nullable();
});
}
if (! Schema::hasColumn('orders', 'colleague_last_poll_at')) {
Schema::table('orders', function ($table) {
$table->timestamp('colleague_last_poll_at')->nullable();
});
}
}
if (! Schema::hasTable('settings')) {
return;
}
$this->insertSetting(
'montzar_order_wait_callback',
'true',
'انتظار کالبک سفارش همکار',
'روشن: سفارش همکار تا دریافت کالبک (یا استعلام مسیر وضعیت) در انتظار می‌ماند و کیف ثبت نمی‌شود. خاموش: مثل قبل بلافاصله با پاسخ HTTP همکار قطعی می‌شود.',
'switch'
);
$this->insertSetting(
'montzar_order_status_path',
'/server/customer/order',
'مسیر استعلام وضعیت سفارش همکار',
'مسیر GET روی سرور همکار (montzar_base_url). شماره سفارش همکار به انتها اضافه می‌شود؛ مثلاً /server/customer/order/40000.',
'text'
);
}
public function down(): void
{
// settings and columns stay
}
private function insertSetting(string $key, string $value, string $title, string $description, string $type): void
{
$exists = DB::table('settings')->where('key', $key)->exists();
if ($exists) {
return;
}
$row = [
'key' => $key,
'value' => $value,
'title_fa' => $title,
'description' => $description,
'can_edit' => 1,
'is_active' => 1,
];
if (Schema::hasColumn('settings', 'type')) {
$row['type'] = $type;
}
DB::table('settings')->insert($row);
}
};