Ejemplo n.º 1
0
    public function view_replyMessageAli_site()
    {
        include_once WEB_PATH . 'lib/AliMessage.class.php';
        $text = isset($_POST['text']) ? trim($_POST['text']) : '';
        //回复的内容
        $buyerId = isset($_GET['buyerid']) ? trim($_GET['buyerid']) : '';
        //买家id
        $account = isset($_GET['account']) ? trim($_GET['account']) : '';
        //卖家账号
        $relationid = isset($_GET['relationid']) ? trim($_GET['relationid']) : '';
        //消息关系id
        $bigestid = isset($_GET['bigestid']) ? trim($_GET['bigestid']) : '';
        //最大的id
        $region_h = isset($_GET['region_h']) ? trim($_GET['region_h']) : 0;
        //回复区间id 头
        $region_e = isset($_GET['region_e']) ? trim($_GET['region_e']) : 0;
        //回复区间id 尾
        $msg_obj = new messageModel();
        if (empty($buyerId)) {
            $msgdata = array('errCode' => 10017, 'errMsg' => '缺少买家ID!');
            echo json_encode($msgdata);
            exit;
        }
        if (empty($account)) {
            $msgdata = array('errCode' => 10017, 'errMsg' => '缺少卖家账号!');
            echo json_encode($msgdata);
            exit;
        }
        if (empty($text)) {
            $msgdata = array('errCode' => 10013, 'errMsg' => '回复内容不能为空!');
            echo json_encode($msgdata);
            exit;
        }
        //加载token信息
        $configFile = WEB_PATH . 'lib/ali_keys/' . "config_{$account}.php";
        //                  echo $configFile;"\n";exit;
        if (file_exists($configFile)) {
            include $configFile;
        } else {
            echo date('Y-m-d H:i:s', time()) . '---' . __LINE__ . "key file was not found !\n";
            exit;
        }
        /*将消息标记为已读*/
        $mysql_obj = new MysqlModel();
        $dataSet = array('hasread' => 2, 'replytime' => time());
        $whereSql = " where message_id>={$region_h} and message_id<={$region_e} and role=1 and relationId={$relationid}";
        $effectNum = $mysql_obj->update('msg_alisitemessage', $dataSet, $whereSql);
        $aliRepl_obj = new AliMessage();
        $aliRepl_obj->setConfig($appKey, $appSecret, $refresh_token);
        $aliRepl_obj->doInit();
        $result = $aliRepl_obj->replySiteMessage($buyerId, $text);
        $alireobj = new AliSiteReplyModel();
        $data = array();
        $data['relationid'] = $relationid;
        //站内信关联id
        $data['content'] = $text;
        //内容
        $data['replyuser'] = $_SESSION['globaluserid'];
        //回复人id
        $alireobj->addNewReplyData($data);
        $starttime = time() - 300;
        $endtime = time() + 300;
        $starttime = trunToLosangeles('m/d/Y H:i:s', $starttime);
        $endtime = trunToLosangeles('m/d/Y H:i:s', $endtime);
        sleep(6);
        $newMsg = $aliRepl_obj->getSiteMessageMin($starttime, $endtime, $bigestid, $buyerId);
        //         print_r($newMsg);exit;
        $newdiv = '';
        foreach ($newMsg as $nmsg) {
            if ($bigestid < $nmsg['id']) {
                $bigestid = $nmsg['id'];
            }
            $sendtime = aliTranslateTime($nmsg['gmtCreate']);
            $sendtime = date('Y-m-d H:i:s', $sendtime);
            // print_r($nmsg);exit;
            $imgstr = '';
            $orderstr = '';
            if (!empty($nmsg['orderUrl'])) {
                $orderstr = <<<EOF
            \t<div style="float:left; margin-left:10px;">
                    <a href="{$nmsg['orderUrl']}" target="_blank">{$nmsg['orderId']}</a>
                </div>
EOF;
            }
            if (!empty($nmsg['fileUrl'])) {
                $imgstr = <<<EOF
            \t<div style="float:left;padding-left:3px;padding-top:1px;">
\t\t\t\t    <a href="{$commn[fileUrl]}" target="_blank"><img src="{$commn[fileUrl]}" style="width:78px; height:78px;"></a>
\t\t\t\t</div>
EOF;
            }
            $newdiv .= <<<EOF
                <div style="background-color:#E1FACF; padding:2px; margin-top:3px;margin-bottom:3px;">
\t                        <div><span style=" width:100px;font-family:Arial,Verdana,Helvetica,sans-serif; font-size:13px;">{$nmsg['senderName']}</span>&nbsp;:{$sendtime}</div>
\t                        <div style="padding-left:113px;color:#525252;font-family:Arial,Verdana,Helvetica,sans-serif;font-size:13px;">{$nmsg['content']}</div>
\t\t                    <div style="background-color:#fff">
\t                        {$imgstr} {$orderstr}
\t\t\t                <div style="clear:both;"></div>
\t                        </div>
\t                    </div>
EOF;
        }
        if (FALSE === $result) {
            //执行失败
            $msgdata = array('errCode' => 10015, 'errMsg' => '回复失败!');
            echo json_encode($msgdata);
            exit;
        } else {
            //执行成功
            $msgdata = array('errCode' => 10016, 'errMsg' => '回复成功!', 'newmsg' => $newdiv, 'bigestid' => $bigestid);
            echo json_encode($msgdata);
            exit;
        }
    }
Ejemplo n.º 2
0
 public function view_getAliOrderList()
 {
     $keywords = isset($_GET['keywords']) ? trim($_GET['keywords']) : '';
     //关键字
     $keywords = mysql_real_escape_string($keywords);
     $status = isset($_GET['status']) ? intval($_GET['status']) : FALSE;
     //回复状态
     $category = isset($_GET['catid']) ? intval($_GET['catid']) : FALSE;
     //分类
     $orderstatus = isset($_GET['orderstatus']) ? trim($_GET['orderstatus']) : false;
     //订单状态
     $senderId = isset($_GET['senderid']) ? trim($_GET['senderid']) : FALSE;
     //发送人id
     $orderId = isset($_GET['orderid']) ? trim($_GET['orderid']) : FALSE;
     //订单号
     $prodname = isset($_GET['prodname']) ? trim($_GET['prodname']) : FALSE;
     //产品名称
     $conkeywords = isset($_GET['conkeywords']) ? trim($_GET['conkeywords']) : FALSE;
     //关键字
     $sellerId = isset($_GET['sellerId']) ? trim($_GET['sellerId']) : FALSE;
     //卖家账号
     $sortName = isset($_GET['sortname']) ? trim($_GET['sortname']) : FALSE;
     $sort = isset($_GET['sort']) ? trim($_GET['sort']) : FALSE;
     $isscroll = isset($_GET['isscroll']) ? intval($_GET['isscroll']) : 1;
     //设置是否收缩 1表示收缩  2表示不收缩 默认收缩
     if ($status == 2 && ($isscroll = 1)) {
         //只有当查看未回复订单留言时才进行收缩
         $isscroll = 1;
     } else {
         $isscroll = 2;
     }
     $cat_obj = new messagecategoryModel();
     /*----- 获得用户所属文件夹 -----*/
     $Lp_obj = new LocalPowerModel();
     $fieldid = $Lp_obj->getAliPowerlist($_SESSION['userId']);
     //获得当前用户所属的id
     $fieldid = isset($fieldid['field']) ? $fieldid['field'] : array(-1);
     $category = in_array($category, $fieldid) ? $category : -1;
     /*----- 获得用户所属文件夹 -----*/
     if (!empty($fieldid)) {
         $powerlist = $cat_obj->getFieldInfoByIds($fieldid, ' order by category_name');
     } else {
         $powerlist = array(-1);
     }
     $wheresql = '';
     if (!empty($keywords)) {
         //是否指定keywords
         $wheresql .= " and sendername='{$keywords}' ";
     }
     if ($status !== FALSE) {
         //指定状态
         switch ($status) {
             case 1:
                 //已读
                 $wheresql .= " and hasread=1";
                 break;
             case 2:
                 //未读
                 $wheresql .= " and hasread=0 ";
                 break;
             default:
                 $wheresql .= "";
                 break;
         }
     }
     if ($category !== FALSE) {
         if ($category == -1) {
             $class_sql = implode(', ', $fieldid);
             if (!empty($class_sql)) {
                 $wheresql .= " and fieldId in ({$class_sql})";
             } else {
                 $wheresql .= 'and fieldId in (-1)';
             }
         } else {
             $wheresql .= " and  fieldId={$category}";
         }
     } else {
         $class_sql = implode(', ', $fieldid);
         $wheresql .= " and fieldId in ({$class_sql})";
     }
     if (FALSE !== $orderstatus && '0' != $orderstatus) {
         //设置的订单状态过滤条件
         $orderstatus = strtoupper($orderstatus);
         $orderstatus = mysql_real_escape_string($orderstatus);
         $wheresql .= " and orderstatus='{$orderstatus}'";
     }
     if (!empty($senderId)) {
         //搜索用户id
         $tempsender = mysql_real_escape_string($senderId);
         $wheresql .= " and senderid='{$tempsender}'";
     }
     if (!empty($orderId)) {
         //搜索订单号
         $temporderid = mysql_real_escape_string($orderId);
         $wheresql .= " and orderid='{$temporderid}' ";
     }
     if (!empty($conkeywords)) {
         //搜索订单号
         $temconkey = mysql_real_escape_string($conkeywords);
         $wheresql .= " and content like '%{$temconkey}%' ";
     }
     if (!empty($sellerId)) {
         $temAcc = mysql_real_escape_string($sellerId);
         $wheresql .= " and receiverid = '{$temAcc}' ";
     }
     $urlquery = convertUrlQuery($_SERVER['QUERY_STRING']);
     unset($urlquery['sortname']);
     unset($urlquery['sort']);
     $orderbysql = '';
     $sort = $sort == 'asc' ? 'asc' : 'desc';
     $resort = $sort == 'asc' ? 'desc' : 'asc';
     switch ($sortName) {
         case 'orderstatus':
             //按订单状态排序
             $orderbysql = ' order by orderstatus ' . $sort;
             break;
         default:
             $orderbysql = ' order by createtimestamp ' . $sort;
     }
     $url = getUrlQuery($urlquery);
     $this->smarty->assign('url', $url);
     $this->smarty->assign('resort', $resort);
     // echo $wheresql;exit;
     $pagesize = 100;
     $msg_obj = new messageModel();
     $groupBySql = '';
     if (1 == $isscroll) {
         $groupBySql = ' group by orderid ';
         $mount = $msg_obj->getCountNumberByConditions_aliOrder_groupby($wheresql . $groupBySql);
     } else {
         $mount = $msg_obj->getCountNumberByConditions_aliOrder($wheresql);
     }
     $page_obj = new Page($mount, $pagesize);
     $usercache = new UserCacheModel();
     $acc_ojb = new AliAccountModel();
     if (1 == $isscroll) {
         $msglist = $msg_obj->getMessageListByConditions_aliorder_groupby($wheresql . $groupBySql . ' ' . $orderbysql . ' ' . $page_obj->limit);
     } else {
         $msglist = $msg_obj->getMessageListByConditions_aliorder($wheresql . ' ' . $orderbysql . ' ' . $page_obj->limit);
     }
     /* --- 格式化数据 ---*/
     foreach ($msglist as &$msgitem) {
         $catinfo = $cat_obj->getCategoryInfoById($msgitem['fieldId']);
         $msgitem['classname'] = $catinfo['category_name'];
         $userinfo = empty($msgitem['replyerid']) ? array('userName' => '') : $usercache->getUserInfoBySysId($msgitem['replyerid'], 0);
         $msgitem['username'] = $userinfo['userName'];
         $msgitem['retime'] = $msgitem['replytime'] ? date("Y-m-d \n H:i:s", $msgitem['replytime']) : '';
         $msgitem['content'] = mb_substr($msgitem['content'], 0, 80);
         $msgitem['content'] .= '...';
         $msgitem['replytime'] = empty($msgitem['responsetime']) ? '' : date("Y-m-d \n H:i:s", $msgitem['responsetime']);
         //             $msgitem['createtimestr'] = formateAliTime($msgitem['createtimestr']);
         $msgitem['createtimestr'] = trunToLosangeles('Y-m-d H:i:s', $msgitem['createtimestamp']);
         $msgitem['accname'] = $acc_ojb->accountId2Name($msgitem['receiverid']);
         $msgitem['statusname'] = AliMessageModel::orderStatusToStr($msgitem['orderstatus']);
     }
     if ($mount > $pagesize) {
         //分页
         $pagestr = $page_obj->fpage(array(0, 2, 3, 4, 5, 6, 7, 8, 9));
     } else {
         $pagestr = $page_obj->fpage(array(0, 2, 3));
     }
     $this->smarty->assign('senderId', $senderId);
     $this->smarty->assign('orderId', $orderId);
     $this->smarty->assign('orderstatus', $orderstatus);
     /*----- 获得分类文件夹列表 -----*/
     $categorylist = $cat_obj->getAllCategoryInfoList(' and is_delete=0', 2);
     //         print_r($categorylist);
     $this->smarty->assign('catlist', $categorylist);
     /*----- 获得分类列表 -----*/
     // print_r($msglist);exit;
     $aliAccount_obj = new AliAccountModel();
     $accountlist = $aliAccount_obj->getAllAliAccountList('name', 'asc');
     $this->smarty->assign('accountlist', $accountlist);
     //         print_r($accountlist);exit;
     $this->smarty->assign('sellerId', $sellerId);
     $this->smarty->assign('conkeywords', $conkeywords);
     $this->smarty->assign('third_menue', 1);
     $this->smarty->assign('powerlist', $powerlist);
     $this->smarty->assign('from', $from);
     $this->smarty->assign('sec_menue', 4);
     $this->smarty->assign('toplevel', 0);
     $this->smarty->assign('keywords', $keywords);
     $this->smarty->assign('category', $category);
     $this->smarty->assign('status', $status);
     $this->smarty->assign('pagestr', $pagestr);
     $this->smarty->assign('msglist', $msglist);
     $this->smarty->assign('categorylist', $arrlist);
     $this->smarty->assign('toptitle', 'message列表');
     $this->smarty->display('msglistaliorder.htm');
 }