/**
  * 回复用户信息
  */
 public function actionReply()
 {
     $this->_utilRbac = $this->_getGlobalData('Util_Rbac', 'object');
     $userClass = $this->_utilRbac->getUserClass();
     $timeout = intval(strtotime($_POST['create_time'])) + intval($_POST['timeout']);
     if (CURRENT_TIME > $timeout && $_POST['cur_status'] == 1) {
         //如果当前时间大于超时时间,并且当前工单为未处理状态,就说明回复时间已经过了,那么就超时
         $isTimeout = '1';
     } else {
         $isTimeout = '0';
     }
     $replyContent = $_POST['reply'];
     if ($_POST['lock']) {
         $replyContent = '<em>[该消息未发送到游戏服务器]</em> ' . $replyContent;
     }
     //如果为不发送消息将自动在前面加上
     $addQaArr = array('is_timeout' => $isTimeout, 'work_order_id' => $_POST['Id'], 'content' => $replyContent, 'qa' => 1, 'reply_name' => $userClass['_userName'], 'create_time' => CURRENT_TIME, 'game_type_id' => $_POST['game_type_id'], 'operator_id' => $_POST['operator_id']);
     if ($isTimeout) {
         $addQaArr['last_reply_time'] = $timeout;
     }
     //如果超时的话,将记录最后超时的时间
     if ($_POST['source'] == 2 && !$_POST['lock']) {
         //如果工单来源为2并且lock为不锁定,那么就要发送webservice
         $gameServerList = $this->_getGlobalData('gameser_list');
         $gameServerUrl = $gameServerList[$_POST['game_server_id']]['send_msg_url'];
         //获取url地址
         if (!$gameServerUrl) {
             $this->_utilMsg->showMsg('发送消息给游戏服务端失败', -2);
         }
         $isOk = $this->_sendMsg(array('work_order_id' => $_POST['Id'], 'service_id' => $userClass['_serviceId'] ? $userClass['_serviceId'] : '001', 'content' => $replyContent, 'server_url' => $gameServerUrl, 'status' => $_POST['status']));
         if ($isOk !== true) {
             $this->_utilMsg->showMsg($isOk, -2);
         }
     }
     $this->_modelWorkOrderQa->add($addQaArr);
     #------改变房间工单,用户回复数------#
     $userClass->setUpdateInfo(1);
     $userClass->addToReplyNum(1);
     if ($_POST['owner_user_id'] == $userClass['_id'] && $_POST['cur_status'] == 1) {
         $userClass->setIncompleteOrderNum(-1);
     }
     //用户完成一个工单
     if ($_POST['cur_status'] == 1) {
         //如果为未回复将房间未完成工单数减1
         $roomClass = $this->_utilRooms->getRoom($_POST['room_id']);
         if (is_object($roomClass)) {
             $roomClass->completeOrder(1);
             //完成一个工单数
             $roomClass->setUpdateInfo(1);
         }
     }
     #------改变房间工单,用户回复数------#
     $workOrderUpdateArr = array('status' => $_POST['status'], 'answer_num' => 'answer_num+1', 'owner_user_id' => $userClass['_id']);
     //变为待处理,提问数+1
     $this->_modelWorkOrder->update($workOrderUpdateArr, "Id={$_POST['Id']}");
     $this->_utilMsg->showMsg(false);
 }
Exemple #2
0
 /**
  * 添加问题
  */
 public function actionAdd()
 {
     if ($this->_isPost()) {
         $this->_modelWorkOrderDetail = $this->_getGlobalData('Model_WorkOrderDetail', 'object');
         $this->_modelWorkOrderQa = $this->_getGlobalData('Model_WorkOrderQa', 'object');
         #------获取问题类型额外信息------#
         $questionType = $this->_modelQuestionType->findById($_POST['question_type']);
         $questionFormTable = $questionType['form_table'];
         $questionFormTableKey = $this->_modelQuestionType->getTtwoArrConvertOneArr($questionFormTable, 'name', 'name');
         $formDetail = array();
         if (!empty($questionFormTableKey)) {
             foreach ($questionFormTableKey as $value) {
                 if ($value == null) {
                     continue;
                 }
                 $formDetail[$value] = $_POST[$value];
             }
         }
         #------获取问题类型额外信息------#
         #------生成工单work_order------#
         $this->_utilRbac = $this->_getGlobalData('Util_Rbac', 'object');
         $userClass = $this->_utilRbac->getUserClass();
         //获取用户资料,
         $userName = $userClass['_nickName'];
         $workOrder = array('game_type' => $_POST['game_type'], 'question_type' => $_POST['question_type'], 'source' => 5, 'question_num' => 1, 'create_time' => CURRENT_TIME, 'title' => $_POST['title']);
         if ($_POST['game_server_id']) {
             #------获取服务器ID和运营商ID------#
             list($workOrder['operator_id'], $workOrder['game_server_id']) = explode(',', $_POST['game_server_id']);
             unset($formDetail['game_server_id']);
             //删除服务器列表数组
             #------获取服务器ID和运营商ID------#
         }
         $this->_modelWorkOrder->add($workOrder);
         $workOrderId = $this->_modelWorkOrder->returnLastInsertId();
         //获取工单id
         #------生成工单work_order------#
         #------生成工单详细信息------#
         $userDetail = array('nick_name' => $userName);
         $detail = array('user_data' => $userDetail, 'form_detail' => $formDetail);
         $addWorkOrderDetailArr = array('work_order_id' => $workOrderId, 'content' => serialize($detail));
         $this->_modelWorkOrderDetail->add($addWorkOrderDetailArr);
         #------生成工单详细信息------#
         #------生成工单提问信息------#
         $addWorkOrderQaArr = array('work_order_id' => $workOrderId, 'content' => $_POST['description'], 'create_time' => CURRENT_TIME);
         $this->_modelWorkOrderQa->add($addWorkOrderQaArr);
         #------生成工单提问回复信息------#
         #------增加问题队列到队列------#
         $this->_utilWorkOrder = $this->_getGlobalData('Util_WorkOrder', 'object');
         $orderManage = $this->_utilWorkOrder->getOrderManage();
         $workOrder['Id'] = $workOrderId;
         $orderManage->addOrder($workOrder);
         $orderManage->setUpdateInfo(1);
         #------增加问题队列到队列------#
         $this->_utilMsg->showMsg('工单提问成功', 1, Tools::url(CONTROL, 'Index', 1));
     }
 }
 /**
  * 用户追问
  */
 public function actionReply()
 {
     //		foreach ($_POST as &$value){
     //			$value=rawurldecode(urldecode($value));
     //		}
     if ($_FILES['image']) {
         $updateInfo = $this->_upload();
     }
     //如果有上传图片就上传文件
     $this->_modelWorkOrder = $this->_getGlobalData('Model_WorkOrder', 'object');
     $this->_modelWorkOrderQa = $this->_getGlobalData('Model_WorkOrderQa', 'object');
     if ($updateInfo['web_path']) {
         $_POST['content'] .= "<br>玩家截图:<br> <img src='{$updateInfo['web_path']}' />";
     }
     $addArr = array('work_order_id' => $_POST['id'], 'content' => $_POST['content'], 'qa' => 0, 'create_time' => CURRENT_TIME);
     $updateArr = array('create_time' => CURRENT_TIME, 'status' => 1, 'question_num' => 'question_num+1');
     $this->_modelWorkOrder->update($updateArr, "Id={$_POST['id']}");
     $this->_modelWorkOrderQa->add($addArr);
     $this->_returnAjaxJson(array('status' => 1, 'info' => null, 'data' => array('image_path' => $updateInfo['web_path'])));
 }
 /**
  * 用户追问
  */
 public function actionReply()
 {
     $_POST['id'] = intval($_POST['id']);
     if (!$_POST['id']) {
         $this->_returnAjaxJson(array('status' => 0, 'info' => 'error id', 'data' => NULL));
     }
     $this->_modelWorkOrder = $this->_getGlobalData('Model_WorkOrder', 'object');
     $orderList = $this->_modelWorkOrder->findById($_POST['id']);
     //工单详细
     if (!$orderList) {
         $this->_returnAjaxJson(array('status' => 0, 'info' => 'work order non-existent', 'data' => NULL));
     }
     $orderList['status'] = intval($orderList['status']);
     if ($orderList['status'] < 1 || $orderList['status'] > 3) {
         //satus是1、2、3才允许回复
         $this->_returnAjaxJson(array('status' => 0, 'info' => 'status forbidden', 'data' => null));
     }
     if ($orderList['evaluation_status'] != '0') {
         //已评价的工单不让追问
         $this->_returnAjaxJson(array('status' => 0, 'info' => 'already evaluation', 'data' => null));
     }
     $sql = "SELECT qa,create_time from cndw_work_order_qa where work_order_id = " . $_POST['id'] . " order by id desc";
     $pevQaInfo = $this->_modelWorkOrder->select($sql, 1);
     if ($pevQaInfo) {
         if ($pevQaInfo['qa'] == 0) {
             $pevQusertionTime = $pevQaInfo['create_time'];
             if (time() - $pevQusertionTime < 60) {
                 // 一分钟内的追问过于频繁
                 $this->_returnAjaxJson(array('status' => 0, 'info' => 'Too often asked, a minute later to continue', 'data' => null));
             }
         } elseif ($pevQaInfo['qa'] == 1) {
             $pevQusertionTime = $pevQaInfo['create_time'];
             if (time() - $pevQusertionTime > 3 * 24 * 60 * 60) {
                 //回复超过3天 后就不能进行追问
                 $this->_returnAjaxJson(array('status' => 0, 'info' => 'Questioning the validity of 3 days', 'data' => null));
             }
         }
     }
     foreach ($_POST as &$value) {
         $value = rawurldecode(urldecode($value));
     }
     if ($_FILES['image']) {
         $updateInfo = $this->_upload();
     }
     //如果有上传图片就上传文件
     $this->_modelWorkOrderQa = $this->_getGlobalData('Model_WorkOrderQa', 'object');
     $content = $_POST['content'];
     $content = str_replace(array('\\r\\n', '\\r'), chr(10), $content);
     $addArr = array('work_order_id' => $_POST['id'], 'content' => $content, 'qa' => 0, 'user_id' => 0, 'create_time' => CURRENT_TIME);
     if ($updateInfo && is_array($updateInfo)) {
         $retArr = array();
         $_imgArr = array();
         $i = '';
         foreach ($updateInfo as $img) {
             $retArr["image_path{$i}"] = $img['web_path'];
             $i++;
             $_imgArr[] = str_replace(__ROOT__, '', $img["web_path"]);
         }
         $addArr['image'] = json_encode($_imgArr);
     }
     $updateArr = array('create_time' => CURRENT_TIME, 'status' => 1, 'question_num' => 'question_num+1');
     $this->_modelWorkOrder->update($updateArr, "Id={$_POST['id']}");
     $this->_modelWorkOrderQa->add($addArr);
     #------检测如果当前负责工单的用户下线了,将重新载入工单------#
     $this->_utilWorkOrder = $this->_getGlobalData('Util_WorkOrder', 'object');
     $this->_utilOnline = $this->_getGlobalData('Util_Online', 'object');
     $orderClass = $this->_utilWorkOrder->getOrderManage();
     $userIsOnline = $this->_utilOnline->isUserOnline($orderList['owner_user_id']);
     //是否在线
     if (!$userIsOnline) {
         //不在线
         $orderList['game_type_id'] = $orderList['game_type'];
         //处理兼容
         $orderClass->addOrder($orderList);
         //增加到order队列
     }
     #------检测如果当前负责工单的用户下线了,将重新载入工单------#
     #------追加日志------#
     $this->_modelOrderLog = $this->_getGlobalData('Model_OrderLog', 'object');
     $this->_modelOrderLog->addLog(array('Id' => $_POST['id']), Model_OrderLog::BACK_ASK);
     #------追加日志------#
     $this->_returnAjaxJson(array('status' => 1, 'info' => 'InterfaceWorkOrder_Reply', 'data' => $retArr));
 }
 private function _saveSource4()
 {
     $orderArr = array();
     $orderArr['game_type'] = intval($_POST['game_id']);
     $orderArr['is_vip'] = intval($_GET['is_vip']);
     $orderArr['user_account'] = $_POST['user_account'] ? $_POST['user_account'] : 0;
     $orderArr['user_nickname'] = trim($_POST['user_nickname']);
     $orderArr['money'] = intval($_POST['money_total']);
     $orderArr['source'] = intval(4);
     //工单来源
     $orderArr['title'] = strip_tags($_POST['title']);
     $orderArr['question_type'] = intval($_POST['question_type']);
     $orderArr['question_num'] = 1;
     $orderArr['create_time'] = CURRENT_TIME;
     $orderArr['game_user_id'] = trim($_POST['user_id']);
     if ($_FILES['image']) {
         $updateInfo = $this->_upload();
         //如果有上传图片就上传文件
     }
     $serverMarking = trim($_POST['server_marking']);
     $gameServerList = $this->_modelGameSerList->findByMarking($_POST['game_id'], $serverMarking, $_POST['server_name']);
     if (!$gameServerList) {
         //未找到服务器
         $this->_utilMsg->showMsg("game server non-existent", 1);
         //			$this->_returnAjaxJson ( array ('status' => 0, 'info' => 'game server non-existent', 'data' => null ) );
     }
     $this->_modelGameOperator = $this->_getGlobalData('Model_GameOperator', 'object');
     $gameOperatorIndex = $this->_modelGameOperator->findByGidOId($_POST['game_id'], $gameServerList['operator_id']);
     //找到此运营商的详细 资料.
     if (!$gameOperatorIndex) {
         //未找到游戏与运营商的索引
         $this->_utilMsg->showMsg("game server or operator non-existent", 1);
         //			$this->_returnAjaxJson ( array ('status' => 0, 'info' => 'game server or operator non-existent', 'data' => null ) );
     }
     //vip等级,如果从游戏中有传$_POST['vip_level']过来,就使用$_POST['vip_level'],否则使用配置值
     $orderArr['vip_level'] = isset($_REQUEST['vip']) ? intval($_REQUEST['vip']) : $this->_modelGameOperator->getVipLevel($gameOperatorIndex['vip_setup']['vip_pay'], $_POST['money_total']);
     $orderArr['vip_level'] = min(6, $orderArr['vip_level']);
     $orderArr['timeout'] = $this->_modelGameOperator->getTimeOut($gameOperatorIndex['vip_setup']['vip_timeout'], $orderArr['vip_level']);
     $orderArr['timeout'] *= 60;
     //换成秒
     $orderArr['is_verify'] = 0;
     $orderArr['operator_id'] = $gameServerList['operator_id'];
     $orderArr['game_server_id'] = $gameServerList['Id'];
     $orderArr['is_read'] = 0;
     if ($gameServerList['room_id']) {
         $orderArr['room_id'] = $gameServerList['room_id'];
     }
     if (!$this->_modelWorkOrder->add($orderArr)) {
         //创建表单失败
         $this->_returnAjaxJson(array('status' => 0, 'info' => 'Failure to create order', 'data' => null));
     }
     $workOrderId = $this->_modelWorkOrder->returnLastInsertId();
     //获取工单id
     #------追加日志------#
     $this->_modelOrderLog = $this->_getGlobalData('Model_OrderLog', 'object');
     $this->_modelOrderLog->addLog(array('game_type_id' => $orderArr['game_type'], 'operator_id' => $orderArr['operator_id'], 'server_id' => $orderArr['game_server_id'], 'Id' => $workOrderId), Model_OrderLog::ASK);
     #------追加日志------#
     #------增加新的工单到队列------#
     if ($orderArr['room_id']) {
         $addOrder = array('Id' => $workOrderId, 'vip_level' => $orderArr['vip_level'], 'room_id' => $orderArr['room_id'], 'game_type_id' => $orderArr['game_type'], 'operator_id' => $orderArr['operator_id']);
         $this->_utilWorkOrder = $this->_getGlobalData('Util_WorkOrder', 'object');
         $orderManageClass = $this->_utilWorkOrder->getOrderManage();
         $orderManageClass->addOrder($addOrder);
         $orderManageClass = null;
     }
     #------增加新的工单到队列------#
     $orderDetail = array();
     $orderDetail['form_detail'] = array();
     $orderDetail['user_data'] = array('user_id' => $_POST['user_id'], 'user_account' => $_POST['user_account'], 'user_nickname' => $_POST['user_nickname'], 'money_total' => isset($_POST['money_total']) ? $_POST['money_total'] : -1, 'money_month' => isset($_POST['money_month']) ? $_POST['money_month'] : -1, 'register_date' => !$_POST['register_date'] || $_POST['register_date'] == 'null' ? null : $_POST['register_date'], 'ip' => $_POST['ip']);
     //钻类型
     if (isset($_POST['flatType'])) {
         $orderDetail['ext']['flatType']['desc'] = '钻类型';
         switch ($_POST['flatType']) {
             case '1':
                 $orderDetail['ext']['flatType']['value'] = '<font color="#FF9900">黄钻</font>';
                 break;
             case '10':
                 $orderDetail['ext']['flatType']['value'] = '<font color="#0000FF">蓝钻</font>';
                 break;
             default:
                 $orderDetail['ext']['flatType']['value'] = '<font color="#999999">无</font>';
         }
     }
     //钻等级
     if (isset($_POST['diamondLevel'])) {
         $orderDetail['ext']['diamondLevel'] = array('desc' => '钻等级', 'value' => $_POST['diamondLevel']);
     }
     //是否年费黄钻
     if (isset($_POST['yearDiamond'])) {
         $orderDetail['ext']['yearDiamond'] = array('desc' => '是否年费', 'value' => $_POST['yearDiamond'] ? '是' : '否');
     }
     //游戏VIP等级
     if (isset($_POST['vip'])) {
         $orderDetail['ext']['vip'] = array('desc' => '游戏VIP等级', 'value' => $_POST['vip']);
     }
     $orderDetail = serialize($orderDetail);
     $this->_modelWorkOrderDetail = $this->_getGlobalData('Model_WorkOrderDetail', 'object');
     $this->_modelWorkOrderDetail->add(array('work_order_id' => $workOrderId, 'content' => $orderDetail));
     #-----插入对话表------#
     $retArr = array('order_id' => $workOrderId);
     $this->_modelWorkOrderQa = $this->_getGlobalData('Model_WorkOrderQa', 'object');
     $content = strip_tags($_POST['content']);
     $content = str_replace(array('\\r\\n', '\\r'), chr(10), $content);
     $orderDialog = array('user_id' => 0, 'game_type_id' => $_POST['game_id'], 'operator_id' => $orderArr['operator_id'], 'work_order_id' => $workOrderId, 'qa' => '0', 'content' => $content, 'create_time' => CURRENT_TIME);
     if ($updateInfo && is_array($updateInfo)) {
         $_imgArr = array();
         $i = '';
         foreach ($updateInfo as $img) {
             $retArr["image_path{$i}"] = $img['web_path'];
             $i++;
             $_imgArr[] = str_replace(__ROOT__, '', $img["web_path"]);
         }
         $orderDialog['image'] = json_encode($_imgArr);
     }
     $this->_modelWorkOrderQa->add($orderDialog);
     //$orderArr["room_id"]
     if ($orderArr['room_id'] && $gameServerList['server_url'] && $_POST['user_id']) {
         $this->_autoreply($orderArr, $gameServerList['server_url']);
     }
     #-----插入对话表------#
     eaccelerator_rm('question_' . $orderArr['user_account']);
     eaccelerator_put('question_' . $orderArr['user_account'], md5($orderArr['user_account'] . $orderArr['title']), 60);
     $this->_utilMsg->showMsg("提交成功", 1);
 }