From 1b30f44c6dd868c93b1c9e6cf710d0ff7788eb4a Mon Sep 17 00:00:00 2001 From: Jing Li Date: Fri, 3 Nov 2023 12:16:57 +0800 Subject: [PATCH] Fix --- app/Services/OfflineOrderService.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Services/OfflineOrderService.php b/app/Services/OfflineOrderService.php index 49806d12..9d234204 100644 --- a/app/Services/OfflineOrderService.php +++ b/app/Services/OfflineOrderService.php @@ -201,7 +201,7 @@ class OfflineOrderService throw new BizException('商品总额不能小于0'); } - $paymentAmount = $productsTotalAmount; + $discountReductionAmount = 0; if (is_numeric($item['discount'])) { if ($item['discount'] <= 0) { throw new BizException('折扣必须大于0'); @@ -209,14 +209,14 @@ class OfflineOrderService throw new BizException('折扣必须小于10'); } $discount = bcdiv($item['discount'], 10, 3); - $paymentAmount = round(bcmul($productsTotalAmount, $discount, 2)); + $discountReductionAmount = bcsub($productsTotalAmount, round(bcmul($productsTotalAmount, $discount, 2))); } return [ 'product_category_id' => $item['product_category_id'], 'products_total_amount' => (int) $productsTotalAmount, - 'discount_reduction_amount' => (int) ($productsTotalAmount - $paymentAmount), - 'payment_amount' => (int) $paymentAmount, + 'discount_reduction_amount' => (int) $discountReductionAmount, + 'payment_amount' => (int) ($productsTotalAmount - $discountReductionAmount), ]; })->all(); }