Jelajahi Sumber

Merge branch 'master' of http://git.9026.com/swdz-WangHaijun/BaoMa

Swdz-WangHaiJun 4 tahun lalu
induk
melakukan
391c545076

+ 81 - 71
app/Admin/Actions/backstage/Coupon/AllCouponBatchGrant.php

xqd
@@ -7,108 +7,118 @@ use App\Models\CouponType;
 use App\Models\UserCoupon;
 use Encore\Admin\Actions\BatchAction;
 use Illuminate\Database\Eloquent\Collection;
+use Illuminate\Http\Request;
 
 class AllCouponBatchGrant extends BatchAction
 {
     public $name = '后台所有优惠券批量发放';
 
-    public function handle(Collection $collection)
+    public function handle(Collection $collection,Request $request)
     {
         //计算总共要发放多少个用户
         $user_arr = $collection->toArray();
         $user_num = count($user_arr);
+        //每种优惠券要发放几张
+        $coupon_num = $request->get('num');
+        //单种优惠券一共要发放几张
+        $all_num = $user_num*$coupon_num;
         //获取所有类型为后台发放的优惠券
         $allcoupon = Coupon::where('position_type',2)->get();
         $coupon_arr = $allcoupon->toArray();
         //判断优惠券数量是否充足
         foreach ($coupon_arr as $value)
         {
-            if ($value['num'] < $user_num)
+            if ($value['num'] < $all_num)
             {
                 return $this->response()->error('优惠券'.$value['name'].'的数量不足')->refresh();
             }
         }
 
-        foreach ($coupon_arr as $coupon)
+        for ($i = 0;$i<$coupon_num;$i++)
         {
-            //拿到基础数据
-            //获取过期类型是指定几天过期
-            if ($coupon['expire_type'] == 1){
-                $effective_days = $coupon['effective_days'];
-                $str_time = '+'.$effective_days.'day';
-                $expire_time_num = strtotime($str_time);
-                $arr = [
-                    'user_id' => 0,
-                    'coupon_id'=>$coupon['id'],
-                    'name' => $coupon['name'],
-                    'title' => $coupon['title'],
-                    'desc' => $coupon['desc'],
-                    'rules' => $coupon['rules'],
-                    'icon' => $coupon['icon'],
-                    'type' => $coupon['type'],
-                    'usable_type' => $coupon['usable_type'],
-                    'money' => $coupon['money'],
-                    'discount' => $coupon['discount'],
-                    'min_consume_amount' => $coupon['min_consume_amount'],
-                    'max_reduce_amount' => $coupon['max_reduce_amount'],
-                    'expire_type' => $coupon['expire_type'],
-                    'effective_days' => $coupon['effective_days'],
-                    'expire_time' => $expire_time_num,
-//                'coupons_num'=>0
-                ];
-            }else if ($coupon->expire_type == 2){
-                //设置有效期的基础数据
-                $arr = [
-                    'user_id' => 0,
-                    'coupon_id'=>$coupon['id'],
-                    'name' => $coupon['name'],
-                    'title' => $coupon['title'],
-                    'desc' => $coupon['desc'],
-                    'rules' => $coupon['rules'],
-                    'icon' => $coupon['icon'],
-                    'type' => $coupon['type'],
-                    'usable_type' => $coupon['usable_type'],
-                    'money' => $coupon['money'],
-                    'discount' => $coupon['discount'],
-                    'min_consume_amount' => $coupon['min_consume_amount'],
-                    'max_reduce_amount' => $coupon['max_reduce_amount'],
-                    'expire_type' => $coupon['expire_type'],
-                    'start_time' => $coupon['start_time'],
-                    'end_time' => $coupon['end_time'],
-//                'coupons_num'=>0
-                ];
-            }
-
-            //如果是部分产品可用,才有类型数组
-            if ($coupon['usable_type'] == 2)
-            //获取类型数组
+            foreach ($coupon_arr as $coupon)
             {
-                $type = CouponType::where('coupon_id',$coupon['id'])->where('user_coupon_id',0)->pluck('product_type');
-            }
-            foreach ($collection as $model) {
-                //插入到用户优惠券中
-                $arr['user_id'] = $model->id;
-                //获取到插入之后的id
-                $insert_id = UserCoupon::create($arr)->id;
-                //如果是部分产品可用,则要插入可用类型到优惠券可用类型表
+                //拿到基础数据
+                //获取过期类型是指定几天过期
+                if ($coupon['expire_type'] == 1){
+                    $effective_days = $coupon['effective_days'];
+                    $str_time = '+'.$effective_days.'day';
+                    $expire_time_num = strtotime($str_time);
+                    $arr = [
+                        'user_id' => 0,
+                        'coupon_id'=>$coupon['id'],
+                        'name' => $coupon['name'],
+                        'title' => $coupon['title'],
+                        'desc' => $coupon['desc'],
+                        'rules' => $coupon['rules'],
+                        'icon' => $coupon['icon'],
+                        'type' => $coupon['type'],
+                        'usable_type' => $coupon['usable_type'],
+                        'money' => $coupon['money'],
+                        'discount' => $coupon['discount'],
+                        'min_consume_amount' => $coupon['min_consume_amount'],
+                        'max_reduce_amount' => $coupon['max_reduce_amount'],
+                        'expire_type' => $coupon['expire_type'],
+                        'effective_days' => $coupon['effective_days'],
+                        'expire_time' => $expire_time_num,
+                    ];
+                }else if ($coupon->expire_type == 2){
+                    //设置有效期的基础数据
+                    $arr = [
+                        'user_id' => 0,
+                        'coupon_id'=>$coupon['id'],
+                        'name' => $coupon['name'],
+                        'title' => $coupon['title'],
+                        'desc' => $coupon['desc'],
+                        'rules' => $coupon['rules'],
+                        'icon' => $coupon['icon'],
+                        'type' => $coupon['type'],
+                        'usable_type' => $coupon['usable_type'],
+                        'money' => $coupon['money'],
+                        'discount' => $coupon['discount'],
+                        'min_consume_amount' => $coupon['min_consume_amount'],
+                        'max_reduce_amount' => $coupon['max_reduce_amount'],
+                        'expire_type' => $coupon['expire_type'],
+                        'start_time' => $coupon['start_time'],
+                        'end_time' => $coupon['end_time'],
+                    ];
+                }
+
+                //如果是部分产品可用,才有类型数组
                 if ($coupon['usable_type'] == 2)
+                    //获取类型数组
                 {
-                    foreach ($type as $value)
+                    $type = CouponType::where('coupon_id',$coupon['id'])->where('user_coupon_id',0)->pluck('product_type');
+                }
+                foreach ($collection as $model) {
+                    //插入到用户优惠券中
+                    $arr['user_id'] = $model->id;
+                    //获取到插入之后的id
+                    $insert_id = UserCoupon::create($arr)->id;
+                    //如果是部分产品可用,则要插入可用类型到优惠券可用类型表
+                    if ($coupon['usable_type'] == 2)
                     {
-                        $coupon_type_arr = [
-                            'coupon_id' => 0,
-                            'user_coupon_id' =>$insert_id,
-                            'product_type' =>$value
-                        ];
-                        CouponType::create($coupon_type_arr);
+                        foreach ($type as $value)
+                        {
+                            $coupon_type_arr = [
+                                'coupon_id' => 0,
+                                'user_coupon_id' =>$insert_id,
+                                'product_type' =>$value
+                            ];
+                            CouponType::create($coupon_type_arr);
+                        }
                     }
+                    $coupon = Coupon::where('id',$coupon['id'])->first();
+                    Coupon::where('id',$coupon['id'])->update(['num'=>$coupon['num']-1]);
                 }
-                $coupon = Coupon::where('id',$coupon['id'])->first();
-                Coupon::where('id',$coupon['id'])->update(['num'=>$coupon['num']-1]);
             }
         }
         return $this->response()->success('优惠券发放成功')->refresh();
 
     }
+    public function form()
+    {
+        $this->text('num', '优惠券数量')->help('点击提交后请耐心等待,请勿再次点击提交按钮,以免造成多次发放');
+    }
 
 }

+ 73 - 66
app/Admin/Actions/backstage/Coupon/CouponBatchGrant.php

xqd xqd
@@ -16,83 +16,89 @@ class CouponBatchGrant extends BatchAction
     public function handle(Collection $collection,Request $request)
     {
         $coupon_id = request('id');
+        //优惠券数量
+        $coupon_num = request('num');
         $user_arr = $collection->toArray();
+        //用户数量
         $user_num = count($user_arr);
         $coupon = Coupon::where('id',$coupon_id)->first();
-        if ($coupon->num < $user_num)
+        $all_num = $coupon_num*$user_num;
+        //判断优惠券是否充足 优惠券数量*用户数量
+        if ($coupon->num < $all_num)
         {
-            return $this->response()->error('优惠券数量不足')->refresh();
+            return $this->response()->error('优惠券'.Coupon::where('id',$coupon_id)->value('name').'数量不足')->refresh();
         }
-        //获取过期类型是指定几天过期
-        if ($coupon->expire_type == 1){
-            $effective_days = $coupon->effective_days;
-            $str_time = '+'.$effective_days.'day';
-            $expire_time_num = strtotime($str_time);
-            $arr = [
-                'user_id' => 0,
-                'coupon_id'=>$coupon_id,
-                'name' => $coupon->name,
-                'title' => $coupon->title,
-                'desc' => $coupon->desc,
-                'rules' => $coupon->rules,
-                'icon' => $coupon->icon,
-                'type' => $coupon->type,
-                'usable_type' => $coupon->usable_type,
-                'money' => $coupon->money,
-                'discount' => $coupon->discount,
-                'min_consume_amount' => $coupon->min_consume_amount,
-                'max_reduce_amount' => $coupon->max_reduce_amount,
-                'expire_type' => $coupon->expire_type,
-                'effective_days' => $coupon->effective_days,
-                'expire_time' => $expire_time_num,
-//                'coupons_num'=>0
-            ];
-        }else if ($coupon->expire_type == 2){
-            $arr = [
-                'user_id' => 0,
-                'coupon_id'=>$coupon_id,
-                'name' => $coupon->name,
-                'title' => $coupon->title,
-                'desc' => $coupon->desc,
-                'rules' => $coupon->rules,
-                'icon' => $coupon->icon,
-                'type' => $coupon->type,
-                'usable_type' => $coupon->usable_type,
-                'money' => $coupon->money,
-                'discount' => $coupon->discount,
-                'min_consume_amount' => $coupon->min_consume_amount,
-                'max_reduce_amount' => $coupon->max_reduce_amount,
-                'expire_type' => $coupon->expire_type,
-                'start_time' => $coupon->start_time,
-                'end_time' => $coupon->end_time,
-//                'coupons_num'=>0
-            ];
-        }
-        if ($coupon->usable_type == 2)
+        for ($i = 0;$i<$coupon_num;$i++)
         {
-            //拿到类型数组
-            $type = CouponType::where('coupon_id',$coupon_id)->where('user_coupon_id',0)->pluck('product_type');
-        }
-
-        foreach ($collection as $model) {
-            //插入到用户优惠券中
-            $arr['user_id'] = $model->id;
-            //获取到插入之后的id
-            $insert_id = UserCoupon::create($arr)->id;
+            //获取过期类型是指定几天过期
+            if ($coupon->expire_type == 1){
+                $effective_days = $coupon->effective_days;
+                $str_time = '+'.$effective_days.'day';
+                $expire_time_num = strtotime($str_time);
+                $arr = [
+                    'user_id' => 0,
+                    'coupon_id'=>$coupon_id,
+                    'name' => $coupon->name,
+                    'title' => $coupon->title,
+                    'desc' => $coupon->desc,
+                    'rules' => $coupon->rules,
+                    'icon' => $coupon->icon,
+                    'type' => $coupon->type,
+                    'usable_type' => $coupon->usable_type,
+                    'money' => $coupon->money,
+                    'discount' => $coupon->discount,
+                    'min_consume_amount' => $coupon->min_consume_amount,
+                    'max_reduce_amount' => $coupon->max_reduce_amount,
+                    'expire_type' => $coupon->expire_type,
+                    'effective_days' => $coupon->effective_days,
+                    'expire_time' => $expire_time_num,
+                ];
+            }else if ($coupon->expire_type == 2){
+                $arr = [
+                    'user_id' => 0,
+                    'coupon_id'=>$coupon_id,
+                    'name' => $coupon->name,
+                    'title' => $coupon->title,
+                    'desc' => $coupon->desc,
+                    'rules' => $coupon->rules,
+                    'icon' => $coupon->icon,
+                    'type' => $coupon->type,
+                    'usable_type' => $coupon->usable_type,
+                    'money' => $coupon->money,
+                    'discount' => $coupon->discount,
+                    'min_consume_amount' => $coupon->min_consume_amount,
+                    'max_reduce_amount' => $coupon->max_reduce_amount,
+                    'expire_type' => $coupon->expire_type,
+                    'start_time' => $coupon->start_time,
+                    'end_time' => $coupon->end_time,
+                ];
+            }
             if ($coupon->usable_type == 2)
             {
-                foreach ($type as $value)
+                //拿到类型数组
+                $type = CouponType::where('coupon_id',$coupon_id)->where('user_coupon_id',0)->pluck('product_type');
+            }
+
+            foreach ($collection as $model) {
+                //插入到用户优惠券中
+                $arr['user_id'] = $model->id;
+                //获取到插入之后的id
+                $insert_id = UserCoupon::create($arr)->id;
+                if ($coupon->usable_type == 2)
                 {
-                    $coupon_type_arr = [
-                        'coupon_id' => 0,
-                        'user_coupon_id' =>$insert_id,
-                        'product_type' =>$value
-                    ];
-                    CouponType::create($coupon_type_arr);
+                    foreach ($type as $value)
+                    {
+                        $coupon_type_arr = [
+                            'coupon_id' => 0,
+                            'user_coupon_id' =>$insert_id,
+                            'product_type' =>$value
+                        ];
+                        CouponType::create($coupon_type_arr);
+                    }
                 }
+                $coupon = Coupon::where('id',$coupon_id)->first();
+                Coupon::where('id',$coupon_id)->update(['num'=>$coupon->num-1]);
             }
-            $coupon = Coupon::where('id',$coupon_id)->first();
-            Coupon::where('id',$coupon_id)->update(['num'=>$coupon->num-1]);
         }
         return $this->response()->success('优惠券发放成功')->refresh();
     }
@@ -101,5 +107,6 @@ class CouponBatchGrant extends BatchAction
     {
         $name = Coupon::where('position_type',2)->pluck('name','id');
         $this->select('id', '优惠券名称')->options($name);
+        $this->text('num', '优惠券数量')->help('点击提交后请耐心等待,请勿再次点击提交按钮,以免造成多次发放');
     }
 }

+ 35 - 0
app/Admin/Actions/backstage/Docters/DefaultOrganazation.php

xqd
@@ -0,0 +1,35 @@
+<?php
+
+namespace App\Admin\Actions\backstage\Docters;
+
+use App\Models\Docter;
+use App\Models\DocterOrganization;
+use App\Models\Organization;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Http\Request;
+
+class DefaultOrganazation extends RowAction
+{
+    public $name = '修改默认机构';
+
+    public function handle(Model $model, Request $request)
+    {
+        // $model ...
+        $org_id = $request->get('org_id');
+        //经度
+        $longitude = Organization::where('id',$org_id)->value('longitude');
+        //纬度
+        $latitude = Organization::where('id',$org_id)->value('latitude');
+        Docter::where('id',$this->row->id)->update(['latitude'=>$latitude,'longitude'=>$longitude]);
+        return $this->response()->success('修改默认机构成功')->refresh();
+    }
+
+    public function form(){
+        $id = $this->row->id;
+        $org_id = DocterOrganization::where('docter_id',$id)->where('state',1)->pluck('organization_id')->toArray();
+        $all_org = Organization::whereIn('id',$org_id)->pluck('name','id')->toArray();
+
+        $this->select('org_id','机构名')->options($all_org);
+    }
+}

+ 25 - 0
app/Admin/Actions/backstage/Pass.php

xqd xqd
@@ -4,6 +4,7 @@ namespace App\Admin\Actions\backstage;
 
 use App\Models\Docter;
 use App\Models\DocterOrganization;
+use App\Models\Organization;
 use App\Models\Serviceapplys;
 use Encore\Admin\Actions\RowAction;
 use Illuminate\Database\Eloquent\Model;
@@ -16,6 +17,30 @@ class Pass extends RowAction
     {
 //         $model ...
 //        dd($model);
+        //判定通过认证的数量
+        $is_pass_num = 0;
+        //查询认证表里有多少条记录
+        $docter_approve_num = DocterOrganization::where('docter_id',$model->docter_id)->get();
+        //转成数组格式方便遍历
+        $docter_approve_num_array = $docter_approve_num->toarray();
+
+        foreach ($docter_approve_num_array as $value)
+        {
+            if ($value['state'] == 1)
+            {
+                $is_pass_num=$is_pass_num+1;
+            }
+        }
+        //如果是第一次认证,就将机构的经纬度覆盖进去
+        if ($is_pass_num == 0 )
+        {
+            //organization_id
+            //经度
+            $longitude = Organization::where('id',$this->row->organization_id)->value('longitude');
+            //纬度
+            $latitude = Organization::where('id',$this->row->organization_id)->value('latitude');
+            Docter::where('id',$this->row->docter_id)->update(['latitude'=>$latitude,'longitude'=>$longitude]);
+        }
         $end_time = strtotime('+1year');
         $authentication_end_time = date('Y-m-d H:i:s',$end_time);
         DocterOrganization::where('id',$model->id)->update(['state'=>1,

+ 90 - 0
app/Admin/Controllers/HelpInfoController.php

xqd
@@ -0,0 +1,90 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\HelpInfo;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class HelpInfoController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '常见问题';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new HelpInfo());
+
+        $grid->column('id', __('Id'));
+        $grid->column('title', __('标题'));
+        $grid->column('content', __('内容'))->limit(50,'...');
+        $state = [
+            'on' => ['value' =>1, 'text' => '展示', 'color' => 'primary'],
+            'off' => ['value' => 0, 'text' => '不展示', 'color' => 'danger']
+        ];
+        $grid->column('status', __('状态'))->switch($state);
+        $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(HelpInfo::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('title', __('标题'));
+        $show->field('content', __('内容'));
+        $show->field('status', __('状态'))->using([0=>'不展示',1=>'展示']);
+        $show->field('created_at', __('创建时间'));
+        $show->field('updated_at', __('更新时间'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new HelpInfo());
+
+        $form->text('title', __('标题'));
+        $form->editor('content', __('内容'));
+        $state = [
+            'on' => ['value' =>1, 'text' => '展示', 'color' => 'primary'],
+            'off' => ['value' => 0, 'text' => '不展示', 'color' => 'danger']
+        ];
+        $form->switch('status', __('状态'))->default(1);
+        $form->footer(function ($footer) {
+            // 去掉`查看`checkbox
+            $footer->disableViewCheck();
+            // 去掉`继续编辑`checkbox
+            $footer->disableEditingCheck();
+            // 去掉`继续创建`checkbox
+            $footer->disableCreatingCheck();
+
+        });
+        return $form;
+    }
+}

+ 78 - 0
app/Admin/Controllers/UserManagement/BmUser/FeedBacksController.php

xqd
@@ -0,0 +1,78 @@
+<?php
+
+namespace App\Admin\Controllers\UserManagement\BmUser;
+
+use App\Models\Feedback;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class FeedBacksController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '反馈列表';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Feedback());
+        $grid->actions(function ($actions){
+           $actions->disableView();
+           $actions->disableEdit();
+        });
+        $grid->filter(function ($filter){
+           $filter->like('docter.nickname','名字');
+        });
+        $grid->column('id', __('Id'));
+        $grid->column('user_id', __('用户id'));
+        $grid->column('docter.nickname', __('用户名字'));
+        $grid->column('docter.phone', __('用户手机号'));
+        $grid->column('content', __('反馈内容'))->limit(50,'...');
+        $grid->column('created_at', __('创建时间'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Feedback::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('user_id', __('User id'));
+        $show->field('content', __('Content'));
+        $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 Feedback());
+
+        $form->number('user_id', __('User id'));
+        $form->text('content', __('Content'));
+
+        return $form;
+    }
+}

+ 9 - 3
app/Admin/Controllers/UserManagement/DocterManagement/DoctorManagementController.php

xqd xqd xqd
@@ -3,6 +3,7 @@
 namespace App\Admin\Controllers\UserManagement\DocterManagement;
 
 use App\Admin\Actions\backstage\Docters\AddLabel;
+use App\Admin\Actions\backstage\Docters\DefaultOrganazation;
 use App\Admin\Actions\backstage\Docters\DelLabel;
 use App\Admin\Actions\backstage\Docters\LabelManagement;
 use App\Admin\Actions\backstage\Docters\ServiceManagement;
@@ -63,6 +64,8 @@ class DoctorManagementController extends AdminController
             $actions->add(new LabelManagement());
             //服务管理
             $actions->add(new ServiceManagement());
+            //修改默认医院
+            $actions->add(new DefaultOrganazation());
         });
         $grid->model()->orderBy('id','desc');
         $grid->column('id', __('Id'))->sortable();
@@ -77,15 +80,18 @@ class DoctorManagementController extends AdminController
             'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
         ];
 //        $grid->column('organization', __('所属机构'))->pluck('name')->label('info');
-        $grid->column('organization', __('所属机构'))->pluck('name')->display(function ($organization){
+        $grid->column('org', __('所属机构'))->display(function (){
 //            dd($organization);
-            if (empty($organization->toArray()))
+//            dd($this->id);
+            $org_id = DocterOrganization::where('docter_id',$this->id)->where('state',1)->pluck('organization_id')->toArray();
+            $name = Organization::whereIn('id',$org_id)->pluck('name')->toArray();
+            if (empty($name))
             {
                 return '无';
             }
             else
             {
-                return $organization;
+                return $name;
             }
         })->label('info');
         $grid->column('serviceapply', __('开通服务'))->where('status',2)->pluck('service_type')->display(function ($type){

+ 7 - 0
app/Admin/routes.php

xqd xqd
@@ -113,6 +113,8 @@ Route::group([
     $router->resource('user_coupons', UserManagement\BmUser\UserCouponsController::class);
     //用户管理->订单数据总览
     $router->resource('user_orders', UserManagement\BmUser\UserOrdersController::class);
+    //反馈列表
+    $router->resource('feedback', UserManagement\BmUser\FeedBacksController::class);
 
     /*
      * 订单管理
@@ -165,5 +167,10 @@ Route::group([
      * 权限管理
      * */
     $router->resource('cdms_roles', PermissionController::class);
+
+    /*
+     * 常见问题
+     * */
+    $router->resource('helpinfos', HelpInfoController::class);
 });
 

+ 17 - 6
app/Http/Controllers/Api/V1/DocterController.php

xqd xqd xqd xqd
@@ -186,7 +186,7 @@ class DocterController extends AuthController
             'longitude' => 'numeric',
         ]);
         $user = $this->user;
-        $builder = Schedule::with(['schedulePeriod.timePeriod', 'schedulePeriod.organization'])->where('docter_id', $req['docter_id'])->where('schedule_type',1)->where('schedule_day', '>=', date('Ymd'))->orderBy('schedule_day');
+        $builder = Schedule::with(['schedulePeriod.timePeriod', 'schedulePeriod.organization'])->where('docter_id', $req['docter_id'])->where('schedule_type', 1)->where('schedule_day', '>=', date('Ymd'))->orderBy('schedule_day');
 //        if (!empty($req['organization_id'])) {
 //            $builder->where('organization_id', $req['organization_id']);
 //        }
@@ -270,7 +270,6 @@ class DocterController extends AuthController
 
     public function timePeriodList()
     {
-
         $req = request()->post();
         $this->validate(request(), [
             'organization_id' => 'integer',
@@ -279,12 +278,22 @@ class DocterController extends AuthController
             'latitude' => 'numeric',
             'longitude' => 'numeric',
         ]);
-        $builder = Schedule::with(['schedulePeriod.timePeriod', 'schedulePeriod.organization'])->where('organization_id', $req['organization_id'])->where('schedule_type', $req['schedule_type'])->where('schedule_day', '>=', date('Ymd'))->orderBy('schedule_day');
-        $data = $builder->paginate($req['per_page']??15)->toArray();
-        $docterSettings = DocterSetting::select(['service_num'])->where('org_id', $req['organization_id'])->where('type',$req['schedule_type'])->first();
+
+        $builder = Schedule::with(['schedulePeriod.timePeriod', 'schedulePeriod.organization'])->where('schedule_day', '>=', date('Ymd'));
+        if (!empty($req['organization_id'])) {
+            $builder->where('organization_id', $req['organization_id']);
+        }
+        if (!empty($req['schedule_type'])) {
+            $builder->where('schedule_type', $req['schedule_type']);
+        }
+        $data = $builder->orderBy('schedule_day', 'asc')->paginate($req['per_page']??15)->toArray();
+
+        $docterSettings = DocterSetting::select(['service_num'])->where('org_id', $req['organization_id'])->where('type', $req['schedule_type'])->first();
         if (!empty($data)) {
             foreach ($data['data'] as $k => &$v) {
-                if(empty($v['schedule_period'])) unset($data['data'][$k]);
+                if (empty($v['schedule_period'])) {
+                    unset($data['data'][$k]);
+                }
                 foreach ($v['schedule_period'] as $k1 => &$v1) {
                     if (empty($docterSettings)) {
                         $v1['can_appoint_num'] = 0;
@@ -296,7 +305,9 @@ class DocterController extends AuthController
                 }
             }
         }
+
         $data['data'] = array_values($data['data']);
+
         return out($data);
     }
 }

+ 0 - 1
app/Http/Controllers/Api/V1/OrderController.php

xqd
@@ -8,7 +8,6 @@
 
 namespace App\Http\Controllers\Api\V1;
 
-use App\Models\Docter;
 use App\Models\Nurse;
 use App\Models\Order;
 use App\Models\OrderNurse;

+ 3 - 0
app/Models/Feedback.php

xqd
@@ -14,4 +14,7 @@ class Feedback extends BaseModel
     {
         return 'feedbacks';
     }
+    public function docter(){
+        return $this->hasOne(User::class,'id','user_id');
+    }
 }