master
cody 3 months ago
parent fd46bce8af
commit 200fdb5c5b

@ -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) {
// 没有 product 时设置默认值(不扣除管理费)
$this->paramedic_total = $this->total ?? 0;
$this->fee = $this->fee ?? 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->fee = 0;
return $this;
}
//todo:考虑不同项目的情况,目前是全部统一
if (!$this->order) {
// 没有 order 时设置默认值
if (!isset($this->paramedic_total) || $this->paramedic_total === null) {
// 没有 order 时设置默认值(不扣除管理费)
$this->paramedic_total = $this->total ?? 0;
$this->fee = $this->fee ?? 0;
}
$this->fee = 0;
return $this;
}
@ -237,14 +234,14 @@ 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;

Loading…
Cancel
Save