|
|
|
|
@ -346,17 +346,17 @@ class OrdersController extends CommonController
|
|
|
|
|
$product = Product::find($request->product_id);
|
|
|
|
|
|
|
|
|
|
if ($request->paramedic_id) {
|
|
|
|
|
$paramedic = Paramedic::withCount("orders",function($query) use ($request) {
|
|
|
|
|
$paramedic = Paramedic::withCount(["orders"=>function($query) use ($request) {
|
|
|
|
|
$query->where("status", Orders::STATUS_ONGOING);
|
|
|
|
|
//todo:计算自动结单对当前所选日期的订单数的影响
|
|
|
|
|
})->find($request->paramedic_id);
|
|
|
|
|
}])->find($request->paramedic_id);
|
|
|
|
|
$product_paramedic_level = (new ProductParamedicLevel())->find($paramedic->paramedic_level_id);
|
|
|
|
|
$product_item = (new ProductItems())->where("patient_quantity", "<=", $paramedic->orders_count + 1)->orderBy("patient_quantity", "desc")->first();
|
|
|
|
|
} else {
|
|
|
|
|
$product_paramedic_level = (new ProductParamedicLevel())->where("product_id", $request->product_id)->where("price", 0)->first();
|
|
|
|
|
$product_item = (new ProductItems())->where("product_id", $request->product_id)->where("patient_quantity",1)->first();
|
|
|
|
|
}
|
|
|
|
|
dd($product);
|
|
|
|
|
|
|
|
|
|
$price = $product_item->price + $product_paramedic_level->price;
|
|
|
|
|
$factors = (new Orders())->requestFactorsToOrderFactors();
|
|
|
|
|
$price += collect($factors)->sum("price");
|
|
|
|
|
|