fix pargar bug
This commit is contained in:
@@ -208,7 +208,30 @@ class SingleOrderController extends Controller
|
||||
|
||||
if ($config->isPargarAccounting()) {
|
||||
try {
|
||||
app(\App\Services\PargarSyncService::class)->recordTrade($data['order'] ?? null);
|
||||
$paymentProductId = (int) ($data['payment_product_id'] ?? 0);
|
||||
$paymentKind = app(\App\Services\PargarSyncService::class)
|
||||
->inferPaymentKindFromContext([
|
||||
'payment_product_id' => $paymentProductId,
|
||||
]);
|
||||
// خرید/فروش عادی از کیف ریالی (بدون payment_product_id) = نقدی
|
||||
if ($paymentProductId <= 0) {
|
||||
$paymentKind = \App\Services\PargarSyncService::PAYMENT_CASH;
|
||||
}
|
||||
$paymentGold = null;
|
||||
if ($paymentKind === \App\Services\PargarSyncService::PAYMENT_MAIN_GOLD) {
|
||||
$paymentGold = (float) ($data['total_amount'] ?? $data['amount'] ?? 0);
|
||||
}
|
||||
app(\App\Services\PargarSyncService::class)->recordTrade(
|
||||
$data['order'] ?? null,
|
||||
false,
|
||||
[
|
||||
'payment_kind' => $paymentKind,
|
||||
'payment_product_id' => $paymentProductId > 0 ? $paymentProductId : null,
|
||||
'product_id' => (int) ($data['product_id'] ?? 0) ?: null,
|
||||
'number' => isset($data['number']) ? (float) $data['number'] : null,
|
||||
'payment_gold' => $paymentGold,
|
||||
]
|
||||
);
|
||||
} catch (\Throwable $e) {
|
||||
report($e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user