Exemplo n.º 1
0
 public function view_getAliSiteList()
 {
     $keywords = isset($_GET['keywords']) ? trim($_GET['keywords']) : '';
     //关键字
     $keywords = mysql_real_escape_string($keywords);
     $status = isset($_GET['status']) ? $_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;
     //产品名称
     $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();
     }
     $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($prodname)) {
         $emppro = mysql_real_escape_string($prodname);
         $wheresql .= " and content like '%{$emppro}%'";
     }
     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 relationId ';
         $mount = $msg_obj->getCountNumberByConditions_aliSite_groupby($wheresql . $groupBySql);
     } else {
         $mount = $msg_obj->getCountNumberByConditions_aliSite($wheresql);
     }
     $page_obj = new Page($mount, $pagesize);
     $usercache = new UserCacheModel();
     $aliAcc_ojb = new AliAccountModel();
     if (1 == $isscroll) {
         $msglist = $msg_obj->getMessageListByConditions_alisite_groupby($wheresql . $groupBySql . ' ' . $orderbysql . ' ' . $page_obj->limit);
     } else {
         $msglist = $msg_obj->getMessageListByConditions_alisite($wheresql . ' ' . $orderbysql . ' ' . $page_obj->limit);
     }
     /* --- 格式化数据 ---*/
     foreach ($msglist as &$msgitem) {
         $catinfo = $cat_obj->getCategoryInfoById($msgitem['fieldId']);
         $msgitem['classname'] = $catinfo['category_name'];
         $userinfo = empty($msgitem['replyUser']) ? array('userName' => '') : $usercache->getUserInfoBySysId($msgitem['replyUser'], 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['replytime']) ? '' : date("Y-m-d \n H:i:s", $msgitem['replytime']);
         $msgitem['gmtCreate'] = formateAliTime($msgitem['gmtCreate']);
         $msgitem['accname'] = $aliAcc_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));
     }
     //         print_r($msglist);exit;
     /*----- 获得分类文件夹列表 -----*/
     $categorylist = $cat_obj->getAllCategoryInfoList(' and is_delete=0', 2);
     //         print_r($categorylist);
     $this->smarty->assign('catlist', $categorylist);
     $this->smarty->assign('orderstatus', $orderstatus);
     /*----- 获得分类列表 -----*/
     $aliAccount_obj = new AliAccountModel();
     $accountlist = $aliAccount_obj->getAllAliAccountList('name', 'asc');
     $this->smarty->assign('accountlist', $accountlist);
     $this->smarty->assign('sellerId', $sellerId);
     $this->smarty->assign('senderId', $senderId);
     $this->smarty->assign('orderId', $orderId);
     $this->smarty->assign('prodname', $prodname);
     // print_r($msglist);exit;
     $this->smarty->assign('third_menue', 2);
     $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('msglistalisite.htm');
 }