cody 2 years ago
parent d8532e44ba
commit fe1f444fb7

@ -62,6 +62,11 @@ class HomeController extends CommonController
})->count();
// 各产品占比
$product = Product::where('project_id', $project_id)->first();
$productItem = ProductItems::where('product_id', $product->id)->get();
$factor = FactorItems::where('factor_id', $product->statistic_factor_id)->get();
$order_total = OrderItems::whereIn('product_item_id', $productItem->pluck('id'))->sum('total');
$lies = $this->getLies($productItem, $factor, $order_total);
$allMontn = [
date("Y") . '-01',
@ -95,36 +100,18 @@ class HomeController extends CommonController
'total' => (new Orders())->ofProject($project_id)->where('created_at', 'like', $month . '%')->count()
];
}
//dd($this->huli(6));
if (is_mobile()) {
return view($this->bladePath . ".mobile_home");
} else {
return view($this->bladePath . ".home");
return view($this->bladePath . ".home", compact('counts', 'lies', 'saleList', 'orderList'));
}
}
public function huli($project_id)
{
$data = Area::where('project_id', $project_id)->with('project', 'building')->get();
$product = Product::where('project_id', $project_id)->first();
$productItem = ProductItems::where('product_id', $product->id)->get();
$factor = FactorItems::where('factor_id', $product->statistic_factor_id)->get();
$lies = $this->getLies($productItem, $factor);
// 获取所有列
$lie = [];
if(isset($data[0]->lies)){
$lie = array_column($data[0]->lies, 'name');
}
dd($lies);
}
/**
* 获取动态列
*/
public function getLies($productItem, $factor)
public function getLies($productItem, $factor, $order_total)
{
$list = [];
foreach ($productItem as $item) {
@ -137,7 +124,8 @@ class HomeController extends CommonController
'total_price' => $item->price + $factor_item->price,
'product_item_id' => $item->id,
'factor_item_id' => $factor_item->id,
'total' => $total
'total' => $total,
'rate' => round($total / $order_total, 2)
];
}
}

@ -191,7 +191,7 @@
<div class="static1">
<div class="static1__item">
<div class="static1__item--label">今日应收(元)</div>
<div class="static1__item--value">9040.00</div>
<div class="static1__item--value">{$counts['bill_today']}</div>
</div>
<div class="static1__item">
<div class="static1__item--label">今日应收(元)</div>

Loading…
Cancel
Save