|
@@ -140,23 +140,30 @@ class WechatService {
|
|
|
}
|
|
|
|
|
|
private function getPushOpenId($exam_id) {
|
|
|
- $exams = DB::table("exams")
|
|
|
+ $exam = 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')
|
|
|
+ ->field('e.patient_id, s.accession_num, s.studyid, pi.temp_patient_id, pi.card_num, pi.phone, e.institution_id')
|
|
|
->where('e.id', $exam_id)
|
|
|
->find();
|
|
|
- if(!$exams) {
|
|
|
+ if(!$exam) {
|
|
|
+ log::record('---------没有对应检查--------');
|
|
|
return false;
|
|
|
}
|
|
|
+ $institution = Db::table('institution')->where('id', $exam['institution_id'])->find();
|
|
|
+ if(!$institution) {
|
|
|
+ log::record('---------没有对应医院--------');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $wx_source = $institution['wx_source'];
|
|
|
$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'];
|
|
|
+ $accession_num = $exam['accession_num'];
|
|
|
+ $studyid = $exam['studyid'];
|
|
|
+ $patient_id = $exam['patient_id'];
|
|
|
+ $temp_patient_id = $exam['temp_patient_id'];
|
|
|
+ $card_num = $exam['card_num'];
|
|
|
+ $phone = $exam['phone'];
|
|
|
|
|
|
$sql1 = "select user_id as uid from user_bind where patient_id = ?";
|
|
|
$options[] = $patient_id;
|
|
@@ -182,7 +189,8 @@ class WechatService {
|
|
|
$options[] = $phone;
|
|
|
}
|
|
|
|
|
|
- $sql = "select wx_openid as openid, source from user where id in (".$sql1." union ".$sql2.")";
|
|
|
+ $sql = "select wx_openid as openid, source from user where id in (".$sql1." union ".$sql2.") and wx_source = ?";
|
|
|
+ $options[] = $wx_source;
|
|
|
log::record('---------微信推送sql--------');
|
|
|
log::record($sql);
|
|
|
log::record($options);
|