diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanListController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanListController.php index 1590e53..87ca059 100644 --- a/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanListController.php +++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanListController.php @@ -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('密码不正确'); } diff --git a/Laravel/app/Services/Admin/YeWu/PlanListService.php b/Laravel/app/Services/Admin/YeWu/PlanListService.php index 16c072f..9d85af8 100644 --- a/Laravel/app/Services/Admin/YeWu/PlanListService.php +++ b/Laravel/app/Services/Admin/YeWu/PlanListService.php @@ -307,10 +307,11 @@ WHERE 'data' => json_encode($u_data) ]); } - if ($u_mainList) { DB::commit(); - $this->SendMsg($oldMainInfos,$do_type); + if(config('app.globals.预约完成短信通知')==1){ + $this->SendMsg($oldMainInfos,$do_type); + } return \Yz::Return(true, '预约成功', ['planid' => $planid, 'mainlistids' => $mainlistids]); } else { DB::rollBack(); diff --git a/Laravel/config/app.php b/Laravel/config/app.php index 785a721..48cf920 100644 --- a/Laravel/config/app.php +++ b/Laravel/config/app.php @@ -2,20 +2,13 @@ return [ 'globals' => [ - 'WxAppid' => 'wx526430047d34c85c', //岚科公众号 - 'WxAppSecret' => '975b8a8b627b1bde71bbe49149134549', //岚科公众号 - -// 'WxAppid' => 'wx8f83ab76a99ba560',//测试 -// 'WxAppSecret' => 'eebc53a9e94f676bd680d3a09eb20303',//测试 - 'BaseServerUrl' =>'http://localhostcommon', - 'WxRedirectUrl'=>'https://www.yanzai.vip/common/laravel/public/wxGetCode', //微信授权登录,重定向地址 - - 'WxReturnCodeUrl_local'=>'http://192.168.31.106:5173/#/getWxCode/', //获取code后引导返回到前端的地址 开发 - 'WxReturnCodeUrl_server'=>'https://www.yanzai.vip/common/mH5/#/getWxCode/', //获取code后引导返回到前端的地址 生产 'YingGuBaseUrl'=>'http://192.168.0.1', //盈谷url + + '预约完成短信通知'=>0,//预约完成后短信通知1开启0关闭 '自动预约'=>1,//开启自动预约,收到推送的医嘱后,自动预约最近可用号源 + '可用号源查询范围'=>7,//根据此字段循环查询当前日期 N天后的数据 ], diff --git a/Laravel/public/jq_page/PersonEntrustList.html b/Laravel/public/jq_page/PersonEntrustList.html index 17aad55..1e2c2e4 100644 --- a/Laravel/public/jq_page/PersonEntrustList.html +++ b/Laravel/public/jq_page/PersonEntrustList.html @@ -14,10 +14,10 @@
- + diff --git a/Laravel/routes/api.php b/Laravel/routes/api.php index 2f7309a..4553caf 100644 --- a/Laravel/routes/api.php +++ b/Laravel/routes/api.php @@ -115,6 +115,7 @@ Route::group(['middleware'=>['log']],function () { Route::post('testSendMsg','App\Http\Controllers\TestSendMsgController@SendMsg');//测试发送短信 Route::post('admin/GetPersonYuYueList','App\Http\Controllers\API\Admin\YeWu\WorkMainController@GetPersonYuYueList');//医生获取某人全部预约记录 + Route::post('admin/AutoYuYue','App\Http\Controllers\API\Admin\YeWu\PlanListController@AutoYuYue');//自动预约 }); //H5端接口