|
@@ -31,38 +31,53 @@ class StatController extends Controller
|
|
$where['organization_id']=$org_id;
|
|
$where['organization_id']=$org_id;
|
|
}
|
|
}
|
|
$order = Order::where(['product_type'=>4])->where($where);
|
|
$order = Order::where(['product_type'=>4])->where($where);
|
|
-
|
|
|
|
|
|
+ $oneday = strtotime(date('Y-m-d 00:00:00',strtotime('+1 days')));
|
|
|
|
+ $twoday = strtotime(date('Y-m-d 00:00:00',strtotime('+2 days')));
|
|
|
|
+ $beforeoneday = strtotime(date('Y-m-d 00:00:00',strtotime('-1 days')));
|
|
//今日预约
|
|
//今日预约
|
|
- $today = $order->whereHas('orderPatient',function ($query){
|
|
|
|
- $query->whereBetween('appoint_start_time',[strtotime('today'),strtotime('+1days')]);
|
|
|
|
- })->count();
|
|
|
|
-
|
|
|
|
- //明日预约
|
|
|
|
- $tomorrow = $order->whereHas('orderPatient',function ($query){
|
|
|
|
- $query->whereBetween('appoint_start_time',[date('Y-m-d',strtotime('+1 days')),date('Y-m-d',strtotime('+2 days'))]);
|
|
|
|
- })->whereNotIn('order_status',[1,5,6])->count();
|
|
|
|
|
|
+ if ($org_id)
|
|
|
|
+ {
|
|
|
|
+ $today = Order::where(['product_type'=>4])
|
|
|
|
+ ->where('organization_id',$org_id)
|
|
|
|
+ ->whereBetween('appoint_start_time',[strtotime('today'),strtotime(date('Y-m-d 00:00:00',strtotime('+1 days')))])
|
|
|
|
+ ->count();
|
|
|
|
+ $tomorrow = Order::where(['product_type'=>4])
|
|
|
|
+ ->where('organization_id',$org_id)
|
|
|
|
+ ->whereBetween('appoint_start_time',[$oneday,$twoday])
|
|
|
|
+ ->count();
|
|
|
|
+ $people = Order::where(['product_type'=>4])
|
|
|
|
+ ->where('organization_id',$org_id)
|
|
|
|
+ ->whereBetween('end_time',[$beforeoneday,strtotime('today')])
|
|
|
|
+ ->where('order_status',4)->count();
|
|
|
|
+ $yesterday = Order::where(['product_type'=>4])
|
|
|
|
+ ->where('organization_id',$org_id)
|
|
|
|
+ ->whereBetween('appoint_start_time',[$beforeoneday,strtotime(date('Y-m-d 00:00:00',strtotime('today')))])
|
|
|
|
+ ->count();
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ $today = Order::where(['product_type'=>4])
|
|
|
|
+ ->whereBetween('appoint_start_time',[strtotime('today'),strtotime(date('Y-m-d 00:00:00',strtotime('+1 days')))])
|
|
|
|
+ ->count();
|
|
|
|
+ $tomorrow = Order::where(['product_type'=>4])
|
|
|
|
+ ->whereBetween('appoint_start_time',[$oneday,$twoday])
|
|
|
|
+ ->count();
|
|
|
|
+ $people = Order::where(['product_type'=>4])->whereBetween('end_time',[$beforeoneday,strtotime('today')])->where('order_status',4)->count();
|
|
|
|
+ $yesterday = Order::where(['product_type'=>4])
|
|
|
|
+ ->whereBetween('appoint_start_time',[$beforeoneday,strtotime(date('Y-m-d 00:00:00',strtotime('today')))])
|
|
|
|
+ ->count();
|
|
|
|
|
|
- //昨日接诊人数
|
|
|
|
- $people = $order->whereBetween('end_time',[strtotime('-1days'),strtotime('today')])->where('order_status',4)->count();
|
|
|
|
-
|
|
|
|
- //昨日预约
|
|
|
|
- $yesterday = $order->whereHas('orderPatient',function ($query){
|
|
|
|
- $query->whereBetween('appoint_start_time',[date('Y-m-d',strtotime('-1 days')),date('Y-m-d',strtotime('today'))]);
|
|
|
|
- })->whereNotIn('order_status',[1,5,6])->count();
|
|
|
|
|
|
+ }
|
|
|
|
|
|
$data['today'] = $today;
|
|
$data['today'] = $today;
|
|
$data['yesterday'] = $yesterday;
|
|
$data['yesterday'] = $yesterday;
|
|
$data['people'] = $people;
|
|
$data['people'] = $people;
|
|
- $data['tomorrow '] = $tomorrow;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ $data['tomorrow'] = $tomorrow;
|
|
// $data ['sum_num'] = Vaccine::where($where)->count();
|
|
// $data ['sum_num'] = Vaccine::where($where)->count();
|
|
// $data['have_num'] = Vaccine::where($where)->sum('stock');
|
|
// $data['have_num'] = Vaccine::where($where)->sum('stock');
|
|
// $data['less_num'] = Vaccine::where($where)->where(['stock'=>0])->count();//取苗钟数
|
|
// $data['less_num'] = Vaccine::where($where)->where(['stock'=>0])->count();//取苗钟数
|
|
// $data['today_schedule'] = Order::where(['order_status'=>1])->where($where)->where('product_type',4)->where('created_at','>',date('Y-m-d H:i:s',time()))->count();
|
|
// $data['today_schedule'] = Order::where(['order_status'=>1])->where($where)->where('product_type',4)->where('created_at','>',date('Y-m-d H:i:s',time()))->count();
|
|
// $data['today_vaccine'] = Order::where(['product_type'=>4])->where($where)->with('orderPatient','appoint_start_time',strtotime('today'))->count();//接诊患者(人次)
|
|
// $data['today_vaccine'] = Order::where(['product_type'=>4])->where($where)->with('orderPatient','appoint_start_time',strtotime('today'))->count();//接诊患者(人次)
|
|
return $data;
|
|
return $data;
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
//儿保
|
|
//儿保
|
|
@@ -74,25 +89,47 @@ class StatController extends Controller
|
|
$where['organization_id']=$org_id;
|
|
$where['organization_id']=$org_id;
|
|
}
|
|
}
|
|
$order = Order::where(['product_type'=>5])->where($where);
|
|
$order = Order::where(['product_type'=>5])->where($where);
|
|
-
|
|
|
|
- //今日预约
|
|
|
|
- $today = $order->whereHas('orderPatient',function ($query){
|
|
|
|
- $query->whereBetween('appoint_start_time',[strtotime('today'),strtotime('+1days')]);
|
|
|
|
- })->count();
|
|
|
|
-
|
|
|
|
- //明日预约
|
|
|
|
- $tomorrow = $order->whereHas('orderPatient',function ($query){
|
|
|
|
- $query->whereBetween('appoint_start_time',[date('Y-m-d',strtotime('+1 days')),date('Y-m-d',strtotime('+2 days'))]);
|
|
|
|
- })->whereNotIn('order_status',[1,5,6])->count();
|
|
|
|
-
|
|
|
|
- //昨日服务人数
|
|
|
|
- $people = $order->whereBetween('end_time',[strtotime('-1days'),strtotime('today')])->where('order_status',4)->count();
|
|
|
|
-
|
|
|
|
- //昨日预约
|
|
|
|
- $yesterday = $order->whereHas('orderPatient',function ($query){
|
|
|
|
- $query->whereBetween('appoint_start_time',[date('Y-m-d',strtotime('-1 days')),date('Y-m-d',strtotime('today'))]);
|
|
|
|
- })->whereNotIn('order_status',[1,5,6])->count();
|
|
|
|
-
|
|
|
|
|
|
+ $oneday = strtotime(date('Y-m-d 00:00:00',strtotime('+1 days')));
|
|
|
|
+ $twoday = strtotime(date('Y-m-d 00:00:00',strtotime('+2 days')));
|
|
|
|
+ $beforeoneday = strtotime(date('Y-m-d 00:00:00',strtotime('-1 days')));
|
|
|
|
+ if ($org_id)
|
|
|
|
+ {
|
|
|
|
+ //今日预约
|
|
|
|
+ $today = Order::where(['product_type'=>5])
|
|
|
|
+ ->where('organization_id',$org_id)
|
|
|
|
+ ->whereBetween('appoint_start_time',[strtotime('today'),strtotime('+1days')])
|
|
|
|
+ ->count();
|
|
|
|
+ //明日预约
|
|
|
|
+ $tomorrow = Order::where(['product_type'=>5])
|
|
|
|
+ ->where('organization_id',$org_id)
|
|
|
|
+ ->whereBetween('appoint_start_time',[$oneday,$twoday])
|
|
|
|
+ ->count();
|
|
|
|
+ //昨日服务人数
|
|
|
|
+ $people = Order::where(['product_type'=>5])
|
|
|
|
+ ->where('organization_id',$org_id)
|
|
|
|
+ ->whereBetween('end_time',[$beforeoneday,strtotime('today')])->where('order_status',4)->count();
|
|
|
|
+ //昨日预约
|
|
|
|
+ $yesterday = Order::where(['product_type'=>5])
|
|
|
|
+ ->where('organization_id',$org_id)
|
|
|
|
+ ->whereBetween('appoint_start_time',[$beforeoneday,date('Y-m-d 00:00:00',strtotime('today'))])
|
|
|
|
+ ->count();
|
|
|
|
+ }else{
|
|
|
|
+ //今日预约
|
|
|
|
+ $today = Order::where(['product_type'=>5])
|
|
|
|
+ ->whereBetween('appoint_start_time',[strtotime('today'),$oneday])
|
|
|
|
+ ->count();
|
|
|
|
+ //明日预约
|
|
|
|
+ $tomorrow = Order::where(['product_type'=>5])
|
|
|
|
+ ->whereBetween('appoint_start_time',[$oneday,$twoday])
|
|
|
|
+ ->count();
|
|
|
|
+ //昨日服务人数
|
|
|
|
+ $people = Order::where(['product_type'=>5])
|
|
|
|
+ ->whereBetween('end_time',[$beforeoneday,strtotime('today')])->where('order_status',4)->count();
|
|
|
|
+ //昨日预约
|
|
|
|
+ $yesterday = Order::where(['product_type'=>5])
|
|
|
|
+ ->whereBetween('appoint_start_time',[$beforeoneday,strtotime(date('Y-m-d 00:00:00',strtotime('today')))])
|
|
|
|
+ ->count();
|
|
|
|
+ }
|
|
$data['today'] = $today;
|
|
$data['today'] = $today;
|
|
$data['tomorrow'] = $tomorrow;
|
|
$data['tomorrow'] = $tomorrow;
|
|
$data['people'] = $people;
|
|
$data['people'] = $people;
|
|
@@ -110,15 +147,26 @@ class StatController extends Controller
|
|
$where['organization_id']=$org_id;
|
|
$where['organization_id']=$org_id;
|
|
$another['org_id'] = $org_id;
|
|
$another['org_id'] = $org_id;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ $oneday = strtotime(date('Y-m-d 00:00:00',strtotime('+1 days')));
|
|
|
|
+ $twoday = strtotime(date('Y-m-d 00:00:00',strtotime('+2 days')));
|
|
|
|
+ $beforeoneday = strtotime(date('Y-m-d 00:00:00',strtotime('-1 days')));
|
|
$data['have_num'] = Vaccine::where($another)->sum('stock'); //疫苗库存总数
|
|
$data['have_num'] = Vaccine::where($another)->sum('stock'); //疫苗库存总数
|
|
- $data['less_num'] = Vaccine::where($another)->where(['stock'=>0])->count();//缺苗钟数
|
|
|
|
- $ids = Order::where(['product_type'=>4])->where($where)->whereHas('orderPatient',function ($query){
|
|
|
|
- $query->where('appoint_start_time',strtotime('today'));//订单id
|
|
|
|
- })->pluck('id')->toArray();
|
|
|
|
-
|
|
|
|
|
|
+ $data['less_num'] = Vaccine::where($another)->where(['stock'=>10])->count();//缺苗钟数
|
|
|
|
+ if ($org_id)
|
|
|
|
+ {
|
|
|
|
+ $ids = Order::where(['product_type'=>4])
|
|
|
|
+ ->where('organization_id',$org_id)
|
|
|
|
+ ->whereBetween('appoint_start_time',[$beforeoneday,strtotime('today')])
|
|
|
|
+ ->where('order_status',4)
|
|
|
|
+ ->pluck('id')->toArray();
|
|
|
|
+ }else
|
|
|
|
+ {
|
|
|
|
+ $ids = Order::where(['product_type'=>4])
|
|
|
|
+ ->whereBetween('appoint_start_time',[$beforeoneday,strtotime('today')])
|
|
|
|
+ ->where('order_status',4)
|
|
|
|
+ ->pluck('id')->toArray();
|
|
|
|
+ }
|
|
$data['yesterday']= OrderVaccine::whereIn('order_id',$ids)->count(); //疫苗订单总数
|
|
$data['yesterday']= OrderVaccine::whereIn('order_id',$ids)->count(); //疫苗订单总数
|
|
-
|
|
|
|
return $data;
|
|
return $data;
|
|
}
|
|
}
|
|
//实时数据
|
|
//实时数据
|
|
@@ -152,7 +200,7 @@ class StatController extends Controller
|
|
$where['organization_id']=$org_id;
|
|
$where['organization_id']=$org_id;
|
|
}
|
|
}
|
|
//todo 是否需要区别状态
|
|
//todo 是否需要区别状态
|
|
- $order_num[] = Order::where('product_type',3)->where($where)->count();
|
|
|
|
|
|
+ $order_num[] = Order::where('product_type',3)->where($where)->where('payment_status','!=',1)->count();
|
|
$order_num[] = Order::where('product_type',4)->where($where)->count();
|
|
$order_num[] = Order::where('product_type',4)->where($where)->count();
|
|
$order_num[] = Order::where('product_type',5)->where($where)->count();
|
|
$order_num[] = Order::where('product_type',5)->where($where)->count();
|
|
$order_num[] = Order::whereIn('product_type',[3,4,5])->where($where)->count();
|
|
$order_num[] = Order::whereIn('product_type',[3,4,5])->where($where)->count();
|
|
@@ -199,7 +247,7 @@ class StatController extends Controller
|
|
//今日预约数
|
|
//今日预约数
|
|
$today = $order->whereHas('orderPatient',function ($query){
|
|
$today = $order->whereHas('orderPatient',function ($query){
|
|
$query->whereBetween('appoint_start_time',[strtotime('today'),strtotime('+1 days')]);
|
|
$query->whereBetween('appoint_start_time',[strtotime('today'),strtotime('+1 days')]);
|
|
- })->whereNotIn('order_status',[1,5,6])->count();
|
|
|
|
|
|
+ })->count();
|
|
|
|
|
|
//医生排班人数
|
|
//医生排班人数
|
|
$docters = SchedulePeriod::where(['schedule_date'=>date('Y-m-d',time()),'schedule_type'=>1])->where($where)->distinct('docter_id')->count();
|
|
$docters = SchedulePeriod::where(['schedule_date'=>date('Y-m-d',time()),'schedule_type'=>1])->where($where)->distinct('docter_id')->count();
|