|
@@ -65,12 +65,13 @@ class Application extends Base
|
|
|
$info['exam_subclass_name'] = $exam_subclass['name'];
|
|
|
$info['exam_project_name'] = $exam_project['name'];
|
|
|
$info['device_name'] = $device['name'];
|
|
|
- $patient_info = DB::table('patient_infos')->where('id',$info['patient_id'])->field(['temp_patient_id','id','name','sex','age','birthday'])->find();
|
|
|
+ $patient_info = DB::table('patient_infos')->where('id',$info['patient_id'])->field(['temp_patient_id','id','name','sex','age','birthday', 'phone'])->find();
|
|
|
$info['pid'] = $patient_info['id'];
|
|
|
$info['temp_patient_id'] = $patient_info['temp_patient_id'];
|
|
|
$info['name'] = $patient_info['name'];
|
|
|
$info['sex'] = $patient_info['sex'];
|
|
|
$info['age'] = $patient_info['age'];
|
|
|
+ $info['phone'] = $patient_info['phone'];
|
|
|
if(!empty($patient_info['birthday'])){
|
|
|
$info['birthday'] = $patient_info['birthday'];
|
|
|
}
|
|
@@ -303,7 +304,7 @@ class Application extends Base
|
|
|
}
|
|
|
$exam_info = DB::table('exams')->where('id',$param['id'])->field('exam_class,exam_status,patient_id')->find();
|
|
|
// 修改病人姓名
|
|
|
- DB::table('patient_infos')->where('id',$exam_info['patient_id'])->update(['name'=>$param['name']]);
|
|
|
+ DB::table('patient_infos')->where('id',$exam_info['patient_id'])->update(['name'=>$param['name'], 'phone'=> $param['phone']]??'');
|
|
|
if($exam_info['exam_status'] != 3 && $exam_info['exam_status'] != 5 && $exam_info['exam_status'] != 8){
|
|
|
// 3 检查完毕 5已驳回
|
|
|
switch($exam_info['exam_status']){
|
|
@@ -363,6 +364,7 @@ class Application extends Base
|
|
|
}
|
|
|
$application_info['application_desc'] = isset($param['description']) ? $param['description'] : '';
|
|
|
$application_info['req_doctor_id'] = $doctor['id'];
|
|
|
+ $application_info['phone'] = $param['phone']?? '';
|
|
|
$application_info['remote_doctor_id'] = $remote_doctor_id;
|
|
|
$application_info['attachment'] = isset($param['attachment']) ? $param['attachment'] : '';
|
|
|
// $remote_application = DB::table('remote_application')->where('exam_id',$param['id'])->select();
|
|
@@ -445,11 +447,11 @@ class Application extends Base
|
|
|
return json_encode(['status'=>'ok','code'=>'2017','msg'=> '远程机构获取失败']);
|
|
|
}
|
|
|
$res = false;
|
|
|
- if($contact['pay_type'] === 0) { //医院挂账
|
|
|
+ if($contact['pay_type'] === self::PAY_TYPE['HOSPITAL']) { //医院挂账
|
|
|
// $hospital_id, $super_hospital_id, $doctor_id, $super_doctor_id, $exam_class, $application_id, $order_money
|
|
|
$res = $this->createHospitalOrder($local_institution_id, $remote_institution_id, $req_doctor_id, $remote_doctor_id, $exam_info['exam_class'], $application['id'], $cost['money'], $is_urgent, $wechatService);
|
|
|
}
|
|
|
- if($contact['pay_type'] === 1) { // 患者支付
|
|
|
+ if($contact['pay_type'] === self::PAY_TYPE['PATIENT']) { // 患者支付
|
|
|
// var_dump(2);
|
|
|
// var_dump($wechatService);
|
|
|
// $push_res = WechatService::pushWechatOrder($param['id']);
|
|
@@ -526,7 +528,7 @@ class Application extends Base
|
|
|
DB::commit();
|
|
|
// return true;
|
|
|
// DB::rollback();
|
|
|
- return json_encode(['status'=>'fail','code'=>'2019','已存在订单,请勿重复发起']);
|
|
|
+ return json_encode(['status'=>'fail','code'=>'2019','msg' => '已存在订单,请勿重复发起']);
|
|
|
}
|
|
|
$hospital = DB::table('institution')
|
|
|
->where('id', $hospital_id)
|
|
@@ -534,13 +536,13 @@ class Application extends Base
|
|
|
->find();
|
|
|
if(!$hospital) {
|
|
|
DB::rollback();
|
|
|
- return json_encode(['status'=>'fail','code'=>'2017','查找本地医院失败']);
|
|
|
+ return json_encode(['status'=>'fail','code'=>'2017','msg' => '查找本地医院失败']);
|
|
|
}
|
|
|
$min_money = $hospital['min_money'];
|
|
|
$current_money = $hospital['current_money'];
|
|
|
if($current_money - $order_money < $min_money) {
|
|
|
DB::rollback();
|
|
|
- return json_encode(['status'=>'fail','code'=>'2017','余额不足请联系医院管理员充值']);
|
|
|
+ return json_encode(['status'=>'fail','code'=>'2017','msg' => '余额不足请联系医院管理员充值']);
|
|
|
}
|
|
|
DB::table('institution')->where('id',$hospital_id)->update(['current_money'=> $current_money - $order_money]);
|
|
|
$order_id = UUIDs::uuid16();
|
|
@@ -575,7 +577,7 @@ class Application extends Base
|
|
|
// 回滚事务
|
|
|
DB::rollback();
|
|
|
}
|
|
|
- return json_encode(['status'=>'fail','code'=>'2018','远程诊断发起失败']);
|
|
|
+ return json_encode(['status'=>'fail','code'=>'2018','msg' => '远程诊断发起失败']);
|
|
|
}
|
|
|
private function createPatientsOrder($hospital_id, $super_hospital_id, $doctor_id, $super_doctor_id, $exam_class, $application_id, $order_money, $is_urgent = 0, $wechatService) {
|
|
|
$pay_type = self::PAY_TYPE['PATIENT'];
|
|
@@ -593,7 +595,7 @@ class Application extends Base
|
|
|
DB::commit();
|
|
|
// return json_encode(['status'=>'ok','code'=>'0000','oid'=>$remote_order['id'],'aid'=>$application_id]);
|
|
|
// DB::rollback();
|
|
|
- return json_encode(['status'=>'fail','code'=>'2019','已存在订单,请勿重复发起']);
|
|
|
+ return json_encode(['status'=>'fail','code'=>'2019','msg' => '已存在订单,请勿重复发起']);
|
|
|
}
|
|
|
$order_id = UUIDs::uuid16();
|
|
|
DB::table('remote_order')->insert([
|
|
@@ -618,7 +620,7 @@ class Application extends Base
|
|
|
var_dump($e);
|
|
|
DB::rollback();
|
|
|
}
|
|
|
- return json_encode(['status'=>'fail','code'=>'2020','远程诊断发起失败']);
|
|
|
+ return json_encode(['status'=>'fail','code'=>'2020','msg' => '远程诊断发起失败']);
|
|
|
}
|
|
|
|
|
|
private function cancelHospitalOrder($order_id, $hospital_id, $order_money) {
|
|
@@ -650,7 +652,7 @@ class Application extends Base
|
|
|
// 回滚事务
|
|
|
DB::rollback();
|
|
|
}
|
|
|
- return json_encode(['status'=>'fail','code'=>'2018','取消订单失败']);
|
|
|
+ return json_encode(['status'=>'fail','code'=>'2018','msg' => '取消订单失败']);
|
|
|
}
|
|
|
private function cancelPatientsOrder($order_id) {
|
|
|
try{
|
|
@@ -660,7 +662,7 @@ class Application extends Base
|
|
|
} catch (\Exception $e) {
|
|
|
var_dump($e);
|
|
|
}
|
|
|
- return json_encode(['status'=>'fail','code'=>'2109','订单取消失败']);
|
|
|
+ return json_encode(['status'=>'fail','code'=>'2109','msg' => '订单取消失败']);
|
|
|
}
|
|
|
|
|
|
/**订单状态 创建 支付完成 订单完成 取消 */
|
|
@@ -694,10 +696,10 @@ class Application extends Base
|
|
|
"BANK" => 13
|
|
|
];
|
|
|
|
|
|
- /**支付类型 医院 微信 */
|
|
|
+ /**支付类型 微信 医院 */
|
|
|
public const PAY_TYPE = [
|
|
|
- "HOSPITAL" => 0,
|
|
|
- "PATIENT" => 1
|
|
|
+ "PATIENT" => 0,
|
|
|
+ "HOSPITAL" => 1
|
|
|
];
|
|
|
|
|
|
/**
|