fix bug of pargar

This commit is contained in:
2026-07-26 14:15:26 +03:30
parent 667e3736fb
commit 06b3113b98
17 changed files with 561 additions and 26 deletions
+16 -2
View File
@@ -6,6 +6,7 @@ use App\Models\Customer;
use App\Models\Order;
use App\Models\PargarSyncLog;
use App\Models\Product;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
@@ -199,7 +200,7 @@ class PargarSyncService
$desc = $isDeposit ? 'شارژ طلای کیف اصلی — ارسال به پرگار' : 'برداشت طلای کیف اصلی — ارسال به پرگار';
}
return PargarSyncLog::create([
$attributes = [
'customer_id' => $customer->id,
'amount' => abs($signedAmount),
'desc' => $desc,
@@ -215,7 +216,20 @@ class PargarSyncService
'product_id' => $meta['product_id'] ?? null,
'source' => $meta['source'] ?? null,
], JSON_UNESCAPED_UNICODE),
]);
];
try {
return PargarSyncLog::create($attributes);
} catch (QueryException $e) {
report($e);
// مبلغ واقعی در data.signed_amount است و خروجی از همان می‌خواند؛
// پس اگر ستون amount مبلغ را نپذیرفت، سند را بدون آن ثبت می‌کنیم تا گم نشود.
$attributes['amount'] = null;
$attributes['sync_log'] = mb_substr('amount ثبت نشد: ' . $e->getMessage(), 0, 500);
return PargarSyncLog::create($attributes);
}
}
/**