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; }
/** *获取当前正在生效的公告列表 */ 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); }
/** *重建问题缓存 */ public function rebuildQuestionDetailAction() { //基础元素,必须参与验证 $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"); //URL验证码 $sign = $this->request->sign; //私钥,以后要移开到数据库存储 $p_sign = '5173'; $sign_to_check = base_common::check_sign($Question, $p_sign); //不参与验证的元素 //验证URL是否来自可信的发信方 if ($sign_to_check == $sign) { //验证时间戳,时差超过600秒即认为非法 if (abs($Question['Time'] - time()) <= 600) { //问题类型为咨询|建议 if ($Question['QuestionType'] == "question") { //获取封装完毕的问题详情 $QuestionDetail = $this->oQuestion->ProcessQuestionDetail($Question); } elseif ($Question['QuestionType'] == "complain") { //获取封装完毕的问题详情 $QuestionDetail = $this->oComplain->ProcessComplainDetail($Question); } if ($QuestionDetail['QuestionId']) { $oMenCache->set('QuestionDetail_' . $Question['QuestionType'] . "_" . $Question['QuestionId'], json_encode($QuestionDetail), 300); $result = array('return' => 1); } else { $result = array('return' => 0, 'comment' => "无此问题"); } } else { $result = array('return' => 0, 'comment' => "时间有误"); } } else { $result = array('return' => 0, 'comment' => "验证失败,请检查URL"); } echo json_encode($result); }
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; } }
/** *获取当前正在生效的常用问题 */ 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); }
/** *获取问题详情 */ 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); }
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; } }