| xqd
@@ -8,6 +8,7 @@
|
|
|
|
|
|
namespace App\Http\Controllers\Api\V1;
|
|
|
|
|
|
+use App\Models\Collection;
|
|
|
use App\Models\Docter;
|
|
|
use App\Models\Organization;
|
|
|
use App\Models\Schedule;
|
| xqd
@@ -53,15 +54,28 @@ class DocterController extends AuthController
|
|
|
$tmpDocterIds = array_column($v['docter'], 'id');
|
|
|
$docterIds = array_merge($docterIds, $tmpDocterIds);
|
|
|
}
|
|
|
- $docterIds = array_values(array_unique($docterIds));
|
|
|
- $builder->where(function ($query) use($name, $docterIds) {
|
|
|
- $query->where('name', 'like', '%'.$name.'%')->orWhereIn('id', $docterIds);
|
|
|
+ $orgDocterIds = array_values(array_unique($docterIds));
|
|
|
+ $builder->where(function ($query) use($name, $orgDocterIds) {
|
|
|
+ $query->where('name', 'like', '%'.$name.'%')->orWhereIn('id', $orgDocterIds);
|
|
|
});
|
|
|
}
|
|
|
+ if (!empty($req['city_id'])) {
|
|
|
+ $organizations = Organization::with('docter')->select(['id'])->where('city_id', $req['city_id'])->get()->toArray();
|
|
|
+ $docterIds = [];
|
|
|
+ foreach ($organizations as $k => $v) {
|
|
|
+ $tmpDocterIds = array_column($v['docter'], 'id');
|
|
|
+ $docterIds = array_merge($docterIds, $tmpDocterIds);
|
|
|
+ }
|
|
|
+ $cityDocterIds = array_values(array_unique($docterIds));
|
|
|
+ $builder->whereIn('id', $cityDocterIds);
|
|
|
+ }
|
|
|
|
|
|
if ($list_type == 3) {
|
|
|
$docterIds2 = SchedulePeriod::where('time_period_id', $req['time_period_id'])->where('schedule_date', $req['schedule_date'])->pluck('docter_id')->toArray();
|
|
|
$builder->whereIn('id', $docterIds2);
|
|
|
+ //查询我关注的医生
|
|
|
+ $docterIds3 = Collection::where('user_id', $user['id'])->where('docter_id', '>', 0)->pluck('docter_id')->toArray();
|
|
|
+ $builder->whereNotIn('id', $docterIds3);
|
|
|
}
|
|
|
|
|
|
if (!empty($req['sort_type'])) {
|
| xqd
@@ -75,7 +89,37 @@ class DocterController extends AuthController
|
|
|
$builder->orderBy('service_persons', 'desc');
|
|
|
}
|
|
|
}
|
|
|
- $data = $builder->paginate();
|
|
|
+ $data = $builder->paginate()->toArray();
|
|
|
+
|
|
|
+ //组合我关注的医生,放在最前面
|
|
|
+ $page = empty($req['page']) ? 1 : $req['page'];
|
|
|
+ if ($list_type == 3 && $page == 1) {
|
|
|
+ $builder2 = 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)])->whereIn('id', $docterIds3)->whereIn('id', $docterIds2)->where('status', 1)->where('is_then', 1)->where('phone', '<>', '')->where('is_appoint', 1);
|
|
|
+ if (!empty($req['name'])) {
|
|
|
+ $builder2->where(function ($query) use($name, $orgDocterIds) {
|
|
|
+ $query->where('name', 'like', '%'.$name.'%')->orWhereIn('id', $orgDocterIds);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (!empty($req['city_id'])) {
|
|
|
+ $builder2->whereIn('id', $cityDocterIds);
|
|
|
+ }
|
|
|
+ if (!empty($req['sort_type'])) {
|
|
|
+ if ($req['sort_type'] == 1) {
|
|
|
+ $builder2->orderBy('distance', 'asc');
|
|
|
+ }
|
|
|
+ elseif ($req['sort_type'] == 2) {
|
|
|
+ $builder2->orderBy('eva_num', 'desc');
|
|
|
+ }
|
|
|
+ elseif ($req['sort_type'] == 3) {
|
|
|
+ $builder2->orderBy('service_persons', 'desc');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $collectDocters = $builder2->get()->toArray();
|
|
|
+ if (!empty($collectDocters)) {
|
|
|
+ $data['data'] = array_merge($collectDocters, $data['data'] );
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
return out($data);
|
|
|
}
|