/**
  *获取当前正在生效的常用问题
  */
 public function commonQuestionAction()
 {
     //基础元素,必须参与验证
     $Common['Time'] = abs(intval($this->request->Time));
     $Common['Count'] = abs(intval($this->request->Count));
     //URL验证码
     $sign = $this->request->sign;
     //私钥,以后要移开到数据库存储
     $p_sign = '5173';
     $sign_to_check = base_common::check_sign($Common, $p_sign);
     //不参与验证的元素
     //验证URL是否来自可信的发信方
     if ($sign_to_check == $sign) {
         //验证时间戳,时差超过600秒即认为非法
         if (abs($Common['Time'] - time()) <= 600) {
             //查询当前正在生效的公告列表
             $oMenCache = new Base_Cache_Memcache("Complaint");
             $M = $oMenCache->get('CurrentBoradCast_' . $Common['Count']);
             if ($M) {
                 $CommonQustionList = json_decode($M, true);
             } else {
                 $CommonQustionList = $this->oBroadCast->getCurrentCommonQustion($Common, "url as Url,title as Content");
                 $oMenCache->set('CurrentBoradCast_' . $Common['Count'], json_encode($CommonQustionList), 3600);
             }
             $result = array('return' => 1, 'CommonQustionList' => $CommonQustionList);
         } else {
             $result = array('return' => 0, 'comment' => "时间有误");
         }
     } else {
         $result = array('return' => 0, 'comment' => "验证失败,请检查URL");
     }
     echo json_encode($result);
 }
Example #2
0
 /**
  *角色信息生成
  */
 public function indexAction()
 {
     echo "<pre>";
     var_dump($_GET);
     echo 223;
     $oApp = new Lm_DB1_DB1();
     $oApp->test($this->request->word);
     $oMenCache = new Base_Cache_Memcache("server");
     //		$oMenCache -> set('a',1,100);
     //		$oMenCache -> set('b',2,100);
     print_r($oMenCache->get(array('a', 'b')));
 }
Example #3
0
 public function getCategoryByQuestionType($QuestionType)
 {
     $oMenCache = new Base_Cache_Memcache("Complaint");
     $M = $oMenCache->get('Category_Type_' . $QuestionType);
     if ($M) {
         $Category = json_decode($M, true);
     } else {
         $table_to_process = Base_Widget::getDbTable($this->table);
         $Category = $this->db->selectRow($table_to_process, "*", '`question_type`=?', array($QuestionType));
         $oMenCache->set('Category_Type_' . $QuestionType, json_encode($Category), 3600);
     }
     return $Category;
 }
Example #4
0
 public function processOperatorInfo($OperatorInfo)
 {
     //获取全局配置
     $oMenCache = new Base_Cache_Memcache("Complaint");
     $Setting = $oMenCache->get('setting');
     $NewOperatorInfo = array();
     if (isset($OperatorInfo['id'])) {
         $NewOperatorInfo['OperatorId'] = $OperatorInfo['id'];
         $NewOperatorInfo['ServiceLogUrl'] = $this->config->ScUrl . "/?question/selfHistoryQuestion/" . urlencode($OperatorInfo['login_name']);
     }
     if (isset($OperatorInfo['login_name'])) {
         $NewOperatorInfo['OperatorName'] = $OperatorInfo['login_name'];
     }
     if (isset($OperatorInfo['cno'])) {
         $NewOperatorInfo['Cno'] = $OperatorInfo['cno'];
     }
     if (isset($OperatorInfo['name'])) {
         $NewOperatorInfo['NickName'] = $OperatorInfo['name'];
     }
     if (isset($OperatorInfo['photo'])) {
         $NewOperatorInfo['PhotoLink'] = strlen(trim($OperatorInfo['photo'])) >= 1 ? trim($OperatorInfo['photo']) : $this->config->DefaultOperatorPic;
     }
     if (isset($OperatorInfo['tel']) && $Setting['telDisplay']) {
         $NewOperatorInfo['Tel'] = $OperatorInfo['tel'];
     }
     if (isset($OperatorInfo['mobile'])) {
         $NewOperatorInfo['Mobile'] = Base_Common::convertPhoneNum($OperatorInfo['mobile']);
     }
     if (isset($OperatorInfo['weixin'])) {
         $NewOperatorInfo['Weixin'] = $OperatorInfo['weixin'];
         $NewOperatorInfo['WeixinPhotoLink'] = $OperatorInfo['weixinPicUrl'];
     }
     if (isset($OperatorInfo['xnGroupId']) && $Setting['xnDisplay']) {
         $NewOperatorInfo['xn']['xnGroupId'] = $OperatorInfo['xnGroupId'];
         $XNDefault = $this->getXNDefault();
         $NewOperatorInfo['xn']['xnSiteId'] = $XNDefault['xnSiteId'];
         $NewOperatorInfo['xn']['xnSellerId'] = $XNDefault['xnSellerId'];
         $NewOperatorInfo['xn']['xnDefaultSettingId'] = $XNDefault['xnDefaultSettingId'];
     } else {
         if (isset($OperatorInfo['QQ']) && $Setting['qqDisplay']) {
             $NewOperatorInfo['QQ'] = $OperatorInfo['QQ'];
         }
     }
     return $NewOperatorInfo;
 }
Example #5
0
 /**
  *获取当前正在生效的公告列表
  */
 public function quicklinkAction()
 {
     //基础元素,必须参与验证
     $QuickLink['Time'] = abs(intval($this->request->Time));
     $QuickLink['LinkType'] = trim($this->request->LinkType);
     //URL验证码
     $sign = $this->request->sign;
     //私钥,以后要移开到数据库存储
     $p_sign = '5173';
     $sign_to_check = base_common::check_sign($QuickLink, $p_sign);
     //不参与验证的元素
     //验证URL是否来自可信的发信方
     if ($sign_to_check == $sign) {
         //验证时间戳,时差超过600秒即认为非法
         if (abs($QuickLink['Time'] - time()) <= 600) {
             //查询当前正在生效的公告列表
             $oMenCache = new Base_Cache_Memcache("Complaint");
             $M = $oMenCache->get('QuickLink_' . $QuickLink['LinkType']);
             if ($M) {
                 $ParentQuickLink = json_decode($M, true);
             } else {
                 $ParentQuickLink = $this->oQuickLink->getQuickLinkByType($QuickLink['LinkType'], "LinkName,LinkUrl,LinkIcon,Id");
                 if ($ParentQuickLink['Id']) {
                     $ParentQuickLink['QuickLinkList'] = $this->oQuickLink->getQuickLinkByParent($ParentQuickLink['Id'], "LinkName,LinkUrl,LinkIcon,Id");
                     $oMenCache->set('QuickLink_' . $QuickLink['LinkType'], json_encode($ParentQuickLink), 3600);
                 } else {
                     $result = array('return' => 0, 'comment' => "无此分类");
                 }
             }
             $result = array('return' => 1, 'QuickLinkList' => $ParentQuickLink);
             //echo "<pre>";
             //print_R($ParentQuickLink);
         } else {
             $result = array('return' => 0, 'comment' => "时间有误");
         }
     } else {
         $result = array('return' => 0, 'comment' => "验证失败,请检查URL");
     }
     echo json_encode($result);
 }
Example #6
0
 function QuestionApply_Timeout_Add()
 {
     $oMenCache = new Base_Cache_Memcache("Complaint");
     $Setting = $oMenCache->get('setting');
     sleep(1);
     $this->oCommon->addSystemLog(0, "system", "system", 2, "系统追问超时自动分单开始");
     //系统操作日志
     sleep(1);
     $AcceptableOperatorList = $this->oOperator->getAcceptableOperator(1);
     $PostList = $this->oOperator->getAllPost("id,timeout");
     foreach ($PostList as $key => $PostInfo) {
         if ($PostInfo['timeout'] > 0) {
             $OperatorList = $this->oOperator->getOperatorByPost($PostInfo['id'], $fields = 'login_name');
             if (count($OperatorList) > 0) {
                 //获取超时的首问列表
                 $timeoutQuestionList = $this->oQuestion->getAppliedUnAnsweredQuestionList(0, $OperatorList, $Setting['helpReApply'], $PostInfo['timeout'], 1);
                 //如果有取到单子
                 if (is_array($timeoutQuestionList['QuestionList'])) {
                     //依次尝试分单
                     foreach ($timeoutQuestionList['QuestionList'] as $key2 => $QuestionInfo) {
                         //取消分单
                         $Cancel = $this->oQuestion->ApplyCancel($QuestionInfo['id']);
                         echo "Cancel:" . intval($Cancel) . "\n";
                         if ($Cancel) {
                             //写日志
                             $this->oCommon->addSystemLog($QuestionInfo['id'], $QuestionInfo['author'], $QuestionInfo['js_kf'], 11, '系统取消了分单给' . $QuestionInfo['js_kf'] . '的咨询问题,撤单原因:' . $PostInfo['timeout'] . '秒超时');
                             //系统操作日志
                             //更新目前的数量
                             $AcceptableOperatorList['operator'][$QuestionInfo['js_kf']]['handling']--;
                             $AcceptableOperatorList['operator'][$QuestionInfo['js_kf']]['last']++;
                             //生成一个可接单客服列表副本
                             $tmp = $AcceptableOperatorList;
                             //不分给当前接这个单的客服
                             unset($tmp['operator'][$QuestionInfo['js_kf']]);
                             //在余下的客服中选取一个
                             $AcceptableOperator = $this->oOperator->getMaxAcceptableOperator($tmp);
                             if ($AcceptableOperator['operator'] != "") {
                                 //分单结果
                                 $Apply = $this->oQuestion->ApplyToOperator($QuestionInfo['id'], $AcceptableOperator['operator']);
                                 echo "Apply:" . intval($Apply) . "\n";
                                 //不论是否成功,本轮次不再对此单进行分单
                                 unset($unAppliedQuestionList['QuestionList'][$key]);
                                 if ($Apply) {
                                     //写日志
                                     $this->oCommon->addSystemLog($QuestionInfo['id'], $QuestionInfo['author'], $AcceptableOperator['operator'], 2, '系统分单给了' . $AcceptableOperator['operator']);
                                     //系统操作日志
                                     //更新目前的数量
                                     $AcceptableOperatorList['operator'][$AcceptableOperator['operator']]['handling']++;
                                     $AcceptableOperatorList['operator'][$AcceptableOperator['operator']]['last']--;
                                     $AcceptableOperatorList['operator'][$AcceptableOperator['operator']]['last_receive'] = time();
                                     //$AcceptableOperatorList['last_accept'] = $AcceptableOperatorList['operator'][$AcceptableOperator['operator']];
                                     $AcceptableOperatorList['last_accept']['operator'] = $AcceptableOperator['operator'];
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Example #7
0
 /**
  *追问
  */
 public function rebuildQuestionDetailTestAction()
 {
     //基础元素,必须参与验证
     $Question['QuestionId'] = abs(intval($this->request->QuestionId));
     $Question['QuestionType'] = urldecode(trim($this->request->QuestionType));
     $Question['Time'] = abs(intval($this->request->Time));
     $oMenCache = new Base_Cache_Memcache("Complaint");
     print_R($Question);
     $M = $oMenCache->get('QuestionDetail_' . $Question['QuestionType'] . "_" . $Question['QuestionId']);
     $QuestionDetail = json_decode($M, true);
     echo "QuestionDetail:" . "<br>";
     print_R($QuestionDetail);
 }
Example #8
0
 public function ProcessComplainDetail($Complain)
 {
     $oMenCache = new Base_Cache_Memcache("Complaint");
     $Setting = $oMenCache->get('setting');
     $oCategory = new Kubao_Category();
     $oOperator = new Kubao_Operator();
     $oQtype = new Kubao_Qtype();
     $QuestionDetail = $this->GetQuestionDetail($Complain['QuestionId']);
     //获取到问题详情
     if ($QuestionDetail['QuestionId'] > 0) {
         //如果问题尚未被转换分类
         if ($QuestionDetail['Transformed'] != 1) {
             //如果问题被设置为隐藏
             if ($QuestionDetail['Hidden'] == 1) {
                 return $QuestionDetail;
             } else {
                 $QuestionType = "complain";
                 //获取问题分类内容
                 $CategoryInfo = $oCategory->getCategoryByQuestionType($QuestionType);
                 $QuestionDetail['CategoryName'] = $CategoryInfo['id'] ? $CategoryInfo['name'] : "未设置分类";
                 $QuestionDetail['QuestionType'] = ucfirst($QuestionType);
                 $QuestionDetail['PageTitle'] = $QuestionDetail['CategoryName'] . "详情";
                 //获取问题主分类内容
                 $QtypeInfo = $oQtype->getQtypeById($QuestionDetail['QtypeId'], 'id,name');
                 $QuestionDetail['QtypeName'] = $QtypeInfo['id'] ? $QtypeInfo['name'] : "未设置分类";
                 //如果回答中包含客服账号
                 if ($QuestionDetail['Answer']['OperatorName']) {
                     $List = 'id,photo,login_name,cno,QQ,mobile,weixin,weixinPicUrl,tel,name';
                     $M = $oMenCache->get('OperatorInfo_' . $QuestionDetail['Answer']['OperatorName'] . "_" . md5($List));
                     if ($M) {
                         $OperatorInfo = json_decode($M, true);
                         //如果获取到的客服信息不合法
                         if (!$OperatorInfo['login_name']) {
                             //从主站获取客服信息
                             $OperatorInfo = $oOperator->getOperatorFromVadmin($QuestionDetail['Answer']['OperatorName'], $List);
                             $OperatorInfo = $oOperator->processOperatorInfo($OperatorInfo);
                         }
                     } else {
                         //从主站获取客服信息
                         $OperatorInfo = $oOperator->getOperatorFromVadmin($QuestionDetail['Answer']['OperatorName'], $List);
                         //如果没有从主站获取到客服信息
                         if ($OperatorInfo['login_name']) {
                             //格式化显示信息
                             $OperatorInfo = $oOperator->processOperatorInfo($OperatorInfo);
                             $oMenCache->set('OperatorInfo_' . $QuestionDetail['Answer']['OperatorName'] . "_" . md5($List), json_encode($OperatorInfo), 60);
                         }
                     }
                     //如果获取到的客服信息合法
                     if ($OperatorInfo['OperatorName']) {
                         $oMenCache->set('OperatorInfo_' . $QuestionDetail['Answer']['OperatorName'] . "_" . md5($List), json_encode($OperatorInfo), 60);
                         $QuestionDetail['Answer']['OperatorInfo'] = $OperatorInfo;
                     } else {
                         unset($QuestionDetail['Answer']['OperatorInfo']);
                     }
                 }
                 //如果包含接单客服账号
                 if ($QuestionDetail['AcceptOperatorName']) {
                     $List = 'id,photo,login_name,cno,QQ,mobile,weixin,weixinPicUrl,tel,name';
                     //$M = $oMenCache -> get('OperatorInfo_'.$QuestionDetail['AcceptOperatorName']."_".md5($List));
                     if ($M) {
                         $OperatorInfo = json_decode($M, true);
                         //如果获取到的客服信息不合法
                         if (!$OperatorInfo['login_name']) {
                             //从主站获取客服信息
                             $OperatorInfo = $oOperator->getOperatorFromVadmin($QuestionDetail['AcceptOperatorName'], $List);
                             $OperatorInfo = $oOperator->processOperatorInfo($OperatorInfo);
                         }
                     } else {
                         //从主站获取客服信息
                         $OperatorInfo = $oOperator->getOperatorFromVadmin($QuestionDetail['AcceptOperatorName'], $List);
                         //如果没有从本地获取到客服信息
                         if ($OperatorInfo['login_name']) {
                             //格式化显示信息
                             $OperatorInfo = $oOperator->processOperatorInfo($OperatorInfo);
                         }
                     }
                     //如果获取到的客服信息合法
                     if ($OperatorInfo['OperatorName']) {
                         $oMenCache->set('OperatorInfo_' . $QuestionDetail['AcceptOperatorName'] . "_" . md5($List), json_encode($OperatorInfo), 60);
                         $QuestionDetail['AcceptOperatorInfo'] = $OperatorInfo;
                     } else {
                         unset($QuestionDetail['AcceptOperatorInfo']);
                     }
                 }
                 //如果问题状态为 已同步至投诉 并且 状态不是已撤销 并且 问题状态未初始创建 或者 开关允许任何状态撤销
                 if ($QuestionDetail['Sync'] == 1 && $QuestionDetail['QuestionStauts'] != 5 && $QuestionDetail['QuestionStatus'] != 5 && ($QuestionDetail['QuestionStauts'] == 0 || $QuestionDetail['QuestionStatus'] == 0 || $Setting['complainSwitch'])) {
                     //允许问题撤销
                     $QuestionDetail['Revoke'] = 1;
                 }
                 unset($QuestionDetail['CatagoryId'], $QuestionDetail['QtypeId']);
                 return $QuestionDetail;
             }
         } else {
             //如果问题被转换为咨询/建议
             if (in_array($QuestionDetail['QuestionType'], array('ask', 'suggest'))) {
                 return $QuestionDetail;
             } else {
                 return false;
             }
         }
     } else {
         return false;
     }
 }
 /**
  *根据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);
 }
Example #10
0
 /**
  *获取问题详情
  */
 public function questionDetailAction()
 {
     //基础元素,必须参与验证
     $List['QuestionId'] = abs(intval($this->request->QuestionId));
     $List['QuestionType'] = urldecode(trim($this->request->QuestionType));
     $List['UserName'] = urldecode(trim($this->request->UserName));
     $List['QuickAsk'] = urldecode(trim($this->request->QuickAsk));
     $List['Time'] = abs(intval($this->request->Time));
     $oMenCache = new Base_Cache_Memcache("Complaint");
     $Setting = $oMenCache->get('setting');
     //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 ($List['QuestionType'] == "question") {
                 //获取缓存
                 $M = $oMenCache->get('QuestionDetail_' . $List['QuestionType'] . "_" . $List['QuestionId']);
                 if ($M) {
                     $QuestionDetail = json_decode($M, true);
                     //如果缓存内的数据不正确
                     if (!$QuestionDetail['QuestionId']) {
                         //获取封装完毕的问题详情
                         $QuestionDetail = $this->oQuestion->ProcessQuestionDetail($List);
                     }
                 } else {
                     //获取封装完毕的问题详情
                     $QuestionDetail = $this->oQuestion->ProcessQuestionDetail($List);
                 }
                 if ($QuestionDetail['QuestionId']) {
                     //写入缓存
                     $oMenCache->set('QuestionDetail_' . $List['QuestionType'] . "_" . $List['QuestionId'], json_encode($QuestionDetail), 300);
                     //如果已经被转换分类
                     if ($QuestionDetail['Transformed'] == 1) {
                         //获取转换后的分类信息
                         $CategoryInfo = $this->oCategory->getCategoryByQuestionType($QuestionDetail['QuestionType']);
                         //提示跳转
                         $result = array('return' => 2, 'action' => $this->oQuestion->getQuestionLink($QuestionDetail['QuestionId'], $QuestionDetail['QuestionType']), 'comment' => "此问题已经被转换为" . $CategoryInfo['name']);
                     } else {
                         //cookie验证
                         $CookieAuthor = $this->oUser->authorUserByCookie($List['QuickAsk'], 'zx,jy', $QuestionDetail['QuestionId']);
                         //用户名验证
                         $UserAuthor = $this->oUser->authorUserByName($List['UserName'], $QuestionDetail['AuthorName']);
                         //用户名验证不通过 并且 COOKIE验证不通过
                         if (!$UserAuthor) {
                             if (!$CookieAuthor) {
                                 $QuestionDetail['AuthorName'] = Base_Common::cutstr($QuestionDetail['AuthorName'], 2, '**');
                             }
                         }
                         //如果问题不是隐私状态
                         if ($QuestionDetail['Hidden'] == 1) {
                             //登陆用户 并且 账号不一致
                             if (!$UserAuthor) {
                                 //不显示附件信息
                                 $QuestionDetail['QuestionAttatch'] = "";
                                 //如果浏览器记录中无该问题提问记录
                                 if (!$CookieAuthor) {
                                     //取消追问资格
                                     $QuestionDetail['SubQuestion'] = 0;
                                     //取消评价资格
                                     $QuestionDetail['Assess'] = 0;
                                     //不显示评价
                                     unset($QuestionDetail['AssessStatus']);
                                 }
                             }
                             $result = array('return' => 1, 'QuestionDetail' => $QuestionDetail);
                             //缓存中清除新处理的问题标记
                             if ($CookieAuthor || $UserAuthor) {
                                 //缓存中清除新处理的问题标记
                                 $oMenCache->remove('fw' . $List['QuestionId']);
                             }
                         } else {
                             //登陆用户 并且 账号不一致
                             if (!$UserAuthor) {
                                 //不显示附件信息
                                 $QuestionDetail['QuestionAttatch'] = "";
                                 //如果浏览器记录中无该问题提问记录
                                 if (!$CookieAuthor) {
                                     //取消追问资格
                                     $QuestionDetail['SubQuestion'] = 0;
                                     //取消评价资格
                                     $QuestionDetail['Assess'] = 0;
                                     //不显示评价
                                     unset($QuestionDetail['AssessStatus']);
                                 }
                             }
                             $result = array('return' => 1, 'QuestionDetail' => $QuestionDetail);
                             //如果cookie验证通过 或者 用户验证通过
                             if ($CookieAuthor || $UserAuthor) {
                                 //缓存中清除新处理的问题标记
                                 $oMenCache->remove('fw' . $List['QuestionId']);
                             } else {
                                 $result = array('return' => 2, 'action' => 'login', 'comment' => "此问题的状态为:用户自己可见,请登录");
                             }
                         }
                     }
                 } else {
                     $result = array('return' => 0, 'comment' => "无此问题");
                 }
             } elseif ($List['QuestionType'] == "complain") {
                 //获取缓存
                 $M = $oMenCache->get('QuestionDetail_' . $List['QuestionType'] . "_" . $List['QuestionId']);
                 if ($M) {
                     $QuestionDetail = json_decode($M, true);
                     //如果缓存内的数据不正确
                     if (!$QuestionDetail['QuestionId']) {
                         //获取封装完毕的问题详情
                         $QuestionDetail = $this->oComplain->ProcessComplainDetail($List);
                     }
                 } else {
                     //获取封装完毕的问题详情
                     $QuestionDetail = $this->oComplain->ProcessComplainDetail($List);
                 }
                 if ($QuestionDetail['QuestionId']) {
                     //写入缓存
                     $oMenCache->set('QuestionDetail_' . $List['QuestionType'] . "_" . $List['QuestionId'], json_encode($QuestionDetail), 300);
                     //如果已经被转换分类
                     if ($QuestionDetail['Transformed'] == 1) {
                         //如果问题被转换为咨询/建议
                         if (in_array($QuestionDetail['QuestionType'], array('ask', 'suggest'))) {
                             //获取转换后的分类信息
                             $CategoryInfo = $this->oCategory->getCategoryByQuestionType($QuestionDetail['QuestionType']);
                             $result = array('return' => 2, 'action' => $this->oQuestion->getQuestionLink($QuestionDetail['QuestionId'], "question"), 'comment' => "此问题已经被转换为" . $CategoryInfo['name']);
                         } else {
                             $result = array('return' => 0, 'comment' => "无此问题");
                         }
                     } else {
                         //cookie验证
                         $CookieAuthor = $this->oUser->authorUserByCookie($List['QuickAsk'], 'ts', $QuestionDetail['QuestionId']);
                         //用户名验证
                         $UserAuthor = $this->oUser->authorUserByName($List['UserName'], $QuestionDetail['AuthorName']);
                         //如果问题被设置为隐藏
                         if ($QuestionDetail['Hidden'] == 1) {
                             $result = array('return' => 0, 'private' => 1, 'comment' => "此问题的状态为:隐藏");
                         } else {
                             //用户名验证不通过 并且 COOKIE验证不通过
                             if (!$UserAuthor) {
                                 if (!$CookieAuthor) {
                                     $QuestionDetail['AuthorName'] = Base_Common::cutstr($QuestionDetail['AuthorName'], 2, '**');
                                 }
                             }
                             //如果问题被设置为公开 或 cookie验证通过 或 用户名验证通过
                             if ($QuestionDetail['Hidden'] == 0 || $CookieAuthor || $UserAuthor) {
                                 //登陆用户 并且 账号不一致 并且 浏览器记录中无该问题提问记录
                                 if (!$UserAuthor && !$CookieAuthor) {
                                     //取消撤销资格
                                     $QuestionDetail['Revoke'] = 0;
                                     //不显示附件信息
                                     $QuestionDetail['QuestionAttatch'] = "";
                                     //不显示评价
                                     unset($QuestionDetail['AssessStatus']);
                                 }
                                 $result = array('return' => 1, 'QuestionDetail' => $QuestionDetail);
                                 //缓存中清除新处理的问题标记
                                 $oMenCache->remove('ts' . $List['QuestionId']);
                             } else {
                                 $result = array('return' => 2, 'action' => 'login', 'comment' => "此问题的状态为:用户自己可见,请登录");
                             }
                         }
                     }
                 } 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);
 }
Example #11
0
 function ProcessQuestionDetail($Question)
 {
     $oMenCache = new Base_Cache_Memcache("Complaint");
     $Setting = $oMenCache->get('setting');
     $oCategory = new Kubao_Category();
     $oOperator = new Kubao_Operator();
     $oQtype = new Kubao_Qtype();
     //根据问题ID判断问题是否属于历史数据库
     $HistoryMapping = $this->GetHistoryMap($Question['QuestionId'], 'ask');
     $QuestionDetail = $this->GetQuestionDetail($Question['QuestionId'], intval($HistoryMapping['year']));
     //获取到问题详情
     if ($QuestionDetail['QuestionId'] > 0) {
         //如果问题尚未被转换分类
         if ($QuestionDetail['Transformed'] != 1) {
             //获取问题分类内容
             $CategoryInfo = $oCategory->getCategory($QuestionDetail['CatagoryId'], 'id,name,question_type');
             $QuestionDetail['CategoryName'] = $CategoryInfo['id'] ? $CategoryInfo['name'] : "未设置分类";
             $QuestionDetail['QuestionType'] = ucfirst($CategoryInfo['question_type']);
             $QuestionDetail['PageTitle'] = $QuestionDetail['CategoryName'] . "详情";
             //获取问题主分类内容
             $QtypeInfo = $oQtype->getQtypeById($QuestionDetail['QtypeId'], 'id,name');
             $QuestionDetail['QtypeName'] = $QtypeInfo['id'] ? $QtypeInfo['name'] : "未设置分类";
             //如果回答中包含客服账号
             if ($QuestionDetail['Answer']['OperatorName']) {
                 $List = 'id,photo,login_name,cno,QQ,tel,mobile,weixin,weixinPicUrl,xnGroupId,name';
                 $M = $oMenCache->get('OperatorInfo_' . $QuestionDetail['Answer']['OperatorName'] . "_" . md5($List));
                 if ($M) {
                     $OperatorInfo = json_decode($M, true);
                     //如果获取到的客服信息合法
                     if (!$OperatorInfo['OperatorId']) {
                         //获取相关客服信息
                         $OperatorInfo = $oOperator->getOperatorByName($QuestionDetail['Answer']['OperatorName'], $List);
                         //格式化显示信息
                         $OperatorInfo = $oOperator->processOperatorInfo($OperatorInfo);
                     }
                 } else {
                     //获取相关客服信息
                     $OperatorInfo = $oOperator->getOperatorByName($QuestionDetail['Answer']['OperatorName'], $List);
                     //格式化显示信息
                     $OperatorInfo = $oOperator->processOperatorInfo($OperatorInfo);
                 }
                 //如果获取到的客服信息合法
                 if ($OperatorInfo['OperatorId']) {
                     $oMenCache->set('OperatorInfo_' . $QuestionDetail['Answer']['OperatorName'] . "_" . md5($List), json_encode($OperatorInfo), 60);
                     $QuestionDetail['Answer']['OperatorInfo'] = $OperatorInfo;
                 } else {
                     unset($QuestionDetail['Answer']['OperatorInfo']);
                 }
             }
             //处理追问内数据
             foreach ($QuestionDetail['SubQuestionList'] as $key => $SubQuestion) {
                 //如果回答中包含客服账号
                 if ($SubQuestion['Answer']['OperatorName']) {
                     $List = 'id,photo,login_name,cno,QQ,tel,mobile,weixin,weixinPicUrl,xnGroupId,name';
                     $M = $oMenCache->get('OperatorInfo_' . $SubQuestion['Answer']['OperatorName'] . "_" . md5($List));
                     if ($M) {
                         $OperatorInfo = json_decode($M, true);
                         //如果获取到的客服信息不合法
                         if (!$OperatorInfo['OperatorId']) {
                             //获取相关客服信息
                             $OperatorInfo = $oOperator->getOperatorByName($SubQuestion['Answer']['OperatorName'], $List);
                             //格式化显示信息
                             $OperatorInfo = $oOperator->processOperatorInfo($OperatorInfo);
                         }
                     } else {
                         //获取相关客服信息
                         $OperatorInfo = $oOperator->getOperatorByName($SubQuestion['Answer']['OperatorName'], $List);
                         //格式化显示信息
                         $OperatorInfo = $oOperator->processOperatorInfo($OperatorInfo);
                     }
                     //如果获取到的客服信息不合法
                     if ($OperatorInfo['OperatorId']) {
                         $oMenCache->set('OperatorInfo_' . $SubQuestion['Answer']['OperatorName'] . "_" . md5($List), json_encode($OperatorInfo), 60);
                         $QuestionDetail['SubQuestionList'][$key]['OperatorInfo'] = $OperatorInfo;
                     } else {
                         unset($QuestionDetail['SubQuestionList'][$key]['OperatorInfo']);
                     }
                 }
             }
             //如果评价次数为正数且达到上限
             if ($Setting['limit_assess_num'] <= $QuestionDetail['AssessCount'] && $Setting['limit_assess_num'] >= 0) {
                 //取消评价资格
                 $QuestionDetail['Assess'] = 0;
             }
             //删除不必要的字段
             unset($QuestionDetail['CatagoryId'], $QuestionDetail['QtypeId']);
             return $QuestionDetail;
         } else {
             //如果问题被转换为投诉
             if ($QuestionDetail['QuestionType'] == "complain") {
                 return $QuestionDetail;
             } else {
                 return false;
             }
         }
     } else {
         return false;
     }
 }