|
|
|
|
@ -4,6 +4,9 @@ namespace App\Http\Controllers\Manager;
|
|
|
|
|
|
|
|
|
|
use App\Models\Area;
|
|
|
|
|
use App\Models\Bed;
|
|
|
|
|
use App\Models\OrderItems;
|
|
|
|
|
use App\Models\Orders;
|
|
|
|
|
use App\Models\Paramedic;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
|
|
@ -19,11 +22,75 @@ class StatisticsController extends CommonController
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response="200",
|
|
|
|
|
* description="获取项目首页总览数据统计"
|
|
|
|
|
* content={
|
|
|
|
|
* @OA\MediaType(
|
|
|
|
|
* mediaType="application/json",
|
|
|
|
|
* @OA\Schema(
|
|
|
|
|
* @OA\Property(
|
|
|
|
|
* property="orders_all",
|
|
|
|
|
* type="integer",
|
|
|
|
|
* description="全部订单数"
|
|
|
|
|
* ),
|
|
|
|
|
* @OA\Property(
|
|
|
|
|
* property="orders_pending",
|
|
|
|
|
* type="integer",
|
|
|
|
|
* description="待处理订单数"
|
|
|
|
|
* ),
|
|
|
|
|
* @OA\Property(
|
|
|
|
|
* property="orders_ongoing",
|
|
|
|
|
* type="integer",
|
|
|
|
|
* description="进行中订单数"
|
|
|
|
|
* ),
|
|
|
|
|
* @OA\Property(
|
|
|
|
|
* property="orders_finished",
|
|
|
|
|
* type="integer",
|
|
|
|
|
* description="已完成订单数"
|
|
|
|
|
* ),
|
|
|
|
|
* @OA\Property(
|
|
|
|
|
* property="orders_finished_today",
|
|
|
|
|
* type="integer",
|
|
|
|
|
* description="今日出院人数"
|
|
|
|
|
* ),
|
|
|
|
|
* @OA\Property(
|
|
|
|
|
* property="paramedics",
|
|
|
|
|
* type="integer",
|
|
|
|
|
* description="医院护工总数"
|
|
|
|
|
* ),
|
|
|
|
|
* @OA\Property(
|
|
|
|
|
* property="bill_today",
|
|
|
|
|
* type="decimal",
|
|
|
|
|
* description="今日应扣款"
|
|
|
|
|
* ),
|
|
|
|
|
* example={
|
|
|
|
|
* "orders_all": "999",
|
|
|
|
|
* "orders_pending": "60",
|
|
|
|
|
* "orders_ongoing": "50",
|
|
|
|
|
* "orders_finished": "889"
|
|
|
|
|
* "orders_finished_today": "12"
|
|
|
|
|
* "paramedics": "126"
|
|
|
|
|
* "bill_today": "9980.00"
|
|
|
|
|
* }
|
|
|
|
|
* )
|
|
|
|
|
* )
|
|
|
|
|
* }
|
|
|
|
|
* )
|
|
|
|
|
* )
|
|
|
|
|
*/
|
|
|
|
|
public function overview() {
|
|
|
|
|
public function overview()
|
|
|
|
|
{
|
|
|
|
|
$project_id = request()->project_id;
|
|
|
|
|
$counts = [];
|
|
|
|
|
$counts["orders_all"] = (new Orders())->ofProject($project_id)->count();
|
|
|
|
|
$counts["orders_pending"] = (new Orders())->ofProject($project_id)->whereIn("status", [Orders::STATUS_UNCONFIRMED, Orders::STATUS_UNASSIGNED])->count();
|
|
|
|
|
$counts["orders_ongoing"] = (new Orders())->ofProject($project_id)->where("status", Orders::STATUS_ONGOING)->count();
|
|
|
|
|
$counts["orders_finished"] = (new Orders())->ofProject($project_id)->where("status", Orders::STATUS_ONGOING)->count();
|
|
|
|
|
$counts["orders_finished_today"] = (new Orders())->ofProject($project_id)->where("to_date", date("Y-m-d"))->where("status", Orders::STATUS_ONGOING)->count();
|
|
|
|
|
$counts["paramedics"] = (new Paramedic())->ofProject($project_id)->count();
|
|
|
|
|
$counts["bill_today"] = (new OrderItems())->where("service_date", date("Y-m-d"))->whereHas("order", function ($query) use ($project_id) {
|
|
|
|
|
$query->ofProject($project_id);
|
|
|
|
|
})->sum("total");
|
|
|
|
|
|
|
|
|
|
return response()->json(compact("counts"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -67,7 +134,7 @@ class StatisticsController extends CommonController
|
|
|
|
|
->withCount("beds")
|
|
|
|
|
->get();
|
|
|
|
|
if ($request->has_ongoing_order) {
|
|
|
|
|
$areas = $areas->filter(function($item) {
|
|
|
|
|
$areas = $areas->filter(function ($item) {
|
|
|
|
|
return $item->beds->count();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|