|
|
|
|
@ -404,8 +404,8 @@ class OrderController extends Controller
|
|
|
|
|
//开始预约二线
|
|
|
|
|
$nowDateTime=date('Y-m-d H:i:s');
|
|
|
|
|
if (!empty($plan_nmr_appointment_info)) {
|
|
|
|
|
// foreach ($erxian_info as $key => $plan_nmr) {
|
|
|
|
|
$plan_nmr=$plan_nmr_appointment_info[0];
|
|
|
|
|
foreach ($plan_nmr_appointment_info as $key => $plan_nmr) {
|
|
|
|
|
//$plan_nmr=$plan_nmr_appointment_info[0];
|
|
|
|
|
|
|
|
|
|
$sex="未知";
|
|
|
|
|
if($person->sex==1) $sex='男';
|
|
|
|
|
@ -434,7 +434,7 @@ class OrderController extends Controller
|
|
|
|
|
//调用接口预约二线
|
|
|
|
|
$erxian_yuyue= $AspNet::ErXian($p_nmr_data, uniqid());
|
|
|
|
|
if(!!$erxian_yuyue){
|
|
|
|
|
$plan_nmr_appointment_info[0]['gid']=$erxian_yuyue;
|
|
|
|
|
$plan_nmr_appointment_info[$key]['gid']=$erxian_yuyue;
|
|
|
|
|
$ex_u= DB::table('orders')->where(['id' => $insert])->update([
|
|
|
|
|
'erxian_appointment_info'=>json_encode($plan_nmr_appointment_info, JSON_UNESCAPED_UNICODE),
|
|
|
|
|
]);
|
|
|
|
|
@ -442,7 +442,7 @@ class OrderController extends Controller
|
|
|
|
|
}else{
|
|
|
|
|
return ['status' => false, 'msg' => "二线预约失败"];
|
|
|
|
|
}
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -508,16 +508,115 @@ class OrderController extends Controller
|
|
|
|
|
//订单改约
|
|
|
|
|
public function ChangeAppointment()
|
|
|
|
|
{
|
|
|
|
|
$AspNet = new AspNetZhuanController();
|
|
|
|
|
$orderid = request('orderid');
|
|
|
|
|
$plan_id = request('planid');
|
|
|
|
|
$nmr_plan_id = request('nmrPlanid');
|
|
|
|
|
$nmr_info = request('nmr_info');
|
|
|
|
|
$doctor = request('doctor');
|
|
|
|
|
$orderInfo = DB::table('orders')->where(['id' => $orderid, 'status' => 2])->first();
|
|
|
|
|
if (!$orderInfo) return \Yz::echoError1("未找到有效订单");
|
|
|
|
|
$planInfo = DB::table('plans')->where(['id' => $plan_id, 'status' => 1])->first();
|
|
|
|
|
if (!$planInfo) return \Yz::echoError1("所选体检日期号源无效");
|
|
|
|
|
$person = DB::table('web_user_person')->where(['id' => $orderInfo->person_id, 'is_del' => 0])->first();
|
|
|
|
|
if (!$person) return \Yz::echoError1('体检人不存在');
|
|
|
|
|
if ($orderInfo->hospital_id == 1) {
|
|
|
|
|
$yyid = 6;
|
|
|
|
|
}
|
|
|
|
|
if ($orderInfo->hospital_id == 4) {
|
|
|
|
|
$yyid = 2;
|
|
|
|
|
}
|
|
|
|
|
//判断核磁号源有效性能,日期范围是否正常,判断核磁新日期时间是否和旧的日期时间一样
|
|
|
|
|
//判断体检日期是否在核磁3天左右
|
|
|
|
|
//判断各个二线直接的跨度是否在设定范围内
|
|
|
|
|
$ErXianKuaDu = config('app.globals.erxian_kuadu');
|
|
|
|
|
$check_erxian_kuadu=$this->checkDatesWithinDays($nmr_info,$ErXianKuaDu);
|
|
|
|
|
if(!$check_erxian_kuadu['check_status']) return \Yz::echoError1("所有二线项目预约跨度不应大于".$ErXianKuaDu."天,请重新选择");
|
|
|
|
|
//判断二线号源日期时间是否改变,如果改变校验号源有效性
|
|
|
|
|
$db_nmr_info=json_decode($orderInfo->erxian_appointment_info,true);
|
|
|
|
|
foreach ($nmr_info as $key=>$nmr_item){
|
|
|
|
|
foreach ($db_nmr_info as $db_nmr_item){
|
|
|
|
|
if($nmr_item['item_id']==$db_nmr_item['item_id']){
|
|
|
|
|
if(!($nmr_item['date']==$db_nmr_item['date'] and $nmr_item['time']==$db_nmr_item['time'] and $db_nmr_item['gid']<>"")){
|
|
|
|
|
$p_nmr_data = [
|
|
|
|
|
'item_id' => $nmr_item['item_id'],
|
|
|
|
|
'name' => $nmr_item['name'],
|
|
|
|
|
'date' => $nmr_item['date'],
|
|
|
|
|
'time' => $nmr_item['time'],
|
|
|
|
|
'price' => $nmr_item['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'] . '号源不可用,请重新选择');
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//如果重新选择了体检号源,则检验号源有效性//判断体检日期是否在核磁前N天范围内
|
|
|
|
|
if(isset($plan_id) && $plan_id <> $orderInfo->plan_id){
|
|
|
|
|
$planInfo = DB::table('plans')->where(['id' => $plan_id, 'status' => 1])->first();
|
|
|
|
|
if (!$planInfo) return \Yz::echoError1("所选体检日期号源无效");
|
|
|
|
|
$check_plan_kuadu=$this->checkDatesWithinDays([['date'=>$check_erxian_kuadu['mindate'],'date'=>$planInfo->date]],$ErXianKuaDu);
|
|
|
|
|
if(!$check_erxian_kuadu['check_status']) return \Yz::echoError1("体检日期与核磁日期跨度不能大于".$ErXianKuaDu."天,请重新选择");
|
|
|
|
|
}
|
|
|
|
|
//如果二线号源校验通过,则先取消再预约新的
|
|
|
|
|
foreach ($nmr_info as $key=>$nmr_item){
|
|
|
|
|
foreach ($db_nmr_info as $key2=> $db_nmr_item){
|
|
|
|
|
if($nmr_item['item_id']==$db_nmr_item['item_id']){
|
|
|
|
|
if(!($nmr_item['date']==$db_nmr_item['date'] and $nmr_item['time']==$db_nmr_item['time'])){
|
|
|
|
|
//先取消
|
|
|
|
|
if($db_nmr_item['gid']<>""){
|
|
|
|
|
$AspNet::ErXian(['id' =>$db_nmr_item['gid'], 'yyid' => $yyid, 'action' => 3], uniqid());//取消
|
|
|
|
|
$db_nmr_info[$key2]['gid']='';
|
|
|
|
|
$ex_u= DB::table('orders')->where(['id' => $orderInfo->id])->update([
|
|
|
|
|
'erxian_appointment_info'=>json_encode($db_nmr_info, JSON_UNESCAPED_UNICODE),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
//再预约新的
|
|
|
|
|
$nowDateTime=date('Y-m-d H:i:s');
|
|
|
|
|
$sex="未知";
|
|
|
|
|
if($person->sex==1) $sex='男';
|
|
|
|
|
if($person->sex==2) $sex='女';
|
|
|
|
|
$p_nmr_data = [
|
|
|
|
|
'ghzid'=>$person->ghzid,
|
|
|
|
|
'YYRQ'=>$nmr_item['date'],
|
|
|
|
|
'YYSJ'=>$nmr_item['time'],
|
|
|
|
|
'U_SFID'=>$nmr_item['item_id'],
|
|
|
|
|
'U_SFMC'=>$nmr_item['name'],
|
|
|
|
|
'HBXMJE'=>$nmr_item['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'=>$nmr_item['time'].':00',
|
|
|
|
|
'YYSJ_E'=>$nmr_item['time'].':00',
|
|
|
|
|
'YYSJ_BE'=>$nmr_item['time'].'-'.$nmr_item['time'],
|
|
|
|
|
'ZCRQ'=>$nowDateTime,
|
|
|
|
|
'yyid'=>$yyid,
|
|
|
|
|
'action'=>2,
|
|
|
|
|
];
|
|
|
|
|
//调用接口预约二线
|
|
|
|
|
$erxian_yuyue= $AspNet::ErXian($p_nmr_data, uniqid());
|
|
|
|
|
if(!!$erxian_yuyue){
|
|
|
|
|
$db_nmr_info[$key2]['gid']=$erxian_yuyue;
|
|
|
|
|
$db_nmr_info[$key2]['date']=$nmr_item['date'];
|
|
|
|
|
$db_nmr_info[$key2]['time']=$nmr_item['time'];
|
|
|
|
|
$ex_u= DB::table('orders')->where(['id' => $orderInfo->id])->update([
|
|
|
|
|
'erxian_appointment_info'=>json_encode($db_nmr_info, JSON_UNESCAPED_UNICODE),
|
|
|
|
|
]);
|
|
|
|
|
if(!$ex_u) return ['status' => false, 'msg' => "二线预约失败"];
|
|
|
|
|
}else{
|
|
|
|
|
return ['status' => false, 'msg' => "二线预约失败"];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// var_dump($nmr_info);
|
|
|
|
|
// return false;
|
|
|
|
|
//判断体检日期时间是否和旧的日期时间一样。一样则跳过,不一样则更新
|
|
|
|
|
if (isset($plan_id) && $plan_id <> $orderInfo->plan_id) {
|
|
|
|
|
$peis = new PEISApiController();
|
|
|
|
|
@ -545,6 +644,24 @@ class OrderController extends Controller
|
|
|
|
|
}
|
|
|
|
|
return \Yz::echoError1("未更改内容,无需进行此操作");
|
|
|
|
|
}
|
|
|
|
|
//判断时间跨度
|
|
|
|
|
function checkDatesWithinDays($data,$kuadu) {
|
|
|
|
|
// 提取所有日期
|
|
|
|
|
$dates = array_column($data, 'date');
|
|
|
|
|
|
|
|
|
|
// 将日期转换为时间戳
|
|
|
|
|
$timestamps = array_map('strtotime', $dates);
|
|
|
|
|
|
|
|
|
|
// 找出最早和最晚的时间戳
|
|
|
|
|
$earliest = min($timestamps);
|
|
|
|
|
$latest = max($timestamps);
|
|
|
|
|
|
|
|
|
|
// 计算时间差(以天为单位)
|
|
|
|
|
$differenceInDays = ($latest - $earliest) / (60 * 60 * 24);
|
|
|
|
|
|
|
|
|
|
// 判断时间差是否在3天以内
|
|
|
|
|
return ['check_status'=>$differenceInDays <= $kuadu,'mindate'=> date('Y-m-d H:i:s', $earliest)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function generateOrderNumber()
|
|
|
|
|
{
|
|
|
|
|
@ -719,6 +836,7 @@ class OrderController extends Controller
|
|
|
|
|
return ['status' => true, 'msg' => "完成"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//未支付取消订单
|
|
|
|
|
public function Cancel()
|
|
|
|
|
{
|
|
|
|
|
|