瀏覽代碼

Merge branch 'master' of ssh://git.9026.com:2212/swdz-WangHaijun/BaoMa into develop

Mike 4 年之前
父節點
當前提交
ce1691fc12

+ 21 - 3
app/Admin/Controllers/UserManagement/DocterManagement/ApproveController.php

xqd
@@ -48,17 +48,35 @@ class ApproveController extends AdminController
         $grid->column('remarks', __('备注'));
         $grid->column('docter.practice','医生照片和执业证书')->display(function ($img) {
             $arr = explode(',',$img);
-            return $arr;
+            $new_arr = [];
+            foreach ($arr as $value)
+            {
+                $value = str_replace('upload/','',$value);
+                array_push($new_arr,$value);
+            }
+            return  $new_arr;
         })->lightbox(['width' =>'', 'height' => 30]);
 
         $grid->column('docter.card_photo','	身份证正反面')->display(function ($img) {
             $arr = explode(',',$img);
-            return $arr;
+            $new_arr = [];
+            foreach ($arr as $value)
+            {
+                $value = str_replace('upload/','',$value);
+                array_push($new_arr,$value);
+            }
+            return  $new_arr;
         })->lightbox(['width' =>'', 'height' => 30]);
 
         $grid->column('docter.is_quail','照片和资格证书')->display(function ($img) {
             $arr = explode(',',$img);
-            return $arr;
+            $new_arr = [];
+            foreach ($arr as $value)
+            {
+                $value = str_replace('upload/','',$value);
+                array_push($new_arr,$value);
+            }
+            return  $new_arr;
         })->lightbox(['width' =>'', 'height' => 30]);
 
         $grid->column('state', __('认证状态'))->using([1=>'已认证',2=>'审核驳回',3=>'待审核'])->label('info');

+ 14 - 0
app/Http/Controllers/Api/V1/CommonController.php

xqd
@@ -339,4 +339,18 @@ class CommonController extends Controller
 
         return out(['token' => $token]);
     }
+
+    public function delServerFile()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'url' => 'required|url'
+        ]);
+
+        $tem = parse_url($req['url']);
+        $allPath = public_path().$tem['path'];
+        unlink($allPath);
+
+        return out();
+    }
 }

+ 13 - 57
app/Http/Controllers/Api/V1/DocterController.php

xqd xqd xqd
@@ -186,12 +186,11 @@ class DocterController extends AuthController
             'longitude' => 'numeric',
         ]);
         $user = $this->user;
-        $builder = Schedule::with(['schedulePeriod.timePeriod', 'schedulePeriod.organization'])->where('docter_id', $req['docter_id'])->where('schedule_type', 1)->where('schedule_day', '>=', date('Ymd'))->orderBy('schedule_day');
+        $builder = Schedule::with(['schedulePeriod.timePeriod', 'schedulePeriod.organization'])->where('docter_id', $req['docter_id'])->where('schedule_type', 1)->where('schedule_day', '>=', date('Ymd'))->orderBy('schedule_day', 'asc');
         if (!empty($req['organization_id'])) {
             $builder->where('organization_id', $req['organization_id']);
         }
         $data = $builder->paginate($req['per_page']??15)->toArray();
-        \Log::info($data);
         if (!empty($data)) {
             foreach ($data['data'] as $k => &$v) {
                 foreach ($v['schedule_period'] as $k1 => &$v1) {
@@ -206,68 +205,19 @@ class DocterController extends AuthController
                         $can_appoint_num = $docterSettings['service_num'] - $v1['order_num'];
                         $v1['can_appoint_num'] = $can_appoint_num < 0 ? 0 : $can_appoint_num;
                     }
+                    //预约时间已经过了,就不展示了
+                    $schedule_time = strtotime($v1['schedule_date'].' '.$v1['time_period']['end_time_period'].':00');
+                    if ($schedule_time < time()) {
+                        unset($v['schedule_period'][$k1]);
+                    }
                 }
+                $v['schedule_period'] = array_values($v['schedule_period']);
             }
         }
 
         return out($data);
     }
 
-//    public function schedulePeriodList()
-//    {
-//        $req = request()->post();
-//        $this->validate(request(), [
-//            'docter_id' => 'required|integer',
-//            'organization_id' => 'integer',
-//            'per_page' => 'integer',
-//            'latitude' => 'numeric',
-//            'longitude' => 'numeric',
-//        ]);
-//        $user = $this->user;
-//        $builder = schedulePeriod::with(['timePeriod', 'organization'])->where('docter_id', $req['docter_id'])->where('schedule_date', '>=', date('Y-m-d'));
-//        if (!empty($req['organization_id'])) {
-//            $builder->where('organization_id', $req['organization_id']);
-//        }
-//        $data = $builder->paginate($req['per_page']??15)->toArray();
-//        //日期有重复,不同机构排班
-//        $newdata = array();
-//        if (!empty($data)) {
-////            foreach ($data['data'] as $k => &$v) {
-//                foreach ($data as $k1 => $v1) {
-//                    if (!empty($v1['organization'])) {
-//                        $v1['organization']['distance'] = get_user_distance($user, $v1['organization']['latitude'], $v1['organization']['longitude']);
-//                    }
-//                    $docterSettings = DocterSetting::select(['service_num'])->where('docter_id', $req['docter_id'])->where('type', 1)->where('org_id', $v1['organization_id'])->first();
-//                    if (empty($docterSettings)) {
-//                        $v1['can_appoint_num'] = 0;
-//                    }
-//                    else {
-//                        $can_appoint_num = $docterSettings['service_num'] - $v1['order_num'];
-//                        $v1['can_appoint_num'] = $can_appoint_num < 0 ? 0 : $can_appoint_num;
-//                    }
-//
-//                    if(empty($newdata[$v1['time_period']])){
-//                        $newdata[$v1['schedule_date']] = $v1;
-//                    }else{
-//                        $newd = $newdata[$v1['schedule_date']];
-//                        foreach ($newd['time_period'] as $k2 => $v2) {
-//                            array_push($v1['time_period'],$v2);
-//                        }
-//                        $newdata[$v['schedule_date']] = $v1;
-//
-//                    }
-//                }
-//
-////            }
-//        }
-//        $res = array();
-//        foreach ($newdata as $v) {
-//            if (!empty($v['time_period']))$res[] = $v;
-//        }
-//
-//        return out($res);
-//    }
-
     public function timePeriodList()
     {
         $req = request()->post();
@@ -302,7 +252,13 @@ class DocterController extends AuthController
                         $can_appoint_num = $docterSettings['service_num'] - $v1['order_num'];
                         $v1['can_appoint_num'] = $can_appoint_num < 0 ? 0 : $can_appoint_num;
                     }
+                    //预约时间已经过了,就不展示了
+                    $schedule_time = strtotime($v1['schedule_date'].' '.$v1['time_period']['end_time_period'].':00');
+                    if ($schedule_time < time()) {
+                        unset($v['schedule_period'][$k1]);
+                    }
                 }
+                $v['schedule_period'] = array_values($v['schedule_period']);
             }
         }
 

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

xqd xqd xqd
@@ -8,6 +8,7 @@
 
 namespace App\Http\Controllers\Api\V1;
 
+use App\Models\DocterSetting;
 use App\Models\Nurse;
 use App\Models\Order;
 use App\Models\OrderNurse;
@@ -17,6 +18,7 @@ use App\Models\OrderVaccine;
 use App\Models\OrganizationVaccine;
 use App\Models\Patient;
 use App\Models\Payment;
+use App\Models\SchedulePeriod;
 use App\Models\ServicePack;
 use App\Models\Team;
 use App\Models\TeamDocter;
@@ -230,6 +232,29 @@ class OrderController extends AuthController
             return out(null, 10011, '请输入支付密码');
         }
 
+        //检查号源
+        if ($product_type == 3) {
+            $schedulePeriod = SchedulePeriod::where('docter_id', $req['docter_id'])->where('time_period_id', $req['time_period_id'])->where('schedule_date', $req['schedule_date'])->where('schedule_type', 1)->first();
+            if (empty($schedulePeriod)) {
+                return out(null, 10012, '医生无该时间段的排班');
+            }
+            $docterSettings = DocterSetting::select(['service_num'])->where('docter_id', $req['docter_id'])->where('type', 1)->first();
+            if ($docterSettings['service_num'] <= $schedulePeriod['order_sn']) {
+                return out(null, 10014, '医生该时间段已经预约满了');
+            }
+        }
+        elseif (in_array($product_type, [4,5])) {
+            $schedule_type_map = [4 => 2, 5 => 3];
+            $schedulePeriod = SchedulePeriod::where('time_period_id', $req['time_period_id'])->where('schedule_date', $req['schedule_date'])->where('organization_id', $req['organization_id'])->where('schedule_type', $schedule_type_map[$product_type])->first();
+            if (empty($schedulePeriod)) {
+                return out(null, 10013, '机构无该时间段的排班');
+            }
+            $docterSettings = DocterSetting::select(['service_num'])->where('org_id', $req['organization_id'])->where('type', $schedule_type_map[$product_type])->first();
+            if ($docterSettings['service_num'] <= $schedulePeriod['order_sn']) {
+                return out(null, 10015, '机构该时间段已经预约满了');
+            }
+        }
+
         if ($req['payment_type'] == 2) {
             if ($user['balance'] < $payment_amount) {
                 return out(null, 601, '余额不足');