瀏覽代碼

Merge branch 'pro' of http://code.pacsonline.cn/zskk_bg/yuanchengpasc into pro

刘桂岩 5 年之前
父節點
當前提交
352e439e9e

+ 20 - 14
application/inter/controller/Application.php

@@ -201,7 +201,7 @@ class Application extends Base
         }
     }
     /**取消订单 */
-    public function cancel(){
+    public function cancel(WechatService $wechatService){
         try{
             log::record($_REQUEST);
             $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'])) {
                 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) {
                 return json_encode(['status'=>'fail','code'=>'2103','msg'=> '没有找到远程诊断申请单']);
             }
             if(!($application['report_status'] === '5' || $application['report_status'] === '12')) {
                 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']) {
                 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'));
             }
             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)) {
                     $remote_doctor_id = $manager['id'];
                 }
@@ -441,21 +444,23 @@ class Application extends Base
                         if(!$contact) {
                             return json_encode(['status'=>'ok','code'=>'2017','msg'=> '远程机构获取失败']);
                         }
+                        $res = false;
                         if($contact['pay_type'] === 0) { //医院挂账
                             // $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) { // 患者支付
                             // 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->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([
@@ -477,7 +482,7 @@ class Application extends Base
                 }
                 // 添加messages信息
 
-                $wechatService->pushWechatOrder($param['id']);
+                // $wechatService->pushWechatOrder($param['id']);
                 $t = '收到一条远程诊断申请';
                 $ins = DB::table('institution')->where('id',$doctor['institution_id'])->field('name')->find();
                 $c = $ins['name'].$doctor['realname'].'医师向您发起一条远程诊断申请';
@@ -496,7 +501,6 @@ class Application extends Base
                     // $type = '发起申请';
                     // $content  = $aid;
     //                $response = send_message::sendSms2Self($tel,$type,$content);
-                
             }
             return json_encode(['status'=>'ok','code'=>'0000','sessionid'=>$sessionid,'aid'=>$aid]);
         }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();
         $pay_type = self::PAY_TYPE['HOSPITAL'];
         $pay_way = self::PAY_TYPE['HOSPITAL'];
@@ -565,6 +569,7 @@ class Application extends Base
             ]);
             // 提交事务
             DB::commit();
+            $wechatService->pushWechatOrder($order_id);
             return true;
         } catch (\Exception $e) {
             // 回滚事务
@@ -572,7 +577,7 @@ class Application extends Base
         }
         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_way = self::PAY_WAY['WECHAT'];
         DB::startTrans();
@@ -607,7 +612,8 @@ class Application extends Base
                 'status' => self::ORDER_STATUS['CREATE']
             ]);
             DB::commit();
-            return json_encode(['status'=>'ok','code'=>'0000','oid'=>$order_id,'aid'=>$application_id]);
+            $wechatService->pushWechatOrder($order_id);
+            return true;
         } catch (\Exception $e) {
             var_dump($e);
             DB::rollback();

+ 19 - 19
application/inter/controller/Dcquery.php

@@ -13,6 +13,7 @@ use think\Controller;
 use think\Request;
 use think\Db;
 use think\Cache;
+use think\exception\HttpResponseException;
 
 class Dcquery extends Controller
 {
@@ -117,16 +118,9 @@ class Dcquery extends Controller
      **/
     public function get_studiesinfo(){
         try{
-            $study_id = $_REQUEST['study_id'];
-            if($study_id == '71e721a36ceb4bf4' || $study_id== '2c7b65989e965c2a'){
-                if(Cache::get($study_id)){
-                    return Cache::get($study_id);
-                }
-            }
-            if($study_id == '17a34f052869eefd' || $study_id == '35684ea1e75ae4d0' || $study_id == 'ef80a21d3a2db803'){
-                if(Cache::get($study_id)){
-                    return Cache::get($study_id);
-                }
+            $study_id = $_REQUEST['study_id']?? false;
+            if($study_id && Cache::get($study_id)){
+                return Cache::get($study_id);
             }
             if(isset($_REQUEST['address']) && !empty($_REQUEST['address'])){
                 $url = $_REQUEST['address'];
@@ -134,11 +128,22 @@ class Dcquery extends Controller
                 $url = '';
             }
             $info = array();
-            if(strlen($study_id) == '16'){
+            $study_uid = $_REQUEST['study_uid']?? false;
+            $acc_num = $_REQUEST['acc_num']?? false;
+            if($study_id && strlen($study_id) == '16') {
                 $study_info = DB::table('studies')->where('id',$study_id)->field('id,studyuid,studyid,patient_id')->find();
-            }else{
-                $study_info = DB::table('studies')->where('studyuid',$study_id)->field('id,studyuid,studyid,patient_id')->find();
+            } else if($study_uid) {
+                $study_info = DB::table('studies')->where('studyuid', $study_uid)->field('id,studyuid,studyid,patient_id')->find();
+            } else if($acc_num) {
+                $study_info = DB::table('studies')->where('accession_num', $acc_num)->field('id,studyuid,studyid,patient_id')->find();
+            } else {
+                throw HttpResponseException('没有查找到对应检查');
             }
+            // if(strlen($study_id) == '16'){
+            //     $study_info = DB::table('studies')->where('id',$study_id)->field('id,studyuid,studyid,patient_id')->find();
+            // }else{
+            //     $study_info = DB::table('studies')->where('studyuid',$study_id)->field('id,studyuid,studyid,patient_id')->find();
+            // }
             $info['studyInstanceUid'] = $study_info['studyuid'];
             $patient_info = DB::table('patient_infos')->where('id',$study_info['patient_id'])->field('birthday,institution_id,temp_patient_id,name,age,sex')->find();
             $date = DB::table('exams')->where('patient_id',$study_info['patient_id'])->field('exam_datetime')->find();
@@ -212,12 +217,7 @@ class Dcquery extends Controller
             $info['patientId'] = $patient_info['temp_patient_id'];
             $info['institution'] = $institution['name'];
             $return['studies'][] = $info;
-            if($study_id == '71e721a36ceb4bf4' || $study_id== '2c7b65989e965c2a'){
-                Cache::set($study_id,json_encode($return),604800);
-            }
-            if($study_id == '17a34f052869eefd' || $study_id == '35684ea1e75ae4d0' || $study_id == 'ef80a21d3a2db803'){
-                Cache::set($study_id,json_encode($return));
-            }
+            Cache::set($study_id,json_encode($return), 1800);
             return json_encode($return);
         }catch(Exception $e){
             echo $e->getMessage();

+ 68 - 67
application/inter/controller/Wechat.php

@@ -1,22 +1,17 @@
 <?php
 namespace app\inter\controller;
 
-use think\Controller;
 use think\Db;
-use think\Session;
-use app\common\library\UUIDs;
-use think\Cache;
 use think\Log;
-use app\common\library\Verify;
-use think\File;
 use app\common\library\send_message;
 use app\common\library\Message;
-class Wechat extends Base {
-    public function _initialize() {
-    }
+use app\inter\service\WechatService;
 
-    public function wechatRefund() {
-        $repsone = '<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>';
+class Wechat extends Base {
+    private const SUCCESS = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
+    
+    public function _initialize() {}
+    public function wechatRefund(WechatService $wechatService) {
         $api_key = '9759a66938e8411ad5889e2b5b394d94';
         Log::record('-----微信退款----开始----');
         Log::record('-----微信退款----xml----');
@@ -36,74 +31,80 @@ class Wechat extends Base {
         DB::table('wechat_refund_log')->insert( array_merge($refund, $data));
 
         $order_id = $refund['out_trade_no'];
-        $order = DB::table('remote_order')->where('id', $order_id)->field('status, ')-find();
+        $order = DB::table('remote_order')->where('id', $order_id)->field('status')-find();
         if(!empty($order) && $order['status'] === Application::ORDER_STATUS['CANCEL']) {
             DB::table('remote_order')->where('id', $order_id)->update(['status' => Application::ORDER_STATUS['REDUCE']]);
+            // $wechatService->pushWechatRefund($remote_application['exam_id']);
+            $wechatService->pushWechatRefund($order_id);
             // todo 微信消息推送
         }
         Log::record('-----微信结束----xml----');
-        return $repsone;
+        return self::SUCCESS;
 
     }
 
     public function  wechatCallback() {
-        // $param = $_REQUEST['param'];
-        $repsone = '<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>';
-        Log::record('-----微信支付回调----开始----');
-
-        Log::record('-----微信支付返回----xml----');
-        $xml = file_get_contents("php://input");
-        Log::record($xml);
-        Log::record('-----xml转数组--------');
-        $data = (array)simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA); //将微信返回的XML 转换成数组
-        Log::record($data);
-        $out_trade_no = $data['out_trade_no'];
-        $data['timestamp'] = time();
-        Log::record('-----添加流水记录----');
-        Log::record($data);
-        Db::table("wechat_pay_log")->insert($data);
+        try {
+             // $param = $_REQUEST['param'];
+            Log::record('-----微信支付回调----开始----');
 
-        Log::record('-----获取订单信息-----');
-        $order = Db::table("remote_order")->where("id", $out_trade_no)->field("id, status, super_doctor_id, application_id, hospital_id, doctor_id, exam_class")->find();
-        Log::record($order);
-        if($order && $order['status'] === Application::ORDER_STATUS['CREATE']) {
-            $order['status'] = Application::ORDER_STATUS['PAYCOMPLTET'];
-            $d = $order['super_doctor_id'];
-            $aid = $order['application_id'];
-            // todo 消息通知
-            Log::record('-----更新订单状态-----');
-            DB::table("remote_order")->where("id", $out_trade_no)->update($order);
-            $application = DB::table('remote_application')->where('id', $order['application_id'])->field('exam_id')->find();
-            $exam_id = $application['exam_id'];
-            $r_info = DB::table('report')->where('exam_id',$exam_id)->where('remote_application_id', $aid)->find();
-            $t = '收到一条远程诊断申请';
-            $ins = DB::table('institution')->where('id',$order['hospital_id'])->field('name')->find();
-            $doctor = DB::table('doctors')->where('id',$order['doctor_id'])->field('realname')->find();
-            $c = $ins['name'].$doctor['realname'].'医师向您发起一条远程诊断申请';
-            $type = '1';
-            $url = Message::url(null, $exam_id,1,$order['exam_class'],$r_info['id'],$aid);
-            Log::record('-----系统内消息通知-----');
-            Message::insert($t,$c,$d,$type,$url,1,$aid);
-                //保存  申请
-            if(empty($d)) {
-                Log::record('---微信支付回调---结束---没有远程医生');
-                return $repsone;
-            }
-            $dinfo = DB::table('doctors')->where('id',$d)->find();
-            $d_phone = $dinfo['phone'];
-            $d_name = $dinfo['realname'];
-            if($order['is_urgent'] === 1) {
-                $d_time = date('H:i',strtotime('+30 min'));
-            } else {
-                $d_time = date('H:i',strtotime('+1 hour'));
-            }
-            if($dinfo['institution_id'] == '22100003' || $dinfo['send_sms'] == 1){ //魏庙
-                Log::record('-----短信通知-----');
-                send_message::sendSms2Apply($d_phone,$d_time,$d_name);
+            Log::record('-----微信支付返回----xml----');
+            $xml = file_get_contents("php://input");
+            Log::record($xml);
+            Log::record('-----xml转数组--------');
+            $data = (array)simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA); //将微信返回的XML 转换成数组
+            Log::record($data);
+            $out_trade_no = $data['out_trade_no'];
+            $data['timestamp'] = time();
+            Log::record('-----添加流水记录----');
+            Log::record($data);
+            Db::table("wechat_pay_log")->insert($data);
+            Log::record('-----获取订单信息-----');
+            $order = Db::table("remote_order")->where("id", $out_trade_no)->field("id, status, super_doctor_id, application_id, hospital_id, doctor_id, exam_class")->find();
+            Log::record($order);
+            if($order && $order['status'] === Application::ORDER_STATUS['CREATE']) {
+                $order['status'] = Application::ORDER_STATUS['PAYCOMPLTET'];
+                $d = $order['super_doctor_id'];
+                $aid = $order['application_id'];
+                // todo 消息通知
+                Log::record('-----更新订单状态-----');
+                DB::table("remote_order")->where("id", $out_trade_no)->update($order);
+                $application = DB::table('remote_application')->where('id', $aid)->field('exam_id')->find();
+                $exam_id = $application['exam_id'];
+                $r_info = DB::table('report')->where('exam_id',$exam_id)->where('remote_application_id', $aid)->field('id')->find();
+                $t = '收到一条远程诊断申请';
+                $ins = DB::table('institution')->where('id',$order['hospital_id'])->field('name')->find();
+                $doctor = DB::table('doctors')->where('id',$order['doctor_id'])->field('realname')->find();
+                $c = $ins['name'].$doctor['realname'].'医师向您发起一条远程诊断申请';
+                $type = '1';
+                $url = Message::url(null, $exam_id,1,$order['exam_class'],$r_info['id'],$aid);
+                Log::record('-----系统内消息通知-----');
+                Message::insert($t,$c,$d,$type,$url,1,$aid);
+                    //保存  申请
+                if(empty($d)) {
+                    Log::record('---微信支付回调---结束---没有远程医生');
+                    return self::SUCCESS;
+                }
+                $dinfo = DB::table('doctors')->where('id',$d)->find();
+                $d_phone = $dinfo['phone'];
+                $d_name = $dinfo['realname'];
+                if($order['is_urgent'] === 1) {
+                    $d_time = date('H:i',strtotime('+30 min'));
+                } else {
+                    $d_time = date('H:i',strtotime('+1 hour'));
+                }
+                if($dinfo['institution_id'] == '22100003' || $dinfo['send_sms'] == 1){ //魏庙
+                    Log::record('-----短信通知-----');
+                    send_message::sendSms2Apply($d_phone,$d_time,$d_name);
+                }
             }
+            Log::record('---微信支付回调---结束---');
+            return self::SUCCESS;
+        } catch (\Throwable $th) {
+            Log::record('支付回调异常');
+            Log::record($th->getMessage());
+            //throw $th;
         }
-        Log::record('---微信支付回调---结束---');
-        return $repsone;
 
 
         // $order_id = $param['order_id'];

+ 5 - 4
application/inter/controller/Writereport.php

@@ -11,6 +11,7 @@ use think\Cache;
 use think\Log;
 use app\common\library\Verify;
 use app\common\library\send_message;
+use app\inter\service\WechatService;
 
 class Writereport extends Base
 {
@@ -462,7 +463,7 @@ class Writereport extends Base
     }
      *")
      **/
-    public function confirm(){
+    public function confirm(WechatService $wechatService){
         try{
             Log::record('confirm');
             $is_remote = $_REQUEST['is_remote'];
@@ -510,8 +511,7 @@ class Writereport extends Base
                 Message::read($doctor['id'],$report_info['remote_application_id'],4);
                 //远程
                 
-                $this->confirmReport($report_info['remote_application_id']);
-               
+                $this->confirmReport($report_info['remote_application_id'],  $wechatService);
                 // DB::table('remote_application')->where('id',$report_info['remote_application_id'])->update(['report_status'=>'9']);
                 // 添加messages消息
                 $t = '您的报告已确认';
@@ -545,7 +545,7 @@ class Writereport extends Base
 
     }
 
-    private function confirmReport($application_id) {
+    private function confirmReport($application_id, $wechatService) {
         Db::startTrans();
         try{
             DB::table('remote_application')->where('id', $application_id)->update(['report_status'=>'9']);
@@ -592,6 +592,7 @@ class Writereport extends Base
             ]);
             // 提交事务
             Db::commit();
+            $wechatService->pushWechatComplete($order_id);
             // todo 消息推送
             return true;
         } catch (\Exception $e) {

+ 91 - 19
application/inter/service/WechatService.php

@@ -6,67 +6,139 @@ use think\Log;
 
 class WechatService {
 
+  private const PUSH_TYPE = [
+    'REMOTE_DIAGNOSIS_PATIENT_PAY' => 1,
+    'REMOTE_DIAGNOSIS_FINISH' => 2,
+    'REMOTE_DIAGNOSIS_CANCEL' => 3,
+    'REMOTE_DIAGNOSIS_REFUND' => 4
+  ];
 
-  public function pushWechatOrder($exam_id) {
-    $openids = $this->getPushOpenId($exam_id);
+  private const BASE_URL = "http://wechat.pacsonline.cn/wx_patient/api/";
+  public function pushWechatOrder($order_id) {
+    $order = $this->getPushOrder($order_id);
+    $orderStr = $this->getPushContent($order);
+    $openids = $this->getPushOpenId($order['exam_id']);
     if(!$openids) {
       log::record('---------没有找到对应openid--------');
       return false;
     }
 
     foreach($openids as $v) {
-      $url   = "http://wechat.pacsonline.cn/wx_patient/api/sendMsg?pushType=1&openid=";
-      $full_url = $url . $v['openid'];
+      $url = $this->getFullUrl(self::PUSH_TYPE['REMOTE_DIAGNOSIS_PATIENT_PAY'], $v['openid'], $v['source'], $orderStr);
+      // $url   = "http://wechat.pacsonline.cn/wx_patient/api/sendMsg?pushType=".."&openid=";
+      // $full_url = $url . $v['openid']."&source=".$v['source']."&content=".$orderStr;
       // 请求
       log::record('---------发送微信通知-发起订单-------');
-      log::record($full_url);
-      $res = $this->curl_request($full_url, 'GET');
+      log::record($url);
+      $res = $this->curl_request($url, 'GET');
       log::record('---------微信通知结果--------');
       log::record($res);
     }
     return true;
   }
 
-  public function pushWechatCancel($exam_id) {
-    $openids = $this->getPushOpenId($exam_id);
+  public function pushWechatCancel($order_id) {
+    $order = $this->getPushOrder($order_id);
+    $orderStr = $this->getPushContent($order);
+    $openids = $this->getPushOpenId($order['exam_id']);
     if(!$openids) {
       log::record('---------没有找到对应openid--------');
       return false;
     }
 
     foreach($openids as $v) {
-      $url   = "http://wechat.pacsonline.cn/wx_patient/api/sendMsg?pushType=1&openid=";
-      $full_url = $url . $v['openid'];
+      $url = $this->getFullUrl(self::PUSH_TYPE['REMOTE_DIAGNOSIS_CANCEL'], $v['openid'], $v['source'], $orderStr);
+      // $url   = "http://wechat.pacsonline.cn/wx_patient/api/sendMsg?pushType=".."&openid=";
+      // $full_url = $url . $v['openid']."&source=".$v['source']."&content=".$orderStr;
       // 请求
       log::record('---------发送微信通知-取消订单-------');
-      log::record($full_url);
-      $res = $this->curl_request($full_url, 'GET');
+      log::record($url);
+      $res = $this->curl_request($url, 'GET');
       log::record('---------微信通知结果--------');
       log::record($res);
     }
     return true;
   }
 
-  public function pushWechatComplete($exam_id) {
-    $openids = $this->getPushOpenId($exam_id);
+  public function pushWechatComplete($order_id) {
+    $order = $this->getPushOrder($order_id);
+    $orderStr = $this->getPushContent($order);
+    $openids = $this->getPushOpenId($order['exam_id']);
     if(!$openids) {
       log::record('---------没有找到对应openid--------');
       return false;
     }
 
     foreach($openids as $v) {
-      $url   = "http://wechat.pacsonline.cn/wx_patient/api/sendMsg?pushType=1&openid=";
-      $full_url = $url . $v['openid'];
+      $url = $this->getFullUrl(self::PUSH_TYPE['REMOTE_DIAGNOSIS_FINISH'], $v['openid'], $v['source'], $orderStr);
+      // $url   = "http://wechat.pacsonline.cn/wx_patient/api/sendMsg?pushType=".."&openid=";
+      // $full_url = $url . $v['openid']."&source=".$v['source']."&content=".$orderStr;
       // 请求
       log::record('---------发送微信通知-完成订单-------');
-      log::record($full_url);
-      $res = $this->curl_request($full_url, 'GET');
+      log::record($url);
+      $res = $this->curl_request($url, 'GET');
       log::record('---------微信通知结果--------');
       log::record($res);
     }
     return true;
   }
 
+  public function pushWechatRefund($order_id) {
+    $order = $this->getPushOrder($order_id);
+    $orderStr = $this->getPushContent($order);
+    $openids = $this->getPushOpenId($order['exam_id']);
+    if(!$openids) {
+      log::record('---------没有找到对应openid--------');
+      return false;
+    }
+
+    foreach($openids as $v) {
+      $url = $this->getFullUrl(self::PUSH_TYPE['REMOTE_DIAGNOSIS_REFUND'], $v['openid'], $v['source'], $orderStr);
+      // $url   = "http://wechat.pacsonline.cn/wx_patient/api/sendMsg?pushType=".."&openid=";
+      // $full_url = $url . $v['openid']."&source=".$v['source']."&content=".$orderStr;
+      // 请求
+      log::record('---------发送微信通知-退款-------');
+      log::record($url);
+      $res = $this->curl_request($url, 'GET');
+      log::record('---------微信通知结果--------');
+      log::record($res);
+    }
+    return true;
+  }
+
+  private function getPushContent($order) {
+    $content = [
+      'out_trade_no' => $order['order_id'],
+      'name' => urlencode($order['name']),
+      'total_fee' => $order['order_money']
+    ];
+    return json_encode($content);
+  }
+
+  // $url   = "http://wechat.pacsonline.cn/wx_patient/api/sendMsg?pushType=".."&openid=";
+  // $full_url = $url . $v['openid']."&source=".$v['source']."&content=".$orderStr;
+
+  private function getFullUrl($pushType, $openid, $source, $content) {
+    return self::BASE_URL."sendMsg?pushType=".$pushType."&openid=".$openid."&source=".urlencode($source)."&content=".urlencode($content);
+  }
+
+  private function getPushOrder($order_id) {
+    $order = DB::table('remote_order')->where('id', $order_id)->field('application_id, order_money')->find();
+    if($order) {
+      $application = DB::table('remote_application')->where('id', $order['application_id'])->field('exam_id')->find();
+      $exam = DB::table('exams')->where('id', $application['exam_id'])->field('patient_id')->find();
+      $patient = DB::table('patient_infos')->where('id', $exam['patient_id'])->field('name')->find();
+      if($application) {
+        return [
+          'order_id' => $order_id,
+          'order_money' => $order['order_money'],
+          'exam_id' => $application['exam_id'],
+          'name' => $patient['name']
+        ];
+      }
+    }
+  }
+
   private function getPushOpenId($exam_id) {
     $exams = DB::table("exams")
     ->alias('e')
@@ -110,7 +182,7 @@ class WechatService {
       $options[] = $phone;
     }
 
-    $sql = "select wx_openid as openid from user where id in (".$sql1." union ".$sql2.")";
+    $sql = "select wx_openid as openid, source from user where id in (".$sql1." union ".$sql2.")";
     log::record('---------微信推送sql--------');
     log::record($sql);
     return Db::query($sql, $options);