|
|
|
|
@ -347,7 +347,7 @@ class PlanListController extends Controller
|
|
|
|
|
//获取最近可用的,计划 日期
|
|
|
|
|
public function NearestEnablePlanDate()
|
|
|
|
|
{
|
|
|
|
|
$dateRange = 7;
|
|
|
|
|
$dateRange=config('app.globals.可用号源查询范围');
|
|
|
|
|
$regnum = request('regnum');
|
|
|
|
|
$entrustids = request('entrustid');
|
|
|
|
|
$episodeid = request('episodeid');
|
|
|
|
|
@ -398,51 +398,64 @@ class PlanListController extends Controller
|
|
|
|
|
$service = new PlanListService();
|
|
|
|
|
return $service->YuYue($planid, $appointment_type, $mainlistid, $do_type);
|
|
|
|
|
}
|
|
|
|
|
//自动预约
|
|
|
|
|
public function AutoYuYue()
|
|
|
|
|
{
|
|
|
|
|
$dateRange=config('app.globals.可用号源查询范围');
|
|
|
|
|
$regnum = request('regnum');
|
|
|
|
|
$entrustids = request('entrustid');
|
|
|
|
|
$episodeid = request('episodeid');
|
|
|
|
|
$appointment_type = request('appointment_type'); //预约类型
|
|
|
|
|
$TodayDateTime = date("Y-m-d H:i:s");
|
|
|
|
|
$service = new PlanListService();
|
|
|
|
|
|
|
|
|
|
$startDate = new DateTime();
|
|
|
|
|
// 设定结束日期为当前日期加7天
|
|
|
|
|
$endDate = new DateTime();
|
|
|
|
|
$endDate->modify('+' . $dateRange . ' day');
|
|
|
|
|
// 循环遍历每一天
|
|
|
|
|
$currentDate = $startDate;
|
|
|
|
|
$enable_plan=false;
|
|
|
|
|
while ($currentDate <= $endDate) {
|
|
|
|
|
$nowdate = $currentDate->format('Y-m-d');
|
|
|
|
|
$s = $service->GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_type, $nowdate);
|
|
|
|
|
if ($s['status']) {
|
|
|
|
|
$list = $s['data']['plan_list'];
|
|
|
|
|
if (count($list) > 0) {
|
|
|
|
|
foreach ($list as $k => $v) {
|
|
|
|
|
if($v->count-$v->used_count>0 and $TodayDateTime< $v->date.' '.$v->end_reservation_time){
|
|
|
|
|
$enable_plan=$v;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!!$enable_plan){
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 每次循环增加一天
|
|
|
|
|
$currentDate->modify('+1 day');
|
|
|
|
|
}
|
|
|
|
|
if(!!$enable_plan){
|
|
|
|
|
$mainlistids=DB::table('s_list')->whereIn('entrust_id',$entrustids)->pluck('id')->toArray();
|
|
|
|
|
$service = new PlanListService();
|
|
|
|
|
return $service->YuYue($enable_plan->id, $appointment_type, $mainlistids, 1);
|
|
|
|
|
}else{
|
|
|
|
|
return \Yz::echoError1('最近'.$dateRange.'日无可用号源');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function CancelYuYue(Request $request)
|
|
|
|
|
{
|
|
|
|
|
// date_default_timezone_set('PRC');
|
|
|
|
|
// $nowdatetime = date("Y-m-d H:i:s");
|
|
|
|
|
$MainListId = request('MainListId');
|
|
|
|
|
$reg_num = request('reg_num');
|
|
|
|
|
$password = request('password');
|
|
|
|
|
$userid = $request->get('userid');//中间件产生的参数
|
|
|
|
|
$query = DB::table('users')->where(['id' => $userid])->get();
|
|
|
|
|
if (password_verify($password, $query[0]->pwd)) {
|
|
|
|
|
|
|
|
|
|
$service = new PlanListService();
|
|
|
|
|
return $service->CancelYuYue($MainListId, $reg_num);
|
|
|
|
|
|
|
|
|
|
// $mainInfo = DB::table('s_list')->where(['id' => $MainListId])->first();
|
|
|
|
|
// if (!$mainInfo) return \Yz::echoError1('医嘱不存在');
|
|
|
|
|
// //判断状态
|
|
|
|
|
// if ($mainInfo->list_status <> 1) return \Yz::echoError1('该记录无法取消,当前状态:' . $mainInfo->list_status);
|
|
|
|
|
// DB::beginTransaction();
|
|
|
|
|
// try {
|
|
|
|
|
// $u_mainList = DB::table('s_list')->where(['id' => $MainListId])->update([
|
|
|
|
|
// 'list_status' => 0,
|
|
|
|
|
// 'reservation_date' => null,
|
|
|
|
|
// 'reservation_time' => null,
|
|
|
|
|
// 'reservation_sources' =>null,
|
|
|
|
|
// 'services_group' => null,
|
|
|
|
|
// 'roster_id' => null,
|
|
|
|
|
// 'xuhao' => null,
|
|
|
|
|
// 'appointment_type_id' => null,
|
|
|
|
|
// 'canel_time'=>$nowdatetime,
|
|
|
|
|
// ]);
|
|
|
|
|
// $u_count = DB::table('s_source_roster_detail_count')->where(['roster_detail_id' => $mainInfo->roster_id, 'appointment_type_id' => $mainInfo->appointment_type_id])->decrement('used_count');
|
|
|
|
|
// if($u_mainList && $u_count){
|
|
|
|
|
// DB::commit();
|
|
|
|
|
// return \Yz::Return(true, '取消成功', []);
|
|
|
|
|
// }else{
|
|
|
|
|
// DB::rollBack();
|
|
|
|
|
// return \Yz::echoError1('取消失败');
|
|
|
|
|
// }
|
|
|
|
|
// } catch (\Exception $e) {
|
|
|
|
|
// DB::rollBack();
|
|
|
|
|
// return \Yz::echoError1('取消异常');
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
return \Yz::echoError1('密码不正确');
|
|
|
|
|
}
|
|
|
|
|
|