コード例 #1
0
ファイル: feedback.php プロジェクト: h3len/Project
 public function fetch_message()
 {
     $id = intval($this->input['id']);
     if (!$this->user['user_id']) {
         $this->errorOutput(NO_ACCESS_TOKEN);
     }
     $sql = 'SELECT id,process,message_id FROM ' . DB_PREFIX . 'record_person WHERE feedback_id = ' . $id . ' and user_id = "' . $this->user['user_id'] . '"';
     $backinfo = $this->db->query_first($sql);
     if ($backinfo['id']) {
         if ($this->settings['App_im']) {
             $msg_id = $backinfo['message_id'];
             if ($msg_id) {
                 $this->curl = new curl($this->settings['App_im']['host'], $this->settings['App_im']['dir']);
                 $this->curl->setSubmitType('post');
                 $this->curl->setReturnFormat('json');
                 $this->curl->initPostData();
                 $this->curl->addRequestData('session_id', $msg_id);
                 $this->curl->addRequestData('sort_type', 'ASC');
                 $this->curl->addRequestData('a', 'session_detail');
                 $message = $this->curl->request('message.php');
                 $message = $message[0];
                 $msg = $message['messages'][$msg_id];
                 $userinfo = $message['users'];
                 if ($id) {
                     $sql = 'SELECT admin_reply_count FROM ' . DB_PREFIX . 'record_person WHERE feedback_id = ' . $id . ' AND user_id = ' . $this->user['user_id'];
                     $back = $this->db->query_first($sql);
                     $reply = $back['admin_reply_count'];
                     $sql = 'UPDATE ' . DB_PREFIX . 'record_person SET admin_reply_count = 0 WHERE feedback_id = ' . $id . ' AND user_id = ' . $this->user['user_id'];
                     $this->db->query($sql);
                     if ($message['session_info']['id'] && $reply) {
                         /*************会员查看过消息之后,管理员的回复数量加新消息数************/
                         if ($this->settings['App_members']) {
                             require_once ROOT_PATH . 'lib/class/members.class.php';
                             $members = new members();
                             $data = array('member_id' => $this->user['user_id'], 'mark' => 'apply', 'math' => 2, 'total' => $reply);
                             $ret = $members->updateMyData($data);
                         }
                         /*************会员查看过消息之后,管理员的回复数量加新消息数************/
                     }
                 }
                 if ($userinfo && is_array($userinfo)) {
                     foreach ($userinfo as $k => $v) {
                         $user[$v['uid']] = $v['utype'];
                     }
                 }
                 if ($msg && is_array($msg)) {
                     foreach ($msg as $k => $v) {
                         $msg[$k]['utype'] = $user[$v['send_uid']];
                     }
                 }
                 $retutn = array('msg' => $msg, 'users' => $userinfo);
             }
         }
     }
     $this->addItem($retutn);
     $this->output();
 }
コード例 #2
0
ファイル: feedback_update.php プロジェクト: h3len/Project
 private function fetch_message($msg_id, $feedback_id, $no_btn = 0)
 {
     if ($msg_id) {
         $this->curl = new curl($this->settings['App_im']['host'], $this->settings['App_im']['dir']);
         $this->curl->setSubmitType('post');
         $this->curl->setReturnFormat('json');
         $this->curl->initPostData();
         $this->curl->addRequestData('session_id', $msg_id);
         $this->curl->addRequestData('sort_type', 'ASC');
         $this->curl->addRequestData('a', 'session_detail');
         $message = $this->curl->request('message.php');
         $message = $message[0];
         $msg = $message['messages'][$msg_id];
         $userinfo = $message['users'];
         if ($feedback_id) {
             $sql = 'SELECT admin_reply_count FROM ' . DB_PREFIX . 'record_person WHERE feedback_id = ' . $feedback_id . ' AND user_id = ' . $this->user['user_id'];
             $back = $this->db->query_first($sql);
             $reply = $back['admin_reply_count'];
             $sql = 'UPDATE ' . DB_PREFIX . 'record_person SET admin_reply_count = 0 WHERE feedback_id = ' . $feedback_id . ' AND user_id = ' . $this->user['user_id'];
             $this->db->query($sql);
             if ($message['session_info']['id'] && $reply) {
                 /*************会员查看过消息之后,管理员的回复数量加新消息数************/
                 if ($this->settings['App_members']) {
                     require_once ROOT_PATH . 'lib/class/members.class.php';
                     $members = new members();
                     $data = array('member_id' => $this->user['user_id'], 'mark' => 'apply', 'math' => 2, 'total' => $reply);
                     $ret = $members->updateMyData($data);
                 }
                 /*************会员查看过消息之后,管理员的回复数量加新消息数************/
             }
         }
         if ($userinfo && is_array($userinfo)) {
             foreach ($userinfo as $k => $v) {
                 $user[$v['uid']] = $v['utype'];
             }
         }
         if ($msg && is_array($msg)) {
             $body_html = '';
             $body_html .= '<ul class="talk-list">';
             foreach ($msg as $k => $v) {
                 if ($user[$v['send_uid']] == 'admin') {
                     $body_html .= '<li class="feedback-flex">';
                     $body_html .= '<img class="service-provider-avatar" src="' . hg_material_link($v['send_uavatar']['host'], $v['send_uavatar']['dir'], $v['send_uavatar']['filepath'], $v['send_uavatar']['filename'], '48x48/') . '" />';
                     $body_html .= '<div class="feedback-flex-one">';
                     $body_html .= '<span class="msg service-provider">' . $v['message'] . '</span>';
                     $body_html .= '</div>';
                     $body_html .= '</li>';
                 } else {
                     $body_html .= '<li>';
                     $body_html .= '<span class="msg user">' . $v['message'] . '</span>';
                     $body_html .= '</li>';
                 }
             }
             $body_html .= '</ul>';
         }
     }
     if ($msg_id && !$no_btn) {
         $body_html .= '<div class="replay feedback-flex">';
         $body_html .= '<input class="feedback-flex-one" type="text" name="replay" placeholder="在此输入回复内容">';
         $body_html .= '<span class="btn-default replay-btn">发送</span>';
         $body_html .= '</div>';
     }
     return $body_html;
 }
コード例 #3
0
ファイル: feedback_update.php プロジェクト: h3len/Project
 public function add_message()
 {
     $id = intval($this->input['id']);
     if (!$id) {
         $this->errorOutput(NOID);
     }
     if (!$this->user['user_id']) {
         $this->errorOutput(NO_ACCESS_TOKEN);
     }
     $sql = 'SELECT rp.message_id, rp.user_id,rp.user_name,rp.device_token,rp.app_id,rp.feedback_id,f.title,f.indexpic,f.brief FROM ' . DB_PREFIX . 'record_person rp LEFT JOIN ' . DB_PREFIX . 'feedback f ON f.id = rp.feedback_id  WHERE rp.id = ' . $id;
     $backinfo = $this->db->query_first($sql);
     if (!$backinfo['user_id'] || !$backinfo['user_name']) {
         $this->errorOutput(NO_TOUSER);
     }
     if ($this->settings['App_im']) {
         require_once ROOT_PATH . 'lib/class/curl.class.php';
         $this->curl = new curl($this->settings['App_im']['host'], $this->settings['App_im']['dir']);
         $this->curl->setSubmitType('post');
         $this->curl->setReturnFormat('json');
         $this->curl->initPostData();
         $params = array('touser_id' => $backinfo['user_id'], 'touser_name' => $backinfo['user_name'], 'touser_type' => '', 'touser_device_token' => $backinfo['device_token'], 'touser_appid' => $backinfo['app_id'], 'utype' => 'admin', 'access_token' => trim($this->input['access_token']), 'user_device_token' => trim($this->input['device_token']), 'user_appid' => $this->user['appid'], 'title' => $backinfo['title'], 'message' => trim($this->input['message']), 'indexpic' => $backinfo['indexpic'], 'brief' => $backinfo['brief'], 'settings[push_notice]' => 1, 'app_uniqueid' => APP_UNIQUEID, 'a' => 'send_message');
         foreach ($params as $k => $v) {
             $this->curl->addRequestData($k, $v);
         }
         $message = $this->curl->request('message.php');
         $message = $message[0];
         if ($message['session_id']) {
             $sql = 'UPDATE ' . DB_PREFIX . 'record_person SET message_id = ' . $message['session_id'] . ' , admin_reply_count = admin_reply_count +1, total_reply = total_reply + 1  WHERE id = ' . $id;
             $this->db->query($sql);
             /*************会员查看过消息之后,管理员的回复数量加新消息数************/
             if ($this->settings['App_members']) {
                 require_once ROOT_PATH . 'lib/class/members.class.php';
                 $members = new members();
                 $data = array('member_id' => $backinfo['user_id'], 'mark' => 'apply', 'math' => 1, 'total' => 1);
                 $members->updateMyData($data);
             }
             /*************会员查看过消息之后,管理员的回复数量加新消息数************/
         } else {
             $this->errorOutput(ERROR_SEND);
         }
     }
     if (!$message) {
         $this->errorOutput(ERROR_SEND);
     }
     $this->addItem($message);
     $this->output();
 }