|
|
|
|
@ -109,31 +109,27 @@ class HomeController extends CommonController
|
|
|
|
|
$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();
|
|
|
|
|
$sumOrderTotal = 0;
|
|
|
|
|
foreach ($data as $item) {
|
|
|
|
|
// 获取所有床位id
|
|
|
|
|
$bedIds = Bed::where('area_id', $item->id)->pluck('id');
|
|
|
|
|
// 子项
|
|
|
|
|
$item->lies = $this->getLies($bedIds, $productItem, $factor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$lies = $this->getLies($productItem, $factor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取所有列
|
|
|
|
|
$lie = [];
|
|
|
|
|
if(isset($data[0]->lies)){
|
|
|
|
|
$lie = array_column($data[0]->lies, 'name');
|
|
|
|
|
}
|
|
|
|
|
dd($data->toArray());
|
|
|
|
|
dd($lies);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取动态列
|
|
|
|
|
*/
|
|
|
|
|
public function getLies($bedIds, $productItem, $factor)
|
|
|
|
|
public function getLies($productItem, $factor)
|
|
|
|
|
{
|
|
|
|
|
$list = [];
|
|
|
|
|
foreach ($productItem as $item) {
|
|
|
|
|
foreach ($factor as $factor_item) {
|
|
|
|
|
$total = OrderItems::where('product_item_id', $item->id)
|
|
|
|
|
->whereIn("bed_id", $bedIds)
|
|
|
|
|
->whereRaw("factors like '%\"factor_item_id\": $factor_item->id%'")
|
|
|
|
|
->sum('total');
|
|
|
|
|
$list [] = [
|
|
|
|
|
|