1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace app\inter\service;
- use think\Db;
- class WechatService {
- public function pushWechatOrder($exam_id) {
- $openids = $this->getPushOpenId($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'];
- // 请求
- $res = $this->curl_request($full_url, 'GET');
- }
- // http://wechat.pacsonline.cn/wx_patient/api/sendMsg?pushType=1&openid=
- }
- public function pushWechatCancel() {
- }
- public function pushWechatComplete() {
- }
- private function getPushOpenId($exam_id) {
- $exams = DB::table("exams")
- ->alias('e')
- ->join('studies s', 'e.study_id = s.id')
- ->join('patient_infos pi', 'e.patient_id = pi.id')
- ->field('e.patient_id, s.accession_num, s.studyid, pi.temp_patient_id, pi.card_num, pi.phone')
- ->where('e.id', $exam_id)
- ->find();
- if(!$exams) {
- return false;
- }
- $options = [];
- $accession_num = $exams['accession_num'];
- $studyid = $exams['studyid'];
- $patient_id = $exams['patient_id'];
- $temp_patient_id = $exams['temp_patient_id'];
- $card_num = $exams['card_num'];
- $phone = $exams['phone'];
- $sql1 = "select user_id as uid from user_bind where patient_id = ?";
- $options[] = $patient_id;
- $sql2 = "select uid from wechat_bind where ";
- $sql2 .= "(patientCode = ?";
- $options[] = $temp_patient_id;
- if(!empty($accession_num)) {
- $sql2 .= " or patientCode = ?";
- $options[] = $accession_num;
- }
- if(!empty($studyid)) {
- $sql2 .= " or patientCode = ?";
- $options[] = $studyid;
- }
- $sql2 .=")";
- if($card_num) {
- $sql2 .= " or idcard = ?";
- $options[] = $card_num;
- }
- if($card_num) {
- $sql2 .= " or phone = ?";
- $options[] = $phone;
- }
- $sql = "select wx_openid as openid from user where id in (".$sql1." union ".$sql2.")";
- log::record('---------微信推送sql--------');
- log::record($sql);
- return Db::query($sql, $options);
- }
- }
|