liuyuanhang 4 سال پیش
والد
کامیت
67270cbb67

+ 50 - 4
app/Helpers/functions.php

xqd xqd xqd xqd xqd xqd xqd
@@ -6,6 +6,7 @@
  * Time: 上午10:56
  */
 
+use Illuminate\Support\Facades\Log;
 use App\Exceptions\ExitOutException;
 use App\Models\SystemConfig;
 use App\Models\TimePeriod;
@@ -102,6 +103,7 @@ if (!function_exists('get_distance_field')) {
     function get_distance_field($latitude, $longitude)
     {
         if (empty($latitude) || empty($longitude)) {
+
             return '未知 distance';
         }
 
@@ -121,6 +123,7 @@ if (!function_exists('get_user_distance_field')) {
         }
 
         return 'if(longitude=0 and latitude=0,"未知",round(6378.138*2*asin(sqrt(pow(sin( (' . $latitude . '*pi()/180-latitude*pi()/180)/2),2)+cos(' . $latitude . '*pi()/180)*cos(latitude*pi()/180)* pow(sin((' . $longitude . '*pi()/180-longitude*pi()/180)/2),2)))*1000)) distance';
+
     }
 }
 
@@ -206,6 +209,7 @@ if (!function_exists('get_user_distance')) {
     }
 }
 
+
 if (!function_exists('numBirthday')){
     /**
      * 生日转年龄
@@ -310,9 +314,9 @@ if (!function_exists('aly_sm_request')) {
 
         try {
             $content = aly_sms_fetch_content($url, $method, "Signature={$signature}{$sortedQueryStringTmp}");
+
             return json_decode($content, true);
         } catch (Exception $e) {
-
             return false;
         }
     }
@@ -366,6 +370,51 @@ if (!function_exists('aly_sms_fetch_content')) {
     }
 }
 
+    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;
+        }
+    }
+
+
+
+
+
+
 //检测重复请求 超过就禁止访问 有用户flag就针对用户flag 没有flag就针对ip地址(ip的话注意反代情况,可能每个用户请求的ip都是反代服务器的ip,当然可以配置一波反代服务器使得业务服务器获取到真实用户ip) 最小只能设置1s一次请求 不支持1s以下 如果开启了redis可以改写支持毫秒级的方法
 if (!function_exists('check_repeat_request')) {
     function check_repeat_request($time, $limit, $flag = '')
@@ -478,6 +527,3 @@ if (!function_exists('numDays')){
         return $Days;
     }
 }
-
-
-

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


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


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


+ 6 - 3
app/Http/Controllers/Api/V2/CommonController.php

xqd xqd xqd xqd xqd
@@ -26,6 +26,7 @@ use App\Models\Axb;
 use App\Models\ImMessage;
 use Cache;
 
+
 /**
  * 公共方法类
  * Class CommonController
@@ -43,6 +44,7 @@ class CommonController extends Controller
             'latitude|纬度' => 'numeric',
             'longitude|纬度' => 'numeric',
         ]);
+
         $app = Factory::miniProgram(config('config.docter_wechat_small_program'));
 
         $data = $app->auth->session($req['wechat_code']);
@@ -116,6 +118,7 @@ class CommonController extends Controller
             'openid' => 'required',
         ]);
 
+
         $app = Factory::miniProgram(config('config.docter_wechat_small_program'));
 //        $data = $app->auth->session($req['code']);
 //        if (empty($data['openid'])){
@@ -335,9 +338,9 @@ class CommonController extends Controller
      * Create By 2020/11/6 10:45
      */
     public function putverfiy(){
+
         //防止恶意刷验证码接口,一分钟最多10次
         check_repeat_request(60, 10);
-
         $req = request()->post();
         $this->validate(request(), [
             'phone|手机号' => 'required|integer',
@@ -1064,8 +1067,8 @@ class CommonController extends Controller
                             $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();
+//                            $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);
                         }

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


+ 92 - 37
app/Http/Controllers/Api/V2/DoctorController.php

xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd
@@ -44,6 +44,8 @@ use App\Models\DocterServiceTimes;
 use App\Models\CallLog;
 use App\Models\ImMessage;
 use App\Models\DocterLable;
+use App\Models\SchedueFlags as Sflag;
+
 
 /**
  * 医生相关类
@@ -654,7 +656,9 @@ class DoctorController extends AuthController
 
                                 $timeList = $this->getTimeHoures($v['service_times']);
                                 foreach ($timeList as $kk => $vv) {
-                                    $times_data[$k][$kk]['type'] = 2;
+
+                                    $times_data[$k][$kk]['type'] = 1;
+
                                     $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];
@@ -924,7 +928,7 @@ class DoctorController extends AuthController
                     // 第二步, 根据时长去生成24小时的时间段,也要存id
                     $timeList = $this->getTimeHoures($v['service_times']);
                     foreach ($timeList as $kk => $vv) {
-                        $times_data[$k][$kk]['type'] = 2;
+                        $times_data[$k][$kk]['type'] = 1;
                         $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];
@@ -1037,7 +1041,11 @@ class DoctorController extends AuthController
 
 
     /**
+<<<<<<< HEAD
+     * 联动医院
+=======
      * 获取地区/联动医院
+>>>>>>> dev
      * Auth:Yuanhang-Liu
      * Date:2020/10/14 17:17 *
      * @return \Illuminate\Http\JsonResponse
@@ -2341,11 +2349,12 @@ class DoctorController extends AuthController
             $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);
+            if (count($morningd)>1){
+                array_pop($morningd);
+            }
             $morning = array_column($morningd, 'id');
+
             return $morning;
         } elseif ($type == 2) {
             $afternoondWhere[] = ['start_time_period', '>=', $zhongTimes[0]];
@@ -2353,7 +2362,9 @@ class DoctorController extends AuthController
             $afternoondWhere['docter_id'] = $doctor_id;
             $afternoondWhere['org_id'] = $org_id;
             $afternoond = TimePeriod::where($afternoondWhere)->get()->toArray();
-            array_pop($afternoond);
+            if (count($afternoond)>1){
+                array_pop($afternoond);
+            }
             $afternoon = array_column($afternoond, 'id');
             return $afternoon;
 
@@ -2363,7 +2374,10 @@ class DoctorController extends AuthController
             $nightWhere['docter_id'] = $doctor_id;
             $nightWhere['org_id'] = $org_id;
             $nightd = TimePeriod::where($nightWhere)->get()->toArray();
-            array_pop($nightd);
+            if (count($nightd)>1){
+                array_pop($nightd);
+            }
+
             $night = array_column($nightd, 'id');
             return $night;
 
@@ -2373,7 +2387,9 @@ class DoctorController extends AuthController
             $morningWhere['docter_id'] = $doctor_id;
             $morningWhere['org_id'] = $org_id;
             $morningd = TimePeriod::where($morningWhere)->get()->toArray();
-            array_pop($morningd);
+            if (count($morningd)>1){
+                array_pop($morningd);
+            }
             $morning = array_column($morningd, 'id');
 
             $afternoondWhere[] = ['start_time_period', '>=', $zhongTimes[0]];
@@ -2381,7 +2397,9 @@ class DoctorController extends AuthController
             $afternoondWhere['docter_id'] = $doctor_id;
             $afternoondWhere['org_id'] = $org_id;
             $afternoond = TimePeriod::where($afternoondWhere)->get()->toArray();
-            array_pop($afternoond);
+            if (count($afternoond)>1){
+                array_pop($afternoond);
+            }
             $afternoon = array_column($afternoond, 'id');
 
             $nightWhere[] = ['start_time_period', '>=', $wanTimes[0]];
@@ -2389,7 +2407,9 @@ class DoctorController extends AuthController
             $nightWhere['docter_id'] = $doctor_id;
             $nightWhere['org_id'] = $org_id;
             $nightd = TimePeriod::where($nightWhere)->get()->toArray();
-            array_pop($nightd);
+            if (count($nightd)>1){
+                array_pop($nightd);
+            }
             $night = array_column($nightd, 'id');
             return [$morning, $afternoon, $night];
         }
@@ -2660,6 +2680,11 @@ class DoctorController extends AuthController
 //        $type_data = explode(',', $req['type']);
         DB::beginTransaction();
         try {
+            $findFlag = Sflag::where(['docter_id'=>$doctor_id,'schedule_date'=>$req['schedule_date']])->first();
+            if (!$findFlag){
+                Sflag::create(['schedule_date'=>$req['schedule_date'],'docter_id'=>$doctor_id]);
+            }
+
             $type_data = json_decode($req['type'],true);
 
             $finds = SelfSchedule::where(['schedule_date' => $req['schedule_date'], 'docter_id' => $doctor_id, 'schedule_type' => 1])->delete();
@@ -2695,24 +2720,27 @@ class DoctorController extends AuthController
 
             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'];
+                    if($save_data){
+                        $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);
                     }
-                    SchedulePeriod::insert($chong);
+
                 }
             }
-            SelfSchedule::insert($save_data);
+
             DB::commit();
             if ($flag) {
                 return true;
@@ -2779,7 +2807,6 @@ class DoctorController extends AuthController
         $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']);
@@ -2843,7 +2870,9 @@ class DoctorController extends AuthController
                 }
             }
         }
+
         $newList = [];
+
         foreach ($moth_date as $k => $v) {
             $newList[$k]['date'] = $v['date'];
             $newList[$k]['ident']['zao'] = 0;
@@ -2859,8 +2888,12 @@ class DoctorController extends AuthController
             }
         }
 
+
+
+
         $selfList = [];
         if ($selfScheduleList) {
+            $putArr = [];
             // 自定义排班数组
             $selfScheduleList = $selfScheduleList->toArray();
             foreach ($selfScheduleList as $k => $v) {
@@ -2890,6 +2923,30 @@ class DoctorController extends AuthController
                 }
             }
 
+            // 自定义的
+            $pusList = Sflag::where('docter_id',$doctor_id)->get();
+            //然后查看下自定义排班是否删除了
+            if ($pusList){
+                foreach ($pusList as $k=>$v){
+                    foreach ($selfScheduleList as $kk=>$vv){
+                        if ($v['schedule_date']==$vv['schedule_date']){
+                            unset($pusList[$k]);
+                        }
+                    }
+                }
+                foreach ($pusList as $k=>$v){
+                    $bl = [
+                        'schedule_date'=>$v['schedule_date'],
+                        'ident'=>[
+                            'zao_id'=>0,
+                            'xia_id'=>0,
+                            'wan_id'=>0,
+                        ],
+                    ];
+                    $selfList[$v['schedule_date']] = $bl;
+                }
+            }
+
             foreach ($selfList as $k => $v) {
                 foreach ($newList as $kk => $vv) {
                     if ($v['schedule_date'] == $vv['date']) {
@@ -2901,7 +2958,6 @@ class DoctorController extends AuthController
                 }
             }
 
-
         }
         return out($newList);
     }
@@ -2929,7 +2985,6 @@ class DoctorController extends AuthController
             $maf[$k]['type'] = $req['type'];
             $maf[$k]['order_num'] = 0;
         }
-
         return $maf;
     }
 
@@ -3141,18 +3196,18 @@ class DoctorController extends AuthController
 
         $newList=[];
         if ($list){
-           foreach ($list as $k=>$v){
-               $decode = json_decode($v['text'],true);
+            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);
-           }
-
-       }
+                $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);
     }
 }

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


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

xqd
@@ -252,8 +252,8 @@ class PatientController extends AuthController
         $finds = Axb::where($axbwhere)->orderBy('id','desc')->first();
 
         if ($status==1 && $finds){
-            $unlok = (new Commons())->unLokPhone($finds['xphone']);
-            Axb::where($axbwhere)->delete();
+            $unlok = (new Commons())->unLokPhone($finds['xphone'],$finds['subs_id']);
+            Axb::where(['subs_id'=>$finds['subs_id']])->delete();
         }
 
         return out();

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


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


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


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


+ 14 - 0
app/Models/SchedueFlags.php

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