|
@@ -339,7 +339,7 @@ class Application extends Base
|
|
|
}
|
|
|
*")
|
|
|
**/
|
|
|
- public function apply(WechatService $wechatService){
|
|
|
+ public function apply(){
|
|
|
try{
|
|
|
// var_dump(1);
|
|
|
// var_dump($wechatService);
|
|
@@ -464,96 +464,8 @@ class Application extends Base
|
|
|
// }
|
|
|
|
|
|
if(isset($param['apply']) && !empty($param['apply'])){
|
|
|
- $institution_id = $doctor['institution_id'];
|
|
|
- $lower_hospital = DB::table('institution')->where('id', $institution_id)->field('is_pay')->find();
|
|
|
- $is_pay = $lower_hospital['is_pay'];
|
|
|
- $application = DB::table('remote_application')->where('exam_id', $param['id'])->field('id, sid, scid, remote_institution_id, remote_doctor_id, local_institution_id, req_doctor_id, is_urgent')->find();
|
|
|
- if(empty($application)) {
|
|
|
- return json_encode(['status'=>'fail','code'=>'2011','msg'=> '申请单创建失败']);
|
|
|
- }
|
|
|
- $remote_institution_id = $application['remote_institution_id'];
|
|
|
- $remote_doctor_id = $application['remote_doctor_id'];
|
|
|
- $is_urgent = $application['is_urgent'];
|
|
|
- $local_institution_id = $application['local_institution_id'];
|
|
|
- $req_doctor_id = $application['req_doctor_id'];
|
|
|
- $sid = $application['sid'];
|
|
|
- $scid = $application['scid'];
|
|
|
- if(empty($remote_institution_id)) {
|
|
|
- return json_encode(['status'=>'fail','code'=>'2012','msg'=> '远程机构id为空']);
|
|
|
- }
|
|
|
- // if(empty($remote_doctor_id)) {
|
|
|
- // return json_encode(['status'=>'fail','code'=>'2013','msg'=> '远程医生id为空']);
|
|
|
- // }
|
|
|
- if(empty($local_institution_id)) {
|
|
|
- return json_encode(['status'=>'fail','code'=>'2014','msg'=> '本地机构id为空']);
|
|
|
- }
|
|
|
- if(empty($req_doctor_id)) {
|
|
|
- return json_encode(['status'=>'fail','code'=>'2015','msg'=> '本地医生id为空']);
|
|
|
- }
|
|
|
-
|
|
|
- if(!empty($sid) && empty($scid)) {
|
|
|
- return json_encode(['status'=>'fail','code'=>'2016','msg'=> '请选择问诊医生']);
|
|
|
- }
|
|
|
-
|
|
|
- if($is_pay === 1 && empty($sid)) {
|
|
|
- $cost = DB::table('remote_cost')
|
|
|
- ->where('hospital_id', $local_institution_id)
|
|
|
- ->where('super_hospital_id', $remote_institution_id)
|
|
|
- ->where('super_doctor_id', $remote_doctor_id)
|
|
|
- ->where('exam_class', $exam_info['exam_class'])
|
|
|
- ->field('money')
|
|
|
- ->find();
|
|
|
- if(!$cost) {
|
|
|
- return json_encode(['status'=>'ok','code'=>'2016','msg'=> '远程医生获取失败']);
|
|
|
- }
|
|
|
- if($cost['money'] !== 0) {
|
|
|
- $contact = DB::table('remote_contact')
|
|
|
- ->where('hospital_id', $local_institution_id)
|
|
|
- ->where('super_hospital_id', $remote_institution_id)
|
|
|
- ->field('pay_type')
|
|
|
- ->find();
|
|
|
- if(!$contact) {
|
|
|
- return json_encode(['status'=>'ok','code'=>'2017','msg'=> '远程机构获取失败']);
|
|
|
- }
|
|
|
- $res = false;
|
|
|
- if($contact['pay_type'] === Config::get('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'] === Config::get('PAY_TYPE')['PATIENT']) { // 患者支付
|
|
|
- // var_dump(2);
|
|
|
- // var_dump($wechatService);
|
|
|
- // $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);
|
|
|
- return json_encode(['status'=>'ok','code'=>'0000']);
|
|
|
- }
|
|
|
- if($res === true) {
|
|
|
- return ['status'=>'ok','code'=>'0000'];
|
|
|
- }
|
|
|
- return $res;
|
|
|
- }
|
|
|
- } else {
|
|
|
- DB::table('remote_order')->insert([
|
|
|
- 'id' => UUIDs::uuid16(),
|
|
|
- 'hospital_id' => $local_institution_id,
|
|
|
- 'super_hospital_id' => $remote_institution_id,
|
|
|
- 'exam_class' => $exam_info['exam_class'],
|
|
|
- 'doctor_id' => $req_doctor_id,
|
|
|
- 'application_id' => $application['id'],
|
|
|
- 'super_doctor_id' => $remote_doctor_id,
|
|
|
- 'is_urgent' => $is_urgent,
|
|
|
- 'status' => Config::get('ORDER_STATUS')['PAYCOMPLTET'],
|
|
|
- 'order_money' => 0,
|
|
|
- 'pay_type' => Config::get('PAY_TYPE')['HOSPITAL'],
|
|
|
- 'pay_way' => Config::get('PAY_WAY')['HOSPITAL'],
|
|
|
- 'timestamp' => time()
|
|
|
- ]);
|
|
|
- DB::table('remote_application')->where('exam_id',$param['id'])->update(['report_status'=>4]);
|
|
|
- }
|
|
|
+ DB::table('remote_application')->where('exam_id',$param['id'])->update(['report_status'=>4]);
|
|
|
// 添加messages信息
|
|
|
-
|
|
|
- // $wechatService->pushWechatOrder($param['id']);
|
|
|
$t = '收到一条远程诊断申请';
|
|
|
$ins = DB::table('institution')->where('id',$doctor['institution_id'])->field('name')->find();
|
|
|
$c = $ins['name'].$doctor['realname'].'医师向您发起一条远程诊断申请';
|
|
@@ -562,9 +474,9 @@ class Application extends Base
|
|
|
$url = Message::url($sessionid,$param['id'],1,$exam_info['exam_class'],$r_id,$aid);
|
|
|
Message::insert($t,$c,$d,$type,$url,1,$aid);
|
|
|
//保存 申请
|
|
|
-
|
|
|
// 发送通知短信
|
|
|
- $this->sendApplySms($d_time, $application_info['remote_doctor_id'], $application_info['remote_institution_id']);
|
|
|
+
|
|
|
+ // $this->sendApplySms($d_time, $application_info['remote_doctor_id'], $application_info['remote_institution_id']);
|
|
|
|
|
|
// $dinfo = DB::table('doctors')->where('id',$application_info['remote_doctor_id'])->find();
|
|
|
// $d_phone = $dinfo['phone'];
|