You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
3.4 KiB
PHP
75 lines
3.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\API\Admin\YeWu;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Tools;
|
|
|
|
class EntrustController extends Controller
|
|
{
|
|
public function GetList(){
|
|
$searchInfo = request('searchInfo');
|
|
$page = request('page');
|
|
$pageSize = request('pageSize');
|
|
$list=DB::table('s_list')
|
|
->leftJoin('s_period','s_list.reservation_time','=','s_period.id')
|
|
->leftJoin('s_department_resources','s_list.reservation_sources','=','s_department_resources.id')
|
|
->select('s_list.*','s_period.period_begin_time','s_period.period_end_time','s_department_resources.department_resources_name');
|
|
if ($searchInfo['dateRange']!=null and count($searchInfo['dateRange']) == 2) {
|
|
$list = $list->where(function ($q) use($searchInfo) {
|
|
$q->whereBetween('s_list.entrust_date', $searchInfo['dateRange'])
|
|
->orWhereBetween('s_list.reservation_date', $searchInfo['dateRange']);
|
|
});
|
|
}
|
|
if(isset($searchInfo['department_id'])){
|
|
$department = DB::table('s_department')->where(['id' => $searchInfo['department_id'],'is_del'=>0])->first();
|
|
$list=$list->where(['RISRAcceptDeptCode'=>$department->department_number]);
|
|
}
|
|
if (isset($searchInfo['list_status'])) {
|
|
$list = $list->where('s_list.list_status', $searchInfo['list_status']);
|
|
}
|
|
if (isset($searchInfo['patient_type'])) {
|
|
$list = $list->where('s_list.patient_type', $searchInfo['patient_type']);
|
|
}
|
|
if (!empty($searchInfo['resources'])) {
|
|
$list = $list->whereIn('s_list.reservation_sources', $searchInfo['resources']);
|
|
}
|
|
if (isset($searchInfo['services_group'])) {
|
|
$list = $list->whereRaw("FIND_IN_SET({$searchInfo['services_group']}, s_list.services_group)");
|
|
}
|
|
if (isset($searchInfo['reg_num'])) {
|
|
$list = $list->where('s_list.reg_num', $searchInfo['reg_num']);
|
|
}
|
|
if (isset($searchInfo['user_name'])) {
|
|
$list = $list->where('s_list.user_name', 'like','%'.$searchInfo['user_name'].'%');
|
|
}
|
|
if (isset($searchInfo['doctor'])) {
|
|
$list = $list->where('s_list.docotr', 'like','%'.$searchInfo['doctor'].'%');
|
|
}
|
|
if (isset($searchInfo['apply_department'])) {
|
|
$list = $list->where('s_list.reservation_department', 'like','%'.$searchInfo['apply_department'].'%');
|
|
}
|
|
|
|
$count = $list;
|
|
$count = $count->count();
|
|
$list=$list->where(['s_list.is_del'=>0,'s_list.is_nullify'=>0])->orderBy('id', 'desc')->limit($pageSize)->skip(($page - 1) * $pageSize) // 跳过前9999条记录
|
|
->take($pageSize)->get();
|
|
|
|
//匹配设备(服务组)
|
|
$devices = DB::table('s_devices')->get();
|
|
foreach ($list as $key => $value) {
|
|
$list[$key]->age = Tools::calculateAgeText($value->user_brithday);
|
|
$list[$key]->devices = [];
|
|
$array_device_id = explode(",", $value->services_group);
|
|
foreach ($devices as $k => $v) {
|
|
if (in_array($v->id, $array_device_id)) {
|
|
$list[$key]->devices[] = $v;
|
|
}
|
|
}
|
|
}
|
|
return \Yz::Return(true,'查询完成',['list'=>$list,'count'=>$count]);
|
|
}
|
|
}
|