|
|
|
@ -6,6 +6,7 @@ use App\Http\Controllers\API\AspNetZhuanController;
|
|
|
|
use App\Http\Controllers\API\PEISApiController;
|
|
|
|
use App\Http\Controllers\API\PEISApiController;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Lib\Tools;
|
|
|
|
use App\Lib\Tools;
|
|
|
|
|
|
|
|
use DateTime;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
|
|
|
|
@ -394,18 +395,120 @@ class OrderNewController extends Controller
|
|
|
|
if(!$order) return \Yz::echoError1("订单不存在");
|
|
|
|
if(!$order) return \Yz::echoError1("订单不存在");
|
|
|
|
if($order->status!== 2) return \Yz::echoError1("订单不是已支付状态不能预约");
|
|
|
|
if($order->status!== 2) return \Yz::echoError1("订单不是已支付状态不能预约");
|
|
|
|
if (!isset($plan_id)) return \Yz::echoError1('号源id不能为空');
|
|
|
|
if (!isset($plan_id)) return \Yz::echoError1('号源id不能为空');
|
|
|
|
|
|
|
|
$person = DB::table('web_user_person')->where(['id' => $order->person_id, 'is_del' => 0])->first();
|
|
|
|
|
|
|
|
if (!$person) return \Yz::echoError1('体检人不存在');
|
|
|
|
|
|
|
|
if ($order->hospital_id == 1) {
|
|
|
|
|
|
|
|
$yyid = 6;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($order->hospital_id == 4) {
|
|
|
|
|
|
|
|
$yyid = 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
//检查号源是否可用
|
|
|
|
//检查号源是否可用
|
|
|
|
$plan = new PlanController();
|
|
|
|
$plan = new PlanController();
|
|
|
|
$plan_check = $plan->CheckPlan($plan_id, $order->hospital_id, $order->type, $order->sex, $order->price, $order->checkup_type_id);
|
|
|
|
$plan_check = $plan->CheckPlan($plan_id, $order->hospital_id, $order->type, $order->sex, $order->price, $order->checkup_type_id);
|
|
|
|
if ($plan_check['status'] === false) return \Yz::echoError1($plan_check['msg']);
|
|
|
|
if ($plan_check['status'] === false) return \Yz::echoError1($plan_check['msg']);
|
|
|
|
$plan = $plan_check['plan'];
|
|
|
|
$plan = $plan_check['plan'];
|
|
|
|
|
|
|
|
$plan_nmr_appointment_info=[];
|
|
|
|
|
|
|
|
//如果有二线号源,根据体检时间查询二线可用号源,区分上下午,二线需预约体检时间1小时后
|
|
|
|
|
|
|
|
$plan_nmr_info=[];
|
|
|
|
|
|
|
|
$erxian_info=json_decode($order->erxian_appointment_info,true);
|
|
|
|
|
|
|
|
$AspNet = new AspNetZhuanController();
|
|
|
|
|
|
|
|
if (isset($erxian_info) and !empty($erxian_info)) {
|
|
|
|
|
|
|
|
foreach ($erxian_info as $erxian_item) {
|
|
|
|
|
|
|
|
$nmrPlans=$AspNet::ErXian(['yyid'=>6,'data'=>[$plan->date],'action'=>"1"],uniqid());
|
|
|
|
|
|
|
|
if($plan->time<="12:00") $end_time="12:00";
|
|
|
|
|
|
|
|
if($plan->time>"12:00") $end_time="23:59";
|
|
|
|
|
|
|
|
if(!isset($nmrPlans[$plan->date]) or empty($nmrPlans[$plan->date])) return \Yz::echoError1("二线号源不可用,请重新选则日期");
|
|
|
|
|
|
|
|
$temp_date=[];
|
|
|
|
|
|
|
|
$planTime = new DateTime($plan->time);
|
|
|
|
|
|
|
|
$planTime->modify('+1 hour');
|
|
|
|
|
|
|
|
$plan_time=$planTime->format('H:i');
|
|
|
|
|
|
|
|
foreach ($nmrPlans[$plan->date] as $nmp_p){
|
|
|
|
|
|
|
|
if($nmp_p['Time']>=$plan_time and $nmp_p['Time']<=$end_time and $nmp_p['keyong']==="0"){
|
|
|
|
|
|
|
|
$temp_date=[
|
|
|
|
|
|
|
|
"item_id"=>$erxian_item['item_id'],
|
|
|
|
|
|
|
|
"name"=>$erxian_item['name'],
|
|
|
|
|
|
|
|
"price"=>$erxian_item['price'],
|
|
|
|
|
|
|
|
"time"=>$plan->date." ".$nmp_p['Time'],
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
$plan_nmr_info[]=$temp_date;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(empty($temp_date)) return \Yz::echoError1("二线号源不可用,请重新选则日期");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//校验二线号源
|
|
|
|
|
|
|
|
if (isset($plan_nmr_info) and !empty($plan_nmr_info)) {
|
|
|
|
|
|
|
|
$plan_nmr_temp = [];
|
|
|
|
|
|
|
|
foreach ($plan_nmr_info as $key => $plan_nmr) {
|
|
|
|
|
|
|
|
if ($plan_nmr['item_id'] <> -1) {
|
|
|
|
|
|
|
|
$dt= explode(" ", $plan_nmr['time']);
|
|
|
|
|
|
|
|
$p_nmr_data = [
|
|
|
|
|
|
|
|
'item_id' => $plan_nmr['item_id'],
|
|
|
|
|
|
|
|
'name' => $plan_nmr['name'],
|
|
|
|
|
|
|
|
'date' => $dt[0],
|
|
|
|
|
|
|
|
'time' => $dt[1],
|
|
|
|
|
|
|
|
'price' => $plan_nmr['price'],
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
//调用接口校验号源是否可用
|
|
|
|
|
|
|
|
$erxian_status = $AspNet::ErXian(['YYRQ' => $p_nmr_data['date'], 'YYSJ' => $p_nmr_data['time'], 'yyid' => $yyid, 'action' => 4], uniqid());
|
|
|
|
|
|
|
|
if ($erxian_status !== true) return \Yz::echoError1($p_nmr_data['name'] . '号源不可用,请重新选择');
|
|
|
|
|
|
|
|
$plan_nmr_temp[] = $p_nmr_data;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$plan_nmr_appointment_info=$plan_nmr_temp;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//开始预约二线
|
|
|
|
|
|
|
|
$nowDateTime=date('Y-m-d H:i:s');
|
|
|
|
|
|
|
|
if (!empty($plan_nmr_appointment_info)) {
|
|
|
|
|
|
|
|
foreach ($plan_nmr_appointment_info as $key => $plan_nmr) {
|
|
|
|
|
|
|
|
//$plan_nmr=$plan_nmr_appointment_info[0];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sex="未知";
|
|
|
|
|
|
|
|
if($person->sex==1) $sex='男';
|
|
|
|
|
|
|
|
if($person->sex==2) $sex='女';
|
|
|
|
|
|
|
|
$p_nmr_data = [
|
|
|
|
|
|
|
|
'ghzid'=>$person->ghzid,
|
|
|
|
|
|
|
|
'YYRQ'=>$plan_nmr['date'],
|
|
|
|
|
|
|
|
'YYSJ'=>$plan_nmr['time'],
|
|
|
|
|
|
|
|
'U_SFID'=>$plan_nmr['item_id'],
|
|
|
|
|
|
|
|
'U_SFMC'=>$plan_nmr['name'],
|
|
|
|
|
|
|
|
'HBXMJE'=>$plan_nmr['price'],
|
|
|
|
|
|
|
|
'CJSJ'=>$nowDateTime,
|
|
|
|
|
|
|
|
'YYDH'=>$person->phone,
|
|
|
|
|
|
|
|
'YYXM'=>$person->name,
|
|
|
|
|
|
|
|
'YYXB'=>$sex,
|
|
|
|
|
|
|
|
'YYSR'=>$person->birthday,
|
|
|
|
|
|
|
|
'YYNL'=>Tools::GetAge($person->birthday).'岁' ,
|
|
|
|
|
|
|
|
'YYZJ'=>$person->id_number,
|
|
|
|
|
|
|
|
'YYSJ_B'=>$plan_nmr['time'].':00',
|
|
|
|
|
|
|
|
'YYSJ_E'=>$plan_nmr['time'].':00',
|
|
|
|
|
|
|
|
'YYSJ_BE'=>$plan_nmr['time'].'-'.$plan_nmr['time'],
|
|
|
|
|
|
|
|
'ZCRQ'=>$nowDateTime,
|
|
|
|
|
|
|
|
'yyid'=>$yyid,
|
|
|
|
|
|
|
|
'action'=>2,
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
//调用接口预约二线
|
|
|
|
|
|
|
|
$erxian_yuyue= $AspNet::ErXian($p_nmr_data, uniqid());
|
|
|
|
|
|
|
|
if(!!$erxian_yuyue){
|
|
|
|
|
|
|
|
$plan_nmr_appointment_info[$key]['gid']=$erxian_yuyue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
return ['status' => false, 'msg' => "二线预约失败"];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data=[
|
|
|
|
$data=[
|
|
|
|
'appointment_date' => $plan->date,
|
|
|
|
'appointment_date' => $plan->date,
|
|
|
|
'appointment_time' => $plan->time,
|
|
|
|
'appointment_time' => $plan->time,
|
|
|
|
'plan_id' => $plan->id,
|
|
|
|
'plan_id' => $plan->id,
|
|
|
|
'plan_number' => $plan->plan_number,
|
|
|
|
'plan_number' => $plan->plan_number,
|
|
|
|
'doctor' => $doctor,
|
|
|
|
'doctor' => $doctor,
|
|
|
|
|
|
|
|
'erxian_appointment_info'=>json_encode($plan_nmr_appointment_info, JSON_UNESCAPED_UNICODE),
|
|
|
|
'updated_at' => date('Y-m-d H:i:s')
|
|
|
|
'updated_at' => date('Y-m-d H:i:s')
|
|
|
|
];
|
|
|
|
];
|
|
|
|
$u = DB::table('orders')->where(['id' => $orderid])->update($data);
|
|
|
|
$u = DB::table('orders')->where(['id' => $orderid])->update($data);
|
|
|
|
|