|
|
|
@ -166,6 +166,7 @@ class OrderItems extends SoftDeletesModel
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$factors = json_decode($this->factors);
|
|
|
|
$factors = json_decode($this->factors);
|
|
|
|
$factor_texts = [];
|
|
|
|
$factor_texts = [];
|
|
|
|
|
|
|
|
if ($factors) {
|
|
|
|
foreach ($factors as $factor_item) {
|
|
|
|
foreach ($factors as $factor_item) {
|
|
|
|
if ($factor_item->used_for_fee) {
|
|
|
|
if ($factor_item->used_for_fee) {
|
|
|
|
$add_text = "(管理费{$factor_item->fee_percent}%+{$factor_item->fee})";
|
|
|
|
$add_text = "(管理费{$factor_item->fee_percent}%+{$factor_item->fee})";
|
|
|
|
@ -174,8 +175,13 @@ class OrderItems extends SoftDeletesModel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$factor_texts[] = "{$factor_item->factor_name}:{$factor_item->factor_item_name}{$add_text}";
|
|
|
|
$factor_texts[] = "{$factor_item->factor_name}:{$factor_item->factor_item_name}{$add_text}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
$this->factor_texts = $factor_texts;
|
|
|
|
$this->factor_texts = $factor_texts;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$this->product) {
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch ($this->product->fee_type) {
|
|
|
|
switch ($this->product->fee_type) {
|
|
|
|
case "factor":
|
|
|
|
case "factor":
|
|
|
|
$factor = collect($factors)->filter(function ($item) {
|
|
|
|
$factor = collect($factors)->filter(function ($item) {
|
|
|
|
@ -183,16 +189,25 @@ class OrderItems extends SoftDeletesModel
|
|
|
|
})->first();
|
|
|
|
})->first();
|
|
|
|
if (!$factor) {
|
|
|
|
if (!$factor) {
|
|
|
|
//todo:检查factors为什么没有进去、缺失的factors已经手工补录进去了
|
|
|
|
//todo:检查factors为什么没有进去、缺失的factors已经手工补录进去了
|
|
|
|
$factor = (new Factor())
|
|
|
|
$factorModel = (new Factor())
|
|
|
|
->with("factorItems")
|
|
|
|
->with("factorItems")
|
|
|
|
->where("product_id", $this->product->id)
|
|
|
|
->where("product_id", $this->product->id)
|
|
|
|
->where("used_for_fee", 1)
|
|
|
|
->where("used_for_fee", 1)
|
|
|
|
->first()
|
|
|
|
|
|
|
|
->factorItems
|
|
|
|
|
|
|
|
->first();
|
|
|
|
->first();
|
|
|
|
|
|
|
|
if ($factorModel && $factorModel->factorItems) {
|
|
|
|
|
|
|
|
$factor = $factorModel->factorItems->first();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$factor) {
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//todo:考虑不同项目的情况,目前是全部统一
|
|
|
|
//todo:考虑不同项目的情况,目前是全部统一
|
|
|
|
|
|
|
|
if (!$this->order) {
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$holidays = cache("holidays_" . $this->order->project_id);
|
|
|
|
$holidays = cache("holidays_" . $this->order->project_id);
|
|
|
|
if (!$holidays) {
|
|
|
|
if (!$holidays) {
|
|
|
|
$holidays = Holiday::where("project_id", $this->order->project_id)->get()->keyBy("date")->toArray();
|
|
|
|
$holidays = Holiday::where("project_id", $this->order->project_id)->get()->keyBy("date")->toArray();
|
|
|
|
|