zilong 4 năm trước cách đây
mục cha
commit
e3ee774119
1 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 5 1
      app/Http/Controllers/Api/V1/PatientController.php

+ 5 - 1
app/Http/Controllers/Api/V1/PatientController.php

xqd xqd
@@ -9,6 +9,7 @@
 namespace App\Http\Controllers\Api\V1;
 
 use App\Models\Order;
+use App\Models\OrderPack;
 use App\Models\Patient;
 
 class PatientController extends AuthController
@@ -108,7 +109,10 @@ class PatientController extends AuthController
         $data['patient'] = Patient::where('id', $req['patient_id'])->where('user_id', $user['id'])->first()->append(['order_num', 'pack_docter_num', 'perfectd_degree']);
 
         $data['orders']['cases'] = Order::with(['docter.office', 'docter.qualification', 'organization.docter'])->where('user_id', $user['id'])->where('patient_id', $req['patient_id'])->whereIn('order_status', [2,3])->where('product_type', '<', 6)->orderBy('id', 'desc')->get();
-        $data['orders']['service_packs'] = Order::with('orderPack')->where('user_id', $user['id'])->where('patient_id', $req['patient_id'])->whereIn('order_status', [2,3])->where('product_type', 6)->orderBy('id', 'desc')->get();
+
+        //只输出未过期的服务包
+        $orderIds = OrderPack::where('user_id', $user['id'])->where('end_time', '<=', time())->pluck('order_id')->toArray();
+        $data['orders']['service_packs'] = Order::with('orderPack')->whereIn('id', $orderIds)->where('user_id', $user['id'])->where('patient_id', $req['patient_id'])->whereIn('order_status', [2,3])->where('product_type', 6)->orderBy('id', 'desc')->get();
 
         return out($data);
     }