From 5784875939017b73d89afc1bce8a4dfdfe63d812 Mon Sep 17 00:00:00 2001 From: liu <2302563948@qq.com> Date: Sun, 13 Sep 2026 23:13:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A6=E5=8D=95=E4=BB=B7=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/BillDetailService.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Services/BillDetailService.php b/app/Services/BillDetailService.php index c1b2d3b..3a57047 100644 --- a/app/Services/BillDetailService.php +++ b/app/Services/BillDetailService.php @@ -22,6 +22,7 @@ class BillDetailService { $items = StoreOrderItemModel::query() ->where('bill_id', $bill->id) + ->where('quantity', '>', 0) ->orderBy('id') ->get(); @@ -39,6 +40,7 @@ class BillDetailService { $items = StoreOrderItemModel::query() ->whereIn('bill_id', $billIds) + ->where('quantity', '>', 0) ->orderBy('id') ->get(); @@ -73,15 +75,14 @@ class BillDetailService $weight = bcadd($weight, (string) $item->weight, 3); $amount = bcadd($amount, (string) $item->amount, 2); } + $price = bcdiv($amount, (string) $quantity, 2); $rows[] = [ 'product_id' => (int) $productId, 'product_name' => $first->product_name, 'product_spec' => $first->product_spec, 'unit' => $first->unit, - 'price' => $quantity > 0 - ? bcdiv($amount, (string) $quantity, 2) - : (string) $first->price, + 'price' => $price, 'quantity' => $quantity, 'weight' => $weight, 'amount' => $amount,