2 Commit-ok 01b76575f4 ... f5e5958dff

Szerző SHA1 Üzenet Dátum
  zilong f5e5958dff Merge branch 'develop' 4 éve
  刘远航 4e11be362e 修复患者列表中订单异常问题 4 éve

+ 16 - 2
app/Http/Controllers/Api/V2/DoctorController.php

xqd xqd xqd
@@ -1069,7 +1069,7 @@ class DoctorController extends AuthController
      * Auth:Yuanhang-Liu
      * Date:2020/10/17 13:21
      * @return \Illuminate\Http\JsonResponse
-     */
+     */ 
     public function userList()
     {
         $req = request()->post();
@@ -1453,6 +1453,8 @@ class DoctorController extends AuthController
         $finds = Patient::where('id', '=', $req['patient_id'])->first();
         if ($finds) {
             $finds = $finds->toArray();
+        }else{
+            return out();
         }
         if ($finds['sex'] == 0) {
             $finds['sex'] = '未知';
@@ -1488,12 +1490,24 @@ class DoctorController extends AuthController
                 $finds['relationship_type'] = '其他';
         }
         $finds['age'] = numBirthday($finds['birthday']);
+        $user_id = $user['id'];
         // 患者单子
-        $patient_list = OrderPatient::with('order')->where('patient_id', '=', $req['patient_id'])->groupBy('id', 'order_id')->get();
+        $order_where = [];
+        $order_where['docter_id'] = $user_id;
+        $order_where['order_status'] = 4;
+        $patient_list = OrderPatient::with("order")
+            ->where('patient_id','=',$req['patient_id'])
+            ->whereHas('order',function ($query) use ($order_where){
+                return $query->where($order_where);
+            })
+            ->groupBy('id', 'order_id')->get();
         $patient_arr = [];
         if ($patient_list) {
             $patient_list = $patient_list->toArray();
             foreach ($patient_list as $k => $v) {
+                if (!$v['order']){
+                    unset($patient_list[$k]);
+                }
                 switch ($v['order']['product_type']) {
                     case 1:
                         $patient_arr[$k]['product_type'] = '电话咨询';

+ 1 - 1
app/Models/OrderPatient.php

xqd
@@ -16,6 +16,6 @@ class OrderPatient extends BaseModel
 
     public function order()
     {
-        return $this->belongsTo(Order::class);
+        return $this->belongsTo(Order::class,'order_id','id','inner');
     }
 }