weizong song 5 years ago
parent a97a29f819
commit 1ed6f18b04

@ -48,9 +48,16 @@ class OrdersController extends CommonController
$query->select("id", "name", "factor_id")->orderBy("myindex");
}]);
}])
->whereRaw("project_id={$id}")
->selectRaw("select product.*,b.max_total from (select sum(max_price) as max_total,product_id from (select max(price) as max_price,product.id as product_id from product inner join factor on factor.product_id = product.id inner join factor_items on factor.id = factor_items.factor_id group by factor_items.factor_id) as a group by a.product_id) as b left join product on product.id = b.product_id")
->where("project_id", $id)
->select("id", "name", "project_id")
->orderBy("myindex")
->first();
$product->min_price = (new ProductItems())->where("product_id", $product->id)->min("price");
$max_price = (new ProductItems())->where("product_id", $product->id)->max("price");
$max_paramedic_price = (new ProductParamedicLevel())->where("product_id", $product->id)->max("price");
$max_factor_total = DB::select(DB::raw("select * from (select sum(max_price) as max_total,product_id from (select max(price) as max_price,product.id as product_id from product inner join factor on factor.product_id = product.id inner join factor_items on factor.id = factor_items.factor_id group by factor_items.factor_id) as a group by a.product_id) as b left join product on product.id = b.product_id where product.id=".$product->id));
$product->max_price = ($max_price + $max_paramedic_price + $max_factor_total[0]->max_total);
return response()->json($product->toArray());
}

Loading…
Cancel
Save