From 200fdb5c5b414fa959c7a70c16a0cef2fca0a73b Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Thu, 15 Jan 2026 14:21:20 +0800 Subject: [PATCH] update --- app/Models/OrderItems.php | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/app/Models/OrderItems.php b/app/Models/OrderItems.php index fcb8f64..90d2f60 100755 --- a/app/Models/OrderItems.php +++ b/app/Models/OrderItems.php @@ -178,12 +178,13 @@ class OrderItems extends SoftDeletesModel } $this->factor_texts = $factor_texts; + // 标志变量:是否成功计算了管理费 + $feeCalculated = false; + if (!$this->product) { - // 没有 product 时设置默认值 - if (!isset($this->paramedic_total) || $this->paramedic_total === null) { - $this->paramedic_total = $this->total ?? 0; - $this->fee = $this->fee ?? 0; - } + // 没有 product 时设置默认值(不扣除管理费) + $this->paramedic_total = $this->total ?? 0; + $this->fee = 0; return $this; } @@ -205,21 +206,17 @@ class OrderItems extends SoftDeletesModel } if (!$factor) { - // 找不到因子时设置默认值 - if (!isset($this->paramedic_total) || $this->paramedic_total === null) { - $this->paramedic_total = $this->total ?? 0; - $this->fee = $this->fee ?? 0; - } + // 找不到因子时设置默认值(不扣除管理费) + $this->paramedic_total = $this->total ?? 0; + $this->fee = 0; return $this; } //todo:考虑不同项目的情况,目前是全部统一 if (!$this->order) { - // 没有 order 时设置默认值 - if (!isset($this->paramedic_total) || $this->paramedic_total === null) { - $this->paramedic_total = $this->total ?? 0; - $this->fee = $this->fee ?? 0; - } + // 没有 order 时设置默认值(不扣除管理费) + $this->paramedic_total = $this->total ?? 0; + $this->fee = 0; return $this; } @@ -237,16 +234,16 @@ class OrderItems extends SoftDeletesModel $paramedic_total = $this->total - $fee; $this->paramedic_total = $paramedic_total; $this->fee = $fee; + $feeCalculated = true; break; } - - // 兜底逻辑:如果 paramedic_total 没有被设置,使用默认值 - // 这通常发生在没有 product、fee_type 不是 "factor"、找不到因子或没有 order 的情况下 - if (!isset($this->paramedic_total) || $this->paramedic_total === null) { + + // 兜底逻辑:如果管理费没有被计算(通常是 fee_type 不是 "factor" 的情况),使用默认值 + if (!$feeCalculated) { $this->paramedic_total = $this->total ?? 0; - $this->fee = $this->fee ?? 0; + $this->fee = 0; } - + return $this; }