1. 新增药品的ERP抓取数量倍数

This commit is contained in:
李琦
2026-07-20 14:30:36 +08:00
parent fe54ece815
commit 9fafba95cc

View File

@@ -219,11 +219,18 @@ class ErpController extends Controller
$factor = $drugFactorMap[$drugId] ?? 1;
$originQty = (int) ($item['number'] ?? 0);
$erpQty = (int) round($originQty * $factor);
$scale = 2; // 金额一般保留 2 位小数
$buyPrice = $item['buy_price'];
if (bccomp($factor, '1', $scale) === 1) {
$erpPaymentPrice = bcdiv($buyPrice, $factor, $scale);
} else {
$erpPaymentPrice = $buyPrice;
}
return [
'detailId' => $item['id'],
'productSku' => $item['drug_no'],
'quantity' => $erpQty,
'paymentPrice' => $item['buy_price'],
'paymentPrice' => $erpPaymentPrice,
'price' => round($originQty * $item['buy_price'], 2),
];
}