|
|
|
@ -166,16 +166,22 @@ class OrderItems extends SoftDeletesModel
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$factors = json_decode($this->factors);
|
|
|
|
$factors = json_decode($this->factors);
|
|
|
|
$factor_texts = [];
|
|
|
|
$factor_texts = [];
|
|
|
|
foreach ($factors as $factor_item) {
|
|
|
|
if ($factors) {
|
|
|
|
if ($factor_item->used_for_fee) {
|
|
|
|
foreach ($factors as $factor_item) {
|
|
|
|
$add_text = "(管理费{$factor_item->fee_percent}%+{$factor_item->fee})";
|
|
|
|
if ($factor_item->used_for_fee) {
|
|
|
|
} else {
|
|
|
|
$add_text = "(管理费{$factor_item->fee_percent}%+{$factor_item->fee})";
|
|
|
|
$add_text = "";
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$add_text = "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$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();
|
|
|
|
@ -224,7 +239,7 @@ class OrderItems extends SoftDeletesModel
|
|
|
|
$unpaid_order_items = (new OrderItems())
|
|
|
|
$unpaid_order_items = (new OrderItems())
|
|
|
|
->whereHas("order", function ($query) use ($projects) {
|
|
|
|
->whereHas("order", function ($query) use ($projects) {
|
|
|
|
$query->where("status", Orders::STATUS_ONGOING)
|
|
|
|
$query->where("status", Orders::STATUS_ONGOING)
|
|
|
|
->whereIn("project_id", $projects);
|
|
|
|
->whereIn("project_id", $projects);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
->where("total", ">", 0)
|
|
|
|
->where("total", ">", 0)
|
|
|
|
->whereNull("paid_at")
|
|
|
|
->whereNull("paid_at")
|
|
|
|
|