Quellcode durchsuchen

提交医生端

root vor 4 Jahren
Ursprung
Commit
8a4e8d3a77
71 geänderte Dateien mit 7424 neuen und 143 gelöschten Zeilen
  1. 0 0
      .htaccess
  2. 218 0
      app/Helpers/functions.php
  3. 11 0
      app/Http/Controllers/Api/V1/ArticleController.php
  4. 33 0
      app/Http/Controllers/Api/V2/ArticleController.php
  5. 22 0
      app/Http/Controllers/Api/V2/AuthController.php
  6. 45 0
      app/Http/Controllers/Api/V2/CallPhoneController.php
  7. 1124 0
      app/Http/Controllers/Api/V2/CommonController.php
  8. 118 0
      app/Http/Controllers/Api/V2/DocterMessageController.php
  9. 3112 0
      app/Http/Controllers/Api/V2/DoctorController.php
  10. 49 0
      app/Http/Controllers/Api/V2/NurseController.php
  11. 679 0
      app/Http/Controllers/Api/V2/PatientController.php
  12. 49 0
      app/Http/Controllers/Api/V2/PhoneCallController.php
  13. 45 0
      app/Http/Controllers/Api/V2/ServiceApplyController.php
  14. 159 0
      app/Http/Controllers/Api/V2/SuggestController.php
  15. 59 0
      app/Http/Controllers/Api/V2/UserController.php
  16. 18 0
      app/Models/Areas.php
  17. 16 0
      app/Models/Axb.php
  18. 21 0
      app/Models/CallLog.php
  19. 15 0
      app/Models/CallPhone.php
  20. 4 0
      app/Models/Collection.php
  21. 15 0
      app/Models/DocterLable.php
  22. 15 0
      app/Models/DocterMessage.php
  23. 28 0
      app/Models/DocterOrganization.php
  24. 14 0
      app/Models/DocterServiceTimes.php
  25. 19 0
      app/Models/DocterSetting.php
  26. 14 0
      app/Models/DocterTimes.php
  27. 39 0
      app/Models/DocterUser.php
  28. 15 0
      app/Models/ImMessage.php
  29. 17 0
      app/Models/Order.php
  30. 5 0
      app/Models/OrderPatient.php
  31. 4 0
      app/Models/Organization.php
  32. 1 0
      app/Models/Patient.php
  33. 1 1
      app/Models/Schedule.php
  34. 1 0
      app/Models/SchedulePeriod.php
  35. 15 0
      app/Models/SelfSchedule.php
  36. 15 0
      app/Models/ServiceApply.php
  37. 29 0
      app/Models/Suggest.php
  38. 16 0
      app/Models/SuggestDetail.php
  39. 16 0
      app/Models/SystemConfig.php
  40. 52 11
      app/Models/User.php
  41. 15 0
      app/Models/UserDocter.php
  42. 14 0
      app/Models/UserMessages.php
  43. 18 0
      app/Models/WeekSchedule.php
  44. 2 0
      composer.json
  45. 588 2
      composer.lock
  46. 1 1
      config/app.php
  47. 21 0
      config/config.php
  48. 0 56
      database/migrations/2016_01_04_173148_create_admin_tables.php
  49. 0 35
      database/migrations/2019_08_19_000000_create_failed_jobs_table.php
  50. 169 0
      database/migrations/2020_10_13_061605_docters.php
  51. 34 0
      database/migrations/2020_10_13_153716_create_suggests_detail_table.php
  52. 42 0
      database/migrations/2020_10_14_023006_alter_docters_table.php
  53. 34 0
      database/migrations/2020_10_15_062105_alter_orders_table.php
  54. 34 0
      database/migrations/2020_10_16_074031_alter_user_messages_table.php
  55. 38 0
      database/migrations/2020_10_16_081824_create_docter_messages_table.php
  56. 28 0
      database/migrations/2020_10_16_083459_alter_docter_messages_table.php
  57. 36 0
      database/migrations/2020_10_16_085317_create_call_logs_table.php
  58. 28 0
      database/migrations/2020_10_16_085827_alert_call_logs_table.php
  59. 39 0
      database/migrations/2020_10_17_100407_crete_docter_times.php
  60. 8 8
      database/migrations/2020_10_19_134219_after_user_table.php
  61. 64 0
      database/migrations/2020_11_03_070733_alert_cmdsuser_org_nurse_office_add_docter_verify.php
  62. 7 10
      database/migrations/2020_11_04_034904_docter_user.php
  63. 0 0
      nginx.htaccess
  64. 7 19
      public/.htaccess
  65. 1 0
      public/.user.ini
  66. 1 0
      public/.well-known/acme-challenge/0F7qTXwRYiBveiBMiqtQjyeDt3Mvp7Uv8uTSCR3xNqs
  67. 1 0
      public/.well-known/pki-validation/fileauth.txt
  68. 26 0
      public/404.html
  69. 39 0
      public/index.html
  70. 1 0
      public/newfile.txt
  71. 0 0
      public/nginx.htaccess

+ 0 - 0
.htaccess


+ 218 - 0
app/Helpers/functions.php

xqd xqd
@@ -47,6 +47,22 @@ if (!function_exists('trace')) {
     }
 }
 
+
+if (!function_exists('upDecimal')) {
+
+    /**
+     * 对价格进行向上取整
+     * @param $price    价格
+     * @param $decimal  保留小数位数
+     */
+    function upDecimal($price, $decimal = 2){
+        $data1 = pow(10, $decimal);
+        $data2 = ceil(bcmul($price, $data1,10));
+        $data3 = bcdiv($data2, $data1, $decimal);
+        return $data3;
+    }
+}
+
 //AES加密
 if (!function_exists('aes_encrypt')) {
     function aes_encrypt($data)
@@ -105,3 +121,205 @@ if (!function_exists('build_sn')) {
         return $sn;
     }
 }
+
+
+if (!function_exists('numBirthday')){
+    /**
+     * 生日转年龄
+     * @author Yuanhang Liu & Xiaoyun Liu
+     * @param $birthday 2020-10-14 00:48
+     * @return string
+     */
+    function numBirthday($birthday){
+
+        if ($birthday){
+            try {
+                list($year,$month,$day) = explode("-",$birthday);
+                $year_diff = (date("Y") - $year)>0?date("Y") - $year.'岁':'';
+                $month_diff = (date("m") - $month)>0?date("m") - $month.'个月':'';
+                $day_diff  = (date("d") - $day)>0?date("d") - $day.'天':'';
+                if ($day_diff < 0 || $month_diff < 0)
+                    $year_diff--;
+                return $year_diff.$month_diff.$day_diff ;
+            }catch (Exception $e){
+
+                return '';
+            }
+
+        }else{
+            return '';
+        }
+
+    }
+}
+if (!function_exists('getWeek')){
+    /**
+     * 获取当日周几
+     * @author Yuanhang Liu & Xiaoyun Liu
+     * @param $birthday 2020-10-14 00:48
+     * @return string
+     */
+    function getWeek($date){
+
+        $weekday= "今天是星期" . mb_substr( "日一二三四五六",$date,1,"utf-8" );
+        return $weekday ;
+    }
+}
+
+//发送短信
+if (!function_exists('send_sms')) {
+    function send_sms($phone, $templateKey, $templateParam = [])
+    {
+        $sms_config = config('config.aly_sms');
+        //是否启用https
+        $security = false;
+        $params = [];
+        $params["PhoneNumbers"] = $phone;
+        $params["SignName"] = $sms_config['sign_name'];
+        $params["TemplateCode"] = $sms_config[$templateKey];
+        $params['TemplateParam'] = $templateParam;
+
+        if (is_array($params["TemplateParam"])) {
+            $params["TemplateParam"] = json_encode($params["TemplateParam"], JSON_UNESCAPED_UNICODE);
+        }
+
+        $content = aly_sm_request(
+            $sms_config['access_key'],
+            $sms_config['access_secret'],
+            "dysmsapi.aliyuncs.com",
+            array_merge($params, array(
+                "RegionId" => "cn-hangzhou",
+                "Action" => "SendSms",
+                "Version" => "2017-05-25",
+            )),
+            $security
+        );
+
+        return $content;
+    }
+}
+
+if (!function_exists('aly_sm_request')) {
+    function aly_sm_request($accessKeyId, $accessKeySecret, $domain, $params, $security = false, $method = 'POST')
+    {
+        $apiParams = array_merge(array(
+            "SignatureMethod" => "HMAC-SHA1",
+            "SignatureNonce" => uniqid(mt_rand(0, 0xffff), true),
+            "SignatureVersion" => "1.0",
+            "AccessKeyId" => $accessKeyId,
+            "Timestamp" => gmdate("Y-m-d\TH:i:s\Z"),
+            "Format" => "JSON",
+        ), $params);
+        ksort($apiParams);
+
+        $sortedQueryStringTmp = "";
+        foreach ($apiParams as $key => $value) {
+            $sortedQueryStringTmp .= "&" . aly_sms_encode($key) . "=" . aly_sms_encode($value);
+        }
+
+        $stringToSign = "${method}&%2F&" . aly_sms_encode(substr($sortedQueryStringTmp, 1));
+
+        $sign = base64_encode(hash_hmac("sha1", $stringToSign, $accessKeySecret . "&", true));
+
+        $signature = aly_sms_encode($sign);
+
+        $url = ($security ? 'https' : 'http') . "://{$domain}/";
+
+        try {
+            $content = aly_sms_fetch_content($url, $method, "Signature={$signature}{$sortedQueryStringTmp}");
+            return json_decode($content);
+        } catch (\Exception $e) {
+            return false;
+        }
+    }
+}
+
+if (!function_exists('aly_sms_encode')) {
+    function aly_sms_encode($str)
+    {
+        $res = urlencode($str);
+        $res = preg_replace("/\+/", "%20", $res);
+        $res = preg_replace("/\*/", "%2A", $res);
+        $res = preg_replace("/%7E/", "~", $res);
+        return $res;
+    }
+}
+
+if (!function_exists('aly_sms_fetch_content')) {
+    function aly_sms_fetch_content($url, $method, $body)
+    {
+        $ch = curl_init();
+
+        if ($method == 'POST') {
+            curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
+            curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
+        } else {
+            $url .= '?' . $body;
+        }
+
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_TIMEOUT, 5);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
+            "x-sdk-client" => "php/2.0.0"
+        ));
+
+        if (substr($url, 0, 5) == 'https') {
+            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+        }
+
+        $rtn = curl_exec($ch);
+
+        if ($rtn === false) {
+            // 大多由设置等原因引起,一般无法保障后续逻辑正常执行,
+            // 所以这里触发的是E_USER_ERROR,会终止脚本执行,无法被try...catch捕获,需要用户排查环境、网络等故障
+            trigger_error("[CURL_" . curl_errno($ch) . "]: " . curl_error($ch), E_USER_ERROR);
+        }
+        curl_close($ch);
+        return $rtn;
+    }
+
+    if (!function_exists('getDateFromList')) {
+        /**
+         * 获取指定日期段内每一天的日期
+         * @param  Date  $startdate 开始日期
+         * @param  Date  $enddate   结束日期
+         * @return Array
+         */
+        function getDateFromList($start,$end){
+            $stimestamp = strtotime($start);
+            $etimestamp = strtotime($end);
+            // 计算日期段内有多少天
+            $days = ($etimestamp-$stimestamp)/86400+1;
+            // 保存每天日期
+            $arr = [];
+            for($i=0;$i<$days;$i++){
+                $arr[] = date('Y-m-d',$stimestamp+(86400*$i));
+            }
+            return $arr;
+
+
+        }
+
+    }
+
+    if (!function_exists('numDays')){
+        /**
+         * 计算日期到现在多天天
+         * @param $date
+         * @return float
+         */
+        function numDays($date){
+            $Date_List_a1=explode("-",date('Y-m-d',time()));
+            $Date_List_a2=explode("-",$date);
+            $d1=mktime(0,0,0,$Date_List_a1[1],$Date_List_a1[2],$Date_List_a1[0]);
+            $d2=mktime(0,0,0,$Date_List_a2[1],$Date_List_a2[2],$Date_List_a2[0]);
+            $Days=round(($d1-$d2)/3600/24);
+            return $Days;
+        }
+    }
+
+
+
+}

+ 11 - 0
app/Http/Controllers/Api/V1/ArticleController.php

xqd
@@ -12,8 +12,19 @@ use App\Models\Article;
 
 class ArticleController extends AuthController
 {
+    /**
+     * 不验证路由
+     * ArticleController constructor.
+     */
+    public function __construct()
+    {
+//        parent::__construct();
+        $this->middleware('auth:api', ['except' => ['articleList']]);
+
+    }
     public function articleList()
     {
+
         $data = Article::orderBy('id', 'desc')->paginate();
 
         return out($data);

+ 33 - 0
app/Http/Controllers/Api/V2/ArticleController.php

xqd
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-10-5
+ * Time: 下午3:40
+ */
+
+namespace App\Http\Controllers\Api\V2;
+
+use App\Models\Article;
+
+class ArticleController extends AuthController
+{
+    public function articleList()
+    {
+        $data = Article::orderBy('id', 'desc')->paginate();
+
+        return out($data);
+    }
+
+    public function articleDetail()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'article_id' => 'required|integer',
+        ]);
+
+        $data = Article::where('id', $req['article_id'])->first();
+
+        return out($data);
+    }
+}

+ 22 - 0
app/Http/Controllers/Api/V2/AuthController.php

xqd
@@ -0,0 +1,22 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-9-23
+ * Time: 上午11:34
+ */
+
+namespace App\Http\Controllers\Api\V2;
+
+use App\Http\Controllers\Controller;
+use App\Models\User;
+
+class AuthController extends Controller
+{
+    protected $user = null;
+
+    public function __construct()
+    {
+        $this->user = User::getUserByToken();
+    }
+}

+ 45 - 0
app/Http/Controllers/Api/V2/CallPhoneController.php

xqd
@@ -0,0 +1,45 @@
+<?php
+namespace App\Http\Controllers\Api\V2;
+use AlibabaCloud\Client\AlibabaCloud;
+use AlibabaCloud\Client\Exception\ClientException;
+use AlibabaCloud\Client\Exception\ServerException;
+
+/**
+ * 通话记录类(一期废弃)
+ * Class CallPhoneController
+ * @package App\Http\Controllers\Api\V2
+ */
+class CallPhoneController extends Controller
+{
+
+    public function BindAxb($phone1='',$phone2='',$data=[]){
+        var_dump('到我了!');die();
+        $config = config('config.axb');
+        AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
+            ->regionId('cn-kunming')
+            ->asDefaultClient();
+        try {
+            $result = AlibabaCloud::rpc()
+                ->product('Dyplsapi')
+                ->version('2017-05-25')
+                ->action('BindAxb')
+                ->method('POST')
+                ->host('dyplsapi.aliyuncs.com')
+                ->options([
+                    'query' => [
+                        "Expiration" => "2020-11-25 12:00:00",
+                        'RegionId' => "cn-kunming",
+                        'PhoneNoA' => "18831125321",
+                        'PhoneNoB' => "18830277213",
+                    ],
+                ])
+                ->request();
+            print_r($result->toArray());
+        } catch (ClientException $e) {
+            echo $e->getErrorMessage() . PHP_EOL;
+        } catch (ServerException $e) {
+            echo $e->getErrorMessage() . PHP_EOL;
+        }
+    }
+
+}

+ 1124 - 0
app/Http/Controllers/Api/V2/CommonController.php

xqd
@@ -0,0 +1,1124 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-9-23
+ * Time: 上午11:26
+ */
+
+namespace App\Http\Controllers\Api\V2;
+
+use App\Http\Controllers\Controller;
+use App\Models\Article;
+use App\Models\Order;
+use App\Models\User;
+use App\Models\Docter;
+use EasyWeChat\Factory;
+use http\Env\Request;
+use Illuminate\Support\Facades\DB;
+use AlibabaCloud\Client\Exception\ClientException;
+use Alibabaloud\Client\Exception\ServerException;
+use AlibabaCloud\Client\AlibabaCloud;
+use AlibabaCloud\Dybaseapi\MNS\Requests\BatchReceiveMessage;
+use AlibabaCloud\Dybaseapi\MNS\Requests\BatchDeleteMessage;
+use App\Models\CallLog;
+use App\Models\Axb;
+use App\Models\ImMessage;
+
+/**
+ * 公共方法类
+ * Class CommonController
+ * @package App\Http\Controllers\Api\V2
+ */
+class CommonController extends Controller
+{
+    public function wxLogin()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'wechat_code' => 'required',
+            'nickname|昵称' => 'max:50',
+            'avatar|头像' => 'url',
+            'latitude|纬度' => 'numeric',
+            'longitude|纬度' => 'numeric',
+        ]);
+        $app = Factory::miniProgram(config('config.wechat_small_program'));
+
+        $data = $app->auth->session($req['wechat_code']);
+
+        if (empty($data['openid'])){
+            return out(null, 10001, '微信登录code错误');
+        }
+
+        $session_key = !empty($data['session_key']) ? $data['session_key'] : '';
+
+        $user = User::select(['id', 'status', 'phone', 'nickname', 'avatar'])->where('openid', $data['openid'])->first();
+        if (empty($user)){
+            $user = User::create([
+                'openid' => $data['openid'],
+                'nickname' => $req['nickname'] ?? '',
+                'avatar' => $req['avatar'] ?? '',
+                'latitude' => $req['latitude'] ?? 0,
+                'longitude' => $req['longitude'] ?? 0,
+                'session_key' => $session_key
+            ]);
+        }
+        else {
+            if ($user['status'] == 0) {
+                return out(null, 10002, '该账号已被冻结');
+            }
+
+            User::where('id', $user['id'])->update([
+                'nickname' => $req['nickname'] ?? '',
+                'avatar' => $req['avatar'] ?? '',
+                'latitude' => $req['latitude'] ?? 0,
+                'longitude' => $req['longitude'] ?? 0,
+                'session_key' => $session_key
+            ]);
+        }
+        // 查询医生表有没有记录
+        $doct = User::where('openid',$data['openid'])->orderBy('id','desc')->first();
+
+        if ($doct['phone']!=''){
+            $list = Docter::where('phone',$doct['phone'])->orderBy('id','desc')->first();
+            if ($list){
+                if ($list['status'] == 0) {
+                    return out(null, 10002, '该账号已被冻结');
+                }
+                $datas = [
+                    'avatar' => $list['avatar'],
+                    'name' => $list['name'],
+                    'flag' => 'doctor_'.$list['id'],
+                ];
+                $token = aes_encrypt(['doctor_id' => $list['id'], 'time' => time()]);
+                return out(['token' => $token,'data'=>$datas]);
+            }else{
+                return out(['session_key'=>$session_key,'openid'=>$data['openid']]);
+            }
+        }else{
+            return out(['session_key'=>$session_key,'openid'=>$data['openid']]);
+        }
+    }
+
+    /**
+     * 获取手机号!
+     * Auth:Yuanhang-Liu
+     * Date:2020/10/18 17:17 *
+     * @return \Illuminate\Http\JsonResponse
+     */
+    public function getPhoneNumber(){
+        $req = request()->post();
+        $this->validate(request(), [
+            'iv' => 'required',
+            'encryptedData' => 'required',
+            'session_key' => 'required',
+            'openid' => 'required',
+        ]);
+
+        $app = Factory::miniProgram(config('config.wechat_small_program'));
+//        $data = $app->auth->session($req['code']);
+//        if (empty($data['openid'])){
+//            return out(null, 10001, '微信登录code错误');
+//        }
+        $session_key = !empty($req['session_key']) ? $req['session_key'] : '';
+        $user = User::select(['id','sex', 'status', 'phone', 'birthday','nickname', 'avatar','status'])->where('openid', $req['openid'])->first();
+        if (!$user){
+            return out(['status'=>false,'msg' => '用户不存在!']);
+        }
+
+
+        $decryptedData = $app->encryptor->decryptData($session_key, $req['iv'], $req['encryptedData']);
+        if (!isset($decryptedData['phoneNumber']) || empty($decryptedData['phoneNumber'])){
+            return out(['status'=>false,'msg' => '手机号解密失败!']);
+        }
+
+
+        $docter_list = [
+            'type' => 1,
+            'name' => $user['nickname'],
+            'phone' => $decryptedData['phoneNumber'],
+            'sex' => $user['sex'],
+            'birthday' => $user['birthday'],
+            'avatar' => $user['avatar'],
+            'status' => 1,
+            'label' => '无',
+            'sign' => '无',
+            'intro' => 0,
+            'office_id' => 0,
+            'qualification_id' => 0,
+            'score' => 0,
+            'service_persons' => 0,
+            'eva_num' => 0,
+            'service_days' => 0,
+            'phone_minutes' => 0,
+            'chat_price' => 0,
+            'phone_price' => 0,
+            'appoint_price' => 0,
+            'is_chat' => 0,
+            'is_phone' => 0,
+            'is_appoint' => 0,
+            'latitude' => 0,
+            'longitude' => 0,
+            'is_then' => 0,
+            'practice' => 0,
+            'card_photo' => 0,
+            'is_quail' => 0,
+            'card_id' => 0,
+        ];
+        // 查询医生表有没有记录
+        $doct = Docter::where('phone',$decryptedData['phoneNumber'])->orderBy('id','desc')->first();
+
+        if ($doct){
+            if ($doct['status'] == 0) {
+                return out(null, 10002, '该账号已被冻结');
+            }
+            $datas = [
+                'avatar' => $doct['avatar'],
+                'name' => $doct['name'],
+                'flag' => 'doctor_'.$doct['id'],
+            ];
+            $token = aes_encrypt(['doctor_id' => $doct['id'], 'time' => time()]);
+            return out(['token' => $token,'data'=>$datas]);
+        }
+        $list=[];
+        if ($user){
+            DB::beginTransaction();
+            try {
+                User::where('openid', $req['openid'])->update([
+                    'phone' => $decryptedData['phoneNumber'] ?? '','is_docter'=>1,
+                ]);
+                // 注册医生
+                $list = Docter::create($docter_list);
+                DB::commit();
+            }catch (\Exception $e){
+                DB::rollback();
+                return out(null, 500, $e->getMessage());
+            }catch (\PDOException $e){
+                DB::rollback();
+                return out(null, 500, $e->getMessage());
+            }
+        }
+
+        $datas = [
+            'avatar' => $list['avatar'],
+            'name' => $list['name'],
+            'flag' => 'doctor_'.$list['id'],
+        ];
+        $token = aes_encrypt(['doctor_id' => $list['id'], 'time' => time()]);
+        return out(['token' => $token,'data'=>$datas]);
+
+    }
+
+    /**
+     * 手机号登陆
+     * Auth:Yuanhang-Liu
+     * Date:2020/10/18 19:17 *
+     * @return \Illuminate\Http\JsonResponse
+     */
+    public function phoneLogin(){
+        $req = request()->post();
+        $this->validate(request(), [
+            'phone|手机号' => 'required|integer',
+        ]);
+        $req['verify'] = 0;
+        $find = Docter::where('phone','=',$req['phone'])->first();
+
+        if (empty($find)){
+            $docter_list = [
+                'type' => 1,
+                'name' => '用户名',
+                'phone' => $req['phone'],
+                'sex' => 0,
+                'birthday' => 0,
+                'avatar' => '../../static/login/moren.png',
+                'status' => 1,
+                'label' => '无',
+                'sign' => '无',
+                'intro' => 0,
+                'office_id' => 0,
+                'qualification_id' => 0,
+                'score' => 0,
+                'service_persons' => 0,
+                'eva_num' => 0,
+                'service_days' => 0,
+                'phone_minutes' => 0,
+                'chat_price' => 0,
+                'phone_price' => 0,
+                'appoint_price' => 0,
+                'is_chat' => 0,
+                'is_phone' => 0,
+                'is_appoint' => 0,
+                'latitude' => 0,
+                'longitude' => 0,
+                'is_then' => 0,
+                'practice' => 0,
+                'card_photo' => 0,
+                'is_quail' => 0,
+                'card_id' => 0,
+            ];
+            $list = Docter::create($docter_list)->toArray();
+            if (!empty($list)){
+                $datas = [
+                    'avatar' => $list['avatar'],
+                    'name' => $list['name'],
+                    'flag' => 'doctor_'.$list['id'],
+                ];
+                $token = aes_encrypt(['doctor_id' => $list['id'], 'time' => time()]);
+                return out(['token' => $token,'data'=>$datas]);
+            }else{
+                return out('',401,'用户不存在,注册失败!');
+            }
+        }
+
+        $find = $find->toArray();
+        if ($find['status'] == 0) {
+            return out(null, 10002, '该账号已被冻结');
+        }
+        if ($req['verify']==0){
+            $datas = [
+                'avatar' => $find['avatar'],
+                'name' => $find['name'],
+                'flag' => 'doctor_'.$find['id'],
+            ];
+            // 验证是否正确
+            $token = aes_encrypt(['doctor_id' => $find['id'], 'time' => time()]);
+            return out(['token' => $token,'data'=>$datas]);
+        }else{
+            return out(null, 401, '验证码错误');
+
+        }
+
+    }
+
+    /**
+     * 账号密码登陆
+     * Auth:Yuanhang-Liu
+     * Date:2020/10/18 19:17 *
+     * @return \Illuminate\Http\JsonResponse
+     */
+    public function passLogin(){
+        $req = request()->post();
+        $this->validate(request(), [
+            'phone|手机号' => 'required|integer',
+            'password|密码' => 'required',
+        ]);
+        $find = Docter::where('phone','=',$req['phone'])->first();
+        if (empty($find)){
+            return out(null, 401, '账号不存在');
+        }
+        if ($find['status'] == 0) {
+            return out(null, 10002, '该账号已被冻结');
+        }
+        $find = $find->toArray();
+        // 验证密码
+        $password = md5(md5(md5($req['password'])));
+        if ($password==$find['password']){
+
+            $datas = [
+                'avatar' => $find['avatar'],
+                'name' => $find['name'],
+                'flag' => 'doctor_'.$find['id'],
+            ];
+            $token = aes_encrypt(['doctor_id' => $find['id'], 'time' => time()]);
+
+            return out(['token' => $token,'data'=>$datas]);
+        }else{
+                return out(null, 401, '密码错误');
+        }
+    }
+
+    /**
+     * 获取验证码
+     * @return \Illuminate\Http\JsonResponse
+     * @author Liu-Yh
+     * Create By 2020/11/6 10:45
+     */
+    public function putverfiy(){
+        $req = request()->post();
+        $this->validate(request(), [
+            'phone|手机号' => 'required|integer',
+        ]);
+        $mobile =$req['phone']; //获取传入的手机号
+        $num = rand(1000,9999);   //随机产生四位数字的验证码
+        $verify_code = $num;
+        $texts = send_sms($mobile,'verify_template_code',['code'=>$verify_code]);
+        if ($texts->Message=='OK'){
+            return out($num);
+        }else{
+            return out('',500,'发送验证码错误');
+        }
+    }
+
+    /**
+     * 手机号注册
+     * Auth:Yuanhang-Liu
+     * Date:2020/10/18 20:17 *
+     * @return \Illuminate\Http\JsonResponse
+     */
+    public function phoneRegister(){
+        $req = request()->post();
+        $this->validate(request(), [
+            'phone|手机号' => 'required|integer',
+            'password|密码' => 'required',
+        ]);
+
+        // 查询是否注册过!
+        $docters = Docter::where('phone','=',$req['phone'])->first();
+
+        if (!empty($docters)){
+            return out('',500,'此手机号已被注册!');
+        }
+
+        $password = md5(md5(md5($req['password'])));
+        $docter_list = [
+            'type' => 1,
+            'name' => '用户名',
+            'phone' => $req['phone'],
+            'sex' => 0,
+            'birthday' => 0,
+            'avatar' => '无',
+            'status' => 1,
+            'label' => '无',
+            'sign' => '',
+            'intro' => '',
+            'office_id' => 0,
+            'qualification_id' => 0,
+            'score' => 0,
+            'service_persons' => 0,
+            'eva_num' => 0,
+            'service_days' => 0,
+            'phone_minutes' => 0,
+            'chat_price' => 0,
+            'phone_price' => 0,
+            'appoint_price' => 0,
+            'is_chat' => 0,
+            'is_phone' => 0,
+            'is_appoint' => 0,
+            'latitude' => 0,
+            'longitude' => 0,
+            'password' => $password,
+            'is_then' => 0,
+            'practice' => 0,
+            'card_photo' => 0,
+            'is_quail' => 0,
+            'card_id' => 0,
+        ];
+        $list = Docter::create($docter_list)->toArray();
+        if (!empty($list)){
+
+            $datas = [
+                'avatar' => $list['avatar'],
+                'name' => $list['name'],
+                'flag' => 'doctor_'.$list['id'],
+            ];
+            $token = aes_encrypt(['doctor_id' => $list['id'], 'time' => time()]);
+            return out(['token' => $token,'data'=>$datas]);
+        }else{
+            return out('',500,'注册失败!');
+        }
+
+//        return out();
+    }
+
+    public function articleList()
+    {
+        $data = Article::orderBy('id', 'desc')->paginate();
+
+        return out($data);
+    }
+
+    public function getUserIdByDoctorId($phone=null){
+        $list = Docter::where('phone', $phone)->first();
+        if ($list){
+            return $list->id;
+        }else{
+            return false;
+        }
+    }
+
+    public function uploadFile()
+    {
+        $file = request()->file('file');
+        if (empty($file)) {
+            return out(null, 10001, '文件不能为空');
+        }
+
+        $path = $file->store('uploads/'.date('Ymd'));
+//        $url = request()->getScheme().'://'.request()->getHost().'/'.$path;
+
+        return out(['url' => $path]);
+    }
+
+    public function doc()
+    {
+        $database = env('DB_DATABASE');
+        $prefix = env('DB_PREFIX');
+        $exclude_tables = "'bm_password_resets','bm_admin_menu','bm_admin_users','bm_failed_jobs','bm_migrations'";
+
+        $sql = "select TABLE_NAME name,TABLE_COMMENT comment from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='".$database."' and TABLE_NAME not in (".$exclude_tables.")";
+        $tables = \DB::select($sql);
+        $map1 = $map2 = [];
+        $i = round(count($tables)/2);
+        foreach ($tables as $k => $v) {
+            $name = str_replace($prefix, '', $v->name);
+            if ($k >= $i) {
+                $map1[$v->name] = $name.'('.$v->comment.')';
+            }
+            else {
+                $map2[$v->name] = $name.'('.$v->comment.')';
+            }
+        }
+
+        $data1 = [];
+        foreach ($map1 as $k => $v){
+            $sql = "select COLUMN_NAME name, DATA_TYPE type, COLUMN_COMMENT comment from INFORMATION_SCHEMA.COLUMNS where table_schema = '".$database."' AND table_name = '".$k."'";
+            $comment = \DB::select($sql);
+            $data1[$v] = $comment;
+        }
+
+        $data2 = [];
+        foreach ($map2 as $k => $v){
+            $sql = "select COLUMN_NAME name, DATA_TYPE type, COLUMN_COMMENT comment from INFORMATION_SCHEMA.COLUMNS where table_schema = '".$database."' AND table_name = '".$k."'";
+            $comment = \DB::select($sql);
+            $data2[$v] = $comment;
+        }
+
+        return view('doc', ['data1' => $data1, 'data2' => $data2]);
+    }
+
+
+    /**
+     * 绑定号码池子
+     * @param string $phone1 医生id
+     * @param string $phone2 用户id
+     * @param array $data 参数
+     * @return mixed
+     */
+    public function BindAxb($phone1,$phone2,$data=[]){
+        $config = config('config.axb');
+        AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
+            ->regionId('cn-kunming')
+            ->asDefaultClient();
+        try {
+            $result = AlibabaCloud::rpc()
+                ->product('Dyplsapi')
+                ->version('2017-05-25')
+                ->action('BindAxb')
+                ->method('POST')
+                ->host('dyplsapi.aliyuncs.com')
+                ->options([
+                    'query' => [
+                        "Expiration" => date("Y-m-d H:i:s",strtotime("+1 day")),
+                        'RegionId' => "cn-kunming",
+                        'PhoneNoA' => $phone1,
+                        'PhoneNoB' => $phone2,
+                    ],
+                ])
+                ->request();
+            return $result->toArray();
+        } catch (ClientException $e) {
+            echo $e->getErrorMessage() . PHP_EOL;
+        } catch (ServerException $e) {
+            echo $e->getErrorMessage() . PHP_EOL;
+        }
+    }
+
+    /**
+     * 释放虚拟号码
+     * @param int $phone
+     */
+    public function ReleaseSecretNo($phone){
+        $config = config('config.axb');
+        AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
+            ->regionId('cn-kunming')
+            ->asDefaultClient();
+
+        try {
+            $result = AlibabaCloud::rpc()
+                ->product('Dyplsapi')
+                // ->scheme('https') // https | http
+                ->version('2017-05-25')
+                ->action('ReleaseSecretNo')
+                ->method('POST')
+                ->host('dyplsapi.aliyuncs.com')
+                ->options([
+                    'query' => [
+                        'RegionId' => "cn-kunming",
+                        "SecretNo" => $phone,
+                        "PoolKey" => $config['PoolKey'],
+                    ],
+                ])
+                ->request();
+            $res = $result->toArray();
+           return $res;
+
+        } catch (ClientException $e) {
+            echo $e->getErrorMessage() . PHP_EOL;
+        } catch (ServerException $e) {
+            echo $e->getErrorMessage() . PHP_EOL;
+        }
+    }
+
+
+    /**
+     * 查询号码关系
+     * @param $phone
+     * @return mixed
+     */
+    public function QuerySubscriptionDetail($phone,$SubsId){
+        $config = config('config.axb');
+        AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
+            ->regionId('cn-kunming')
+            ->asDefaultClient();
+
+        try {
+
+            $result = AlibabaCloud::rpc()
+                ->product('Dyplsapi')
+                // ->scheme('https') // https | http
+                ->version('2017-05-25')
+                ->action('QuerySubscriptionDetail')
+                ->method('POST')
+                ->host('dyplsapi.aliyuncs.com')
+                ->options([
+                    'query' => [
+                        'RegionId' => "cn-hangzhou",
+                        "PoolKey" => $config['PoolKey'],
+                        "SubsId" => $SubsId,
+                        "PhoneNoX" => $phone,
+
+                    ],
+                ])
+                ->request();
+
+            $res = $result->toArray();
+           return $res;
+
+        } catch (ClientException $e) {
+            echo $e->getErrorMessage() . PHP_EOL;
+        } catch (ServerException $e) {
+            echo $e->getErrorMessage() . PHP_EOL;
+        }
+    }
+
+
+    /**
+     * 解除绑定关系
+     * @param $phone
+     * @return mixed
+     */
+    public function UnbindSubscription($phone,$subId){
+        $config = config('config.axb');
+        AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
+            ->regionId('cn-kunming')
+            ->asDefaultClient();
+        try {
+            $result = AlibabaCloud::rpc()
+                ->product('Dyplsapi')
+                // ->scheme('https') // https | http
+                ->version('2017-05-25')
+                ->action('UnbindSubscription')
+                ->method('POST')
+                ->host('dyplsapi.aliyuncs.com')
+                ->options([
+                    'query' => [
+                        'RegionId' => "cn-kunming",
+                        'SubsId' => $subId,
+                        "SecretNo" => $phone,
+                        "PoolKey" => $config['PoolKey'],
+                    ],
+                ])
+                ->request();
+            $res = $result->toArray();
+            return $res;
+        } catch (ClientException $e) {
+            echo $e->getErrorMessage() . PHP_EOL;
+        } catch (ServerException $e) {
+            echo $e->getErrorMessage() . PHP_EOL;
+        }
+    }
+
+
+    /**
+     * 调用接口QuerySubsId查询绑定唯一标识SubsId
+     * @param $phone X号码
+     * @return mixed
+     */
+    public function QuerySubsId($phone){
+        $config = config('config.axb');
+        AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
+            ->regionId('cn-kunming')
+            ->asDefaultClient();
+        try {
+            $result = AlibabaCloud::rpc()
+                ->product('Dyplsapi')
+                // ->scheme('https') // https | http
+                ->version('2017-05-25')
+                ->action('QuerySubsId')
+                ->method('POST')
+                ->host('dyplsapi.aliyuncs.com')
+                ->options([
+                    'query' => [
+                        'RegionId' => "cn-hangzhou",
+                        'Action' => "QuerySubsId",
+                        "PhoneNoX" => $phone,
+                        "PoolKey" => $config['PoolKey'],
+                    ],
+                ])
+                ->request();
+            $res = $result->toArray();
+            return $res;
+        } catch (ClientException $e) {
+            echo $e->getErrorMessage() . PHP_EOL;
+        } catch (ServerException $e) {
+            echo $e->getErrorMessage() . PHP_EOL;
+        }
+    }
+
+
+    /**
+     * 解锁号码
+     * @return \Illuminate\Http\JsonResponse
+     * @author Liu-Yh
+     * Create By 2020/11/25 18:36
+     */
+    public function unLokPhone($phone,$SubsId){
+        $unlok = $this->UnbindSubscription($phone,$SubsId);
+        if ($unlok['Code']!='OK'){
+            return out($unlok);
+        }else{
+            return 1;
+        }
+    }
+
+    /**
+     * 测试解除绑定电话的方法
+     */
+    public function testunlockphone(){
+        $phone = 17052201940;
+        $sub_id = 1000027059330181;
+        var_dump($this->unLokPhone($phone,$sub_id));
+
+    }
+
+    /**
+     * 调用接口QueryCallStatus查询呼叫状态。
+     * @param $phone
+     * @author Liu-Yh
+     * Create By 2020/11/26 10:51
+     */
+    public function QueryCallStatus($phone,$SubsId){
+        $config = config('config.axb');
+        AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
+            ->regionId('cn-kunming')
+            ->asDefaultClient();
+        try {
+            $result = AlibabaCloud::rpc()
+                ->product('Dyplsapi')
+                // ->scheme('https') // https | http
+                ->version('2017-05-25')
+                ->action('QueryCallStatus')
+                ->method('POST')
+                ->host('dyplsapi.aliyuncs.com')
+                ->options([
+                    'query' => [
+                        'RegionId' => "cn-hangzhou",
+                        "PoolKey" => $config['PoolKey'],
+                        "SubsId" => $SubsId,
+                    ],
+                ])
+                ->request();
+            $res = $result->toArray();
+            return $res;
+        } catch (ClientException $e) {
+            echo $e->getErrorMessage() . PHP_EOL;
+        } catch (ServerException $e) {
+            echo $e->getErrorMessage() . PHP_EOL;
+        }
+
+    }
+
+
+    /**
+     * 接收通话发起时的通话记录报告内容,可以在呼叫发起时立即获取到通话记录信息,包括通话开始时间、主被叫号码等,便于平台进行预判处理
+     * @author Liu-Yh
+     * Create By 2020/11/25 14:44
+     */
+    public function StartSecretReport(){
+        $config = config('config.axb');
+        AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
+            ->regionId('cn-kunming')
+            ->asDefaultClient();
+        $queueName = $config['StartReport']; // 队列名称
+        $messageType = "SecretStartReport"; // 需要接收的消息类型
+        $response = null;
+        $token = null;
+        $i = 0;
+        do {
+            try {
+                if (null == $token || strtotime($token['ExpireTime']) - time() > 2 * 60) {
+                    $response = AlibabaCloud::rpcRequest()
+                        ->product('Dybaseapi')
+                        ->version('2017-05-25')
+                        ->action('QueryTokenForMnsQueue')
+                        ->method('POST')
+                        ->host("dybaseapi.aliyuncs.com")
+                        ->options([
+                            'query' => [
+                                'MessageType' => $messageType,
+                                'QueueName' => $queueName,
+                            ],
+                        ])
+                        ->request()
+                        ->toArray();
+                }
+                $token = $response['MessageTokenDTO'];
+                $mnsClient = new \AlibabaCloud\Dybaseapi\MNS\MnsClient(
+                    "http://1943695596114318.mns.cn-hangzhou.aliyuncs.com",
+                    $token['AccessKeyId'],
+                    $token['AccessKeySecret'],
+                    $token['SecurityToken']
+                );
+                $mnsRequest = new BatchReceiveMessage(10, 5);
+                $mnsRequest->setQueueName($queueName);
+                $mnsResponse = $mnsClient->sendRequest($mnsRequest);
+                $receiptHandles = Array();
+                foreach ($mnsResponse->Message as $message) {
+                    // 用户逻辑:
+                    // 入库
+//                    var_dump(base64_decode($message->MessageBody));
+//                    var_dump(json_decode(base64_decode($message->MessageBody),true));
+
+//                    $receiptHandles[] = $message->ReceiptHandle; // 加入$receiptHandles数组中的记录将会被删除
+                    $messageBody = json_decode(base64_decode($message->MessageBody),true); // base64解码后的JSON字符串
+                    echo "进来了";
+
+                    var_dump($messageBody);
+                }
+
+                if (count($receiptHandles) > 0) {
+                    $deleteRequest = new BatchDeleteMessage($queueName, $receiptHandles);
+                    $mnsClient->sendRequest($deleteRequest);
+                }
+            } catch (ClientException $e) {
+                echo $e->getErrorMessage() . PHP_EOL;
+            } catch (ServerException $e) {
+                if ($e->getCode() == 404) {
+                    $i++;
+                }
+                echo $e->getErrorMessage() . PHP_EOL;
+            }
+        } while ($i < 3);
+    }
+
+
+
+    /**
+     * 接收通话结束时的通话记录报告内容,可以在呼叫结束后获取通话记录信息,包括通话开始时间、通话结束时间、主被叫号码等,
+     * @author Liu-Yh
+     * Create By 2020/11/25 12:29
+     */
+    public function SecretPullReport(){
+        $config = config('config.axb');
+        AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
+            ->regionId('cn-kunming')
+            ->asDefaultClient();
+        $queueName = $config['Report']; // 队列名称
+        $messageType = "SecretReport"; // 需要接收的消息类型
+        $response = null;
+        $token = null;
+        $i = 0;
+        do {
+            try {
+                if (null == $token || strtotime($token['ExpireTime']) - time() > 2 * 60) {
+                    $response = AlibabaCloud::rpcRequest()
+                        ->product('Dybaseapi')
+                        ->version('2017-05-25')
+                        ->action('QueryTokenForMnsQueue')
+                        ->method('POST')
+                        ->host("dybaseapi.aliyuncs.com")
+                        ->options([
+                            'query' => [
+                                'MessageType' => $messageType,
+                                'QueueName' => $queueName,
+                            ],
+                        ])
+                        ->request()
+                        ->toArray();
+                }
+                $token = $response['MessageTokenDTO'];
+                $mnsClient = new \AlibabaCloud\Dybaseapi\MNS\MnsClient(
+                    "http://1943695596114318.mns.cn-hangzhou.aliyuncs.com",
+                    $token['AccessKeyId'],
+                    $token['AccessKeySecret'],
+                    $token['SecurityToken']
+                );
+                $mnsRequest = new BatchReceiveMessage(10, 5);
+                $mnsRequest->setQueueName($queueName);
+                $mnsResponse = $mnsClient->sendRequest($mnsRequest);
+                $receiptHandles = Array();
+                $getList = CallLog::get();
+                if ($getList){
+                    $getList = $getList->toArray();
+                }
+                $msgs = $mnsResponse->Message;
+                if (!is_array($msgs)){
+                    $messageBody = json_decode(base64_decode($msgs->MessageBody),true); // base64解码后的JSON字符
+                    if (count($getList)==0){
+                        CallLog::create([
+                            'call_time'=>$messageBody['call_time'],
+                            'ring_time'=>$messageBody['release_time'],
+                            'release_dir'=>$messageBody['release_dir'],
+                            'call_type'=>$messageBody['call_type'],
+                            'aphone'=>$messageBody['phone_no'],
+                            'bphone'=>$messageBody['peer_no'],
+                            'call_id'=>$messageBody['call_id'],
+                            'secret_no'=>$messageBody['secret_no'],
+                            'sub_id'=>$messageBody['sub_id'],
+                            'talk_time'=> strtotime($messageBody['release_time'])-strtotime($messageBody['start_time']),
+                        ]);
+                    }else{
+                        foreach ($getList as $k=>$v){
+                            if ($v['call_id']==$messageBody['call_id']){
+                                unset($messageBody);
+                            }else{
+                                CallLog::create([
+                                    'call_time'=>$messageBody['call_time'],
+                                    'ring_time'=>$messageBody['release_time'],
+                                    'release_dir'=>$messageBody['release_dir'],
+                                    'call_type'=>$messageBody['call_type'],
+                                    'aphone'=>$messageBody['phone_no'],
+                                    'bphone'=>$messageBody['peer_no'],
+                                    'call_id'=>$messageBody['call_id'],
+                                    'secret_no'=>$messageBody['secret_no'],
+                                    'sub_id'=>$messageBody['sub_id'],
+                                    'talk_time'=> strtotime($messageBody['release_time'])-strtotime($messageBody['start_time']),
+                                ]);
+                            }
+                        }
+                    }
+                }else{
+                    foreach ($msgs as $message) {
+                        // 用户逻辑:
+                        $messageBody = json_decode(base64_decode($message->MessageBody),true); // base64解码后的JSON字符串
+                        if (count($getList)==0) {
+                            CallLog::create([
+                                'call_time'=>$messageBody['call_time'],
+                                'ring_time'=>$messageBody['release_time'],
+                                'release_dir'=>$messageBody['release_dir'],
+                                'call_type'=>$messageBody['call_type'],
+                                'aphone'=>$messageBody['phone_no'],
+                                'bphone'=>$messageBody['peer_no'],
+                                'call_id'=>$messageBody['call_id'],
+                                'secret_no'=>$messageBody['secret_no'],
+                                'sub_id'=>$messageBody['sub_id'],
+                                'talk_time'=> strtotime($messageBody['release_time'])-strtotime($messageBody['start_time']),
+                            ]);
+                        }else{
+                            foreach ($getList as $k=>$v){
+                                if ($v['call_id']==$messageBody['call_id']){
+                                    unset($messageBody);
+                                }else{
+                                    CallLog::create([
+                                        'call_time'=>$messageBody['call_time'],
+                                        'ring_time'=>$messageBody['release_time'],
+                                        'release_dir'=>$messageBody['release_dir'],
+                                        'call_type'=>$messageBody['call_type'],
+                                        'aphone'=>$messageBody['phone_no'],
+                                        'bphone'=>$messageBody['peer_no'],
+                                        'call_id'=>$messageBody['call_id'],
+                                        'secret_no'=>$messageBody['secret_no'],
+                                        'sub_id'=>$messageBody['sub_id'],
+                                        'talk_time'=> strtotime($messageBody['release_time'])-strtotime($messageBody['start_time']),
+                                    ]);
+                                }
+                            }
+                        }
+                     $receiptHandles[] = $message->ReceiptHandle; // 加入$receiptHandles数组中的记录将会被删除
+                    }
+                }
+                if (count($receiptHandles) > 0) {
+                    $deleteRequest = new BatchDeleteMessage($queueName, $receiptHandles);
+                    $mnsClient->sendRequest($deleteRequest);
+                }
+            } catch (ClientException $e) {
+                echo $e->getErrorMessage() . PHP_EOL;
+            } catch (ServerException $e) {
+                if ($e->getCode() == 404) {
+                    $i++;
+                }
+                echo $e->getErrorMessage() . PHP_EOL;
+            }
+        } while ($i < 3);
+
+    }
+
+
+
+
+    /**
+     * 通话开始时候回调数据
+     * @return false|string
+     * 返回参数
+     * [{
+        "phone_no": "18831138292",
+        "pool_key": "FC100000115024469", 对应的号池Key。
+        "city": "昆明",
+        "sub_id": 1000027052283144,  	通话对应的三元组的绑定关系ID。
+        "unconnected_cause": 0,
+        "call_time": "2020-12-21 17:23:56",  主叫拨打时间。
+        "peer_no": "15222021008",             AXB中的B号码或者N号码。
+        "called_display_no": "17052201941",   被叫显号X号码
+        "call_id": "31343639616333323735",  	唯一标识一通通话记录的ID。
+        "partner_key": "FC100000115024469",
+        "control_msg": "OK",
+        "id": 1007221453890,
+        "secret_no": "17052201941",
+        "call_type": 0,0:主叫(phone_no打给peer_no);1:被叫(peer_no打给phone_no);2:短信发送;3:短信接收;4:呼叫拦截;5:短信收发拦截;
+        "control_type": "CONTINUE"
+      }]
+     */
+    public function SecretStartReport(){
+        // 开始json
+        $req = request()->post();
+        // 首先创建记录
+        try {
+            $data = [];
+            $data['call_time'] = $req[0]['call_time'];
+            $data['call_type'] = $req[0]['call_type'];
+            $data['aphone'] = $req[0]['phone_no'];
+            $data['bphone'] = $req[0]['peer_no'];
+            $data['call_id'] = $req[0]['call_id'];
+            $data['secret_no'] = $req[0]['called_display_no'];
+            $data['sub_id'] = $req[0]['sub_id'];
+            CallLog::create($data);
+        }catch (\Exception $e){
+            var_dump($e->getFile().$e->getLine().$e->getMessage());
+
+        }catch (\PDOException $e){
+            var_dump($e->getFile().$e->getLine().$e->getMessage());
+        }
+
+        return json_encode(['code'=>0,'msg'=>"成功"],JSON_UNESCAPED_UNICODE);
+    }
+
+
+    /**
+     * 电话挂断时候回调数据!
+     * @return false|string
+     * 回调数据
+     * [{
+        "phone_no": "18831138292",              主叫号码
+        "pool_key": "FC100000115024469",        对应的号池Key。
+        "city": "昆明",
+        "sub_id": 1000027052283144, 	        通话对应的三元组的绑定关系ID。
+        "unconnected_cause": 0,                 0表示正常通话,1表示黑名单拦截,2表示无绑定关系,3表示呼叫限制,4表示其他
+        "call_time": "2020-12-21 17:23:56",     主叫拨打时间
+        "call_out_time": "2020-12-21 17:23:56", 呼叫由X送给B端局的时间
+        "peer_no": "15222021008",               AXB中的B号码或者N号码
+        "called_display_no": "17052201941",     被叫显号
+        "release_dir": 2,                       通话释放方向。0表示平台释放,1表示主叫挂断,2表示被叫挂断
+        "ring_time": "2020-12-21 17:23:56",     呼叫送被叫端局时,被叫端局响应的时间。
+        "call_id": "31343639616333323735",  	唯一标识一通通话记录的ID。
+        "start_time": "2020-12-21 17:24:05",    被叫接听时间
+        "free_ring_time": "2020-12-21 17:24:03",被叫手机真实的振铃时间。free_ring_time 大于call_out_time表示被叫真实发生了振铃事件。free_ring_time 和call_out_time相等表示未振铃。
+        "partner_key": "FC100000115024469",
+        "control_msg": "OK",
+        "id": 1007221453890,
+        "secret_no": "17052201941",             AXB中的X号码
+        "call_type": 0,                         呼叫类型,包括:0:主叫,即phone_no打给peer_no。1:被叫,即peer_no打给phone_no。2:短信发送。3:短信接收。4:呼叫拦截5:短信收发拦截
+        "release_cause": 16,                    释放原因。请根据编号在释放原因中查看。
+        "control_type": "CONTINUE",
+        "release_time": "2020-12-21 17:24:09"   被叫挂断时间。release_time和start_time之差表示通话时长, 如果结果为0,说明呼叫未接通
+        }]
+     *
+     */
+    public function SecretReport(){
+        $req = request()->post();
+        $callids = CallLog::where('call_id',$req[0]['call_id'])->first();
+        try {
+            if ($callids){
+                if($req[0]['release_dir']==0||(strtotime($req[0]['release_time'])-strtotime($req[0]['start_time']))==0||$req[0]['unconnected_cause']!=0){
+                    CallLog::where('call_id',$req[0]['call_id'])->delete();
+                }else{
+                    // 修改信息
+                    $axbId = Axb::where(['xphone'=>$req[0]['called_display_no'],'subs_id'=>$req[0]['sub_id']])->first();
+                    if($axbId){
+                        $where['docter_id'] = $axbId['docter_id'];
+                        $where['user_id'] = $axbId['user_id'];
+                        $where['product_type'] =1;
+                        $where['order_status'] =3;
+                        $where['payment_status'] =2;
+                        $order_id = Order::where($where)->first();
+                        if ($order_id){
+                            $order_id = $order_id->id;
+                            $save_data = [];
+                            $save_data['order_id'] = $order_id;
+                            $save_data['ring_time'] = $req[0]['release_time'];
+                            $save_data['docter_id'] = $axbId['docter_id'];
+                            $save_data['release_dir'] = $req[0]['release_dir'];
+                            $save_data['talk_time'] = strtotime($req[0]['release_time'])-strtotime($req[0]['start_time']);
+                            $save_data['text'] = json_encode($req,JSON_UNESCAPED_UNICODE);
+                            // 解除号码绑定,并且删除数据库绑定信息
+                            $this->unLokPhone($req[0]['called_display_no'],$req[0]['sub_id']);
+                            Axb::where(['subs_id'=>$req[0]['sub_id']])->delete();
+                            CallLog::where('call_id',$req[0]['call_id'])->update($save_data);
+                            return json_encode(['code'=>0,'msg'=>"成功"],JSON_UNESCAPED_UNICODE);
+                        }
+                    }
+                }
+            }
+
+        }catch (\Exception $e){
+            CallLog::create(['text'=>json_encode($e->getFile().$e->getCode().$e->getMessage(),JSON_UNESCAPED_UNICODE)]);
+        }catch (\PDOException $e){
+            CallLog::create(['text'=>json_encode($e->getFile().$e->getCode().$e->getMessage(),JSON_UNESCAPED_UNICODE)]);
+        }
+
+    }
+
+
+    /**
+     * goEasy聊天记录存入数据库
+     * * @return false|string
+     */
+    public function easyMessage(){
+        $req = request()->post();
+        try {
+            $data = json_decode($req['content'],true);
+            $ImList = ImMessage::get();
+            $newList=[];
+            if ($ImList){
+                foreach ($ImList as $k=>$v){
+                    $newList[$k] = $v['messageId'];
+                }
+            }
+            $list = [];
+            if($data){
+                foreach ($data as $k=>$v){
+                    if(!in_array($v['messageId'],$newList)){
+                        $list[$k]['messageId'] = $v['messageId'];
+                        $list[$k]['type'] = $v['type'];
+                        $list[$k]['senderId'] = $v['senderId'];
+                        $list[$k]['receiverId'] = $v['receiverId'];
+                        $list[$k]['timestamp'] = $v['timestamp'];
+                        $list[$k]['payload'] = $v['payload'];
+                        $list[$k]['text'] = $req['content'];
+                        $list[$k]['create_time'] = time();
+                    }
+                }
+                ImMessage::insert($list);
+            }else{
+                $list['text'] = $req['content'];
+                ImMessage::create($list);
+
+            }
+            return json_encode(['code'=>200,'content'=>'success']);
+        }catch (\Exception $e){
+            ImMessage::create(['text'=>json_encode($e->getFile().'的第 '.$e->getLine().'行报错:'.$e->getMessage(),true)]);
+        }catch (\PDOException $e){
+            ImMessage::create(['text'=>json_encode($e->getFile().'的第 '.$e->getLine().'行报错:'.$e->getMessage(),true)]);
+        }
+
+    }
+}

+ 118 - 0
app/Http/Controllers/Api/V2/DocterMessageController.php

xqd
@@ -0,0 +1,118 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Yuanhang Liu
+ * Date: 20-10-15
+ * Time: 下午8:46
+ */
+
+namespace App\Http\Controllers\Api\V2;
+
+use App\Models\Order;
+use App\Models\Patient;
+use App\Models\CallLog;
+use App\Models\OrderPatient;
+use App\Models\DocterOrganization;
+use App\Models\Organization;
+use App\Models\DocterMessage;
+use App\Http\Controllers\Api\V2\CommonController as Commons;
+
+/**
+ * 医生通知类
+ * Class DocterMessageController
+ * @package App\Http\Controllers\Api\V2
+ */
+class DocterMessageController extends AuthController
+{
+    /**
+     * @return mixed
+     * 医生通知列表
+     * @author Yuanhang Liu & Xiaoyun Liu
+     */
+    public function docterMessageList()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'curPage' => 'required|integer',
+            'pageSize' => 'required|integer',
+        ]);
+        $pageSize = ($req['curPage']-1)*$req['pageSize'];
+        $user = $this->user;
+        $doctor_id = $user['id'];
+
+        $where['docter_id'] = $doctor_id;
+        $data = DocterMessage::where($where)->orderBy('id', 'desc')->skip($pageSize)->take($req['pageSize'])->get();
+
+        if ($data){
+            $data = $data->toArray();
+
+        }else{
+            return out([]);
+        }
+        return out($data);
+    }
+
+    /**
+     * @return mixed
+     * 删除医生通知
+     * @author Yuanhang Liu & Xiaoyun Liu
+     */
+    public function delDocterMessage()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'id' => 'required|integer',
+        ]);
+
+        $del = DocterMessage::where('id','=',$req['id'])->delete();
+        if ($del){
+            return out();
+        }else{
+            return out('',500,'删除错误!');
+        }
+
+    }
+
+    /**
+     * @return mixed
+     * 全部标为已读医生通知
+     * @author Yuanhang Liu & Xiaoyun Liu
+     */
+    public function okDocterMessage()
+    {
+        $req = request()->post();
+//        $this->validate(request(), [
+//            'id' => 'required|integer',
+//        ]);
+        $user = $this->user;
+        $del = DocterMessage::where('docter_id','=',$user['id'])->update(['status'=>2]);
+        if ($del){
+            return out();
+        }else{
+            return out('',500,'操作失败!');
+        }
+
+    }
+
+    /**
+     * 标记已读
+     * @return \Illuminate\Http\JsonResponse
+     * @author Liu-Yh
+     * Create By 2020/12/9 10:46
+     */
+    public function readOk()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'id' => 'required|integer',
+        ]);
+        $user = $this->user;
+        $del = DocterMessage::where('id','=',$req['id'])->update(['status'=>2]);
+        if ($del){
+            return out();
+        }else{
+            return out('',500,'操作失败!');
+        }
+
+    }
+}

+ 3112 - 0
app/Http/Controllers/Api/V2/DoctorController.php

xqd
@@ -0,0 +1,3112 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Yuanhang Liu & Xiaoyun Liu
+ * Date: 20-10-14
+ * Time: 下午2:50
+ */
+
+namespace App\Http\Controllers\Api\V2;
+
+use App\Http\Controllers\Api\V1\AuthController;
+use App\Models\Docter;
+use App\Models\Office;
+use App\Models\Order;
+use App\Models\OrderPack;
+use App\Models\OrderPatient;
+use App\Models\Patient;
+use App\Models\Qualification;
+use App\Models\Suggest;
+use App\Models\Areas;
+use App\Models\Collection as Collections;
+use App\Models\Organization;
+use App\Models\DocterTimes;
+use App\Models\DocterOrganization;
+use App\Http\Controllers\Api\V2\CommonController as Commons;
+use App\Models\Team;
+use App\Models\User;
+use Illuminate\Support\Facades\DB;
+use MongoDB\BSON\ObjectId;
+use PhpParser\Comment\Doc;
+use App\Models\DocterUser;
+use App\Models\Schedule;
+use App\Models\TimePeriod;
+use App\Models\SchedulePeriod;
+use App\Models\DocterMessage;
+use App\Models\Evaluate;
+use App\Models\UserDocter;
+use App\Models\ServiceApply;
+use App\Models\SystemConfig;
+use App\Models\WeekSchedule;
+use App\Models\SelfSchedule;
+use App\Models\DocterSetting;
+use App\Models\DocterServiceTimes;
+use App\Models\CallLog;
+use App\Models\ImMessage;
+use App\Models\DocterLable;
+
+/**
+ * 医生相关类
+ * Auth Yuanhang Liu
+ * Date 2020/10/14 15:06
+ * Class DoctorController
+ * @package App\Http\Controllers\Api\V2
+ */
+class DoctorController extends AuthController
+{
+
+    /**service_schedule
+     * @return \Illuminate\Http\JsonResponse
+     * 首页医生个人信息接口
+     */
+    public function doctorInfor()
+    {
+        $req = $this->user;
+        $data = Docter::where('phone', $req['phone'])->first(['id', 'name', 'avatar', 'label', 'sign', 'intro', 'service_days', 'service_persons','password', 'eva_num', 'score', 'is_then', 'created_at']);
+
+        if (!empty($data)) {
+
+            // 获取标签
+            $LabFind = [];
+            if ($data['label']!='无'){
+                if(count($data['label'])!=0){
+                    $labstr = $data['label'];
+                    $LabFind = DocterLable::whereIn('id',$labstr)->where('status',1)->select('label_name')->get();
+                }
+            }
+
+
+
+            $data['label'] = $LabFind;
+//            $counts = Evaluate::where('docter_id', '=', $req['id'])->count();
+            $evalList = Evaluate::where('docter_id', '=', $req['id'])->get();
+            $counts = count($evalList);
+
+
+            $data['eva_num'] = $counts;
+            $soc = 0;
+            if ($counts != 0) {
+                $evalList = $evalList->toArray();
+                foreach ($evalList as $k => $v) {
+                    $soc += $v['score'];
+                }
+                $data['score'] = upDecimal($soc / $counts, 1);
+            }
+
+            $data['service_days'] = numDays(date('Y-m-d', strtotime($data['created_at'])));
+            return out($data);
+        } else {
+            return exit_out($data, 1, '参数错误,数据不存在');
+        }
+
+    }
+
+    /**
+     * 医生端个人信息修改
+     * @return mixed
+     */
+    public function doctorInfoEdit()
+    {
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        if (request()->isMethod('post')) {
+            $req = request()->post();
+            $this->validate(request(), [
+                'avatar' => 'string',
+                'sign' => 'max:255',
+//            'phone|手机号不正确' => 'regex:/^1[3456789][0-9]{9}$/',
+                'intro' => 'max:2555'
+            ]);
+            $data = [];
+            if (isset($req['avatar']) && !empty($req['avatar'])) {
+                $data['avatar'] = $req['avatar'];
+            }
+            if (isset($req['sign']) && !empty($req['sign'])) {
+                $data['sign'] = $req['sign'];
+            }
+            if (isset($req['intro']) && !empty($req['intro'])) {
+                $data['intro'] = $req['intro'];
+            }
+
+            if (empty($data)) {
+                return out();
+            }
+            if ($doctor_id) {
+                $save = Docter::where('id', $doctor_id)->update($data);
+                return out();
+            }
+        } else {
+            // get提交哈
+            $list = Docter::where('id', '=', $doctor_id)->first()->toArray();
+            // 头像,个人标签,服务简介展示
+            $data = [
+                'avatar' => !empty($list['avatar'])?$list['avatar']:'',
+                'sign' => !empty($list['sign'])?$list['sign']:'',
+                'intro' => !empty($list['intro'])?$list['intro']:'',
+            ];
+            return out($data);
+        }
+    }
+
+
+    /**
+     * 修改密码
+     * @return \Illuminate\Http\JsonResponse
+     * @author Liu-Yh
+     * Create By 2020/11/4 18:19
+     */
+    public function passwordEdit()
+    {
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        $req = request()->post();
+        $this->validate(request(), [
+            'lis:原密码' => 'string',
+            'newpassword:新密码' => 'string',
+        ]);
+        $data = [];
+        $data = Docter::where('id', '=', $doctor_id)->first()->toArray();
+        $password = md5(md5(md5($req['newpassword'])));
+        if ($data['password'] == '' || !$data['password']) {
+            // 说明第一次直接跳过
+            $save = Docter::where('id', $doctor_id)->update(['password' => $password]);
+            return out();
+        } else {
+            if(isset($req['lis'])&&!empty($req['lis'])){
+                $oldpassword = md5(md5(md5($req['lis'])));
+                if ($oldpassword != $data['password']) {
+                    return out('', '401', '旧密码错误');
+                } else {
+                    $save = Docter::where('id', $doctor_id)->update(['password' => $password]);
+                    return out();
+                }
+            }else{
+                return out('', '401', '请输入旧密码');
+
+            }
+
+        }
+    }
+
+
+    /**
+     * 基本/更多设置读取(废弃)
+     * @return \Illuminate\Http\JsonResponse
+     * @author Yuanhang Liu
+     */
+    public function getSettingList()
+    {
+        $req = request()->post();
+
+        $this->validate(request(), [
+            'type' => 'required|integer|in:1,2',
+            'service_type' => 'integer'
+        ]);
+        $user = $this->user;
+        $doctor_id = (new Commons)->getUserIdByDoctorId($user['phone']);
+        $finds = Docter::select(['is_chat', 'is_phone', 'is_appoint'])->where('id', $doctor_id)->first()->toArray();
+
+        $finds['is_chat'] = $finds['is_chat'] == 0 ? false : true;
+        $finds['is_phone'] = $finds['is_phone'] == 0 ? false : true;
+        $finds['is_appoint'] = $finds['is_appoint'] == 0 ? false : true;
+        $finds['is_chat_status'] = $this->getStyStatus(1);
+        $finds['is_phone_status'] = $this->getStyStatus(2);
+        $finds['is_appoint_status'] = $this->getStyStatus(3);
+
+        if ($req['type'] == 2) {
+            (array)$list = [];
+            // 获取显示状态:
+            $list['show'] = $finds;
+
+            // 获取电话咨询时间
+            $phone_fins = DocterTimes::where(['docter_id' => $doctor_id, 'type' => 1])->first();
+            if ($phone_fins) {
+                $phone_fins = $phone_fins->toArray();
+            } else {
+                $phone_fins = [];
+            }
+            $list['list']['phone'] = $phone_fins;
+            // 图文咨询时间
+            $pic_fins = DocterTimes::where(['docter_id' => $doctor_id, 'type' => 2])->first();
+            if ($pic_fins) {
+                $pic_fins = $pic_fins->toArray();
+            } else {
+                $pic_fins = [];
+            }
+            $list['list']['chat'] = $pic_fins;
+            // 门诊咨询时间
+
+            $men_fins = DocterTimes::where(['docter_id' => $doctor_id, 'type' => 3])->get();
+            if ($men_fins) {
+                $men_fins = $men_fins->toArray();
+            } else {
+                $men_fins = [];
+            }
+            $list['list']['men'] = $men_fins;
+
+            // 获取医院
+            $org = DocterOrganization::with('organization')->where('docter_id', $doctor_id)->get();
+            $org_pre = [];
+            $org_pres = [];
+            if ($org) {
+                $org = $org->toArray();
+                foreach ($org as $k => $v) {
+                    $org_pres[$k]['id'] = $v['organization']['id'];
+                    $org_pres[$k]['name'] = $v['organization']['name'];
+                    $org_pre[$k]['name'] = $v['organization']['name'];
+                }
+            }
+            $list['org'] = $org_pre;
+            $list['orgs'] = $org_pres;
+            $times = TimePeriod::get();
+            if ($times) {
+                $times = $times->toArray();
+                $newTimes = [];
+                foreach ($times as $k => $v) {
+                    $newTimes[$k]['id'] = $v['id'];
+                    $newTimes[$k]['name'] = $v['start_time_period'] . ' - ' . $v['end_time_period'];
+                    $newTimes[$k]['checked'] = false;
+                }
+                $times1 = [];
+                $times2 = [];
+                $times3 = [];
+                foreach ($newTimes as $k => $v) {
+                    if ($k >= 0 && $k < 16) {
+                        array_push($times1, $v);
+                    } else if ($k >= 16 && $k < 32) {
+                        array_push($times2, $v);
+                    } else {
+                        array_push($times3, $v);
+                    }
+                }
+                $list['times']['list1'] = $times1;
+                $list['times']['list2'] = $times2;
+                $list['times']['list3'] = $times3;
+            } else {
+                $times = [];
+            }
+            return out($list);
+        }
+        return out($finds);
+    }
+
+
+    /**
+     * 更多设置读取,新的
+     * @return \Illuminate\Http\JsonResponse
+     * @author Liu-Yh
+     * Create By 2020/12/16 11:10
+     */
+    public function getSettingListnew()
+    {
+        $req = request()->post();
+
+        $this->validate(request(), [
+            'type' => 'required|integer|in:1,2',
+            'service_type' => 'integer'
+        ]);
+        $user = $this->user;
+        $doctor_id = (new Commons)->getUserIdByDoctorId($user['phone']);
+        $finds = Docter::select(['is_chat', 'is_phone', 'is_appoint'])->where('id', $doctor_id)->first()->toArray();
+
+        $finds['is_chat'] = $finds['is_chat'] == 0 ? false : true;
+        $finds['is_phone'] = $finds['is_phone'] == 0 ? false : true;
+        $finds['is_appoint'] = $finds['is_appoint'] == 0 ? false : true;
+        $finds['is_chat_status'] = $this->getStyStatus(1);
+        $finds['is_phone_status'] = $this->getStyStatus(2);
+        $finds['is_appoint_status'] = $this->getStyStatus(3);
+
+
+        if ($req['type'] == 2) {
+            (array)$list = [];
+            // 获取显示状态:
+            $list['show'] = $finds;
+            // 获取电话咨询时间
+            $phone_fins = DocterTimes::where(['docter_id' => $doctor_id, 'type' => 1])->first();
+            if ($phone_fins) {
+                $phone_fins = $phone_fins->toArray();
+                $phone_fins['service_time'] = json_decode($phone_fins['service_time']);
+            } else {
+                $phone_fins = [];
+            }
+            $list['list']['phone'] = $phone_fins;
+            // 图文咨询时间
+            $pic_fins = DocterTimes::where(['docter_id' => $doctor_id, 'type' => 2])->first();
+            if ($pic_fins) {
+                $pic_fins = $pic_fins->toArray();
+                $pic_fins['service_time'] = json_decode($pic_fins['service_time']);
+
+            } else {
+                $pic_fins = [];
+            }
+            $list['list']['chat'] = $pic_fins;
+            // 门诊咨询时间
+            $newLists=[];
+            $men_fins = DocterSetting::where(['docter_id' => $doctor_id, 'type' => 1])->orderBy('org_id','asc')->get();
+            $org = DocterOrganization::with('organization')->where(['docter_id'=>$doctor_id,'state'=>1])->orderBy('organization_id','asc')->get();
+            if ($org) {
+                $org = $org->toArray();
+                foreach ($org as $k => $v) {
+                    $org_pre[$k]['id'] = $v['organization']['id'];
+                    $org_pre[$k]['name'] = $v['organization']['name'];
+                }
+            }
+
+            if ($men_fins) {
+                $men_fins = $men_fins->toArray();
+
+                foreach ($men_fins as $k => $v) {
+                    $men_fins[$k]['service_time'] = json_decode($v['service_time'],true);
+                }
+
+                $org_list=[];
+
+                foreach ($org as $k=>$v){
+                    $org_list[$k]['docter_id'] = $doctor_id;
+                    $org_list[$k]['type'] = 1;
+                    $org_list[$k]['status'] = 2;
+                    $org_list[$k]['show_days'] = '';
+                    $org_list[$k]['service_times'] = '';
+                    $org_list[$k]['service_num'] = '';
+                    $org_list[$k]['org_id'] = $v['organization']['id'];
+                    $org_list[$k]['org_name'] = $v['organization']['name'];
+                    $org_list[$k]['appoint_price'] = '';
+                    $org_list[$k]['service_time'] = [
+                        1=>['amStartTime'=>'','amEndTime'=>'','amPerson'=>''],
+                        2=>['pmStartTime'=>'','pmEndTime'=>'','pmPerson'=>''],
+                        3=>['nightStartTime'=>'','nightEndTime'=>'','nightPerson'=>''],
+                    ];
+                }
+                foreach ($org_list as $k=>$v){
+                    foreach ($men_fins as $kk=>$vv){
+                        if ($v['org_id']==$vv['org_id']){
+                            $org_list[$k]['docter_id'] = $doctor_id;
+                            $org_list[$k]['type'] = 1;
+                            $org_list[$k]['status'] = 2;
+                            $org_list[$k]['show_days'] = $vv['show_days'];
+                            $org_list[$k]['service_times'] = $vv['service_times'];
+                            $org_list[$k]['service_num'] = $vv['service_num'];
+                            $org_list[$k]['org_id'] = $vv['org_id'];
+                            $org_list[$k]['org_name'] = $v['org_name'];
+                            $org_list[$k]['appoint_price'] = $vv['appoint_price'];
+                            $org_list[$k]['service_time'] = [
+                                1=>['amStartTime'=>$vv['service_time'][1]['amStartTime'],'amEndTime'=>$vv['service_time'][1]['amEndTime'],'amPerson'=>$vv['service_time'][1]['amPerson']],
+                                2=>['pmStartTime'=>$vv['service_time'][2]['pmStartTime'],'pmEndTime'=>$vv['service_time'][2]['pmEndTime'],'pmPerson'=>$vv['service_time'][2]['pmPerson']],
+                                3=>['nightStartTime'=>$vv['service_time'][3]['nightStartTime'],'nightEndTime'=>$vv['service_time'][3]['nightEndTime'],'nightPerson'=>$vv['service_time'][3]['nightPerson']],
+                            ];
+                        }
+                    }
+
+                }
+                $newLists = $org_list;
+            } else {
+                $men_fins = [];
+                foreach ($org as $k=>$v){
+                    $newLists[$k]['docter_id'] = $doctor_id;
+                    $newLists[$k]['type'] = 1;
+                    $newLists[$k]['status'] = 2;
+                    $newLists[$k]['show_days'] = '';
+                    $newLists[$k]['service_times'] = '';
+                    $newLists[$k]['service_num'] = '';
+                    $newLists[$k]['org_id'] = $v['organization']['id'];
+                    $newLists[$k]['org_name'] = $v['organization']['name'];
+                    $newLists[$k]['appoint_price'] = '';
+                    $newLists[$k]['service_time'] = [
+                        1=>['amStartTime'=>'','amEndTime'=>'','amPerson'=>''],
+                        2=>['pmStartTime'=>'','pmEndTime'=>'','pmPerson'=>''],
+                        3=>['nightStartTime'=>'','nightEndTime'=>'','nightPerson'=>''],
+                    ];
+                }
+            }
+
+            // 获取医院
+//            $org_pre = [];
+
+            $list['list']['men'] = $newLists;
+
+//            $list['org'] = $org_pre;
+            return out($list);
+        }
+        return out($finds);
+    }
+
+
+
+
+
+
+    /**
+     * 获取审核状态
+     * @param $type
+     * @return bool
+     */
+    public function getStyStatus($type)
+    {
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        $where['docter_id'] = $doctor_id;
+        $where['service_type'] = $type;
+        $statusD = ServiceApply::where($where)->first();
+        if ($statusD) {
+            return $statusD;
+        } else {
+            return false;
+        }
+    }
+
+
+    /**
+     * 基本/更多设置修改
+     * @return \Illuminate\Http\JsonResponse
+     * @author Yuanhang Liu
+     */
+    public function saveSettingList()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'type' => 'required|integer|in:1,2',
+        ]);
+        $data = json_decode($req['data'], true);
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        $finds = Docter::select(['is_chat', 'is_phone', 'is_appoint'])->where('id', $doctor_id)->first();
+
+        $flag = false;
+        if ($req['type'] == 1) {
+            // 修改基本信息
+            $list = [];
+            isset($data['is_chat']) ? $data['is_chat'] == true ? $list['is_chat'] = 1 : $list['is_chat'] = 0 : '';
+            isset($data['is_phone']) ? $data['is_phone'] == true ? $list['is_phone'] = 1 : $list['is_phone'] = 0 : '';
+            isset($data['is_appoint']) ? $data['is_appoint'] == true ? $list['is_appoint'] = 1 : $list['is_appoint'] = 0 : '';
+            Docter::where('id', $doctor_id)->update($list);
+            return out();
+        } else if ($req['type'] == 2) {
+            Db::beginTransaction();
+            try {
+                // 修改更多信息
+                if ($finds['is_chat'] == 0) {
+                    if (isset($data['is_chat']) && !empty($data['is_chat'])) {
+                        unset($data['is_chat']);
+
+                    }
+                } else {
+                    if (isset($data['is_chat']) && !empty($data['is_chat'])) {
+                        DocterServiceTimes::where(['docter_id'=>$doctor_id,'type'=>2])->delete();
+                        $save_data = $data['is_chat'];
+                        $newData = [];
+                        $serviceData = [];
+                        $newData['base_price'] = $save_data['base_price'];
+                        $newData['step_price'] = $save_data['step_price'];
+                        $serviceData[0]['docter_id']=$doctor_id;
+                        $serviceData[0]['type']=2;
+                        $serviceData[0]['start_time_period']=$save_data['amStartTime'];
+                        $serviceData[0]['end_time_period']=$save_data['amEndTime'];
+                        $serviceData[0]['start_time_line']=str_replace(':','',$save_data['amStartTime']);
+                        $serviceData[0]['end_time_line']=str_replace(':','',$save_data['amEndTime']);
+
+                        $serviceData[1]['docter_id']=$doctor_id;
+                        $serviceData[1]['type']=2;
+                        $serviceData[1]['start_time_period']=$save_data['pmStartTime'];
+                        $serviceData[1]['end_time_period']=$save_data['pmEndTime'];
+                        $serviceData[1]['start_time_line']=str_replace(':','',$save_data['pmStartTime']);
+                        $serviceData[1]['end_time_line']=str_replace(':','',$save_data['pmEndTime']);
+
+                        $serviceData[2]['docter_id']=$doctor_id;
+                        $serviceData[2]['type']=2;
+                        $serviceData[2]['start_time_period']=$save_data['nightStartTime'];
+                        $serviceData[2]['end_time_period']=$save_data['nightEndTime'];
+                        $serviceData[2]['start_time_line']=str_replace(':','',$save_data['nightStartTime']);
+                        $serviceData[2]['end_time_line']=str_replace(':','',$save_data['nightEndTime']);
+
+
+
+
+                        $service_times = [
+                            1 => ['amStartTime' => $save_data['amStartTime'], 'amEndTime' => $save_data['amEndTime']],
+                            2 => ['pmStartTime' => $save_data['pmStartTime'], 'pmEndTime' => $save_data['pmEndTime']],
+                            3 => ['nightStartTime' => $save_data['nightStartTime'], 'nightEndTime' => $save_data['nightEndTime']],
+                        ];
+                        $newData['service_time'] = json_encode($service_times, JSON_UNESCAPED_UNICODE);
+                        $newData['person'] = $save_data['person'];
+                        $newData['type'] = $save_data['type'];
+                        $pic_fins = DocterTimes::where(['docter_id' => $doctor_id, 'type' => 2])->first();
+
+                        DocterServiceTimes::insert($serviceData);
+                        if (empty($pic_fins)) {
+                            $newData['docter_id'] = $doctor_id;
+                            DocterTimes::create($newData);
+                        } else {
+                            $pic_fins = $pic_fins->toArray();
+                            DocterTimes::where(['id' => $pic_fins['id']])->update($newData);
+                        }
+                    }
+                }
+                if ($finds['is_phone'] == 0) {
+                    if (isset($data['is_phone']) && !empty($data['is_phone'])) {
+                        unset($data['is_phone']);
+                    }
+                } else {
+                    if (isset($data['is_phone']) && !empty($data['is_phone'])) {
+                        // 存入状态为1的操作
+                        DocterServiceTimes::where(['docter_id'=>$doctor_id,'type'=>1])->delete();
+
+                        $save_data = $data['is_phone'];
+                        $newData = [];
+                        $serviceData = [];
+
+                        $newData['base_price'] = $save_data['base_price'];
+                        $newData['step_price'] = $save_data['step_price'];
+
+                        $serviceData[0]['docter_id']=$doctor_id;
+                        $serviceData[0]['type']=1;
+                        $serviceData[0]['start_time_period']=$save_data['amStartTime'];
+                        $serviceData[0]['end_time_period']=$save_data['amEndTime'];
+                        $serviceData[0]['start_time_line']=str_replace(':','',$save_data['amStartTime']);
+                        $serviceData[0]['end_time_line']=str_replace(':','',$save_data['amEndTime']);
+
+                        $serviceData[1]['docter_id']=$doctor_id;
+                        $serviceData[1]['type']=1;
+                        $serviceData[1]['start_time_period']=$save_data['pmStartTime'];
+                        $serviceData[1]['end_time_period']=$save_data['pmEndTime'];
+                        $serviceData[1]['start_time_line']=str_replace(':','',$save_data['pmStartTime']);
+                        $serviceData[1]['end_time_line']=str_replace(':','',$save_data['pmEndTime']);
+
+                        $serviceData[2]['docter_id']=$doctor_id;
+                        $serviceData[2]['type']=1;
+                        $serviceData[2]['start_time_period']=$save_data['nightStartTime'];
+                        $serviceData[2]['end_time_period']=$save_data['nightEndTime'];
+                        $serviceData[2]['start_time_line']=str_replace(':','',$save_data['nightStartTime']);
+                        $serviceData[2]['end_time_line']=str_replace(':','',$save_data['nightEndTime']);
+
+                        $service_times = [
+                            1 => ['amStartTime' => $save_data['amStartTime'], 'amEndTime' => $save_data['amEndTime']],
+                            2 => ['pmStartTime' => $save_data['pmStartTime'], 'pmEndTime' => $save_data['pmEndTime']],
+                            3 => ['nightStartTime' => $save_data['nightStartTime'], 'nightEndTime' => $save_data['nightEndTime']],
+                        ];
+                        $newData['service_time'] = json_encode($service_times, JSON_UNESCAPED_UNICODE);
+                        $newData['person'] = $save_data['person'];
+                        $newData['type'] = $save_data['type'];
+                        // 图文咨询时间
+                        $phone_fins = DocterTimes::where(['docter_id' => $doctor_id, 'type' => 1])->first();
+                        DocterServiceTimes::insert($serviceData);
+                        if (empty($phone_fins)) {
+                            $newData['docter_id'] = $doctor_id;
+                            DocterTimes::create($newData);
+                        } else {
+                            $phone_fins = $phone_fins->toArray();
+                            DocterTimes::where(['id' => $phone_fins['id']])->update($newData);
+                        }
+                    }
+                }
+                if ($finds['is_appoint'] == 0) {
+                    if (isset($data['is_appoint']) && !empty($data['is_appoint'])) {
+                        unset($data['is_appoint']);
+                    }
+                } else {
+                    // 此时可能有两个医院,为一个数组,一个一个入库
+                    if (isset($data['is_appoint']) && !empty($data['is_appoint'])) {
+                        $save_data = $data['is_appoint'];
+                        $setting_data = [];
+                        $times_data = [];
+                        // 查询除本地来
+                        $edutime = DocterSetting::where(['docter_id' => $doctor_id, 'type' => 1])->get();
+                        if ($edutime) {
+                            $newedu = [];
+                            foreach ($edutime as $k => $v) {
+                                $newedu[$k]['org_id'] = $v['org_id'];
+                                $newedu[$k]['service_times'] = $v['service_times'];
+                            }
+                            $flag_arr = [];
+                            foreach ($newedu as $k => $v) {
+                                foreach ($save_data as $kk => $vv) {
+                                    if ($v['org_id'] == $vv['org_id']) {
+                                        if ($v['service_times'] != $vv['service_times']) {
+                                            $flag_arr[] = $vv['org_id'];
+                                        }
+                                    }
+                                }
+                            }
+                            $flag = !empty($flag_arr) ? $flag_arr : false;
+                        }
+                        foreach ($save_data as $k => $v) {
+                            if (!isset($v['service_times'])||empty($v['service_times'])){
+                                unset($save_data[$k]);
+                            }else{
+                                DocterSetting::where('docter_id', '=', $doctor_id)->where('org_id', $v['org_id'])->delete();
+                                TimePeriod::where('docter_id', '=', $doctor_id)->where('org_id', $v['org_id'])->delete();
+                                $setting_data[$k]['docter_id'] = $doctor_id;
+                                $setting_data[$k]['type'] = 1;
+                                $setting_data[$k]['status'] = 2;
+                                $setting_data[$k]['appoint_price'] = $v['base_price'];
+                                $setting_data[$k]['show_days'] = $v['show_days'];
+                                $setting_data[$k]['service_times'] = $v['service_times'];
+                                $setting_data[$k]['service_num'] = $v['service_num'];
+                                $setting_data[$k]['org_id'] = $v['org_id'];
+                                $service_times = [
+                                    1 => ['amStartTime' => $v['amStartTime'], 'amEndTime' => $v['amEndTime'], 'amPerson' => $v['amPerson']],
+                                    2 => ['pmStartTime' => $v['pmStartTime'], 'pmEndTime' => $v['pmEndTime'], 'pmPerson' => $v['pmPerson']],
+                                    3 => ['nightStartTime' => $v['nightStartTime'], 'nightEndTime' => $v['nightEndTime'], 'nightPerson' => $v['nightPerson']],
+                                ];
+                                $setting_data[$k]['service_time'] = json_encode($service_times, JSON_UNESCAPED_UNICODE);
+                                $setting_data[$k]['created_at'] = date('Y-m-d H:i:s', time());
+                                $setting_data[$k]['updated_at'] = date('Y-m-d H:i:s', time());
+                                // 第二步, 根据时长去生成24小时的时间段,也要存id
+
+                                $timeList = $this->getTimeHoures($v['service_times']);
+                                foreach ($timeList as $kk => $vv) {
+                                    $times_data[$k][$kk]['type'] = 2;
+                                    $times_data[$k][$kk]['docter_id'] = $doctor_id;
+                                    $times_data[$k][$kk]['start_time_period'] = $vv[0];
+                                    $times_data[$k][$kk]['end_time_period'] = $vv[1];
+                                    $times_data[$k][$kk]['org_id'] = $v['org_id'];
+                                }
+                            }
+
+                        }
+                        if($times_data&&$setting_data){
+                            foreach ($times_data as $k => $v) {
+                                TimePeriod::insert($v);
+                            }
+                            DocterSetting::insert($setting_data);
+                        }
+                    }
+                }
+                DB::commit();
+            } catch (\Exception $e) {
+                DB::rollBack();
+                return out('', 500, $e->getMessage());
+            } catch (\PDOException $e) {
+                DB::rollBack();
+                return out('', 500, $e->getMessage());
+            }
+
+            if ($finds['is_appoint'] != 0 && isset($data['is_appoint']) && !empty($data['is_appoint'])) {
+                /*去重新更新,自定义排班表,和排班详情表,因为时间段id发生了变化!*/
+
+                if ($flag != false) {
+                    $weekList = WeekSchedule::where('docter_id', $doctor_id)->get();
+                    $moth_date = $this->date_bool();
+                    $counts = Schedule::where('schedule_date', '>=', $moth_date[0]['date'])->where('schedule_date', '<=', end($moth_date)['date'])->get();
+                    if ($weekList && $counts) {
+                        $weekList = $weekList->toArray();
+                        $selfScheduleList = SelfSchedule::where('docter_id', $doctor_id)->whereIn('organization_id', $flag)->get();
+                        // 修改自定义表 不存在则不管就好
+                        SchedulePeriod::where('docter_id', '=', $doctor_id)->delete();
+                        if ($selfScheduleList) {
+                            $selfScheduleList = $selfScheduleList->toArray();
+                            $selfList = [];
+                            foreach ($selfScheduleList as $k => $v) {
+                                if (!isset($selfList[$v['schedule_date']])) {
+                                    $selfList[$v['schedule_date']] = $v;
+                                    if ($v['type'] == 1) {
+                                        $selfList[$v['schedule_date']]['ident']['zao_id'] = $v['organization_id'];
+                                        $selfList[$v['schedule_date']]['ident']['xia_id'] = 0;
+                                        $selfList[$v['schedule_date']]['ident']['wan_id'] = 0;
+                                    } else if ($v['type'] == 2) {
+                                        $selfList[$v['schedule_date']]['ident']['zao_id'] = 0;
+                                        $selfList[$v['schedule_date']]['ident']['xia_id'] = $v['organization_id'];
+                                        $selfList[$v['schedule_date']]['ident']['wan_id'] = 0;
+                                    } else {
+                                        $selfList[$v['schedule_date']]['ident']['zao_id'] = 0;
+                                        $selfList[$v['schedule_date']]['ident']['xia_id'] = 0;
+                                        $selfList[$v['schedule_date']]['ident']['wan_id'] = $v['organization_id'];
+                                    }
+                                } else {
+                                    if ($v['type'] == 1) {
+                                        $selfList[$v['schedule_date']]['ident']['zao_id'] = $v['organization_id'];
+                                    } else if ($v['type'] == 2) {
+                                        $selfList[$v['schedule_date']]['ident']['xia_id'] = $v['organization_id'];
+                                    } else {
+                                        $selfList[$v['schedule_date']]['ident']['wan_id'] = $v['organization_id'];
+                                    }
+                                }
+                            }
+
+                            // 拼接数据交给saveDay来操作
+                            $saveDatas = [];
+                            SelfSchedule::where('docter_id', $doctor_id)->delete();
+                            foreach ($selfList as $k => $v) {
+                                $saveDatas[$k]['schedule_date'] = $v['schedule_date'];
+                                $saveDatas[$k]['week'] = $v['week'];
+                                if ($v['ident']['zao_id']) {
+                                    $saveDatas[$k]['type'] = 1;
+                                    $saveDatas[$k]['organization_id'] = $v['ident']['zao_id'];
+                                    $saveSelf = $this->saveDay($saveDatas[$k]);
+                                    if (!$saveSelf) {
+                                        return out('', 500, '修改排班失败!');
+                                    }
+                                }
+                                if ($v['ident']['xia_id']) {
+                                    $saveDatas[$k]['type'] = 2;
+                                    $saveDatas[$k]['organization_id'] = $v['ident']['xia_id'];
+                                    $saveSelf = $this->saveDay($saveDatas[$k]);
+                                    if (!$saveSelf) {
+                                        return out('', 500, '修改排班失败!');
+                                    }
+                                }
+                                if ($v['ident']['wan_id']) {
+                                    $saveDatas[$k]['type'] = 3;
+                                    $saveDatas[$k]['organization_id'] = $v['ident']['wan_id'];
+                                    $saveSelf = $this->saveDay($saveDatas[$k]);
+                                    if (!$saveSelf) {
+                                        return out('', 500, '修改排班失败!');
+                                    }
+
+                                }
+                            }
+                        }
+                        Db::beginTransaction();
+                        try {
+                            $selfScheduleList = SelfSchedule::where('docter_id', $doctor_id)->whereIn('organization_id', $flag)->get();
+
+                            foreach ($counts as $kk => $vv) {
+                                $schedule[$kk]['schedule_date'] = $vv['schedule_date'];
+                                $schedule[$kk]['week'] = $vv['week'];
+                                $sid[$kk] = $vv['id'];
+                            }
+                            // 占用效率
+                            $scheduleLists = [];
+                            foreach ($sid as $kk => $vv) {
+                                foreach ($weekList as $k => $v) {
+                                    if ($schedule[$kk]['week'] == $v['week']) {
+                                        if ($v['type'] == 1) {
+                                            $times = $this->num_time($v['organization_id'], 1);
+                                            if (!$times) {
+                                                return out('', 500, "请先在排班设置中填写本机构的时间段");
+                                            }
+                                            $maf = $this->getMaf($vv, $times, ['organization_id' => $v['organization_id'], 'schedule_date' => $schedule[$kk]['schedule_date'], 'type' => 1], $doctor_id);
+                                            if ($maf) {
+                                                foreach ($maf as $os) {
+                                                    $scheduleLists[] = $os;
+                                                }
+                                            }
+                                        }
+                                        if ($v['type'] == 2) {
+                                            $times = $this->num_time($v['organization_id'], 2);
+                                            if (!$times) {
+                                                return out('', 500, "请先在排班设置中填写本机构的时间段");
+                                            }
+                                            $maf = $this->getMaf($vv, $times, ['organization_id' => $v['organization_id'], 'schedule_date' => $schedule[$kk]['schedule_date'], 'type' => 2], $doctor_id);
+                                            if ($maf) {
+                                                foreach ($maf as $os) {
+                                                    $scheduleLists[] = $os;
+                                                }
+                                            }
+                                        }
+                                        if ($v['type'] == 3) {
+                                            $times = $this->num_time($v['organization_id'], 3);
+                                            if (!$times) {
+                                                return out('', 500, "请先在排班设置中填写本机构的时间段");
+                                            }
+                                            $maf = $this->getMaf($vv, $times, ['organization_id' => $v['organization_id'], 'schedule_date' => $schedule[$kk]['schedule_date'], 'type' => 3], $doctor_id);
+                                            if ($maf) {
+                                                foreach ($maf as $os) {
+                                                    $scheduleLists[] = $os;
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+
+                            // 查询重复替换
+                            $chong = [];
+                            if ($selfScheduleList && $scheduleLists) {
+                                foreach ($scheduleLists as $k => $v) {
+                                    foreach ($selfScheduleList as $kk => $vv) {
+                                        if ($v['schedule_date'] == $vv['schedule_date']) {
+                                            $chong[$kk]['schedule_id'] = $v['schedule_id'];
+                                            $chong[$kk]['docter_id'] = $v['docter_id'];
+                                            $chong[$kk]['order_num'] = $v['order_num'];
+                                            $chong[$kk]['organization_id'] = $vv['organization_id'];
+                                            $chong[$kk]['time_period_id'] = $vv['time_period_id'];
+                                            $chong[$kk]['type'] = $vv['type'];
+                                            $chong[$kk]['schedule_date'] = $vv['schedule_date'];
+                                            unset($scheduleLists[$k]);
+                                        }
+                                    }
+                                }
+                            }
+
+                            $listPeriod = array_merge($chong, $scheduleLists);
+                            SchedulePeriod::insert($listPeriod);
+                            DB::commit();
+                        } catch (\Exception $e) {
+                            DB::rollBack();
+                            return out('', 500, '2' . $$e->getMessage());
+                        } catch (\PDOException $e) {
+                            DB::rollBack();
+                            return out('', 500, '2' . $e->getMessage());
+                        }
+                    }
+                }
+
+            }
+
+        }
+
+        return out();
+    }
+
+
+    /**
+     * 计算24小时的时间区间段
+     * @param $minute 分钟比如:15
+     * @return array
+     */
+    public function getTimeHoures($minute)
+    {
+        // 可选10分钟,15分钟,20分钟,30分钟,1个小时
+        $start = strtotime(date("Y-m-d 00:00:00"));
+        $end = strtotime(date("Y-m-d 23:59:59"));
+        $returnArr = [];
+        for ($time = $start; $time <= $end; $time = $time + $minute * 60) {
+            array_push($returnArr, date("H:i", $time));
+        }
+        $newList = [];
+//        for($i=0;$i<count($returnArr)-1;$i++){
+//            $newList[$i]['start']=$returnArr[$i];
+//            $newList[$i]['end']=$returnArr[$i+1];
+//        }
+        $k = 0;
+        for ($i = 0; $i < (count($returnArr) * 2) - 1; $i++) {
+            if ($i % 2 != 0) {
+                if ($i != 0) {
+                    $k++;
+                    $newList[$k][0] = $returnArr[$k];
+                }
+            } else {
+                if ($i != 0) {
+                    $newList[$k - 1][1] = $returnArr[$k];
+                } else {
+                    $newList[$k][0] = $returnArr[$k];
+                }
+            }
+        }
+        $newList[count($newList) - 1][1] = $returnArr[0];
+        return $newList;
+    }
+
+    /**
+     * 新修改医生排班设置(废弃)
+     * @return mixed
+     * @throws \Exception
+     */
+    public function service_schedule()
+    {
+        $req = request()->post();
+        $data = json_decode($req['data'], true);
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        Db::beginTransaction();
+        try {
+            if (isset($data) && !empty($data)) {
+                $setting_data = [];
+                $times_data = [];
+                foreach ($data as $k => $v) {
+                    DocterSetting::where('docter_id', '=', $doctor_id)->where('org_id', $v['org_id'])->delete();
+                    TimePeriod::where('docter_id', '=', $doctor_id)->where('org_id', $v['org_id'])->delete();
+                    $setting_data[$k]['docter_id'] = $doctor_id;
+                    $setting_data[$k]['type'] = 1;
+                    $setting_data[$k]['status'] = 2;
+                    $setting_data[$k]['show_days'] = $v['show_days'];
+                    $setting_data[$k]['service_times'] = $v['service_times'];
+                    $setting_data[$k]['service_num'] = $v['service_num'];
+                    $setting_data[$k]['org_id'] = $v['org_id'];
+                    $service_times = [
+                        1 => ['amStartTime' => $v['amStartTime'], 'amEndTime' => $v['amEndTime'], 'amPerson' => $v['amPerson']],
+                        2 => ['pmStartTime' => $v['pmStartTime'], 'pmEndTime' => $v['pmEndTime'], 'pmPerson' => $v['pmPerson']],
+                        3 => ['nightStartTime' => $v['nightStartTime'], 'nightEndTime' => $v['nightEndTime'], 'nightPerson' => $v['nightPerson']],
+                    ];
+                    $setting_data[$k]['service_time'] = json_encode($service_times, JSON_UNESCAPED_UNICODE);
+                    $setting_data[$k]['created_at'] = date('Y-m-d H:i:s', time());
+                    $setting_data[$k]['updated_at'] = date('Y-m-d H:i:s', time());
+                    // 第二步, 根据时长去生成24小时的时间段,也要存id
+                    $timeList = $this->getTimeHoures($v['service_times']);
+                    foreach ($timeList as $kk => $vv) {
+                        $times_data[$k][$kk]['type'] = 2;
+                        $times_data[$k][$kk]['docter_id'] = $doctor_id;
+                        $times_data[$k][$kk]['start_time_period'] = $vv[0];
+                        $times_data[$k][$kk]['end_time_period'] = $vv[1];
+                        $times_data[$k][$kk]['org_id'] = $v['org_id'];
+                    }
+                }
+                foreach ($times_data as $k => $v) {
+                    TimePeriod::insert($v);
+                }
+                DocterSetting::insert($setting_data);
+            }
+            DB::commit();
+            return out('');
+        } catch (\Exception $e) {
+            DB::rollBack();
+            return out('', 500, $e->getMessage());
+        } catch (\PDOException $e) {
+            DB::rollBack();
+            return out('', 500, $e->getMessage());
+        }
+    }
+
+    /**
+     * 提交认证
+     * Auth:Yuanhang-Liu
+     * Date:2020/10/14 15:08 *
+     * @return \Illuminate\Http\JsonResponse
+     */
+    public function addthen()
+    {
+        $req = request()->post();
+
+        $this->validate(request(), [
+            'name|医生姓名' => 'required|max:50',
+            'sex|性别' => 'required|in:男,女',
+            'ID|身份证号' => 'required|min:16|max:18',
+            'works|医院信息' => 'required',
+            'certificate|医生照片和执业证书' => 'required|string',
+            'idPhoto|身份证正反面' => 'required|string',
+            'doctorQualification|照片和资格证书' => 'required|string',
+        ]);
+        if ($req['sex'] == '男') {
+            $req['sex'] = 1;
+        } else {
+            $req['sex'] = 2;
+        }
+        // 首先获取医生姓名,性别,身份证号,照片,身份证,资格证去补全医生表
+        // 入库organization_ids这个数据是一条字符串,先分割成数组,如果只有一条则医生只选择了一个医院,机构id和医生id入库docter_organization(医生机构关联表)
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        if (!$doctor_id) {
+            return out(null, 500, '医生信息错误!');
+        }
+        $data = [];
+        $data['name'] = $req['name'];
+        $data['sex'] = $req['sex'];
+        $data['card_id'] = $req['ID'];
+        $data['practice'] = $req['certificate'];
+        $data['card_photo'] = $req['idPhoto'];
+        $data['is_quail'] = $req['doctorQualification'];
+        //处理医院机构id
+        $work = json_decode($req['works'], true);
+        if (!$work) {
+            return out('', '', '缺少医院');
+        }
+        $off_then = DocterOrganization::where('docter_id', '=', $doctor_id)->get('id')->toArray();
+        $is_del = false;
+        if ($off_then) {
+            $newids = [];
+            foreach ($off_then as $k => $v) {
+                $newids[$k] = $v['id'];
+            }
+            $is_del = true;
+        }
+        $org_list = [];
+        foreach ($work as $k => $v) {
+            if ($v['hospital']) {
+                $org_list[$k]['docter_id'] = $doctor_id;
+                $org_list[$k]['organization_id'] = $v['hospital'];
+                $org_list[$k]['offices_id'] = $v['department'];
+                $org_list[$k]['qualifications_id'] = $v['qualifications'];
+                $org_list[$k]['state'] = $v['state'];
+            }
+        }
+
+        DB::beginTransaction();//开启事务
+        try {
+            //补全医生表
+            Docter::where('id', $doctor_id)->update($data);
+            if ($is_del) {
+                foreach ($newids as $k => $v) {
+                    DocterOrganization::where('id', $v)->delete();
+                }
+            }
+            // 提交消息;
+            DocterMessage::create([
+                'docter_id' => $doctor_id,
+                'status' => 1,
+                'type' => 8,
+                'content' => '您已提交医生资质认证审核材料 '
+            ]);
+            DocterOrganization::insertOrIgnore($org_list);
+            DB::commit();//提交至数据库
+            return out();
+        } catch (\Exception $e) {
+            DB::rollback();
+            return out(null, 500, $e->getMessage());
+        }
+    }
+
+
+    /**
+     * 获取地区/联动医院
+     * Auth:Yuanhang-Liu
+     * Date:2020/10/14 17:17 *
+     * @return \Illuminate\Http\JsonResponse
+     */
+    public function get_city_id()
+    {
+        // 查询机构!
+        $req = request()->post();
+
+        $this->validate(request(), [
+            'level_type' => 'required|in:4',
+            'province|省或直辖市id' => 'required_if:level_type,==,4',
+            'city|市' => 'required_if:level_type,==,4',
+            'area|区' => 'required_if:level_type,==,4',
+        ]);
+        // 查找下医院
+//            $ids_string = explode(',',$req['organizations_ids']);
+        $province = trim($req['province']);
+        $city = trim($req['city']);
+        $area = trim($req['area']);
+
+
+        $where['province_id'] = $province;
+        $where['city_id'] = $city;
+        $where['area_id'] = $area;
+        $where['type'] = 1;
+        $Organization = Organization::with('offices')->where($where)->get()->toArray();
+        $qulire = Qualification::where('status', 1)->get();
+        $newList = [];
+
+        if ($Organization) {
+
+            foreach ($Organization as $k => $v) {
+                $newList[$k]['value'] = $v['id'];
+                $newList[$k]['label'] = $v['name'];
+                if ($v['offices']) {
+                    foreach ($v['offices'] as $kk => $vv) {
+                        $newList[$k]['children'][$kk]['value'] = $vv['id'];
+                        $newList[$k]['children'][$kk]['label'] = $vv['name'];
+                        if ($qulire) {
+                            foreach ($qulire as $p => $c) {
+                                $newList[$k]['children'][$kk]['children'][$p]['value'] = $c['id'];
+                                $newList[$k]['children'][$kk]['children'][$p]['label'] = $c['name'];
+                            }
+                        } else {
+                            unset($Organization[$k], $newList[$k]);
+                        }
+                    }
+                } else {
+                    unset($Organization[$k], $newList[$k]);
+                }
+            }
+        }
+        return out($newList);
+    }
+
+    /**
+     * 获取城市联动
+     * @return \Illuminate\Http\JsonResponse
+     * @author Liu-Yh
+     * Create By 2020/11/4 19:35
+     */
+    public function getCityList()
+    {
+        // 查询机构!
+        $req = request()->post();
+        $where['status'] = 1;
+        $data = Areas::where($where)->get(['id', 'name', 'level', 'parent_id'])->toArray();
+        $newData = [];
+        foreach ($data as $k => $v) {
+            $newData[$k]['value'] = $v['id'];
+            $newData[$k]['label'] = $v['name'];
+            $newData[$k]['pid'] = $v['parent_id'];
+        }
+        $list = $this->getTrees($newData);
+        $list = $this->getTree($list);
+        return out($list);
+    }
+
+    /**
+     * 获取城市树
+     * @param $data
+     * @return array
+     */
+    protected function getTrees($arr, $pid = 0)
+    {
+        static $list = [];
+
+        foreach ($arr as $key => $value) {
+            if ($value["pid"] == $pid) {
+                $list[] = $value;
+                unset($arr[$key]); //删除已经排好的数据为了减少遍历的次数,当然递归本身就很费神就是了
+                $this->getTrees($arr, $value["value"]);
+            }
+        }
+        return $list;
+    }
+
+    /**
+     * 整合树🌲
+     * @param $data
+     * @param $pId
+     * @return string
+     */
+    protected function getTree($data, $pId = 0)
+    {
+        $tree = [];
+        foreach ($data as $k => $v) {
+            if ($v['pid'] == $pId) {         //父亲找到儿子
+                $chid = $this->getTree($data, $v['value']);
+                if ($chid) {
+                    $v['children'] = $chid;
+                }
+                $tree[] = $v;
+                unset($data[$k]);
+            } else {
+                unset($data[$k]);
+
+            }
+        }
+        return $tree;
+    }
+
+
+    /*    public function getCityList(){
+            // 查询机构!
+            $req = request()->post();
+            $this->validate(request(), [
+                'type' => 'required|in:1,2,3',
+                'parent_id|父级id' => 'required_if:type,==,2|required_if:type,==,3|integer',
+            ]);//1=省,2=市,3=区
+            $where['level'] = $req['type'];
+            $where['status'] = 1;
+            if($req['type']==1){
+                $cityList = Areas::where($where)->get(['id','name'])->toArray();
+            }else if ($req['type']==2){
+                $where['parent_id']= $req['parent_id'];
+                $cityList = Areas::where($where)->get(['id','name'])->toArray();
+            }else if ($req['type']==3){
+                $where['parent_id']= $req['parent_id'];
+                $cityList = Areas::where($where)->get(['id','name'])->toArray();
+            }else{
+                return out('','','错误请求');
+            }
+            return out($cityList);
+        }*/
+
+    /**
+     * 获取科室和资质
+     * @return mixed
+     */
+    public function getOfferList()
+    {
+        // 查询机构!
+        $req = request()->post();
+        $this->validate(request(), [
+            'type' => 'required|in:1,2',
+        ]);//1=科室,2=资质
+        $type = $req['type'];
+        if ($type == 1) {
+            $List = Office::get(['id', 'name'])->toArray();
+        } else if ($type == 2) {
+            $List = Qualification::get(['id', 'name'])->toArray();
+        } else {
+            return out('', '', '错误请求');
+        }
+        return out($List);
+    }
+
+
+    /**
+     * 获取我的患者列表
+     * Auth:Yuanhang-Liu
+     * Date:2020/10/17 13:21
+     * @return \Illuminate\Http\JsonResponse
+     */
+    public function userList()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'userId' => 'integer',
+            'userType|用户类型' => 'integer|in:1,2,3,4,5,6,7',
+        ]);
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        if (!$doctor_id) {
+            return out(null, 500, '医生信息错误!');
+        }
+
+        $returnList = [];
+        $orderList = Order::with(['user'])->where('docter_id', '=', $doctor_id)->groupBy('id', 'product_type', 'user_id')->get()->toArray();
+        $collections = DocterUser::with('user')->where('docter_id', '=', $doctor_id)->groupBy('user_id')->get()->toArray();
+        $newList = [];
+        foreach ($orderList as $k => $v) {
+            $newList[$k]['order_id'] = $v['id'];
+            $newList[$k]['user_id'] = $v['user_id'];
+            $newList[$k]['order_sn'] = $v['order_sn'];
+            $newList[$k]['nickname'] = $v['user']['nickname'];
+            $save = UserDocter::where('user_id', '=', $v['user']['id'])->first();
+            if ($save) {
+                $newList[$k]['remark'] = $save['remark'];
+            } else {
+                $newList[$k]['remark'] = '';
+            }
+            $newList[$k]['avatar'] = $v['user']['avatar'];
+            $newList[$k]['product_type'] = $v['product_type'];
+        }
+        $newcoll = [];
+        foreach ($collections as $k => $v) {
+            $newcoll[$k]['id'] = $v['id'];
+            $newcoll[$k]['user_id'] = $v['user_id'];
+            $newcoll[$k]['nickname'] = $v['user']['nickname'];
+            $save = UserDocter::where('user_id', '=', $v['user_id'])->first();
+            if ($save) {
+                $newList[$k]['remark'] = $save['remark'];
+            } else {
+                $newList[$k]['remark'] = '';
+            }
+            $newcoll[$k]['avatar'] = $v['user']['avatar'];
+        }
+        $user_pic = [];
+        $user_relation = [];
+        $user_vaccines = [];
+        $user_guar = [];
+        $user_pack = [];
+
+
+        foreach ($newList as $k => $v) {
+            if ($v['product_type'] == 1 || $v['product_type'] == 2) {
+                // 咨询患者
+                if (!$this->putusers($user_pic, $v['user_id'])) {
+                    array_push($user_pic, $v);
+                }
+            }
+            if ($v['product_type'] == 3) {
+                // 门诊患者
+                if (!$this->putusers($user_relation, $v['user_id'])) {
+                    array_push($user_relation, $v);
+                }
+
+            }
+            if ($v['product_type'] == 4) {
+                // 疫苗患者
+                if (!$this->putusers($user_vaccines, $v['user_id'])) {
+                    array_push($user_vaccines, $v);
+                }
+
+
+            }
+            if ($v['product_type'] == 5) {
+                // 儿保预约
+                if (!$this->putusers($user_guar, $v['user_id'])) {
+                    array_push($user_guar, $v);
+                }
+            }
+            if ($v['product_type'] == 6) {
+                // 服务包
+                $OrderPacks = OrderPack::where('order_id', '=', $v['order_id'])->first();
+                if ($OrderPacks) {
+                    $teams = Team::with('docter')->where('id', '=', $OrderPacks['team_id'])->first();
+                    if ($teams) {
+                        $teams = $teams->toArray();
+                        if ($teams['docter']) {
+                            foreach ($teams['docter'] as $kk => $vv) {
+                                if ($vv['id'] == $doctor_id) {
+                                    array_push($user_pack, $v);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        $returnList['user_pic']['data'] = $user_pic;
+        $returnList['user_relation']['data'] = $user_relation;
+        $returnList['user_vaccines']['data'] = $user_vaccines;
+        $returnList['user_guar']['data'] = $user_guar;
+        $returnList['user_pack']['data'] = $user_pack;
+        if (empty($newcoll)) {
+            // 关注患者
+            $returnList['user_collection']['data'] = [];
+        } else {
+            $returnList['user_collection']['data'] = $newcoll;
+        }
+
+
+        $returnList['user_pic']['count'] = count($user_pic);
+        $returnList['user_relation']['count'] = count($user_relation);
+        $returnList['user_vaccines']['count'] = count($user_vaccines);
+        $returnList['user_guar']['count'] = count($user_guar);
+        $returnList['user_pack']['count'] = count($user_pack);
+        $returnList['user_collection']['count'] = count($returnList['user_collection']['data']);
+        return out($returnList);
+    }
+
+
+    /**
+     * 升级版 in_array
+     * @param $data1
+     * @param $data2
+     * @return bool
+     * @author Liu-Yh
+     * Create By 2020/11/27 16:18
+     */
+    protected function putusers($data1, $data2)
+    {
+        if (empty($data1)) {
+            return false;
+        }
+
+        $list = [];
+        foreach ($data1 as $k => $v) {
+            array_push($list, $v['user_id']);
+        }
+        if (in_array($data2, $list)) {
+            return true;
+        } else {
+            return false;
+        }
+
+    }
+
+
+    /**
+     * 上备注
+     * @return \Illuminate\Http\JsonResponse
+     * @author Liu-Yh
+     * Create By 2020/11/27 16:16
+     */
+    public function remacks()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'remak|备注' => 'required',
+            'id|id' => 'required',
+        ]);
+        $user = $this->user;
+        $user_id = $user['id'];
+        $wheres['docter_id'] = $user_id;
+        $wheres['user_id'] = $req['id'];
+        $save = UserDocter::where($wheres)->first();
+
+        if ($save) {
+            UserDocter::where('id', '=', $save['id'])->update([
+                'remark' => $req['remak']
+            ]);
+        } else {
+            UserDocter::create([
+                'docter_id' => $user_id,
+                'user_id' => $req['id'],
+                'remark' => $req['remak']
+            ]);
+        }
+        return out([]);
+
+
+    }
+
+    /**
+     * 评价列表
+     * @return \Illuminate\Http\JsonResponse
+     * @author Liu-Yh
+     * Create By 2020/11/17 17:41
+     */
+    public function evaluate()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'curPage' => 'required|integer',
+            'pageSize' => 'required|integer',
+        ]);
+        $pageSize = ($req['curPage'] - 1) * $req['pageSize'];
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        $wheres['docter_id'] = $doctor_id;
+        $wheres['status'] = 2;
+        $data = Evaluate::with(['order', 'user'])->where($wheres)->skip($pageSize)->take($req['pageSize'])->groupBy('id')->get()->toArray();;
+        if ($data) {
+            $newList = [];
+            foreach ($data as $k => $v) {
+                $newList[$k]['order_id'] = $v['order']['order_sn'];
+                $newList[$k]['user'] = $v['user']['nickname'];
+                $newList[$k]['lv'] = $v['score'];
+                $newList[$k]['time'] = $v['created_at'];
+                $newList[$k]['evaluate'] = $v['content'];
+            }
+            return out($newList);
+        } else {
+            return out([]);
+        }
+    }
+
+
+    /**
+     * 我的列表进入详情
+     * Auth:Yuanhang-Liu
+     * Date:2020/10/18 15:21
+     * @return \Illuminate\Http\JsonResponse
+     */
+    public function userListDetile()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'user_id|用户ID' => 'required|integer',
+            'userType|用户类型' => 'integer|in:1,2,3,4,5,6,7',
+        ]);
+        $user = $this->user;
+        // 查询详情;
+        $finds_patient = User::with('patients')->where('id', '=', $req['user_id'])->first();
+        $remarks = UserDocter::where('user_id', '=', $req['user_id'])->first();
+
+
+        $finds_order = Order::with('orderPatient')->where('user_id', '=', $req['user_id'])->orderBy('created_at', 'desc')->limit(3)->get();
+        if ($finds_order) {
+            $finds_order = $finds_order->toArray();
+        }
+        $userArr = $patientsArr = $orderArr = $fuwArr = [];
+        $patientsArr = [];
+        $ws['user_id'] = $req['user_id'];
+        $ws['product_type'] = 6;
+        $fuw_order = Order::with('orderPack')->where($ws)->orderBy('created_at', 'desc')->get();
+        if ($fuw_order) {
+            $fuw_order = $fuw_order->toArray();
+
+            foreach ($fuw_order as $kk => $vv) {
+                $fuwArr[$kk]['order_id'] = $vv['id'];
+                if ($vv['order_pack']) {
+                    foreach ($vv['order_pack'] as $k => $v) {
+                        $fuwArr[$kk]['id'] = $v['id'];
+                        $fuwArr[$kk]['pack_name'] = $v['pack_name'];
+                        $fuwArr[$kk]['pack_intro'] = $v['pack_intro'];
+                        $fuwArr[$kk]['pack_price'] = $v['pack_price'];
+                        $fuwArr[$kk]['effective_days'] = $v['effective_days'];
+                        $fuwArr[$kk]['start_time'] = date('Y-m-d,H:i', $v['start_time']);
+                        $fuwArr[$kk]['end_time'] = date('Y-m-d,H:i', $v['end_time']);
+                    }
+                }
+
+            }
+        }
+
+
+        if ($finds_patient) {
+            $finds_patient = $finds_patient->toArray();
+            $userArr['id'] = $finds_patient['id'];
+            if ($remarks) {
+                $userArr['remark'] = $remarks['remark']; //用户备注
+            } else {
+                $userArr['remark'] = ''; //用户备注
+            }
+            $userArr['nickname'] = $finds_patient['nickname'];
+            $userArr['avatar'] = $finds_patient['avatar'];
+            if ($finds_patient['patients']) {
+                foreach ($finds_patient['patients'] as $kk => $vv) {
+                    $patientsArr[$kk]['id'] = $vv['id'];
+                    $patientsArr[$kk]['avatar'] = $vv['avatar'];
+                    $patientsArr[$kk]['name'] = $vv['name'];
+                    if ($vv['sex'] == 0) {
+                        $patientsArr[$kk]['sex'] = '未知';
+                    } elseif ($vv['sex'] == 1) {
+                        $patientsArr[$kk]['sex'] = '男';
+                    } else {
+                        $patientsArr[$kk]['sex'] = '女';
+                    }
+                    $patientsArr[$kk]['age'] = numBirthday($vv['birthday']);
+                }
+            }
+        }
+
+
+        if ($finds_order) {
+            foreach ($finds_order as $k => $v) {
+                $orderArr[$k]['id'] = $v['id'];
+                $orderArr[$k]['order_sn'] = $v['order_sn'];
+                if ($v['order_status'] >= 4) {
+                    $orderArr[$k]['receiving_time'] = date('Y-m-d H:i', $v['receiving_time']);
+                    $orderArr[$k]['outtime'] = date('Y-m-d H:i', $v['end_time']);
+                } else {
+                    $orderArr[$k]['receiving_time'] = '';
+                    $orderArr[$k]['outtime'] = '';
+                }
+                $orderArr[$k]['order_status'] = $v['order_status'];
+                $orderArr[$k]['product_type'] = $v['product_type'];
+                $orderArr[$k]['created_at'] = $v['created_at'];
+                $orderArr[$k]['name'] = $v['order_patient']['name'];
+                $orderArr[$k]['birthday'] = numBirthday($v['order_patient']['birthday']);
+            }
+        }
+
+
+        // 拼接服务消息
+        $wh['user_id'] = $req['user_id'];
+        $wh['order_status'] = ['>', 3];
+        $wh['product_type'] = 6;
+        $fuwuList = [];
+        $fuwuInfo = Order::where($wh)->get();
+        $fuwuList['fuwu_num'] = count($fuwuInfo);
+        $whs['user_id'] = $req['user_id'];
+        $whs['order_status'] = ['>', 3];
+        $order_nums = Order::where($whs)->get();
+
+        $fuwuList['order_num'] = count($order_nums);
+        $pati_nums = Patient::where('user_id', '=', $req['user_id'])->get();
+        $fuwuList['pati_num'] = count($pati_nums);
+
+
+        $returnArr = [
+            'user_arr' => $userArr,
+            'patients_arr' => $patientsArr,//患者档案
+            'order_arr' => $orderArr, //历史问诊
+            'fuwu_arr' => $fuwArr, //已购服务
+            'nums' => $fuwuList,
+        ];
+        return out($returnArr);
+    }
+
+
+    /**
+     * 我的列表进入详情
+     * Auth:Yuanhang-Liu
+     * Date:2020/10/20 23:21
+     * @return \Illuminate\Http\JsonResponse
+     */
+    public function patientsDetile()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'patient_id|患者ID' => 'required|integer',
+        ]);
+        $user = $this->user;
+        $finds = Patient::where('id', '=', $req['patient_id'])->first();
+        if ($finds) {
+            $finds = $finds->toArray();
+        }
+        if ($finds['sex'] == 0) {
+            $finds['sex'] = '中性';
+        } elseif ($finds['sex'] == 1) {
+            $finds['sex'] = '男';
+        } else {
+            $finds['sex'] = '女';
+        }
+
+        switch ($finds['relationship_type']) {
+            case 1:
+                $finds['relationship_type'] = '父亲';
+                break;
+            case 2:
+                $finds['relationship_type'] = '母亲';
+                break;
+            case 3:
+                $finds['relationship_type'] = '祖父';
+                break;
+            case 4:
+                $finds['relationship_type'] = '祖母';
+                break;
+            case 5:
+                $finds['relationship_type'] = '外祖父';
+                break;
+            case 6:
+                $finds['relationship_type'] = '外祖母';
+                break;
+            case 7:
+                $finds['relationship_type'] = '叔侄';
+                break;
+            default:
+                $finds['relationship_type'] = '其他';
+        }
+        $finds['age'] = numBirthday($finds['birthday']);
+        // 患者单子
+        $patient_list = OrderPatient::with('order')->where('patient_id', '=', $req['patient_id'])->groupBy('id', 'order_id')->get();
+        $patient_arr = [];
+        if ($patient_list) {
+            $patient_list = $patient_list->toArray();
+            foreach ($patient_list as $k => $v) {
+                switch ($v['order']['product_type']) {
+                    case 1:
+                        $patient_arr[$k]['product_type'] = '电话咨询';
+                        break;
+                    case 2:
+                        $patient_arr[$k]['product_type'] = '图文咨询';
+                        break;
+                    case 3:
+                        $patient_arr[$k]['product_type'] = '门诊';
+                        break;
+                    case 4:
+                        $patient_arr[$k]['product_type'] = '疫苗接种预约';
+                        break;
+                    case 5:
+                        $patient_arr[$k]['product_type'] = '儿保预约';
+                        break;
+                    case 6:
+                        $patient_arr[$k]['product_type'] = '服务包';
+                        break;
+                    case 7:
+                        $patient_arr[$k]['product_type'] = '充值';
+                        break;
+                    default:
+                        $patient_arr[$k]['product_type'] = '错误';
+                }
+                switch ($v['order']['order_status']) {
+                    case 1:
+                        $patient_arr[$k]['order_status'] = '未支付';
+                        break;
+                    case 2:
+                        $patient_arr[$k]['order_status'] = '待接单';
+                        break;
+                    case 3:
+                        $patient_arr[$k]['order_status'] = '进行中';
+                        break;
+                    case 4:
+                        $patient_arr[$k]['order_status'] = '已完成';
+                        break;
+                    case 5:
+                        $patient_arr[$k]['order_status'] = '已取消';
+                        break;
+                    default:
+                        $patient_arr[$k]['order_status'] = '未知';
+                }
+                $patient_arr[$k]['created_at'] = $v['created_at'];
+            }
+        }
+
+        $returnArr = [
+            'patient' => $finds,
+            'patientOrder' => $patient_arr,
+        ];
+        return out($returnArr);
+    }
+
+    /**
+     * 关注用户
+     * Auth:Yuanhang-Liu
+     * Date:2020/10/21 00:21
+     * @return \Illuminate\Http\JsonResponse
+     */
+    public function userFollow()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'user_id|用户ID' => 'required|integer',
+            'is_ley' => 'required',
+        ]);
+        // 如果ley==false说明要取消关注,反之添加关注
+        $user = $this->user;
+        $docter_id = $user['id'];
+
+        if ($req['is_ley'] == 1) {
+            DocterUser::where('user_id', '=', $req['user_id'])->delete();
+        } else {
+            DocterUser::create([
+                'user_id' => $req['user_id'],
+                'docter_id' => $user['id'],
+            ]);
+        }
+        return out();
+    }
+
+    /**
+     * 是否关注用户
+     * Auth:Yuanhang-Liu
+     * Date:2020/10/21 00:21
+     * @return \Illuminate\Http\JsonResponse
+     */
+    public function getFollows()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'user_id|用户ID' => 'required|integer',
+        ]);
+        $user = $this->user;
+        $docter_id = $user['id'];
+        $where['docter_id'] = $docter_id;
+        $where['user_id'] = $req['user_id'];
+        $find = DocterUser::where($where)->first();
+
+        if ($find) {
+            $find = $find->toArray();
+            return out(true);
+        } else {
+            return out(false);
+        }
+    }
+
+    /**
+     * 获取医生所在机构列表
+     * Auth:Yuanhang-Liu
+     * Date:2020/10/21 00:21
+     * @return \Illuminate\Http\JsonResponse
+     */
+    public function organizationList()
+    {
+
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        $where['docter_id'] = $doctor_id;
+        $where['state'] = 1;
+        $orgList = DocterOrganization::with('organization')->where($where)->get()->toArray();
+        $newList = [];
+        foreach ($orgList as $k => $v) {
+            $newList[$k]['value'] = $v['organization']['id'];
+            $newList[$k]['label'] = $v['organization']['name'];
+        }
+        return out($newList);
+    }
+
+
+    /**
+     * 获取医院的服务时间
+     * @return mixed
+     */
+    public function getOrgTimes()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'org_id|医院id' => 'required',
+        ]);
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        $where['docter_id'] = $doctor_id;
+        $orgList = DocterSetting::where(['docter_id'=>$doctor_id,'type'=>1,'org_id'=>$req['org_id']])->first();
+        $newList = [];
+
+        if($orgList){
+            $time = json_decode($orgList['service_time'],true);
+            $newList['zao']['amStartTime'] = isset($time[1])?$time[1]['amStartTime']:'';
+            $newList['zao']['amEndTime'] = isset($time[1])?$time[1]['amEndTime']:'';
+            $newList['zao']['amPerson'] = isset($time[1])?$time[1]['amPerson']:'';
+
+            $newList['zhong']['pmStartTime'] = isset($time[2])?$time[2]['pmStartTime']:'';
+            $newList['zhong']['pmEndTime'] = isset($time[2])?$time[2]['pmEndTime']:'';
+            $newList['zhong']['pmPerson'] = isset($time[2])?$time[2]['pmPerson']:'';
+
+            $newList['wan']['nightStartTime'] = isset($time[3])?$time[3]['nightStartTime']:'';
+            $newList['wan']['nightEndTime'] = isset($time[3])?$time[3]['nightEndTime']:'';
+            $newList['wan']['nightPerson'] = isset($time[3])?$time[3]['nightPerson']:'';
+        }
+
+        return out($newList);
+    }
+
+    /**
+     * 获取历史排班时间列表
+     */
+    public function getLinsList()
+    {
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        $newData = [];
+        $strim = date('Y-m-d', (time() + (7 - (date('w') == 0 ? 7 : date('w'))) * 24 * 3600));
+        $wheres['docter_id'] = $doctor_id;
+        $data = Schedule::select(['id', 'schedule_date'])->where($wheres)->whereDate('schedule_date', '>', $strim)->orderBy('schedule_date', 'desc')->get();
+        if ($data) {
+            $data = $data->toArray();
+        } else {
+            return out($newData);
+        }
+
+//        $newDates = [];
+//        foreach ($data as $k=>$v){
+//            if((time() + (7 - (date('w') == 0 ? 7 : date('w'))) * 24 * 3600) > strtotime($v['schedule_date'])){
+//                array_push($newDates,$data[$k]);
+//            }
+//        }
+//        $data =$newDates;
+//        $k=1;
+//        foreach ($data as $v){
+//            $newData[$k]=$v;
+//            $k++;
+//        }
+        $newData = array_values($data);
+        $lab = [];
+        $p = 0;
+        for ($i = count($newData); $i > 0; $i--) {
+//            if ($i%7==0||$i==1){
+//
+//                if ($p>=1){
+//                    $lab[$p-1]['end_time'] = $arr[$i-1];
+//                    $lab[$p]['start_time'] = $arr[$i-1];
+//                    if(isset($arr[$i-7])){
+//                        $lab[$p]['end_time'] = isset($arr[$i-7])?$arr[$i-7]:'error';
+//
+//                    }else{
+//                        unset($lab[$p]);
+//                    }
+////                    $lab[$p]['end_time'] = isset($arr[$i-7])?$arr[$i-7]:'error';
+//                }else{
+//                    $lab[$p]['start_time'] = $arr[$i-1];
+//                }
+//                ++$p;
+//            }else{
+//                continue;
+//            }
+            if ($i % 7 == 0 || $i == 1) {
+                if ($p >= 1) {
+                    $lab[$p - 1]['end_time'] = $newData[$i - 1];
+                    if (isset($newData[$i - 7])) {
+                        $lab[$p]['start_time'] = $newData[$i - 1];
+                        $lab[$p]['end_time'] = $newData[$i - 7];
+                    } else {
+                        unset($lab[$p]);
+                    }
+                } else {
+                    $lab[$p]['start_time'] = $newData[$i - 1];
+                }
+                ++$p;
+            } else {
+                continue;
+            }
+        }
+        // 审核通过时间拿出来
+        $wh['docter_id'] = $doctor_id;
+        $wh['service_type'] = 3;
+        $wh['status'] = 2;
+        $service = ServiceApply::where($wh)->first();
+        if ($service) {
+            $service = $service;
+        } else {
+            $service = 0;
+        }
+        $rtuenList = [
+            'list' => $lab,
+            'service' => $service,
+        ];
+        return out($rtuenList);
+    }
+
+
+    /**
+     * 获取历史排班详情(废弃)
+     */
+    public function getLinsDetail()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'start_date|开始时间' => 'required',
+            'end_date|结束时间' => 'required',
+        ]);
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        $newData = [];
+        $req['start_date'] = date("Y-m-d", strtotime($req['start_date']));
+        $req['end_date'] = date("Y-m-d", strtotime($req['end_date']));
+//        $data = Schedule::with(['schedulePeriod'])->orderBy('id','desc')->get();
+        $data = SchedulePeriod::with('organization')->where('docter_id', '=', $doctor_id)->whereBetween('schedule_date', [$req['start_date'], $req['end_date']])->groupBy('schedule_id', 'type')->get();
+        if ($data) {
+            $data = $data->toArray();
+        } else {
+            return out($newData);
+        }
+
+        $lab = [];
+        $datesList = getDateFromList($req['start_date'], $req['end_date']);
+        foreach ($data as $k => $v) {
+            $lab[$k]['schedule_id'] = $v['schedule_id'];
+            $lab[$k]['type'] = $v['type']; // 1=早上,2=下午,3=晚上
+            switch (date('w', strtotime($v['schedule_date']))) {
+                case "0":
+                    $lab[$k]['week'] = '周日';
+                    break;
+                case "1":
+                    $lab[$k]['week'] = '周一';
+                    break;
+                case "2":
+                    $lab[$k]['week'] = '周二';
+                    break;
+                case "3":
+                    $lab[$k]['week'] = '周三';
+                    break;
+                case "4":
+                    $lab[$k]['week'] = '周四';
+                    break;
+                case "5":
+                    $lab[$k]['week'] = '周五';
+                    break;
+                default:
+                    $lab[$k]['week'] = '周六';
+            }
+            $lab[$k]['schedule_date'] = date('m-d', strtotime($v['schedule_date'])); // 日期
+            $lab[$k]['name'] = $v['organization']; // 所在医院
+            $lab[$k]['flag'] = $v['me_sure']; // 所在医院
+        }
+        $newLists = [];
+        $newReturn = [];
+        foreach ($lab as $k => $v) {
+            if (!isset($newLists[$v['schedule_id']])) {
+                $newLists[$v['schedule_id']] = $v;
+                $newReturn[$v['schedule_id']]['schedule_id'] = $v['schedule_id'];
+                if ($v['type'] == 1) {
+                    if ($v['flag'] != 0) {
+                        $newReturn[$v['schedule_id']]['type']['zao_flag'] = true;
+                        $newReturn[$v['schedule_id']]['type']['xia_flag'] = false;
+                        $newReturn[$v['schedule_id']]['type']['wan_flag'] = false;
+                    } else {
+                        $newReturn[$v['schedule_id']]['type']['zao_flag'] = false;
+                        $newReturn[$v['schedule_id']]['type']['xia_flag'] = false;
+                        $newReturn[$v['schedule_id']]['type']['wan_flag'] = false;
+                    }
+                    $newReturn[$v['schedule_id']]['type']['zao'] = $v['name']['name'];
+                    $newReturn[$v['schedule_id']]['type']['xia'] = false;
+                    $newReturn[$v['schedule_id']]['type']['wan'] = false;
+                    $newReturn[$v['schedule_id']]['type']['zao_id'] = $v['name']['id'];
+                    $newReturn[$v['schedule_id']]['type']['xia_id'] = 0;
+                    $newReturn[$v['schedule_id']]['type']['wan_id'] = 0;
+                } else if ($v['type'] == 2) {
+                    if ($v['flag'] != 0) {
+                        $newReturn[$v['schedule_id']]['type']['zao_flag'] = false;
+                        $newReturn[$v['schedule_id']]['type']['xia_flag'] = true;
+                        $newReturn[$v['schedule_id']]['type']['wan_flag'] = false;
+                    } else {
+                        $newReturn[$v['schedule_id']]['type']['zao_flag'] = false;
+                        $newReturn[$v['schedule_id']]['type']['xia_flag'] = false;
+                        $newReturn[$v['schedule_id']]['type']['wan_flag'] = false;
+                    }
+                    $newReturn[$v['schedule_id']]['type']['zao'] = false;
+                    $newReturn[$v['schedule_id']]['type']['xia'] = $v['name']['name'];
+                    $newReturn[$v['schedule_id']]['type']['wan'] = false;
+
+                    $newReturn[$v['schedule_id']]['type']['zao_id'] = 0;
+                    $newReturn[$v['schedule_id']]['type']['xia_id'] = $v['name']['id'];
+                    $newReturn[$v['schedule_id']]['type']['wan_id'] = 0;
+                } else {
+
+                    if ($v['flag'] != 0) {
+                        $newReturn[$v['schedule_id']]['type']['zao_flag'] = false;
+                        $newReturn[$v['schedule_id']]['type']['xia_flag'] = false;
+                        $newReturn[$v['schedule_id']]['type']['wan_flag'] = true;
+                    } else {
+                        $newReturn[$v['schedule_id']]['type']['zao_flag'] = false;
+                        $newReturn[$v['schedule_id']]['type']['xia_flag'] = false;
+                        $newReturn[$v['schedule_id']]['type']['wan_flag'] = false;
+                    }
+
+                    $newReturn[$v['schedule_id']]['type']['zao'] = false;
+                    $newReturn[$v['schedule_id']]['type']['xia'] = false;
+                    $newReturn[$v['schedule_id']]['type']['wan'] = $v['name']['name'];
+
+                    $newReturn[$v['schedule_id']]['type']['zao_id'] = 0;
+                    $newReturn[$v['schedule_id']]['type']['xia_id'] = 0;
+                    $newReturn[$v['schedule_id']]['type']['wan_id'] = $v['name']['id'];
+                }
+                $newReturn[$v['schedule_id']]['week'] = $v['week'];
+                $newReturn[$v['schedule_id']]['schedule_date'] = $v['schedule_date'];
+                $newReturn[$v['schedule_id']]['name'] = $v['name'];
+            } else {
+                if ($v['type'] == 1) {
+                    if ($v['flag'] != 0) {
+                        $newReturn[$v['schedule_id']]['type']['zao_flag'] = true;
+                    } else {
+                        $newReturn[$v['schedule_id']]['type']['zao_flag'] = false;
+                    }
+                    $newReturn[$v['schedule_id']]['type']['zao'] = $v['name']['name'];
+                    $newReturn[$v['schedule_id']]['type']['zao_id'] = $v['name']['id'];
+                } else if ($v['type'] == 2) {
+                    $newReturn[$v['schedule_id']]['type']['xia'] = $v['name']['name'];
+                    if ($v['flag'] != 0) {
+                        $newReturn[$v['schedule_id']]['type']['xia_flag'] = true;
+                    } else {
+                        $newReturn[$v['schedule_id']]['type']['xia_flag'] = false;
+                    }
+                    $newReturn[$v['schedule_id']]['type']['xia_id'] = $v['name']['id'];
+
+                } else {
+                    $newReturn[$v['schedule_id']]['type']['wan'] = $v['name']['name'];
+                    if ($v['flag'] != 0) {
+                        $newReturn[$v['schedule_id']]['type']['wan_flag'] = true;
+                    } else {
+                        $newReturn[$v['schedule_id']]['type']['wan_flag'] = false;
+                    }
+                    $newReturn[$v['schedule_id']]['type']['wan_id'] = $v['name']['id'];
+                }
+            }
+        }
+
+        $returnLists['list'] = array_values($newReturn);
+        $instartTimes = $req['start_date'];
+        // 判断数据库有没有这个时间段
+        $whr['docter_id'] = $doctor_id;
+        $whr['schedule_date'] = $instartTimes;
+        $finds = Schedule::where($whr)->first();
+        if ($finds) {
+            $returnLists['save_flag'] = false;
+        } else {
+            $returnLists['save_flag'] = true;
+        }
+        return out($returnLists);
+    }
+
+    /**
+     * 获取周模板详情
+     * @return \Illuminate\Http\JsonResponse
+     * @author Liu-Yh
+     * Create By 2020/12/16 12:09
+     */
+    public function getLinsDetailnew()
+    {
+        $req = request()->post();
+
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        $newData = [];
+
+//        $data = Schedule::with(['schedulePeriod'])->orderBy('id','desc')->get();
+        $data = WeekSchedule::with('organization')->where('docter_id', '=', $doctor_id)->groupBy('type', 'week')->orderBy('week', 'asc')->get();
+
+        if ($data) {
+            $data = $data->toArray();
+        } else {
+            return out($newData);
+        }
+
+        $lab = [];
+
+        foreach ($data as $k => $v) {
+            $lab[$k]['id'] = $v['id'];
+            $lab[$k]['type'] = $v['type']; // 1=早上,2=下午,3=晚上
+            $lab[$k]['organization_id'] = $v['organization_id']; // 1=早上,2=下午,3=晚上
+            $lab[$k]['flag'] = $v['week'];
+
+            switch ($v['week']) {
+                case "7":
+                    $lab[$k]['week'] = '周日';
+                    break;
+                case "1":
+                    $lab[$k]['week'] = '周一';
+                    break;
+                case "2":
+                    $lab[$k]['week'] = '周二';
+                    break;
+                case "3":
+                    $lab[$k]['week'] = '周三';
+                    break;
+                case "4":
+                    $lab[$k]['week'] = '周四';
+                    break;
+                case "5":
+                    $lab[$k]['week'] = '周五';
+                    break;
+                default:
+                    $lab[$k]['week'] = '周六';
+            }
+            $lab[$k]['name'] = $v['organization']; // 所在医院
+        }
+        $weekList = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'];
+
+        try {
+            $newReturn = [];
+
+            foreach ($lab as $k => $v) {
+                if (!isset($newReturn[$v['flag']])) {
+                    $newReturn[$v['flag']] = $v;
+                    if ($v['type'] == 1) {
+                        if ($v['flag'] != 0) {
+                            $newReturn[$v['flag']]['ident']['zao_flag'] = true;
+                            $newReturn[$v['flag']]['ident']['xia_flag'] = false;
+                            $newReturn[$v['flag']]['ident']['wan_flag'] = false;
+                        } else {
+                            $newReturn[$v['flag']]['ident']['zao_flag'] = false;
+                            $newReturn[$v['flag']]['ident']['xia_flag'] = false;
+                            $newReturn[$v['flag']]['ident']['wan_flag'] = false;
+                        }
+                        $newReturn[$v['flag']]['ident']['zao'] = $v['name']['name'];
+                        $newReturn[$v['flag']]['ident']['xia'] = false;
+                        $newReturn[$v['flag']]['ident']['wan'] = false;
+                        $newReturn[$v['flag']]['ident']['zao_id'] = $v['name']['id'];
+                        $newReturn[$v['flag']]['ident']['xia_id'] = 0;
+                        $newReturn[$v['flag']]['ident']['wan_id'] = 0;
+                    } else if ($v['type'] == 2) {
+                        if ($v['flag'] != 0) {
+                            $newReturn[$v['flag']]['ident']['zao_flag'] = false;
+                            $newReturn[$v['flag']]['ident']['xia_flag'] = true;
+                            $newReturn[$v['flag']]['ident']['wan_flag'] = false;
+                        } else {
+                            $newReturn[$v['flag']]['ident']['zao_flag'] = false;
+                            $newReturn[$v['flag']]['ident']['xia_flag'] = false;
+                            $newReturn[$v['flag']]['ident']['wan_flag'] = false;
+                        }
+                        $newReturn[$v['flag']]['ident']['zao'] = false;
+                        $newReturn[$v['flag']]['ident']['xia'] = $v['name']['name'];
+                        $newReturn[$v['flag']]['ident']['wan'] = false;
+
+                        $newReturn[$v['flag']]['ident']['zao_id'] = 0;
+                        $newReturn[$v['flag']]['ident']['xia_id'] = $v['name']['id'];
+                        $newReturn[$v['flag']]['ident']['wan_id'] = 0;
+                    } else {
+                        if ($v['flag'] != 0) {
+                            $newReturn[$v['flag']]['ident']['zao_flag'] = false;
+                            $newReturn[$v['flag']]['ident']['xia_flag'] = false;
+                            $newReturn[$v['flag']]['ident']['wan_flag'] = true;
+                        } else {
+                            $newReturn[$v['flag']]['ident']['zao_flag'] = false;
+                            $newReturn[$v['flag']]['ident']['xia_flag'] = false;
+                            $newReturn[$v['flag']]['ident']['wan_flag'] = false;
+                        }
+                        $newReturn[$v['flag']]['ident']['zao'] = false;
+                        $newReturn[$v['flag']]['ident']['xia'] = false;
+                        $newReturn[$v['flag']]['ident']['wan'] = $v['name']['name'];
+                        $newReturn[$v['flag']]['ident']['zao_id'] = 0;
+                        $newReturn[$v['flag']]['ident']['xia_id'] = 0;
+                        $newReturn[$v['flag']]['ident']['wan_id'] = $v['name']['id'];
+                    }
+                    $newReturn[$v['flag']]['week'] = $v['week'];
+                    $newReturn[$v['flag']]['name'] = $v['name'];
+                } else {
+                    if ($v['type'] == 1) {
+                        if ($v['flag'] != 0) {
+                            $newReturn[$v['flag']]['ident']['zao_flag'] = true;
+                        } else {
+                            $newReturn[$v['flag']]['ident']['zao_flag'] = false;
+                        }
+                        $newReturn[$v['flag']]['ident']['zao'] = $v['name']['name'];
+                        $newReturn[$v['flag']]['ident']['zao_id'] = $v['name']['id'];
+                    } else if ($v['type'] == 2) {
+                        $newReturn[$v['flag']]['ident']['xia'] = $v['name']['name'];
+                        if ($v['flag'] != 0) {
+                            $newReturn[$v['flag']]['ident']['xia_flag'] = true;
+                        } else {
+                            $newReturn[$v['flag']]['ident']['xia_flag'] = false;
+                        }
+                        $newReturn[$v['flag']]['ident']['xia_id'] = $v['name']['id'];
+
+                    } else {
+                        $newReturn[$v['flag']]['ident']['wan'] = $v['name']['name'];
+                        if ($v['flag'] != 0) {
+                            $newReturn[$v['flag']]['ident']['wan_flag'] = true;
+                        } else {
+                            $newReturn[$v['flag']]['ident']['wan_flag'] = false;
+                        }
+                        $newReturn[$v['flag']]['ident']['wan_id'] = $v['name']['id'];
+                    }
+                }
+                unset($newReturn[$v['flag']]['name']);
+
+            }
+        } catch (\Exception $e) {
+            var_dump($e->getMessage() . $e->getFile() . $e->getLine());
+        }
+
+
+        $returnLists['list'] = array_values($newReturn);
+
+        return out($returnLists);
+    }
+
+    /**
+     * 门诊排班(废弃)
+     * Auth:Yuanhang-Liu
+     * Date:2020/10/21 00:21
+     * @return \Illuminate\Http\JsonResponse
+     */
+    public function scheduling()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'data|数据' => 'required',
+        ]);
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        $data = json_decode($req['data'], true);
+        $schedule = [];
+        $morning = [];//早上
+        $afternoon = [];//下午
+        $night = [];//晚上
+        $zaoTimes = [];
+        $zhongTimes = [];
+        $wanTimes = [];
+        $configs = SystemConfig::get()->toArray();
+        if (isset($configs[0]['value']) && !empty($configs[0]['value'])) {
+            $zaoTimes[0] = $configs[0]['value'];
+        } else {
+            $zaoTimes[0] = "09:00";
+        }
+        if (isset($configs[1]['value']) && !empty($configs[1]['value'])) {
+            $zaoTimes[1] = $configs[1]['value'];
+        } else {
+            $zaoTimes[1] = "12:00";
+        }
+        if (isset($configs[2]['value']) && !empty($configs[2]['value'])) {
+            $zhongTimes[0] = $configs[2]['value'];
+        } else {
+            $zhongTimes[0] = "13:00";
+        }
+        if (isset($configs[3]['value']) && !empty($configs[3]['value'])) {
+            $zhongTimes[1] = $configs[3]['value'];
+        } else {
+            $zhongTimes[1] = "18:00";
+        }
+        if (isset($configs[4]['value']) && !empty($configs[4]['value'])) {
+            $wanTimes[0] = $configs[4]['value'];
+        } else {
+            $wanTimes[0] = "19:00";
+        }
+        if (isset($configs[5]['value']) && !empty($configs[5]['value'])) {
+            $wanTimes[1] = $configs[5]['value'];
+        } else {
+            $wanTimes[1] = "21:00";
+        }
+
+        $morningd = TimePeriod::where('start_time_period', '>=', $zaoTimes[0])->where('end_time_period', '<=', $zaoTimes[1])->get()->toArray();
+        $morning = array_column($morningd, 'id');
+        $afternoond = TimePeriod::where('start_time_period', '>=', $zhongTimes[0])->where('end_time_period', '<=', $zhongTimes[1])->get()->toArray();
+        $afternoon = array_column($afternoond, 'id');
+        $nightd = TimePeriod::where('start_time_period', '>=', $wanTimes[0])->where('end_time_period', '<=', $wanTimes[1])->get()->toArray();
+        $night = array_column($nightd, 'id');
+        // 先进行删除
+        DB::beginTransaction();
+        try {
+            foreach ($data as $k => $v) {
+                // 删除
+                Schedule::where('schedule_date', '=', $v["schedule_date"])->delete();
+                SchedulePeriod::where('schedule_date', '=', $v['schedule_date'])->delete();
+                $schedule[$k]['schedule_date'] = $v['schedule_date'];
+                $schedule[$k]['schedule_day'] = str_replace('-', '', $v['schedule_date']);
+                $schedule[$k]['docter_id'] = $doctor_id;
+                $schedule[$k]['organization_id'] = 0;
+                $schedule[$k]['per_time_num'] = 10;
+                $sid = Schedule::insertGetId($schedule[$k]);
+                // 插入详情
+                if ($v['hospital'][0]['organization_id']) {
+                    $maf = $this->getMaf($sid, $morning, ['organization_id' => $v['hospital'][0]['organization_id'], 'schedule_date' => $v['schedule_date'], 'type' => 1], $doctor_id);
+                    SchedulePeriod::insert($maf);
+                }
+                if ($v['hospital'][1]['organization_id']) {
+                    $maf = $this->getMaf($sid, $afternoon, ['organization_id' => $v['hospital'][1]['organization_id'], 'schedule_date' => $v['schedule_date'], 'type' => 2], $doctor_id);
+                    SchedulePeriod::insert($maf);
+                }
+                if ($v['hospital'][2]['organization_id']) {
+                    $maf = $this->getMaf($sid, $night, ['organization_id' => $v['hospital'][2]['organization_id'], 'schedule_date' => $v['schedule_date'], 'type' => 3], $doctor_id);
+                    SchedulePeriod::insert($maf);
+                }
+            }
+            DB::commit();
+            return out('', '', '成功');
+        } catch (\Exception $e) {
+            DB::rollBack();
+            return out('', 500, $e->getFile() . '中的第:' . $e->getLine() . '行报错:' . $e->getCode(), $e->getMessage());
+        }
+
+    }
+
+
+    /**
+     * 生成时间段
+     * @param int $org_id 机构id
+     * @param int $type 时间段,1=早上,2=下午,3=晚上
+     * @return array|bool
+     * @author Liu-Yh
+     * Create By 2020/12/15 18:47
+     */
+    protected function num_time($org_id = 0, $type = 1)
+    {
+
+
+
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        $zaoTimes = [];
+        $zhongTimes = [];
+        $wanTimes = [];
+        $where['docter_id'] = $doctor_id;
+        $where['type'] = 1;
+        $where['org_id'] = $org_id;
+        $configs = DocterSetting::where($where)->first();
+
+        if ($configs) {
+            $list = json_decode($configs['service_time'], true);
+            if (isset($list[1]['amStartTime']) && !empty($list[1]['amStartTime'])) {
+                $zaoTimes[0] = $list[1]['amStartTime'];
+            } else {
+                $zaoTimes[0] = "08:00";
+            }
+            if (isset($list[1]['amEndTime']) && !empty($list[1]['amEndTime'])) {
+                $zaoTimes[1] = $list[1]['amEndTime'];
+            } else {
+                $zaoTimes[1] = "12:00";
+            }
+            if (isset($list[2]['pmStartTime']) && !empty($list[2]['pmStartTime'])) {
+                $zhongTimes[0] = $list[2]['pmStartTime'];
+            } else {
+                $zhongTimes[0] = "13:00";
+            }
+            if (isset($list[2]['pmEndTime']) && !empty($list[2]['pmEndTime'])) {
+                $zhongTimes[1] = $list[2]['pmEndTime'];
+            } else {
+                $zhongTimes[1] = "18:00";
+            }
+            if (isset($list[3]['nightStartTime']) && !empty($list[3]['nightStartTime'])) {
+                $wanTimes[0] = $list[3]['nightStartTime'];
+            } else {
+                $wanTimes[0] = "19:00";
+            }
+            if (isset($list[3]['nightEndTime']) && !empty($list[3]['nightEndTime'])) {
+                $wanTimes[1] = $list[3]['nightEndTime'];
+            } else {
+                $wanTimes[1] = "21:00";
+            }
+        } else {
+            return false;
+        }
+        if ($type == 1) {
+            $morningWhere[] = ['start_time_period', '>=', $zaoTimes[0]];
+            $morningWhere[] = ['end_time_period', '<=', $zaoTimes[1]];
+            $morningWhere['docter_id'] = $doctor_id;
+            $morningWhere['org_id'] = $org_id;
+
+            $morningd = TimePeriod::where($morningWhere)->get()->toArray();
+
+            array_pop($morningd);
+            $morning = array_column($morningd, 'id');
+            return $morning;
+        } elseif ($type == 2) {
+            $afternoondWhere[] = ['start_time_period', '>=', $zhongTimes[0]];
+            $afternoondWhere[] = ['end_time_period', '<=', $zhongTimes[1]];
+            $afternoondWhere['docter_id'] = $doctor_id;
+            $afternoondWhere['org_id'] = $org_id;
+            $afternoond = TimePeriod::where($afternoondWhere)->get()->toArray();
+            array_pop($afternoond);
+            $afternoon = array_column($afternoond, 'id');
+            return $afternoon;
+
+        } elseif ($type == 3) {
+            $nightWhere[] = ['start_time_period', '>=', $wanTimes[0]];
+            $nightWhere[] = ['end_time_period', '<=', $wanTimes[1]];
+            $nightWhere['docter_id'] = $doctor_id;
+            $nightWhere['org_id'] = $org_id;
+            $nightd = TimePeriod::where($nightWhere)->get()->toArray();
+            array_pop($nightd);
+            $night = array_column($nightd, 'id');
+            return $night;
+
+        } else {
+            $morningWhere[] = ['start_time_period', '>=', $zaoTimes[0]];
+            $morningWhere[] = ['end_time_period', '<=', $zaoTimes[1]];
+            $morningWhere['docter_id'] = $doctor_id;
+            $morningWhere['org_id'] = $org_id;
+            $morningd = TimePeriod::where($morningWhere)->get()->toArray();
+            array_pop($morningd);
+            $morning = array_column($morningd, 'id');
+
+            $afternoondWhere[] = ['start_time_period', '>=', $zhongTimes[0]];
+            $afternoondWhere[] = ['end_time_period', '<=', $zhongTimes[1]];
+            $afternoondWhere['docter_id'] = $doctor_id;
+            $afternoondWhere['org_id'] = $org_id;
+            $afternoond = TimePeriod::where($afternoondWhere)->get()->toArray();
+            array_pop($afternoond);
+            $afternoon = array_column($afternoond, 'id');
+
+            $nightWhere[] = ['start_time_period', '>=', $wanTimes[0]];
+            $nightWhere[] = ['end_time_period', '<=', $wanTimes[1]];
+            $nightWhere['docter_id'] = $doctor_id;
+            $nightWhere['org_id'] = $org_id;
+            $nightd = TimePeriod::where($nightWhere)->get()->toArray();
+            array_pop($nightd);
+            $night = array_column($nightd, 'id');
+            return [$morning, $afternoon, $night];
+        }
+    }
+
+
+    /**
+     * 获取俩月日期
+     * @return array
+     */
+    protected function date_bool($start_time = false, $end_time = false)
+    {
+        $weekarray = array(7, 1, 2, 3, 4, 5, 6);
+        $monthDays = [];
+
+        if ($start_time && $end_time) {
+            $firstDay = $start_time;
+            $lastDay = $end_time;
+        } else {
+            $firstDay = date('Y-m-01', time());
+            $lastDay = date('Y-m-d', strtotime("$firstDay +2 month -1 day"));
+        }
+
+        $i = 0;
+        while (date('Y-m-d', strtotime("$firstDay +$i days")) <= $lastDay) {
+            $monthDays[$i]['date'] = date('Y-m-d', strtotime("$firstDay +$i days"));
+            $monthDays[$i]['week'] = $weekarray[date("w", strtotime("$firstDay +$i days"))];
+            $i++;
+        }
+        return $monthDays;
+    }
+
+
+    /**
+     * 新版门诊排班(排班周模板)
+     * @return mixed
+     * @throws \Exception
+     */
+    public function week_scheduling()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'data|数据' => 'required',
+        ]);
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        $data = json_decode($req['data'], true);
+
+        $moth_date = $this->date_bool();
+        // 添加到周模板(不管时间)
+        $weekList = [];
+        $weekModel = new WeekSchedule();
+        // 先进行删除
+        $counts = Schedule::where('schedule_date', '>=', $moth_date[0]['date'])->where('docter_id',$doctor_id)->where('schedule_date', '<=', end($moth_date)['date'])->get();
+        // 12个月平均两个月最短是29天
+        $selfWhere['docter_id'] = $doctor_id;
+        $selfWhere[] = ['schedule_date','>=',date('Y-m-d',time())];
+        $selfScheduleList = SelfSchedule::where($selfWhere)->get();
+
+        $flag = false;
+        DB::beginTransaction();
+        try {
+            $weekModel->where('docter_id', '=', $doctor_id)->where('schedule_type', '=', 1)->delete();
+            $delWhere['docter_id'] = $doctor_id;
+            $delWhere[] = ['schedule_date','>=',date('Y-m-d',time())];
+            SchedulePeriod::where($delWhere)->delete();
+            $schedule = [];
+            if (count($counts) < 29) {
+                $flag = true;
+                Schedule::where('docter_id', '=', $doctor_id)->delete();
+                foreach ($moth_date as $kk => $vv) {
+                    $schedule[$kk]['schedule_date'] = $vv['date'];
+                    $schedule[$kk]['schedule_day'] = str_replace('-', '', $vv['date']);
+                    $schedule[$kk]['docter_id'] = $doctor_id;
+                    $schedule[$kk]['organization_id'] = 0;
+                    $schedule[$kk]['week'] = $vv['week'];
+                    $schedule[$kk]['per_time_num'] = 10;
+                    $sid[$kk] = Schedule::insertGetId($schedule[$kk]);
+                }
+            } else {
+                foreach ($counts as $kk => $vv) {
+                    if ($vv['schedule_date'] >= date('Y-m-d',time())){
+                        $schedule[$kk]['schedule_date'] = $vv['schedule_date'];
+                        $schedule[$kk]['week'] = $vv['week'];
+                        $sid[$kk] = $vv['id'];
+                    }
+                }
+            }
+
+
+            foreach ($data as $k => $v) {
+
+                // 插入详情
+                if ($v['identifi']['zao']!=0) {
+                    $maf[$k]['schedule_type'] = 1;
+                    $maf[$k]['docter_id'] = $doctor_id;
+                    $maf[$k]['week'] = $v['week'];
+                    $maf[$k]['type'] = 1;
+                    $maf[$k]['organization_id'] = $v['identifi']['zao'];
+                    $weekList[] = $maf[$k];
+//                        $times = $this->num_time($v['identifi']['zao'],1);
+//                        if (!$times){
+//                            return out('',500,"请先在排班设置中填写本机构的时间段");
+//                        }
+//                        $zao_maf=$this->week_getMaf($times,['organization_id'=>$v['identifi']['zao'],'week'=>$v['week'],'type'=>1],$doctor_id);
+//                        if ($zao_maf){
+//                            foreach ($zao_maf as $o){
+//                                $weekList[]=$o;
+//                            }
+//                        }
+                }
+                if ($v['identifi']['zhong']!=0) {
+                    $maf[$k]['schedule_type'] = 1;
+                    $maf[$k]['docter_id'] = $doctor_id;
+                    $maf[$k]['week'] = $v['week'];
+                    $maf[$k]['type'] = 2;
+                    $maf[$k]['organization_id'] = $v['identifi']['zhong'];
+                    $weekList[] = $maf[$k];
+                    /*       $times = $this->num_time($v['identifi']['zhong'],2);
+                           if (!$times){
+                               return out('',500,"请先在排班设置中填写本机构的时间段");
+                           }
+                           $zhong_maf=$this->week_getMaf($times,['organization_id'=>$v['identifi']['zhong'],'week'=>$v['week'],'type'=>2],$doctor_id);
+                           if ($zhong_maf){
+                               foreach ($zhong_maf as $o){
+                                   $weekList[]=$o;
+
+                               }
+                           }*/
+                }
+                if ($v['identifi']['wan']!=0) {
+                    $maf[$k]['schedule_type'] = 1;
+                    $maf[$k]['docter_id'] = $doctor_id;
+                    $maf[$k]['week'] = $v['week'];
+                    $maf[$k]['type'] = 3;
+                    $maf[$k]['organization_id'] = $v['identifi']['wan'];
+                    $weekList[] = $maf[$k];
+                    /*$times = $this->num_time($v['identifi']['wan'],3);
+                    if (!$times){
+                        return out('',500,"请先在排班设置中填写本机构的时间段");
+                    }
+                    $wan_maf=$this->week_getMaf($times,['organization_id'=>$v['identifi']['wan'],'week'=>$v['week'],'type'=>3],$doctor_id);
+                    if ($wan_maf){
+                        foreach ($wan_maf as $o){
+                            $weekList[]=$o;
+
+                        }
+                    }*/
+                }
+            }
+
+            // 占用效率
+
+            $scheduleLists = [];
+            foreach ($sid as $kk => $vv) {
+                foreach ($data as $k => $v) {
+                    if ($schedule[$kk]['week'] == $v['week']) {
+                        //检查有没有设置时间
+//                        if ($v['identifi']['zao']==0) {
+//                            $times = $this->num_time($v['identifi']['zao'], 1);
+//                            if (!$times) {
+//                                return out('', 500, "请先在排班设置中填写本机构的时间段1");
+//                            }
+//                        }
+
+                        if ($v['identifi']['zao']) {
+                            $times = $this->num_time($v['identifi']['zao'], 1);
+                            if (!$times) {
+                                return out('', 500, "请先在排班设置中填写本机构的时间段2");
+                            }
+                            $maf = $this->getMaf($vv, $times, ['organization_id' => $v['identifi']['zao'], 'schedule_date' => $schedule[$kk]['schedule_date'], 'type' => 1], $doctor_id);
+                            if ($maf) {
+                                foreach ($maf as $os) {
+//                                    array_push($scheduleLists, $os);
+                                    $scheduleLists[] = $os;
+                                }
+                            }
+                        }
+                        if ($v['identifi']['zhong']) {
+                            $times = $this->num_time($v['identifi']['zhong'], 2);
+                            if (!$times) {
+                                return out('', 500, "请先在排班设置中填写本机构的时间段3");
+                            }
+                            $maf = $this->getMaf($vv, $times, ['organization_id' => $v['identifi']['zhong'], 'schedule_date' => $schedule[$kk]['schedule_date'], 'type' => 2], $doctor_id);
+                            if ($maf) {
+                                foreach ($maf as $os) {
+                                    $scheduleLists[] = $os;
+
+                                }
+                            }
+                        }
+                        if ($v['identifi']['wan']) {
+                            $times = $this->num_time($v['identifi']['wan'], 3);
+                            if (!$times) {
+                                return out('', 500, "请先在排班设置中填写本机构的时间段4");
+                            }
+                            $maf = $this->getMaf($vv, $times, ['organization_id' => $v['identifi']['wan'], 'schedule_date' => $schedule[$kk]['schedule_date'], 'type' => 3], $doctor_id);
+                            if ($maf) {
+                                foreach ($maf as $os) {
+//                                    array_push($scheduleLists, $os);
+                                    $scheduleLists[] = $os;
+
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+
+
+            // 查询重复替换
+            $chong = [];
+            if ($selfScheduleList && $scheduleLists) {
+                foreach ($scheduleLists as $k => $v) {
+                    foreach ($selfScheduleList as $kk => $vv) {
+                        if ($v['schedule_date'] == $vv['schedule_date']) {
+                            $chong[$kk]['schedule_id'] = $v['schedule_id'];
+                            $chong[$kk]['docter_id'] = $v['docter_id'];
+                            $chong[$kk]['order_num'] = $v['order_num'];
+                            $chong[$kk]['organization_id'] = $vv['organization_id'];
+                            $chong[$kk]['time_period_id'] = $vv['time_period_id'];
+                            $chong[$kk]['type'] = $vv['type'];
+                            $chong[$kk]['schedule_date'] = $vv['schedule_date'];
+                            unset($scheduleLists[$k]);
+                        }
+                    }
+                }
+            }
+            $listPeriod = array_merge($chong, $scheduleLists);
+            SchedulePeriod::insert($listPeriod);
+            WeekSchedule::insert($weekList);
+            DB::commit();
+            return out();
+        } catch (\Exception $e) {
+            DB::rollBack();
+            return out('', 500, $e->getFile() . '中的第:' . $e->getLine() . '行报错:' . $e->getCode(), $e->getMessage());
+        } catch (\PDOException $e) {
+            DB::rollBack();
+            return out('', 500, $e->getFile() . '中的第:' . $e->getLine() . '行报错:' . $e->getCode(), $e->getMessage());
+        }
+    }
+
+
+    /**
+     * 修改某一天的数据
+     * @author Liu-Yh
+     * Create By 2020/12/16 18:46
+     */
+    public function saveDay($data = [])
+    {
+        $flag = false;
+        if (empty($data)) {
+            $req = request()->post();
+            $this->validate(request(), [
+                'schedule_date|日期' => 'required',
+                'week|日期' => 'required',
+                'type|日期' => 'required',
+                'organization_id|日期' => 'required',
+            ]);
+        } else {
+            $flag = true;
+            $req = $data;
+        }
+
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        $save_data = [];
+        $type_data = explode(',', $req['type']);
+        DB::beginTransaction();
+        try {
+
+            foreach ($type_data as $k => $v) {
+                $finds = SelfSchedule::where(['schedule_date' => $req['schedule_date'], 'docter_id' => $doctor_id, 'schedule_type' => 1, 'organization_id' => $req['organization_id']])->delete();
+                $times = $this->num_time($req['organization_id'], $v);
+                $mf = $this->arrangeDay($times, ['organization_id' => $req['organization_id'], 'week' => $req['week'], 'schedule_date' => $req['schedule_date'], 'type' => $v], $doctor_id);
+                if ($mf) {
+                    foreach ($mf as $v) {
+                        $save_data[] = $v;
+                    }
+                }
+            }
+
+            if (!$flag){
+                $lists = Schedule::where(['docter_id'=>$doctor_id,'schedule_date'=>$req['schedule_date']])->first();
+                if($lists){
+                    SchedulePeriod::where(['docter_id'=>$doctor_id,'schedule_date'=>$req['schedule_date']])->delete();
+                    $chong = [];
+                    foreach ($save_data as $k => $v) {
+                        $chong[$k]['schedule_id'] = $lists['id'];
+                        $chong[$k]['docter_id'] = $v['docter_id'];
+                        $chong[$k]['order_num'] = 0;
+                        $chong[$k]['organization_id'] = $v['organization_id'];
+                        $chong[$k]['time_period_id'] = $v['time_period_id'];
+                        $chong[$k]['type'] = $v['type'];
+                        $chong[$k]['schedule_date'] = $v['schedule_date'];
+                    }
+
+                    SchedulePeriod::insert($chong);
+                }
+            }
+            SelfSchedule::insert($save_data);
+            DB::commit();
+            if ($flag) {
+                return true;
+            } else {
+                return out();
+            }
+        } catch (\Exception $e) {
+            DB::rollBack();
+            if ($flag) {
+                return false;
+            } else {
+                return out('', 500, $e->getFile() . '中的第:' . $e->getLine() . '行报错:' . $e->getCode(), $e->getMessage());
+            }
+        } catch (\PDOException $e) {
+            DB::rollBack();
+            if ($flag) {
+                return false;
+            } else {
+                return out('', 500, $e->getFile() . '中的第:' . $e->getLine() . '行报错:' . $e->getCode(), $e->getMessage());
+            }
+        }
+    }
+
+    /**
+     * 整理单个修改排班的数据
+     * @param $time
+     * @param $req
+     * @param $doctor_id
+     * @return array
+     * @author Liu-Yh
+     * Create By 2020/12/16 19:00
+     */
+    protected function arrangeDay($time, $req, $doctor_id)
+    {
+
+        $save_data = [];
+        foreach ($time as $k => $v) {
+            $save_data[$k]['schedule_date'] = $req['schedule_date'];
+            $save_data[$k]['week'] = $req['week'];
+            $save_data[$k]['schedule_type'] = 1;
+            $save_data[$k]['type'] = $req['type'];
+            $save_data[$k]['organization_id'] = $req['organization_id'];
+            $save_data[$k]['docter_id'] = $doctor_id;
+            $save_data[$k]['time_period_id'] = $v;
+        }
+
+        return $save_data;
+    }
+
+
+    /**
+     * 查看月视图
+     * @author Liu-Yh
+     * Create By 2020/12/16 19:20
+     */
+    public function monthDetail()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'start_day|日期' => 'required',
+            'end_day|日期' => 'required',
+        ]);
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        $selfScheduleList = SelfSchedule::where('docter_id', '=', $doctor_id)->get();
+        $weekSchduleList = WeekSchedule::with('organization')->where('docter_id', '=', $doctor_id)->groupBy('type', 'week')->orderBy('week', 'asc')->get()->toArray();
+
+        // 占用效率
+        $scheduleLists = [];
+        $moth_date = $this->date_bool($req['start_day'], $req['end_day']);
+        $lab=[];
+        foreach ($weekSchduleList as $k => $v) {
+            $lab[$k]['id'] = $v['id'];
+            $lab[$k]['type'] = $v['type']; // 1=早上,2=下午,3=晚上
+            $lab[$k]['organization_id'] = $v['organization_id']; // 1=早上,2=下午,3=晚上
+            $lab[$k]['flag'] = $v['week'];
+            switch ($v['week']) {
+                case "7":
+                    $lab[$k]['week'] = '周日';
+                    break;
+                case "1":
+                    $lab[$k]['week'] = '周一';
+                    break;
+                case "2":
+                    $lab[$k]['week'] = '周二';
+                    break;
+                case "3":
+                    $lab[$k]['week'] = '周三';
+                    break;
+                case "4":
+                    $lab[$k]['week'] = '周四';
+                    break;
+                case "5":
+                    $lab[$k]['week'] = '周五';
+                    break;
+                default:
+                    $lab[$k]['week'] = '周六';
+            }
+        }
+
+
+        $newReturn = [];
+        $weekList = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'];
+        foreach ($lab as $k => $v) {
+            if (!isset($newReturn[$v['flag']])) {
+                $newReturn[$v['flag']] = $v;
+                if ($v['type'] == 1) {
+                    $newReturn[$v['flag']]['ident']['zao_id'] = $v['organization_id'];
+                    $newReturn[$v['flag']]['ident']['xia_id'] = 0;
+                    $newReturn[$v['flag']]['ident']['wan_id'] = 0;
+                } else if ($v['type'] == 2) {
+                    $newReturn[$v['flag']]['ident']['zao_id'] = 0;
+                    $newReturn[$v['flag']]['ident']['xia_id'] = $v['organization_id'];
+                    $newReturn[$v['flag']]['ident']['wan_id'] = 0;
+                } else {
+                    $newReturn[$v['flag']]['ident']['zao_id'] = 0;
+                    $newReturn[$v['flag']]['ident']['xia_id'] = 0;
+                    $newReturn[$v['flag']]['ident']['wan_id'] = $v['organization_id'];
+                }
+            } else {
+                if ($v['type'] == 1) {
+                    $newReturn[$v['flag']]['ident']['zao_id'] = $v['organization_id'];
+                } else if ($v['type'] == 2) {
+                    $newReturn[$v['flag']]['ident']['xia_id'] = $v['organization_id'];
+                } else {
+
+                    $newReturn[$v['flag']]['ident']['wan_id'] = $v['organization_id'];
+                }
+            }
+        }
+        $newList = [];
+        foreach ($moth_date as $k => $v) {
+            $newList[$k]['date'] = $v['date'];
+            $newList[$k]['ident']['zao'] = 0;
+            $newList[$k]['ident']['xia'] = 0;
+            $newList[$k]['ident']['wan'] = 0;
+            foreach ($newReturn as $kk => $vv) {
+                if ($v['week'] == $vv['flag']) {
+                    $newList[$k]['date'] = $v['date'];
+                    $newList[$k]['ident']['zao'] = $vv['ident']['zao_id'];
+                    $newList[$k]['ident']['xia'] = $vv['ident']['xia_id'];
+                    $newList[$k]['ident']['wan'] = $vv['ident']['wan_id'];
+                }
+            }
+        }
+
+        $selfList = [];
+        if ($selfScheduleList) {
+            // 自定义排班数组
+            $selfScheduleList = $selfScheduleList->toArray();
+            foreach ($selfScheduleList as $k => $v) {
+                if (!isset($selfList[$v['schedule_date']])) {
+                    $selfList[$v['schedule_date']] = $v;
+                    if ($v['type'] == 1) {
+                        $selfList[$v['schedule_date']]['ident']['zao_id'] = $v['organization_id'];
+                        $selfList[$v['schedule_date']]['ident']['xia_id'] = 0;
+                        $selfList[$v['schedule_date']]['ident']['wan_id'] = 0;
+                    } else if ($v['type'] == 2) {
+                        $selfList[$v['schedule_date']]['ident']['zao_id'] = 0;
+                        $selfList[$v['schedule_date']]['ident']['xia_id'] = $v['organization_id'];
+                        $selfList[$v['schedule_date']]['ident']['wan_id'] = 0;
+                    } else {
+                        $selfList[$v['schedule_date']]['ident']['zao_id'] = 0;
+                        $selfList[$v['schedule_date']]['ident']['xia_id'] = 0;
+                        $selfList[$v['schedule_date']]['ident']['wan_id'] = $v['organization_id'];
+                    }
+                } else {
+                    if ($v['type'] == 1) {
+                        $selfList[$v['schedule_date']]['ident']['zao_id'] = $v['organization_id'];
+                    } else if ($v['type'] == 2) {
+                        $selfList[$v['schedule_date']]['ident']['xia_id'] = $v['organization_id'];
+                    } else {
+                        $selfList[$v['schedule_date']]['ident']['wan_id'] = $v['organization_id'];
+                    }
+                }
+            }
+
+            foreach ($selfList as $k => $v) {
+                foreach ($newList as $kk => $vv) {
+                    if ($v['schedule_date'] == $vv['date']) {
+                        $newList[$kk]['date'] = $vv['date'];
+                        $newList[$kk]['ident']['zao'] = $v['ident']['zao_id'];
+                        $newList[$kk]['ident']['xia'] = $v['ident']['xia_id'];
+                        $newList[$kk]['ident']['wan'] = $v['ident']['wan_id'];
+                    }
+                }
+            }
+
+
+        }
+        return out($newList);
+    }
+
+
+    /**
+     * 获取早中下午的id
+     * @param $sid
+     * @param $time
+     * @param $req
+     * @param $doctor_id
+     * @return array
+     * @author Liu-Yh
+     * Create By 2020/11/6 16:27
+     */
+    protected function getMaf($sid, $time, $req, $doctor_id)
+    {
+        $maf = [];
+        foreach ($time as $k => $v) {
+            $maf[$k]['schedule_id'] = $sid;
+            $maf[$k]['organization_id'] = $req['organization_id'];
+            $maf[$k]['time_period_id'] = $v;
+            $maf[$k]['schedule_date'] = $req['schedule_date'];
+            $maf[$k]['docter_id'] = $doctor_id;
+            $maf[$k]['type'] = $req['type'];
+            $maf[$k]['order_num'] = 0;
+        }
+
+        return $maf;
+    }
+
+
+    /**
+     * 周模板添加数据
+     * @param $time
+     * @param $req
+     * @param $doctor_id
+     * @return array
+     */
+    protected function week_getMaf($time, $req, $doctor_id)
+    {
+
+        $maf = [];
+        foreach ($time as $k => $v) {
+//            $maf[$k]['schedule_id']=$sid;
+//            $maf[$k]['schedule_date']=$req['schedule_date'];
+            $maf[$k]['type'] = $req['type'];
+            $maf[$k]['schedule_type'] = 1;
+            $maf[$k]['organization_id'] = $req['organization_id'];
+            $maf[$k]['docter_id'] = $doctor_id;
+            $maf[$k]['time_period_id'] = $v;
+            $maf[$k]['week'] = $req['week'];
+        }
+
+        return $maf;
+    }
+
+
+    /**
+     * 获取会话列表
+     * @return \Illuminate\Http\JsonResponse
+     * @author Liu-Yh
+     * Create By 2020/11/6 17:11
+     */
+    public function getUserListMsg()
+    {
+        $req = request()->post();
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        $where[] = ['product_type', 2];
+        $where[] = ['order_status', '>', 2];
+        $where[] = ['payment_status', 2];
+        $where[] = ['docter_id', $doctor_id];
+        $list = Order::with('user')->where($where)->orderBy('receiving_time', 'desc')->get();
+        $newList = [];
+        if ($list) {
+            $list = $list->toArray();
+            foreach ($list as $k => $v) {
+                $newList[$v['user_id']]['flag'] = 'member_' . $v['user_id'];
+                $newList[$v['user_id']]['order_status'] = $v['order_status'];
+                $newList[$v['user_id']]['nickname'] = $v['user']['nickname'];
+                $newList[$v['user_id']]['avatar'] = $v['user']['avatar'];
+                $newList[$v['user_id']]['remark'] = !empty($v['user']['remark'])?$v['user']['remark']:'';
+            }
+            $newList = array_values($newList);
+        }
+        return out($newList);
+    }
+
+
+    /**
+     * 获取认证信息
+     * @return mixed
+     */
+    public function getRenInfo()
+    {
+        $req = request()->post();
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        // 获取本人认证信息
+        $returnRes = [];
+        $docter = Docter::where('id', '=', $doctor_id)->first();
+        if ($docter) {
+            $docter = $docter->toArray();
+        } else {
+            return $docter;
+        }
+        $returnRes['info'] = $docter;
+        // 获取申请的认证机构
+        $org = DocterOrganization::with(['organization'])->where('docter_id', '=', $doctor_id)->get();
+        $oqf = DocterOrganization::with(['office', 'qualification'])->where('docter_id', '=', $doctor_id)->get();
+        foreach ($org as $k => $v) {
+            $org[$k]['province'] = Areas::where('id', '=', $v['organization']['province_id'])->select('name')->first()['name'];
+            $org[$k]['city'] = Areas::where('id', '=', $v['organization']['city_id'])->select('name')->first()['name'];
+            $org[$k]['area'] = Areas::where('id', '=', $v['organization']['area_id'])->select('name')->first()['name'];
+            $org[$k]['name'] = $v['organization']['name'];
+        }
+        $returnRes['orgList'] = $org;
+        $returnRes['oqf'] = $oqf;
+        return out($returnRes);
+    }
+
+    /**
+     * 获取通话记录
+     * @return mixed
+     */
+    public function callLog(){
+        $req = request()->post();
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        $where =[];
+        if(isset($req['order_id'])&&!empty($req['order_id'])){
+            $where['order_id'] = $req['order_id'];
+        }
+        $where['docter_id'] = $doctor_id;
+        $list = CallLog::where($where)->get();
+        return out($list);
+    }
+
+
+    /**
+     * 通话列表
+     * @return mixed
+     */
+    public function user_call(){
+        $req = request()->post();
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        $list=[];
+//        var_dump($doctor_id);
+//die();
+        if(isset($req['user_id'])&&!empty($req['user_id'])){
+            $ids = [];
+            $orderList = Order::where(['user_id'=>$req['user_id'],'product_type'=>1,'payment_status'=>2])->select('id')->get();
+            if($orderList){
+                foreach ($orderList as $k=>$v){
+                    $ids[$k] = $v['id'];
+                }
+            }
+            $lists = CallLog::with('orders')->whereIn('order_id',$ids)->orderBy('call_time', 'desc')->get();
+            if ($lists){
+                foreach ($lists as $k=>$v){
+                    $list[$k]['time'] = $v['call_time'];
+                    $list[$k]['talk_time'] = $v['talk_time'];
+                    $list[$k]['order_sn'] = $v['orders']['order_sn'];
+                }
+            }
+        }else{
+            $orderList = Order::with(['user','calllog'])->where(['docter_id'=>$doctor_id,'product_type'=>1,'payment_status'=>2])->groupBy(['id','user_id'])->get();
+            if ($orderList){
+                foreach ($orderList as $k=>$v){
+                    $list[$k]['user'] = $v['user'];
+                    if ($v['calllog']){
+                        $dates = $v['calllog']->toArray();
+                        $list[$k]['user']['dates'] = end($dates)['call_time'];
+                    }else{
+                        $list[$k]['user']['dates'] = '无';
+                    }
+
+                    $save = UserDocter::where(['user_id'=>$v['user']['id'],'docter_id'=>$doctor_id])->first();
+
+                    if ($save) {
+                        $list[$k]['user']['remark'] = $save['remark'];
+                    } else {
+                        $list[$k]['user']['remark'] = '';
+                    }
+
+                    $list[$k]['user']['log'] = $v['calllog'];
+//                    $list[$k]['log']['date'] = date('m/d',strtotime(end($v['calllog'])['call_time']));
+                }
+            }
+
+        }
+
+        return out($list);
+    }
+
+    /**
+     * 获取聊天记录
+     * @return mixed
+     */
+    public function getImList(){
+        $req = request()->post();
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        $where =[];
+        if(!isset($req['flag'])||empty($req['flag'])){
+            return out("",500,'用户flag不能为空');
+        }
+        $list = ImMessage::where(['senderId'=>'doctor_'.$doctor_id,'receiverId'=>$req['flag']])->orWhere(function ($query) use ($req,$doctor_id){
+            $query->where(['senderId'=>$req['flag'],'receiverId'=>'doctor_'.$doctor_id]);
+        })->get();
+
+        $newList=[];
+        if ($list){
+           foreach ($list as $k=>$v){
+               $decode = json_decode($v['text'],true);
+//               $newList[$k]['id']=$decode['id'];
+               $newList[$k]['messageId']=$decode[0]['messageId'];
+               $newList[$k]['type']=$decode[0]['type'];
+               $newList[$k]['senderId']=$decode[0]['senderId'];
+               $newList[$k]['receiverId']=$decode[0]['receiverId'];
+               $newList[$k]['timestamp']=$decode[0]['timestamp'];
+               $newList[$k]['payload']= json_decode($decode[0]['payload'],true);
+           }
+
+       }
+        return out($newList);
+    }
+}

+ 49 - 0
app/Http/Controllers/Api/V2/NurseController.php

xqd
@@ -0,0 +1,49 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-10-4
+ * Time: 下午8:43
+ */
+
+namespace App\Http\Controllers\Api\V2;
+
+use App\Models\Nurse;
+
+class NurseController extends AuthController
+{
+    public function nurseList()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'name' => 'max:255',
+            'free_type' => 'in:0,1,2',
+            'sort_type' => 'in:1,2'
+        ]);
+
+        $builder = Nurse::select(['id', 'price', 'name', 'remark']);
+        if (!empty($req['free_type'])) {
+            if ($req['free_type'] == 1) {
+                $builder->where('price', 0);
+            }
+            elseif ($req['free_type'] == 2) {
+                $builder->where('price', '>', 0);
+            }
+        }
+        if (!empty($req['name'])) {
+            $builder->where('name', 'like', '%'.$req['name'].'%');
+        }
+        if (!empty($req['sort_type'])) {
+            if ($req['sort_type'] == 1) {
+                $builder->orderBy('price', 'asc');
+            }
+            elseif ($req['sort_type'] == 2) {
+                $builder->orderBy('price', 'desc');
+            }
+        }
+
+        $data = $builder->paginate();
+
+        return out($data);
+    }
+}

+ 679 - 0
app/Http/Controllers/Api/V2/PatientController.php

xqd
@@ -0,0 +1,679 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Yuanhang Liu
+ * Date: 20-10-15
+ * Time: 下午8:46
+ */
+
+namespace App\Http\Controllers\Api\V2;
+
+use App\Models\Docter;
+use App\Models\Order;
+use App\Models\Patient;
+use App\Models\CallLog;
+use App\Models\OrderPatient;
+use App\Models\DocterOrganization;
+use App\Models\Suggest;
+use App\Models\User;
+use App\Models\UserMessages;
+use App\Models\Organization;
+use App\Http\Controllers\Api\V2\CommonController as Commons;
+use Illuminate\Support\Facades\DB;
+use App\Models\Axb;
+use App\Models\CallPhone;
+
+/**
+ * 咨询订单用户类
+ * Class PatientController
+ * @package App\Http\Controllers\Api\V2
+ */
+class PatientController extends AuthController
+{
+    protected $relationSearch = true;
+    /**
+     * @return mixed
+     * 患者咨询列表
+     * @author Yuanhang Liu & Xiaoyun Liu
+     */
+    public function orderPatientList()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'curPage' => 'required|integer',
+            'pageSize' => 'required|integer',
+        ]);
+        $pageSize = ($req['curPage']-1)*$req['pageSize'];
+        $user = $this->user;
+        $doctor_id = $user['id'];
+        $where = [];
+        $order=['created_at','desc'];
+
+        $where['docter_id'] = $doctor_id;
+        if (isset($req['appointment']) && $req['appointment']==1){
+            // 门诊预约
+            $where['product_type'] = 3;
+            if (isset($req['timeSort']) && $req['timeSort']=='0') {
+                $order = ['order_patients.appoint_start_time','asc']; //预约时间正序
+            }
+            if (isset($req['timeSort']) && $req['timeSort']=='1') {
+                $order= ['order_patients.appoint_start_time','desc']; //预约时间倒叙
+            }
+            if (isset($req['timeSort']) && $req['timeSort']=='2') {
+                $order = ['created_at','asc']; //下单时间正序
+            }
+            if (isset($req['timeSort']) && $req['timeSort']=='3') {
+                $order = ['created_at','desc']; //下单时间倒叙
+            }
+
+            if (isset($req['comStatus']) && $req['comStatus']=='0') {
+                $comstatus = [1,2,3];
+                $where[] = [function($query) use ($comstatus){
+                    $query->whereIn('order_status', $comstatus);//处理中
+                }];
+            }
+            if (isset($req['comStatus']) && $req['comStatus']=='1') {
+                $where['order_status'] = 4; //已完成
+
+            }
+        }else{
+            // 图文和电话的
+            $ids = [1,2];
+            $where[] = [function($query) use ($ids){
+                $query->whereIn('product_type', $ids);
+            }];
+            if(isset($req['typeAll']) && $req['typeAll']==1){
+                $where['product_type']=2;//图文咨询
+            }
+            if(isset($req['typeAll']) && $req['typeAll']==2){
+                $where['product_type']=1;//电话咨询
+            }
+            if(isset($req['processing']) && $req['processing']==0){
+                $status = [1,2,3];
+                $where[] = [function($query) use ($status){
+                    $query->whereIn('order_status', $status);//处理中
+                }];
+            }
+            if(isset($req['processing']) && $req['processing']==1){
+                $where['order_status'] = 4; //历史记录,已完成订单
+            }
+        }
+
+
+//        $data = Order::With(['orderPatient'=>function($query) use ($orders){
+//            $query->orderBy($orders[0],$orders[1]);
+//        }])->where($where)->orderBy($order[0],$order[1])->skip($pageSize)->take($req['pageSize'])->groupBy('id')->get()->toArray();
+        $data = DB::table('orders')
+                ->leftJoin('order_patients','order_patients.order_id','=','orders.id')
+                ->select(['orders.*','order_patients.birthday as obirthday','order_patients.appoint_start_time','order_patients.name as oanme'])
+                ->where($where)->orderBy($order[0],$order[1])
+                ->skip($pageSize)->take($req['pageSize'])
+                ->groupBy('id')
+                ->get()->toArray();
+
+//        $data = Order::with('orderPatient')->where($where)->skip($pageSize)->take($req['pageSize'])->groupBy('id')->toSql();
+//        $data = OrderPatient::with("order")->where('id', $user['id'])->orderBy('id', 'desc')->limit($pageSize,$req['pageSize'])->get()->toarray();
+        $list = [];
+        try {
+
+            foreach ($data as $k=>$v){
+                $v = get_object_vars($v);
+                if (!$v['obirthday']){
+                    unset($list[$k]);
+                }else{
+                    $list[$k]['id'] = $v['id'];
+                    $list[$k]['user_id'] = $v['user_id'];
+                    $list[$k]['order_sn'] = $v['order_sn'];
+                    $list[$k]['zl'] = $v['product_type'];
+                    $list[$k]['zt'] = $v['order_status'];
+                    unset($list[$k]['order_status'],$list[$k]['product_type']);
+                    $list[$k]['created_at'] = $v['created_at'];
+                    $list[$k]['appoint_time'] = empty($v['appoint_start_time'])?'---':date('Y-m-d H:i:s',$v['appoint_start_time']);
+                    $list[$k]['name'] = $v['oanme'];
+                    $list[$k]['birthday'] = numBirthday($v['obirthday']);
+                }
+
+            }
+
+            return out($list);
+        }catch (\Exception $e){
+            return out($e->getFile().'中第 '.$e->getLine().'行发生了 '.$e->getMessage().'错误');
+        }
+        return out($list);
+    }
+
+
+    public function mzPutOrder(){
+
+    }
+    /**
+     * @return mixed
+     * 完成订单
+     * @author Yuanhang Liu & Xiaoyun Liu
+     */
+    public function orderPatientok(){
+        $req = request()->post();
+        $this->validate(request(), [
+            'order_id|订单id' => 'required|integer',
+            'pathogen|病因' => 'required',
+            'suggest|建议' => 'required',
+            'patient_id|患者ID' => 'required',
+
+        ]);
+        $user = $this->user;
+        $find = Order::where('id','=',$req['order_id'])->first()->toArray();
+        if (!$find){
+            return out('',500,'订单错误!');
+        }
+        if ($find['order_status']>3){
+            return out('',500,'此订单不可操作!');
+
+        }
+        $lable = '';
+        switch ($find['product_type']){
+            case 1:
+                $lable = '电话咨询';
+                break;
+            case 2:
+                $lable = '图文咨询';
+                break;
+            case 3:
+                $lable = '门诊预约';
+                break;
+            case 4:
+                $lable = '疫苗接种预约';
+                break;
+            case 5:
+                $lable = '儿保预约';
+                break;
+            case 6:
+                $lable = '服务包';
+                break;
+            default:
+                $lable ='参数错误!';
+        }
+        $relation_id = '';
+        if ($find['product_type']==1 || $find['product_type']==2){
+            // 需要有意见单的
+            $suggests = Suggest::create([
+                'order_id'=> $find['id'],
+                'user_id'=> $find['user_id'],
+                'symptoms'=> $req['symptoms'],
+                'pathogen'=> $req['pathogen'],
+                'suggest'=> $req['suggest'],
+                'patient_id'=> $req['patient_id']
+            ]);
+            $suggests = $suggests->toArray();
+            $relation_id= $suggests['id'];
+        }else{
+            $relation_id= 0;
+        }
+
+
+        $status = $find['product_type'];
+        $lab='';
+        $mesid = $relation_id;
+        if ($status==1){
+            $lab = '电话咨询';
+        }else if ($status==2){
+            $lab = '图文咨询';
+        }else if($status==3){
+            $mesid = $find['id'];
+            $lab = '门诊预约';
+        }
+        $order_sn = $find['order_sn'];
+        $doctername = $user['name'];
+
+
+        DB::beginTransaction();
+        try {
+            Order::where('id','=',$req['order_id'])->update(['order_status'=>4,'updated_at'=>date('Y-m-d H:i:s',time()),'end_time'=>time()]);
+            Docter::where('id','=',$user['id'])->increment('service_persons');
+            // 添加到用户记录中!
+            UserMessages::create([
+                'user_id'=>$find['user_id'],
+                'docter_id'=>$user['id'],
+                'status'=>1,
+                'type'=>2,
+                'relation_id'=>$mesid,
+                'content'=>"您的 ".$lab." 订单,订单号".$order_sn.",医生".$doctername."已经确认完成(点击查看意见单)",
+            ]);
+            DB::commit();
+        }catch (\Exception $e){
+            DB::rollBack();
+            return out('',500,$e->getMessage());
+        }catch (\PDOException $e){
+            DB::rollBack();
+            return out('',500,$e->getMessage());
+        }
+
+        $axbwhere['docter_id'] = $user['id'];
+        $axbwhere['user_id'] = $req['user_id'];
+        $finds = Axb::where($axbwhere)->orderBy('id','desc')->first();
+
+        if ($status==1 && $finds){
+            $unlok = (new Commons())->unLokPhone($finds['xphone']);
+            Axb::where($axbwhere)->delete();
+        }
+
+        return out();
+
+    }
+
+
+    /**
+     * 门诊预约完成订单
+     * @return mixed
+     * @throws \Exception
+     */
+    public function mzPatientok(){
+        $req = request()->post();
+        $this->validate(request(), [
+            'order_id|订单id' => 'required|integer',
+        ]);
+        $user = $this->user;
+        $find = Order::where('id','=',$req['order_id'])->first()->toArray();
+        if (!$find){
+            return out('',500,'订单错误!');
+        }
+        if ($find['order_status']>3){
+            return out('',500,'此订单不可操作!');
+
+        }
+        $lable = '';
+        switch ($find['product_type']){
+            case 1:
+                $lable = '电话咨询';
+                break;
+            case 2:
+                $lable = '图文咨询';
+                break;
+            case 3:
+                $lable = '门诊预约';
+                break;
+            case 4:
+                $lable = '疫苗接种预约';
+                break;
+            case 5:
+                $lable = '儿保预约';
+                break;
+            case 6:
+                $lable = '服务包';
+                break;
+            default:
+                $lable ='参数错误!';
+        }
+        $relation_id= 0;
+        $status = $find['product_type'];
+        $lab='';
+        $mesid = $relation_id;
+        if ($status==1){
+            $lab = '电话咨询';
+        }else if ($status==2){
+            $lab = '图文咨询';
+        }else if($status==3){
+            $mesid = $find['id'];
+            $lab = '门诊预约';
+        }
+        $order_sn = $find['order_sn'];
+        $doctername = $user['name'];
+        DB::beginTransaction();
+        try {
+            Order::where('id','=',$req['order_id'])->update(['order_status'=>4,'updated_at'=>date('Y-m-d H:i:s',time()),'end_time'=>time()]);
+            Docter::where('id','=',$user['id'])->increment('service_persons');
+            // 添加到用户记录中!
+            UserMessages::create([
+                'user_id'=>$find['user_id'],
+                'docter_id'=>$user['id'],
+                'status'=>1,
+                'type'=>2,
+                'relation_id'=>$mesid,
+                'content'=>"您的 ".$lab." 订单,订单号".$order_sn.",医生".$doctername."已经确认完成(点击查看订单)",
+            ]);
+            DB::commit();
+        }catch (\Exception $e){
+            DB::rollBack();
+            return out('',500,$e->getMessage());
+        }catch (\PDOException $e){
+            DB::rollBack();
+            return out('',500,$e->getMessage());
+        }
+
+        return out();
+    }
+
+    /**
+     * @return mixed
+     * 接单
+     * @author Yuanhang Liu & Xiaoyun Liu
+     */
+    public function putOrderPatient(){
+        $req = request()->post();
+        $this->validate(request(), [
+            'order_id|订单id' => 'required|integer',
+        ]);
+        $user = $this->user;
+
+        $find = Order::where('id','=',$req['order_id'])->first()->toArray();
+        $status = $find['product_type'];
+        $lab='';
+        if ($status==1){
+            $lab = '电话咨询';
+        }else if ($status==2){
+            $lab = '图文咨询';
+        }else if($status==3){
+            $lab = '门诊预约';
+        }
+        $order_sn = $find['order_sn'];
+        $order_id = $find['id'];
+        $doctername = $user['name'];
+//        1.电话咨询 2.图文咨询 3.门诊预约 4.疫苗接种预约 5.儿保预约 6.服务包 7.充值
+
+        if (!$find){
+            return out('',500,'订单错误!');
+        }
+        if ($find['order_status']!=2){
+            return out('',500,'此订单已被接单或未付款!');
+        }
+        if ($find['payment_status']>=4){
+            return out('',500,'此订单可能已完成!');
+        }
+        DB::beginTransaction();
+        try {
+            Order::where('id','=',$req['order_id'])->update(['order_status'=>3,'updated_at'=>date('Y-m-d H:i:s',time()),'receiving_time'=>time()]);
+            // 添加到用户记录中!
+            UserMessages::create([
+                'user_id'=>$find['user_id'],
+                'docter_id'=>$user['id'],
+                'status'=>1,
+                'type'=>1,
+                'relation_id'=>$order_id,
+                'content'=> "您的 ".$lab." 订单,订单号".$order_sn.",医生".$doctername."已经确认接单(点击查看订单详情)",
+            ]);
+            DB::commit();
+            return out();
+        }catch (\Exception $e){
+
+            DB::rollBack();
+            return out('',500,$e->getMessage());
+        }catch (\PDOException $e){
+
+            DB::rollBack();
+            return out('',500,$e->getMessage());
+        }
+    }
+
+    /**
+     * @return mixed
+     * 患者咨询详情
+     * @author Yuanhang Liu & Xiaoyun Liu
+     */
+    public function orderPatientDetail()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'patient_id' => 'required|integer',
+        ]);
+        $data = [];
+        // 订单查询
+        $data = Order::with(['orderPatient','user','calllog'])->where('id', $req['patient_id'])->first()->toArray();
+
+        // 通话记录查询
+        $datas = CallLog::where('order_id', $req['patient_id'])->get();
+
+        // 机构查询
+        $user = $this->user;
+        $doctor_id = (new Commons)->getUserIdByDoctorId($user['phone']);
+        // 返回数组
+        $res_patient = [];
+        //电话咨询
+
+        if($data['product_type']==1){
+
+            $res_patient['patient_id'] = $data['order_patient']['id'];
+            $res_patient['user_id'] = $data['user_id'];
+            $res_patient['order_sn'] = $data['order_sn'];
+            $res_patient['patient_id'] = $data['patient_id'];
+            $res_patient['product_type'] = $data['product_type'];
+            $res_patient['name']=$data['order_patient']['name'];//患者姓名
+            $res_patient['numbirthday']=numBirthday($data['order_patient']['birthday']);//年龄
+            $res_patient['card_number']=$data['order_patient']['card_number'];//身份证号
+            $res_patient['created_at']=$data['created_at'];//下单时间
+            $res_patient['nickname']=$data['user']['nickname'];//下单用户
+            $res_patient['receiving_time']=!empty($data['receiving_time'])?date('Y-m-d H:i:s',$data['receiving_time']):'---';//接单时间
+            $res_patient['order_status']=$data['order_status'];//订单状态
+            $res_patient['call_list']=[];//通话记录
+            $res_patient['one_call'] = '';
+            if ($data['calllog']){
+                $res_patient['one_call'] = $data['calllog'][0]['call_time'];
+                $res_patient['secret_no']=$data['calllog'][count($data['calllog'])-1]['secret_no'];//X号码
+                foreach ($data['calllog'] as $ks=>$vs){
+                    $res_patient['call_list'][$ks]['frequency']='通话'.($ks+=1);//拨打电话开始时间
+                    $res_patient['call_list'][$ks]['start']=$vs['call_time'];//拨打电话开始时间
+                    $res_patient['call_list'][$ks]['end']=$vs['ring_time'];//拨打电话结束时间
+                    $res_patient['call_list'][$ks]['duration']=gmdate('i:s',$vs['talk_time']);//拨打电话结束时间
+
+                }
+            }
+        }
+
+        //图文咨询
+        if($data['product_type']==2){
+            $res_patient['order_sn'] = $data['order_sn'];
+            $res_patient['patient_id'] = $data['patient_id'];
+            $res_patient['user_id'] = $data['user_id'];
+            $res_patient['user_name'] = $data['user']['nickname'];
+            $res_patient['user_avatar'] = $data['user']['avatar'];
+            $res_patient['product_type'] = $data['product_type'];
+            $res_patient['name']=$data['order_patient']['name'];
+            $res_patient['numbirthday']=numBirthday($data['order_patient']['birthday']);
+            $res_patient['card_number']=$data['order_patient']['card_number'];
+            $res_patient['symptoms']=$data['order_patient']['symptoms'];//病情描述
+            $res_patient['medical_imgs']=json_decode($data['order_patient']['medical_imgs'],true);//病情照片
+            $res_patient['created_at']=$data['created_at'];//下单时间
+            $res_patient['nickname']=$data['user']['nickname'];//下单用户
+            $res_patient['receiving_time']=!empty($data['receiving_time'])?date('Y-m-d H:i:s',$data['receiving_time']):'---'; //接单时间
+            $res_patient['order_status']=$data['order_status'];//接单时间
+        }
+
+        //门诊预约
+        if($data['product_type']==3){
+            $res_patient['order_sn'] = $data['order_sn'];
+            $res_patient['patient_id'] = $data['patient_id'];
+            $res_patient['product_type'] =$data['product_type'];
+            $res_patient['name']=$data['order_patient']['name']; // 患者
+            $res_patient['numbirthday']=numBirthday($data['order_patient']['birthday']); //年龄
+            $res_patient['card_number']=$data['order_patient']['card_number']; // 证件号
+            $res_patient['appoint_time'] = date('Y年m月d日 H:i',$data['order_patient']['appoint_start_time']);// 预约时间
+            $res_patient['order_status'] = $data['order_status'];// 订单状态
+            $organization = Organization::where('id','=',$data['organization_id'])->first();
+            if($organization){
+                $organization = $organization->toArray();
+                $res_patient['organization']= $organization['name']; // 门诊机构
+            }else{
+                $res_patient['organization']= ''; // 门诊机构
+
+            }
+            $res_patient['order_sn']=$data['order_sn'];//订单号
+            $res_patient['created_at']=$data['created_at'];//下单时间
+            $res_patient['nickname']=$data['user']['nickname'];//下单用户
+        }
+
+        return out($res_patient);
+    }
+
+
+    /**
+     * 拨打电话/绑定电话
+     * @return \Illuminate\Http\JsonResponse
+     * @author Liu-Yh
+     * Create By 2020/11/24 19:19
+     */
+    public function callPhones(){
+        $req = request()->post();
+        $user = $this->user;
+        $this->validate(request(), [
+            'order_id' => 'required',
+            'user_id' => 'required|integer',
+        ]);
+        $docter_id = $user['id'];
+        $docter_phone = $user['phone'];
+        if(!$docter_phone){
+            return out('',500,'医生电话不存在!');
+        }
+        $find = Order::with('orderPatient')->where('order_sn',$req['order_id'])->first()->toArray();
+        if (empty($find['order_patient'])){
+            return out('',500,'患者电话不存在');
+        }
+        $phone = $find['order_patient']['phone'];
+
+        if($docter_phone==$phone){
+            return out('',500,'医生和患者电话号不能一样!');
+
+        }
+        $wheres['docter_id'] = $docter_id;
+        $wheres['user_id'] = $req['user_id'];
+        $commons = new Commons();
+        $finds = Axb::where($wheres)->orderBy('id','desc')->first();
+
+        if ($finds){
+            $querylok = $commons->QuerySubsId($finds['xphone']);
+            if ($querylok['Code']=='OK'){
+                // 可能是数组
+                $new_arr = explode(',',$querylok['SubsId']);
+                foreach ($new_arr as $v){
+                    $queryCallStatus = $commons->QuerySubscriptionDetail($finds['xphone'],$v);
+                    if ($queryCallStatus['Code']=='OK'){
+                        if ($queryCallStatus['Code']=="OK"){
+                            if ($queryCallStatus['SecretBindDetailDTO']['PhoneNoA']==$docter_phone&&$queryCallStatus['SecretBindDetailDTO']['PhoneNoB']==$phone){
+                                return out($finds['xphone']);
+                            }else{
+                                if ($phone){
+                                    $callModel = $commons->BindAxb($docter_phone,$phone);
+                                    if ($callModel['Code']=="OK"){
+                                        Axb::create([
+                                            'docter_id'=>$docter_id,
+                                            'user_id'=>$req['user_id'],
+                                            'xphone'=>$callModel['SecretBindDTO']['SecretNo'],
+                                            'subs_id'=>$callModel['SecretBindDTO']['SubsId'],
+                                            'createtime'=>time(),
+                                        ]);
+                                        return out($callModel['SecretBindDTO']['SecretNo']);
+                                    }
+                                }else{
+                                    return out('',500,'患者电话不存在');
+                                }
+                            }
+                        }else{
+                            if ($phone){
+                                $callModel = $commons->BindAxb($docter_phone,$phone);
+                                if ($callModel['Code']=="OK"){
+                                    Axb::create([
+                                        'docter_id'=>$docter_id,
+                                        'user_id'=>$req['user_id'],
+                                        'xphone'=>$callModel['SecretBindDTO']['SecretNo'],
+                                        'subs_id'=>$callModel['SecretBindDTO']['SubsId'],
+                                        'createtime'=>time(),
+                                    ]);
+                                    return out($callModel['SecretBindDTO']['SecretNo']);
+                                }
+                            }else{
+                                return out('',500,'患者电话不存在');
+                            }
+                        }
+                    }
+                }
+
+
+            }
+
+        }else{
+            if ($phone){
+                $callModel = $commons->BindAxb($docter_phone,$phone);
+
+                if ($callModel['Code']=="OK"){
+                    Axb::create([
+                        'docter_id'=>$docter_id,
+                        'user_id'=>$req['user_id'],
+                        'xphone'=>$callModel['SecretBindDTO']['SecretNo'],
+                        'subs_id'=>$callModel['SecretBindDTO']['SubsId'],
+                        'createtime'=>time(),
+                    ]);
+                    return out($callModel['SecretBindDTO']['SecretNo']);
+                }else{
+                    return out($callModel);
+                }
+            }else{
+                return out('',500,'患者电话不存在');
+            }
+        }
+
+    }
+
+
+    /**
+     * 电话随访
+     * @return \Illuminate\Http\JsonResponse
+     * @author Liu-Yh
+     * Create By 2020/11/24 19:19
+     */
+    public function callPhoneSure(){
+        $req = request()->post();
+        $user = $this->user;
+        $this->validate(request(), [
+            'user_id' => 'required|integer',
+        ]);
+        $docter_id = $user['id'];
+        $docter_phone = $user['phone'];
+        if(!$docter_phone){
+            return out('',500,'医生电话不存在!');
+        }
+        $find = User::where('id',$req['user_id'])->first()->toArray();
+        $phone = $find['phone'];
+        $wheres['docter_id'] = $docter_id;
+        $wheres['user_id'] = $find['id'];
+        $commons = new Commons();
+        $finds = Axb::where($wheres)->orderBy('id','desc')->first();
+        if ($finds){
+            $querylok = $commons->QuerySubsId($finds['xphone']);
+            if ($querylok['Code']=='OK'){
+                $queryCallStatus = $commons->QueryCallStatus($phone,$querylok['SubsId']);
+                if ($queryCallStatus['Code']=='OK'){
+                    if ($queryCallStatus['SecretCallStatusDTO']!=4){
+                        return out($finds['xphone']);
+                    }else{
+                        if ($phone){
+                            $callModel = $commons->BindAxb($docter_phone,$phone);
+                            if ($callModel['Code']=="OK"){
+                                return out($callModel['SecretBindDTO']['SecretNo']);
+                            }
+                        }else{
+                            return out('',500,'患者电话不存在');
+                        }
+                    }
+                }
+            }
+
+        }else{
+            if ($phone){
+                $callModel = $commons->BindAxb($docter_phone,$phone);
+                if ($callModel['Code']=="OK"){
+                    Axb::create([
+                        'docter_id'=>$docter_id,
+                        'user_id'=>$req['user_id'],
+                        'xphone'=>$callModel['SecretBindDTO']['SecretNo'],
+                        'createtime'=>time(),
+                    ]);
+                    return out($callModel['SecretBindDTO']['SecretNo']);
+                }else{
+                    return out($callModel);
+                }
+            }else{
+                return out('',500,'患者电话不存在');
+            }
+        }
+
+    }
+
+
+}

+ 49 - 0
app/Http/Controllers/Api/V2/PhoneCallController.php

xqd
@@ -0,0 +1,49 @@
+<?php
+namespace App\Http\Controllers\Api\V2;
+use AlibabaCloud\Client\AlibabaCloud;
+use AlibabaCloud\Client\Exception\ClientException;
+use Alibabaloud\Client\Exception\ServerException;
+
+/**
+ * 废弃!
+ * Class PhoneCallController
+ * @package App\Http\Controllers\Api\V2
+ */
+class PhoneCallController extends Controller
+{
+    public function BindAxb($phone1='',$phone2='',$data=[]){
+
+        $config = config('config.axb');
+        AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
+            ->regionId('cn-kunming')
+            ->asDefaultClient();
+        try {
+            $result = AlibabaCloud::rpc()
+                ->product('Dyplsapi')
+                ->version('2017-05-25')
+                ->action('BindAxb')
+                ->method('POST')
+                ->host('dyplsapi.aliyuncs.com')
+                ->options([
+                    'query' => [
+                        "Expiration" => "2020-11-25 12:00:00",
+                        'RegionId' => "cn-kunming",
+                        'PhoneNoA' => "18831125321",
+                        'PhoneNoB' => "18830277213",
+                    ],
+                ])
+                ->request();
+            print_r($result->toArray());
+        } catch (ClientException $e) {
+            echo $e->getErrorMessage() . PHP_EOL;
+        } catch (ServerException $e) {
+            echo $e->getErrorMessage() . PHP_EOL;
+        }
+    }
+
+
+
+
+}
+
+?>

+ 45 - 0
app/Http/Controllers/Api/V2/ServiceApplyController.php

xqd
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Yuanhang Liu
+ * Date: 20-10-14
+ * Time: 上午00:01
+ */
+
+namespace App\Http\Controllers\Api\V2;
+
+use App\Models\ServiceApply;
+
+/**
+ * 服务设置类
+ * Class ServiceApplyController
+ * @package App\Http\Controllers\Api\V2
+ */
+class ServiceApplyController extends AuthController
+{
+    /**
+     * 服务设置审核
+     */
+    public function serviceExamine(){
+        $req = request()->post();
+        $this->validate(request(), [
+            'service_type' => 'required|integer',
+        ]);
+        $user = $this->user;
+        $doctor_id = $user['id'];
+
+        $where['docter_id'] = $doctor_id;
+        $where['service_type'] = $req['service_type'];
+        $data = ServiceApply::where($where)->first();
+        if(empty($data)){
+            ServiceApply::create([
+                'docter_id' => $doctor_id,
+                'service_type' => $req['service_type'],
+                'status' => 1   //审核状态 1 审核 2 已通过 3 已拒绝
+            ]);
+            return out();
+        }else{
+            return out('','','您已提交');
+        }
+    }
+}

+ 159 - 0
app/Http/Controllers/Api/V2/SuggestController.php

xqd
@@ -0,0 +1,159 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Yuanhang Liu
+ * Date: 20-10-14
+ * Time: 上午00:01
+ */
+
+namespace App\Http\Controllers\Api\V2;
+
+use App\Models\Evaluate;
+use App\Models\Order;
+use App\Models\Suggest;
+use App\Models\SuggestDetail;
+
+/**
+ * 意见管理类
+ * Class SuggestController
+ * @author Yuanhang Liu & Xiaoyun Liu
+ * @package App\Http\Controllers\Api\V2
+ */
+class SuggestController extends AuthController
+{
+    /**
+     * 意见单查看
+     * @author Yuanhang Liu & Xiaoyun Liu
+     * @date 2020/10/14 00:03
+     * @return mixedsuggestList
+     */
+    public function suggestList(){
+        $req = request()->post();
+        $this->validate(request(), [
+            'curPage' => 'required|integer',
+            'pageSize' => 'required|integer',
+            'orders' => 'required',
+        ]);
+        $pageSize = ($req['curPage']-1)*$req['pageSize'];
+        $user = $this->user;
+        $docter_id = $user['id'];
+        $order =[];
+        if($req['orders']==1){
+            // 正序
+            $order = ['created_at','ASC'];
+        }else if($req['orders']==2){
+            // 倒叙
+            $order = ['created_at','desc'];
+        }else{
+            $order =['id','desc'];
+        }
+
+        $order_ids = Order::where('docter_id',$docter_id)->select('id')->get();
+        $data = [];
+        $ids = [];
+        if ($order_ids){
+            foreach($order_ids as $k=>$v){
+                $ids[$k] = $v['id'];
+            }
+            $data = Suggest::with(['order','Patient'])->whereIn('order_id',$ids)->orderBy($order[0], $order[1])->skip($pageSize)->take($req['pageSize'])->get()->toArray();
+            foreach ($data as $k=>$v){
+                if (!$data[$k]['order']||$data[$k]['order']==null||!$data[$k]['patient']||$data[$k]['patient']==null){
+                    unset($data[$k]);
+                }
+                else{
+                    $data[$k]['numBirthday'] = numBirthday($v['patient']['birthday']);
+                    $data[$k]['patient_name'] = $v['patient']['name'];
+                    $data[$k]['order_sn'] = $v['order']['order_sn'];
+                    unset($data[$k]['patient'],$data[$k]['order']);
+                }
+
+            }
+        }
+
+        return out($data);
+    }
+
+    /**
+     * 获取意见单
+     * @author Yuanhang Liu & Xiaoyun Liu
+     * @date 2020/10/14 00:10
+     * @return mixed
+     */
+    public function getSuggestDetail($id=null)
+    {
+        if (empty($id)){
+            $req = request()->post();
+            $this->validate(request(), [
+                'suggest_id' => 'required|integer',
+                'type'  => 'integer',
+            ]);
+            if($req['type']==2){
+                $data = Suggest::where('order_id',$req['suggest_id'])->get()->first();
+                if($data){
+                    $data = $data->toArray();
+                    $id = $data['id'];
+                }else{
+                    return out('',500,'数据错误!');
+                }
+            }else{
+                $id = $req['suggest_id'];
+            }
+        }
+        $data = Suggest::with(['details','Patient','user','order'])->where('id',$id)->get()->toArray();
+//        var_dump($data);die();
+        if ($data){
+            $data[0]['patient_name'] = $data[0]['patient']['name'];
+            $data[0]['patient_card_number'] = $data[0]['patient']['card_number'];
+            $data[0]['birthday'] = numBirthday($data[0]['patient']['birthday']);
+            $data[0]['username'] = $data[0]['user']['nickname'];
+            $data[0]['order_sn'] = $data[0]['order']['order_sn'];
+            unset($data[0]['patient'],$data[0]['user'],$data[0]['order']);
+            return out($data[0]);
+        }else{
+            return out([]);
+        }
+    }
+
+
+
+
+    /**
+     * 补充意见单
+     * @author Yuanhang Liu & Xiaoyun Liu
+     * @date 2020/10/14 00:20
+     * @return mixed
+     */
+    public function addSuggestDetail()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'suggest_id' => 'required|integer',
+            'supplement_reason' => 'required|max:500',
+            'supplement_content' => 'required|max:500',
+        ]);
+
+        $num = 0;
+        // 查询补充过几次了!
+        $count_array = $this->getSuggestDetail($req['suggest_id']);
+        $count_array = json_decode($count_array->getContent(),true);
+        if ($count_array){
+            $count_array = $count_array['data']['details'];
+            $num = count($count_array);
+        }
+//        var_dump($num);die();
+        if ($num>=2){
+            return out(null, 500, '您已经补充过两次意见了!');
+        }
+        $data = SuggestDetail::create([
+            'suggest_id'=>$req['suggest_id'],
+            'supplement_reason'=>$req['supplement_reason'],
+            'supplement_content'=>$req['supplement_content'],
+        ]);
+        return out();
+    }
+
+    public function getWeek(){
+        $data=getWeek(date("w"));
+        return out($data);
+    }
+}

+ 59 - 0
app/Http/Controllers/Api/V2/UserController.php

xqd
@@ -0,0 +1,59 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-9-23
+ * Time: 上午11:36
+ */
+
+namespace App\Http\Controllers\Api\V2;
+
+use App\Models\Order;
+use App\Models\User;
+use App\Models\Docter;
+use App\Models\UserBalanceLog;
+use EasyWeChat\Factory;
+use Illuminate\Support\Facades\DB;
+
+/**
+ * 用户类
+ * Class UserController
+ * @package App\Http\Controllers\Api\V2
+ */
+class UserController extends AuthController
+{
+    public function userInfo()
+    {
+        $user = $this->user;
+
+        unset($user['session_key']);
+
+        return out($user);
+    }
+
+
+
+    public function updateUser()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'nickname' => 'max:100',
+            'avatar' => 'url',
+            'sex' => 'in:1,2',
+            'birthday' => 'date',
+            'latitude' => 'numeric',
+            'longitude' => 'numeric',
+        ]);
+        $user = $this->user;
+        User::where('id', $user['id'])->update($req);
+        return out();
+    }
+
+    public function userBalanceLog()
+    {
+        $user = $this->user;
+        $data = UserBalanceLog::where('user_id', $user['id'])->orderBy('id', 'desc')->paginate();
+        return out($data);
+    }
+
+}

+ 18 - 0
app/Models/Areas.php

xqd
@@ -0,0 +1,18 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-9-29
+ * Time: 上午11:15
+ */
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Areas extends Model
+{
+    protected $guarded = [];
+
+    public $timestamps = false;
+}

+ 16 - 0
app/Models/Axb.php

xqd
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-10-5
+ * Time: 下午3:37
+ */
+
+namespace App\Models;
+
+class Axb extends BaseModel
+{
+    protected $table='axb';
+
+
+}

+ 21 - 0
app/Models/CallLog.php

xqd
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-10-5
+ * Time: 下午3:37
+ */
+
+namespace App\Models;
+
+class CallLog extends BaseModel
+{
+    protected $table='call_logs';
+
+    public function orders()
+    {
+        
+//        return $this->belongsTo(Order::class);
+        return $this->hasOne(Order::class,'id','order_id');
+    }
+}

+ 15 - 0
app/Models/CallPhone.php

xqd
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-10-5
+ * Time: 下午3:37
+ */
+
+namespace App\Models;
+
+class CallPhone extends BaseModel
+{
+    protected $table='call_phone';
+
+}

+ 4 - 0
app/Models/Collection.php

xqd
@@ -14,6 +14,10 @@ class Collection extends BaseModel
     {
         return $this->belongsTo(Docter::class);
     }
+    public function user()
+    {
+        return $this->belongsTo(User::class);
+    }
 
     public function article()
     {

+ 15 - 0
app/Models/DocterLable.php

xqd
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-10-5
+ * Time: 下午3:37
+ */
+
+namespace App\Models;
+
+class DocterLable extends BaseModel
+{
+    protected $table='docter_label';
+
+}

+ 15 - 0
app/Models/DocterMessage.php

xqd
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-10-5
+ * Time: 下午3:37
+ */
+
+namespace App\Models;
+
+class DocterMessage extends BaseModel
+{
+    protected $table='docter_messages';
+    public $timestamps = true;
+}

+ 28 - 0
app/Models/DocterOrganization.php

xqd
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-9-29
+ * Time: 上午11:12
+ */
+
+namespace App\Models;
+
+class DocterOrganization extends BaseModel
+{
+    protected $table='docter_organization';
+    public $timestamps = true;
+    public function organization()
+    {
+        return $this->belongsTo(Organization::class);
+    }
+
+    public function office()
+    {
+        return $this->belongsTo(Office::class,'offices_id','id');
+    }
+    public function qualification()
+    {
+        return $this->belongsTo(Qualification::class,'qualifications_id','id');
+    }
+}

+ 14 - 0
app/Models/DocterServiceTimes.php

xqd
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-9-29
+ * Time: 上午11:12
+ */
+
+namespace App\Models;
+
+class DocterServiceTimes extends BaseModel
+{
+    protected $table='docter_service_times';
+}

+ 19 - 0
app/Models/DocterSetting.php

xqd
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-9-29
+ * Time: 上午11:12
+ */
+
+namespace App\Models;
+
+class DocterSetting extends BaseModel
+{
+    protected $table="docter_settings";
+
+    public function organization()
+    {
+        return $this->belongsTo(Organization::class,'org_id','id');
+    }
+}

+ 14 - 0
app/Models/DocterTimes.php

xqd
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-9-29
+ * Time: 上午11:12
+ */
+
+namespace App\Models;
+
+class DocterTimes extends BaseModel
+{
+
+}

+ 39 - 0
app/Models/DocterUser.php

xqd
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-9-29
+ * Time: 上午11:12
+ */
+
+namespace App\Models;
+
+class DocterUser extends BaseModel
+{
+    protected $table='docter_user';
+    public $timestamps = true;
+    public function user()
+    {
+        return $this->belongsTo(User::class);
+    }
+
+//    public function office()
+//    {
+//        return $this->belongsTo(Office::class)->select(['id', 'name']);
+//    }
+//
+//    public function qualification()
+//    {
+//        return $this->belongsTo(Qualification::class)->select(['id', 'name']);
+//    }
+//
+//    public function organization()
+//    {
+//        return $this->belongsToMany(Organization::class);
+//    }
+//
+//    public function evaluate()
+//    {
+//        return $this->hasMany(Evaluate::class)->where('status', 2);
+//    }
+}

+ 15 - 0
app/Models/ImMessage.php

xqd
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-10-5
+ * Time: 下午3:37
+ */
+
+namespace App\Models;
+
+class ImMessage extends BaseModel
+{
+    protected $table='im_message';
+
+}

+ 17 - 0
app/Models/Order.php

xqd
@@ -14,6 +14,23 @@ class Order extends BaseModel
     {
         return $this->belongsTo(Docter::class);
     }
+    public function user()
+    {
+        return $this->belongsTo(User::class);
+    }
+    public function calllog()
+    {
+        return $this->hasMany(CallLog::class);
+    }
+    /**
+     * 用户医生关注表
+     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+     * @author Liu-Yh
+     * Create By 2020/11/18 11:06
+     */
+    public function userDocter(){
+        return $this->hasOne(UserDocter::class,'user_id','user_id')->select(['id', 'remark']);;
+    }
 
     public function orderPatient()
     {

+ 5 - 0
app/Models/OrderPatient.php

xqd
@@ -13,4 +13,9 @@ class OrderPatient extends BaseModel
     protected $casts = [
         'medical_imgs' => 'json',
     ];
+
+    public function order()
+    {
+        return $this->belongsTo(Order::class);
+    }
 }

+ 4 - 0
app/Models/Organization.php

xqd
@@ -14,4 +14,8 @@ class Organization extends BaseModel
     {
         return $this->belongsToMany(Docter::class);
     }
+
+    public function offices(){
+        return $this->hasMany(Office::class,'org_id','id');
+    }
 }

+ 1 - 0
app/Models/Patient.php

xqd
@@ -10,5 +10,6 @@ namespace App\Models;
 
 class Patient extends BaseModel
 {
+    protected $table="patients";
 
 }

+ 1 - 1
app/Models/Schedule.php

xqd
@@ -12,6 +12,6 @@ class Schedule extends BaseModel
 {
     public function schedulePeriod()
     {
-        return $this->hasMany(SchedulePeriod::class)->select(['id', 'schedule_id', 'organization_id', 'time_period_id', 'order_num']);
+        return $this->hasMany(SchedulePeriod::class);
     }
 }

+ 1 - 0
app/Models/SchedulePeriod.php

xqd
@@ -19,4 +19,5 @@ class SchedulePeriod extends BaseModel
     {
         return $this->belongsTo(TimePeriod::class)->select(['id', 'start_time_period', 'end_time_period']);
     }
+
 }

+ 15 - 0
app/Models/SelfSchedule.php

xqd
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-10-1
+ * Time: 上午12:10
+ */
+
+namespace App\Models;
+
+class SelfSchedule extends BaseModel
+{
+    protected $table="self_schedule";
+
+}

+ 15 - 0
app/Models/ServiceApply.php

xqd
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: lyh
+ * Date: 20-10-4
+ * Time: 下午7:11
+ */
+
+namespace App\Models;
+
+class ServiceApply extends BaseModel
+{
+    protected $table='service_applys';
+    public $timestamps = true;
+}

+ 29 - 0
app/Models/Suggest.php

xqd
@@ -10,8 +10,37 @@ namespace App\Models;
 
 class Suggest extends BaseModel
 {
+
+
     public function order()
     {
         return $this->belongsTo(Order::class);
     }
+
+    /**
+     * 患者表联查
+     * @return mixed
+     */
+    public function Patient()
+    {
+        return $this->hasOne(Patient::class,'id','patient_id');
+    }
+
+    /**
+     * 意见详情表联查
+     * @return mixed
+     */
+    public function details()
+    {
+        return $this->hasMany(SuggestDetail::class,'suggest_id','id');
+    }
+
+    /**
+     * 获取用户信息
+     * @return mixed
+     */
+    public function user()
+    {
+        return $this->hasOne(User::class,'id','user_id');
+    }
 }

+ 16 - 0
app/Models/SuggestDetail.php

xqd
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-10-5
+ * Time: 上午11:31
+ */
+
+namespace App\Models;
+
+class SuggestDetail extends BaseModel
+{
+    protected $table='suggests_detail';
+    public $timestamps = true;
+
+}

+ 16 - 0
app/Models/SystemConfig.php

xqd
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-10-5
+ * Time: 上午11:31
+ */
+
+namespace App\Models;
+
+class SystemConfig extends BaseModel
+{
+    protected $table='system_config';
+
+
+}

+ 52 - 11
app/Models/User.php

xqd xqd
@@ -10,6 +10,17 @@ namespace App\Models;
 
 class User extends BaseModel
 {
+    protected $table = 'users';
+
+    public function patients()
+    {
+        return $this->hasMany(Patient::class);
+    }
+
+    public function order()
+    {
+        return $this->hasMany(Order::class);
+    }
     //通过token获取用户信息
     public static function getUserByToken()
     {
@@ -19,21 +30,51 @@ class User extends BaseModel
         }
 
         $arr = aes_decrypt($auth);
-        if (empty($arr['id'])) {
-            exit_out(null, 401, '认证失效,请重新登录');
-        }
+        if (isset($arr['doctor_id'])){
+            // 说明是医生登陆!
+            if (empty($arr['doctor_id'])) {
+                exit_out(null, 401, '认证失效,请重新登录');
+            }
 
-        $user = User::where('id', $arr['id'])->first();
-        if (empty($user)){
-            exit_out(null, 601, '该账号已被删除');
-        }
-        $user = $user->toArray();
+            $user = Docter::where('id', $arr['doctor_id'])->first();
+            if (empty($user)){
+                exit_out(null, 601, '该账号已被删除');
+            }
+            $user = $user->toArray();
+//            if ($user['status'] == 0){
+//                exit_out(null, 602, '该账号已被冻结');
+//            }
+
+            return $user;
+
+        }else{
+            if (empty($arr['id'])) {
+                exit_out(null, 401, '认证失效,请重新登录');
+            }
+
+            $user = User::where('id', $arr['id'])->first();
+            if (empty($user)){
+                exit_out(null, 601, '该账号已被删除');
+            }
+            $user = $user->toArray();
 
-        if ($user['status'] == 0){
-            exit_out(null, 602, '该账号已被冻结');
+            if ($user['status'] == 0){
+                exit_out(null, 602, '该账号已被冻结');
+            }
+
+            return $user;
         }
 
-        return $user;
+    }
+
+    /**
+     * 用户医生关注表
+     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+     * @author Liu-Yh
+     * Create By 2020/11/18 11:06
+     */
+    public function userDorter(){
+        return $this->hasOne(UserDocter::class,'user_id','id')->select(['id', 'remark']);;
     }
 
     //改变用户余额

+ 15 - 0
app/Models/UserDocter.php

xqd
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-9-30
+ * Time: 下午11:25
+ */
+
+namespace App\Models;
+
+class UserDocter extends BaseModel
+{
+    protected $table='user_docter';
+    public $timestamps = true;
+}

+ 14 - 0
app/Models/UserMessages.php

xqd
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-10-5
+ * Time: 下午12:04
+ */
+
+namespace App\Models;
+
+class UserMessages extends BaseModel
+{
+
+}

+ 18 - 0
app/Models/WeekSchedule.php

xqd
@@ -0,0 +1,18 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-10-1
+ * Time: 上午12:10
+ */
+
+namespace App\Models;
+
+class WeekSchedule extends BaseModel
+{
+    protected $table="week_schedule";
+    public function organization()
+    {
+        return $this->belongsTo(Organization::class);
+    }
+}

+ 2 - 0
composer.json

xqd
@@ -9,6 +9,8 @@
     "license": "MIT",
     "require": {
         "php": "^7.2",
+        "alibabacloud/client": "^1.5",
+        "alibabacloud/sdk": "^1.8",
         "encore/laravel-admin": "^2.0",
         "fideloper/proxy": "^4.0",
         "laravel/framework": "^6.0",

+ 588 - 2
composer.lock

xqd xqd xqd
@@ -4,8 +4,526 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "5c15593d000c96a97bfb0fb53c9f7019",
+    "content-hash": "b1e2a37a29371869ed3406ffb8788459",
     "packages": [
+        {
+            "name": "adbario/php-dot-notation",
+            "version": "2.2.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/adbario/php-dot-notation.git",
+                "reference": "eee4fc81296531e6aafba4c2bbccfc5adab1676e"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/adbario/php-dot-notation/zipball/eee4fc81296531e6aafba4c2bbccfc5adab1676e",
+                "reference": "eee4fc81296531e6aafba4c2bbccfc5adab1676e",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "ext-json": "*",
+                "php": ">=5.5"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^4.0|^5.0|^6.0",
+                "squizlabs/php_codesniffer": "^3.0"
+            },
+            "type": "library",
+            "autoload": {
+                "files": [
+                    "src/helpers.php"
+                ],
+                "psr-4": {
+                    "Adbar\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Riku Särkinen",
+                    "email": "riku@adbar.io"
+                }
+            ],
+            "description": "PHP dot notation access to arrays",
+            "homepage": "https://github.com/adbario/php-dot-notation",
+            "keywords": [
+                "ArrayAccess",
+                "dotnotation"
+            ],
+            "support": {
+                "issues": "https://github.com/adbario/php-dot-notation/issues",
+                "source": "https://github.com/adbario/php-dot-notation/tree/2.x"
+            },
+            "time": "2019-01-01T23:59:15+00:00"
+        },
+        {
+            "name": "alibabacloud/client",
+            "version": "1.5.29",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/aliyun/openapi-sdk-php-client.git",
+                "reference": "2d0137828ef5c44664dcb8cc90eac4f545dd3301"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/aliyun/openapi-sdk-php-client/zipball/2d0137828ef5c44664dcb8cc90eac4f545dd3301",
+                "reference": "2d0137828ef5c44664dcb8cc90eac4f545dd3301",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "adbario/php-dot-notation": "^2.2",
+                "clagiordano/weblibs-configmanager": "^1.0",
+                "danielstjules/stringy": "^3.1",
+                "ext-curl": "*",
+                "ext-json": "*",
+                "ext-libxml": "*",
+                "ext-mbstring": "*",
+                "ext-openssl": "*",
+                "ext-simplexml": "*",
+                "ext-xmlwriter": "*",
+                "guzzlehttp/guzzle": "^6.3|^7.0",
+                "mtdowling/jmespath.php": "^2.5",
+                "php": ">=5.5"
+            },
+            "require-dev": {
+                "composer/composer": "^1.8",
+                "drupal/coder": "^8.3",
+                "ext-dom": "*",
+                "ext-pcre": "*",
+                "ext-sockets": "*",
+                "ext-spl": "*",
+                "league/climate": "^3.2.4",
+                "mikey179/vfsstream": "^1.6",
+                "monolog/monolog": "^1.24",
+                "phpunit/phpunit": "^5.7.27",
+                "psr/cache": "^1.0",
+                "symfony/dotenv": "^3.4",
+                "symfony/var-dumper": "^3.4"
+            },
+            "suggest": {
+                "ext-sockets": "To use client-side monitoring"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "AlibabaCloud\\Client\\": "src"
+                },
+                "files": [
+                    "src/Functions.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "Alibaba Cloud SDK",
+                    "email": "sdk-team@alibabacloud.com",
+                    "homepage": "http://www.alibabacloud.com"
+                }
+            ],
+            "description": "Alibaba Cloud Client for PHP - Use Alibaba Cloud in your PHP project",
+            "homepage": "https://www.alibabacloud.com/",
+            "keywords": [
+                "alibaba",
+                "alibabacloud",
+                "aliyun",
+                "client",
+                "cloud",
+                "library",
+                "sdk",
+                "tool"
+            ],
+            "support": {
+                "issues": "https://github.com/aliyun/openapi-sdk-php-client/issues",
+                "source": "https://github.com/aliyun/openapi-sdk-php-client"
+            },
+            "time": "2020-08-03T06:19:07+00:00"
+        },
+        {
+            "name": "alibabacloud/sdk",
+            "version": "1.8.662",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/aliyun/openapi-sdk-php.git",
+                "reference": "85ebc0c426b9c5a2e9ac4eee670cea59fb47e448"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/aliyun/openapi-sdk-php/zipball/85ebc0c426b9c5a2e9ac4eee670cea59fb47e448",
+                "reference": "85ebc0c426b9c5a2e9ac4eee670cea59fb47e448",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "alibabacloud/client": "^1.5",
+                "ext-curl": "*",
+                "ext-json": "*",
+                "ext-libxml": "*",
+                "ext-mbstring": "*",
+                "ext-openssl": "*",
+                "ext-simplexml": "*",
+                "ext-xmlwriter": "*",
+                "php": ">=5.5"
+            },
+            "replace": {
+                "alibabacloud/aas": "self.version",
+                "alibabacloud/actiontrail": "self.version",
+                "alibabacloud/adb": "self.version",
+                "alibabacloud/aegis": "self.version",
+                "alibabacloud/afs": "self.version",
+                "alibabacloud/airec": "self.version",
+                "alibabacloud/alidns": "self.version",
+                "alibabacloud/alikafka": "self.version",
+                "alibabacloud/alimt": "self.version",
+                "alibabacloud/aliprobe": "self.version",
+                "alibabacloud/aliyuncvc": "self.version",
+                "alibabacloud/appmallsservice": "self.version",
+                "alibabacloud/arms": "self.version",
+                "alibabacloud/arms4finance": "self.version",
+                "alibabacloud/baas": "self.version",
+                "alibabacloud/batchcompute": "self.version",
+                "alibabacloud/bss": "self.version",
+                "alibabacloud/bssopenapi": "self.version",
+                "alibabacloud/cas": "self.version",
+                "alibabacloud/cbn": "self.version",
+                "alibabacloud/ccc": "self.version",
+                "alibabacloud/ccs": "self.version",
+                "alibabacloud/cdn": "self.version",
+                "alibabacloud/cds": "self.version",
+                "alibabacloud/cf": "self.version",
+                "alibabacloud/chatbot": "self.version",
+                "alibabacloud/cloudapi": "self.version",
+                "alibabacloud/cloudauth": "self.version",
+                "alibabacloud/cloudesl": "self.version",
+                "alibabacloud/cloudmarketing": "self.version",
+                "alibabacloud/cloudphoto": "self.version",
+                "alibabacloud/cloudwf": "self.version",
+                "alibabacloud/cms": "self.version",
+                "alibabacloud/commondriver": "self.version",
+                "alibabacloud/companyreg": "self.version",
+                "alibabacloud/cr": "self.version",
+                "alibabacloud/crm": "self.version",
+                "alibabacloud/cs": "self.version",
+                "alibabacloud/csb": "self.version",
+                "alibabacloud/cusanalyticsconline": "self.version",
+                "alibabacloud/dataworkspublic": "self.version",
+                "alibabacloud/dbs": "self.version",
+                "alibabacloud/dcdn": "self.version",
+                "alibabacloud/dds": "self.version",
+                "alibabacloud/democenter": "self.version",
+                "alibabacloud/dm": "self.version",
+                "alibabacloud/dmsenterprise": "self.version",
+                "alibabacloud/domain": "self.version",
+                "alibabacloud/domainintl": "self.version",
+                "alibabacloud/drcloud": "self.version",
+                "alibabacloud/drds": "self.version",
+                "alibabacloud/dts": "self.version",
+                "alibabacloud/dybaseapi": "self.version",
+                "alibabacloud/dyplsapi": "self.version",
+                "alibabacloud/dypnsapi": "self.version",
+                "alibabacloud/dysmsapi": "self.version",
+                "alibabacloud/dyvmsapi": "self.version",
+                "alibabacloud/eci": "self.version",
+                "alibabacloud/ecs": "self.version",
+                "alibabacloud/ecsinc": "self.version",
+                "alibabacloud/edas": "self.version",
+                "alibabacloud/ehpc": "self.version",
+                "alibabacloud/elasticsearch": "self.version",
+                "alibabacloud/emr": "self.version",
+                "alibabacloud/ess": "self.version",
+                "alibabacloud/facebody": "self.version",
+                "alibabacloud/fnf": "self.version",
+                "alibabacloud/foas": "self.version",
+                "alibabacloud/ft": "self.version",
+                "alibabacloud/goodstech": "self.version",
+                "alibabacloud/gpdb": "self.version",
+                "alibabacloud/green": "self.version",
+                "alibabacloud/hbase": "self.version",
+                "alibabacloud/hiknoengine": "self.version",
+                "alibabacloud/hpc": "self.version",
+                "alibabacloud/hsm": "self.version",
+                "alibabacloud/httpdns": "self.version",
+                "alibabacloud/idst": "self.version",
+                "alibabacloud/imageaudit": "self.version",
+                "alibabacloud/imageenhan": "self.version",
+                "alibabacloud/imagerecog": "self.version",
+                "alibabacloud/imagesearch": "self.version",
+                "alibabacloud/imageseg": "self.version",
+                "alibabacloud/imm": "self.version",
+                "alibabacloud/industrybrain": "self.version",
+                "alibabacloud/iot": "self.version",
+                "alibabacloud/iqa": "self.version",
+                "alibabacloud/itaas": "self.version",
+                "alibabacloud/ivision": "self.version",
+                "alibabacloud/ivpd": "self.version",
+                "alibabacloud/jaq": "self.version",
+                "alibabacloud/jarvis": "self.version",
+                "alibabacloud/jarvispublic": "self.version",
+                "alibabacloud/kms": "self.version",
+                "alibabacloud/linkedmall": "self.version",
+                "alibabacloud/linkface": "self.version",
+                "alibabacloud/linkwan": "self.version",
+                "alibabacloud/live": "self.version",
+                "alibabacloud/lubancloud": "self.version",
+                "alibabacloud/lubanruler": "self.version",
+                "alibabacloud/market": "self.version",
+                "alibabacloud/mopen": "self.version",
+                "alibabacloud/mpserverless": "self.version",
+                "alibabacloud/mts": "self.version",
+                "alibabacloud/multimediaai": "self.version",
+                "alibabacloud/nas": "self.version",
+                "alibabacloud/netana": "self.version",
+                "alibabacloud/nlp": "self.version",
+                "alibabacloud/nlpautoml": "self.version",
+                "alibabacloud/nlscloudmeta": "self.version",
+                "alibabacloud/nlsfiletrans": "self.version",
+                "alibabacloud/objectdet": "self.version",
+                "alibabacloud/ocr": "self.version",
+                "alibabacloud/ocs": "self.version",
+                "alibabacloud/oms": "self.version",
+                "alibabacloud/ons": "self.version",
+                "alibabacloud/onsmqtt": "self.version",
+                "alibabacloud/oos": "self.version",
+                "alibabacloud/openanalytics": "self.version",
+                "alibabacloud/ossadmin": "self.version",
+                "alibabacloud/ots": "self.version",
+                "alibabacloud/outboundbot": "self.version",
+                "alibabacloud/petadata": "self.version",
+                "alibabacloud/polardb": "self.version",
+                "alibabacloud/productcatalog": "self.version",
+                "alibabacloud/pts": "self.version",
+                "alibabacloud/push": "self.version",
+                "alibabacloud/pvtz": "self.version",
+                "alibabacloud/qualitycheck": "self.version",
+                "alibabacloud/ram": "self.version",
+                "alibabacloud/rds": "self.version",
+                "alibabacloud/reid": "self.version",
+                "alibabacloud/retailcloud": "self.version",
+                "alibabacloud/rkvstore": "self.version",
+                "alibabacloud/ros": "self.version",
+                "alibabacloud/rtc": "self.version",
+                "alibabacloud/saf": "self.version",
+                "alibabacloud/sas": "self.version",
+                "alibabacloud/sasapi": "self.version",
+                "alibabacloud/scdn": "self.version",
+                "alibabacloud/schedulerx2": "self.version",
+                "alibabacloud/skyeye": "self.version",
+                "alibabacloud/slb": "self.version",
+                "alibabacloud/smartag": "self.version",
+                "alibabacloud/smc": "self.version",
+                "alibabacloud/sms": "self.version",
+                "alibabacloud/smsintl": "self.version",
+                "alibabacloud/snsuapi": "self.version",
+                "alibabacloud/sts": "self.version",
+                "alibabacloud/taginner": "self.version",
+                "alibabacloud/tesladam": "self.version",
+                "alibabacloud/teslamaxcompute": "self.version",
+                "alibabacloud/teslastream": "self.version",
+                "alibabacloud/ubsms": "self.version",
+                "alibabacloud/ubsmsinner": "self.version",
+                "alibabacloud/uis": "self.version",
+                "alibabacloud/unimkt": "self.version",
+                "alibabacloud/visionai": "self.version",
+                "alibabacloud/vod": "self.version",
+                "alibabacloud/voicenavigator": "self.version",
+                "alibabacloud/vpc": "self.version",
+                "alibabacloud/vs": "self.version",
+                "alibabacloud/wafopenapi": "self.version",
+                "alibabacloud/welfareinner": "self.version",
+                "alibabacloud/xspace": "self.version",
+                "alibabacloud/xtrace": "self.version",
+                "alibabacloud/yqbridge": "self.version",
+                "alibabacloud/yundun": "self.version"
+            },
+            "require-dev": {
+                "composer/composer": "^1.8",
+                "league/climate": "^3.2.4",
+                "phpunit/phpunit": "^4.8",
+                "symfony/dotenv": "^3.4",
+                "symfony/var-dumper": "^3.4"
+            },
+            "suggest": {
+                "ext-sockets": "To use client-side monitoring"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "AlibabaCloud\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "Alibaba Cloud SDK",
+                    "email": "sdk-team@alibabacloud.com",
+                    "homepage": "http://www.alibabacloud.com"
+                }
+            ],
+            "description": "Alibaba Cloud SDK for PHP - Easier to Use Alibaba Cloud in your PHP project",
+            "homepage": "https://www.alibabacloud.com/",
+            "keywords": [
+                "alibaba",
+                "alibabacloud",
+                "aliyun",
+                "cloud",
+                "library",
+                "sdk"
+            ],
+            "support": {
+                "issues": "https://github.com/aliyun/openapi-sdk-php/issues",
+                "source": "https://github.com/aliyun/openapi-sdk-php"
+            },
+            "time": "2020-11-25T03:18:55+00:00"
+        },
+        {
+            "name": "clagiordano/weblibs-configmanager",
+            "version": "v1.1.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/clagiordano/weblibs-configmanager.git",
+                "reference": "ecf584f5b3a27929175ff0abdba52f0131bef795"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/clagiordano/weblibs-configmanager/zipball/ecf584f5b3a27929175ff0abdba52f0131bef795",
+                "reference": "ecf584f5b3a27929175ff0abdba52f0131bef795",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "php": ">=5.4"
+            },
+            "require-dev": {
+                "clagiordano/phpunit-result-printer": "^1",
+                "phpunit/phpunit": "^4.8"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "clagiordano\\weblibs\\configmanager\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "LGPL-3.0-or-later"
+            ],
+            "authors": [
+                {
+                    "name": "Claudio Giordano",
+                    "email": "claudio.giordano@autistici.org",
+                    "role": "Developer"
+                }
+            ],
+            "description": "weblibs-configmanager is a tool library for easily read and access to php config array file and direct read/write configuration file / object",
+            "keywords": [
+                "clagiordano",
+                "configuration",
+                "manager",
+                "tool",
+                "weblibs"
+            ],
+            "support": {
+                "issues": "https://github.com/clagiordano/weblibs-configmanager/issues",
+                "source": "https://github.com/clagiordano/weblibs-configmanager/tree/v1.1.0"
+            },
+            "time": "2020-07-20T20:39:25+00:00"
+        },
+        {
+            "name": "danielstjules/stringy",
+            "version": "3.1.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/danielstjules/Stringy.git",
+                "reference": "df24ab62d2d8213bbbe88cc36fc35a4503b4bd7e"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/danielstjules/Stringy/zipball/df24ab62d2d8213bbbe88cc36fc35a4503b4bd7e",
+                "reference": "df24ab62d2d8213bbbe88cc36fc35a4503b4bd7e",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "php": ">=5.4.0",
+                "symfony/polyfill-mbstring": "~1.1"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "~4.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Stringy\\": "src/"
+                },
+                "files": [
+                    "src/Create.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Daniel St. Jules",
+                    "email": "danielst.jules@gmail.com",
+                    "homepage": "http://www.danielstjules.com"
+                }
+            ],
+            "description": "A string manipulation library with multibyte support",
+            "homepage": "https://github.com/danielstjules/Stringy",
+            "keywords": [
+                "UTF",
+                "helpers",
+                "manipulation",
+                "methods",
+                "multibyte",
+                "string",
+                "utf-8",
+                "utility",
+                "utils"
+            ],
+            "support": {
+                "issues": "https://github.com/danielstjules/Stringy/issues",
+                "source": "https://github.com/danielstjules/Stringy"
+            },
+            "time": "2017-06-12T01:10:27+00:00"
+        },
         {
             "name": "dnoegel/php-xdg-base-dir",
             "version": "v0.1.1",
@@ -1622,6 +2140,73 @@
             ],
             "time": "2020-07-23T08:41:23+00:00"
         },
+        {
+            "name": "mtdowling/jmespath.php",
+            "version": "2.6.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/jmespath/jmespath.php.git",
+                "reference": "42dae2cbd13154083ca6d70099692fef8ca84bfb"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/jmespath/jmespath.php/zipball/42dae2cbd13154083ca6d70099692fef8ca84bfb",
+                "reference": "42dae2cbd13154083ca6d70099692fef8ca84bfb",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "php": "^5.4 || ^7.0 || ^8.0",
+                "symfony/polyfill-mbstring": "^1.17"
+            },
+            "require-dev": {
+                "composer/xdebug-handler": "^1.4",
+                "phpunit/phpunit": "^4.8.36 || ^7.5.15"
+            },
+            "bin": [
+                "bin/jp.php"
+            ],
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "2.6-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "JmesPath\\": "src/"
+                },
+                "files": [
+                    "src/JmesPath.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Michael Dowling",
+                    "email": "mtdowling@gmail.com",
+                    "homepage": "https://github.com/mtdowling"
+                }
+            ],
+            "description": "Declaratively specify how to extract elements from a JSON document",
+            "keywords": [
+                "json",
+                "jsonpath"
+            ],
+            "support": {
+                "issues": "https://github.com/jmespath/jmespath.php/issues",
+                "source": "https://github.com/jmespath/jmespath.php/tree/2.6.0"
+            },
+            "time": "2020-07-31T21:01:56+00:00"
+        },
         {
             "name": "nesbot/carbon",
             "version": "2.40.0",
@@ -6940,5 +7525,6 @@
     "platform": {
         "php": "^7.2"
     },
-    "platform-dev": []
+    "platform-dev": [],
+    "plugin-api-version": "2.0.0"
 }

+ 1 - 1
config/app.php

xqd
@@ -67,7 +67,7 @@ return [
     |
     */
 
-    'timezone' => 'UTC',
+    'timezone' => 'Asia/Shanghai',
 
     /*
     |--------------------------------------------------------------------------

+ 21 - 0
config/config.php

xqd xqd
@@ -11,6 +11,13 @@ return [
     'aes_key' => 'bEJwbf2w8Abbhr1g',
     'aes_iv' => 'sfX2ReOCcY22CEUF',
 
+    // 正式服 小程序id
+/*    'wechat_small_program' => [
+        'app_id' => 'wx1dcbf8ce4bca6870',
+        'secret' => 'f978c16e3664c33c811c02f1d48690b9',
+    ],*/
+
+    // 测试服务
     'wechat_small_program' => [
         'app_id' => 'wx92066f7587c34617',
         'secret' => 'bd7849c5259b79c41ec158173c5fb1d6',
@@ -22,6 +29,20 @@ return [
         'key' => 'c1891122765718911227657189112276',
         'notify_url' => env('API_HOST', '').'/api/payCallback/wechatPayNotify'
     ],
+    'aly_sms' => [
+        'access_key' => 'LTAI4FgJdnfwsj5Bb6ioWSD9',
+        'access_secret' => 'S4Tp2eNVKHROuNOLjTvAICTnjqXFFR',
+        'sign_name' => '思维定制',
+        'verify_template_code' => 'SMS_185242509',
+        'sms_verify_code_expire' => 360,
+    ],
+    'axb'   =>[
+        'appid' => 'LTAI4GGMyBKstgVLLckoPxtf',
+        'appscret' => 'goLufn8Qe0Mfip5PBR8R0DfbYYYkDF',
+        'PoolKey' => 'FC100000115024469', // 隐私号码key
+        'StartReport' => 'Alicom-Queue-1938404972693193-SecretStartReport-14860002', // 童话开始时回调
+        'Report' => 'Alicom-Queue-1938404972693193-SecretReport-14865001', // 通话结束时回调
+    ],
 
     'product_type_map' => [1 => '电话咨询', 2 => '图文咨询', 3 => '门诊预约', 4 => '疫苗接种预约', 5 => '儿保预约', 6 => '服务包', 7 => '充值'],
 ];

+ 0 - 56
database/migrations/2016_01_04_173148_create_admin_tables.php

xqd
@@ -1,56 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class CreateAdminTables extends Migration
-{
-    /**
-     * {@inheritdoc}
-     */
-    public function getConnection()
-    {
-        return config('admin.database.connection') ?: config('database.default');
-    }
-
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::create(config('admin.database.users_table'), function (Blueprint $table) {
-            $table->increments('id');
-            $table->string('username', 190)->unique();
-            $table->string('password', 60);
-            $table->string('name');
-            $table->string('avatar')->nullable();
-            $table->string('remember_token', 100)->nullable();
-            $table->timestamps();
-        });
-
-        Schema::create(config('admin.database.menu_table'), function (Blueprint $table) {
-            $table->increments('id');
-            $table->integer('parent_id')->default(0);
-            $table->integer('order')->default(0);
-            $table->string('title', 50);
-            $table->string('icon', 50);
-            $table->string('uri')->nullable();
-
-            $table->timestamps();
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::dropIfExists(config('admin.database.users_table'));
-        Schema::dropIfExists(config('admin.database.menu_table'));
-    }
-}

+ 0 - 35
database/migrations/2019_08_19_000000_create_failed_jobs_table.php

xqd
@@ -1,35 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class CreateFailedJobsTable extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::create('failed_jobs', function (Blueprint $table) {
-            $table->bigIncrements('id');
-            $table->text('connection');
-            $table->text('queue');
-            $table->longText('payload');
-            $table->longText('exception');
-            $table->timestamp('failed_at')->useCurrent();
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::dropIfExists('failed_jobs');
-    }
-}

+ 169 - 0
database/migrations/2020_10_13_061605_docters.php

xqd
@@ -0,0 +1,169 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class Docters extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('docters', function (Blueprint $table) {
+            // 修改docters字段
+//            $table->integer('user_id')->comment('用户表关联id');
+//            $table->string('password',50)->nullable()->comment('密码');
+//            $table->integer('is_then')->nullable()->comment('是否认证:0=未认证;1=认证');
+//            $table->string('practice',200)->nullable()->comment('医生照片和执业证书,号分开');
+//            $table->string('card_photo',200)->nullable()->comment('身份证正反面,号分开');
+//            $table->string('is_quail',200)->nullable()->comment('照片和资格证书,号分开');
+//            $table->integer('card_id',20)->nullable()->comment('身份证号');
+        });
+
+        // 创建意见详情
+/*        Schema::create('suggests_detail', function (Blueprint $table) {
+            $table->integer('suggest_id')->comment('suggest表主键');
+            $table->string('supplement_reason',2000)->comment('补充原因');
+            $table->string('supplement_content',2000)->comment('补充建议');
+            $table->timestamps();
+        });*/
+
+        // 修改订单表
+        Schema::table('orders', function (Blueprint $table) {
+            //添加接单时间
+//            $table->integer('receiving_time')->comment('接单时间');
+        });
+
+        // 用户消息表
+        Schema::table('user_messages', function (Blueprint $table) {
+            //添加医生id
+//            $table->integer('docter_id')->after('user_id')->comment('医生ID');
+        });
+
+        // 医生消息表
+        Schema::create('docter_messages', function (Blueprint $table) {
+//            $table->bigIncrements('id');
+//            $table->integer('user_id')->comment("用户ID");
+//            $table->integer('docter_id')->comment("医生ID");
+//            $table->tinyInteger('status')->comment("状态(1.未读 2.已读)");
+//            $table->tinyInteger('type')->comment("类型(1.图文订单 2.电话订单 3.预约订单 4.评价通知 5.系统通知)");
+//            $table->integer('relation_id')->comment("关联ID(发出消息操作关联的表的id,比如:医生结束消息时,就该关联意见单ID,因为用户点击消息会进入看意见单)");
+//            $table->string('content',500)->comment("消息内容");
+//            $table->timestamps();
+        });
+
+
+        // 童话记录表
+    /*    Schema::create('call_logs', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->integer('order_id')->nullable()->comment("订单表ID");
+            $table->integer('dial_time')->nullable()->comment("拨打时间");
+            $table->integer('dialend_time')->nullable()->comment("结束时间");
+            $table->integer('talk_time')->nullable()->comment("通话时长");
+            $table->timestamps();
+        });*/
+
+
+        // 医生时间段服务设置
+  /*      Schema::create('docter_times', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->integer('docter_id')->comment("医生id");
+            $table->decimal('base_price',8,2)->nullable()->comment("基础价格");
+            $table->decimal('step_price',8,2)->nullable()->comment("步进价格");
+            $table->string('service_time',2000)->nullable()->comment("服务时间(00点到24点的索引)");
+            $table->integer('person')->nullable()->comment("服务人次");
+            $table->integer('type')->nullable()->comment("类型(1=电话咨询,2=图文咨询,3=门诊预约,4=疫苗接种预约,5=儿保预约,6=服务包,7=充值)");
+            $table->integer('relation_id')->nullable()->comment("关联id(为门诊预约时,关联机构id)");
+            $table->timestamps();
+        });*/
+
+        // user表添加字段
+        Schema::table('users', function (Blueprint $table) {
+//            $table->string('remark',200)->nullable()->comment('用户备注');
+        });
+
+        // 医生用户关联表,暂时没用到 (可以作为拓展用)
+        Schema::create('docter_user', function (Blueprint $table) {
+//            $table->bigIncrements('id');
+//            $table->integer('docter_id')->comment('医生表主键');
+//            $table->integer('user_id')->comment('用户表主键');
+//            $table->timestamps();
+        });
+
+        //医生机构表加字段
+        Schema::table('docter_organization', function (Blueprint $table) {
+            //添加医生id
+//            $table->integer('offices_id')->nullable()->after('organization_id')->comment('机构ID');
+//            $table->integer('qualifications_id')->nullable()->after('offices_id')->comment('资质id');
+//            $table->integer('state')->nullable()->after('qualifications_id')->comment('审核状态(0=待审核,1=审核通过,2=审核拒绝)');
+        });
+
+        // 排班具体时间表
+        Schema::table('schedule_periods', function (Blueprint $table) {
+            //添加医生id
+            $table->integer('type')->nullable()->after('docter_id')->comment('下单时间段(1=早上,2=下午,3=晚上)');
+        });
+
+
+        // 意见
+        Schema::table('suggests', function (Blueprint $table) {
+            //添加医生id
+            $table->integer('patient_id')->nullable()->after('user_id')->comment('患者id');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('docters', function (Blueprint $table) {
+            $table->dropColumn('user_id');
+            $table->dropColumn('receiving_time');
+        });
+
+        Schema::dropIfExists('suggests_detail');
+
+        Schema::table('orders', function (Blueprint $table) {
+            //删除接单时间
+            $table->dropColumn('receiving_time');
+        });
+
+        Schema::dropIfExists('docter_messages');
+
+//        Schema::dropIfExists('call_logs');
+
+//        Schema::dropIfExists('docter_times');
+
+        Schema::table('user', function (Blueprint $table) {
+
+        });
+
+
+        Schema::table('user_messages', function (Blueprint $table) {
+            //
+        });
+
+
+        Schema::table('docter_organization', function (Blueprint $table) {
+            //
+        });
+
+        Schema::table('schedule_periods', function (Blueprint $table) {
+            //
+        });
+
+        Schema::table('suggests', function (Blueprint $table) {
+                    //
+        });
+
+        Schema::dropIfExists('docter_user');
+
+    }
+}

+ 34 - 0
database/migrations/2020_10_13_153716_create_suggests_detail_table.php

xqd
@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateSuggestsDetailTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('suggests_detail', function (Blueprint $table) {
+//            $table->bigIncrements('id');
+            $table->integer('suggest_id')->comment('suggest表主键');
+            $table->string('supplement_reason',2000)->comment('补充原因');
+            $table->string('supplement_content',2000)->comment('补充建议');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('suggests_detail');
+    }
+}

+ 42 - 0
database/migrations/2020_10_14_023006_alter_docters_table.php

xqd
@@ -0,0 +1,42 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AlterDoctersTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('docters', function (Blueprint $table) {
+            //添加字段
+            $table->integer('user_id')->comment('用户表关联id');
+            $table->string('password',50)->nullable()->comment('密码');
+            $table->integer('is_then')->nullable()->comment('是否认证:0=未认证;1=认证');
+            $table->string('practice',200)->nullable()->comment('医生照片和执业证书,号分开');
+            $table->string('card_photo',200)->nullable()->comment('身份证正反面,号分开');
+            $table->string('is_quail',200)->nullable()->comment('照片和资格证书,号分开');
+            $table->integer('card_id',20)->nullable()->comment('身份证号');
+
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('docters', function (Blueprint $table) {
+            //删除字段
+            $table->dropColumn('user_id');
+
+        });
+    }
+}

+ 34 - 0
database/migrations/2020_10_15_062105_alter_orders_table.php

xqd
@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AlterOrdersTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('orders', function (Blueprint $table) {
+            //添加接单时间
+            $table->integer('receiving_time')->comment('接单时间');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('orders', function (Blueprint $table) {
+            //删除接单时间
+            $table->dropColumn('receiving_time');
+        });
+    }
+}

+ 34 - 0
database/migrations/2020_10_16_074031_alter_user_messages_table.php

xqd
@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AlterUserMessagesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('user_messages', function (Blueprint $table) {
+            //添加医生id
+            $table->integer('docter_id')->after('user_id')->comment('医生ID');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('orders', function (Blueprint $table) {
+            //删除医生id
+            $table->dropColumn('docter_id');
+        });
+    }
+}

+ 38 - 0
database/migrations/2020_10_16_081824_create_docter_messages_table.php

xqd
@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Support\Facades\DB;
+class CreateDocterMessagesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('docter_messages', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->integer('user_id')->comment("用户ID");
+            $table->integer('docter_id')->comment("医生ID");
+            $table->tinyInteger('status')->comment("状态(1.未读 2.已读)");
+            $table->tinyInteger('type')->comment("类型(1.图文订单 2.电话订单 3.预约订单 4.评价通知 5.系统通知)");
+            $table->integer('relation_id')->comment("关联ID(发出消息操作关联的表的id,比如:医生结束消息时,就该关联意见单ID,因为用户点击消息会进入看意见单)");
+            $table->string('content',500)->comment("消息内容");
+            $table->timestamps();
+        });
+        DB::statement("ALTER TABLE `docter_messages` comment '医生消息表'");
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('docter_messages');
+    }
+}

+ 28 - 0
database/migrations/2020_10_16_083459_alter_docter_messages_table.php

xqd
@@ -0,0 +1,28 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Support\Facades\DB;
+class AlterDocterMessagesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        DB::statement("ALTER TABLE `bm_docter_messages` comment '医生消息表'");
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+    }
+}

+ 36 - 0
database/migrations/2020_10_16_085317_create_call_logs_table.php

xqd
@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Support\Facades\DB;
+class CreateCallLogsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('call_logs', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->integer('order_id')->comment("订单表ID");
+            $table->integer('dial_time')->comment("拨打时间");
+            $table->integer('dialend_time')->comment("结束时间");
+            $table->integer('talk_time')->comment("通话时长");
+            $table->timestamps();
+        });
+        DB::statement("ALTER TABLE `bm_call_logs` comment '通话记录表'");
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('call_logs');
+    }
+}

+ 28 - 0
database/migrations/2020_10_16_085827_alert_call_logs_table.php

xqd
@@ -0,0 +1,28 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Support\Facades\DB;
+class AlertCallLogsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        DB::statement("ALTER TABLE `bm_call_logs` comment '通话记录表'");
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+    }
+}

+ 39 - 0
database/migrations/2020_10_17_100407_crete_docter_times.php

xqd
@@ -0,0 +1,39 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreteDocterTimes extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        // 医生时间段服务设置
+        Schema::create('docter_times', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->integer('docter_id')->comment("医生id");
+            $table->decimal('base_price',8,2)->nullable()->comment("基础价格");
+            $table->decimal('step_price',8,2)->nullable()->comment("步进价格");
+            $table->string('service_time',2000)->nullable()->comment("服务时间(00点到24点的索引)");
+            $table->integer('person')->nullable()->comment("服务人次");
+            $table->integer('type')->nullable()->comment("类型(1=电话咨询,2=图文咨询,3=门诊预约,4=疫苗接种预约,5=儿保预约,6=服务包,7=充值)");
+            $table->integer('relation_id')->nullable()->comment("关联id(为门诊预约时,关联机构id)");
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('docter_times');
+    }
+}

+ 8 - 8
database/migrations/2014_10_12_100000_create_password_resets_table.php → database/migrations/2020_10_19_134219_after_user_table.php

xqd xqd xqd
@@ -1,10 +1,10 @@
 <?php
 
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
 
-class CreatePasswordResetsTable extends Migration
+class AfterUserTable extends Migration
 {
     /**
      * Run the migrations.
@@ -13,10 +13,8 @@ class CreatePasswordResetsTable extends Migration
      */
     public function up()
     {
-        Schema::create('password_resets', function (Blueprint $table) {
-            $table->string('email')->index();
-            $table->string('token');
-            $table->timestamp('created_at')->nullable();
+        Schema::table('users', function (Blueprint $table) {
+            $table->string('remark',200)->nullable()->comment('用户备注');
         });
     }
 
@@ -27,6 +25,8 @@ class CreatePasswordResetsTable extends Migration
      */
     public function down()
     {
-        Schema::dropIfExists('password_resets');
+        Schema::table('user', function (Blueprint $table) {
+            //
+        });
     }
 }

+ 64 - 0
database/migrations/2020_11_03_070733_alert_cmdsuser_org_nurse_office_add_docter_verify.php

xqd
@@ -0,0 +1,64 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AlertCmdsuserOrgNurseOfficeAddDocterVerify extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+//        Schema::table('nurses',function (Blueprint $table){
+//            $table->integer('stock')->nullable(false)->comment('库存')->after('price');
+//            $table->integer('used')->nullable()->comment('已使用')->after('stock');
+//        });
+//
+//        Schema::table('organizations', function (Blueprint $table) {
+//            $table->integer('cdms_id')->after('id')->comment('后台账号id')->nullable();
+//        });
+//
+//        Schema::table('cdms_users', function (Blueprint $table) {
+//            $table->integer('org_id')->after('password')->comment('机构id')->nullable();
+//        });
+//        Schema::table('offices', function (Blueprint $table) {
+//            $table->integer('org_id')->after('id')->comment('机构id');
+//        });
+
+        Schema::create('docter_verify',function (Blueprint $table){
+            $table->bigIncrements('id')->comment('自增id');
+            $table->integer('docter_id')->nullable(false)->comment('医生id');
+            $table->integer('org_id')->nullable(false)->comment('社区id');
+            $table->integer('status')->nullable(false)->comment('状态 1 待审核 2 社区审核通过 3 后台审核通过 4审核失败')->default(1);
+            $table->dateTime('created_at')->comment('创建时间');
+            $table->dateTime('updated_at')->comment('跟新时间');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+//        Schema::table('nurses', function (Blueprint $table) {
+//            $table->dropColumn('stock');
+//            $table->dropColumn('used');
+//        });
+//
+//        Schema::table('organizations', function (Blueprint $table) {
+//            $table->dropColumn('cdms_id');
+//        });
+//
+//        Schema::table('cdms_users', function (Blueprint $table) {
+//            $table->dropColumn('org_id');
+//        });
+
+        Schema::dropIfExists('docter_verify');
+    }
+}

+ 7 - 10
database/migrations/2014_10_12_000000_create_users_table.php → database/migrations/2020_11_04_034904_docter_user.php

xqd xqd xqd
@@ -1,10 +1,10 @@
 <?php
 
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
 
-class CreateUsersTable extends Migration
+class DocterUser extends Migration
 {
     /**
      * Run the migrations.
@@ -13,13 +13,10 @@ class CreateUsersTable extends Migration
      */
     public function up()
     {
-        Schema::create('users', function (Blueprint $table) {
+        Schema::create('docter_user', function (Blueprint $table) {
             $table->bigIncrements('id');
-            $table->string('name');
-            $table->string('email')->unique();
-            $table->timestamp('email_verified_at')->nullable();
-            $table->string('password');
-            $table->rememberToken();
+            $table->integer('docter_id')->comment('医生表主键');
+            $table->integer('user_id')->comment('用户表主键');
             $table->timestamps();
         });
     }
@@ -31,6 +28,6 @@ class CreateUsersTable extends Migration
      */
     public function down()
     {
-        Schema::dropIfExists('users');
+        Schema::dropIfExists('docter_user');
     }
 }

+ 0 - 0
nginx.htaccess


+ 7 - 19
public/.htaccess

xqd
@@ -1,21 +1,9 @@
-<IfModule mod_rewrite.c>
-    <IfModule mod_negotiation.c>
-        Options -MultiViews -Indexes
-    </IfModule>
+Options +FollowSymLinks -Indexes
+RewriteEngine On
 
-    RewriteEngine On
+RewriteCond %{HTTP:Authorization} .
+RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
 
-    # Handle Authorization Header
-    RewriteCond %{HTTP:Authorization} .
-    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
-
-    # Redirect Trailing Slashes If Not A Folder...
-    RewriteCond %{REQUEST_FILENAME} !-d
-    RewriteCond %{REQUEST_URI} (.+)/$
-    RewriteRule ^ %1 [L,R=301]
-
-    # Handle Front Controller...
-    RewriteCond %{REQUEST_FILENAME} !-d
-    RewriteCond %{REQUEST_FILENAME} !-f
-    RewriteRule ^ index.php [L]
-</IfModule>
+RewriteCond %{REQUEST_FILENAME} !-d
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteRule ^ index.php [L]

+ 1 - 0
public/.user.ini

xqd
@@ -0,0 +1 @@
+open_basedir=/www/wwwroot/BaoMa/:/tmp/

+ 1 - 0
public/.well-known/acme-challenge/0F7qTXwRYiBveiBMiqtQjyeDt3Mvp7Uv8uTSCR3xNqs

xqd
@@ -0,0 +1 @@
+0F7qTXwRYiBveiBMiqtQjyeDt3Mvp7Uv8uTSCR3xNqs.ZTYV4bkFMi_YCqSWmWrhQ_EpgaBVVljytKOim6cUiuU

+ 1 - 0
public/.well-known/pki-validation/fileauth.txt

xqd
@@ -0,0 +1 @@
+1K0hF2e77qYAcbjbJawK2sERkpdlo137

+ 26 - 0
public/404.html

xqd
@@ -0,0 +1,26 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
+<title>404</title>
+<style>
+	body{
+		background-color:#444;
+		font-size:14px;
+	}
+	h3{
+		font-size:60px;
+		color:#eee;
+		text-align:center;
+		padding-top:30px;
+		font-weight:normal;
+	}
+</style>
+</head>
+
+<body>
+<h3>404,您请求的文件不存在!</h3>
+</body>
+</html>

+ 39 - 0
public/index.html

xqd
@@ -0,0 +1,39 @@
+<!doctype html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>恭喜,站点创建成功!</title>
+    <style>
+        .container {
+            width: 60%;
+            margin: 10% auto 0;
+            background-color: #f0f0f0;
+            padding: 2% 5%;
+            border-radius: 10px
+        }
+
+        ul {
+            padding-left: 20px;
+        }
+
+            ul li {
+                line-height: 2.3
+            }
+
+        a {
+            color: #20a53a
+        }
+    </style>
+</head>
+<body>
+    <div class="container">
+        <h1>恭喜, 站点创建成功!</h1>
+        <h3>这是默认index.html,本页面由系统自动生成</h3>
+        <ul>
+            <li>本页面在FTP根目录下的index.html</li>
+            <li>您可以修改、删除或覆盖本页面</li>
+            <li>FTP相关信息,请到“面板系统后台 > FTP” 查看</li>
+        </ul>
+    </div>
+</body>
+</html>

+ 1 - 0
public/newfile.txt

xqd
@@ -0,0 +1 @@
+[{"phone_no":"18831138292","pool_key":"FC100000115024469","city":"昆明","sub_id":1000027052283144,"unconnected_cause":0,"call_time":"2020-12-21 17:13:57","peer_no":"15222021008","called_display_no":"17052201941","call_id":"31353637353534303965","partner_key":"FC100000115024469","control_msg":"OK","id":1007219638881,"secret_no":"17052201941","call_type":1,"control_type":"CONTINUE"}]

+ 0 - 0
public/nginx.htaccess