|
|
|
|
@ -297,33 +297,7 @@ class OrderController extends Controller
|
|
|
|
|
if ($plan_check['status'] === false) return \Yz::echoError1($plan_check['msg']);
|
|
|
|
|
$plan = $plan_check['plan'];
|
|
|
|
|
|
|
|
|
|
//判断号源是否可用vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
|
|
|
|
// $plan = DB::table('plans')->where(['id' => $plan_id, 'hospital_id' => $hospital_id, 'status' => 1, 'is_del' => 0])->first();
|
|
|
|
|
// if (!$plan) return \Yz::echoError1("号源不可用");
|
|
|
|
|
// //判断个检/团检类型
|
|
|
|
|
// if ($plan->use_type <> 0 and $plan->use_type <> $type) {
|
|
|
|
|
// $type_temp = '';
|
|
|
|
|
// if ($plan->use_type == 1) $type_temp = '个检';
|
|
|
|
|
// if ($plan->use_type == 2) $type_temp = '团检';
|
|
|
|
|
// return \Yz::echoError1("此号源为" . $type_temp . "号源,不可用");
|
|
|
|
|
// }
|
|
|
|
|
// //判断是否是预留号源
|
|
|
|
|
// if ($plan->type <> 1) return \Yz::echoError1("此号源为预留号源,不可用");
|
|
|
|
|
// //判断是否是vip
|
|
|
|
|
// //判断性别
|
|
|
|
|
// if ($plan->sex <> 0 and $plan->sex <> $person->sex) return \Yz::echoError1("此号源性别与体检人性别不符,不可用");
|
|
|
|
|
// //判断体检类型checkup_type
|
|
|
|
|
// //判断金额
|
|
|
|
|
// if ($plan->use_type == 1 and $plan->amount_limit1 <> 0) {
|
|
|
|
|
// if ($price < $plan->amount_limit1) return \Yz::echoError1("未达到此号源限制的金额,不可用");
|
|
|
|
|
// }
|
|
|
|
|
// if ($plan->use_type == 2 and $plan->amount_limit2 <> 0) {
|
|
|
|
|
// if ($price < $plan->amount_limit2) return \Yz::echoError1("未达到此号源限制的金额,不可用");
|
|
|
|
|
// }
|
|
|
|
|
// //判断时间是否过期
|
|
|
|
|
// $plan_datetime = $plan->date . ' ' . $plan->time;
|
|
|
|
|
// if ($plan_datetime < date('Y-m-d H:i:s')) return \Yz::echoError1("号源已过期,不可用");
|
|
|
|
|
//判断号源是否可用^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果是团检 判断号源在 团检登记人的有效时间范围内
|
|
|
|
|
$plan_datetime = $plan->date . ' ' . $plan->time;
|
|
|
|
|
@ -350,7 +324,7 @@ class OrderController extends Controller
|
|
|
|
|
if ($true_price < -1) return \Yz::echoError1("预抵扣金额超过订单金额,操作失败");
|
|
|
|
|
if ($true_price < 0) $true_price = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//校验二线号源
|
|
|
|
|
if (isset($plan_nmr_info) and !empty($plan_nmr_info)) {
|
|
|
|
|
$plan_nmr_temp = [];
|
|
|
|
|
foreach ($plan_nmr_info as $key => $plan_nmr) {
|
|
|
|
|
@ -391,7 +365,7 @@ class OrderController extends Controller
|
|
|
|
|
'jifen' => $jifen,
|
|
|
|
|
'yucunkuan' => $yucunkuan,
|
|
|
|
|
'order_number' => $order_num,
|
|
|
|
|
'status' => 1,
|
|
|
|
|
'status' => 99, //先标记为异常,方法最底部更新为正常状态
|
|
|
|
|
'appointment_date' => $plan->date,
|
|
|
|
|
'appointment_time' => $plan->time,
|
|
|
|
|
'erxian_appointment_info' => json_encode($plan_nmr_appointment_info, JSON_UNESCAPED_UNICODE),
|
|
|
|
|
@ -425,6 +399,56 @@ class OrderController extends Controller
|
|
|
|
|
$youhuiquan_dikou_status = true;
|
|
|
|
|
|
|
|
|
|
if ($env == 'pro') { //如果是正式环境
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//把状态更新为支付后,然后再开始预约思信
|
|
|
|
|
$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];
|
|
|
|
|
|
|
|
|
|
$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[0]['gid']=$erxian_yuyue;
|
|
|
|
|
$ex_u= DB::table('orders')->where(['id' => $insert])->update([
|
|
|
|
|
'erxian_appointment_info'=>json_encode($plan_nmr_appointment_info, JSON_UNESCAPED_UNICODE),
|
|
|
|
|
]);
|
|
|
|
|
if(!$ex_u) return ['status' => false, 'msg' => "二线预约失败"];
|
|
|
|
|
}else{
|
|
|
|
|
return ['status' => false, 'msg' => "二线预约失败"];
|
|
|
|
|
}
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($jifen > 0) {
|
|
|
|
|
$jifen_dikou_status = false;
|
|
|
|
|
$jifen_dikou_status = $AspNet::UseJiFen($person->ghzid, -$jifen, $yyid, $insert, 'tj_h5', '抵扣体检H5订单', $now_datetime);
|
|
|
|
|
@ -450,7 +474,10 @@ class OrderController extends Controller
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($insert and $up_plan and $jifen_dikou_status and $yucunkuan_dikou_status and $youhuiquan_dikou_status) {
|
|
|
|
|
|
|
|
|
|
//中途未报错,更新订单为待支付
|
|
|
|
|
DB::table('orders')->where('id', $insert)->update([
|
|
|
|
|
'status' => 1 //标记为待支付
|
|
|
|
|
]);
|
|
|
|
|
$action = false;
|
|
|
|
|
if ($true_price == 0) {
|
|
|
|
|
//如果是免费的,直接去预约
|
|
|
|
|
@ -467,7 +494,7 @@ class OrderController extends Controller
|
|
|
|
|
}
|
|
|
|
|
return \Yz::return(true, "操作成功", ['action' => $action, 'orderid' => $insert]);
|
|
|
|
|
} else {
|
|
|
|
|
DB::table('orders')->where('id', $insert)->delete();
|
|
|
|
|
|
|
|
|
|
DB::table('plans')->where(['id' => $plan->id])->update([
|
|
|
|
|
'status' => 1
|
|
|
|
|
]);
|
|
|
|
|
@ -563,21 +590,21 @@ class OrderController extends Controller
|
|
|
|
|
$yyid=2;
|
|
|
|
|
}
|
|
|
|
|
//如果有二线信息校验二线号源是否可用
|
|
|
|
|
$erxian_info=json_decode($order_info->erxian_appointment_info, true);
|
|
|
|
|
if (isset($erxian_info) and !empty($erxian_info)) {
|
|
|
|
|
foreach ($erxian_info as $key => $plan_nmr) {
|
|
|
|
|
$p_nmr_data = [
|
|
|
|
|
'item_id' => $plan_nmr['item_id'],
|
|
|
|
|
'name' => $plan_nmr['name'],
|
|
|
|
|
'date' => $plan_nmr['date'],
|
|
|
|
|
'time' => $plan_nmr['time'],
|
|
|
|
|
];
|
|
|
|
|
//调用接口校验号源是否可用
|
|
|
|
|
$erxian_status = $AspNet::ErXian(['YYRQ' => $p_nmr_data['date'], 'YYSJ' => $p_nmr_data['time'], 'yyid' => $yyid, 'action' => 4], uniqid());
|
|
|
|
|
if ($erxian_status !== true) return ['status' => false, 'msg' => $p_nmr_data['name'] . '号源不可用'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// $erxian_info=json_decode($order_info->erxian_appointment_info, true);
|
|
|
|
|
// if (isset($erxian_info) and !empty($erxian_info)) {
|
|
|
|
|
// foreach ($erxian_info as $key => $plan_nmr) {
|
|
|
|
|
// $p_nmr_data = [
|
|
|
|
|
// 'item_id' => $plan_nmr['item_id'],
|
|
|
|
|
// 'name' => $plan_nmr['name'],
|
|
|
|
|
// 'date' => $plan_nmr['date'],
|
|
|
|
|
// 'time' => $plan_nmr['time'],
|
|
|
|
|
// ];
|
|
|
|
|
// //调用接口校验号源是否可用
|
|
|
|
|
// $erxian_status = $AspNet::ErXian(['YYRQ' => $p_nmr_data['date'], 'YYSJ' => $p_nmr_data['time'], 'yyid' => $yyid, 'action' => 4], uniqid());
|
|
|
|
|
// if ($erxian_status !== true) return ['status' => false, 'msg' => $p_nmr_data['name'] . '号源不可用'];
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
$buy_info = json_decode($order_info->buy_info, true);
|
|
|
|
|
$combo_id = $buy_info['combo']['id'];
|
|
|
|
|
@ -655,50 +682,7 @@ class OrderController extends Controller
|
|
|
|
|
//查询确认订单已经是支付状态
|
|
|
|
|
$cha = DB::table('orders')->where(['order_number' => $order_number, 'status' => 2])->first();
|
|
|
|
|
if (!$cha) return ['status' => false, 'msg' => "订单未支付,禁止预约"];
|
|
|
|
|
//把状态更新为支付后,先二线,然后再开始预约思信
|
|
|
|
|
$nowDateTime=date('Y-m-d H:i:s');
|
|
|
|
|
if (isset($erxian_info) and !empty($erxian_info)) {
|
|
|
|
|
// foreach ($erxian_info as $key => $plan_nmr) {
|
|
|
|
|
$plan_nmr=$erxian_info[0];
|
|
|
|
|
|
|
|
|
|
$sex="未知";
|
|
|
|
|
if($order_info->sex==1) $sex='男';
|
|
|
|
|
if($order_info->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'=>$order_info->phone,
|
|
|
|
|
'YYXM'=>$order_info->name,
|
|
|
|
|
'YYXB'=>$sex,
|
|
|
|
|
'YYSR'=>$order_info->birthday,
|
|
|
|
|
'YYNL'=>Tools::GetAge($order_info->birthday).'岁' ,
|
|
|
|
|
'YYZJ'=>$order_info->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){
|
|
|
|
|
$erxian_info[0]['gid']=$erxian_yuyue;
|
|
|
|
|
$ex_u= DB::table('orders')->where(['id' => $order_info->id])->update([
|
|
|
|
|
'erxian_appointment_info'=>json_encode($erxian_info, JSON_UNESCAPED_UNICODE),
|
|
|
|
|
]);
|
|
|
|
|
if(!$ex_u) return ['status' => false, 'msg' => "二线预约失败"];
|
|
|
|
|
}else{
|
|
|
|
|
return ['status' => false, 'msg' => "二线预约失败"];
|
|
|
|
|
}
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$create_appointment = self::create_appointment($order_info->hospital_id, $cad);
|
|
|
|
|
|
|
|
|
|
|