Browse Source

合并代码

root 4 years ago
parent
commit
a038750726
100 changed files with 6646 additions and 15 deletions
  1. 3 2
      .gitignore
  2. 16 0
      app/Admin/Actions/Cdmuser.php
  3. 25 0
      app/Admin/Actions/Community.php
  4. 22 0
      app/Admin/Actions/Community/Docter/AddAccount.php
  5. 15 0
      app/Admin/Actions/Community/Docter/Chat.php
  6. 24 0
      app/Admin/Actions/Community/Docter/EditAccount.php
  7. 32 0
      app/Admin/Actions/Community/Docter/Failed.php
  8. 56 0
      app/Admin/Actions/Community/Docter/Pass.php
  9. 109 0
      app/Admin/Actions/Community/Notice/sendNotice.php
  10. 22 0
      app/Admin/Actions/Community/Nurse/DelNurse.php
  11. 24 0
      app/Admin/Actions/Community/Nurse/Finished.php
  12. 29 0
      app/Admin/Actions/Community/Nurse/Reserved.php
  13. 19 0
      app/Admin/Actions/Community/Order/Detail.php
  14. 24 0
      app/Admin/Actions/Serve/Addmember.php
  15. 19 0
      app/Admin/Actions/Serve/member.php
  16. 26 0
      app/Admin/Actions/Service/ApplysAction.php
  17. 20 0
      app/Admin/Actions/Service/PassAction.php
  18. 20 0
      app/Admin/Actions/Service/RefuseAction.php
  19. 21 0
      app/Admin/Actions/Service/RevokeAction.php
  20. 26 0
      app/Admin/Actions/UpdateCdms.php
  21. 112 0
      app/Admin/Actions/Vaccines/ImportAction.php
  22. 114 0
      app/Admin/Actions/backstage/Coupon/AllCouponBatchGrant.php
  23. 105 0
      app/Admin/Actions/backstage/Coupon/CouponBatchGrant.php
  24. 19 0
      app/Admin/Actions/backstage/Coupon/CouponDetails.php
  25. 23 0
      app/Admin/Actions/backstage/Coupon/CouponDistributions.php
  26. 19 0
      app/Admin/Actions/backstage/Docters/AppointAction.php
  27. 19 0
      app/Admin/Actions/backstage/Docters/ChatAction.php
  28. 50 0
      app/Admin/Actions/backstage/Docters/LabelManagement.php
  29. 19 0
      app/Admin/Actions/backstage/Docters/PhoneAction.php
  30. 18 0
      app/Admin/Actions/backstage/Docters/ServiceManagement.php
  31. 18 0
      app/Admin/Actions/backstage/Docters/SignUp.php
  32. 19 0
      app/Admin/Actions/backstage/Docters/Team.php
  33. 20 0
      app/Admin/Actions/backstage/Evaluate/Ignore.php
  34. 20 0
      app/Admin/Actions/backstage/Evaluate/Pass.php
  35. 19 0
      app/Admin/Actions/backstage/Orders/Evaluate.php
  36. 20 0
      app/Admin/Actions/backstage/Orders/OrderDetails.php
  37. 19 0
      app/Admin/Actions/backstage/Orders/PdfAction.php
  38. 17 0
      app/Admin/Actions/backstage/Orders/ServicePack.php
  39. 23 0
      app/Admin/Actions/backstage/Orders/ServicePackOrderList.php
  40. 43 0
      app/Admin/Actions/backstage/Pass.php
  41. 20 0
      app/Admin/Actions/backstage/Refuse.php
  42. 41 0
      app/Admin/Actions/backstage/Revoke.php
  43. 18 0
      app/Admin/Actions/backstage/User/BalanceLog.php
  44. 20 0
      app/Admin/Actions/backstage/User/BlackList.php
  45. 28 0
      app/Admin/Actions/backstage/User/Insurance.php
  46. 37 0
      app/Admin/Actions/backstage/User/MapDepot.php
  47. 19 0
      app/Admin/Actions/backstage/User/Orders.php
  48. 19 0
      app/Admin/Actions/backstage/User/Suggests.php
  49. 19 0
      app/Admin/Actions/backstage/User/archives.php
  50. 19 0
      app/Admin/Actions/backstage/User/coupons.php
  51. 19 0
      app/Admin/Actions/backstage/User/service.php
  52. 25 0
      app/Admin/Actions/finished.php
  53. 26 0
      app/Admin/Controllers/Api/ApiController.php
  54. 24 0
      app/Admin/Controllers/ApiController.php
  55. 88 0
      app/Admin/Controllers/ArticleManagement/ArticleController.php
  56. 1 1
      app/Admin/Controllers/AuthController.php
  57. 70 0
      app/Admin/Controllers/CdmsController.php
  58. 81 0
      app/Admin/Controllers/CommunityNotice/CommunityNotices.php
  59. 118 0
      app/Admin/Controllers/Config/ConfigController.php
  60. 307 0
      app/Admin/Controllers/Config/FormController.php
  61. 103 0
      app/Admin/Controllers/CouponManagement/CouponDetailsController.php
  62. 133 0
      app/Admin/Controllers/CouponManagement/CouponDistributionUserList.php
  63. 195 0
      app/Admin/Controllers/CouponManagement/CouponManagementController.php
  64. 11 11
      app/Admin/Controllers/ExampleController.php
  65. 2 1
      app/Admin/Controllers/HomeController.php
  66. 229 0
      app/Admin/Controllers/OrdersManagement/BookingOrderController.php
  67. 234 0
      app/Admin/Controllers/OrdersManagement/ConsultingOrdersController.php
  68. 73 0
      app/Admin/Controllers/OrdersManagement/InsuranceListController.php
  69. 125 0
      app/Admin/Controllers/OrdersManagement/OrdersDetailsController.php
  70. 106 0
      app/Admin/Controllers/OrdersManagement/OrdersEvaluate.php
  71. 190 0
      app/Admin/Controllers/OrdersManagement/RechargeOrderController.php
  72. 125 0
      app/Admin/Controllers/OrdersManagement/ServicePackDetailsController.php
  73. 176 0
      app/Admin/Controllers/OrdersManagement/ServicePackOrderController.php
  74. 148 0
      app/Admin/Controllers/OrdersManagement/ServicePackOrderListController.php
  75. 96 0
      app/Admin/Controllers/OrdersManagement/UserSuggestsController.php
  76. 141 0
      app/Admin/Controllers/OrganizationController.php
  77. 65 0
      app/Admin/Controllers/OutpatientServiceCCController.php
  78. 55 0
      app/Admin/Controllers/OutpatientServiceController.php
  79. 92 0
      app/Admin/Controllers/PermissionController.php
  80. 70 0
      app/Admin/Controllers/PhoneServiceCCController.php
  81. 62 0
      app/Admin/Controllers/PhoneServiceController.php
  82. 68 0
      app/Admin/Controllers/ReplyServiceCCController.php
  83. 56 0
      app/Admin/Controllers/ReplyServiceController.php
  84. 101 0
      app/Admin/Controllers/ServiceManagement/ServiceController.php
  85. 44 0
      app/Admin/Controllers/ServicePacksManagment/OpenPackController.php
  86. 82 0
      app/Admin/Controllers/ServicePacksManagment/ServebannerController.php
  87. 113 0
      app/Admin/Controllers/ServicePacksManagment/ServicePacksController.php
  88. 100 0
      app/Admin/Controllers/ServicePacksManagment/TeamController.php
  89. 63 0
      app/Admin/Controllers/ServicePacksManagment/TeamDocterController.php
  90. 106 0
      app/Admin/Controllers/UserManagement/BmUser/UserBalanceLogController.php
  91. 142 0
      app/Admin/Controllers/UserManagement/BmUser/UserCouponsController.php
  92. 115 0
      app/Admin/Controllers/UserManagement/BmUser/UserListController.php
  93. 144 0
      app/Admin/Controllers/UserManagement/BmUser/UserOrdersController.php
  94. 107 0
      app/Admin/Controllers/UserManagement/BmUser/UserPatientsController.php
  95. 132 0
      app/Admin/Controllers/UserManagement/BmUser/UserServiceController.php
  96. 135 0
      app/Admin/Controllers/UserManagement/DocterManagement/AppointController.php
  97. 144 0
      app/Admin/Controllers/UserManagement/DocterManagement/ApproveController.php
  98. 128 0
      app/Admin/Controllers/UserManagement/DocterManagement/ChatController.php
  99. 86 0
      app/Admin/Controllers/UserManagement/DocterManagement/DocterLabelController.php
  100. 82 0
      app/Admin/Controllers/UserManagement/DocterManagement/DocterTeamController.php

+ 3 - 2
.gitignore

xqd xqd
@@ -2,8 +2,8 @@
 /public/hot
 /public/storage
 /storage/*.key
-#/vendor
-#.env
+/vendor
+.env
 .env.backup
 .phpunit.result.cache
 Homestead.json
@@ -11,3 +11,4 @@ Homestead.yaml
 npm-debug.log
 yarn-error.log
 .idea/
+.DS_Store

+ 16 - 0
app/Admin/Actions/Cdmuser.php

xqd
@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Admin\Actions;
+
+use Encore\Admin\Actions\Action;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Http\Request;
+
+class Cdmuser extends RowAction
+{
+    public $name = '创建账号';
+    public function href()
+    {
+        return '/admin/cdms_user/create?id='.$this->row->id;
+    }
+}

+ 25 - 0
app/Admin/Actions/Community.php

xqd
@@ -0,0 +1,25 @@
+<?php
+
+namespace App\Admin\Actions;
+
+use Encore\Admin\Actions\Action;
+use Illuminate\Http\Request;
+
+class Community extends Action
+{
+    protected $selector = '.community';
+
+    public function handle(Request $request)
+    {
+        // $request ...
+
+        return $this->response()->success('Success message...')->refresh();
+    }
+
+    public function html()
+    {
+        return <<<HTML
+        <a class="btn btn-sm btn-default community"></a>
+HTML;
+    }
+}

+ 22 - 0
app/Admin/Actions/Community/Docter/AddAccount.php

xqd
@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Admin\Actions\Community\Docter;
+
+use Encore\Admin\Actions\Action;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Http\Request;
+
+class AddAccount extends RowAction
+{
+    public $name = '添加账号';
+
+    public function href()
+    {
+        $organization_id = $this->row->organization_id;
+        $docter_id = $this->row->docter_id;
+        if($organization_id && $docter_id){
+            return  '/cdms/docter_account/create?org_id='.$organization_id.'&docter_id='.$docter_id;
+        }
+        return '';
+    }
+}

+ 15 - 0
app/Admin/Actions/Community/Docter/Chat.php

xqd
@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Admin\Actions\Community\Docter;
+
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Http\Request;
+
+class Chat extends RowAction
+{
+    public $name = '查看';
+    public function href()
+    {
+        return '/cdms/chats';
+    }
+}

+ 24 - 0
app/Admin/Actions/Community/Docter/EditAccount.php

xqd
@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Admin\Actions\Community\Docter;
+
+use App\Models\CdmsUsers;
+use Encore\Admin\Actions\Action;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Http\Request;
+
+class EditAccount extends RowAction
+{
+    public $name = '编辑账号';
+
+    public function href()
+    {
+        $docter_id = $this->row->docter_id;
+        $org_id = $this->row->organization_id;
+        $account = CdmsUsers::where(['org_id'=>$org_id,'docter_id'=>$docter_id])->first();
+        if($account){
+            return  '/cdms/docter_account/'.$account->id.'/edit';
+        }
+        return '';
+    }
+}

+ 32 - 0
app/Admin/Actions/Community/Docter/Failed.php

xqd
@@ -0,0 +1,32 @@
+<?php
+
+namespace App\Admin\Actions\Community\Docter;
+
+use App\Models\Docter;
+use App\Models\DocterOrganization;
+use Encore\Admin\Actions\Action;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+use Mockery\Exception;
+
+class Failed extends RowAction
+{
+    protected $selector = '.failed';
+
+    public $name = '驳回';
+    public function handle()
+    {
+        DB::beginTransaction();
+        try {
+            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){
+            DB::rollBack();
+            return $this->response()->error('操作失败');
+        }
+        return $this->response()->success('操作成功')->refresh();
+    }
+}

+ 56 - 0
app/Admin/Actions/Community/Docter/Pass.php

xqd
@@ -0,0 +1,56 @@
+<?php
+
+namespace App\Admin\Actions\Community\Docter;
+
+use App\Models\CdmsUsers;
+use App\Models\Docter;
+use App\Models\DocterOrganization;
+use Encore\Admin\Actions\RowAction;
+use Encore\Admin\Grid\Model;
+use Illuminate\Http\Request;
+
+class Pass extends RowAction
+{
+    public $name = '通过';
+
+    public function handle()
+    {
+        $id = $this->row->id;
+        $org_id = $this->row->organization_id;
+        $docter_id = $this->row->docter_id;
+        $name = $this->row->docter->name;
+        try{
+            $DocOrg = new DocterOrganization();
+            $DocOrg->where('id',$id)->update(['state'=>3]);
+//            $count = $DocOrg->where('state','!=',1)->where('docter_id',$docter_id)->count();
+//            if($count == 0){
+//                Docter::where(['id'=>$docter_id])->update(['is_then'=>1]);
+//                $user_name = $this->randomkeys(8);
+//                $data['username'] = $user_name;
+//                $data['name'] = $name;
+//                $data['password'] = bcrypt('123456');
+//                $data['org_id'] = $org_id;
+//                $data['docter_id'] = $docter_id;
+//                CdmsUsers::insert($data);
+//            }
+
+        } catch (\Exception $e){
+            return $this->response()->error('更新失败!');
+        }
+
+        return $this->response()->success('更新成功')->refresh();
+    }
+
+    function randomkeys($length)
+    {
+        $key = '';
+        $pattern = '1234567890abcdefghijklmnopqrstuvwxyz
+               ABCDEFGHIJKLOMNOPQRSTUVWXYZ';
+        for($i=0;$i<$length;$i++)
+        {
+            $key .= $pattern{mt_rand(0,35)};    //生成php随机数
+        }
+        return $key;
+    }
+
+}

+ 109 - 0
app/Admin/Actions/Community/Notice/sendNotice.php

xqd
@@ -0,0 +1,109 @@
+<?php
+
+namespace App\Admin\Actions\Community\Notice;
+
+use App\User;
+use EasyWeChat\Factory;
+use Encore\Admin\Actions\BatchAction;
+use Illuminate\Database\Eloquent\Collection;
+
+class sendNotice extends BatchAction
+{
+    public $name = '群发通知';
+
+    public function handle(Collection $collection)
+    {
+        foreach ($collection as $model) {
+            $openid = User::where('id',$model->id)->value('openid');
+            $content = request('content');
+            $remark= request('remark');
+//            $openid = 'oVxTzvgYlGktIDZXwfLMLQ01Tr5s'; 自己
+            if(empty($openid)) continue;
+            $this->send($openid,$content,$remark);
+        }
+
+        return $this->response()->success('发送成功')->refresh();
+    }
+
+    public function form()
+    {
+        $this->text('title','标题')->value('社区通知')->disable();
+        $this->textarea('content','内容')->rows(4);
+        $this->textarea('remark','备注')->rows(3);
+    }
+
+    public function send($open_id,$cotent, $remark)
+    {
+        if(empty($open_id)) return true;
+        $config = [
+                'app_id' => 'wx1c2357232cd25f65',
+                'secret' => 'c8cab53e4e52234ed1bc2abbdeaba57d',
+//            'app_id' => 'wx13bedfcc62e9bab0',
+//            'secret' => '175e5518b6426dd12d3096f24ca68fb8',
+                'response_type' => 'array'
+            ];
+        $app = Factory::officialAccount($config);
+        if(!isset($user['openid'])) return true;
+        $res = $app->template_message->send([
+            'touser' => $open_id,
+            'template_id' => 'GWIu1FBBA8SOdOwEbXRAmBL9LlYJP_H6EJUC7rv-YiQ',
+            'url' => 'https://t5.9026.com',
+//            'miniprogram' => [
+//                'appid' => 'wx6131f74e623bf6bf',
+//                'pagepath' => '/pages/index/index',
+//            ],
+            'data' => [
+                'first'=>'社区通知',
+                'cardNumber' => '测试服务服务包',
+                'type' => '门诊',
+                'address' => '华西医院',
+                'VIPPhone' => 18719141830,
+                'VIPName' => '测试服务包',
+                'expDate' => '2021年12月31号',
+                'remark' => '请咨询13912345678。',
+            ],
+        ]);
+        return true;
+    }
+
+
+    public function send2($user_ids,$number,$content){
+
+        if(!is_array($user_ids)) {
+            $user_ids = [$user_ids];
+        }
+
+
+        $app = app('wechat.official_account');
+
+        foreach($user_ids as $user_id) {
+
+            $user = (new User())->find($user_id);
+
+            if(empty($user) || empty($user['open_id'])) continue;
+
+            $official_open_id = $user->getOfficialOpenId($user['union_id']);
+
+            if(empty($official_open_id)) continue;
+
+            $result=$app->template_message->send([
+                'touser' => $official_open_id,
+                'template_id' => '4x80cGpV2boFdY7fm4QpsPBNo-FLytKjQGJKtZq_nr4',
+                'miniprogram' => [
+                    'appid' => env('WECHAT_MINI_PROGRAM_APPID'),
+                    'pagepath' => 'pages/index/index',
+                ],
+                'data' => [
+                    'first' => '作业许可状态改变',
+                    'keyword1' => $number,
+                    'keyword2' => $content,
+                    'keyword3' => $user->name,
+                    'remark' => '备注'
+                ],
+            ]);
+            var_dump($result);
+        }
+        return true;
+    }
+
+}

+ 22 - 0
app/Admin/Actions/Community/Nurse/DelNurse.php

xqd
@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Admin\Actions\Community\Nurse;
+
+use App\Models\Order;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class  DelNurse extends RowAction
+{
+    public $name = '删除';
+
+    public function handle(Model $model)
+    {
+        $id = $this->row->id;
+        $order_id = $this->row->order_id;
+        $model->where('id',$id)->delete();
+        Order::where('id',$order_id)->delete();
+        return $this->response()->success('Success message.')->refresh();
+    }
+
+}

+ 24 - 0
app/Admin/Actions/Community/Nurse/Finished.php

xqd
@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Admin\Actions\Community\Nurse;
+
+use App\Models\Order;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class Finished extends RowAction
+{
+    public $name = '完成';
+
+    public function handle(Model $model)
+    {
+        $id = $this->row->order_id;
+        $res = Order::where('id',$id)->update(['order_status'=>Order::FINISHED]);
+        if($res){
+            return $this->response()->success('操作成功!')->refresh();
+        }
+
+        return $this->response()->error('操作失败!');
+    }
+
+}

+ 29 - 0
app/Admin/Actions/Community/Nurse/Reserved.php

xqd
@@ -0,0 +1,29 @@
+<?php
+
+
+namespace App\Admin\Actions\Community\Nurse;
+
+
+use App\Models\Order;
+use App\Models\User;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class Reserved extends RowAction
+{
+    public $name = '已预约';
+
+    public function handle(Model $model)
+    {
+        $id = $this->row->orders->order_id;
+
+        $res = Order::where('id',$id)->update(['order_status'=>Order::ISING]);
+
+
+        if($res){
+            return $this->response()->success('操作成功!')->refresh();
+        }
+
+        return $this->response()->error('操作失败!');
+    }
+}

+ 19 - 0
app/Admin/Actions/Community/Order/Detail.php

xqd
@@ -0,0 +1,19 @@
+<?php
+
+
+namespace App\Admin\Actions\Community\Order;
+
+
+use App\Models\Order;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class Detail extends RowAction
+{
+
+    public $name = '详情';
+    public function href()
+    {
+       return '/cdms/order_detail?id='.$this->row->id;
+    }
+}

+ 24 - 0
app/Admin/Actions/Serve/Addmember.php

xqd
@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Admin\Actions\Serve;
+
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class Addmember extends RowAction
+{
+    public $name = '添加成员';
+
+//    public function form(){
+//       TeamDocter::insert();
+//      $this->multipleSelect('member', '成员选择')->options(function ($ids) {
+//           return Docter::where('is_then', 1)->pluck('name', 'id');
+//       });
+//    }
+    public function handle(Model $model)
+    {
+        // $request ...
+//        TeamDocter::insert();
+        return $this->response()->success('跳转成功成功')->redirect('/admin/team_docter?team_id='.$this->row->id.'');
+    }
+}

+ 19 - 0
app/Admin/Actions/Serve/member.php

xqd
@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Admin\Actions\Serve;
+
+use Encore\Admin\Actions\Action;
+use Illuminate\Http\Request;
+use App\Models\Docter;
+
+class member extends Action
+{
+//    protected $selector = '.member';
+
+    public function handle(Request $request)
+    {
+        // $request ...
+        $provinceId = $request->get('q');
+        return Docter::where('is_then', 1)->get(['id', DB::raw('name as text')]);
+    }
+}

+ 26 - 0
app/Admin/Actions/Service/ApplysAction.php

xqd
@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Admin\Actions\Service;
+
+use App\Models\Docter;
+use Encore\Admin\Actions\RowAction;
+use App\Models\Serviceapplys;
+use Illuminate\Database\Eloquent\Model;
+use PHPUnit\Util\Filter;
+
+class ApplysAction extends RowAction
+{
+    public $name = '通过';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+        Serviceapplys::where('id',$model->id)->update(['status'=>2]);
+        $filter = [1=>'is_chat',2=>'is_phone',3=>'is_appoint'];
+
+        Docter::where('id',$model->docter_id)->update([$filter[$model->service_type]=>1]);
+
+        return $this->response()->success('审核通过')->refresh();
+    }
+
+}

+ 20 - 0
app/Admin/Actions/Service/PassAction.php

xqd
@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Admin\Actions\Service;
+
+use App\Models\Serviceapplys;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class PassAction extends RowAction
+{
+    public $name = '开通';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+        Serviceapplys::where('id',$this->row->id)->update(['status'=>2]);
+        return $this->response()->success('开通成功')->refresh();
+    }
+
+}

+ 20 - 0
app/Admin/Actions/Service/RefuseAction.php

xqd
@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Admin\Actions\Service;
+
+use App\Models\Serviceapplys;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class RefuseAction extends RowAction
+{
+    public $name = '驳回';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+        Serviceapplys::where('id',$model->id)->update(['status'=>3]);
+        return $this->response()->success('驳回通过')->refresh();
+    }
+
+}

+ 21 - 0
app/Admin/Actions/Service/RevokeAction.php

xqd
@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Admin\Actions\Service;
+
+use App\Models\Serviceapplys;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class RevokeAction extends RowAction
+{
+    public $name = '撤销';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+//        dd($this->row->id);
+        Serviceapplys::where('id',$this->row->id)->update(['status'=>3]);
+        return $this->response()->success('撤销成功')->refresh();
+    }
+
+}

+ 26 - 0
app/Admin/Actions/UpdateCdms.php

xqd
@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Admin\Actions;
+
+use App\Models\Organization;
+use Encore\Admin\Actions\RowAction;
+
+class UpdateCdms extends RowAction
+{
+   public $name = '修改账号';
+
+    public function href()
+    {
+        $id = $this->row->id;
+        $cmds_id = Organization::where(['id'=>$id])->value('cdms_id');
+        if(empty($cmds_id)){
+            return '/admin/organizations';
+        }
+        return "/admin/cdms_user/".$cmds_id."/edit";
+    }
+
+    public function form()
+    {
+        $this->display('')->image();
+    }
+}

+ 112 - 0
app/Admin/Actions/Vaccines/ImportAction.php

xqd
@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Admin\Actions\Vaccines;
+
+use Encore\Admin\Actions\Action;
+use Illuminate\Http\Request;
+use App\Imports\Vaccines\ImportMember;
+use Encore\Admin\Admin;
+use Maatwebsite\Excel\Facades\Excel;
+
+class ImportAction extends Action
+{
+    protected $selector = '.import-action';
+
+    public function handle(Request $request)
+    {
+        try{
+            // $request ...
+            $file = $request-> file('file');
+
+            Excel::import(new ImportMember(),$file);
+
+            return $this->response()->success('数据导入成功')->refresh();
+        }catch (\Exception $e){
+            return $this->response()->error($e -> getMessage());
+        }
+    }
+
+    public function html()
+    {
+        return <<<HTML
+        <a class="btn btn-sm btn-default import-action">导入</a>
+HTML;
+    }
+
+
+    //表单
+    public function form()
+    {
+        $this
+            ->file('file', '请选择文件')
+            ->options(['showPreview' => false,
+                'allowedFileExtensions'=>['xlsx','xls','csv'],
+                'showUpload'=>true
+            ]);
+    }
+
+    //上传等待
+    public function handleActionPromise()
+    {
+        $resolve = <<<SCRIPT
+var actionResolverss = function (data) {
+            $('.modal-footer').show()
+            $('.tips').remove()
+            var response = data[0];
+            var target   = data[1];
+
+            if (typeof response !== 'object') {
+                return $.admin.swal({type: 'error', title: 'Oops!'});
+            }
+
+            var then = function (then) {
+                if (then.action == 'refresh') {
+                    $.admin.reload();
+                }
+
+                if (then.action == 'download') {
+                    window.open(then.value, '_blank');
+                }
+
+                if (then.action == 'redirect') {
+                    $.admin.redirect(then.value);
+                }
+            };
+
+            if (typeof response.html === 'string') {
+                target.html(response.html);
+            }
+
+            if (typeof response.swal === 'object') {
+                $.admin.swal(response.swal);
+            }
+
+            if (typeof response.toastr === 'object') {
+                $.admin.toastr[response.toastr.type](response.toastr.content, '', response.toastr.options);
+            }
+
+            if (response.then) {
+              then(response.then);
+            }
+        };
+
+        var actionCatcherss = function (request) {
+            $('.modal-footer').show()
+            $('.tips').remove()
+
+            if (request && typeof request.responseJSON === 'object') {
+                $.admin.toastr.error(request.responseJSON.message, '', {positionClass:"toast-bottom-center", timeOut: 10000}).css("width","500px")
+            }
+        };
+SCRIPT;
+
+        Admin::script($resolve);
+
+        return <<<SCRIPT
+         $('.modal-footer').hide()
+         let html = `<div class='tips' style='color: #ff3249;font-size: 18px;'>导入时间取决于数据量,请耐心等待结果不要关闭窗口!<img src="data:image/gif;base64,R0lGODlhEAAQAPQAAP///1VVVfr6+np6eqysrFhYWG5ubuPj48TExGNjY6Ojo5iYmOzs7Lq6utjY2ISEhI6OjgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAAFUCAgjmRpnqUwFGwhKoRgqq2YFMaRGjWA8AbZiIBbjQQ8AmmFUJEQhQGJhaKOrCksgEla+KIkYvC6SJKQOISoNSYdeIk1ayA8ExTyeR3F749CACH5BAkKAAAALAAAAAAQABAAAAVoICCKR9KMaCoaxeCoqEAkRX3AwMHWxQIIjJSAZWgUEgzBwCBAEQpMwIDwY1FHgwJCtOW2UDWYIDyqNVVkUbYr6CK+o2eUMKgWrqKhj0FrEM8jQQALPFA3MAc8CQSAMA5ZBjgqDQmHIyEAIfkECQoAAAAsAAAAABAAEAAABWAgII4j85Ao2hRIKgrEUBQJLaSHMe8zgQo6Q8sxS7RIhILhBkgumCTZsXkACBC+0cwF2GoLLoFXREDcDlkAojBICRaFLDCOQtQKjmsQSubtDFU/NXcDBHwkaw1cKQ8MiyEAIfkECQoAAAAsAAAAABAAEAAABVIgII5kaZ6AIJQCMRTFQKiDQx4GrBfGa4uCnAEhQuRgPwCBtwK+kCNFgjh6QlFYgGO7baJ2CxIioSDpwqNggWCGDVVGphly3BkOpXDrKfNm/4AhACH5BAkKAAAALAAAAAAQABAAAAVgICCOZGmeqEAMRTEQwskYbV0Yx7kYSIzQhtgoBxCKBDQCIOcoLBimRiFhSABYU5gIgW01pLUBYkRItAYAqrlhYiwKjiWAcDMWY8QjsCf4DewiBzQ2N1AmKlgvgCiMjSQhACH5BAkKAAAALAAAAAAQABAAAAVfICCOZGmeqEgUxUAIpkA0AMKyxkEiSZEIsJqhYAg+boUFSTAkiBiNHks3sg1ILAfBiS10gyqCg0UaFBCkwy3RYKiIYMAC+RAxiQgYsJdAjw5DN2gILzEEZgVcKYuMJiEAOwAAAAAAAAAAAA=="><\/div>`
+         $('.modal-header').append(html)
+process.then(actionResolverss).catch(actionCatcherss);
+SCRIPT;
+    }
+}

+ 114 - 0
app/Admin/Actions/backstage/Coupon/AllCouponBatchGrant.php

xqd
@@ -0,0 +1,114 @@
+<?php
+
+namespace App\Admin\Actions\backstage\Coupon;
+
+use App\Models\Coupon;
+use App\Models\CouponType;
+use App\Models\UserCoupon;
+use Encore\Admin\Actions\BatchAction;
+use Illuminate\Database\Eloquent\Collection;
+
+class AllCouponBatchGrant extends BatchAction
+{
+    public $name = '后台所有优惠券批量发放';
+
+    public function handle(Collection $collection)
+    {
+        //计算总共要发放多少个用户
+        $user_arr = $collection->toArray();
+        $user_num = count($user_arr);
+        //获取所有类型为后台发放的优惠券
+        $allcoupon = Coupon::where('position_type',2)->get();
+        $coupon_arr = $allcoupon->toArray();
+        //判断优惠券数量是否充足
+        foreach ($coupon_arr as $value)
+        {
+            if ($value['num'] < $user_num)
+            {
+                return $this->response()->error('优惠券'.$value['name'].'的数量不足')->refresh();
+            }
+        }
+
+        foreach ($coupon_arr as $coupon)
+        {
+            //拿到基础数据
+            //获取过期类型是指定几天过期
+            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)
+            //获取类型数组
+            {
+                $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)
+                {
+                    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]);
+            }
+        }
+        return $this->response()->success('优惠券发放成功')->refresh();
+
+    }
+
+}

+ 105 - 0
app/Admin/Actions/backstage/Coupon/CouponBatchGrant.php

xqd
@@ -0,0 +1,105 @@
+<?php
+
+namespace App\Admin\Actions\backstage\Coupon;
+
+use App\Models\Coupon;
+use App\Models\CouponType;
+use App\Models\User;
+use App\Models\UserCoupon;
+use Encore\Admin\Actions\BatchAction;
+use Illuminate\Database\Eloquent\Collection;
+use Illuminate\Http\Request;
+
+class CouponBatchGrant extends BatchAction
+{
+    public $name = '优惠券批量发放';
+    public function handle(Collection $collection,Request $request)
+    {
+        $coupon_id = request('id');
+        $user_arr = $collection->toArray();
+        $user_num = count($user_arr);
+        $coupon = Coupon::where('id',$coupon_id)->first();
+        if ($coupon->num < $user_num)
+        {
+            return $this->response()->error('优惠券数量不足')->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)
+        {
+            //拿到类型数组
+            $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)
+            {
+                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]);
+        }
+        return $this->response()->success('优惠券发放成功')->refresh();
+    }
+
+    public function form()
+    {
+        $name = Coupon::where('position_type',2)->pluck('name','id');
+        $this->select('id', '优惠券名称')->options($name);
+    }
+}

+ 19 - 0
app/Admin/Actions/backstage/Coupon/CouponDetails.php

xqd
@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Admin\Actions\backstage\Coupon;
+
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class CouponDetails extends RowAction
+{
+    public $name = '优惠券详情';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+
+        return $this->response()->success('跳转订单详情成功')->redirect('/admin/coupons_details?id='.$this->row->id.'');
+    }
+
+}

+ 23 - 0
app/Admin/Actions/backstage/Coupon/CouponDistributions.php

xqd
@@ -0,0 +1,23 @@
+<?php
+
+namespace App\Admin\Actions\backstage\Coupon;
+
+use Encore\Admin\Actions\Action;
+use Illuminate\Http\Request;
+
+class CouponDistributions extends Action
+{
+    protected $selector = '.coupon-distributions';
+    public function handle(Request $request)
+    {
+        // $request ...
+
+        return $this->response()->success('跳转优惠券发放列表成功')->redirect('/admin/coupon_distribution_user_list');
+    }
+    public function html()
+    {
+        return <<<HTML
+        <a class="btn btn-sm btn-default coupon-distributions">优惠券发放</a>
+HTML;
+    }
+}

+ 19 - 0
app/Admin/Actions/backstage/Docters/AppointAction.php

xqd
@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Admin\Actions\backstage\Docters;
+
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class AppointAction extends RowAction
+{
+    public $name = '门诊预约配置';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+
+        return $this->response()->success('跳转门诊预约配置成功')->redirect('/admin/docter_appoint?docter_id='.$this->row->id.'');
+    }
+
+}

+ 19 - 0
app/Admin/Actions/backstage/Docters/ChatAction.php

xqd
@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Admin\Actions\backstage\Docters;
+
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class ChatAction extends RowAction
+{
+    public $name = '图文服务配置';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+
+        return $this->response()->success('跳转图文服务配置成功')->redirect('/admin/docter_chat?docter_id='.$this->row->id.'');
+    }
+
+}

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

xqd
@@ -0,0 +1,50 @@
+<?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');
+        if ($label_name == null)
+        {
+            $label_name = [];
+        }
+        $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();
+        }
+
+    }
+    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::where('status','1')->get()->pluck('label_name','id'))
+            ->value($result);
+    }
+}

+ 19 - 0
app/Admin/Actions/backstage/Docters/PhoneAction.php

xqd
@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Admin\Actions\backstage\Docters;
+
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class PhoneAction extends RowAction
+{
+    public $name = '电话服务配置';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+
+        return $this->response()->success('跳转电话服务配置成功')->redirect('/admin/docter_phone?docter_id='.$this->row->id.'');
+    }
+
+}

+ 18 - 0
app/Admin/Actions/backstage/Docters/ServiceManagement.php

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

+ 18 - 0
app/Admin/Actions/backstage/Docters/SignUp.php

xqd
@@ -0,0 +1,18 @@
+<?php
+
+namespace App\Admin\Actions\backstage\Docters;
+
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class SignUp extends RowAction
+{
+    public $name = '签约管理';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+        return $this->response()->success('跳转签约管理成功')->redirect('/admin/sign_up?docter_id='.$this->row->id.'');
+    }
+
+}

+ 19 - 0
app/Admin/Actions/backstage/Docters/Team.php

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

+ 20 - 0
app/Admin/Actions/backstage/Evaluate/Ignore.php

xqd
@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Admin\Actions\backstage\Evaluate;
+
+use App\Models\Evaluate;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class Ignore extends RowAction
+{
+    public $name = '忽略';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+        Evaluate::where('id',$model->id)->update(['status'=>3,'audit_time'=>time()]);
+        return $this->response()->success('忽略成功')->refresh();
+    }
+
+}

+ 20 - 0
app/Admin/Actions/backstage/Evaluate/Pass.php

xqd
@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Admin\Actions\backstage\Evaluate;
+
+use App\Models\Evaluate;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class Pass extends RowAction
+{
+    public $name = '审核通过';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+        Evaluate::where('id',$model->id)->update(['status'=>2,'audit_time'=>time()]);
+        return $this->response()->success('审核通过.')->refresh();
+    }
+
+}

+ 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.'');
+    }
+
+}

+ 20 - 0
app/Admin/Actions/backstage/Orders/OrderDetails.php

xqd
@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Admin\Actions\backstage\Orders;
+
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class OrderDetails extends RowAction
+{
+    public $name = '订单详情';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+
+        return $this->response()->success('跳转订单详情成功')->redirect('/admin/orders_details?id='.$this->row->id.'');
+
+    }
+
+}

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

xqd
@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Admin\Actions\backstage\Orders;
+
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class PdfAction extends RowAction
+{
+    public $name = '查看保单';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+
+        return $this->response()->success('查看保单成功')->refresh();
+    }
+
+}

+ 17 - 0
app/Admin/Actions/backstage/Orders/ServicePack.php

xqd
@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Admin\Actions\backstage\Orders;
+
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class ServicePack extends RowAction
+{
+    public $name = '服务包详情';
+
+    public function handle(Model $model)
+    {
+        return $this->response()->success('跳转服务包详情成功')->redirect('/admin/service_packs_datails?order_id='.$this->row->id.'');
+    }
+
+}

+ 23 - 0
app/Admin/Actions/backstage/Orders/ServicePackOrderList.php

xqd
@@ -0,0 +1,23 @@
+<?php
+
+namespace App\Admin\Actions\backstage\Orders;
+
+use App\Models\OrderPack;
+use App\Models\OrderPatient;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class ServicePackOrderList extends RowAction
+{
+    public $name = '服务包订单列表';
+
+    public function handle(Model $model)
+    {
+        $patient_id_arr = OrderPatient::where('order_id',$this->row->id)->pluck('patient_id');
+        $patient_id = $patient_id_arr[0];
+        $pack_id_arr = OrderPack::where('order_id',$this->row->id)->pluck('service_pack_id');
+        $pack_id = $pack_id_arr[0];
+        return $this->response()->success('跳转服务包订单列表成功')->redirect('/admin/service_packs_order_list?patient_id='.$patient_id.'&pay_order_pack_id='.$pack_id.'');
+    }
+
+}

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

xqd
@@ -0,0 +1,43 @@
+<?php
+
+namespace App\Admin\Actions\backstage;
+
+use App\Models\Docter;
+use App\Models\DocterOrganization;
+use App\Models\Serviceapplys;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class Pass extends RowAction
+{
+    public $name = '通过';
+
+    public function handle(Model $model)
+    {
+//         $model ...
+//        dd($model);
+        $end_time = strtotime('+1year');
+        $authentication_end_time = date('Y-m-d H:i:s',$end_time);
+        DocterOrganization::where('id',$model->id)->update(['state'=>1,
+                                                            'authentication_time'=>date('Y-m-d H:i:s'),
+                                                            'authentication_end_time'=>$authentication_end_time]
+                                                            );
+        Docter::where('id',$model->docter_id)->update(['is_then'=>1,'office_id'=>$model->offices_id,'qualification_id'=>$model->qualifications_id]);
+        //生成默认的图文、电话、门诊的记录
+        $service_type_arr = [1,2,3];
+        foreach ($service_type_arr as $value)
+        {
+            $total_arr = [
+                'docter_id' => $model->docter_id,
+                'service_type' => $value,
+                'status' => 3,
+                'created_at' =>date('Y-m-d H;i;s'),
+                'updated_at' =>date('Y-m-d H;i;s'),
+            ];
+//            dd($total_arr);
+            Serviceapplys::insert($total_arr);
+        }
+        return $this->response()->success('审核通过')->refresh();
+    }
+
+}

+ 20 - 0
app/Admin/Actions/backstage/Refuse.php

xqd
@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Admin\Actions\backstage;
+use App\Models\DocterOrganization;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class Refuse extends RowAction
+{
+    public $name = '驳回';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+        DocterOrganization::where('id',$model->id)->update(['state'=>2,'authentication_time'=>0,'authentication_end_time'=>0]);
+
+        return $this->response()->success('审核驳回')->refresh();
+    }
+
+}

+ 41 - 0
app/Admin/Actions/backstage/Revoke.php

xqd
@@ -0,0 +1,41 @@
+<?php
+
+namespace App\Admin\Actions\backstage;
+use App\Models\Docter;
+use App\Models\DocterOrganization;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class Revoke extends RowAction
+{
+    public $name = '撤销';
+
+    public function handle(Model $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 > 1)
+        {
+            //撤销到社区端
+            DocterOrganization::where('id',$model->id)->update(['state'=>0,'authentication_time'=>'','authentication_end_time'=>0]);
+        }
+        if ($is_pass_num ==1)
+        {
+            DocterOrganization::where('id',$model->id)->update(['state'=>0,'authentication_time'=>0,'authentication_end_time'=>0]);
+            Docter::where('id',$model->docter_id)->update(['is_then'=>0]);
+        }
+        return $this->response()->success('审核撤销成功')->refresh();
+    }
+
+}

+ 18 - 0
app/Admin/Actions/backstage/User/BalanceLog.php

xqd
@@ -0,0 +1,18 @@
+<?php
+
+namespace App\Admin\Actions\backstage\User;
+
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class BalanceLog extends RowAction
+{
+    public $name = '余额明细';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+        return $this->response()->success('跳转余额成功')->redirect('/admin/user_balance_logs?user_id='.$this->row->id.'');
+    }
+
+}

+ 20 - 0
app/Admin/Actions/backstage/User/BlackList.php

xqd
@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Admin\Actions\backstage\User;
+
+use App\Models\User;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class BlackList extends RowAction
+{
+    public $name = '拉黑';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+        User::where('id',$model->id)->update(['status'=>0]);
+        return $this->response()->success('拉黑成功.')->refresh();
+    }
+
+}

+ 28 - 0
app/Admin/Actions/backstage/User/Insurance.php

xqd
@@ -0,0 +1,28 @@
+<?php
+
+namespace App\Admin\Actions\backstage\User;
+
+use App\Models\Order;
+use App\Models\OrderPack;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class Insurance extends RowAction
+{
+    public $name = '保险单链接';
+
+//    public function handle(Model $model)
+//    {
+//        // $model ...
+//
+//        return $this->response()->success('Success message.')->refresh();
+//    }
+    public function form(Model $model)
+    {
+//        dd($model);
+//        $order_id = Order::where('patient_id',$model->id)->where('product_type','6')->value('id');
+        $val = OrderPack::where('order_id',$model->id)->value('insurance_img_url');
+        $this->image('name')->value($val);
+    }
+
+}

+ 37 - 0
app/Admin/Actions/backstage/User/MapDepot.php

xqd
@@ -0,0 +1,37 @@
+<?php
+
+namespace App\Admin\Actions\backstage\User;
+
+use App\Models\OrderPatient;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class MapDepot extends RowAction
+{
+    public $name = '病例图库';
+
+    public function form(Model $model)
+    {
+        $imgs = OrderPatient::where('patient_id',$model->patient_id)->get('medical_imgs');
+        $all = json_decode($imgs,true);
+        $i =1;
+        $all1 =  array_column($all,'medical_imgs');
+//        dd($all1);
+        foreach ($all1 as $val)
+        {
+//            dd($val);
+            if (is_array($val) || is_object($val))
+            {
+                foreach ($val as $value1){
+//                dd($value1);
+                    $this->image('name'.$i)->value($value1);
+                    $i++;
+//                echo $value1."<br>";
+                }
+            }
+
+//            dd($value1);
+        }
+    }
+
+}

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

xqd
@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Admin\Actions\backstage\User;
+
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class Orders extends RowAction
+{
+    public $name = '订单数据总览';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+
+        return $this->response()->success('跳转用户订单列表成功')->redirect('/admin/user_orders?user_id='.$this->row->id.'');
+    }
+
+}

+ 19 - 0
app/Admin/Actions/backstage/User/Suggests.php

xqd
@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Admin\Actions\backstage\User;
+
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class Suggests extends RowAction
+{
+    public $name = '病例意见单';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+//        dd($model);
+        return $this->response()->success('跳转病例意见单成功')->redirect('/admin/user_suggests?order_id='.$this->row->id.'');
+    }
+
+}

+ 19 - 0
app/Admin/Actions/backstage/User/archives.php

xqd
@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Admin\Actions\backstage\User;
+
+use App\Models\Patient;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class archives extends RowAction
+{
+    public $name = '查看患者档案';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+        return $this->response()->success('跳转档案库成功')->redirect('/admin/user_patients?user_id='.$this->row->id.'');
+    }
+
+}

+ 19 - 0
app/Admin/Actions/backstage/User/coupons.php

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

+ 19 - 0
app/Admin/Actions/backstage/User/service.php

xqd
@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Admin\Actions\backstage\User;
+
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class service extends RowAction
+{
+    public $name = '服务包管理';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+        return $this->response()->success('跳转服务包库成功')->redirect('/admin/user_order?user_id='.$this->row->id.'&product_type=6');
+
+    }
+
+}

+ 25 - 0
app/Admin/Actions/finished.php

xqd
@@ -0,0 +1,25 @@
+<?php
+
+namespace App\Admin\Actions;
+
+use Encore\Admin\Actions\Action;
+use Illuminate\Http\Request;
+
+class finished extends Action
+{
+    protected $selector = '.finished';
+
+    public function handle(Request $request)
+    {
+        // $request ...
+
+        return $this->response()->success('Success message...')->refresh();
+    }
+
+    public function html()
+    {
+        return <<<HTML
+        <a class="btn btn-sm btn-default finished"></a>
+HTML;
+    }
+}

+ 26 - 0
app/Admin/Controllers/Api/ApiController.php

xqd
@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Admin\Controllers\Api;
+
+use Encore\Admin\Controllers\AdminController;
+
+class ApiController extends AdminController
+{
+    /**
+     * 后台上传图片
+     * @return string
+     */
+
+    public function upload()
+    {
+        $url = "error|服务器端错误";
+
+        foreach (request()->file() as $file) {
+            $url = "upload/images/".uniqid().rand(9000,100000).'.'.$file->getClientOriginalExtension();
+            file_put_contents($url,file_get_contents($file->getRealPath()));
+        }
+
+        return env('APP_URL').'/'.$url;
+    }
+
+}

+ 24 - 0
app/Admin/Controllers/ApiController.php

xqd
@@ -0,0 +1,24 @@
+<?php
+
+
+namespace App\Admin\Controllers;
+
+
+use App\Http\Controllers\Controller;
+use App\Models\Area;
+
+class ApiController extends Controller
+{
+
+    public function getCity()
+    {
+        $id  = request('q');
+        return Area::where(['level'=>2,'parent_id'=>intval($id)])->get(['name as text','id']);
+    }
+
+    public function getArea()
+    {
+        $id  = request('q');
+        return Area::where(['level'=>3,'parent_id'=>intval($id)])->get(['name as text','id']);
+    }
+}

+ 88 - 0
app/Admin/Controllers/ArticleManagement/ArticleController.php

xqd
@@ -0,0 +1,88 @@
+<?php
+
+namespace App\Admin\Controllers\ArticleManagement;
+
+use App\Models\Article;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class ArticleController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '文章列表';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Article());
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id', __('Id'));
+        $grid->column('type', __('分类'))->using([1=>'健康科普',2=>'疫苗科普',3=>'常见问题']);
+        $grid->column('title', __('标题'))->limit(10,'...')->width(100);
+        $grid->column('content', __('内容'))->limit(20,'...')->width(200);
+        $grid->column('banner_url', __('图片'))->lightbox(['width' =>'', 'height' => 30]);
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+        $grid->filter(function($filter){
+
+            // Remove the default id filter
+            $filter->disableIdFilter();
+
+            // Add a column filter
+            $type = [''=>'全部'];
+            $type = array_merge($type,Article::$_post_type);
+            $filter->equal('type', '类别')->select(Article::$_post_type);
+
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Article::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('type', __('分类'));
+        $show->field('title', __('标题'));
+        $show->field('content', __('内容'));
+        $show->field('banner_url', __('图片'))->image('',100,100);
+        $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 Article());
+
+        $form->select('type', __('分类'))->options(Article::$_post_type)->default('1');
+        $form->text('title', __('标题'))->rules('required|min:3|max:255',['required'=>'请填写标题','min'=>'标题字符不能少于3个','max'=>'标题长度过长']);
+        $form->editor('content', __('内容'))->rules('required|min:3',['required'=>'请填写标题','min'=>'标题字符不能少于3个']);
+        $form->image('banner_url', __('图片'))->rules('required' ,['required'=>'请选择图片!']);
+
+        return $form;
+    }
+}

+ 1 - 1
app/Admin/Controllers/AuthController.php

xqd
@@ -2,7 +2,7 @@
 
 namespace App\Admin\Controllers;
 
-use Encore\Admin\Http\Controllers\AuthController as BaseAuthController;
+use Encore\Admin\Controllers\AuthController as BaseAuthController;
 
 class AuthController extends BaseAuthController
 {

+ 70 - 0
app/Admin/Controllers/CdmsController.php

xqd
@@ -0,0 +1,70 @@
+<?php
+
+
+namespace App\Admin\Controllers;
+
+
+use App\Models\Organization;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+
+class CdmsController extends AdminController
+{
+
+    protected $title = '机构账号';
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    public function form()
+    {
+        $userModel = config('tenancy.database.users_model');
+        $permissionModel = config('tenancy.database.permissions_model');
+        $roleModel = config('tenancy.database.roles_model');
+
+        $id = request('id');
+
+        $form = new Form(new $userModel());
+
+        $userTable = config('tenancy.database.users_table');
+        $connection = config('tenancy.database.connection');
+
+        $form->display('id', 'ID');
+        $form->text('username', trans('tenancy.login_account'))
+            ->creationRules(['required', "unique:{$connection}.{$userTable}"])
+            ->updateRules(['required', "unique:{$connection}.{$userTable},username,{{id}}"]);
+
+        $form->text('name', trans('tenancy.name'))->rules('required');
+        $form->image('avatar', trans('tenancy.avatar'));
+        $form->password('password', trans('tenancy.password'))->rules('required|confirmed');
+        $form->password('password_confirmation', trans('tenancy.password_confirmation'))->rules('required')
+            ->default(function ($form) {
+                return $form->model()->password;
+            });
+
+        $form->ignore(['password_confirmation']);
+
+        $form->hidden('org_id')->value(request('id'));
+        $form->multipleSelect('roles', trans('tenancy.roles'))->options($roleModel::all()->pluck('name', 'id'));
+        $form->multipleSelect('permissions', trans('tenancy.permissions'))->options($permissionModel::all()->pluck('name', 'id'));
+
+        $form->display('created_at', trans('tenancy.created_at'));
+        $form->display('updated_at', trans('tenancy.updated_at'));
+
+        $form->saving(function (Form $form) use ($id){
+            if ($form->password && $form->model()->password != $form->password) {
+                $form->password = bcrypt($form->password);
+            }
+        });
+
+        $form->saved(function (Form $form) use ($id) {
+            $org_id = $form->model()->org_id;
+            \Log::info($form->model()->id.'--------id-----'.'组织id'.$org_id);
+            Organization::where(['id'=>$org_id])->update(['cdms_id'=>$form->model()->id]);
+           return redirect('/admin/organizations');
+        });
+
+        return $form;
+    }
+}

+ 81 - 0
app/Admin/Controllers/CommunityNotice/CommunityNotices.php

xqd
@@ -0,0 +1,81 @@
+<?php
+
+namespace App\Admin\Controllers\CommunityNotice;
+
+use App\Models\CommunityNotice;
+use App\Models\Organization;
+use Encore\Admin\Auth\Database\Administrator;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class CommunityNotices extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '社区端通告';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new CommunityNotice());
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id', __('Id'))->sortable();
+        $grid->column('organization.name', __('发放社区'));
+        $grid->column('title', __('标题'));
+        $grid->column('type', __('类型'))->using([1=>'社区通告']);
+        $grid->column('content', __('内容'))->limit(100,'...');
+        $grid->column('admin_id', __('发布人'))->display(function ($id){
+            return Administrator::where('id',$id)->value('username');
+        });
+        $grid->column('updated_at', __('更新时间'));
+        $grid->column('created_at', __('创建时间'));
+
+
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(CommunityNotice::findOrFail($id));
+
+
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new CommunityNotice());
+        $form->text('title', __('标题'));
+        $form->select('organization_id', __('发放的社区'))->options(Organization::all()->pluck('name','id'));
+        $form->select('type', __('类型'))->options([1=>'社区端通告']);
+        $form->editor('content', __('内容'));
+        $form->submitted(function ($form){
+            $form->model()->admin_id = Admin::user()->id;
+        });
+
+        return $form;
+    }
+}

+ 118 - 0
app/Admin/Controllers/Config/ConfigController.php

xqd
@@ -0,0 +1,118 @@
+<?php
+
+namespace App\Admin\Controllers\Config;
+
+use App\Base_Area;
+use App\Models\SystemConfig;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+/**
+ * @author pxwei
+ * Class ConfigController
+ * @package App\Admin\Controllers\City
+ */
+class ConfigController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '配置管理';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new SystemConfig);
+
+        $grid->disableCreateButton(false);
+        $grid->column('id', __('ID'))->sortable();
+        $grid->column('group', __('分组'))->editable();
+        $grid->column('key', __('键'))->editable();
+        $grid->column('value', __('值'))->display(function (){
+            if (strlen($this->value)>30){
+                return mb_substr($this->value,0,20).'...';
+            }
+            return $this->value;
+        })->modal('值',function (){
+            return $this->value;
+        })->copyable();
+
+        $grid->column('chinese', __('中文名'))->editable();
+        $grid->column('fieldType', __('类型'))->editable('select',SystemConfig::getType());
+        $grid->column('comment', __('说明'))->editable();
+        $grid->column('sort', __('排序'))->editable()->sortable();
+        $grid->column('updated_at', __('更新时间'))->sortable();
+
+        $grid->filter(function (Grid\Filter $filter){
+            $filter->disableIdFilter();
+            $filter->column(1/2, function ($filter) {
+                $filter->like('group','分组');
+                $filter->like('key','键');
+
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->like('value','值');
+
+            });
+
+
+
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed   $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(SystemConfig::findOrFail($id));
+
+        $show->field('id', __('ID'));
+        $show->field('group', __('分组'));
+        $show->field('key', __('key'));
+        $show->field('value', __('value'));
+        $show->field('fieldType', __('类型'))->using(SystemConfig::getType());
+        $show->field('chinese', __('标签名称'));
+        $show->field('comment', __('说明'));
+        $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 SystemConfig);
+        $form->display('id', __('ID'));
+        $form->text('group', __('group/分组'));
+//        $form->select('group', __('group/分组'))->options(SystemConfig::getGroup());
+        $form->text('key', __('key/键'));
+        $form->text('chinese', __('Label/标签名词'))->help('中文标签名词,方便用户查看');
+        $form->number('sort', __('Sort/排序'))->help('排序,越大越前')->default(0);
+        $form->select('fieldType', __('Type/字段类型'))->options(SystemConfig::getType());
+        $form->text('comment', __('comment/配置描述'));
+        $form->textarea('value', __('value/内容'));
+        $form->display('created_at', __('Created At'));
+        $form->display('updated_at', __('Updated At'));
+
+        return $form;
+    }
+}

+ 307 - 0
app/Admin/Controllers/Config/FormController.php

xqd
@@ -0,0 +1,307 @@
+<?php
+
+namespace App\Admin\Controllers\Config;
+
+use App\Model\BaseArea;
+use App\Model\Communities;
+use App\Models\SystemConfig;
+use App\Http\Controllers\Controller;
+use Encore\Admin\Form\Tab;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Widgets\Form;
+use Encore\Admin\Widgets\Table;
+
+/**
+ * @author pxwei
+ * Class ConfigController
+ * @package App\Admin\Controllers\Form
+ */
+class FormController extends Controller
+{
+    public function form()
+    {
+        $dbs = SystemConfig::orderby('sort','desc')->orderby('created_at','asc')->get(['id','group','key','value','comment','chinese','fieldType'])->toArray();
+
+        $configs = [];
+
+        foreach ($dbs as $db){
+            $configs[$db['group']][] = $db;
+        }
+        $tab = new \Encore\Admin\Widgets\Tab();
+
+
+        foreach ($configs as $k => $config){
+            $form = new Form();
+            $form->action("/admin/setting_form_save");
+
+            foreach ($config as $value){
+                switch ($value['fieldType']){
+                    case SystemConfig::Field_textarea:
+                        $form->textarea($value['group'].'____'.$value['key'],$value['chinese'])->help($value['comment'])->rows(1)->default($value['value']);
+                        break;
+                    case  SystemConfig::Filed_richText:
+                        $form->editor($value['group'].'____'.$value['key'],$value['chinese'])->default($value['value']);
+                        break;
+                    case  SystemConfig::Field_Time:
+                        $form->time($value['group'].'____'.$value['key'],$value['chinese'])->default($value['value'])->format('HH:mm');
+                        break;
+                    case  SystemConfig::Field_File:
+                        $form->file($value['group'].'____'.$value['key'],$value['chinese'])->help('当前文件:'.$value['value']);
+                        break;
+                    case  SystemConfig::Field_Switch:
+
+
+                            $states = [
+                                'on'  => ['value' => 1, 'text' => '开', 'color' => 'success'],
+                                'off' => ['value' => 0, 'text' => '关', 'color' => 'danger'],
+
+                            ];
+                            $s = $value['value'];
+
+                        if ($value['key']=='use_personal')
+                        {
+                            $s = $s==0?1:0;
+                        }
+
+
+                        $form->switch($value['group'].'____'.$value['key'].'____Switch',$value['chinese'])->help($value['comment'])->default($s)->states($states);
+                        break;
+                    case  SystemConfig::Field_Checkbox:
+                        $data = [];
+                        $default = [];
+                        foreach (json_decode($value['value'],true) as $v){
+                            $data[$v['key']] =$v['text'];
+                            if ($v['value'] == 1)
+                                $default[] = $v['key'];
+
+                        }
+
+                        $form->checkbox($value['group'].'____'.$value['key'].'____checkbox',$value['chinese'])->options($data)->default($default)->help($value['comment'])->canCheckAll();
+                        break;
+                    case SystemConfig::Field_Json:
+                        $json = json_decode($value['value'],true);
+                        if (!$json)
+                            $form->display('json',$value['chinese'])->default('字段JSON解析失败');
+                        else{
+                            $form->fieldset($value['chinese'].'_配置组', function (Form $form)use ($json,$value) {
+                                foreach ($json as $kk=> $v){
+                                    $form->text($value['group'].'____'.$value['key'].'____J____'.$kk,$kk)->default($v);
+                                }
+                            });
+                        }
+                        break;
+
+                    case SystemConfig::Field_Json_Array:
+                        $json = json_decode($value['value'],true);
+                        if (!$json)
+                            $form->display('json',$value['chinese'])->default('数组JSON解析失败');
+                        else{
+                            $form->fieldset($value['chinese'].'_配置组', function (Form $form)use ($json,$value) {
+                                foreach ($json as $kk=> $v){
+                                    $form->text($value['group'].'____'.$value['key'].'____JA____'.$kk,$v['text'])->default($v['value']);
+                                }
+                            });
+                        }
+                        break;
+                    case SystemConfig::Field_Image:
+                        $form->image($value['group'].'____'.$value['key'],$value['chinese'])->default($value['value']);
+
+                }
+            }
+
+            $tab->add(SystemConfig::$groups[$k]??$k,$form->render());
+            $form = null;
+
+
+
+        }
+        $c =  new Content();
+        return $c->title("配置")->description('设置')->row($tab->render());
+    }
+
+    public function setting_form_save()
+    {
+        $inputs = request()->input();
+        unset($inputs['_token']);
+        $data = [];
+        $json = [];
+        $jsonArr = [];
+        foreach ($inputs as $k => $v){
+            $groups = explode('____',$k);
+            $num = count($groups);
+            if ($num< 1)
+                continue;
+            else if ($num === 2){
+                //普通字段配置
+                SystemConfig::where(['group'=>$groups[0],'key'=>$groups[1]])->update(['value'=>$v]);
+            }else if ($num === 3){
+                if ($groups[2] == "Switch"){
+                    if ($v=="on")
+                        $v = 1;
+                    else
+                        $v = 0;
+
+                    if ($groups[1] =='use_personal')
+                    {
+                        $v = $v==0?1:0;
+                    }
+
+                    SystemConfig::where(['group'=>$groups[0],'key'=>$groups[1]])->update(['value'=>$v]);
+                }else if ($groups[2] == "checkbox"){
+                    $origin_data = SystemConfig::get($groups[0],$groups[1]);
+                    $origin_data = json_decode($origin_data,true);
+                    foreach ($origin_data as $kk => $datum){
+                        $origin_data[$kk]['value'] =0;
+                        foreach ($v as $vv){
+                            if ($datum['key'] == $vv)
+                                $origin_data[$kk]['value'] =1;
+                        }
+                    }
+
+                    SystemConfig::where(['group'=>$groups[0],'key'=>$groups[1]])->update(['value'=>json_encode($origin_data)]);
+                }
+
+            }else if ($num == 4){
+                if ($groups[2]=="JA"){
+                    $jsonArr[$groups[0]][$groups[1]][$groups[3]] = $v;
+                }else{
+                    //JSON字段配置
+                    $json[$groups[0]][$groups[1]][$groups[3]] = $v;
+                }
+
+            }
+        }
+
+        if (count($json)>0){
+            foreach ($json as $k =>$value){
+                foreach ($value as $kk => $item){
+                    SystemConfig::where(['group'=>$k,'key'=>$kk])->update(['value'=>json_encode($item)]);
+                }
+            }
+        }
+
+        if (count($jsonArr)>0){
+            foreach ($jsonArr as $k =>$value){
+                foreach ($value as $kk => $item){
+                    $res = SystemConfig::where(['group'=>$k,'key'=>$kk])->first();
+                    if (!$res)
+                        continue;
+                    $json = json_decode($res['value'],true);
+
+                    foreach ($item as $kkk => $item2){
+                        $json[$kkk]['value'] = $item2;
+                        $res->update(['value'=>json_encode($json)]);
+
+
+
+                }
+            }
+        }
+        }
+
+        $files = request()->file();
+
+        foreach ($files as $key => $file){
+            $groups = explode('____',$key);
+            $file_name ='upload/SystemFiles/'.uniqid().'.'.$file->getClientOriginalExtension();
+            file_put_contents(public_path($file_name),file_get_contents($file->getRealPath()));
+            SystemConfig::where(['group'=>$groups[0],'key'=>$groups[1]])->update(['value'=>$file_name]);
+
+        }
+
+
+        admin_info('保存成功');
+        return back();
+    }
+
+
+    public function setCommunity()
+    {
+        $id = request('pid')?:'1';
+        $grid = new Grid(new BaseArea());
+
+        $grid->model()->where('pid',$id);
+
+
+        $c =  new Content();
+        return $c->title("配置")->description('设置')->body($grid->render());
+    }
+
+
+    public function setAreaById()
+    {
+        $id = request('id');
+        $type = request('t');
+        $m = request('m');
+
+        if ($m == "0")
+        {
+            $rs = Communities::where('id',$id)->update(['is_door'=>$type]);
+            if ($rs)
+            {
+                admin_toastr('设置成功','info');
+                return back();
+            }
+            admin_toastr('设置失败','error');
+            return back();
+        }
+
+        $rs = BaseArea::where('relation','like',"%{$id}%")->orwhere('id',$id)->update(['is_door'=>intval($type)]);
+
+
+
+        $rs = BaseArea::where(['grade'=>5])->where('relation','like',"%{$id}%")->get(['id']);
+        $ds = [];
+        foreach ($rs as $r){
+            $ds[] = $r['id'];
+        }
+
+        $rs = Communities::whereIn('area_id',$ds)->update(['is_door'=>intval($type)]);
+
+
+            admin_toastr('设置成功','info');
+            return back();
+
+
+    }
+
+
+    public function setPrice()
+    {
+        $id = request('pid');
+        $key = request('key');
+        $p = request('price');
+        $m = request('m');
+        $text = request('text');
+
+        if ($m == "1")
+        {
+            $rs = Communities::where('id',$id)->update([$key=>($p/10)]);
+            if ($rs)
+            {
+                return response()->json(['status'=>'ok']);
+            }
+            return response()->json(['status'=>'error']);
+        }
+
+
+        $rs = BaseArea::where('merger_name','like',"%{$text}%")->update([$key=>$p/10]);
+       if(!$rs) return response()->json(['status'=>'error']);
+        $rs = BaseArea::where('merger_name','like',"%{$text}%")->get(['id']);
+        $ds = [];
+
+        foreach ($rs as $r){
+            $ds[] = $r['id'];
+        }
+
+        $rs = Communities::whereIn('area_id',$ds)->update([$key=>$p/10]);
+
+        if ($rs)
+        {
+            return response()->json(['status'=>'ok']);
+        }
+        return response()->json(['status'=>'error']);
+    }
+
+}

+ 103 - 0
app/Admin/Controllers/CouponManagement/CouponDetailsController.php

xqd
@@ -0,0 +1,103 @@
+<?php
+
+namespace App\Admin\Controllers\CouponManagement;
+
+use App\Models\Coupon;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class CouponDetailsController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '优惠券详情';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Coupon());
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id', __('Id'));
+        $grid->column('name', __('券名称'));
+        $grid->column('title', __('券标题'));
+        $grid->column('desc', __('使用说明'))->limit(20,'...');
+        $grid->column('rules', __('使用规则'))->limit(20,'...');
+        $grid->column('min_consume_amount', __('最低消费金额'))->display(function ($money){
+            return $money/100;
+        });
+        $grid->column('max_reduce_amount', __('折扣券的最大抵扣金额'))->display(function ($money){
+            return $money/100;
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Coupon::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('name', __('Name'));
+        $show->field('title', __('Title'));
+        $show->field('desc', __('Desc'));
+        $show->field('rules', __('Rules'));
+        $show->field('icon', __('Icon'));
+        $show->field('type', __('Type'));
+        $show->field('usable_type', __('Usable type'));
+        $show->field('money', __('Money'));
+        $show->field('discount', __('Discount'));
+        $show->field('min_consume_amount', __('Min consume amount'));
+        $show->field('max_reduce_amount', __('Max reduce amount'));
+        $show->field('expire_type', __('Expire type'));
+        $show->field('effective_days', __('Effective days'));
+        $show->field('start_time', __('Start time'));
+        $show->field('end_time', __('End time'));
+        $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 Coupon());
+
+        $form->text('name', __('Name'));
+        $form->text('title', __('Title'));
+        $form->text('desc', __('Desc'));
+        $form->text('rules', __('Rules'));
+        $form->text('icon', __('Icon'));
+        $form->switch('type', __('Type'));
+        $form->switch('usable_type', __('Usable type'));
+        $form->number('money', __('Money'));
+        $form->decimal('discount', __('Discount'))->default(0.00);
+        $form->number('min_consume_amount', __('Min consume amount'));
+        $form->number('max_reduce_amount', __('Max reduce amount'));
+        $form->switch('expire_type', __('Expire type'));
+        $form->number('effective_days', __('Effective days'));
+        $form->number('start_time', __('Start time'));
+        $form->number('end_time', __('End time'));
+
+        return $form;
+    }
+}

+ 133 - 0
app/Admin/Controllers/CouponManagement/CouponDistributionUserList.php

xqd
@@ -0,0 +1,133 @@
+<?php
+
+namespace App\Admin\Controllers\CouponManagement;
+
+use App\Admin\Actions\backstage\Coupon\AllCouponBatchGrant;
+use App\Admin\Actions\backstage\Coupon\CouponBatchGrant;
+use App\Models\User;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class CouponDistributionUserList extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '优惠券发放用户列表';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new User());
+        $grid->filter(function($filter){
+            $filter->disableIdFilter();
+            $filter->equal('phone','手机')->mobile()->placeholder("请输入手机");
+            $filter->like('patient.name','患者姓名')->placeholder("请输入患者姓名");
+            $filter->like('nickname','昵称');
+            $filter->equal('status','用户状态')->radio([
+                ''   => '不限',
+                0    => '黑名单',
+                1    => '正常',
+            ]);
+            $filter->equal('is_pack','用户状态')->radio([
+                ''   => '全部用户',
+                0    => '普通用户',
+                1    => '服务包用户',
+            ]);
+        });
+        $grid->batchActions(function ($batch) {
+            $batch->add(new CouponBatchGrant());
+            $batch->add(new AllCouponBatchGrant());
+        });
+        $grid->disableActions();
+        $grid ->model()->where('status','>=','0');
+        $grid->column('id', __('用户id'))->sortable();
+        $grid->column('nickname', __('用户名'));
+        $grid->column('sex', __('性别'))->using([0=>'未知',1=>'男',2=>'女']);
+        $grid->column('age', __('年龄'));
+        $grid->column('status', __('状态'))->using([0=>'黑名单',1=>'正常',]);
+        $grid->column('is_pack', __('用户身份'))->using([0=>'普通用户',1=>'付费用户']);
+        $grid->column('balance', __('当前余额'))->display(function ($price){
+            return $price/100;
+        });
+        $grid->column('created_at', __('注册时间'));
+        $grid->column('last_login_time', __('最后登录时间'))->display(function ($time){
+            return date("Y-m-d H:i",$time);
+        });
+//            $grid->column('patient', __('患者姓名'))->pluck('name')->map('ucwords')->implode(',');
+        $grid->column('patient', __('患者姓名'))->pluck('name')->label('default');
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(User::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('nickname', __('Nickname'));
+        $show->field('phone', __('Phone'));
+        $show->field('sex', __('Sex'));
+        $show->field('avatar', __('Avatar'));
+        $show->field('openid', __('Openid'));
+        $show->field('remark', __('Remark'));
+        $show->field('birthday', __('Birthday'));
+        $show->field('status', __('Status'));
+        $show->field('balance', __('Balance'));
+        $show->field('giving_balance', __('Giving balance'));
+        $show->field('topup_balance', __('Topup balance'));
+        $show->field('session_key', __('Session key'));
+        $show->field('pay_password', __('Pay password'));
+        $show->field('latitude', __('Latitude'));
+        $show->field('longitude', __('Longitude'));
+        $show->field('is_pack', __('Is pack'));
+        $show->field('last_login_time', __('Last login time'));
+        $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 User());
+
+        $form->text('nickname', __('Nickname'));
+        $form->mobile('phone', __('Phone'));
+        $form->switch('sex', __('Sex'));
+        $form->image('avatar', __('Avatar'));
+        $form->text('openid', __('Openid'));
+        $form->text('remark', __('Remark'));
+        $form->text('birthday', __('Birthday'));
+        $form->switch('status', __('Status'))->default(1);
+        $form->number('balance', __('Balance'));
+        $form->number('giving_balance', __('Giving balance'));
+        $form->number('topup_balance', __('Topup balance'));
+        $form->text('session_key', __('Session key'));
+        $form->text('pay_password', __('Pay password'));
+        $form->decimal('latitude', __('Latitude'))->default(0.0000000);
+        $form->decimal('longitude', __('Longitude'))->default(0.0000000);
+        $form->switch('is_pack', __('Is pack'));
+        $form->number('last_login_time', __('Last login time'));
+
+        return $form;
+    }
+}

+ 195 - 0
app/Admin/Controllers/CouponManagement/CouponManagementController.php

xqd
@@ -0,0 +1,195 @@
+<?php
+
+namespace App\Admin\Controllers\CouponManagement;
+
+use App\Admin\Actions\backstage\Coupon\CouponDetails;
+use App\Admin\Actions\backstage\Coupon\CouponDistribution;
+use App\Admin\Actions\backstage\Coupon\CouponDistributions;
+use App\Models\Coupon;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class CouponManagementController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '优惠券管理';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Coupon());
+
+        $grid->tools(function (Grid\Tools $tools) {
+            $tools->append(new CouponDistributions());
+        });
+        $grid->actions(function ($actions) {
+            $actions->disableView();
+            $actions->add(new CouponDetails());
+        });
+        $grid->filter(function($filter){
+            $filter->timestampBetween('start_time', "有效期开始时间")->datetime();
+            $filter->timestampBetween('end_time', "有效期结束时间")->datetime();
+        });
+
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id', __('Id'));
+        $grid->column('name', __('劵名称'));
+        $grid->column('title', __('劵标题'));
+        $grid->column('icon', __('券图标'))->lightbox(['width' =>'', 'height' => 30]);
+        $grid->column('type', __('类型'))->using([1=>'满减券',2=>'折扣券']);
+        $grid->column('usable_type', __('可用类型'))->using([1=>'全部产品通用',2=>'部分产品可用']);
+        $grid->column('CouponType', __('可用产品'))->pluck('product_type','id')->display(function ($i){
+            $name = [];
+            foreach ($i as $value)
+            {
+                switch ($value){
+                    case 1:
+                        array_push($name,'电话咨询');
+                        break;
+                    case 2:
+                        array_push($name,'图文咨询');
+                        break;
+                    case 3:
+                        array_push($name,'门诊咨询');
+                        break;
+                    case 4:
+                        array_push($name,'疫苗接种');
+                        break;
+                    case 5:
+                        array_push($name,'儿保预约');
+                        break;
+                    case 6:
+                        array_push($name,'服务包');
+                        break;
+                    case 7:
+                        array_push($name,'充值');
+                        break;
+                }
+            }
+            return $name;
+        })->label('info');
+        $grid->column('money', __('满减券的优惠钱数'))->display(function ($money){
+            return $money/100;
+        });
+        $grid->column('discount', __('折扣'));
+        $grid->column('position_type', __('发放平台'))->using([1=>'领券中心',2=>'后台发放']);
+        $grid->column('num', __('数量'));
+        $grid->column('effective_days', __('有效天数'));
+        $grid->column('start_time', __('有效期开始时间'))->display(function ($time){
+            if ($time ==0)
+                return '';
+            return date('Y-m-d H:i:s',$time);
+        });
+        $grid->column('end_time', __('有效期结束时间'))->display(function ($time){
+            if ($time ==0)
+                return '';
+            return date('Y-m-d H:i:s',$time);
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Coupon::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('name', __('Name'));
+        $show->field('title', __('Title'));
+        $show->field('desc', __('Desc'));
+        $show->field('rules', __('Rules'));
+        $show->field('icon', __('Icon'));
+        $show->field('type', __('Type'));
+        $show->field('usable_type', __('Usable type'));
+        $show->field('money', __('Money'));
+        $show->field('discount', __('Discount'));
+        $show->field('min_consume_amount', __('Min consume amount'));
+        $show->field('max_reduce_amount', __('Max reduce amount'));
+        $show->field('expire_type', __('Expire type'));
+        $show->field('effective_days', __('Effective days'));
+        $show->field('start_time', __('Start time'));
+        $show->field('end_time', __('End time'));
+        $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 Coupon());
+
+        $form->text('name', __('优惠券名称'));
+        $form->text('title', __('券标题'));
+        $form->text('desc', __('使用说明'));
+        $form->text('rules', __('使用规则'));
+        $form->image('icon', __('券图标'))->help('图标大小48px * 48px');
+        $form->select('type', '类型')
+            ->options([
+                1 => '满减券',
+                2 => '折扣券',
+            ])->when(1, function (Form $form) {
+                $form->text('money', '满减券的优惠钱数');
+                $form->text('min_consume_amount', '最低消费金额');
+            })->when(2, function (Form $form) {
+                $form->text('discount', '折扣');
+                $form->text('max_reduce_amount', '折扣券的最大抵扣金额');
+            });
+        $form->select('position_type',__('发放平台'))->options([1=>'领券中心',2=>'后台发放']);
+        $form->number('num', __('数量'));
+        $form->select('usable_type',__('可用类型'))
+            ->options([
+                1=>'全部产品通用',
+                2=>'部分产品可用'
+            ])->when(2,function (Form $form){
+                $form->hasMany('CouponType','可用类型',function (Form\NestedForm $form){
+                    $form->select('product_type','可用类型')->options([
+                        1=>'电话咨询',
+                        2=>'图文咨询',
+                        3=>'门诊咨询',
+                        4=>'疫苗接种',
+                        5=>'儿保预约',
+                        6=>'服务包',
+                        7=>'充值',
+                    ]);
+                });
+            });
+        $form->select('expire_type', '过期类型')
+            ->options([
+                1 => '领取N天过期',
+                2 => '设置固定过期时间',
+            ])->when(1, function (Form $form) {
+                $form->text('effective_days', __('有效天数'));
+            })->when(2, function (Form $form) {
+                $form->date('start_time', __('有效期开始时间'));
+                $form->date('end_time', __('有效期结束时间'));
+                $form->saving(function ($form){
+                    $form->start_time = strtotime($form->start_time);
+                    $form->end_time = strtotime($form->end_time);
+                });
+
+
+            });
+        return $form;
+    }
+}

+ 11 - 11
app/Admin/Controllers/ExampleController.php

xqd xqd
@@ -2,9 +2,10 @@
 
 namespace App\Admin\Controllers;
 
-use Encore\Admin\Http\Controllers\AdminController;
+
+use Encore\Admin\Controllers\AdminController;
 use Encore\Admin\Form;
-use Encore\Admin\Table;
+use Encore\Admin\Grid;
 use Encore\Admin\Show;
 
 class ExampleController extends AdminController
@@ -17,19 +18,18 @@ class ExampleController extends AdminController
     protected $title = 'Example controller';
 
     /**
-     * Make a table builder.
+     * Make a grid builder.
      *
-     * @return Table
+     * @return Grid
      */
-    protected function table()
+    protected function grid()
     {
-        $table = new Table(new ExampleModel);
-
-        $table->column('id', __('ID'))->sortable();
-        $table->column('created_at', __('Created at'));
-        $table->column('updated_at', __('Updated at'));
+        $grid = new Grid(new ExampleModel);
 
-        return $table;
+        $grid->column('id', __('ID'))->sortable();
+        $grid->column('created_at', __('Created at'));
+        $grid->column('updated_at', __('Updated at'));
+        return $grid;
     }
 
     /**

+ 2 - 1
app/Admin/Controllers/HomeController.php

xqd
@@ -3,7 +3,8 @@
 namespace App\Admin\Controllers;
 
 use App\Http\Controllers\Controller;
-use Encore\Admin\Http\Controllers\Dashboard;
+
+use Encore\Admin\Controllers\Dashboard;
 use Encore\Admin\Layout\Column;
 use Encore\Admin\Layout\Content;
 use Encore\Admin\Layout\Row;

+ 229 - 0
app/Admin/Controllers/OrdersManagement/BookingOrderController.php

xqd
@@ -0,0 +1,229 @@
+<?php
+
+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 App\Models\ServicePack;
+use Encore\Admin\Controllers\AdminController;
+use App\Admin\Actions\backstage\User\MapDepot;
+use App\Admin\Actions\backstage\User\Suggests;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class BookingOrderController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '预约订单';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Order());
+        $grid->disableCreateButton();
+        $grid->model()->wherein('product_type',[3,4,5]);
+
+        //筛选
+
+        $grid->filter(function ($filter){
+            $filter->disableIdFilter();
+            $filter->column(1/3, function ($filter) {
+                $filter->like('user.nickname','用户姓名');
+                $filter->like('docter.name','医生姓名');
+                $filter->like('orderPatient.name','患者姓名');
+                $filter->timestampBetween('payment_time', "支付时间")->datetime();
+            });
+            $filter->column(1/3, function ($filter) {
+                $filter->equal('user_id', '用户id');
+                $filter->equal('docter_id', '医生id');
+                $filter->timestampBetween('receiving_time', "接单时间")->datetime();
+            });
+            $filter->column(1/3,function ($filter) {
+                $filter->equal('product_type','预约类型')->radio(
+                    [
+                        ''=>'不限',
+                        3=>'门诊预约',
+                        4=>'疫苗接种预约',
+                        5=>'儿保预约'
+                    ]
+                );
+                $filter->equal('order_status','订单状态')->radio(
+                    [
+                        ''=>'不限',
+                        1=>'未支付',
+                        2=>'待接单',
+                        3=>'进行中',
+                        4=>'已完成',
+                        5=>'已取消'
+                    ]
+                );
+                $filter->timestampBetween('end_time', "订单完成时间")->datetime();
+            });
+        });
+
+        $grid->actions(function ($actions) {
+            // 去掉删除
+            $actions->disableDelete();
+            // 去掉编辑
+            $actions->disableEdit();
+//            $actions->add(new MapDepot());
+            $actions->add(new Evaluate());
+//            $actions->add(new Suggests());
+        });
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id', __('Id'))->sortable();
+        $grid->column('user.nickname', __('用户姓名'));
+        $grid->column('docter.name', __('医生姓名'));
+        $grid->column('orderPatient.name', __('患者姓名'));
+        $grid->column('orderPatient.patient_phone', __('患者电话'));
+        $grid->column('orderPatient.appoint_start_time', __('预约日期'))->display(function ($time){
+            return date('Y-m-d H:i:s',$time);
+        });
+        $grid->column('orderPatient.appoint_end_time', __('就诊日期'))->display(function ($time){
+            return date('Y-m-d H:i:s',$time);
+        });
+        $grid->column('product_type', __('产品类型'))->using([3=>'门诊预约',4=>'疫苗接种预约',5=>'儿保预约']);
+        $grid->column('payment_type', __('支付方式'))->display(function ($payment_type){
+            if ($payment_type == 1)
+            {
+                return '微信支付';
+            }
+            if ($payment_type == 2){
+                return '余额支付';
+            }
+            if ($payment_type == 3){
+                $order_pack_id = OrderPack::where('id',$this->pay_order_pack_id)->pluck('service_pack_id');
+                $name = ServicePack::where('id',$order_pack_id[0])->pluck('name');
+                return '服务包支付('.$name[0].')';
+            }
+        });
+        $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;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Order::findOrFail($id));
+        $show->field('id', __('Id'));
+        $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;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Order());
+
+        $form->number('user_id', __('User id'));
+        $form->number('docter_id', __('Docter id'));
+        $form->number('patient_id', __('Patient id'));
+        $form->number('organization_id', __('Organization id'));
+        $form->text('order_sn', __('Order sn'));
+        $form->switch('payment_type', __('Payment type'))->default(1);
+        $form->switch('product_type', __('Product type'))->default(1);
+        $form->switch('order_status', __('Order status'))->default(1);
+        $form->switch('payment_status', __('Payment status'))->default(1);
+        $form->number('total_amount', __('Total amount'));
+        $form->number('payment_amount', __('Payment amount'));
+        $form->number('discount_amount', __('Discount amount'));
+        $form->number('payment_time', __('Payment time'));
+        $form->number('outtime', __('Outtime'));
+        $form->number('receiving_time', __('Receiving time'));
+
+        return $form;
+    }
+}

+ 234 - 0
app/Admin/Controllers/OrdersManagement/ConsultingOrdersController.php

xqd
@@ -0,0 +1,234 @@
+<?php
+
+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;
+use App\Models\Order;
+use App\Models\OrderPack;
+use App\Models\ServicePack;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class ConsultingOrdersController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '咨询订单';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Order());
+        $grid->disableCreateButton();
+        $grid->model()->wherein('product_type',[1,2]);
+        //筛选
+        $grid->filter(function ($filter){
+            $filter->disableIdFilter();
+            $filter->column(1/3, function ($filter) {
+                $filter->like('user.nickname','用户姓名');
+                $filter->equal('user_id', '用户id');
+                $filter->timestampBetween('payment_time', "支付时间")->datetime();
+                $filter->in('evaluate.score','评分')->checkbox([
+                    1    => 1,
+                    2    => 2,
+                    3    => 3,
+                    4    => 4,
+                    5    => 5,
+                ]);
+
+            });
+            $filter->column(1/3, function ($filter) {
+                $filter->like('docter.name','医生姓名');
+                $filter->equal('docter_id', '医生id');
+                $filter->equal('product_type','产品类型')->radio(
+                    [
+                        ''=>'不限',
+                        1=>'电话咨询',
+                        2=>'图文咨询',
+                    ]
+                );
+                $filter->timestampBetween('receiving_time', "接单时间")->datetime();
+            });
+            $filter->column(1/3, function ($filter) {
+                $filter->like('orderPatient.name','患者姓名');
+                $filter->equal('order_status','订单状态')->radio(
+                    [
+                        ''=>'不限',
+                        1=>'未支付',
+                        2=>'待接单',
+                        3=>'进行中',
+                        4=>'已完成',
+                        5=>'已取消'
+                    ]
+                );
+                $filter->timestampBetween('end_time', "订单完成时间")->datetime();
+            });
+        });
+        //操作
+        $grid->actions(function ($actions) {
+            // 去掉删除
+            $actions->disableDelete();
+            // 去掉编辑
+            $actions->disableEdit();
+//            $actions->add(new MapDepot());
+            $actions->add(new Evaluate());
+//            $actions->add(new Suggests());
+
+        });
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id', __('Id'))->sortable();
+        $grid->column('user.nickname', __('用户姓名'));
+        $grid->column('docter.name', __('医生姓名'));
+        $grid->column('orderPatient.name', __('患者姓名'));
+        $grid->column('orderPatient.patient_phone', __('患者电话'));
+        $grid->column('orderPatient.symptoms', __('患者描述'));
+        $grid->column('product_type', __('产品类型'))->using([1=>'电话咨询',2=>'图文咨询']);
+        $grid->column('payment_type', __('支付方式'))->display(function ($payment_type){
+            if ($payment_type == 1)
+            {
+                return '微信支付';
+            }
+            if ($payment_type == 2){
+                return '余额支付';
+            }
+            if ($payment_type == 3){
+                $order_pack_id = OrderPack::where('id',$this->pay_order_pack_id)->pluck('service_pack_id');
+                $name = ServicePack::where('id',$order_pack_id[0])->pluck('name');
+                return '服务包支付('.$name[0].')';
+            }
+        });
+        $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('evaluate.score', __('订单评分'));
+        $grid->column('evaluate.status', __('评分状态'))->using([1=>'待审核',2=>'审核通过',3=>'审核拒绝']);
+        $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;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Order::findOrFail($id));
+        $show->field('id', __('Id'));
+        $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;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Order());
+
+        $form->number('user_id', __('User id'));
+        $form->number('docter_id', __('Docter id'));
+        $form->number('patient_id', __('Patient id'));
+        $form->number('organization_id', __('Organization id'));
+        $form->text('order_sn', __('Order sn'));
+        $form->switch('payment_type', __('Payment type'))->default(1);
+        $form->switch('product_type', __('Product type'))->default(1);
+        $form->switch('order_status', __('Order status'))->default(1);
+        $form->switch('payment_status', __('Payment status'))->default(1);
+        $form->number('total_amount', __('Total amount'));
+        $form->number('payment_amount', __('Payment amount'));
+        $form->number('discount_amount', __('Discount amount'));
+        $form->number('payment_time', __('Payment time'));
+        $form->number('outtime', __('Outtime'));
+        $form->number('receiving_time', __('Receiving time'));
+
+        return $form;
+    }
+}

+ 73 - 0
app/Admin/Controllers/OrdersManagement/InsuranceListController.php

xqd
@@ -0,0 +1,73 @@
+<?php
+
+namespace App\Admin\Controllers\OrdersManagement;
+
+use App\Admin\Actions\backstage\Orders\PdfAction;
+use App\Models\Order;
+use App\Models\OrderPack;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class InsuranceListController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '保险信息列表';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Order());
+        $grid->actions(function ($actions){
+           $actions->disableView();
+           $actions->disableDelete();
+           if ($actions->row->payment_status != 2)
+           {
+               $actions->disableEdit();
+           }
+           $has_pdf = OrderPack::where('order_id',$actions->row->id)->value('insurance_img_url');
+           if (!empty($has_pdf))
+           {
+               $actions->add(new PdfAction());
+           }
+        });
+        $grid->disableCreateButton();
+        $grid->model()->wherein('product_type',[6]);
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id', __('订单id'))->sortable();
+        $grid->column('orderPack.pack_name', __('服务包名称'));
+        $grid->column('user.nickname', __('用户姓名'));
+        $grid->column('orderPatient.name', __('患者姓名'));
+        $grid->column('orderPatient.sex', __('性别'))->using([0=>'未知',1=>'男',2=>'女']);
+        $grid->column('orderPatient.relationship_type', __('与投保人的关系'))
+            ->using([1=>'父亲',2=>'母亲',3=>'祖父',4=>'祖母',5=>'外祖父',6=>'外祖母',7=>'叔侄',8=>'其他']);
+        $grid->column('orderPatient.patient_id', __('患者id'))->hide();
+        $grid->column('user.phone', __('用户电话'));
+        //保单信息
+        $grid->column('orderPatient.birthday', __('出生日期'));
+        $grid->column('orderPatient.card_type', __('证件类型'))->using([1=>'身份证',2=>'护照']);
+        $grid->column('orderPatient.card_number', __('证件号码'));
+        $grid->column('orderPatient.social_card_number', __('社保卡号'));
+        $grid->column('order_status', __('订单状态'))->using([1=>'未支付',2=>'待接单',3=>'进行中',4=>'已完成',5=>'已取消']);
+        $grid->column('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款']);
+
+
+        return $grid;
+    }
+
+    protected function form()
+    {
+        $form = new Form(new Order());
+        $form->file('orderPack.insurance_img_url','保单文件')->help('请上传pdf文件')->rules('required');
+        return $form;
+    }
+}

+ 125 - 0
app/Admin/Controllers/OrdersManagement/OrdersDetailsController.php

xqd
@@ -0,0 +1,125 @@
+<?php
+
+namespace App\Admin\Controllers\OrdersManagement;
+
+use App\Models\Order;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class OrdersDetailsController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '订单详情';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Order());
+        $grid->disableCreateButton();
+        $grid->disableActions();
+        $grid->column('id', __('Id'));
+        $grid->column('product_type', __('产品类型'))->using([
+            1=>'电话咨询',
+            2=>'图文咨询',
+            3=>'门诊预约',
+            4=>'疫苗接种预约',
+            5=>'儿保预约',
+            6=>'服务包',
+            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('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);
+        });
+        $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;
+        });
+
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    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'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Order());
+
+        $form->number('user_id', __('User id'));
+        $form->number('docter_id', __('Docter id'));
+        $form->number('patient_id', __('Patient id'));
+        $form->number('organization_id', __('Organization id'));
+        $form->text('order_sn', __('Order sn'));
+        $form->switch('payment_type', __('Payment type'))->default(1);
+        $form->switch('product_type', __('Product type'))->default(1);
+        $form->switch('order_status', __('Order status'))->default(1);
+        $form->switch('payment_status', __('Payment status'))->default(1);
+        $form->number('total_amount', __('Total amount'));
+        $form->number('payment_amount', __('Payment amount'));
+        $form->number('discount_amount', __('Discount amount'));
+        $form->number('payment_time', __('Payment time'));
+        $form->number('outtime', __('Outtime'));
+        $form->number('receiving_time', __('Receiving time'));
+
+        return $form;
+    }
+}

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

xqd
@@ -0,0 +1,106 @@
+<?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->model()->orderBy('id','desc');
+        $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;
+    }
+}

+ 190 - 0
app/Admin/Controllers/OrdersManagement/RechargeOrderController.php

xqd
@@ -0,0 +1,190 @@
+<?php
+
+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;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class RechargeOrderController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '充值订单';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Order());
+        $grid->disableCreateButton();
+        $grid->model()->wherein('product_type',[7]);
+
+        //筛选
+
+        $grid->filter(function ($filter){
+            $filter->disableIdFilter();
+            $filter->column(1/2, function ($filter) {
+                $filter->like('user.nickname','用户姓名');
+                $filter->equal('user_id', '用户id');
+                $filter->equal('order_status','订单状态')->radio(
+                    [
+                        ''=>'不限',
+                        1=>'未支付',
+                        2=>'待接单',
+                        3=>'进行中',
+                        4=>'已完成',
+                        5=>'已取消'
+                    ]
+                );
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->timestampBetween('payment_time', "支付时间")->datetime();
+                $filter->timestampBetween('receiving_time', "接单时间")->datetime();
+                $filter->timestampBetween('end_time', "订单完成时间")->datetime();
+            });
+            });
+
+        $grid->actions(function ($actions) {
+            // 去掉删除
+            $actions->disableDelete();
+            // 去掉编辑
+            $actions->disableEdit();
+        });
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id', __('Id'))->sortable();
+        $grid->column('user_id', __('用户id'));
+        $grid->column('user.nickname', __('用户姓名'));
+        $grid->column('user.phone', __('用户电话'));
+        $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;
+        });
+        $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;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Order::findOrFail($id));        $show->field('id', __('Id'));
+        $show->field('id', __('Id'));
+        $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;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Order());
+
+        $form->number('user_id', __('User id'));
+        $form->number('docter_id', __('Docter id'));
+        $form->number('patient_id', __('Patient id'));
+        $form->number('organization_id', __('Organization id'));
+        $form->text('order_sn', __('Order sn'));
+        $form->switch('payment_type', __('Payment type'))->default(1);
+        $form->switch('product_type', __('Product type'))->default(1);
+        $form->switch('order_status', __('Order status'))->default(1);
+        $form->switch('payment_status', __('Payment status'))->default(1);
+        $form->number('total_amount', __('Total amount'));
+        $form->number('payment_amount', __('Payment amount'));
+        $form->number('discount_amount', __('Discount amount'));
+        $form->number('payment_time', __('Payment time'));
+        $form->number('outtime', __('Outtime'));
+        $form->number('receiving_time', __('Receiving time'));
+
+        return $form;
+    }
+}

+ 125 - 0
app/Admin/Controllers/OrdersManagement/ServicePackDetailsController.php

xqd
@@ -0,0 +1,125 @@
+<?php
+
+namespace App\Admin\Controllers\OrdersManagement;
+
+use App\Models\OrderPack;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class ServicePackDetailsController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '服务包详情';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $order_id = \request('order_id');
+        $grid = new Grid(new OrderPack());
+
+        $grid->disableActions();
+        $grid->filter(function ($filter){
+            $filter->disableIdFilter();
+            $filter->equal('order_id','订单id');
+        });
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id', __('id'));
+        $grid->column('order_id', __('订单id'));
+        $grid->column('service_pack_id', __('服务包id'));
+        $grid->column('pack_name', __('服务包名称'));
+        $grid->column('pack_price', __('服务包价格'))->display(function ($price){
+            return $price/100;
+        });
+        $grid->column('phone_minutes', __('剩余电话分钟数'));
+        $grid->column('chat_num', __('剩余图文咨询次数'));
+        $grid->column('appoint_num', __('剩余门诊预约次数'));
+        $grid->column('vaccine_limit_amount', __('剩余疫苗金额'));
+        $grid->column('nurses_limit_amount', __('剩余儿保金额'));
+        $grid->column('effective_days', __('有效天数'));
+        $grid->column('start_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;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(OrderPack::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('order_id', __('Order id'));
+        $show->field('service_pack_id', __('Service pack id'));
+        $show->field('pack_name', __('Pack name'));
+        $show->field('pack_intro', __('Pack intro'));
+        $show->field('pack_price', __('Pack price'));
+        $show->field('insurance_policy', __('Insurance policy'));
+        $show->field('insurance_img_url', __('Insurance img url'));
+        $show->field('team_id', __('Team id'));
+        $show->field('phone_minutes', __('Phone minutes'));
+        $show->field('chat_num', __('Chat num'));
+        $show->field('appoint_num', __('Appoint num'));
+        $show->field('vaccine_limit_amount', __('Vaccine limit amount'));
+        $show->field('nurses_limit_amount', __('Nurses limit amount'));
+        $show->field('effective_days', __('Effective days'));
+        $show->field('start_time', __('Start time'));
+        $show->field('end_time', __('End time'));
+        $show->field('is_security', __('Is security'));
+        $show->field('guardian_name', __('Guardian name'));
+        $show->field('relationship_type', __('Relationship type'));
+        $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 OrderPack());
+
+        $form->number('order_id', __('Order id'));
+        $form->number('service_pack_id', __('Service pack id'));
+        $form->text('pack_name', __('Pack name'));
+        $form->text('pack_intro', __('Pack intro'));
+        $form->number('pack_price', __('Pack price'));
+        $form->text('insurance_policy', __('Insurance policy'));
+        $form->text('insurance_img_url', __('Insurance img url'));
+        $form->number('team_id', __('Team id'));
+        $form->number('phone_minutes', __('Phone minutes'));
+        $form->number('chat_num', __('Chat num'));
+        $form->number('appoint_num', __('Appoint num'));
+        $form->number('vaccine_limit_amount', __('Vaccine limit amount'));
+        $form->number('nurses_limit_amount', __('Nurses limit amount'));
+        $form->number('effective_days', __('Effective days'));
+        $form->number('start_time', __('Start time'));
+        $form->number('end_time', __('End time'));
+        $form->switch('is_security', __('Is security'));
+        $form->text('guardian_name', __('Guardian name'));
+        $form->switch('relationship_type', __('Relationship type'));
+
+        return $form;
+    }
+}

+ 176 - 0
app/Admin/Controllers/OrdersManagement/ServicePackOrderController.php

xqd
@@ -0,0 +1,176 @@
+<?php
+
+namespace App\Admin\Controllers\OrdersManagement;
+
+use App\Admin\Actions\backstage\Orders\Evaluate;
+use App\Admin\Actions\backstage\Orders\ServicePack;
+use App\Admin\Actions\backstage\Orders\ServicePackOrderList;
+use App\Models\Order;
+use App\Admin\Actions\backstage\Orders\OrderDetails;
+use Encore\Admin\Controllers\AdminController;
+use App\Admin\Actions\backstage\User\MapDepot;
+use App\Admin\Actions\backstage\User\Suggests;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class ServicePackOrderController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '服务包开通订单';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Order());
+        $grid->disableCreateButton();
+        $grid->model()->wherein('product_type',[6]);
+        //筛选
+        $grid->filter(function ($filter){
+            $filter->disableIdFilter();
+            $filter->column(1/3, function ($filter) {
+                $filter->like('user.nickname','用户姓名');
+                $filter->like('docter.name','医生姓名');
+                $filter->like('orderPatient.name','患者姓名');
+            });
+            $filter->column(1/3, function ($filter) {
+                $filter->equal('user_id', '用户id');
+                $filter->equal('docter_id', '医生id');
+                $filter->equal('order_status','订单状态')->radio(
+                    [
+                        ''=>'不限',
+                        1=>'未支付',
+                        2=>'待接单',
+                        3=>'进行中',
+                        4=>'已完成',
+                        5=>'已取消'
+                    ]
+                );
+                $filter->column(1/3, function ($filter) {
+                    $filter->timestampBetween('payment_time', "支付时间")->datetime();
+                    $filter->timestampBetween('receiving_time', "接单时间")->datetime();
+                    $filter->timestampBetween('end_time', "订单完成时间")->datetime();
+                });
+            });
+        });
+        //操作
+        $grid->actions(function ($actions) {
+            // 去掉删除
+            $actions->disableDelete();
+            // 去掉编辑
+            $actions->disableEdit();
+            $actions->add(new ServicePack());
+            $actions->add(new ServicePackOrderList());
+        });
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id', __('Id'))->sortable();
+        $grid->column('user.nickname', __('用户姓名'));
+        $grid->column('orderPatient.name', __('患者姓名'));
+        $grid->column('orderPatient.patient_id', __('患者id'))->hide();
+        $grid->column('user.phone', __('用户电话'));
+        $grid->column('orderPack.service_pack_id', __('服务包id'));
+        $grid->column('orderPack.pack_name', __('服务包名称'));
+        $grid->column('orderPack.pack_price', __('服务包价格'))->display(function ($money){
+            return $money/100;
+        });
+        $grid->column('product_type', __('产品类型'))->using([6=>'服务包订单']);
+        $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;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Order::findOrFail($id));
+        $show->field('id', __('Id'));
+        $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;
+    }
+}

+ 148 - 0
app/Admin/Controllers/OrdersManagement/ServicePackOrderListController.php

xqd
@@ -0,0 +1,148 @@
+<?php
+
+namespace App\Admin\Controllers\OrdersManagement;
+
+use App\Models\Order;
+use App\Models\ServicePack;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class ServicePackOrderListController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '服务包订单列表';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $pack_id = \request('pay_order_pack_id');
+        $patient_id = \request('patient_id');
+
+        $grid = new Grid(new Order());
+
+        
+        $grid->filter(function ($filter){
+            $filter->disableIdFilter();
+            $filter->equal('pay_order_pack_id','服务包id');
+            $filter->equal('patient_id','患者id');
+        });
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id', __('Id'))->sortable();
+        $grid->column('user.nickname', __('用户姓名'));
+        $grid->column('docter.name', __('医生姓名'));
+        $grid->column('orderPatient.name', __('患者姓名'));
+        $grid->column('orderPatient.patient_phone', __('患者电话'));
+        $grid->column('orderPatient.symptoms', __('患者描述'));
+        $grid->column('product_type', __('产品类型'))
+            ->using([1=>'电话咨询',2=>'图文咨询',3=>'门诊咨询',4=>'疫苗接种预约',5=>'儿保预约',6=>'服务包',7=>'充值']);
+        $grid->column('payment_type', __('支付方式'))->display(function ($payment_type){
+            if ($payment_type == 1)
+            {
+                return '微信支付';
+            }
+            if ($payment_type == 2){
+                return '余额支付';
+            }
+            if ($payment_type == 3){
+                $name = ServicePack::where('id',$this->pay_order_pack_id)->pluck('name');
+                return '服务包支付('.$name[0].')';
+            }
+        });
+        $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('evaluate.score', __('订单评分'));
+        $grid->column('evaluate.status', __('评分状态'))->using([1=>'待审核',2=>'审核通过',3=>'审核拒绝']);
+        $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;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    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('pay_order_pack_id', __('Pay order pack id'));
+        $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('end_time', __('End time'));
+        $show->field('receiving_time', __('Receiving time'));
+        $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 Order());
+
+        $form->number('user_id', __('User id'));
+        $form->number('docter_id', __('Docter id'));
+        $form->number('patient_id', __('Patient id'));
+        $form->number('organization_id', __('Organization id'));
+        $form->text('order_sn', __('Order sn'));
+        $form->number('pay_order_pack_id', __('Pay order pack id'));
+        $form->switch('payment_type', __('Payment type'))->default(1);
+        $form->switch('product_type', __('Product type'))->default(1);
+        $form->switch('order_status', __('Order status'))->default(1);
+        $form->switch('payment_status', __('Payment status'))->default(1);
+        $form->number('total_amount', __('Total amount'));
+        $form->number('payment_amount', __('Payment amount'));
+        $form->number('discount_amount', __('Discount amount'));
+        $form->number('payment_time', __('Payment time'));
+        $form->number('end_time', __('End time'));
+        $form->number('receiving_time', __('Receiving time'));
+
+        return $form;
+    }
+}

+ 96 - 0
app/Admin/Controllers/OrdersManagement/UserSuggestsController.php

xqd
@@ -0,0 +1,96 @@
+<?php
+
+namespace App\Admin\Controllers\OrdersManagement;
+
+use App\Models\Suggest;
+use App\Models\User;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class UserSuggestsController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '病例意见单';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Suggest());
+        $grid->disableCreateButton();
+        $grid->disableActions();
+        $uesr_id = \request('order_id');
+        $grid->filter(function ($filter){
+            $filter->disableIdFilter();
+            $filter->equal('order_id','订单id');
+        });
+        $grid->column('id', __('Id'));
+        $grid->column('order_id', __('订单id'));
+        $grid->column('user_id', __('用户id'));
+        $grid->column('patient_id', __('档案id'));
+        $grid->column('symptoms', __('病症'))->limit(20,'...');
+        $grid->column('pathogen', __('病因'))->limit(20,'...');
+        $grid->column('suggest', __('结论建议'))->limit(20,'...');
+        $grid->column('supplement_reason', __('补充原因'))->limit(20,'...');
+        $grid->column('supplement_content', __('补充内容'))->limit(20,'...');
+        $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(Suggest::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('order_id', __('Order id'));
+        $show->field('user_id', __('User id'));
+        $show->field('patient_id', __('Patient id'));
+        $show->field('symptoms', __('Symptoms'));
+        $show->field('pathogen', __('Pathogen'));
+        $show->field('suggest', __('Suggest'));
+        $show->field('supplement_reason', __('Supplement reason'));
+        $show->field('supplement_content', __('Supplement 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 Suggest());
+
+        $form->number('order_id', __('Order id'));
+        $form->number('user_id', __('User id'));
+        $form->number('patient_id', __('Patient id'));
+        $form->text('symptoms', __('Symptoms'));
+        $form->text('pathogen', __('Pathogen'));
+        $form->text('suggest', __('Suggest'));
+        $form->text('supplement_reason', __('Supplement reason'));
+        $form->text('supplement_content', __('Supplement content'));
+
+        return $form;
+    }
+}

+ 141 - 0
app/Admin/Controllers/OrganizationController.php

xqd
@@ -0,0 +1,141 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Admin\Actions\Cdmuser;
+use App\Admin\Actions\UpdateCdms;
+use App\Models\Area;
+use App\Models\Organization;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class OrganizationController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '机构列表';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Organization());
+        $grid->filter(function ($filter){
+           $filter->disableIdFilter();
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('type','机构类型')->select([
+                    1=>'公立医院',
+                    2=>'私立医院'
+                ]);
+                $filter->equal('level','机构级别')->select([
+                    0=>'未定级',
+                    1=>'一级',
+                    2=>'二级',
+                    3=>'三级'
+                ]);
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('province_id','省份')->select(Area::where('level',1)->pluck('name','id'));
+                $filter->equal('city_id','城市')->select(Area::where('level',2)->pluck('name','id'));
+                $filter->equal('area_id','地区')->select(Area::where('level',3)->pluck('name','id'));
+            });
+        });
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id', __('Id'));
+        $grid->column('type', __('机构类型'))->using([1=>'公立医院',2=>'私立医院']);
+        $grid->column('level', __('机构级别'))->using([0=>'未定级',1=>'一级',2=>'二级',3=>'三级']);
+        $grid->column('name', __('名称'));
+        $grid->column('province_id', __('省份'))->display(function ($id){
+            return Area::where('id',$id)->value('name');
+        });
+        $grid->column('city_id', __('城市'))->display(function ($id){
+            return Area::where('id',$id)->value('name');
+        });
+        $grid->column('area_id', __('地区'))->display(function ($id){
+            return Area::where('id',$id)->value('name');
+        });
+        $grid->column('address', __('详细地址'));
+        $grid->column('latitude', __('经度'));
+        $grid->column('longitude', __('纬度'));
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+
+        $grid->actions(function ($actions){
+            if($actions->row->cdms_id){
+                $actions->add(new UpdateCdms());
+            } else {
+                $actions->add(new Cdmuser());
+            }
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Organization::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('type', __('Type'));
+        $show->field('name', __('Name'));
+        $show->field('province_id', __('Province id'));
+        $show->field('city_id', __('City id'));
+        $show->field('area_id', __('Area id'));
+        $show->field('address', __('Address'));
+        $show->field('latitude', __('Latitude'));
+        $show->field('longitude', __('Longitude'));
+        $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 Organization());
+
+        $form->select('type', __('机构类型'))->options([
+            1=>'公立医院',
+            2=>'私立医院'
+        ])->required();
+        $form->select('level', __('机构级别'))->options([
+            0=>'未定级',
+            1=>'一级',
+            2=>'二级',
+            3=>'三级',
+        ])->required();
+        $form->text('name', __('名称'))->required();
+        $form->select('province_id', __('省份'))->options(function (){
+            return Area::where('level',1)->pluck('name','id');
+        })->load('city_id','/admin/api/getCity')->required();
+        $form->select('city_id', __('城市'))->options(function (){
+            return Area::where('level',2)->pluck('name','id');
+        })->load('area_id','/admin/api/getArea')->required();;
+        $form->select('area_id', __('地区'))->required();
+        $form->text('address', __('详细地址'))->required();
+        $form->textarea('nurse_notice','门诊通告');
+        $form->textarea('vaccine_notice','计免通告');
+        $form->latlong('latitude', 'longitude','经纬度');
+
+        return $form;
+    }
+}

+ 65 - 0
app/Admin/Controllers/OutpatientServiceCCController.php

xqd
@@ -0,0 +1,65 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Admin\Actions\Service\ApplysAction;
+use App\Admin\Actions\Service\RefuseAction;
+use App\Models\Serviceapplys;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class OutpatientServiceCCController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '门诊咨询认证';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Serviceapplys());
+
+        $grid->model()->where('service_type','3');
+        $grid->column('id', __('Id'));
+        $grid->column('docter.avatar', __('头像'))->image('',50,50);
+        $grid->column('docter.id', __('医生ID'));
+        $grid->column('docter.name','医生名称');
+        $grid->column('docter.sex','性别')->using([1=>'男',2=>'女']);
+        $grid->column('docter.DocterOrganization', __('所属机构'));
+//        $grid->column('docter.label', __('标签'))->map('ucwords')->implode('-');
+        $grid->column('docter.label', __('标签'))->label('info');
+
+        //$grid->column('service_type', __('服务类型'));
+
+        $grid->column('status', __('状态'))->using([1=>'审核',2=>'已通过',3=>'已拒绝'])->label([
+            1 => 'warning',
+            2 => 'success',
+            3 => 'default'
+        ]);
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+//        $grid->column('service_type','123')->hide();
+
+        $grid->actions(function ($actions) {
+            // 去掉删除
+            $actions->disableDelete();
+            // 去掉编辑
+            $actions->disableEdit();
+            // 去掉查看
+            $actions->disableView();
+
+            $actions->add(new ApplysAction());
+            $actions->add(new RefuseAction());
+        });
+        return $grid;
+    }
+}

+ 55 - 0
app/Admin/Controllers/OutpatientServiceController.php

xqd
@@ -0,0 +1,55 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\Docter;
+use App\Models\Order;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class OutpatientServiceController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '门诊订单数';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Docter());
+
+        $grid->column('id','ID');
+        $grid->column('name','医生姓名');
+        $grid->column('appoint_price','咨询价格');
+        $grid->column('orders','总订单数')->display(function (){
+
+            $order_type = Order::where(['docter_id'=>$this->id,'product_type'=>3])->count();
+            return $order_type;
+        });
+        $grid->column('orders_actions','进行中数')->display(function (){
+            $action = Order::where(['docter_id'=>$this->id,'product_type'=>3,'order_status'=>3])->count();
+            return $action;
+        });
+        $grid->column('orders_inishs','完成数')->display(function (){
+            $finish = Order::where(['docter_id'=>$this->id,'product_type'=>3,'order_status'=>4])->count();
+            return $finish;
+        });
+        $grid->column('orders_anomaly','异常数')->display(function (){
+            $anomaly = Order::where(['docter_id'=>$this->id,'product_type'=>3])->whereIn('order_status',[1,2,5])->count();
+//            dd($anomaly);
+            return $anomaly;
+        });
+
+        return $grid;
+    }
+
+}

+ 92 - 0
app/Admin/Controllers/PermissionController.php

xqd
@@ -0,0 +1,92 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\CdmsPermissions;
+use App\Models\CdmsRoles;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class PermissionController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '权限列表';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new CdmsRoles());
+
+        $user = Admin::user();
+        $is_admin = Admin::user()->inRoles(['administrator','devloper']);
+        $grid->disableCreateButton(false);
+//        $is_manager = Admin::user()->isRole('manager');
+        if(!$is_admin){
+            $org_id = $user->org_id;
+            $grid->model()->where(['org_id'=>$org_id]);
+        }
+        $grid->column('organization.name', __('所属机构'))->display(function ($org_name){
+            return $org_name ?? '总后台';
+        });
+        $grid->column('name', __('名称'));
+        $grid->column('slug', __('标识'));
+        $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(CdmsRoles::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('name', __('Name'));
+        $show->field('slug', __('Slug'));
+        $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 CdmsRoles());
+        $is_manager = Admin::user()->isRole('manager');
+
+        if($is_manager){
+            $org_id = Admin::user()->org_id;
+            $form->hidden('org_id')->value($org_id);
+        }
+
+        $form->text('slug', __('标识'))->rules('required',['required'=>'标识必须']);
+        $form->text('name', '名称')
+            ->creationRules(['required', "unique:cdms_roles"])
+            ->updateRules(['required', "unique:cdms_roles,name,{{id}}"]);
+        $form->listbox('permissions', trans('admin.permissions'))->options(CdmsPermissions::all()->pluck('name', 'id'));
+
+        return $form;
+    }
+}

+ 70 - 0
app/Admin/Controllers/PhoneServiceCCController.php

xqd
@@ -0,0 +1,70 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Admin\Actions\Service\ApplysAction;
+use App\Admin\Actions\Service\RefuseAction;
+use App\Models\Serviceapplys;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class PhoneServiceCCController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '电话咨询认证';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Serviceapplys());
+
+        $grid->model()->where('service_type','2');
+        $grid->column('id', __('Id'));
+        $grid->column('docter.avatar', __('头像'))->image('',50,50);
+        $grid->column('docter.id', __('医生ID'));
+        $grid->column('docter.name','医生名称');
+        $grid->column('docter.sex','性别')->using([1=>'男',2=>'女']);
+        $grid->column('docter.DocterOrganization', __('所属机构'));
+//        $grid->column('docter.label', __('标签'))->map('ucwords')->implode('-');
+        $grid->column('docter.label', __('标签'))->label('info');
+
+        //$grid->column('service_type', __('服务类型'));
+
+        $grid->column('status', __('状态'))->using([1=>'审核',2=>'已通过',3=>'已拒绝'])->label([
+            1 => 'warning',
+            2 => 'success',
+            3 => 'default'
+        ]);
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+
+        $grid->actions(function ($actions) {
+            // 去掉删除
+            $actions->disableDelete();
+            // 去掉编辑
+            $actions->disableEdit();
+            // 去掉查看
+            $actions->disableView();
+
+
+            $actions->add(new ApplysAction());
+            $actions->add(new RefuseAction());
+        });
+
+
+
+        return $grid;
+    }
+}
+
+

+ 62 - 0
app/Admin/Controllers/PhoneServiceController.php

xqd
@@ -0,0 +1,62 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\Docter;
+use App\Models\Order;
+use App\Models\Doctertimes;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class PhoneServiceController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '电话订单数';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Docter());
+
+        $grid->column('id','ID');
+        $grid->column('name','医生姓名');
+        $grid->column('phone_price','咨询价格');
+        $grid->column('step_price','步进价格')->display(function (){
+            $step = Doctertimes::where(['docter_id'=>$this->id])->value('step_price');
+            return $step;
+        });
+
+
+        $grid->column('orders','总订单数')->display(function (){
+
+            $order_type = Order::where(['docter_id'=>$this->id,'product_type'=>1])->count();
+            return $order_type;
+        });
+        $grid->column('orders_actions','进行中数')->display(function (){
+            $action = Order::where(['docter_id'=>$this->id,'product_type'=>1,'order_status'=>3])->count();
+            return $action;
+        });
+        $grid->column('orders_inishs','完成数')->display(function (){
+            $finish = Order::where(['docter_id'=>$this->id,'product_type'=>1,'order_status'=>4])->count();
+            return $finish;
+        });
+        $grid->column('orders_anomaly','异常数')->display(function (){
+            $anomaly = Order::where(['docter_id'=>$this->id,'product_type'=>1])->whereIn('order_status',[1,2,5])->count();
+//            dd($anomaly);
+            return $anomaly;
+        });
+
+        return $grid;
+    }
+
+}

+ 68 - 0
app/Admin/Controllers/ReplyServiceCCController.php

xqd
@@ -0,0 +1,68 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Admin\Actions\Service\ApplysAction;
+use App\Admin\Actions\Service\RefuseAction;
+use App\Models\Serviceapplys;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class ReplyServiceCCController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '图文咨询认证';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Serviceapplys());
+
+        $grid->model()->where('service_type','1');
+        $grid->column('id', __('Id'));
+        $grid->column('docter.avatar', __('头像'))->image('',50,50);
+        $grid->column('docter.id', __('医生ID'));
+        $grid->column('docter.name','医生名称');
+        $grid->column('docter.sex','性别')->using([1=>'男',2=>'女']);
+        $grid->column('docter.DocterOrganization', __('所属机构'));
+//        $grid->column('docter.label', __('标签'))->map('ucwords')->implode('-');
+        $grid->column('docter.label', __('标签'))->label('info');
+
+        //$grid->column('service_type', __('服务类型'));
+
+        $grid->column('status', __('状态'))->using([1=>'审核',2=>'已通过',3=>'已拒绝'])->label([
+            1 => 'warning',
+            2 => 'success',
+            3 => 'default'
+        ]);
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+
+        $grid->actions(function ($actions) {
+            // 去掉删除
+            $actions->disableDelete();
+            // 去掉编辑
+            $actions->disableEdit();
+            // 去掉查看
+            $actions->disableView();
+
+
+            $actions->add(new ApplysAction());
+            $actions->add(new RefuseAction());
+        });
+
+
+
+        return $grid;
+    }
+}

+ 56 - 0
app/Admin/Controllers/ReplyServiceController.php

xqd
@@ -0,0 +1,56 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\Docter;
+use App\Models\Order;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class ReplyServiceController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '图文订单数';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Docter());
+
+
+        $grid->column('id','ID');
+        $grid->column('name','医生姓名');
+        $grid->column('chat_price','咨询价格');
+        $grid->column('orders','总订单数')->display(function (){
+
+            $order_type = Order::where(['docter_id'=>$this->id,'product_type'=>2])->count();
+            return $order_type;
+        });
+        $grid->column('orders_actions','进行中数')->display(function (){
+            $action = Order::where(['docter_id'=>$this->id,'product_type'=>2,'order_status'=>3])->count();
+            return $action;
+        });
+        $grid->column('orders_inishs','完成数')->display(function (){
+            $finish = Order::where(['docter_id'=>$this->id,'product_type'=>2,'order_status'=>4])->count();
+            return $finish;
+        });
+        $grid->column('orders_anomaly','异常数')->display(function (){
+            $anomaly = Order::where(['docter_id'=>$this->id,'product_type'=>2])->whereIn('order_status',[1,2,5])->count();
+//            dd($anomaly);
+            return $anomaly;
+        });
+
+        return $grid;
+    }
+
+}

+ 101 - 0
app/Admin/Controllers/ServiceManagement/ServiceController.php

xqd
@@ -0,0 +1,101 @@
+<?php
+
+namespace App\Admin\Controllers\ServiceManagement;
+
+use App\Admin\Actions\backstage\Pass;
+use App\Admin\Actions\Service\ApplysAction;
+use App\Admin\Actions\Service\PassAction;
+use App\Admin\Actions\Service\RefuseAction;
+use App\Admin\Actions\Service\RevokeAction;
+use App\Models\Docter;
+use App\Models\DocterLabel;
+use App\Models\Order;
+use App\Models\Doctertimes;
+use App\Models\Organization;
+use App\Models\Serviceapplys;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class ServiceController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '服务审核';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Serviceapplys());
+
+//        $status = request('status',2);
+
+        $grid->tools(function ($tools) {
+            $tools->batch(function ($batch) {
+                $batch->disableDelete();
+            });
+        });
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id', __('Id'));
+        $grid->column('ondocter.avatar', __('头像'))->lightbox(['width' =>'', 'height' => 30]);
+        $grid->column('ondocter.id', __('医生ID'));
+        $grid->column('ondocter.name','医生名称');
+        $grid->column('service_type','服务类别')->using([1=>'图文咨询',2=>'电话咨询',3=>'门诊预约'])->label('default');
+        $grid->column('ondocter.sex','性别')->using([1=>'男',2=>'女']);
+        $grid->column('docterorganization', __('所属机构'))->pluck('organization_id')->display(function ($organization){
+            $value = Organization::whereIn('id',$organization->toArray())->pluck('name')->toArray();
+            return $value;
+        })->label('info');
+        $grid->column('ondocter.label', __('标签'))->display(function ($label){
+            if($label==null || $label == '无')
+            {
+                return '无';
+            }else{
+                $label_value = DocterLabel::whereIn('id',$label)->pluck('label_name')->toArray();
+                return $label_value;
+            }
+        })->label(['info']);
+
+
+        $grid->column('status', __('状态'))->using([1=>'待审核',2=>'已开通',3=>'未开通'])->label([
+            1 => 'warning',
+            2 => 'success',
+            3 => 'default'
+        ]);
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+
+        $grid->filter(function ($filter){
+            $filter->equal('service_type','服务类型')->select([1 => '图文', 2 => '电话', 3 => '问诊']);
+            $filter->equal('status','服务类型')->select([1=>'待审核',2 =>'已通过 ',3=>'已拒绝']);
+            $filter->equal('docterorganization.organization_id','机构')->select(Organization::pluck('name','id'));
+        });
+        $grid->actions(function ($actions) {
+            $actions->disableEdit();
+            $actions->disableView();
+            $actions->disableDelete();
+            if($actions->row->status == 1){
+                $actions->add(new ApplysAction());
+                $actions->add(new RefuseAction());
+            }
+            if ($actions->row->status == 2)
+            {
+                $actions->add(new RevokeAction());
+            }
+            if ($actions->row->status == 3)
+            {
+                $actions->add(new PassAction());
+            }
+        });
+        return $grid;
+    }
+
+}

+ 44 - 0
app/Admin/Controllers/ServicePacksManagment/OpenPackController.php

xqd
@@ -0,0 +1,44 @@
+<?php
+
+namespace App\Admin\Controllers\ServicePacksManagment;
+
+use App\Models\Team;
+use App\Models\Order;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Grid;
+
+class OpenPackController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '开通记录';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Order());
+        $grid->disableActions();
+        $grid->model()->where('product_type','6')->orderBy('id','desc');
+        $grid->column('id', __('订单ID'));
+        $grid->column('user_id', __('用户ID'));
+        $grid->column('user.nickname','用户姓名');
+        $grid->column('orderPatient.name', __('患者名称'));
+        $grid->column('orderPack.service_pack_id', __('服务包ID'));
+        $grid->column('orderPack.pack_name', __('服务包名称'));
+        $grid->column('orderPack.pack_price', __('服务包价格'));
+        $grid->column('orderPack.team_id', __('所属团队'))->display(function ($model){
+            $name = Team::where('id',$model)->value('name');
+            return $name;
+        });
+        $grid->column('created_at', __('创建时间'));
+
+        return $grid;
+    }
+}

+ 82 - 0
app/Admin/Controllers/ServicePacksManagment/ServebannerController.php

xqd
@@ -0,0 +1,82 @@
+<?php
+
+namespace App\Admin\Controllers\ServicePacksManagment;
+
+use App\Models\Servebanner;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class ServebannerController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '服务包海报';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Servebanner());
+
+        $grid->column('id', __('Id'));
+        $grid->column('image', __('海报'))->image('',100,100);
+        $grid->column('url', __('链接'));
+        $states = [
+            'on'  => ['value' => 1, 'text' => '启用', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
+        ];
+        $grid->column('status','状态')->switch($states);
+        $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(Servebanner::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('image', __('Image'))->image('',100,100);
+        $show->field('url', __('Url'));
+        $show->field('status', __('Status'));
+        $show->field('updated_at', __('Updated at'));
+        $show->field('created_at', __('Created at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Servebanner());
+
+        $form->image('image', __('海报'))->rules('required' ,['required'=>'请选择图片!']);
+        $form->text('url', __('链接'));
+        $states = [
+            'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
+            'on'  => ['value' => 1, 'text' => '启用', 'color' => 'success'],
+        ];
+        $form->switch('status','状态')->states($states);
+
+        return $form;
+    }
+}

+ 113 - 0
app/Admin/Controllers/ServicePacksManagment/ServicePacksController.php

xqd
@@ -0,0 +1,113 @@
+<?php
+
+namespace App\Admin\Controllers\ServicePacksManagment;
+
+use App\Models\ServicePack;
+use App\Models\Team;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class ServicePacksController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '服务包列表';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+        protected function grid()
+    {
+        $grid = new Grid(new ServicePack());
+        $grid->actions(function ($actions){
+           $actions->disableView();
+        });
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id', __('Id'));
+        $grid->column('name', __('服务包名称'));
+        $grid->column('intro', __('简介'));
+        $grid->column('desc', __('详细内容'))->limit(100);
+        $grid->column('label','服务类型')->display(function (){
+            $tag = [1 => '图文',2 => '电话',3 => '门诊',4 => '计免',5 => '儿保'];
+            $datas = $this -> label;
+
+            if($datas){
+                for ($i=0;$i<count($datas);$i++){
+                    $str = $tag[$datas[$i]];
+                    $label[$i]= $str;
+                }
+                return $label;
+                    }
+            return 0;
+        })->label('info');
+        $grid->column('price', __('价格'));
+        $grid->column('team_id', __('团队名称'))->display(function (){
+            $modal = $this->team_id;
+            if ($modal){
+                for ($i=0; $i < count((array)$modal); $i++){
+                    $id = $modal[$i];
+                    $name[$i] = Team::where('id',$id)->value('name');
+                }
+                return $name;
+            }
+            return '通用';
+        })->label('success');
+
+        $grid->column('image','图片')->lightbox(['width' =>'', 'height' => 30]);
+        $grid->column('phone_minutes', __('电话次数(分钟)'));
+        $grid->column('chat_num', __('图文次数'));
+        $grid->column('appoint_num', __('门诊次数'));
+        $grid->column('vaccine_limit_amount', __('计免次数'));
+        $grid->column('nurses_limit_amount', __('儿保次数'));
+        $grid->column('effective_days', __('服务时长'));
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+
+        return $grid;
+    }
+        /**
+         * Make a form builder.
+         *
+         * @return Form
+         */
+        protected function form()
+    {
+        $form = new Form(new ServicePack());
+
+        $form->text('name', __('服务包名称'))->rules('required' ,['required'=>'请填写名称!']);
+        $form->image('image','图片')->rules('required' ,['required'=>'请选择图片!']);
+        $form->text('intro', __('简介'))->rules('required' ,['required'=>'请填写简介!']);;
+        $form->editor('desc', __('详情内容'))->rules('required' ,['required'=>'请填写内容!']);;
+        $form->number('price', __('价钱'))->default(0);
+        $form->multipleSelect('team_id', __('团队选择'))->options(Team::all()->pluck('name','id'));
+        //$form->multipleSelect('label','服务类型')->options([1 => '图文',2 => '电话',3 => '门诊',4 => '计免',5 => '儿保']);
+        $form->checkbox('label','服务类型')
+            ->options([
+                1 => '图文',
+                2 => '电话',
+                3 => '门诊',
+                4 => '计免',
+                5 => '儿保'
+            ])->when('has',1,function (Form $form){
+                $form->number('chat_num', __('图文次数'))->default(0);
+            })->when('has',2,function (Form $form){
+                $form->number('phone_minutes', __('电话分钟数'))->default(0);
+            })->when('has',3,function (Form $form){
+                $form->number('appoint_num', __('门诊次数'))->default(0);
+            })->when('has',4,function (Form $form){
+                $form->number('vaccine_limit_amount', __('计免次数'))->default(0);
+            })->when('has',5,function (Form $form){
+                $form->number('nurses_limit_amount', __('儿保次数'))->default(0);
+            })->rules('required',['required'=>'请选择服务类型']);
+
+        $form->text('effective_days', __('服务时长(秒)'))->default(0);
+        return $form;
+    }
+}

+ 100 - 0
app/Admin/Controllers/ServicePacksManagment/TeamController.php

xqd
@@ -0,0 +1,100 @@
+<?php
+
+namespace App\Admin\Controllers\ServicePacksManagment;
+
+use App\Admin\Actions\Serve\Addmember;
+use App\Models\Docter;
+use App\Models\Team;
+use App\Models\TeamDocter;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+use Encore\Admin\Widgets\Table;
+
+class TeamController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '团队列表';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Team());
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id', __('Id'));
+        $grid->column('name', __('团队名称'));
+        $grid->column('introduction','简介')->limit(15,'...')->width(200);
+        $grid->column('member','成员查看')->display(function (){
+            return '点击查看';
+        })->modal('成员列表', function ($model){
+            $docters = $model->docter()->get()->map(function ($docter) {
+                return $docter->only(['id', 'name']);
+            });
+            return new Table(['医生ID', '医生名称'], $docters->toArray());
+        });
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+        $status = [
+            'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
+            'on'  => ['value' => 1, 'text' => '启用', 'color' => 'success'],
+        ];
+        $grid->column('status', __('状态'))->switch($status);
+        $grid->actions(function ($actions) {
+            // 去掉查看
+            $actions->disableView();
+        });
+        return $grid;
+    }
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Team());
+        $form->text('name', __('团队名称'))->rules('required' ,['required'=>'请填写团队名称!']);
+        $form->text('introduction','简介')->rules('required' ,['required'=>'请填写团队简介!']);
+        $form->multipleSelect('member',' 成员')->options(function (){
+            //筛选医生列表
+            $member = Docter::where('is_then', 1)->pluck('name', 'id');
+            return $member;
+        })->rules('required');
+        $status = [
+            'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
+            'on'  => ['value' => 1, 'text' => '启用', 'color' => 'success'],
+        ];
+        $form->switch('status', __('状态'))->states($status);
+        $form->saved(function (Form $form) {
+            //保存后回调插入数据
+            $id = $form->model()->id;
+            $team = TeamDocter::where('team_id',$id)->get();
+            if ($team != null)
+            {
+                TeamDocter::where('team_id',$id)->delete();
+            }
+            foreach ($form->member as $value)
+            {
+                if ($value != null)
+                {
+                    $arr = [
+                        'docter_id' => $value,
+                        'team_id' =>$id,
+                    ];
+                    TeamDocter::create($arr);
+                }
+            }
+        });
+        return $form;
+    }
+
+}

+ 63 - 0
app/Admin/Controllers/ServicePacksManagment/TeamDocterController.php

xqd
@@ -0,0 +1,63 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\TeamDocter;
+use App\Models\Docter;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class TeamDocterController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '团队——医生表';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new TeamDocter());
+
+        $grid->filter(function ($filter){
+            $filter->disableIdFilter();
+            $filter->equal('team_id','团队');
+        });
+        $grid->column('id', __('Id'));
+        $grid->column('docter_id', __('医生ID'));
+        $grid->column('docter.name', __('医生姓名'));
+        $grid->column('team.name', __('团队名称'));
+        $grid->column('team.introduction', __('团队简介'));
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new TeamDocter());
+        $form->select('docter_id', __('医生名称'))->options(function (){
+            return Docter::where('is_then', 1)->pluck('name', 'id');
+        });
+//        $form->saving(function (Form $form){
+//           $form -> team_id = $form ->
+//        });
+        $form->text('team_id', __('团队ID'));
+
+        return $form;
+    }
+}

+ 106 - 0
app/Admin/Controllers/UserManagement/BmUser/UserBalanceLogController.php

xqd
@@ -0,0 +1,106 @@
+<?php
+
+namespace App\Admin\Controllers\UserManagement\BmUser;
+
+use App\Models\UserBalanceLog;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class UserBalanceLogController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '余额明细';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new UserBalanceLog());
+        $grid->disableCreateButton();
+        //根据id筛选数据
+        $uesr_id = \request('user_id');
+        $grid->filter(function ($filter){
+            $filter->disableIdFilter();
+            $filter->equal('user_id','用户id');
+        });
+        //关闭全部的操作
+        $grid->disableActions();
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id', __('Id'));
+        $grid->column('user_id', __('用户ID'));
+        $grid->column('user.nickname', __('用户名称'));
+        $grid->column('admin_user_id', __('后台用户ID'));
+        $grid->column('type', __('类型'))
+            ->using([1=>'订单消费',2=>'用户充值',3=>'后台赠送']);
+        $grid->column('relation_id', __('订单id'));
+        $grid->column('before_balance', __('变化前的余额'))->display(function ($price){
+            return $price/100;
+        });
+        $grid->column('change_balance', __('改变的余额'))->display(function ($price){
+            return $price/100;
+        });
+        $grid->column('after_balance', __('变化后的余额'))->display(function ($price){
+            return $price/100;
+        });
+        $grid->column('remark', __('备注'));
+        $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(UserBalanceLog::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('user_id', __('User id'));
+        $show->field('admin_user_id', __('Admin user id'));
+        $show->field('type', __('Type'));
+        $show->field('relation_id', __('Relation id'));
+        $show->field('before_balance', __('Before balance'));
+        $show->field('change_balance', __('Change balance'));
+        $show->field('after_balance', __('After balance'));
+        $show->field('remark', __('Remark'));
+        $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 UserBalanceLog());
+
+        $form->number('user_id', __('User id'));
+        $form->number('admin_user_id', __('Admin user id'));
+        $form->switch('type', __('Type'));
+        $form->number('relation_id', __('Relation id'));
+        $form->number('before_balance', __('Before balance'));
+        $form->number('change_balance', __('Change balance'));
+        $form->number('after_balance', __('After balance'));
+        $form->text('remark', __('Remark'));
+
+        return $form;
+    }
+}

+ 142 - 0
app/Admin/Controllers/UserManagement/BmUser/UserCouponsController.php

xqd
@@ -0,0 +1,142 @@
+<?php
+
+namespace App\Admin\Controllers\UserManagement\BmUser;
+
+use App\Models\UserCoupon;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class UserCouponsController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '优惠券列表';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new UserCoupon());
+        $grid->disableCreateButton();
+        $uesr_id = \request('user_id');
+        $grid->filter(function ($filter){
+            $filter->disableIdFilter();
+            $filter->equal('user_id','用户id');
+        });
+        $grid->disableActions();
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id', __('Id'));
+        $grid->column('coupon_id', __('优惠券ID'));
+        $grid->column('name', __('券名称'));
+        $grid->column('icon', __('券图标'))->lightbox(['width' =>'', 'height' => 30]);
+        $grid->column('title', __('券标题'));
+        $grid->column('type', __('类型'))->using([1=>'满减券',2=>'折扣券']);
+        $grid->column('usable_type', __('可用类型'))->using([1=>'全部产品通用',2=>'部分产品可用']);
+        $grid->column('CouponType', __('可用产品'))->pluck('product_type','id')->display(function ($i){
+            $name = [];
+            foreach ($i as $value)
+            {
+                switch ($value){
+                    case 1:
+                        array_push($name,'电话咨询');
+                        break;
+                    case 2:
+                        array_push($name,'图文咨询');
+                        break;
+                    case 3:
+                        array_push($name,'门诊咨询');
+                        break;
+                    case 4:
+                        array_push($name,'疫苗接种');
+                        break;
+                    case 5:
+                        array_push($name,'儿保预约');
+                        break;
+                    case 6:
+                        array_push($name,'服务包');
+                        break;
+                    case 7:
+                        array_push($name,'充值');
+                        break;
+                }
+            }
+            return $name;
+        })->label('info');
+        $grid->column('money', __('满减券的优惠钱数'))->display(function ($money){
+            return $money/100;
+        });
+        $grid->column('min_consume_amount', __('最低消费金额'))->display(function ($money){
+            return $money/100;
+        });
+        $grid->column('discount', __('折扣'));
+        $grid->column('max_reduce_amount', __('折扣券的最大抵扣金额'))->display(function ($money){
+            return $money/100;
+        });
+        $grid->column('expire_type', __('过期类型'))->using([1=>'领取N天过期',2=>'设置固定过期时间']);
+        $grid->column('effective_days', __('有效天数'));
+        $grid->column('start_time', __('有效期开始时间'))->display(function ($time){
+            if($time == 0)
+            {
+                return '';
+            }else
+                return date("Y-m-d H:i",$time);
+        });
+        $grid->column('end_time', __('有效期结束时间'))->display(function ($time){
+            if($time == 0)
+            {
+                return '';
+            }else
+                return date("Y-m-d H:i",$time);
+        });
+        $grid->column('expire_time', __('过期时间'))->display(function ($time){
+            if($time == 0)
+            {
+                return '';
+            }else
+                return date("Y-m-d H:i",$time);
+        });
+        $grid->column('use_time', __('使用时间'))->display(function ($time){
+            if($time == 0)
+            {
+                return '';
+            }else
+                return date("Y-m-d H:i",$time);
+        });
+        $grid->column('status', __('优惠券状态'))->using([1=>'可用',2=>'已用',3=>'已过期']);
+        $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(UserCoupon::findOrFail($id));
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new UserCoupon());
+        return $form;
+    }
+}

+ 115 - 0
app/Admin/Controllers/UserManagement/BmUser/UserListController.php

xqd
@@ -0,0 +1,115 @@
+<?php
+
+namespace App\Admin\Controllers\UserManagement\BmUser;
+
+
+use App\Admin\Actions\backstage\User\archives;
+use App\Admin\Actions\backstage\User\BalanceLog;
+use App\Admin\Actions\backstage\User\BlackList;
+use App\Admin\Actions\backstage\User\coupons;
+use App\Admin\Actions\backstage\User\Orders;
+use App\Admin\Actions\backstage\User\service;
+use App\Models\Patient;
+use App\Models\User;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class UserListController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '用户列表';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new User());
+        $grid->disableCreateButton();
+        $grid->actions(function ($actions) {
+        // 去掉删除
+        $actions->disableDelete();
+        // 去掉编辑
+        $actions->disableEdit();
+        // 去掉查看
+        $actions->disableView();
+//        $actions->add(new archives());
+        $actions->add(new BalanceLog());
+        $actions->add(new BlackList());
+        $actions->add(new coupons());
+        $actions->add(new Orders());
+        $actions->add(new service());
+    });
+        //筛选
+        $grid->filter(function ($filter){
+            $filter->column(1/2, function ($filter) {
+                $filter->disableIdFilter();
+                $filter->equal('phone','手机')->mobile()->placeholder("请输入手机");
+                $filter->like('patient.name','患者姓名')->placeholder("请输入患者姓名");
+                $filter->like('nickname','昵称');
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('status','用户状态')->radio([
+                    ''   => '不限',
+                    0    => '黑名单',
+                    1    => '正常',
+                ]);
+//                $filter->equal('is_pack','用户状态')->radio([
+//                    ''   => '全部用户',
+//                    0    => '普通用户',
+//                    1    => '服务包用户',
+//                ]);
+                $filter->between('created_at', '注册时间')->datetime();
+                $filter->timestampBetween('last_login_time', "最后登录时间")->datetime();
+            });
+        });
+            $grid ->model()->where('status','>=','0')->orderBy('id','desc');
+            $grid->column('id', __('用户id'))->sortable();
+            $grid->column('avatar', __('头像'))->lightbox(['width' =>'', 'height' => 30]);
+            $grid->column('nickname', __('用户名'));
+            $grid->column('phone', __('手机号码'));
+            $grid->column('status', __('状态'))->using([0=>'黑名单',1=>'正常',]);
+//            $grid->column('is_pack', __('用户身份'))->using([0=>'普通用户',1=>'付费用户']);
+            $grid->column('balance', __('当前余额'))->display(function ($price){
+                return $price/100;
+            });
+            $grid->column('created_at', __('注册时间'));
+            $grid->column('last_login_time', __('最后登录时间'))->display(function ($time){
+                return date("Y-m-d H:i",$time);
+            });
+//            $grid->column('patient', __('患者姓名'))->pluck('name')->map('ucwords')->implode(',');
+//            $grid->column('patient', __('患者姓名'))->pluck('name')->label('default');
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(User::findOrFail($id));
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new User());
+        return $form;
+    }
+}

+ 144 - 0
app/Admin/Controllers/UserManagement/BmUser/UserOrdersController.php

xqd
@@ -0,0 +1,144 @@
+<?php
+
+namespace App\Admin\Controllers\UserManagement\BmUser;
+
+use App\Admin\Actions\backstage\Orders\ServicePack;
+use App\Models\Order;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class UserOrdersController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '订单数据总览';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Order());
+        $uesr_id = \request('user_id');
+        $grid->filter(function ($filter){
+            $filter->disableIdFilter();
+            $filter->equal('user_id','用户id');
+        });
+        $grid->disableActions();
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id', __('Id'))->sortable();
+        $grid->column('user.nickname', __('用户姓名'));
+        $grid->column('docter.name', __('医生姓名'));
+        $grid->column('orderPatient.name', __('患者姓名'));
+        $grid->column('orderPatient.patient_phone', __('患者电话'));
+        $grid->column('orderPatient.appoint_start_time', __('预约日期'))->display(function ($time){
+            return date('Y-m-d H:i:s',$time);
+        });
+        $grid->column('orderPatient.appoint_end_time', __('就诊日期'))->display(function ($time){
+            return date('Y-m-d H:i:s',$time);
+        });
+        $grid->column('product_type', __('产品类型'))->using([1=>'电话咨询',2=>'图文咨询',3=>'门诊预约',4=>'疫苗接种预约',5=>'儿保预约',6=>'服务包',7=>'充值']);
+        $grid->column('payment_type', __('支付方式'))->display(function ($payment_type){
+            if ($payment_type == 1)
+            {
+                return '微信支付';
+            }
+            if ($payment_type == 2){
+                return '余额支付';
+            }
+            if ($payment_type == 3){
+                $name = ServicePack::where('id',$this->pay_order_pack_id)->pluck('name');
+                return '服务包支付('.$name[0].')';
+            }
+            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;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    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('end_time', __('End time'));
+        $show->field('receiving_time', __('Receiving time'));
+        $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 Order());
+
+        $form->number('user_id', __('User id'));
+        $form->number('docter_id', __('Docter id'));
+        $form->number('patient_id', __('Patient id'));
+        $form->number('organization_id', __('Organization id'));
+        $form->text('order_sn', __('Order sn'));
+        $form->switch('payment_type', __('Payment type'))->default(1);
+        $form->switch('product_type', __('Product type'))->default(1);
+        $form->switch('order_status', __('Order status'))->default(1);
+        $form->switch('payment_status', __('Payment status'))->default(1);
+        $form->number('total_amount', __('Total amount'));
+        $form->number('payment_amount', __('Payment amount'));
+        $form->number('discount_amount', __('Discount amount'));
+        $form->number('payment_time', __('Payment time'));
+        $form->number('end_time', __('End time'));
+        $form->number('receiving_time', __('Receiving time'));
+
+        return $form;
+    }
+}

+ 107 - 0
app/Admin/Controllers/UserManagement/BmUser/UserPatientsController.php

xqd
@@ -0,0 +1,107 @@
+<?php
+
+namespace App\Admin\Controllers\UserManagement\BmUser;
+
+use App\Admin\Actions\backstage\User\MapDepot;
+use App\Admin\Actions\backstage\User\Suggests;
+use App\Models\Patient;
+use Encore\Admin\Controllers\AdminController;
+use App\Admin\Actions\backstage\User\service;
+use Illuminate\Http\Request;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class UserPatientsController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '患者列表';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Patient());
+        $grid->disableCreateButton();
+        $uesr_id = \request('user_id');
+        $grid->filter(function ($filter){
+            $filter->disableIdFilter();
+            $filter->equal('user_id','用户id');
+            $filter->equal('id','患者id');
+            $filter->like('name','患者姓名');
+        });
+        $grid->disableActions();
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id', __('患者id'));
+        $grid->column('user_id', __('用户id'));
+        $grid->column('name', __('患者姓名'));
+        $grid->column('sex', __('性别'))->using([0=>'未知',1=>'男',2=>'女',]);
+        $grid->column('avatar', __('头像'))->lightbox(['width' =>'', 'height' => 30]);
+        $grid->column('age', __('年龄'));
+        $grid->column('email', __('邮箱'));
+        $grid->column('phone', __('联系电话'));
+        $grid->column('address', __('家庭住址'))->limit(20,'...');
+        $grid->column('guardian_name', __('监护人姓名'));
+        $grid->column('card_type', __('证件类型'))->using([1=>'身份证',2=>'护照']);
+        $grid->column('card_number', __('证件号'));
+        $grid->column('social_card_number', __('社保卡号'));
+        $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(Patient::findOrFail($id));
+
+        $show->field('id', __('档案id'));
+        $show->field('user_id', __('用户id'));
+        $show->field('name', __('姓名'));
+        $show->field('sex', __('性别'))->using([0=>'未知',1=>'男',2=>'女',]);
+        $show->field('avatar', __('头像'))->image();
+        $show->field('card_img_url', __('身份证正面照片'))->image();
+        $show->field('card_back_img_url', __('身份证背面照片'))->image();
+        $show->field('birthday', __('生日'));
+        $show->field('age', __('年龄'));
+        $show->field('email', __('邮箱'));
+        $show->field('phone', __('联系电话'));
+        $show->field('address', __('家庭住址'));
+        $show->field('guardian_name', __('监护人姓名'));
+        $show->field('relationship_type', __('与就诊人关系类型'))
+            ->using([1=>'父亲',2=>'母亲',3=>'祖父',4=>'祖母',5=>'外祖父',6=>'外祖母',7=>'叔侄',8=>'其他']);
+        $show->field('info', __('就诊信息'));
+        $show->field('card_type', __('证件类型'))->using([1=>'身份证',2=>'护照']);
+        $show->field('card_number', __('证件号'));
+        $show->field('social_card_number', __('社保卡号'));
+        $show->field('born_hospital', __('出生医院'));
+        $show->field('created_at', __('创建时间'));
+        $show->field('updated_at', __('更新时间'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Patient());
+        return $form;
+    }
+}

+ 132 - 0
app/Admin/Controllers/UserManagement/BmUser/UserServiceController.php

xqd
@@ -0,0 +1,132 @@
+<?php
+
+namespace App\Admin\Controllers\UserManagement\BmUser;
+
+use App\Models\Order;
+use App\Models\OrderPack;
+use App\Models\Patient;
+use App\Admin\Actions\backstage\User\Insurance ;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class UserServiceController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '服务包管理';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Order());
+        $product_type = 6;
+        $uesr_id = \request('user_id');
+        $grid->filter(function ($filter){
+            $filter->disableIdFilter();
+            $filter->equal('user_id','用户id');
+            $filter->equal('product_type','订单类型');
+        });
+        $grid->actions(function ($actions) {
+
+            // 去掉删除
+            $actions->disableDelete();
+
+            // 去掉编辑
+            $actions->disableEdit();
+            //保险单链接
+            $actions->add(new Insurance());
+        });
+        $grid->model()->orderBy('id','desc');
+        $grid->column('orderPack.id', __('Id'));
+        $grid->column('orderPack.order_id', __('订单id'));
+        $grid->column('patient_id', __('患者姓名'))->display(function ($id){
+            return Patient::where('id',$id)->value('name');
+        });
+        $grid->column('orderPack.service_pack_id', __('服务包id'));
+        $grid->column('orderPack.pack_name', __('服务包名称'));
+        $grid->column('orderPack.pack_intro', __('服务包简介'));
+        $grid->column('orderPack.pack_price', __('服务包价格'))->display(function ($price){
+            return $price/100;
+        });
+        $grid->column('orderPack.team_id', __('医生团队ID'));
+
+        $grid->column('orderPack.effective_days', __('有效天数'));
+        $grid->column('orderPack.start_time', __('开始时间'))->display(function ($start_time){
+            return date("Y-m-d H:i",$start_time);
+        });
+        $grid->column('orderPack.end_time', __('结束时间'))->display(function ($end_time){
+            return date("Y-m-d H:i",$end_time);
+        });
+        $grid->column('orderPack.created_at', __('创建时间'));
+        $grid->column('orderPack.updated_at', __('更新时间'));
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Order::findOrFail($id));
+
+        $show->field('orderPack.id', __('Id'));
+        $show->field('orderPack.order_id', __('订单ID'));
+        $show->field('orderPack.service_pack_id', __('服务包ID'));
+        $show->field('orderPack.pack_name', __('服务包名称'));
+        $show->field('orderPack.pack_intro', __('服务包简介'));
+        $show->field('orderPack.pack_price', __('服务包价格'))->as(function ($price){
+            return $price/100;
+        });
+        $show->field('orderPack.insurance_policy', __('保单名称'));
+        $show->field('orderPack.insurance_img_url', __('保单图片链接'));
+        $show->field('orderPack.team_id', __('医生团队ID'));
+        $show->field('orderPack.phone_minutes', __('	电话分钟数'));
+        $show->field('orderPack.chat_num', __('图文咨询次数'));
+        $show->field('orderPack.appoint_num', __('门诊预约次数'));
+        $show->field('orderPack.vaccine_limit_amount', __('疫苗总金额限制'))->as(function ($price){
+            return $price/100;
+        });
+        $show->field('orderPack.nurses_limit_amount', __('儿保总金额限制'))->as(function ($price){
+            return $price/100;
+        });
+        $show->field('orderPack.effective_days', __('	有效天数'));
+        $show->field('orderPack.start_time', __('开始时间'))->as(function ($start_time){
+            return date("Y-m-d H:i",$start_time);
+        });
+        $show->field('orderPack.end_time', __('结束时间'))->as(function ($end_time){
+            return date("Y-m-d H:i",$end_time);
+        });
+        $show->field('orderPack.is_security', __('宝贝是否有医保'))
+            ->using([0=>'否',1=>'是']);
+        $show->field('orderPack.guardian_name', __('监护人姓名'));
+        $show->field('orderPack.relationship_type', __('与宝贝的关系'))
+            ->using([1=>'父亲',2=>'母亲',3=>'祖父',4=>'祖母',5=>'外祖父',6=>'外祖母',7=>'叔侄']);
+        $show->field('orderPack.created_at', __('创建时间'));
+        $show->field('orderPack.updated_at', __('更新时间'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Order());
+        return $form;
+    }
+}

+ 135 - 0
app/Admin/Controllers/UserManagement/DocterManagement/AppointController.php

xqd
@@ -0,0 +1,135 @@
+<?php
+
+namespace App\Admin\Controllers\UserManagement\DocterManagement;
+
+use App\Models\DocterSetting;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class AppointController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '门诊预约配置列表';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new DocterSetting());
+        $grid->disableCreateButton();
+        $grid->disableActions();
+        $grid->disableBatchActions();
+        $docter_id = request('docter_id');
+        $grid->model()->where('docter_id',$docter_id)->where('type',1);
+        $grid->column('id', __('Id'));
+        $grid->column('docter_id', __('医生id'));
+        $grid->column('docter.name', __('医生姓名'));
+        $grid->column('docter.avatar', __('医生头像'))->lightbox(['width' =>'', 'height' => 30]);
+        $grid->column('organization.name', __('机构名'));
+        $grid->column('type', __('类型'))->using([1=>'门诊预约']);
+        $grid->column('show_days', __('可预约天数'));
+        $grid->column('service_times', __('就诊时长'));
+        $grid->column('service_num', __('同时服务订单数'));
+        $grid->column('appoint_price', __('预约单价'));
+
+        $grid->column('am', __('上午服务时间'))->display(function (){
+            $service_time = DocterSetting::where('docter_id',$this->docter_id)->where('id',$this->id)->value('service_time');
+            $arr = json_decode($service_time);
+            $obj_arr = object_array($arr);
+            if (empty($obj_arr[1]))
+            {
+                return '无';
+            }else
+            {
+                $str = $obj_arr[1]['amStartTime'].'-'.$obj_arr[1]['amEndTime'];
+                return $str;
+            }
+        });
+        $grid->column('pm', __('下午服务时间'))->display(function (){
+            $service_time = DocterSetting::where('docter_id',$this->docter_id)->where('id',$this->id)->value('service_time');
+            $arr = json_decode($service_time);
+            $obj_arr = object_array($arr);
+            if (empty($obj_arr[2]))
+            {
+                return '无';
+            }else
+            {
+                $str = $obj_arr[2]['pmStartTime'].'-'.$obj_arr[2]['pmEndTime'];
+                return $str;
+            }
+        });
+        $grid->column('night', __('晚上服务时间'))->display(function (){
+            $service_time = DocterSetting::where('docter_id',$this->docter_id)->where('id',$this->id)->value('service_time');
+            $arr = json_decode($service_time);
+            $obj_arr = object_array($arr);
+            if (empty($obj_arr[3]))
+            {
+                return '无';
+            }else
+            {
+                $str = $obj_arr[3]['nightStartTime'].'-'.$obj_arr[3]['nightEndTime'];
+                return $str;
+            }
+        });
+        $grid->column('updated_at', __('更新时间'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(DocterSetting::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('docter_id', __('Docter id'));
+        $show->field('type', __('Type'));
+        $show->field('status', __('Status'));
+        $show->field('show_days', __('Show days'));
+        $show->field('service_times', __('Service times'));
+        $show->field('service_num', __('Service num'));
+        $show->field('org_id', __('Org id'));
+        $show->field('appoint_price', __('Appoint price'));
+        $show->field('service_time', __('Service time'));
+        $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 DocterSetting());
+
+        $form->number('docter_id', __('Docter id'));
+        $form->number('type', __('Type'));
+        $form->number('status', __('Status'));
+        $form->number('show_days', __('Show days'));
+        $form->number('service_times', __('Service times'));
+        $form->number('service_num', __('Service num'));
+        $form->number('org_id', __('Org id'));
+        $form->decimal('appoint_price', __('Appoint price'))->default(0.00);
+        $form->text('service_time', __('Service time'));
+
+        return $form;
+    }
+}

+ 144 - 0
app/Admin/Controllers/UserManagement/DocterManagement/ApproveController.php

xqd
@@ -0,0 +1,144 @@
+<?php
+
+namespace App\Admin\Controllers\UserManagement\DocterManagement;
+
+use App\Admin\Actions\backstage\Pass;
+use App\Admin\Actions\backstage\Refuse;
+use App\Admin\Actions\backstage\Revoke;
+use App\Models\Docter;
+use App\Models\DocterOrganization;
+use App\Models\Office;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class ApproveController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '认证列表';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+
+        $grid = new Grid(new DocterOrganization());
+        $grid->filter(function($filter){
+            $filter->between('authentication_time', '签约时间')->datetime();
+            $filter->between('authentication_end_time', '签约到期时间')->datetime();
+        });
+
+        $grid ->model()->where('state','>',0)->orderBy('id','desc');
+        $grid->column('id', __('Id'));
+        $grid->column('docter.id', __('医生ID'));
+        $grid->column('docter.name', __('医生姓名'));
+        $grid->column('docter.avatar', __('医生头像'))->lightbox(['width' =>'', 'height' => 30]);
+        $grid->column('docter.sex', __('性别'))->using([0=>'未知',1=>'男',2=>'女']);
+        $grid->column('organization.name', __('机构'));
+        $grid->column('office.name', __('科室'));
+        $grid->column('qualification.name', __('医生资质'));
+        $grid->column('remarks', __('备注'));
+        $grid->column('state', __('认证状态'))->using([1=>'已认证',2=>'审核驳回',3=>'待审核'])->label('info');
+        $grid->column('authentication_time', __('签约时间'))->display(function ($time){
+            if ($time == 0){
+                return '';
+            }else
+            {
+                return $time;
+            }
+        });
+        $grid->column('authentication_end_time', __('签约到期时间'))->display(function ($time){
+            if ($time == 0){
+                return '';
+            }else
+            {
+                return $time;
+            }
+        });
+        //禁用创建按钮
+        $grid->disableCreateButton();
+        $grid->actions(function ($actions) {
+            // 去掉删除
+            $actions->disableDelete();
+            // 去掉编辑
+            $actions->disableEdit();
+            // 去掉查看
+            $actions->disableView();
+            //待审核状态下 给通过和驳回
+            if ($actions->row->state == 3){
+                //通过申请
+                $actions->add(new Pass());
+                //驳回申请
+                $actions->add(new Refuse());
+            }
+            //已认证状态下 给撤销
+            if ($actions->row->state == 1){
+                $actions->add(new Revoke());
+            }
+            //驳回状态下 不给任何操作
+            if ($actions->row->state == 2){
+
+            }
+
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+
+        $show = new Show(DocterOrganization::findOrFail($id));
+        $show->field('id', __('Id'));
+        $show->field('docter.id', __('医生ID'));
+        $show->field('docter.name', __('名字'));
+        $show->field('docter.sex', __('性别'))->using([0=>'未知',1=>'男',2=>'女']);
+        $show->field('docter.card_id', __('身份证'));
+        $show->field('organization.name', __('机构'));
+        $show->field('office.name', __('科室'));
+        $show->field('qualification.name', __('医生资质'));
+//        $show->field('docter.card_photo', __('身份证正反面'))->as(function ($id){
+////            dd($id);
+//            $imgs = explode(',',$id);
+//            $html = '';
+//            foreach ($imgs as $val){
+//                $html .='img src="'.$val.'"';
+//            }
+//            return "<{$html}>";
+////            return json_decode($id,true);
+//        });
+        $show->field('docter.card_photo', __('身份证正反面'))->image();
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new DocterOrganization());
+
+        $form->number('docter_id', __('Docter id'));
+        $form->number('organization_id', __('Organization id'));
+        $form->number('offices_id', __('Offices id'));
+        $form->number('qualifications_id', __('Qualifications id'));
+        $form->number('state', __('State'));
+
+        return $form;
+    }
+}

+ 128 - 0
app/Admin/Controllers/UserManagement/DocterManagement/ChatController.php

xqd
@@ -0,0 +1,128 @@
+<?php
+
+namespace App\Admin\Controllers\UserManagement\DocterManagement;
+
+use App\Models\Docter;
+use App\Models\Doctertimes;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class ChatController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '图文服务配置列表';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Doctertimes());
+        $grid->disableCreateButton();
+        $grid->disableActions();
+        $grid->disableBatchActions();
+        $docter_id = request('docter_id');
+        $grid->model()->where('docter_id',$docter_id)->where('type',2);
+        $grid->column('id', __('Id'));
+        $grid->column('docter_id', __('医生id'));
+        $grid->column('docter.avatar', __('医生头像'))->lightbox(['width' =>'', 'height' => 30]);
+        $grid->column('docter.name', __('医生姓名'));
+        $grid->column('type', __('类型'))->using([1=>'电话咨询',2=>'图文咨询',3=>'门诊咨询',4=>'疫苗预约接种',5=>'儿保预约',6=>'服务包',7=>'充值']);
+        $grid->column('base_price', __('基础价格'));
+        $grid->column('am', __('上午服务时间'))->display(function (){
+            $service_time = Doctertimes::where('docter_id',$this->docter_id)->where('id',$this->id)->value('service_time');
+            $arr = json_decode($service_time);
+            $obj_arr = object_array($arr);
+            if (empty($obj_arr[1]))
+            {
+                return '无';
+            }else
+            {
+                $str = $obj_arr[1]['amStartTime'].'-'.$obj_arr[1]['amEndTime'];
+                return $str;
+            }
+        });
+        $grid->column('pm', __('下午服务时间'))->display(function (){
+            $service_time = Doctertimes::where('docter_id',$this->docter_id)->where('id',$this->id)->value('service_time');
+            $arr = json_decode($service_time);
+            $obj_arr = object_array($arr);
+            if (empty($obj_arr[2]))
+            {
+                return '无';
+            }else
+            {
+                $str = $obj_arr[2]['pmStartTime'].'-'.$obj_arr[2]['pmEndTime'];
+                return $str;
+            }
+        });
+        $grid->column('night', __('晚上服务时间'))->display(function (){
+            $service_time = Doctertimes::where('docter_id',$this->docter_id)->where('id',$this->id)->value('service_time');
+            $arr = json_decode($service_time);
+            $obj_arr = object_array($arr);
+            if (empty($obj_arr[3]))
+            {
+                return '无';
+            }else
+            {
+                $str = $obj_arr[3]['nightStartTime'].'-'.$obj_arr[3]['nightEndTime'];
+                return $str;
+            }
+        });
+        $grid->column('person', __('服务人数'));
+        $grid->column('updated_at', __('更新时间'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Doctertimes::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('docter_id', __('Docter id'));
+        $show->field('base_price', __('Base price'));
+        $show->field('step_price', __('Step price'));
+        $show->field('service_time', __('Service time'));
+        $show->field('person', __('Person'));
+        $show->field('type', __('Type'));
+        $show->field('relation_id', __('Relation id'));
+        $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 Doctertimes());
+
+        $form->number('docter_id', __('Docter id'));
+        $form->decimal('base_price', __('Base price'));
+        $form->decimal('step_price', __('Step price'));
+        $form->text('service_time', __('Service time'));
+        $form->number('person', __('Person'));
+        $form->number('type', __('Type'));
+        $form->number('relation_id', __('Relation id'));
+
+        return $form;
+    }
+}

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

xqd
@@ -0,0 +1,86 @@
+<?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->model()->orderBy('id','desc');
+        $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;
+    }
+}

+ 82 - 0
app/Admin/Controllers/UserManagement/DocterManagement/DocterTeamController.php

xqd
@@ -0,0 +1,82 @@
+<?php
+
+namespace App\Admin\Controllers\UserManagement\DocterManagement;
+
+use App\Models\TeamDocter;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class DocterTeamController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '团队管理';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new TeamDocter());
+
+        $docter_id = \request('docter_id');
+        $grid->filter(function ($filter){
+            $filter->disableIdFilter();
+            $filter->equal('docter_id','医生');
+        });
+        //关闭操作栏
+        $grid->disableActions();
+        $grid->model()->orderBy('id','desc');
+        $grid->column('id', __('Id'));
+        $grid->column('docter_id', __('医生id'));
+        $grid->column('docter.name', __('医生姓名'));
+        $grid->column('team_id', __('团队id'));
+        $grid->column('team.name', __('团队名称'));
+        $grid->column('team.introduction', __('团队简介'));
+        $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(TeamDocter::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('docter_id', __('Docter id'));
+        $show->field('team_id', __('Team id'));
+        $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 TeamDocter());
+
+        $form->number('docter_id', __('Docter id'));
+        $form->number('team_id', __('Team id'));
+
+        return $form;
+    }
+}

Some files were not shown because too many files changed in this diff