Ejemplo n.º 1
0
function process_message($msg)
{
    $dbalive = mysql_ping();
    if ($dbalive !== TRUE) {
        //数据库连接失效 重连
        echo "reconnecting DB ! \n";
    }
    global $remsg_obj, $msg_obj, $rm_obj, $remsgque_obj, $dbConn;
    $message_body = json_decode($msg->body, TRUE);
    if ($message_body == FALSE || !is_array($message_body) || !isset($message_body['id'])) {
        echo 'invalid message ! --- ' . $msg->body . "\n";
        return;
    }
    $id = $message_body['id'];
    $sql = "select * from msg_replyqueue where id={$id}  limit 1";
    $row = $dbConn->fetch_first($sql);
    if (empty($row)) {
        //没找到信息 直接return
        $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
        //删除队列信息
        return;
    }
    $infor = unserialize($row['parameter']);
    // 反序列化其他扩展信息
    /*----- 根据账号来加载账号信息 -----*/
    $ebayaccount = $row['account'];
    //所属账号
    $token_file = WEB_PATH . "lib/ebaylibrary/keys/keys_" . $ebayaccount . ".php";
    if (!file_exists($token_file)) {
        echo formatetime() . '---' . $token_file . " does not exists!!! at code line--" . __LINE__ . "\n";
        // 密码文件不存在
        $remsgque_obj->delAQueueRecords($row['id']);
        //数据不对直接删除
        $msg_obj->updateMessageStatus(array($row['messageid']), 0);
        //重置message为0的状态
        $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
        //删除队列信息
        return;
        // 退出
    }
    include '' . $token_file;
    /*----- 导出为全局变量 ugly code -----*/
    $GLOBALS['siteID'] = $siteID;
    $GLOBALS['production'] = $production;
    $GLOBALS['compatabilityLevel'] = $compatabilityLevel;
    $GLOBALS['devID'] = $devID;
    $GLOBALS['appID'] = $appID;
    $GLOBALS['certID'] = $certID;
    $GLOBALS['serverUrl'] = $serverUrl;
    $GLOBALS['userToken'] = $userToken;
    /*----- 根据账号来加载账号信息 -----*/
    $msgid = $row['messageid'];
    //对应的message表的主键id
    if ($row['replytype'] == 1) {
        //带有回复内容的message回复
        $content = $row['retext'];
        //回复内容
        $copytosender = $infor['iscopy'];
        // 是否抄送 改值只能为0、1
        /*----- 推送回复到线上 -----*/
        $result = $rm_obj->replyMessage($msgid, $content, $copytosender);
        //回复 并返回结果
        if ($result == TRUE) {
            //执行成功则标记为已经读取
            $result = $rm_obj->markAsRead($msgid, 'Read');
            if (!$result) {
                echo ReplyMessageModel::$errMsg . " --- 回邮件发送成功, 标记已读失败!\n";
            }
        }
    } else {
        //只标及为回复状态 没有回复内容的
        /*----- 发送请求 -----*/
        $result = $rm_obj->markAsRead($msgid, 'Read');
    }
    if ($result == TRUE) {
        // 发送成功 删除该回复队列记录
        $remsgque_obj->delAQueueRecords($row['id']);
        $status = 2;
        // 默认为正常回复
        if ($row['replytype'] == 2) {
            //为标记回复
            $status = 3;
        }
        $msg_obj->updateMessageStatus(array($msgid), $status);
        //将message状态改为回复成功
        echo 'success!  ' . date('Y:m:d H:i:s', time()) . "\n";
    } else {
        // 发送失败
        echo date('Y-m-d H:i:s', time()) . '---' . __LINE__ . '---' . __FILE__ . '---' . ReplyMessageModel::$errMsg . "\n";
        $errcontent = ReplyMessageModel::$sendMsg;
        if (ReplyMessageModel::$sender != NULL) {
            $usrmod_obj = new GetLoacalUserModel();
            $userinfo = $usrmod_obj->getUserInfoBySysId(ReplyMessageModel::$sender);
            if (!empty($userinfo)) {
                /*发送邮件*/
                $result_sys = getOpenSysApi('notice.send.message', array('content' => $errcontent, 'from' => 'tuxinglong', 'to' => $userinfo['global_user_login_name'], 'type' => 'email'));
            }
        }
        $remsgque_obj->plusCountById($row['id']);
        // 将失败次数加一
    }
    //确认收到
    $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
    //确认收到
    // Send a message with the string "quit" to cancel the consumer.
    if ($msg->body === 'quit') {
        $msg->delivery_info['channel']->basic_cancel($msg->delivery_info['consumer_tag']);
    }
}
Ejemplo n.º 2
0
 public function getUserInfoBySysId($userId, $way = 1)
 {
     $returnar = array('userName' => NULL);
     if ($way === 1) {
         $info = $this->getUsernameById($userId);
         if (!empty($info)) {
             $decode = json_decode($info, TRUE);
             if (is_array($decode)) {
                 $returnar['userName'] = $decode[0]['userName'];
             } else {
                 $returnar['userName'] = '';
             }
         }
     } else {
         $glu_ojb = new GetLoacalUserModel();
         $user = $glu_ojb->getUserInfoBySysId($userId);
         if (!empty($user)) {
             $returnar['userName'] = $user['global_user_name'];
         }
     }
     return $returnar;
 }
Ejemplo n.º 3
0
 public function view_mailPushSettingList()
 {
     include_once WEB_PATH . 'lib/global_ebay_accounts.php';
     //导入ebay平台账号
     $bindObj = new UserAccountBindModel();
     $relatio = array();
     $userObj = new GetLoacalUserModel();
     foreach ($GLOBAL_EBAY_ACCOUNT as $account) {
         $users = $bindObj->getBindInfo($account);
         foreach ($users as &$u) {
             $userInfo = $userObj->getUserInfoBySysId($u['userID']);
             $u['name'] = isset($userInfo['global_user_name']) ? $userInfo['global_user_name'] : '';
         }
         $relation[$account] = $users;
     }
     $allowedList = $bindObj->getAllowedAccount($_SESSION['globaluserid']);
     $GLOBAL_EBAY_ACCOUNT = array_intersect($allowedList, $GLOBAL_EBAY_ACCOUNT);
     //         print_r($relation);exit;
     $this->smarty->assign('accountList', $GLOBAL_EBAY_ACCOUNT);
     $this->smarty->assign('sec_menue', 4);
     $this->smarty->assign('toplevel', 4);
     $this->smarty->assign('powerList', $relation);
     $this->smarty->assign('toptitle', 'message类别列表');
     $this->smarty->display('mailPushSettingList.htm');
 }