fix count bug
This commit is contained in:
@@ -518,7 +518,7 @@ class PargarInboundController extends Controller
|
|||||||
|
|
||||||
$product = $sync->resolveOrderProduct($order, $payload);
|
$product = $sync->resolveOrderProduct($order, $payload);
|
||||||
$number = (float) ($payload['number'] ?? 0);
|
$number = (float) ($payload['number'] ?? 0);
|
||||||
$amount = (float) ($order->amount ?? 0);
|
$amount = abs((float) ($order->amount ?? 0));
|
||||||
$totalPrice = (float) ($order->total_price ?? $order->payment_amount ?? 0);
|
$totalPrice = (float) ($order->total_price ?? $order->payment_amount ?? 0);
|
||||||
$unitPrice = (float) ($order->price ?? 0);
|
$unitPrice = (float) ($order->price ?? 0);
|
||||||
|
|
||||||
@@ -526,13 +526,13 @@ class PargarInboundController extends Controller
|
|||||||
? self::isCountBasedProduct(self::productUnitPayload($product))
|
? self::isCountBasedProduct(self::productUnitPayload($product))
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
$count = 1;
|
// پرگار: Count>0 → سند تعدادی (وزن را نادیده میگیرد)
|
||||||
|
// آبشده/وزنی مثل آذین: Count=0 و Weight=گرم
|
||||||
|
$count = 0;
|
||||||
$weight = $amount;
|
$weight = $amount;
|
||||||
if ($isCountBased && $number > 0) {
|
if ($isCountBased) {
|
||||||
$count = max(1, (int) round($number));
|
$count = $number > 0 ? max(1, (int) round($number)) : 1;
|
||||||
$weight = $amount;
|
$weight = $amount;
|
||||||
} elseif ($number > 0 && abs($number - $amount) > 0.0001) {
|
|
||||||
$count = max(1, (int) round($number));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$itemId = $sync->pargarItemIdGold();
|
$itemId = $sync->pargarItemIdGold();
|
||||||
@@ -543,25 +543,29 @@ class PargarInboundController extends Controller
|
|||||||
|
|
||||||
$tradedProductId = (int) ($payload['product_id'] ?? $order->product_id ?? 0);
|
$tradedProductId = (int) ($payload['product_id'] ?? $order->product_id ?? 0);
|
||||||
$tradesMainGold = $tradedProductId <= 0
|
$tradesMainGold = $tradedProductId <= 0
|
||||||
|| app(ConfigService::class)->isMainWalletProduct($tradedProductId);
|
|| app(ConfigService::class)->isMainWalletProduct($tradedProductId)
|
||||||
|
|| ($product && self::isMeltedTradeGroup($product->group_type ?? null));
|
||||||
|
|
||||||
// اثر مانده از روش پرداخت؛ وزن طلا فقط وقتی کالای معامله یا پرداخت به کیف اصلی مربوط است
|
// اثر مانده از روش پرداخت؛ وزن طلا فقط وقتی کالای معامله یا پرداخت به کیف اصلی مربوط است
|
||||||
if ($paymentKind === PargarSyncService::PAYMENT_CASH) {
|
if ($paymentKind === PargarSyncService::PAYMENT_CASH) {
|
||||||
if ($tradesMainGold) {
|
if ($tradesMainGold) {
|
||||||
// خرید/فروش آبشده کیفاصلی با نقدی: وزن + مبلغ
|
// خرید/فروش آبشده کیفاصلی با نقدی: وزن + مبلغ — حتماً تعدادی نباشد
|
||||||
$itemId = $sync->pargarItemIdGold();
|
$itemId = $sync->pargarItemIdGold();
|
||||||
|
$count = 0;
|
||||||
|
$weight = $amount;
|
||||||
} else {
|
} else {
|
||||||
// محصول غیر اصلی با پرداخت نقدی: فقط ریال
|
// محصول غیر اصلی با پرداخت نقدی: فقط ریال
|
||||||
$rialItemId = $sync->pargarItemIdRial();
|
$rialItemId = $sync->pargarItemIdRial();
|
||||||
$itemId = $rialItemId > 0 ? $rialItemId : $sync->pargarItemIdGold();
|
$itemId = $rialItemId > 0 ? $rialItemId : $sync->pargarItemIdGold();
|
||||||
$weight = 0;
|
$weight = 0;
|
||||||
$count = 1;
|
$count = 0;
|
||||||
}
|
}
|
||||||
} elseif ($paymentKind === PargarSyncService::PAYMENT_MAIN_GOLD) {
|
} elseif ($paymentKind === PargarSyncService::PAYMENT_MAIN_GOLD) {
|
||||||
$itemId = $sync->pargarItemIdGold();
|
$itemId = $sync->pargarItemIdGold();
|
||||||
$itemName = $sync->mainWalletGoldItemName();
|
$itemName = $sync->mainWalletGoldItemName();
|
||||||
$paymentGold = (float) ($payload['payment_gold'] ?? $amount);
|
$paymentGold = abs((float) ($payload['payment_gold'] ?? $amount));
|
||||||
$weight = abs($paymentGold);
|
$weight = $paymentGold;
|
||||||
|
$count = 0;
|
||||||
$totalPrice = 0;
|
$totalPrice = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -624,7 +628,7 @@ class PargarInboundController extends Controller
|
|||||||
'ItemName' => $sync->mainWalletGoldItemName(),
|
'ItemName' => $sync->mainWalletGoldItemName(),
|
||||||
'OrderDate' => Jalalian::fromDateTime($log->date ?? $log->created_at)->format('Y/m/d-H:i:s'),
|
'OrderDate' => Jalalian::fromDateTime($log->date ?? $log->created_at)->format('Y/m/d-H:i:s'),
|
||||||
'Fee' => 0,
|
'Fee' => 0,
|
||||||
'Count' => 1,
|
'Count' => 0,
|
||||||
'Weight' => abs($signed),
|
'Weight' => abs($signed),
|
||||||
'Price' => 0,
|
'Price' => 0,
|
||||||
'Carat' => 750,
|
'Carat' => 750,
|
||||||
@@ -643,7 +647,7 @@ class PargarInboundController extends Controller
|
|||||||
'ItemName' => $isDeposit ? 'واریز ریالی' : 'برداشت ریالی',
|
'ItemName' => $isDeposit ? 'واریز ریالی' : 'برداشت ریالی',
|
||||||
'OrderDate' => Jalalian::fromDateTime($log->date ?? $log->created_at)->format('Y/m/d-H:i:s'),
|
'OrderDate' => Jalalian::fromDateTime($log->date ?? $log->created_at)->format('Y/m/d-H:i:s'),
|
||||||
'Fee' => 0,
|
'Fee' => 0,
|
||||||
'Count' => 1,
|
'Count' => 0,
|
||||||
'Weight' => 0,
|
'Weight' => 0,
|
||||||
'Price' => abs($signed),
|
'Price' => abs($signed),
|
||||||
'Carat' => 750,
|
'Carat' => 750,
|
||||||
|
|||||||
Reference in New Issue
Block a user