jingyuzhi 4 jaren geleden
bovenliggende
commit
2c4be7bf57

+ 4 - 2
app/Admin/Actions/Community/Docter/Failed.php

xqd
@@ -22,9 +22,11 @@ class Failed extends RowAction
             DocterOrganization::where('id',$this->row->id)->update(['state'=>2]);
             $docter_id = $this->row->docter_id;
             Docter::where(['id'=>$docter_id])->update(['is_then'=>0]);
+            DB::commit();
         } catch (Exception $e){
-            return $this->response->error('操作失败');
+            DB::rollBack();
+            return $this->response()->error('操作失败');
         }
-        return $this->response->success('操作成功')->refresh();
+        return $this->response()->success('操作成功')->refresh();
     }
 }

+ 41 - 0
app/Admin/Actions/backstage/Docters/LabelManagement.php

xqd
@@ -0,0 +1,41 @@
+<?php
+
+namespace App\Admin\Actions\backstage\Docters;
+
+use App\Models\Docter;
+use App\Models\DocterLabel;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Http\Request;
+
+class LabelManagement extends RowAction
+{
+    public $name = '标签管理';
+
+    public function handle(Model $model,Request $request)
+    {
+        // $model ...
+        $label_name = $request->get('name');
+        $arr = [];
+        if ($label_name == null)
+        {
+            Docter::where('id',$model->id)->update(['label'=>$arr]);
+        }
+        else
+        {
+            Docter::where('id',$model->id)->update(['label'=>$label_name]);
+        }
+        return $this->response()->success('修改标签成功')->refresh();
+    }
+    public function form()
+    {
+        $label = Docter::where('id',$this->row->id)->pluck('label');
+        $result = [];
+        array_walk_recursive($label, function($value) use (&$result) {
+            array_push($result, $value);
+        });
+        $this->multipleSelect('name', '请选择标签')
+            ->options(DocterLabel::all()->pluck('label_name','id'))
+            ->value($result);
+    }
+}

+ 85 - 0
app/Admin/Controllers/UserManagement/DocterManagement/DocterLabelController.php

xqd
@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Admin\Controllers\UserManagement\DocterManagement;
+
+use App\Models\DocterLabel;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class DocterLabelController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '标签管理';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new DocterLabel());
+        $grid->actions(function ($actions) {
+            // 去掉查看
+            $actions->disableView();
+        });
+        $grid->column('id', __('Id'));
+        $grid->column('label_name', __('标签名称'));
+        $states = [
+            'on'  => ['value' => 1, 'text' => '启用', 'color' => 'primary'],
+            'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
+        ];
+        $grid->column('status', __('状态'))->switch($states);
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(DocterLabel::findOrFail($id));
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new DocterLabel());
+        $form->footer(function ($footer) {
+            // 去掉`查看`checkbox
+            $footer->disableViewCheck();
+            // 去掉`继续编辑`checkbox
+            $footer->disableEditingCheck();
+            // 去掉`继续创建`checkbox
+            $footer->disableCreatingCheck();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            // 去掉`列表`按钮
+            $tools->disableList();
+            // 去掉`删除`按钮
+            $tools->disableDelete();
+            // 去掉`查看`按钮
+            $tools->disableView();
+        });
+
+        $form->text('label_name', __('标签名'))->rules('required|max:8');
+        $form->switch('status', __('状态'))->default(1);
+
+        return $form;
+    }
+}

+ 10 - 44
app/Admin/Controllers/UserManagement/DocterManagement/DoctorManagementController.php

xqd xqd xqd xqd xqd xqd
@@ -2,9 +2,13 @@
 
 namespace App\Admin\Controllers\UserManagement\DocterManagement;
 
+use App\Admin\Actions\backstage\Docters\AddLabel;
+use App\Admin\Actions\backstage\Docters\DelLabel;
+use App\Admin\Actions\backstage\Docters\LabelManagement;
 use App\Admin\Actions\backstage\Docters\SignUp;
 use App\Admin\Actions\backstage\Docters\Team;
 use App\Models\Docter;
+use App\Models\DocterLabel;
 use App\Models\DocterOrganization;
 use App\Models\Organization;
 use App\Models\User;
@@ -38,9 +42,7 @@ class DoctorManagementController extends AdminController
                 0    => '禁用',
                 1    => '启用',
             ]);
-
         });
-
         $grid->actions(function ($actions) {
             // 去掉编辑
             $actions->disableEdit();
@@ -50,8 +52,9 @@ class DoctorManagementController extends AdminController
             $actions->add(new SignUp());
             //团队管理
             $actions->add(new Team());
+            //标签管理
+            $actions->add(new LabelManagement());
         });
-
         $grid->column('id', __('Id'))->sortable();
         $grid->column('name', __('姓名'));
         $grid->column('avatar', __('头像'))->image('',50,50);
@@ -63,10 +66,12 @@ class DoctorManagementController extends AdminController
         ];
         $grid->column('status', __('工作状态'))->switch($states);
         $grid->column('is_then', __('认证状态'))->using([0=>'未认证',1=>'已认证']);
-        $grid->column('label', __('标签'))->label('info');
+        $grid->column('label', __('标签'))->display(function ($label){
+                $label_value = DocterLabel::whereIn('id',$label)->pluck('label_name');
+                return $label_value;
+        })->label('info');
         return $grid;
     }
-
     /**
      * Make a show builder.
      *
@@ -76,44 +81,6 @@ class DoctorManagementController extends AdminController
     protected function detail($id)
     {
         $show = new Show(Docter::findOrFail($id));
-
-        $show->field('id', __('Id'));
-        $show->field('type', __('Type'));
-        $show->field('name', __('Name'));
-        $show->field('phone', __('Phone'));
-        $show->field('sex', __('Sex'));
-        $show->field('birthday', __('Birthday'));
-        $show->field('avatar', __('Avatar'));
-        $show->field('status', __('Status'));
-        $show->field('label', __('Label'));
-        $show->field('sign', __('Sign'));
-        $show->field('intro', __('Intro'));
-        $show->field('office_id', __('Office id'));
-        $show->field('qualification_id', __('Qualification id'));
-        $show->field('score', __('Score'));
-        $show->field('service_persons', __('Service persons'));
-        $show->field('eva_num', __('Eva num'));
-        $show->field('service_days', __('Service days'));
-        $show->field('phone_minutes', __('Phone minutes'));
-        $show->field('chat_price', __('Chat price'));
-        $show->field('phone_price', __('Phone price'));
-        $show->field('appoint_price', __('Appoint price'));
-        $show->field('is_chat', __('Is chat'));
-        $show->field('is_phone', __('Is phone'));
-        $show->field('is_appoint', __('Is appoint'));
-        $show->field('latitude', __('Latitude'));
-        $show->field('longitude', __('Longitude'));
-        $show->field('created_at', __('Created at'));
-        $show->field('updated_at', __('Updated at'));
-        $show->field('user_id', __('User id'));
-        $show->field('password', __('Password'));
-        $show->field('is_then', __('Is then'));
-        $show->field('practice', __('Practice'));
-        $show->field('card_photo', __('Card photo'));
-        $show->field('is_quail', __('Is quail'));
-        $show->field('card_id', __('Card id'));
-        $show->field('receiving_time', __('Receiving time'));
-
         return $show;
     }
 
@@ -125,7 +92,6 @@ class DoctorManagementController extends AdminController
     protected function form()
     {
         $form = new Form(new Docter());
-
         $form->switch('status', __('状态'));
         return $form;
     }

+ 1 - 1
app/Admin/Controllers/UserManagement/DocterManagement/QualificationsController.php

xqd
@@ -15,7 +15,7 @@ class QualificationsController extends AdminController
      *
      * @var string
      */
-    protected $title = '职称类别';
+    protected $title = '资质管理';
 
     /**
      * Make a grid builder.

+ 2 - 1
app/Admin/routes.php

xqd
@@ -79,7 +79,8 @@ Route::group([
     $router->resource('evaluates', UserManagement\DocterManagement\UserEvaluatesController::class);
     //职称类别
     $router->resource('qualifications', UserManagement\DocterManagement\QualificationsController::class);
-
+    //标签管理
+    $router->resource('docter_labels', UserManagement\DocterManagement\DocterLabelController::class);
     /*
      * 用户管理->宝妈用户
      * */

+ 35 - 33
app/Community/Controllers/ApiController.php

xqd xqd xqd xqd xqd xqd xqd xqd
@@ -112,11 +112,12 @@ class ApiController extends Controller
 
         $set_time = request('time');//时间
         $user = Admin::user();
-        $org_id = $user->org_id;
+
         $doc_id = $user->docter_id;
 
         $docter_id = request('docter_id');
-        $role = request('role');
+        $role = request('role',1);
+
 
         $is_docter = CdmsUsers::where('docter_id',$doc_id)->where('docter_id','!=','')->first();
 
@@ -126,8 +127,10 @@ class ApiController extends Controller
 
         if($is_docter){
             $role =2;
+            $org_id = request('org_id');
+        } else {
+            $org_id = $user->org_id;
         }
-
         $all_time = explode('至',$set_time);
         if(count($all_time) <2){
             return json_encode(['code'=>601,'msg'=>'缺少必要参数','data'=>'']);
@@ -137,6 +140,7 @@ class ApiController extends Controller
         $end_time  = intval(str_replace('-','',$all_time[1]));
         $first_day = strtotime($all_time[0]);
 //        DB::enableQueryLog();
+
         $sche_dule = Schedule::whereBetween('schedule_day',[$start_time,$end_time])
             ->where(['docter_id'=>$docter_id])
             ->pluck('id')
@@ -187,7 +191,6 @@ class ApiController extends Controller
         $times[] = TimePeriod::where('start_time_period','>=',$schedule_config['morning_start'])->where('end_time_period','<=',$schedule_config['morning_end'])->pluck('id')->toArray();
         $times[] = TimePeriod::where('start_time_period','>=',$schedule_config['afternoon_start'])->where('end_time_period','<=',$schedule_config['afternoon_end'])->pluck('id')->toArray();
         $times[] = TimePeriod::where('start_time_period','>=',$schedule_config['evening_start'])->where('end_time_period','<=',$schedule_config['evening_end'])->pluck('id')->toArray();
-
         if(empty($sche_dule)){
             return ['code'=>200,'msg'=>'ok','data'=>['docter'=>$sche_dule_arr,'org_id'=>$org_id,'docter_id'=>$docter_id]];
         }
@@ -204,13 +207,10 @@ class ApiController extends Controller
 
                     //检测上午
                     $is_mo_have = SchedulePeriod::whereIn('schedule_id',$sche_dule)->where('schedule_date',$str_time)->whereIn('time_period_id',$times[$j])
-                        ->where('docter_id','!=',$docter_id)->count();
-//                    echo '<pre>';
-//                    print_r(DB::getQueryLog());
-//                    echo '</pre>';
-//                    dd($is_mo_have);
+                        ->where('organization_id','!=',$org_id)->where('docter_id',$docter_id)->count();
                     $is_self = SchedulePeriod::whereIn('schedule_id',$sche_dule)->where('schedule_date',$str_time)->whereIn('time_period_id',$times[$j])
-                        ->where('docter_id',$docter_id)->count();
+                        ->where('organization_id','=',$org_id)->where('docter_id',$docter_id)->count();
+
                     if($is_self){
                         $sche_dule_arr[$j][$week_arr[$i]] = true;
                     }
@@ -221,18 +221,15 @@ class ApiController extends Controller
             }
         } else {
 
-            $ids = DocterOrganization::where(['docter_id'=>$docter_id])->pluck('organization_id');
             $name = Docter::where('id',$docter_id)->value('name');
             $user_id = $docter_id;
             for ($i=0; $i<=6; $i++){
                 $str_time =  date('Y-m-d',($first_day + $i * 86400));
                 for($j=0;$j<=2;$j++){
-
                     $is_mo_have = SchedulePeriod::whereIn('schedule_id',$sche_dule)->where('schedule_date',$str_time)->whereIn('time_period_id',$times[$j])
-                        ->where('organization_id','!=',$org_id)->where('docter_id','=',$docter_id)->count();
+                        ->where('organization_id','!=',$org_id)->where('docter_id',$docter_id)->count();
                     $is_mo_self = SchedulePeriod::whereIn('schedule_id',$sche_dule)->where('schedule_date',$str_time)->whereIn('time_period_id',$times[$j])
                         ->where('organization_id',$org_id)->where('docter_id',$docter_id)->count();
-
                     if($is_mo_self){
                         $sche_dule_arr[$j][$week_arr[$i]] = true;
                     }
@@ -273,13 +270,29 @@ class ApiController extends Controller
         }
 
         $all_time = explode('至',$set_time);
-        $schedule_id = Schedule::where(['organization_id'=>$org_id,'docter_id'=>$docter_id,'schedule_date'=>$all_time[0]])->value('id');
         if(count($all_time) <2) {
             return json_encode(['status'=>601,'msg'=>'缺少必要参数','data'=>'']);
         }
+        $first_day = strtotime($all_time[0]);
         $start_time  = intval(str_replace('-','',$all_time[0]));
         $end_time  = intval(str_replace('-','',$all_time[1]));
-        $first_day = strtotime($start_time);
+        $schedule_id = Schedule::where(['docter_id'=>$docter_id])->whereBetween('schedule_day',[$start_time,$end_time])->pluck('id');
+        if(empty($schedule_id) || count($schedule_id) < 7){
+//           Schedule::whereIn('id',$schedule_id)->delete();
+//           SchedulePeriod::whereIn('schedule_id',$schedule_id);
+            for($i = 0;$i<=6;$i++){
+                $real_time = $first_day + (86400 * $i);
+                $schedule=  [
+                    'schedule_date'=> date('Y-m-d',$real_time),
+                    'schedule_day'=>intval(str_replace('-','',date('Y-m-d H:i:s',$real_time))),
+                    'docter_id'=>$docter_id
+                ] ;
+                Schedule::Insert($schedule);
+//                echo '日期:'.date('Y-m-d H:i:s',$real_time).'<br>';
+//                echo $i;
+            }
+        }
+
         //周字段映射
         $week_arr = ['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];
 //        $data = [
@@ -334,50 +347,39 @@ class ApiController extends Controller
                 $time_period[] = $t;
             }
         }
-
         $data[0] = array_values(object_array(json_decode($data[0])));
         $data[1] = array_values(object_array(json_decode($data[1])));
         $data[2] = array_values(object_array(json_decode($data[2])));
-
-        $mo_schedule = array_values($data[0]);
-        $af_schedule = array_values($data[1]);
-        $ev_schedule = array_values($data[2]);
-
-
         DB::beginTransaction();
         try {
+
             $schedule_insert = [
                 'organization_id'=>$org_id,
                 'docter_id'=>$docter_id,
                 'schedule_date'=>$all_time[0],
-                'schedule_day'=>$start_time,
                 'created_at'=>Carbon::now(),
                 'updated_at'=>Carbon::now(),
             ];
-            if(!$schedule_id){
-                $schedule_id = Schedule::insertGetId($schedule_insert);
-            }
-            unset($schedule_insert['schedule_day']);
-            $schedule_insert['schedule_id'] =$schedule_id;
             $info = [];
             for ($i = 1 ;$i<=3;$i++){
                 $mo_schedule = array_values($data[$i-1]);
                 foreach ($mo_schedule as $key=>$val){
                     if($key==0) continue;
-                    $schedule_date = $start_time + $key;
-                    $strtime = "$schedule_date";
                     $time_insert = $schedule_insert;
                     $time_insert['type'] = $i;
 
                     $schedule_time = $times[$i];
                     $real_time = date('Y-m-d',($first_day + ($key-1)*86400));
+                    $schedule_id = Schedule::where(['docter_id'=>$docter_id,'schedule_date'=>$real_time])->value('id');
+                    if(empty($schedule_id)) continue;
+                    $time_insert['schedule_id'] = $schedule_id;
                     $time_insert['schedule_date'] = $real_time;
                     $time_insert['me_sure'] = 1;
 
                     if($val == true){
-                        $data['schedule_date'] = $start_time ;
+                        $data['schedule_date'] = $start_time;
                         foreach ($schedule_time as $time_id){
-                            $is_have = SchedulePeriod::where(['time_period_id'=>$time_id,'type'=>($i),'schedule_date'=>$real_time,'organization_id'=>$org_id])->value('id');
+                            $is_have = SchedulePeriod::where(['time_period_id'=>$time_id,'type'=>($i),'schedule_date'=>$real_time])->value('id');
                             if($is_have) break;
                             $time_insert['time_period_id'] = $time_id;
                             $info[] = $time_insert;

+ 1 - 1
app/Community/Controllers/DocterVerifyController.php

xqd
@@ -41,7 +41,7 @@ class DocterVerifyController extends AdminController
         $grid->column('docter.card_id', __('身份证号'));
         $grid->column('office.name', __('认证科室'));
         $grid->column('qualification.name', __('认证资质'));
-        $grid->column('state', __('状态'))->using(['待审核','已认证','认证失败','审核中'])->label(['info','success','error','info']);
+        $grid->column('state', __('状态'))->using(['待审核','已认证','审核驳回','审核中'])->label(['info','success','danger','info']);
 
         $grid->actions(function($actions){
             $actions->disableDelete();

+ 91 - 0
app/Community/Controllers/Vaccine/OrganizationVaccineController.php

xqd
@@ -0,0 +1,91 @@
+<?php
+
+namespace App\Community\Controllers\Vaccine;
+
+use App\Models\Organization;
+use App\Models\OrganizationVaccine;
+use App\Models\Vaccine;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class OrganizationVaccineController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '机构疫苗';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new OrganizationVaccine());
+
+        $org_id = Admin::user()->org_id;
+        if($org_id){
+            $grid->model()->where(['org_id'=>$org_id]);
+        }
+        $grid->disableCreateButton(false);
+
+        $grid->column('id', __('Id'));
+        $grid->column('organization.name', __('机构'));
+        $grid->column('vaccine.name', __('疫苗'));
+        $grid->column('stock', __('库存'));
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(OrganizationVaccine::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('org_id', __('Org id'));
+        $show->field('vaccine_id', __('Vaccine id'));
+        $show->field('stock', __('Stock'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new OrganizationVaccine());
+        $is_admin = Admin::user()->isAdministrator();
+        if($is_admin){
+            if($form->isEditing()){
+                $form->select('org_id','机构')->options(Organization::pluck('name','id'))->disable();
+            } else {
+                $form->select('org_id','机构')->options(Organization::pluck('name','id'));
+            }
+        } else {
+            $form->hidden('org_id')->value(Admin::user()->org_id);
+        }
+        $form->select('vaccine_id', __('疫苗'))->options(Vaccine::pluck('name','id'));
+        $form->text('stock', __('库存'))->rules('required',['required'=>'请输入库存']);
+
+        return $form;
+    }
+}

+ 3 - 3
app/Community/routes.php

xqd xqd xqd
@@ -17,6 +17,9 @@ Route::resource('docter_verifies', DocterVerifyController::class);
 Route::resource('cdms_roles', PermissionController::class);
 Route::resource('docter_account', DocterAccountController::class);
 Route::resource('docter_chats', DocterChatController::class);
+
+Route::resource('organization_vaccines', Vaccine\OrganizationVaccineController::class);
+//服务管理
 Route::resource('services', ServiceController::class);
 Route::resource('orgservice', OrganizationController::class);
 Route::resource('nurse_ervice', NurseServiceController::class);
@@ -30,7 +33,6 @@ Route::resource('user_notices', UserNoticeController::class);
 Route::get('schedule', 'ScheduleController@index');
 Route::get('schedule_view', 'ScheduleController@schedule');
 
-//
 
 Route::get('send_notices', 'NoticeController@send');
 Route::resource('/docter_chats', DocterChatController::class);
@@ -49,7 +51,5 @@ Route::get('/setDocChedule', 'ApiController@setDocChedule');
 Route::get('/getScheduleInfo', 'ApiController@getScheduleInfo');
 
 
-Route::get('/getChatOrder', 'ScheDuleController@get_chat_order');
-
 
 

+ 11 - 0
app/Models/DocterLabel.php

xqd
@@ -0,0 +1,11 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class DocterLabel extends Model
+{
+    //
+    protected $table = 'docter_label';
+}

+ 18 - 0
app/Models/OrganizationVaccine.php

xqd
@@ -0,0 +1,18 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class OrganizationVaccine extends Model
+{
+    public function organization()
+    {
+        return $this->hasOne(Organization::class,'id','org_id');
+    }
+
+    public function vaccine()
+    {
+        return $this->hasOne(Vaccine::class,'id','vaccine_id');
+    }
+}