Ver Fonte

订单列表筛选,社区数据中心

wanghaijun há 4 anos atrás
pai
commit
c2746d5474

+ 13 - 11
app/Community/Controllers/NurseUserController.php

xqd xqd xqd xqd
@@ -38,11 +38,7 @@ class NurseUserController extends AdminController
         $grid->column('orderUser.nickname', __('用户'));
         $grid->column('orderPatient.guardian_name', __('监护人'));
         $grid->column('orderPatient.name', __('患者'));
-
-        $grid->column('orderPatient.phone', __('监护人手机号'))->display(function ($w){
-            if(empty($w)) return Patient::where('id',$this->patient_id)->value('phone');
-            return $w;
-        });;
+        $grid->column('patient.phone', __('监护人手机号'));
         $grid->column('orderPatient.birthday', __('出生日期'));
 
         if(!$is_amdin){
@@ -51,6 +47,7 @@ class NurseUserController extends AdminController
                 return PatientRemark::where(['org_id'=>intval(Admin::user()->org_id),'patient_id'=>$w,'type'=>1])->value('remark');
             });
         }
+
         if($is_amdin){
             $grid->actions(function ($actions){
                 $actions->disableDelete();
@@ -59,11 +56,16 @@ class NurseUserController extends AdminController
             });
         }
 
-        $grid->filter(function ($flter){
-            $flter->like('orderPatient.name','请输入患者姓名');
-            $flter->like('orderUser.nickname','请输入用户名');
-            $flter->like('orderPatient.guardian_name','请输入监护人姓名');
-            $flter->between('orderUser.birthday','生日')->datetime();
+        $grid->filter(function ($filter){
+            $filter->where(function ($query) {
+                $query->whereHas('patient',function ($query){
+                    $query->where('phone', 'like', "%{$this->input}%");
+                });
+            }, '请输入电话号码');
+            $filter->like('orderPatient.name','请输入患者姓名');
+            $filter->like('orderUser.nickname','请输入用户名');
+            $filter->like('orderPatient.guardian_name','请输入监护人姓名');
+            $filter->between('orderUser.birthday','生日')->datetime();
         });
 
         return $grid;
@@ -100,7 +102,7 @@ class NurseUserController extends AdminController
             });
 
         }
-            $form->hidden('org_id')->value(intval($org_id));
+        $form->hidden('org_id')->value(intval($org_id));
         $form->saving(function ($form){
             $form->type = 1;
         });

+ 26 - 20
app/Community/Controllers/StatController.php

xqd xqd xqd xqd xqd xqd xqd 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;
@@ -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);
 
@@ -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);
 
@@ -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();
@@ -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');
@@ -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();
@@ -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)){
@@ -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);
 

+ 11 - 9
app/Community/Controllers/VaccineUserController.php

xqd
@@ -40,20 +40,22 @@ class VaccineUserController extends AdminController
         $grid->column('orderUser.nickname', __('用户'));
         $grid->column('orderPatient.guardian_name', __('监护人'));
         $grid->column('orderPatient.name', __('患者'));
-        $grid->column('orderPatient.phone', __('监护人手机号'))->display(function ($w){
-            if(empty($w)) return Patient::where('id',$this->patient_id)->value('phone');
-            return $w;
-        });
+        $grid->column('patient.phone', __('监护人手机号'));
         $grid->column('orderPatient.birthday', __('出生日期'));
         $grid->column('patient_id', __('备注'))->display(function ($w) use($user) {
             return PatientRemark::where(['org_id'=>intval($user->org_id),'patient_id'=>$w,'type'=>2])->value('remark');
         });
 
-        $grid->filter(function ($flter){
-            $flter->like('orderPatient.name','请输入患者姓名');
-            $flter->like('orderUser.nickname','请输入用户名');
-            $flter->like('orderPatient.guardian_name','请输入监护人姓名');
-            $flter->between('orderUser.birthday','生日')->datetime();
+        $grid->filter(function ($filter){
+            $filter->where(function ($query) {
+                $query->whereHas('patient',function ($query){
+                    $query->where('phone', 'like', "%{$this->input}%");
+                });
+            }, '请输入电话号码');
+            $filter->like('orderPatient.name','请输入患者姓名');
+            $filter->like('orderUser.nickname','请输入用户名');
+            $filter->like('orderPatient.guardian_name','请输入监护人姓名');
+            $filter->between('orderUser.birthday','生日')->datetime();
         });
 
         return $grid;

+ 7 - 8
app/Http/Controllers/AppiontController.php

xqd xqd xqd xqd
@@ -89,6 +89,8 @@ class AppiontController extends Controller
            }
 
            $sign = md5($data['id'].$data['telephone'].$data['barcode'].$data['st'].$data['area'].'2018');
+           if($data['sign'] == 1) dd($sign);
+
            if($data['sig'] != $sign){
                $defaulRes['tip_msg'] = '签名验证失败';
                exit(json_encode($defaulRes));
@@ -105,16 +107,16 @@ class AppiontController extends Controller
                exit(json_encode($defaulRes));
            }
 
-//           DB::enableQueryLog();
-           $order = Order::where('user_id',$user_id)->where('organization_id',$data['area'])->select('id','order_sn','user_id','patient_id','is_ticket')->with('orderPatient:order_id,appoint_start_time,appoint_end_time');
-          //dd(DB::getQueryLog());
+           DB::enableQueryLog();
+           $order = Order::where('user_id',$user_id)->where('organization_id',$data['area'])->select('id','order_sn','user_id','patient_id','is_ticket')->with('orderPatient:order_id,appoint_start_time,appoint_end_time,name');
+
 //           if($data['st']){
 //               $order = $order->whereHas('orderPatient',function ($query) use ($data){
 //                   $query->where('appoint_start_time','<=',$data['st']);
 //                   $query->where('appoint_end_time','>=',$data['st']);
 //               });
 //           }
-
+//dd(strtotime('2021-01-21 12:00:00'));
            if($data['st']){
                $order = $order->whereHas('orderPatient',function ($query) use ($data){
                    $query->where('appoint_start_time','>=',$data['st']);
@@ -122,6 +124,7 @@ class AppiontController extends Controller
            }
 
            $order_list =$order->first();
+           if($data['sql'] == 1) dd(DB::getQueryLog());
            if(empty($order_list)){
                $defaulRes['tip_msg'] = '无预约';
                exit(json_encode($defaulRes));
@@ -135,10 +138,6 @@ class AppiontController extends Controller
                $end = intval($order['order_patient']['appoint_end_time']);
                $date = date('Y-m-d',intval($order['order_patient']['appoint_start_time']));
 
-//               if(intval($data['st']) < time()){
-//                   $defaulRes['tip_msg'] = '请选择时间';
-//                   exit(json_encode($defaulRes));
-//               }
                if($end < intval($data['st']) ){
                    $defaulRes['tip_msg'] = '预约已过期,您预约的时间为:'.$date.' '.date('H:i',$start).'~'.date('H:i',$end);
                    exit(json_encode($defaulRes));