Ejemplo n.º 1
0
 /**
  * 用户追问
  */
 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));
 }