Ejemplo n.º 1
0
 public function getQuestionDetail($QuestionId)
 {
     //获取问题的ID和父ID
     $QuestionInfo = $this->getComplain($QuestionId, 'id,author,time,qtype,view,status,description,resolve,photo,call_time,call_type,loginId,receive_time,comment,public,assess,sync,rtime');
     //问题获取到
     $CallTypeList = $this->config->CallTypeList;
     //格式化问题内容
     if ($QuestionInfo['id']) {
         //解包压缩数组
         $Comment = unserialize($QuestionInfo['comment']);
         //如果问题分类已经被转换
         if ($Comment['convert']['to_id'] > 0) {
             $QuestionDetail = array('QuestionId' => $Comment['convert']['to_id'], 'QuestionType' => $Comment['convert']['to_type'], 'Transformed' => 1);
         } else {
             $QuestionDetail = array('QuestionId' => intval($QuestionInfo['id']), 'QuestionContent' => $QuestionInfo['description'], 'QuestionResolve' => $QuestionInfo['resolve'], 'AuthorName' => $QuestionInfo['author'], 'QuestionTime' => date("Y-m-d H:i:s", $QuestionInfo['time']), 'QuestionAttatch' => $QuestionInfo['photo'], 'Views' => $QuestionInfo['view'], 'QtypeId' => $QuestionInfo['qtype'], 'CallType' => $QuestionInfo['call_time'] > 0 ? $CallTypeList[$QuestionInfo['call_type']] : "", 'CallTime' => $QuestionInfo['call_time'] > 0 ? date("Y-m-d H:i:s", $QuestionInfo['call_time']) : 0, 'QuestionStauts' => $this->processStatus($QuestionInfo['status']), 'QuestionStatus' => $this->processStatus($QuestionInfo['status']), 'AcceptTime' => date("Y-m-d H:i:s", $QuestionInfo['receive_time']), 'Hidden' => $QuestionInfo['public'], 'AcceptOperatorName' => $QuestionInfo['loginId'], 'AssessStatus' => $QuestionInfo['assess'], "Sync" => $QuestionInfo['sync'], "RevokeTime" => date("Y-m-d H:i:s", $QuestionInfo['rtime']));
             //获取回答内容
             $AnswerInfo = $this->getAnswer($QuestionDetail['QuestionId']);
             //如果获取到回答
             if ($AnswerInfo['id']) {
                 $QuestionDetail['Answer'] = array('OperatorName' => $AnswerInfo['contact'], 'AnswerTime' => date("Y-m-d H:i:s", $AnswerInfo['time']), 'AnswerContent' => $AnswerInfo['content']);
                 $QuestionDetail['AnswerLag'] = Base_Common::timeLagToText($QuestionInfo['time'], $AnswerInfo['time']);
             }
         }
     } else {
         return false;
     }
     return $QuestionDetail;
 }
Ejemplo n.º 2
0
 /**
  *获取日期段的问题数量汇总列表
  */
 public function questionListAction()
 {
     $QuestionTypeList = $this->config->QuestionTypeList;
     $QuestionStatusList = $this->config->QuestionStatusList;
     //基础元素,必须参与验证
     $List['Time'] = abs(intval($this->request->Time));
     $List['QuestionType'] = trim($this->request->QuestionType);
     $List['QuestionStatus'] = abs(intval($this->request->QuestionStatus));
     $List['QtypeId'] = abs(intval($this->request->QtypeId));
     $List['Page'] = abs(intval($this->request->Page));
     $List['PageSize'] = abs(intval($this->request->PageSize));
     //URL验证码
     $sign = $this->request->sign;
     //私钥,以后要移开到数据库存储
     $p_sign = '5173';
     $sign_to_check = base_common::check_sign($List, $p_sign);
     //不参与验证的元素
     //验证URL是否来自可信的发信方
     if ($sign_to_check == $sign) {
         //验证时间戳,时差超过600秒即认为非法
         if (abs($List['Time'] - time()) <= 600) {
             if (isset($QuestionTypeList[$List['QuestionType']])) {
                 if ($List['QtypeId'] >= 0) {
                     $QtypeList = array();
                     $QtypeInfo = $this->oQtype->getQtypeById($List['QtypeId']);
                     if ($QtypeInfo['id'] && $QtypeInfo['visiable'] || $List['QtypeId'] == 0) {
                         $time = time();
                         $List['EndDate'] = date("Y-m-d", $time);
                         if ($List['QuestionType'] == "complain") {
                             $List['StartDate'] = date("Y-m-01", strtotime("-1 month", $time));
                         } else {
                             $List['StartDate'] = date("Y-m-01", strtotime("-1 month", $time));
                         }
                         //查询当前正在生效的公告列表
                         $oMenCache = new Base_Cache_Memcache("Complaint");
                         $M = $oMenCache->get('NewQuestionNumList_' . $List['StartDate'] . '_' . $List['EndDate'] . '_' . $List['QuestionType'] . '_' . $List['QtypeId'] . '_' . $List['QuestionStatus'] . '_' . $List['Page'] . '_' . $List['PageSize']);
                         if ($M) {
                             $QuestionList = json_decode($M, true);
                         } else {
                             switch ($List['QuestionType']) {
                                 //咨询
                                 case "ask":
                                     $List['Parent'] = 0;
                                     $List['Revocation'] = 0;
                                     $List['hidden'] = 1;
                                     $QuestionList = $this->oQuestion->getQuestionList($List, "id,description,time,atime,status,qtype");
                                     foreach ($QuestionList['QuestionList'] as $key => $QuestionInfo) {
                                         //生成问题链接
                                         $QuestionList['QuestionList'][$key]['QuestionUrl'] = $this->oQuestion->getQuestionLink($QuestionInfo['id'], "question");
                                         //生成问题状态
                                         if ($QuestionInfo['status'] == 1) {
                                             $QuestionList['QuestionList'][$key]['QuestionStatus'] = 1;
                                         } else {
                                             $QuestionList['QuestionList'][$key]['QuestionStatus'] = 2;
                                         }
                                     }
                                     break;
                                     //建议
                                 //建议
                                 case "suggest":
                                     $List['Parent'] = 0;
                                     $List['Revocation'] = 0;
                                     $List['hidden'] = 1;
                                     $QuestionList = $this->oQuestion->getQuestionList($List, "id,description,time,atime,status,qtype");
                                     foreach ($QuestionList['QuestionList'] as $key => $QuestionInfo) {
                                         //生成问题链接
                                         $QuestionList['QuestionList'][$key]['QuestionUrl'] = $this->oQuestion->getQuestionLink($QuestionInfo['id'], "question");
                                         //生成问题状态
                                         if ($QuestionInfo['status'] == 1) {
                                             $QuestionList['QuestionList'][$key]['QuestionStatus'] = 1;
                                         } else {
                                             $QuestionList['QuestionList'][$key]['QuestionStatus'] = 2;
                                         }
                                     }
                                     break;
                                     //投诉
                                 //投诉
                                 case "complain":
                                     $List['Public'] = 0;
                                     $QuestionList = $this->oComplain->getComplainList($List, "id,description,time,atime,status,qtype");
                                     foreach ($QuestionList['QuestionList'] as $key => $QuestionInfo) {
                                         //生成问题链接
                                         $QuestionList['QuestionList'][$key]['QuestionUrl'] = $this->oComplain->getQuestionLink($QuestionInfo['id'], "complain");
                                         //生成问题状态
                                         if (in_array($QuestionInfo['status'], array(0, 4))) {
                                             $QuestionList['QuestionList'][$key]['QuestionStatus'] = 1;
                                         } elseif (in_array($QuestionInfo['status'], array(1, 3))) {
                                             $QuestionList['QuestionList'][$key]['QuestionStatus'] = 2;
                                         }
                                         if ($QuestionInfo['status'] == 2) {
                                             $QuestionList['QuestionList'][$key]['QuestionStatus'] = 3;
                                         }
                                     }
                                     break;
                             }
                             $QtypeList = array();
                             foreach ($QuestionList['QuestionList'] as $key => $QuestionInfo) {
                                 //获取问题分类
                                 $CategoryInfo = $this->oCategory->getCategoryByQuestionType($List['QuestionType'], 'name');
                                 //获取问题主分类
                                 $QuestionList['QuestionList'][$key]['QuestionType'] = $CategoryInfo['name'];
                                 if (!isset($QtypeList[$QuestionInfo['qtype']])) {
                                     $QtypeList[$QuestionInfo['qtype']] = $this->oQtype->getQtypeById($QuestionInfo['qtype']);
                                 }
                                 $QuestionList['QuestionList'][$key]['Qtype'] = $QtypeList[$QuestionInfo['qtype']]['name'];
                                 //格式化提问时间
                                 $QuestionList['QuestionList'][$key]['AddTime'] = date("Y-m-d H:i", $QuestionInfo['time']);
                                 //格式化回答时间
                                 $QuestionList['QuestionList'][$key]['AnswerTimeLag'] = $QuestionInfo['QuestionStatus'] >= 2 && $QuestionInfo['atime'] ? Base_Common::timeLagToText($QuestionInfo['time'], $QuestionInfo['atime']) : "-";
                                 //获取问题状态名称
                                 $QuestionList['QuestionList'][$key]['QuestionStatusName'] = $QuestionStatusList[$QuestionInfo['QuestionStatus']];
                                 //格式化问题内容
                                 $QuestionList['QuestionList'][$key]['Content'] = Base_Common::cutstr($QuestionInfo['description'], 14);
                                 unset($QuestionInfo['description']);
                             }
                             $oMenCache->set('NewQuestionNumList_' . $List['StartDate'] . '_' . $List['EndDate'] . '_' . $List['QuestionType'] . '_' . $List['QtypeId'] . '_' . $List['QuestionStatus'] . '_' . $List['Page'] . '_' . $List['PageSize'], json_encode($QuestionList), 10);
                         }
                         $result = array('return' => 1, 'QuestionList' => $QuestionList);
                     } else {
                         $result = array('return' => 0, 'comment' => "无此问题主分类");
                     }
                 }
             } else {
                 $result = array('return' => 0, 'comment' => "无此问题分类");
             }
         } else {
             $result = array('return' => 0, 'comment' => "时间有误");
         }
     } else {
         $result = array('return' => 0, 'comment' => "验证失败,请检查URL");
     }
     echo json_encode($result);
 }
Ejemplo n.º 3
0
 /**
  *根据cookie信息获取未登录用户的服务记录数量
  */
 public function serviceLogUnloggedAction()
 {
     //基础元素,必须参与验证
     $User['QuickAsk'] = urldecode(trim($this->request->QuickAsk));
     $User['Time'] = abs(intval($this->request->Time));
     $User['NewCount'] = abs(intval($this->request->NewCount)) ? abs(intval($this->request->NewCount)) : 3;
     //URL验证码
     $sign = $this->request->sign;
     //私钥,以后要移开到数据库存储
     $p_sign = '5173';
     $sign_to_check = base_common::check_sign($User, $p_sign);
     //不参与验证的元素
     $oMenCache = new Base_Cache_Memcache("Complaint");
     $QuestionStatusList = $this->config->QuestionStatusList;
     $QuestionTypeList = $this->config->QuestionTypeList;
     //验证URL是否来自可信的发信方
     if ($sign_to_check == $sign) {
         //验证时间戳,时差超过600秒即认为非法
         if (abs($User['Time'] - time()) <= 600) {
             //初始化结果数组
             $QuestionTypeArr = array('ask', 'suggest', 'complain');
             foreach ($QuestionTypeArr as $key => $value) {
                 $CategoryInfo = $this->oCategory->getCategoryByQuestionType($value, 'name');
                 $ServiceNum[$value] = array('Num' => 0, 'Content' => "我的" . $CategoryInfo['name'] . "记录");
             }
             $NewLog = array();
             $ask_type = unserialize(stripslashes($User['QuickAsk']));
             $IdArr = array($ask_type['zx'], $ask_type['jy']);
             foreach ($IdArr as $key => $value) {
                 if (trim($value) == "") {
                     unset($IdArr[$key]);
                 }
             }
             if (count($IdArr)) {
                 //获取咨询数量
                 $ServiceNum['ask']['List'] = $this->oQuestion->getServiceQuestionList(array('IdList' => implode(",", $IdArr), 'QuestionType' => 'ask', 'Parent' => 0, 'Revocation' => 0));
                 $ServiceNum['ask']['Num'] = count($ServiceNum['ask']['List']);
                 //从缓存服务器上获取是否有新未读数据
                 foreach ($ServiceNum['ask']['List'] as $key => $QuestionInfo) {
                     $M = $oMenCache->get('fw' . $QuestionInfo['QuestionId']);
                     if ($M) {
                         $ServiceNum['ask']['New'] = 1;
                     }
                     //echo $QuestionInfo['QuestionId']."-".$QuestionInfo['status']."<br>";
                     if ($QuestionInfo['status'] == 1) {
                         $NewLog[$QuestionInfo['time']][] = array('QuestionId' => $QuestionInfo['QuestionId'], 'QuestionType' => 'ask');
                     }
                 }
                 unset($ServiceNum['ask']['List']);
                 //获取建议数量
                 $ServiceNum['suggest']['List'] = $this->oQuestion->getServiceQuestionList(array('IdList' => implode(",", $IdArr), 'QuestionType' => 'suggest', 'Parent' => 0, 'Revocation' => 0));
                 $ServiceNum['suggest']['Num'] = count($ServiceNum['suggest']['List']);
                 //从缓存服务器上获取是否有新未读数据
                 foreach ($ServiceNum['suggest']['List'] as $key => $QuestionInfo) {
                     $M = $oMenCache->get('fw' . $QuestionInfo['QuestionId']);
                     if ($M) {
                         $ServiceNum['suggest']['New'] = 1;
                     }
                     if ($QuestionInfo['status'] == 1) {
                         $NewLog[$QuestionInfo['time']][] = array('QuestionId' => $QuestionInfo['QuestionId'], 'QuestionType' => 'suggest');
                     }
                 }
                 unset($ServiceNum['suggest']['List']);
             } else {
                 $ServiceNum['ask']['Num'] = 0;
                 $ServiceNum['suggest']['Num'] = 0;
             }
             $IdList = $ask_type['ts'];
             if (count(explode(',', $IdList)) >= 1 && $IdList != "") {
                 //获取投诉数量
                 $ServiceNum['complain']['List'] = $this->oComplain->getComplainServiceList(array('IdList' => $IdList, 'Public' => '0,2'));
                 $ServiceNum['complain']['Num'] = count($ServiceNum['complain']['List']);
                 //从缓存服务器上获取是否有新未读数据
                 foreach ($ServiceNum['complain']['List'] as $key => $QuestionInfo) {
                     $M = $oMenCache->get('ts' . $QuestionInfo['QuestionId']);
                     if ($M) {
                         $ServiceNum['complain']['New'] = 1;
                     }
                     if (in_array($QuestionInfo['status'], array(0, 4))) {
                         $NewLog[$QuestionInfo['time']][] = array('QuestionId' => $QuestionInfo['QuestionId'], 'QuestionType' => 'complain');
                     }
                 }
                 unset($ServiceNum['complain']['List']);
             } else {
                 $ServiceNum['complain']['Num'] = 0;
             }
             krsort($NewLog);
             $i = 0;
             $NewServiceList = array();
             foreach ($NewLog as $Time => $TimeList) {
                 foreach ($TimeList as $key => $Question) {
                     if ($i < $User['NewCount']) {
                         switch ($Question['QuestionType']) {
                             case "ask":
                                 $QuestionInfo = $this->oQuestion->getQuestion($Question['QuestionId'], "id,description,time,atime,status,qtype");
                                 //生成问题链接
                                 $QuestionInfo['QuestionUrl'] = $this->oQuestion->getQuestionLink($QuestionInfo['id'], "question");
                                 //复制问题分类
                                 $QuestionInfo['QuestionType'] = $Question['QuestionType'];
                                 //生成问题状态
                                 if ($QuestionInfo['status'] == 1) {
                                     $QuestionInfo['QuestionStatus'] = 1;
                                 } else {
                                     $QuestionInfo['QuestionStatus'] = 2;
                                 }
                                 $NewServiceList[] = $QuestionInfo;
                                 break;
                             case "suggest":
                                 $QuestionInfo = $this->oQuestion->getQuestion($Question['QuestionId'], "id,description,time,atime,status,qtype");
                                 //生成问题链接
                                 $QuestionInfo['QuestionUrl'] = $this->oQuestion->getQuestionLink($QuestionInfo['id'], "question");
                                 //复制问题分类
                                 $QuestionInfo['QuestionType'] = $Question['QuestionType'];
                                 //生成问题状态
                                 if ($QuestionInfo['status'] == 1) {
                                     $QuestionInfo['QuestionStatus'] = 1;
                                 } else {
                                     $QuestionInfo['QuestionStatus'] = 2;
                                 }
                                 $NewServiceList[] = $QuestionInfo;
                                 break;
                             case "complain":
                                 $QuestionInfo = $this->oComplain->getComplain($Question['QuestionId'], "id,description,time,atime,status,qtype");
                                 //生成问题链接
                                 $QuestionInfo['QuestionUrl'] = $this->oComplain->getQuestionLink($QuestionInfo['id'], "complain");
                                 //复制问题分类
                                 $QuestionInfo['QuestionType'] = $Question['QuestionType'];
                                 //生成问题状态
                                 if (in_array($QuestionInfo['status'], array(0, 4))) {
                                     $QuestionInfo['QuestionStatus'] = 1;
                                 } elseif (in_array($QuestionInfo['status'], array(1, 3))) {
                                     $QuestionInfo['QuestionStatus'] = 2;
                                 }
                                 if ($QuestionInfo['status'] == 2) {
                                     $QuestionInfo['QuestionStatus'] = 3;
                                 }
                                 $NewServiceList[] = $QuestionInfo;
                                 break;
                         }
                     }
                     $i++;
                 }
             }
             foreach ($NewServiceList as $key => $QuestionInfo) {
                 if (!isset($QtypeList[$QuestionInfo['qtype']])) {
                     $QtypeList[$QuestionInfo['qtype']] = $this->oQtype->getQtypeById($QuestionInfo['qtype']);
                 }
                 $NewServiceList[$key]['Qtype'] = $QtypeList[$QuestionInfo['qtype']]['name'];
                 //格式化提问时间
                 $NewServiceList[$key]['AddTime'] = date("Y-m-d H:i", $QuestionInfo['time']);
                 //格式化回答时间
                 $NewServiceList[$key]['AnswerTimeLag'] = $QuestionInfo['QuestionStatus'] >= 2 && $QuestionInfo['atime'] ? Base_Common::timeLagToText($QuestionInfo['time'], $QuestionInfo['atime']) : "-";
                 //获取问题状态名称
                 $NewServiceList[$key]['QuestionStatusName'] = $QuestionStatusList[$QuestionInfo['QuestionStatus']];
                 //格式化问题内容
                 $NewServiceList[$key]['Content'] = Base_Common::cutstr($QuestionInfo['description'], 14);
                 //获取问题分类
                 $CategoryInfo = $QuestionTypeList[$QuestionInfo['QuestionType']];
                 //获取问题主分类
                 $NewServiceList[$key]['QuestionType'] = $CategoryInfo;
                 unset($NewServiceList[$key]['description']);
             }
             //服务记录详情页面信息
             $ServiceLogDetail = array('Url' => 'http://sc.5173.com/index.php?question/my_ask.html', 'Content' => '查看全部服务记录');
             //入口信息
             $ServiceEntrance = array('Url' => 'http://sc.5173.com/index.php?question/ask_skip.html', 'Content' => '我要提问');
             $result = array('return' => 1, 'ServiceNum' => $ServiceNum, 'ServiceLogDetail' => $ServiceLogDetail, 'ServiceEntrance' => $ServiceEntrance, 'NewServiceList' => $NewServiceList);
         } else {
             $result = array('return' => 0, 'comment' => "时间有误");
         }
     } else {
         $result = array('return' => 0, 'comment' => "验证失败,请检查URL");
     }
     echo json_encode($result);
 }
Ejemplo n.º 4
0
 public function getQuestionDetail($QuestionId, $History = 0)
 {
     //获取问题的ID和父ID
     $QuestionInfo = $this->getQuestion($QuestionId, 'id,pid', $History);
     //问题获取到
     if ($QuestionInfo['id']) {
         //如果问题父ID大于0,为追问
         if ($QuestionInfo['pid']) {
             $ParentID = $QuestionInfo['pid'];
         } else {
             $ParentID = $QuestionInfo['id'];
         }
         //获取主问内容
         $ParentInfo = $this->getQuestion($ParentID, 'id,author,time,cid,cid1,qtype,attach,views,status,description,is_pj,comment,hidden', $History);
         //解包压缩数组
         $Comment = unserialize($ParentInfo['comment']);
         //如果问题分类已经被转换
         if ($Comment['convert']['to_id'] > 0) {
             $QuestionDetail = array('QuestionId' => $Comment['convert']['to_id'], 'QuestionType' => $Comment['convert']['to_type'], 'Transformed' => 1);
         } else {
             //格式化问题内容
             $QuestionDetail = array('QuestionId' => intval($ParentInfo['id']), 'QuestionContent' => $ParentInfo['description'], 'AuthorName' => $ParentInfo['author'], 'QuestionTime' => date("Y-m-d H:i:s", $ParentInfo['time']), 'QuestionAttatch' => $ParentInfo['attach'], 'Views' => $ParentInfo['views'], 'CatagoryId' => $ParentInfo['cid'], 'QtypeId' => $ParentInfo['qtype'], 'QuestionStauts' => $this->processStatus($ParentInfo['status']), 'QuestionStatus' => $this->processStatus($ParentInfo['status']), 'SubQuestion' => 0, 'AssessStatus' => $ParentInfo['is_pj'], 'AssessCount' => intval($Comment['assess_num']), 'Hidden' => $ParentInfo['hidden'], 'Assess' => $ParentInfo['is_pj'] == 1 ? 0 : 1, 'SubQuestionList' => array());
             //获取回答内容
             $AnswerInfo = $this->getAnswer($QuestionDetail['QuestionId'], "*", $History);
             //如果获取到回答
             if ($AnswerInfo['id']) {
                 //可以继续追问
                 $QuestionDetail['SubQuestion'] = 1;
                 //可以评价
                 $QuestionDetail['Assess'] = $QuestionDetail['Assess'] == 0 ? 0 : 1;
                 //格式化回答内容
                 $QuestionDetail['Answer'] = array('OperatorName' => $AnswerInfo['author'], 'AnswerTime' => date("Y-m-d H:i:s", $AnswerInfo['time']), 'AnswerContent' => $AnswerInfo['content']);
                 $QuestionDetail['AnswerLag'] = Base_Common::timeLagToText($ParentInfo['time'], $AnswerInfo['time']);
             }
             //获取追问信息
             $SubQuestionList = $this->getQuestionList(array('Accepted' => -1, 'Parent' => $ParentID, 'Revocation' => -1, 'Help' => -1, 'History' => $History, 'QuestionType' => "ask,suggest"), 'id,time,cid,cid1,qtype,attach,views,status,description', 'asc');
             $QuestionDetail['SubQuestionList'] = array();
             if (count($SubQuestionList['QuestionNum']) > 0) {
                 foreach ($SubQuestionList['QuestionList'] as $key => $SubQuestion) {
                     //格式化追问内容
                     $QuestionDetail['SubQuestionList'][$key] = array('QuestionId' => intval($SubQuestion['id']), 'QuestionContent' => $SubQuestion['description'], 'QuestionTime' => date("Y-m-d H:i:s", $SubQuestion['time']), 'QuestionStauts' => $this->processStatus($SubQuestion['status']), 'QuestionStatus' => $this->processStatus($SubQuestion['status']));
                     //获取追问回答内容
                     $AnswerInfo = $this->getAnswer($SubQuestion['id'], "*", $History);
                     //如果获取到回答
                     if ($AnswerInfo['id']) {
                         //可以继续追问
                         $QuestionDetail['SubQuestion'] = 1;
                         //格式化追问回答内容
                         $QuestionDetail['SubQuestionList'][$key]['Answer'] = array('OperatorName' => $AnswerInfo['author'], 'AnswerTime' => date("Y-m-d H:i:s", $AnswerInfo['time']), 'AnswerContent' => $AnswerInfo['content']);
                         $QuestionDetail['SubQuestionList'][$key]['AnswerLag'] = Base_Common::timeLagToText($SubQuestion['time'], $AnswerInfo['time']);
                     } else {
                         //不可继续追问
                         $QuestionDetail['SubQuestion'] = 0;
                     }
                 }
             }
         }
         //如果是历史数据
         if ($History > 0) {
             //不可继续追问
             $QuestionDetail['SubQuestion'] = 0;
             //不可评价
             $QuestionDetail['Assess'] = 0;
         }
         return $QuestionDetail;
     } else {
         return false;
     }
 }