public function recount($kindId) { $this->_modelPlayerFaq = $this->_getGlobalData('Model_PlayerFaq', 'object'); $count = $this->_modelPlayerFaq->findCount("kind_id={$kindId}"); parent::update(array('count' => $count), "Id={$kindId}"); return array('status' => 1, 'msg' => '更新计数器成功', 'href' => 1); }
/** * 缓存获取指定faq * @param $id * @param $expire */ public function getId($id, $expire = NULL) { if ($expire == null) { $expire = 3600 * 24; } //默认缓存24小时 $key = FAQ_ID . $id; $result = $this->get(FAQ_ID . $id); if (!$result) { $this->_modelPlayerFaq = $this->_getGlobalData('Model_PlayerFaq', 'object'); $result = $this->_modelPlayerFaq->findById($id); $this->set($key, $result, $expire); } return $result; }
/** * searchFAQ */ public function actionSearch() { $this->_loadCore('Help_SqlSearch'); $this->_helpSqlSearch = new Help_SqlSearch(); $this->_modelPlayerFaq = $this->_getGlobalData('Model_PlayerFaq', 'object'); $gameTypeId = abs(intval($_REQUEST['game_id'])); $keyWords = $_REQUEST['keywords']; $page = abs(intval($_REQUEST['p'])); if (!$page) { $page = 1; } $pageSize = abs(intval($_REQUEST['ps'])); if (!$pageSize) { $pageSize = 8; } $this->_helpSqlSearch->set_tableName($this->_modelPlayerFaq->tName()); $this->_helpSqlSearch->set_field('Id,ratio,game_type_id,kind_id,question'); $this->_helpSqlSearch->set_conditions("game_type_id={$gameTypeId}"); $this->_helpSqlSearch->set_conditions("question like '%{$keyWords}%'"); $this->_helpSqlSearch->setPageLimit($page, $pageSize); $conditions = $this->_helpSqlSearch->get_conditions(); $sql = $this->_helpSqlSearch->createSql(); $dataList = $this->_modelPlayerFaq->select($sql); if (!$dataList) { $this->_returnAjaxJson(array('status' => 0, 'info' => 'NO_FIND', 'data' => null)); } //无数据返回出错. $count = $this->_modelPlayerFaq->findCount($conditions); $toalPgae = ceil($count / $pageSize); $this->_returnAjaxJson(array('status' => 1, 'info' => null, 'data' => array('page' => array('total' => $count, 'total_page' => $toalPgae, 'page' => $page, 'page_size' => $pageSize), 'list' => $dataList))); }
/** * 客服faq管理 */ public function actionServiceIndex() { $gameTypes = $this->_faqKind; $kindList = $this->_modelServiceKindFaq->findAll(); foreach ($kindList as &$value) { $value['word_game_type_id'] = $gameTypes[$value['game_type_id']]; $value['url_add'] = Tools::url(CONTROL, 'ServiceAdd', array('kind_id' => $value['Id'], 'game_type_id' => $value['game_type_id'])); $value['url_view_faq'] = Tools::url(CONTROL, ACTION, array('kind_id' => $value['Id'], 'game_type_id' => $value['game_type_id'])); } if ($_GET['kind_id'] && $_GET['game_type_id']) { //如果Id有值那么将显示列表 $faqList = $this->_modelPlayerFaq->findByKindId($_GET['kind_id']); foreach ($faqList as &$value) { $value['question'] = str_replace("\\", '', $value['question']); $value['answer'] = str_replace("\\", '', $value['answer']); } $faqGameType = $gameTypes[$_GET['game_type_id']]; $faqKind = $this->_modelServiceKindFaq->findById($_GET['kind_id']); $faqKind = $faqKind['name']; $this->_view->assign('faqList', $faqList); $this->_view->assign('faqGameType', $faqGameType); $this->_view->assign('faqKind', $faqKind); $this->_view->assign('displayFaq', true); } $this->_view->assign('faqList', $faqList); $this->_view->assign('kindList', $kindList); $this->_utilMsg->createNavBar(); $this->_view->display(); }
/** * 最高点击率faq */ public function actionHot() { $this->_modelPlayerFaq = $this->_getGlobalData('Model_PlayerFaq', 'object'); $pageSize = abs(intval($_REQUEST['ps'])); $gameTypeId = abs(intval($_REQUEST['game_id'])); $dataList = $this->_modelPlayerFaq->findHotList($gameTypeId, $pageSize, $this->_curLang); if ($dataList !== false) { $this->_returnAjaxJson(array('status' => 1, 'info' => 'InterfaceFaq_Hot', 'data' => $dataList)); } else { $this->_returnAjaxJson(array('status' => 0, 'info' => 'NO_FIND', 'data' => null)); } }
/** * 分页 * @param array $conditions sql条件 * @param int $page 第几页 */ public function findPage($conditions, $page = 0) { $this->_modelPlayerFaq = $this->_getGlobalData('Model_PlayerFaq', 'object'); $thisTableName = $this->tName(); $faqTableName = $this->_modelPlayerFaq->tName(); $sql = "select {$thisTableName}.*,{$faqTableName}.lang_id,{$faqTableName}.kind_id,{$faqTableName}.ratio,{$faqTableName}.question from {$thisTableName} left join {$faqTableName} on {$thisTableName}.player_faq_id={$faqTableName}.Id where 1 "; $where = ''; if ($conditions['faq_id']) { $where .= " and {$thisTableName}.player_faq_id={$conditions['faq_id']} "; } else { if ($conditions['whether'] != '') { $where .= " and {$thisTableName}.faq_whether={$conditions['whether']}"; } if ($conditions['game_type_id']) { $where .= " and {$thisTableName}.game_type_id={$conditions['game_type_id']}"; } if ($conditions['faq_opinion'] != '') { $where .= " and {$thisTableName}.faq_opinion={$conditions['faq_opinion']}"; } if ($conditions['source']) { $where .= " and {$thisTableName}.source={$conditions['source']}"; } if ($conditions['time']['start'] && $conditions['time']['end']) { $where .= " and date_create between " . strtotime($conditions['time']['start']) . " and " . strtotime($conditions['time']['end']); } if ($conditions['lang']) { $where .= " and {$thisTableName}.lang_id = {$conditions['lang']}"; } } $sql .= $where; $sql .= ' order by Id desc'; if ($page != 0) { $page--; } $begin = $page * PAGE_SIZE; $sql .= " limit {$begin}," . PAGE_SIZE; $dataList = $this->select($sql); $total = $this->findCount(substr($where, 5)); return array('dataList' => $dataList, 'total' => $total); }
/** * 修复FAQ分类下的FAQ数量不对的接口 */ public function actionXiuFu() { $game_id = intval($_GET['game_id']); if (!$game_id) { echo 'field'; exit; } $faqKindTable = $this->_modelPlayerKindFaq->tName(); $kindIds = $this->_modelPlayerKindFaq->select("select Id from {$faqKindTable} where game_type_id = {$game_id}"); foreach ($kindIds as $key => $val) { $faqCount = $this->_modelPlayerFaq->findCount("kind_id={$val['Id']} and status !=1"); $this->_modelPlayerKindFaq->update(array('count' => $faqCount), "Id={$val['Id']}"); } echo 'ok'; }