jingyuzhi %!s(int64=4) %!d(string=hai) anos
pai
achega
9d8ee4188d

+ 13 - 4
app/Admin/Actions/backstage/Docters/LabelManagement.php

xqd
@@ -16,16 +16,25 @@ class LabelManagement extends RowAction
     {
         // $model ...
         $label_name = $request->get('name');
-        $arr = [];
         if ($label_name == null)
         {
-            Docter::where('id',$model->id)->update(['label'=>$arr]);
+            $label_name = [];
         }
-        else
+        $label_num = count($label_name);
+        if($label_num > 2)
+        {
+            return $this->response()->error('不能选择超过两个标签')->refresh();
+        }
+        if ($label_num == 0)
         {
             Docter::where('id',$model->id)->update(['label'=>$label_name]);
+            return $this->response()->success('修改标签成功')->refresh();
+        }else
+        {
+            Docter::where('id',$model->id)->update(['label'=>$label_name]);
+            return $this->response()->success('修改标签成功')->refresh();
         }
-        return $this->response()->success('修改标签成功')->refresh();
+
     }
     public function form()
     {

+ 19 - 0
app/Admin/Actions/backstage/Orders/Evaluate.php

xqd
@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Admin\Actions\backstage\Orders;
+
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class Evaluate extends RowAction
+{
+    public $name = '评价管理';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+
+        return $this->response()->success('跳转评价管理成功')->redirect('/admin/orders_evaluates?order_id='.$this->row->id.'');
+    }
+
+}

+ 2 - 1
app/Admin/Actions/backstage/User/Suggests.php

xqd
@@ -12,7 +12,8 @@ class Suggests extends RowAction
     public function handle(Model $model)
     {
         // $model ...
-        return $this->response()->success('跳转病例意见单成功')->redirect('/admin/user_suggests?patient_id='.$this->row->patient_id.'');
+//        dd($model);
+        return $this->response()->success('跳转病例意见单成功')->redirect('/admin/user_suggests?order_id='.$this->row->id.'');
     }
 
 }

+ 91 - 26
app/Admin/Controllers/OrdersManagement/BookingOrderController.php

xqd xqd xqd xqd
@@ -2,8 +2,10 @@
 
 namespace App\Admin\Controllers\OrdersManagement;
 
+use App\Admin\Actions\backstage\Orders\Evaluate;
 use App\Models\Order;
 use App\Admin\Actions\backstage\Orders\OrderDetails;
+use App\Models\OrderPack;
 use Encore\Admin\Controllers\AdminController;
 use App\Admin\Actions\backstage\User\MapDepot;
 use App\Admin\Actions\backstage\User\Suggests;
@@ -71,19 +73,14 @@ class BookingOrderController extends AdminController
             $actions->disableDelete();
             // 去掉编辑
             $actions->disableEdit();
-            // 去掉查看
-            $actions->disableView();
-            $actions->add(new OrderDetails());
             $actions->add(new MapDepot());
+            $actions->add(new Evaluate());
             $actions->add(new Suggests());
         });
 
         $grid->column('id', __('Id'))->sortable();
-        $grid->column('user_id', __('用户id'));
         $grid->column('user.nickname', __('用户姓名'));
-        $grid->column('docter_id', __('医生id'));
         $grid->column('docter.name', __('医生姓名'));
-        $grid->column('patient_id', __('患者id'));
         $grid->column('orderPatient.name', __('患者姓名'));
         $grid->column('orderPatient.appoint_start_time', __('预约日期'))->display(function ($time){
             return date('Y-m-d H:i:s',$time);
@@ -92,10 +89,42 @@ class BookingOrderController extends AdminController
             return date('Y-m-d H:i:s',$time);
         });
         $grid->column('product_type', __('产品类型'))->using([3=>'门诊预约',4=>'疫苗接种预约',5=>'儿保预约']);
-        $grid->column('payment_type', __('支付方式'))->using([1=>'微信支付',2=>'余额支付']);
+        $grid->column('payment_type', __('支付方式'))->using([1=>'微信支付',2=>'余额支付',3=>'服务包支付']);
+//        $grid->column('payment_type', __('支付方式'))->display(function ($payment_type){
+//            if ($payment_type == 1)
+//            {
+//                return '微信支付';
+//            }
+//            if ($payment_type == 2){
+//                return '余额支付';
+//            }
+//            if ($payment_type == 3){
+//////                dd($this);
+////                $patient_id = $this->patient_id;
+////                $orde_id = Order::where('patient_id',$patient_id)->where('product_type',6)->get('id');
+//                return '服务包支付';
+//            }
+//        });
         $grid->column('order_status', __('订单状态'))->using([1=>'未支付',2=>'待接单',3=>'进行中',4=>'已完成',5=>'已取消']);
         $grid->column('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款']);
-
+        $grid->column('total_amount', __('订单总金额'))->display(function ($money){
+            return $money/100;
+        });
+        $grid->column('payment_amount', __('用户实际支付的金额'))->display(function ($money){
+            return $money/100;
+        });
+        $grid->column('discount_amount', __('折扣金额'))->display(function ($money){
+            return $money/100;
+        });
+        $grid->column('payment_time', __('支付时间'))->display(function ($time){
+            return date('Y-m-d H:i:s',$time);
+        });
+        $grid->column('receiving_time', __('接单时间'))->display(function ($time){
+            return date('Y-m-d H:i:s',$time);
+        });
+        $grid->column('end_time', __('订单完成时间'))->display(function ($time){
+            return date('Y-m-d H:i:s',$time);
+        });
         return $grid;
     }
 
@@ -108,25 +137,61 @@ class BookingOrderController extends AdminController
     protected function detail($id)
     {
         $show = new Show(Order::findOrFail($id));
-
         $show->field('id', __('Id'));
-        $show->field('user_id', __('User id'));
-        $show->field('docter_id', __('Docter id'));
-        $show->field('patient_id', __('Patient id'));
-        $show->field('organization_id', __('Organization id'));
-        $show->field('order_sn', __('Order sn'));
-        $show->field('payment_type', __('Payment type'));
-        $show->field('product_type', __('Product type'));
-        $show->field('order_status', __('Order status'));
-        $show->field('payment_status', __('Payment status'));
-        $show->field('total_amount', __('Total amount'));
-        $show->field('payment_amount', __('Payment amount'));
-        $show->field('discount_amount', __('Discount amount'));
-        $show->field('payment_time', __('Payment time'));
-        $show->field('created_at', __('Created at'));
-        $show->field('updated_at', __('Updated at'));
-        $show->field('outtime', __('Outtime'));
-        $show->field('receiving_time', __('Receiving time'));
+        $show->field('user_id', __('用户id'));
+        $show->field('user.nickname', __('用户姓名'));
+        $show->field('docter_id', __('医生id'));
+        $show->field('docter.name', __('医生姓名'));
+        $show->field('patient_id', __('患者id'));
+        $show->field('orderPatient.name', __('患者姓名'));
+        $show->field('organization_id', __('机构id'));
+        $show->field('organization.name', __('机构名'));
+        $show->field('order_sn', __('订单号'));
+        $show->field('product_type', __('产品类型'))->using([3=>'门诊预约',4=>'疫苗接种预约',5=>'儿保预约']);
+        $show->field('payment_type', __('支付类型'))->using([1=>'微信支付',2=>'余额支付']);
+        $show->field('order_status', __('订单状态'))->using([1=>'未支付',2=>'待接单',3=>'进行中',4=>'已完成',5=>'已取消']);
+        $show->field('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款']);
+        $show->field('total_amount', __('	订单总金额'))->as(function ($money){
+            return $money/100;
+        });
+        $show->field('payment_amount', __('用户实际支付的金额'))->as(function ($money){
+            return $money/100;
+        });
+        $show->field('discount_amount', __('折扣金额'))->as(function ($money){
+            return $money/100;
+        });
+        $show->field('payment_time', __('支付时间'))->as(function ($time){
+            if($time == 0)
+            {
+                return '';
+            }
+            else
+            {
+                return date('Y-m-d H:i:s',$time);
+            }
+        });
+        $show->field('receiving_time', __('接单时间'))->as(function ($time){
+            if($time == 0)
+            {
+                return '';
+            }
+            else
+            {
+                return date('Y-m-d H:i:s',$time);
+            }
+        });
+        $show->field('end_time', __('订单完成时间'))->as(function ($time){
+            if($time == 0)
+            {
+                return '';
+            }
+            else
+            {
+                return date('Y-m-d H:i:s',$time);
+            }
+        });
+        $show->field('created_at', __('创建时间'));
+        $show->field('updated_at', __('更新时间'));
 
         return $show;
     }

+ 76 - 25
app/Admin/Controllers/OrdersManagement/ConsultingOrdersController.php

xqd xqd xqd
@@ -2,6 +2,7 @@
 
 namespace App\Admin\Controllers\OrdersManagement;
 
+use App\Admin\Actions\backstage\Orders\Evaluate;
 use App\Admin\Actions\backstage\Orders\OrderDetails;
 use App\Admin\Actions\backstage\User\MapDepot;
 use App\Admin\Actions\backstage\User\Suggests;
@@ -68,25 +69,38 @@ class ConsultingOrdersController extends AdminController
             $actions->disableDelete();
             // 去掉编辑
             $actions->disableEdit();
-            // 去掉查看
-            $actions->disableView();
-            $actions->add(new OrderDetails());
             $actions->add(new MapDepot());
+            $actions->add(new Evaluate());
             $actions->add(new Suggests());
 
         });
         $grid->column('id', __('Id'))->sortable();
-        $grid->column('user_id', __('用户id'));
         $grid->column('user.nickname', __('用户姓名'));
-        $grid->column('docter_id', __('医生id'));
         $grid->column('docter.name', __('医生姓名'));
-        $grid->column('patient_id', __('患者id'));
         $grid->column('orderPatient.name', __('患者姓名'));
         $grid->column('orderPatient.symptoms', __('患者描述'));
         $grid->column('product_type', __('产品类型'))->using([1=>'电话咨询',2=>'图文咨询']);
-        $grid->column('payment_type', __('支付方式'))->using([1=>'微信支付',2=>'余额支付']);
+        $grid->column('payment_type', __('支付方式'))->using([1=>'微信支付',2=>'余额支付',3=>'服务包支付']);
         $grid->column('order_status', __('订单状态'))->using([1=>'未支付',2=>'待接单',3=>'进行中',4=>'已完成',5=>'已取消']);
         $grid->column('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款']);
+        $grid->column('total_amount', __('订单总金额'))->display(function ($money){
+            return $money/100;
+        });
+        $grid->column('payment_amount', __('用户实际支付的金额'))->display(function ($money){
+            return $money/100;
+        });
+        $grid->column('discount_amount', __('折扣金额'))->display(function ($money){
+            return $money/100;
+        });
+        $grid->column('payment_time', __('支付时间'))->display(function ($time){
+            return date('Y-m-d H:i:s',$time);
+        });
+        $grid->column('receiving_time', __('接单时间'))->display(function ($time){
+            return date('Y-m-d H:i:s',$time);
+        });
+        $grid->column('end_time', __('订单完成时间'))->display(function ($time){
+            return date('Y-m-d H:i:s',$time);
+        });
 
         return $grid;
     }
@@ -100,25 +114,62 @@ class ConsultingOrdersController extends AdminController
     protected function detail($id)
     {
         $show = new Show(Order::findOrFail($id));
-
         $show->field('id', __('Id'));
-        $show->field('user_id', __('User id'));
-        $show->field('docter_id', __('Docter id'));
-        $show->field('patient_id', __('Patient id'));
-        $show->field('organization_id', __('Organization id'));
-        $show->field('order_sn', __('Order sn'));
-        $show->field('payment_type', __('Payment type'));
-        $show->field('product_type', __('Product type'));
-        $show->field('order_status', __('Order status'));
-        $show->field('payment_status', __('Payment status'));
-        $show->field('total_amount', __('Total amount'));
-        $show->field('payment_amount', __('Payment amount'));
-        $show->field('discount_amount', __('Discount amount'));
-        $show->field('payment_time', __('Payment time'));
-        $show->field('created_at', __('Created at'));
-        $show->field('updated_at', __('Updated at'));
-        $show->field('outtime', __('Outtime'));
-        $show->field('receiving_time', __('Receiving time'));
+        $show->field('user_id', __('用户id'));
+        $show->field('user.nickname', __('用户姓名'));
+        $show->field('docter_id', __('医生id'));
+        $show->field('docter.name', __('医生姓名'));
+        $show->field('patient_id', __('患者id'));
+        $show->field('orderPatient.name', __('患者姓名'));
+        $show->field('organization_id', __('机构id'));
+        $show->field('organization.name', __('机构名'));
+        $show->field('order_sn', __('订单号'));
+        $show->field('product_type', __('产品类型'))->using([1=>'电话咨询',2=>'图文咨询']);
+        $show->field('payment_type', __('支付类型'))->using([1=>'微信支付',2=>'余额支付']);
+        $show->field('order_status', __('订单状态'))->using([1=>'未支付',2=>'待接单',3=>'进行中',4=>'已完成',5=>'已取消']);
+        $show->field('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款']);
+        $show->field('total_amount', __('	订单总金额'))->as(function ($money){
+            return $money/100;
+        });
+        $show->field('payment_amount', __('用户实际支付的金额'))->as(function ($money){
+            return $money/100;
+        });
+        $show->field('discount_amount', __('折扣金额'))->as(function ($money){
+            return $money/100;
+        });
+        $show->field('payment_time', __('支付时间'))->as(function ($time){
+            if($time == 0)
+            {
+                return '';
+            }
+            else
+            {
+                return date('Y-m-d H:i:s',$time);
+            }
+        });
+        $show->field('receiving_time', __('接单时间'))->as(function ($time){
+            if($time == 0)
+            {
+                return '';
+            }
+            else
+            {
+                return date('Y-m-d H:i:s',$time);
+            }
+        });
+        $show->field('end_time', __('订单完成时间'))->as(function ($time){
+            if($time == 0)
+            {
+                return '';
+            }
+            else
+            {
+                return date('Y-m-d H:i:s',$time);
+            }
+        });
+        $show->field('created_at', __('创建时间'));
+        $show->field('updated_at', __('更新时间'));
+
 
         return $show;
     }

+ 105 - 0
app/Admin/Controllers/OrdersManagement/OrdersEvaluate.php

xqd
@@ -0,0 +1,105 @@
+<?php
+
+namespace App\Admin\Controllers\OrdersManagement;
+
+use App\Models\Evaluate;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class OrdersEvaluate extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '评价管理';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Evaluate());
+        $grid->filter(function ($filter){
+            $filter->disableIdFilter();
+            $filter->like('user.nickname','用户名字');
+            $filter->like('docter.name','医生名字');
+            $filter->like('content','评价内容');
+            $filter->equal('order_id','订单id');
+            $filter->equal('status','审核状态')->select([
+                1   => '待审核',
+                2    => '审核通过',
+                3    => '忽略',
+            ]);
+        });
+        $grid->disableActions();
+        $grid->column('id', __('Id'));
+        $grid->column('order_id', __('订单ID'));
+        $grid->column('user.nickname', __('用户姓名'));
+        $grid->column('docter.name', __('医生名称'));
+        $grid->column('content', __('评价内容'));
+        $grid->column('score', __('评分'));
+        $grid->column('status', __('状态'))->using([1=>'待审核',2=>'审核通过',3=>'忽略']);
+        $grid->column('audit_time', __('审核时间'))->display(function ($time){
+            if($time == 0)
+                return '';
+            else
+            {
+                return date('Y-m-d H:i:s',$time);
+            }
+        });
+        $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(Evaluate::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('user_id', __('User id'));
+        $show->field('order_id', __('Order id'));
+        $show->field('docter_id', __('Docter id'));
+        $show->field('status', __('Status'));
+        $show->field('audit_time', __('Audit time'));
+        $show->field('content', __('Content'));
+        $show->field('score', __('Score'));
+        $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 Evaluate());
+
+        $form->number('user_id', __('User id'));
+        $form->number('order_id', __('Order id'));
+        $form->number('docter_id', __('Docter id'));
+        $form->switch('status', __('Status'))->default(1);
+        $form->number('audit_time', __('Audit time'));
+        $form->text('content', __('Content'));
+        $form->switch('score', __('Score'));
+
+        return $form;
+    }
+}

+ 69 - 25
app/Admin/Controllers/OrdersManagement/RechargeOrderController.php

xqd xqd xqd xqd xqd
@@ -2,6 +2,7 @@
 
 namespace App\Admin\Controllers\OrdersManagement;
 
+use App\Admin\Actions\backstage\Orders\Evaluate;
 use App\Models\Order;
 use App\Admin\Actions\backstage\Orders\OrderDetails;
 use Encore\Admin\Controllers\AdminController;
@@ -52,9 +53,7 @@ class RechargeOrderController extends AdminController
             $actions->disableDelete();
             // 去掉编辑
             $actions->disableEdit();
-            // 去掉查看
-            $actions->disableView();
-            $actions->add(new OrderDetails());
+            $actions->add(new Evaluate());
         });
 
         $grid->column('id', __('Id'))->sortable();
@@ -62,6 +61,8 @@ class RechargeOrderController extends AdminController
         $grid->column('user.nickname', __('用户姓名'));
         $grid->column('product_type', __('产品类型'))->using([7=>'充值订单']);
         $grid->column('payment_type', __('支付方式'))->using([1=>'微信支付',2=>'余额支付']);
+        $grid->column('order_status', __('订单状态'))->using([1=>'未支付',2=>'待接单',3=>'进行中',4=>'已完成',5=>'已取消']);
+        $grid->column('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款']);
         $grid->column('total_amount', __('订单总金额'))->display(function ($money){
             return $money/100;
         });
@@ -71,9 +72,15 @@ class RechargeOrderController extends AdminController
         $grid->column('discount_amount', __('折扣金额'))->display(function ($money){
             return $money/100;
         });
-        $grid->column('order_status', __('订单状态'))->using([1=>'未支付',2=>'待接单',3=>'进行中',4=>'已完成',5=>'已取消']);
-        $grid->column('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款']);
-
+        $grid->column('payment_time', __('支付时间'))->display(function ($time){
+            return date('Y-m-d H:i:s',$time);
+        });
+        $grid->column('receiving_time', __('接单时间'))->display(function ($time){
+            return date('Y-m-d H:i:s',$time);
+        });
+        $grid->column('end_time', __('订单完成时间'))->display(function ($time){
+            return date('Y-m-d H:i:s',$time);
+        });
         return $grid;
     }
 
@@ -85,26 +92,63 @@ class RechargeOrderController extends AdminController
      */
     protected function detail($id)
     {
-        $show = new Show(Order::findOrFail($id));
-
+        $show = new Show(Order::findOrFail($id));        $show->field('id', __('Id'));
         $show->field('id', __('Id'));
-        $show->field('user_id', __('User id'));
-        $show->field('docter_id', __('Docter id'));
-        $show->field('patient_id', __('Patient id'));
-        $show->field('organization_id', __('Organization id'));
-        $show->field('order_sn', __('Order sn'));
-        $show->field('payment_type', __('Payment type'));
-        $show->field('product_type', __('Product type'));
-        $show->field('order_status', __('Order status'));
-        $show->field('payment_status', __('Payment status'));
-        $show->field('total_amount', __('Total amount'));
-        $show->field('payment_amount', __('Payment amount'));
-        $show->field('discount_amount', __('Discount amount'));
-        $show->field('payment_time', __('Payment time'));
-        $show->field('created_at', __('Created at'));
-        $show->field('updated_at', __('Updated at'));
-        $show->field('outtime', __('Outtime'));
-        $show->field('receiving_time', __('Receiving time'));
+        $show->field('user_id', __('用户id'));
+        $show->field('user.nickname', __('用户姓名'));
+        $show->field('docter_id', __('医生id'));
+        $show->field('docter.name', __('医生姓名'));
+        $show->field('patient_id', __('患者id'));
+        $show->field('orderPatient.name', __('患者姓名'));
+        $show->field('organization_id', __('机构id'));
+        $show->field('organization.name', __('机构名'));
+        $show->field('order_sn', __('订单号'));
+        $show->field('product_type', __('产品类型'))->using([7=>'充值订单']);
+        $show->field('payment_type', __('支付类型'))->using([1=>'微信支付',2=>'余额支付']);
+        $show->field('order_status', __('订单状态'))->using([1=>'未支付',2=>'待接单',3=>'进行中',4=>'已完成',5=>'已取消']);
+        $show->field('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款']);
+        $show->field('total_amount', __('	订单总金额'))->as(function ($money){
+            return $money/100;
+        });
+        $show->field('payment_amount', __('用户实际支付的金额'))->as(function ($money){
+            return $money/100;
+        });
+        $show->field('discount_amount', __('折扣金额'))->as(function ($money){
+            return $money/100;
+        });
+        $show->field('payment_time', __('支付时间'))->as(function ($time){
+            if($time == 0)
+            {
+                return '';
+            }
+            else
+            {
+                return date('Y-m-d H:i:s',$time);
+            }
+        });
+        $show->field('receiving_time', __('接单时间'))->as(function ($time){
+            if($time == 0)
+            {
+                return '';
+            }
+            else
+            {
+                return date('Y-m-d H:i:s',$time);
+            }
+        });
+        $show->field('end_time', __('订单完成时间'))->as(function ($time){
+            if($time == 0)
+            {
+                return '';
+            }
+            else
+            {
+                return date('Y-m-d H:i:s',$time);
+            }
+        });
+        $show->field('created_at', __('创建时间'));
+        $show->field('updated_at', __('更新时间'));
+
 
         return $show;
     }

+ 74 - 24
app/Admin/Controllers/OrdersManagement/ServicePackOrderController.php

xqd xqd xqd xqd
@@ -2,6 +2,7 @@
 
 namespace App\Admin\Controllers\OrdersManagement;
 
+use App\Admin\Actions\backstage\Orders\Evaluate;
 use App\Models\Order;
 use App\Admin\Actions\backstage\Orders\OrderDetails;
 use Encore\Admin\Controllers\AdminController;
@@ -59,16 +60,12 @@ class ServicePackOrderController extends AdminController
             $actions->disableDelete();
             // 去掉编辑
             $actions->disableEdit();
-            // 去掉查看
-            $actions->disableView();
-            $actions->add(new OrderDetails());
             $actions->add(new MapDepot());
             $actions->add(new Suggests());
+            $actions->add(new Evaluate());
         });
         $grid->column('id', __('Id'))->sortable();
-        $grid->column('user_id', __('用户id'));
         $grid->column('user.nickname', __('用户姓名'));
-        $grid->column('patient_id', __('患者id'));
         $grid->column('orderPatient.name', __('患者姓名'));
         $grid->column('orderPack.service_pack_id', __('服务包id'));
         $grid->column('orderPack.pack_name', __('服务包名称'));
@@ -79,7 +76,24 @@ class ServicePackOrderController extends AdminController
         $grid->column('payment_type', __('支付方式'))->using([1=>'微信支付',2=>'余额支付']);
         $grid->column('order_status', __('订单状态'))->using([1=>'未支付',2=>'待接单',3=>'进行中',4=>'已完成',5=>'已取消']);
         $grid->column('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款']);
-
+        $grid->column('total_amount', __('订单总金额'))->display(function ($money){
+            return $money/100;
+        });
+        $grid->column('payment_amount', __('用户实际支付的金额'))->display(function ($money){
+            return $money/100;
+        });
+        $grid->column('discount_amount', __('折扣金额'))->display(function ($money){
+            return $money/100;
+        });
+        $grid->column('payment_time', __('支付时间'))->display(function ($time){
+            return date('Y-m-d H:i:s',$time);
+        });
+        $grid->column('receiving_time', __('接单时间'))->display(function ($time){
+            return date('Y-m-d H:i:s',$time);
+        });
+        $grid->column('end_time', __('订单完成时间'))->display(function ($time){
+            return date('Y-m-d H:i:s',$time);
+        });
         return $grid;
     }
 
@@ -92,25 +106,61 @@ class ServicePackOrderController extends AdminController
     protected function detail($id)
     {
         $show = new Show(Order::findOrFail($id));
-
         $show->field('id', __('Id'));
-        $show->field('user_id', __('User id'));
-        $show->field('docter_id', __('Docter id'));
-        $show->field('patient_id', __('Patient id'));
-        $show->field('organization_id', __('Organization id'));
-        $show->field('order_sn', __('Order sn'));
-        $show->field('payment_type', __('Payment type'));
-        $show->field('product_type', __('Product type'));
-        $show->field('order_status', __('Order status'));
-        $show->field('payment_status', __('Payment status'));
-        $show->field('total_amount', __('Total amount'));
-        $show->field('payment_amount', __('Payment amount'));
-        $show->field('discount_amount', __('Discount amount'));
-        $show->field('payment_time', __('Payment time'));
-        $show->field('created_at', __('Created at'));
-        $show->field('updated_at', __('Updated at'));
-        $show->field('outtime', __('Outtime'));
-        $show->field('receiving_time', __('Receiving time'));
+        $show->field('user_id', __('用户id'));
+        $show->field('user.nickname', __('用户姓名'));
+        $show->field('docter_id', __('医生id'));
+        $show->field('docter.name', __('医生姓名'));
+        $show->field('patient_id', __('患者id'));
+        $show->field('orderPatient.name', __('患者姓名'));
+        $show->field('organization_id', __('机构id'));
+        $show->field('organization.name', __('机构名'));
+        $show->field('order_sn', __('订单号'));
+        $show->field('product_type', __('产品类型'))->using([6=>'服务包订单']);
+        $show->field('payment_type', __('支付类型'))->using([1=>'微信支付',2=>'余额支付']);
+        $show->field('order_status', __('订单状态'))->using([1=>'未支付',2=>'待接单',3=>'进行中',4=>'已完成',5=>'已取消']);
+        $show->field('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款']);
+        $show->field('total_amount', __('	订单总金额'))->as(function ($money){
+            return $money/100;
+        });
+        $show->field('payment_amount', __('用户实际支付的金额'))->as(function ($money){
+            return $money/100;
+        });
+        $show->field('discount_amount', __('折扣金额'))->as(function ($money){
+            return $money/100;
+        });
+        $show->field('payment_time', __('支付时间'))->as(function ($time){
+            if($time == 0)
+            {
+                return '';
+            }
+            else
+            {
+                return date('Y-m-d H:i:s',$time);
+            }
+        });
+        $show->field('receiving_time', __('接单时间'))->as(function ($time){
+            if($time == 0)
+            {
+                return '';
+            }
+            else
+            {
+                return date('Y-m-d H:i:s',$time);
+            }
+        });
+        $show->field('end_time', __('订单完成时间'))->as(function ($time){
+            if($time == 0)
+            {
+                return '';
+            }
+            else
+            {
+                return date('Y-m-d H:i:s',$time);
+            }
+        });
+        $show->field('created_at', __('创建时间'));
+        $show->field('updated_at', __('更新时间'));
 
         return $show;
     }

+ 3 - 2
app/Admin/Controllers/OrdersManagement/UserSuggestsController.php

xqd
@@ -27,10 +27,11 @@ class UserSuggestsController extends AdminController
     {
         $grid = new Grid(new Suggest());
         $grid->disableCreateButton();
-        $uesr_id = \request('patient_id');
+        $grid->disableActions();
+        $uesr_id = \request('order_id');
         $grid->filter(function ($filter){
             $filter->disableIdFilter();
-            $filter->equal('patient_id','档案id');
+            $filter->equal('order_id','订单id');
         });
         $grid->column('id', __('Id'));
         $grid->column('order_id', __('订单id'));

+ 1 - 1
app/Admin/Controllers/UserManagement/BmUser/UserListController.php

xqd
@@ -76,7 +76,7 @@ class UserListController extends AdminController
                 return date("Y-m-d H:i",$time);
             });
 //            $grid->column('patient', __('患者姓名'))->pluck('name')->map('ucwords')->implode(',');
-            $grid->column('patient', __('患者姓名'))->pluck('name')->label('default');
+//            $grid->column('patient', __('患者姓名'))->pluck('name')->label('default');
         return $grid;
     }
 

+ 8 - 0
app/Admin/Controllers/UserManagement/DocterManagement/DoctorManagementController.php

xqd xqd xqd
@@ -38,6 +38,12 @@ class DoctorManagementController extends AdminController
         $grid->filter(function ($filter){
             $filter->disableIdFilter();
             $filter->like('name','昵称');
+//            $filter->like('organization','机构名称');
+            $filter->where(function ($query) {
+                $query->whereHas('organization',function ($query){
+                    $query->where('name','like',"%{$this->input}%");
+                });
+            },'机构名');
             $filter->equal('status','工作状态')->select([
                 0    => '禁用',
                 1    => '启用',
@@ -58,6 +64,7 @@ class DoctorManagementController extends AdminController
         $grid->column('id', __('Id'))->sortable();
         $grid->column('name', __('姓名'));
         $grid->column('avatar', __('头像'))->image('',50,50);
+        $grid->column('phone', __('电话'));
         $grid->column('score', __('评分'));
         $grid->column('service_persons', __('服务人数'));
         $states = [
@@ -65,6 +72,7 @@ class DoctorManagementController extends AdminController
             'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
         ];
         $grid->column('status', __('工作状态'))->switch($states);
+        $grid->column('organization', __('所属机构'))->pluck('name')->label('info');
         $grid->column('is_then', __('认证状态'))->using([0=>'未认证',1=>'已认证']);
         $grid->column('label', __('标签'))->display(function ($label){
                 $label_value = DocterLabel::whereIn('id',$label)->pluck('label_name');

+ 2 - 1
app/Admin/Controllers/UserManagement/DocterManagement/UserEvaluatesController.php

xqd
@@ -46,7 +46,8 @@ class UserEvaluatesController extends AdminController
             $filter->like('user.nickname','用户名字');
             $filter->like('docter.name','医生名字');
             $filter->like('content','评价内容');
-            $filter->equal('status','审核状态')->select([
+//            $filter->equal('id','订单id');
+                $filter->equal('status','审核状态')->select([
                 1   => '待审核',
                 2    => '审核通过',
                 3    => '忽略',

+ 2 - 0
app/Admin/routes.php

xqd
@@ -116,6 +116,8 @@ Route::group([
     $router->resource('orders_details', OrdersManagement\OrdersDetailsController::class);
     //订单记录中->病例意见单
     $router->resource('user_suggests', OrdersManagement\UserSuggestsController::class);
+    //评价管理
+    $router->resource('orders_evaluates', OrdersManagement\OrdersEvaluate::class);
 
     /*
      * 优惠券管理

+ 48 - 4
app/Http/Controllers/Api/V1/DocterController.php

xqd xqd xqd
@@ -8,6 +8,7 @@
 
 namespace App\Http\Controllers\Api\V1;
 
+use App\Models\Collection;
 use App\Models\Docter;
 use App\Models\Organization;
 use App\Models\Schedule;
@@ -53,15 +54,28 @@ class DocterController extends AuthController
                 $tmpDocterIds = array_column($v['docter'], 'id');
                 $docterIds = array_merge($docterIds, $tmpDocterIds);
             }
-            $docterIds = array_values(array_unique($docterIds));
-            $builder->where(function ($query) use($name, $docterIds) {
-                $query->where('name', 'like', '%'.$name.'%')->orWhereIn('id', $docterIds);
+            $orgDocterIds = array_values(array_unique($docterIds));
+            $builder->where(function ($query) use($name, $orgDocterIds) {
+                $query->where('name', 'like', '%'.$name.'%')->orWhereIn('id', $orgDocterIds);
             });
         }
+        if (!empty($req['city_id'])) {
+            $organizations = Organization::with('docter')->select(['id'])->where('city_id', $req['city_id'])->get()->toArray();
+            $docterIds = [];
+            foreach ($organizations as $k => $v) {
+                $tmpDocterIds = array_column($v['docter'], 'id');
+                $docterIds = array_merge($docterIds, $tmpDocterIds);
+            }
+            $cityDocterIds = array_values(array_unique($docterIds));
+            $builder->whereIn('id', $cityDocterIds);
+        }
 
         if ($list_type == 3) {
             $docterIds2 = SchedulePeriod::where('time_period_id', $req['time_period_id'])->where('schedule_date', $req['schedule_date'])->pluck('docter_id')->toArray();
             $builder->whereIn('id', $docterIds2);
+            //查询我关注的医生
+            $docterIds3 = Collection::where('user_id', $user['id'])->where('docter_id', '>', 0)->pluck('docter_id')->toArray();
+            $builder->whereNotIn('id', $docterIds3);
         }
 
         if (!empty($req['sort_type'])) {
@@ -75,7 +89,37 @@ class DocterController extends AuthController
                 $builder->orderBy('service_persons', 'desc');
             }
         }
-        $data = $builder->paginate();
+        $data = $builder->paginate()->toArray();
+
+        //组合我关注的医生,放在最前面
+        $page = empty($req['page']) ? 1 : $req['page'];
+        if ($list_type == 3 && $page == 1) {
+            $builder2 = Docter::with('office', 'qualification')->select(['id', 'type', 'name', 'phone', 'sex', 'birthday', 'avatar', 'status', 'label', 'sign', 'intro', 'office_id', 'qualification_id', 'score', 'service_persons', 'eva_num', 'service_days', 'phone_minutes', 'chat_price', 'phone_price', 'appoint_price', 'is_chat', 'is_phone', 'is_appoint', 'latitude', 'longitude', DB::raw($distance_field)])->whereIn('id', $docterIds3)->whereIn('id', $docterIds2)->where('status', 1)->where('is_then', 1)->where('phone', '<>', '')->where('is_appoint', 1);
+            if (!empty($req['name'])) {
+                $builder2->where(function ($query) use($name, $orgDocterIds) {
+                    $query->where('name', 'like', '%'.$name.'%')->orWhereIn('id', $orgDocterIds);
+                });
+            }
+            if (!empty($req['city_id'])) {
+                $builder2->whereIn('id', $cityDocterIds);
+            }
+            if (!empty($req['sort_type'])) {
+                if ($req['sort_type'] == 1) {
+                    $builder2->orderBy('distance', 'asc');
+                }
+                elseif ($req['sort_type'] == 2) {
+                    $builder2->orderBy('eva_num', 'desc');
+                }
+                elseif ($req['sort_type'] == 3) {
+                    $builder2->orderBy('service_persons', 'desc');
+                }
+            }
+
+            $collectDocters = $builder2->get()->toArray();
+            if (!empty($collectDocters)) {
+                $data['data'] = array_merge($collectDocters, $data['data'] );
+            }
+        }
 
         return out($data);
     }

+ 2 - 2
app/Http/Controllers/Api/V1/PatientController.php

xqd xqd
@@ -25,7 +25,7 @@ class PatientController extends AuthController
             'info' => 'max:1000',
             'card_type' => 'in:0,1,2',
             'card_number' => 'max:50',
-            'email' => 'required|email',
+            'email' => 'email',
             'phone' => 'required',
             'guardian_name' => 'required',
             'address' => 'required',
@@ -53,7 +53,7 @@ class PatientController extends AuthController
             'info' => 'max:1000',
             'card_type' => 'in:0,1,2',
             'card_number' => 'max:50',
-            'email' => 'required|email',
+            'email' => 'email',
             'phone' => 'required',
             'guardian_name' => 'required',
             'address' => 'required',

+ 15 - 1
app/Models/Docter.php

xqd xqd
@@ -13,7 +13,7 @@ class Docter extends BaseModel
     protected $casts = [
         'label' => 'json',
     ];
-    protected $appends = ['is_collect'];
+    protected $appends = ['is_collect', 'label_texts'];
 
     public function office()
     {
@@ -64,4 +64,18 @@ class Docter extends BaseModel
     {
         return $this->hasOne(Serviceapplys::class);
     }
+
+    public function getLabelTextsAttribute()
+    {
+        $data = [];
+        if (!empty($this->label)) {
+            $data = DocterLabel::select(['label_name'])->whereIn('id', $this->label)->where('status', 1)->get()->toArray();
+        }
+
+        return $data;
+    }
+    public function organization()
+    {
+        return $this->belongsToMany(Organization::class);
+    }
 }