query("select s.owner_name,s.unitinfo,s.company,c.owner_address from sp_owner s ,sp_owner_company c where s.company=c.owner_id and s.owner_code ='" . $dataid . "'"); $union_sql = M()->query("select phone from sp_owner_phone WHERE owner_code='" . $company[0]['company'] . "' " . $where . " union select phone from sp_owner_phone WHERE owner_code in (select other_code from sp_owner_fujin where owner_code='" . $company[0]['company'] . "') " . $where . ""); // print_r("select phone from sp_owner_phone WHERE owner_code='" . $company[0]['company'] . "' " . $where . " union select phone from sp_owner_phone WHERE owner_code in (select other_code from sp_owner_fujin where owner_code='" . $company[0]['company'] . "') " . $where . ""); if (count($union_sql) == 0) { exit; } $openids = $this->array_column1($union_sql, "phone"); if (empty($openids)) { echo 'open is null'; exit; } $status11 = M()->query("SELECT statustime FROM sp_devices_status where deviceid='" . $dataid . "'"); $op = M()->query("SELECT openid FROM sp_wx_customuser WHERE type='wx' and idphone in($openids)"); print_r("SELECT openid FROM sp_wx_customuser WHERE type='wx' and idphone in($openids)"); $access_token = GetAccess_Token1(); // $access_token1 = S('accesToken'); $address = '警报地址:' . $company[0]['owner_address'] . $company[0]['unitinfo']; $deviceid = $dataid; $type = $status; if (empty($time)) { $time = $status11[0]['statustime']; } // $ljcompany = $company[0]['company']; if (!empty($bz)) { $remark = $bz; } else { $remark = '设备名称:' . $company[0]['owner_name']; } // $ljurl = "https://iot.usky.cn/jdxf/wxapp2.php/Home/Fireinfo/index/type/2/id/" . $insert_id; foreach ($op as $o) { if (!empty($o['openid'])) { $arr = $this->SendDeviceAlarm($access_token, $o['openid'], $address, $deviceid, $type, $time, $remark, $ljurl='', $url = ''); // print_r($arr); } } } }