zilong před 4 roky
rodič
revize
736bdbf673

+ 6 - 1
app/Http/Controllers/Api/V1/DocterController.php

xqd xqd
@@ -10,6 +10,7 @@ namespace App\Http\Controllers\Api\V1;
 
 use App\Models\Collection;
 use App\Models\Docter;
+use App\Models\DocterServiceTime;
 use App\Models\Organization;
 use App\Models\Schedule;
 use App\Models\SchedulePeriod;
@@ -37,10 +38,14 @@ class DocterController extends AuthController
 
         $builder = Docter::with('office', 'qualification')->select(['id', 'type', 'name', 'phone', 'sex', 'birthday', 'avatar', 'status', 'label', 'sign', 'intro', 'office_id', 'qualification_id', 'score', 'service_persons', 'eva_num', 'service_days', 'phone_minutes', 'chat_price', 'phone_price', 'appoint_price', 'is_chat', 'is_phone', 'is_appoint', 'latitude', 'longitude', DB::raw($distance_field)])->where('status', 1)->where('is_then', 1)->where('phone', '<>', '');
         $list_type = !empty($req['list_type']) ? $req['list_type'] : 0;
+        $now_line = (int)date('Hi');
         if ($list_type == 1) {
-            $builder->where('is_phone', 1);
+            $ids = DocterServiceTime::where('type', 1)->where('start_time_line', '<=', $now_line)->where('end_time_line', '>', $now_line)->pluck('docter_id')->toArray();
+            $builder->where('is_phone', 1)->whereIn('id', $ids);
         }
         if ($list_type == 2) {
+            $ids = DocterServiceTime::where('type', 2)->where('start_time_line', '<=', $now_line)->where('end_time_line', '>', $now_line)->pluck('docter_id')->toArray();
+            $builder->where('is_phone', 1)->whereIn('id', $ids);
             $builder->where('is_chat', 1);
         }
         if ($list_type == 3) {

+ 13 - 0
app/Models/Docter.php

xqd
@@ -74,8 +74,21 @@ class Docter extends BaseModel
 
         return $data;
     }
+
     public function organization()
     {
         return $this->belongsToMany(Organization::class);
     }
+
+    public function getChatPriceAttribute()
+    {
+        $base_price = Doctertimes::where('docter_id', $this->id)->where('type', 2)->value('base_price');
+        return $base_price*100;
+    }
+
+    public function getPhonePriceAttribute()
+    {
+        $base_price = Doctertimes::where('docter_id', $this->id)->where('type', 1)->value('base_price');
+        return $base_price*100;
+    }
 }

+ 16 - 0
app/Models/DocterServiceTime.php

xqd
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 2020/12/18
+ * Time: 11:02 下午
+ */
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class DocterServiceTime extends Model
+{
+
+}