diff --git a/platform/modules/v1/controllers/ErpController.php b/platform/modules/v1/controllers/ErpController.php index 7c4b780..228ef53 100644 --- a/platform/modules/v1/controllers/ErpController.php +++ b/platform/modules/v1/controllers/ErpController.php @@ -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), ]; }