| xqd
@@ -8,7 +8,6 @@ use App\Http\Controllers\Controller;
|
|
|
use App\Models\Docter;
|
|
|
use App\Models\Order;
|
|
|
use App\Models\OrderVaccine;
|
|
|
-use App\Models\Schedule;
|
|
|
use App\Models\SchedulePeriod;
|
|
|
use App\Models\Vaccine;
|
|
|
use Encore\Admin\Facades\Admin;
|
| xqd
@@ -20,15 +19,16 @@ class StatController extends Controller
|
|
|
public static $org_id;
|
|
|
public function __construct()
|
|
|
{
|
|
|
- self::$org_id = Admin::user()->org_id;;
|
|
|
+ self::$org_id = Admin::user()->org_id;
|
|
|
}
|
|
|
|
|
|
//疫苗预约
|
|
|
public static function vaccine()
|
|
|
{
|
|
|
$where = [];
|
|
|
- if(self::$org_id){
|
|
|
- $where['organization_id']=self::$org_id;
|
|
|
+ $org_id = Admin::user()->org_id;
|
|
|
+ if($org_id){
|
|
|
+ $where['organization_id']=$org_id;
|
|
|
}
|
|
|
$order = Order::where(['product_type'=>4])->where($where);
|
|
|
|
| xqd
@@ -69,8 +69,9 @@ class StatController extends Controller
|
|
|
public static function nurse()
|
|
|
{
|
|
|
$where = [];
|
|
|
- if(self::$org_id){
|
|
|
- $where['organization_id']=self::$org_id;
|
|
|
+ $org_id = Admin::user()->org_id;
|
|
|
+ if($org_id){
|
|
|
+ $where['organization_id']=$org_id;
|
|
|
}
|
|
|
$order = Order::where(['product_type'=>5])->where($where);
|
|
|
|
| xqd
@@ -103,12 +104,15 @@ class StatController extends Controller
|
|
|
public static function vaccineToal()
|
|
|
{
|
|
|
$where = [];
|
|
|
- if(self::$org_id){
|
|
|
- $where['organization_id']=self::$org_id;
|
|
|
+ $another = [];
|
|
|
+ $org_id = Admin::user()->org_id;
|
|
|
+ if($org_id){
|
|
|
+ $where['organization_id']=$org_id;
|
|
|
+ $another['org_id'] = $org_id;
|
|
|
}
|
|
|
|
|
|
- $data['have_num'] = Vaccine::where($where)->sum('stock'); //疫苗库存总数
|
|
|
- $data['less_num'] = Vaccine::where($where)->where(['stock'=>0])->count();//缺苗钟数
|
|
|
+ $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();
|
| xqd
@@ -121,10 +125,10 @@ class StatController extends Controller
|
|
|
public static function service()
|
|
|
{
|
|
|
$where = [];
|
|
|
- if(self::$org_id){
|
|
|
- $where['organization_id']=self::$org_id;
|
|
|
+ $org_id = Admin::user()->org_id;
|
|
|
+ if($org_id){
|
|
|
+ $where['organization_id']=$org_id;
|
|
|
}
|
|
|
-
|
|
|
$data['schedule_paitent'] = Order::where(['order_status'=>1])->where($where)->whereIn('product_type',[3,4,5])->where('created_at','>',date('Y-m-d H:i:s',time()))->count();
|
|
|
$data['schedule_docter'] = SchedulePeriod::distinct('docter_id')->where($where)->where('schedule_date',date('Y-m-d H:i:s',time()))->count();
|
|
|
// $data['paitent_num'] = Order::where(['order_status'=>1])->distinct()->count()->BgroupBy('patient_id');
|
| xqd
@@ -143,8 +147,9 @@ class StatController extends Controller
|
|
|
{
|
|
|
//3.门诊预约 4.疫苗接种预约 5.儿保预约
|
|
|
$where = [];
|
|
|
- if(self::$org_id){
|
|
|
- $where['organization_id']=self::$org_id;
|
|
|
+ $org_id = Admin::user()->org_id;
|
|
|
+ if($org_id){
|
|
|
+ $where['organization_id']=$org_id;
|
|
|
}
|
|
|
//todo 是否需要区别状态
|
|
|
$order_num[] = Order::where('product_type',3)->where($where)->count();
|
| xqd
@@ -159,10 +164,10 @@ class StatController extends Controller
|
|
|
public static function schedule()
|
|
|
{
|
|
|
$where = [];
|
|
|
- if(self::$org_id){
|
|
|
- $where['organization_id']=self::$org_id;
|
|
|
+ $org_id = Admin::user()->org_id;
|
|
|
+ if($org_id){
|
|
|
+ $where['organization_id']=$org_id;
|
|
|
}
|
|
|
-
|
|
|
$ids = SchedulePeriod::where('schedule_date',date("Y-m-d"))->where($where)->distinct('docter_id')->pluck('docter_id')->toArray();
|
|
|
$data = ['clinic_num'=>0,'vaccine_num'=>0,'nurse_num'=>0];
|
|
|
if(empty($ids)){
|
| xqd
@@ -185,8 +190,9 @@ class StatController extends Controller
|
|
|
public static function clinc()
|
|
|
{
|
|
|
$where = [];
|
|
|
- if(self::$org_id){
|
|
|
- $where['organization_id']=self::$org_id;
|
|
|
+ $org_id = Admin::user()->org_id;
|
|
|
+ if($org_id){
|
|
|
+ $where['organization_id']=$org_id;
|
|
|
}
|
|
|
$order = Order::where(['product_type'=>3])->where($where);
|
|
|
|