|
@@ -201,7 +201,7 @@ class Application extends Base
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/**取消订单 */
|
|
/**取消订单 */
|
|
- public function cancel(){
|
|
|
|
|
|
+ public function cancel(WechatService $wechatService){
|
|
try{
|
|
try{
|
|
log::record($_REQUEST);
|
|
log::record($_REQUEST);
|
|
$sessionid = $_REQUEST['sessionid'];
|
|
$sessionid = $_REQUEST['sessionid'];
|
|
@@ -220,13 +220,16 @@ class Application extends Base
|
|
if(!($remote_order['status'] === self::ORDER_STATUS['CREATE'] || $remote_order['status'] === self::ORDER_STATUS['PAYCOMPLTET'])) {
|
|
if(!($remote_order['status'] === self::ORDER_STATUS['CREATE'] || $remote_order['status'] === self::ORDER_STATUS['PAYCOMPLTET'])) {
|
|
return json_encode(['status'=>'fail','code'=>'2102','msg'=> '订单状态不可取消']);
|
|
return json_encode(['status'=>'fail','code'=>'2102','msg'=> '订单状态不可取消']);
|
|
}
|
|
}
|
|
- $application = DB::table('remote_application')->where('id', $remote_order['application_id'])->field('report_status')->find();
|
|
|
|
|
|
+ $application = DB::table('remote_application')->where('id', $remote_order['application_id'])->field('report_status, exam_id')->find();
|
|
if(!$application) {
|
|
if(!$application) {
|
|
return json_encode(['status'=>'fail','code'=>'2103','msg'=> '没有找到远程诊断申请单']);
|
|
return json_encode(['status'=>'fail','code'=>'2103','msg'=> '没有找到远程诊断申请单']);
|
|
}
|
|
}
|
|
if(!($application['report_status'] === '5' || $application['report_status'] === '12')) {
|
|
if(!($application['report_status'] === '5' || $application['report_status'] === '12')) {
|
|
return json_encode(['status'=>'fail','code'=>'2103','msg'=> '进行中的远程诊断订单不可取消']);
|
|
return json_encode(['status'=>'fail','code'=>'2103','msg'=> '进行中的远程诊断订单不可取消']);
|
|
}
|
|
}
|
|
|
|
+ // 微信消息推送
|
|
|
|
+ // $wechatService->pushWechatCancel($application['exam_id']);
|
|
|
|
+ $wechatService->pushWechatCancel($order_id);
|
|
if($remote_order['pay_type'] === self::PAY_TYPE['HOSPITAL']) {
|
|
if($remote_order['pay_type'] === self::PAY_TYPE['HOSPITAL']) {
|
|
return $this->cancelHospitalOrder($order_id, $remote_order['hospital_id'], $remote_order['order_money']);
|
|
return $this->cancelHospitalOrder($order_id, $remote_order['hospital_id'], $remote_order['order_money']);
|
|
}
|
|
}
|
|
@@ -353,7 +356,7 @@ class Application extends Base
|
|
$d_time = date('H:i',strtotime('+1 hour'));
|
|
$d_time = date('H:i',strtotime('+1 hour'));
|
|
}
|
|
}
|
|
if($remote_doctor_id === '') {
|
|
if($remote_doctor_id === '') {
|
|
- $manager = DB::table('')->where('institution_id',$application_info['remote_institution_id'])->where('is_admin', '1')->field('id')->find();
|
|
|
|
|
|
+ $manager = DB::table('doctors')->where('institution_id',$application_info['remote_institution_id'])->where('is_admin', '1')->field('id')->find();
|
|
if(!empty($manager)) {
|
|
if(!empty($manager)) {
|
|
$remote_doctor_id = $manager['id'];
|
|
$remote_doctor_id = $manager['id'];
|
|
}
|
|
}
|
|
@@ -441,21 +444,23 @@ class Application extends Base
|
|
if(!$contact) {
|
|
if(!$contact) {
|
|
return json_encode(['status'=>'ok','code'=>'2017','msg'=> '远程机构获取失败']);
|
|
return json_encode(['status'=>'ok','code'=>'2017','msg'=> '远程机构获取失败']);
|
|
}
|
|
}
|
|
|
|
+ $res = false;
|
|
if($contact['pay_type'] === 0) { //医院挂账
|
|
if($contact['pay_type'] === 0) { //医院挂账
|
|
// $hospital_id, $super_hospital_id, $doctor_id, $super_doctor_id, $exam_class, $application_id, $order_money
|
|
// $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);
|
|
|
|
- if($res !== true) {
|
|
|
|
- return $res;
|
|
|
|
- }
|
|
|
|
|
|
+ $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'] === 1) { // 患者支付
|
|
// var_dump(2);
|
|
// var_dump(2);
|
|
// var_dump($wechatService);
|
|
// var_dump($wechatService);
|
|
// $push_res = WechatService::pushWechatOrder($param['id']);
|
|
// $push_res = WechatService::pushWechatOrder($param['id']);
|
|
- $wechatService->pushWechatOrder($param['id']);
|
|
|
|
- $res = $this->createPatientsOrder($local_institution_id, $remote_institution_id, $req_doctor_id, $remote_doctor_id, $exam_info['exam_class'], $application['id'], $cost['money'], $is_urgent);
|
|
|
|
|
|
+ // $wechatService->pushWechatOrder($param['id']);
|
|
|
|
+ $res = $this->createPatientsOrder($local_institution_id, $remote_institution_id, $req_doctor_id, $remote_doctor_id, $exam_info['exam_class'], $application['id'], $cost['money'], $is_urgent, $wechatService);
|
|
return json_encode(['status'=>'ok','code'=>'0000']);
|
|
return json_encode(['status'=>'ok','code'=>'0000']);
|
|
}
|
|
}
|
|
|
|
+ if($res === true) {
|
|
|
|
+ return ['status'=>'ok','code'=>'0000'];
|
|
|
|
+ }
|
|
|
|
+ return $res;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
DB::table('remote_order')->insert([
|
|
DB::table('remote_order')->insert([
|
|
@@ -477,7 +482,7 @@ class Application extends Base
|
|
}
|
|
}
|
|
// 添加messages信息
|
|
// 添加messages信息
|
|
|
|
|
|
- $wechatService->pushWechatOrder($param['id']);
|
|
|
|
|
|
+ // $wechatService->pushWechatOrder($param['id']);
|
|
$t = '收到一条远程诊断申请';
|
|
$t = '收到一条远程诊断申请';
|
|
$ins = DB::table('institution')->where('id',$doctor['institution_id'])->field('name')->find();
|
|
$ins = DB::table('institution')->where('id',$doctor['institution_id'])->field('name')->find();
|
|
$c = $ins['name'].$doctor['realname'].'医师向您发起一条远程诊断申请';
|
|
$c = $ins['name'].$doctor['realname'].'医师向您发起一条远程诊断申请';
|
|
@@ -496,7 +501,6 @@ class Application extends Base
|
|
// $type = '发起申请';
|
|
// $type = '发起申请';
|
|
// $content = $aid;
|
|
// $content = $aid;
|
|
// $response = send_message::sendSms2Self($tel,$type,$content);
|
|
// $response = send_message::sendSms2Self($tel,$type,$content);
|
|
-
|
|
|
|
}
|
|
}
|
|
return json_encode(['status'=>'ok','code'=>'0000','sessionid'=>$sessionid,'aid'=>$aid]);
|
|
return json_encode(['status'=>'ok','code'=>'0000','sessionid'=>$sessionid,'aid'=>$aid]);
|
|
}catch(\Exception $e){
|
|
}catch(\Exception $e){
|
|
@@ -504,7 +508,7 @@ class Application extends Base
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private function createHospitalOrder($hospital_id, $super_hospital_id, $doctor_id, $super_doctor_id, $exam_class, $application_id, $order_money, $is_urgent = 0) {
|
|
|
|
|
|
+ private function createHospitalOrder($hospital_id, $super_hospital_id, $doctor_id, $super_doctor_id, $exam_class, $application_id, $order_money, $is_urgent = 0, $wechatService) {
|
|
DB::startTrans();
|
|
DB::startTrans();
|
|
$pay_type = self::PAY_TYPE['HOSPITAL'];
|
|
$pay_type = self::PAY_TYPE['HOSPITAL'];
|
|
$pay_way = self::PAY_TYPE['HOSPITAL'];
|
|
$pay_way = self::PAY_TYPE['HOSPITAL'];
|
|
@@ -565,6 +569,7 @@ class Application extends Base
|
|
]);
|
|
]);
|
|
// 提交事务
|
|
// 提交事务
|
|
DB::commit();
|
|
DB::commit();
|
|
|
|
+ $wechatService->pushWechatOrder($order_id);
|
|
return true;
|
|
return true;
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
// 回滚事务
|
|
// 回滚事务
|
|
@@ -572,7 +577,7 @@ class Application extends Base
|
|
}
|
|
}
|
|
return json_encode(['status'=>'fail','code'=>'2018','远程诊断发起失败']);
|
|
return json_encode(['status'=>'fail','code'=>'2018','远程诊断发起失败']);
|
|
}
|
|
}
|
|
- private function createPatientsOrder($hospital_id, $super_hospital_id, $doctor_id, $super_doctor_id, $exam_class, $application_id, $order_money, $is_urgent = 0) {
|
|
|
|
|
|
+ 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'];
|
|
$pay_type = self::PAY_TYPE['PATIENT'];
|
|
$pay_way = self::PAY_WAY['WECHAT'];
|
|
$pay_way = self::PAY_WAY['WECHAT'];
|
|
DB::startTrans();
|
|
DB::startTrans();
|
|
@@ -607,7 +612,8 @@ class Application extends Base
|
|
'status' => self::ORDER_STATUS['CREATE']
|
|
'status' => self::ORDER_STATUS['CREATE']
|
|
]);
|
|
]);
|
|
DB::commit();
|
|
DB::commit();
|
|
- return json_encode(['status'=>'ok','code'=>'0000','oid'=>$order_id,'aid'=>$application_id]);
|
|
|
|
|
|
+ $wechatService->pushWechatOrder($order_id);
|
|
|
|
+ return true;
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
var_dump($e);
|
|
var_dump($e);
|
|
DB::rollback();
|
|
DB::rollback();
|