Beispiel #1
0
 public function reply($data)
 {
     $noticeid = $data["noticeid"];
     if (empty($noticeid)) {
         return Utils::WrapResultError("noticeid不能为空");
     }
     $files = isset($data["files"]) ? $data["files"] : '';
     if (!empty($files) && is_array($files)) {
         $files = implode(',', $files);
     }
     $sql = 'update im_pushnotice_memebr set receive_time=now() where noticeid=? and employeeid=? and receive_time is not null';
     $sql1 = 'insert into im_pushnotice_msg(id,replyid,msg,created,us,msgid)values(?,?,?,now(),?,?)';
     $replyid = SysSeq::GetSeqNextValue($this->conn_im, "im_pushnotice_msg", "id");
     $sql = 'select count(1)+1 cnt from im_pushnotice_msg where replyid=?';
     $ds = $this->conn_im->Getdata('t', $sql, array((int) $noticeid));
     $cnt = $ds['t']['rows'][0]['cnt'];
     $senddata = array();
     $senddata = array('noticeid' => $noticeid, 'reply_count' => $cnt, 'reply' => array('id' => $replyid, 'nickname' => $this->user["nick_name"], 'photo' => $this->user["photo_path"], 'jid' => $this->user["jid"], 'text' => $data["reply-text"], 'files' => $files, 'sendtime' => date("Y-m-d H:i:s", time())));
     $notice = array();
     // Utils::WrapMessageNoticeinfo($data["reply-text"],$this->module["appname"],null,$this->module["logo"]);
     $msg = Utils::WrapMessage('push-notice-reply', $senddata, $notice);
     $msgxml = Utils::WrapMessageXml($this->module["jid"], $msg, 'push-notice-reply-' . $replyid);
     $this->conn_im->ExecSQLs(array($sql, $sql1), array(array((int) $noticeid, (string) $this->user["jid"]), array((int) $replyid, (int) $noticeid, (string) json_encode($senddata['reply']), $this->user['jid'], 'push-notice-reply-' . $replyid)));
     $noticeinfo = $this->getinfo($noticeid);
     $receiver = $this->getmember($noticeid);
     $receiver[] = $noticeinfo["us"];
     Utils::findonlinejid($this->conn_im, $receiver);
     if (!empty($receiver)) {
         //发送消息
         $presence = new \Justsy\OpenAPIBundle\Controller\ApiController();
         $presence->setContainer($this->container);
         $presence->sendMsg($this->module["jid"], $receiver, '通知回复', json_encode($msg));
     }
     return Utils::WrapResultOK(array('noticeid' => $noticeid));
 }
Beispiel #2
0
 public function write_msg($fromjid, $msgxml, $msgid)
 {
     if (empty($fromjid)) {
         $domain = $this->container->getParameter('edomain');
         $staffinfo = new \Justsy\BaseBundle\Management\Staff($this->conn, $this->conn_im, 'admin@' . $domain, $this->container->get("logger"), $this->container);
         $staffdata = $staffinfo->getInfo();
         $fromjid = $staffdata['jid'];
     }
     if (empty($msgid)) {
         $msgid = split("@", $fromjid);
         $msgid = $msgid[0] . time();
     }
     //存储业务消息
     $xml = Utils::WrapMessageXml($fromjid, $msgxml, $msgid);
     $sql = 'insert into im_b_msg(msg,created,us,msgid)values(?,now(),?,?)';
     $para = array((string) $xml, (string) $fromjid, (string) $msgid);
     $this->conn_im->ExecSQL($sql, $para);
 }