fix bug of pargar
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user