123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?php
- /**
- * GameHelpLogic.php UTF-8
- * WWW
- *
- * @date : 2018/7/12 18:00
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : chenbingling <cbl@huosdk.com>
- * @version : HUOSDK 8.0
- */
- namespace huo\logic\game;
- use huo\logic\qq\QqConfLogic;
- use huo\model\common\CommonModel;
- use huo\model\game\GameHelpModel;
- use huolib\constant\CommonConst;
- class GameHelpLogic extends CommonModel {
- /**
- * @param array $param
- *
- * @return array
- */
- protected function getWhere($param = []) {
- $_map = [];
- if (!empty($param['start_time']) && !empty($param['end_time'])) {
- $_map['create_time']
- = [
- 'between',
- [
- strtotime($param['start_time']),
- CommonConst::CONST_DAY_SECONDS + strtotime($param['end_time'])
- ]
- ];
- } elseif (!empty($param['start_time'])) {
- $_map['create_time'] = ['egt', strtotime($param['start_time'])];
- } elseif (!empty($param['end_time'])) {
- $_map['create_time'] = ['elt', CommonConst::CONST_DAY_SECONDS + strtotime($param['end_time'])];
- }
- if (!empty($param['game_id'])) {
- $_map['app_id'] = $param['game_id'];
- }
- if (!empty($param['app_id'])) {
- $_map['app_id'] = $param['app_id'];
- }
- return $_map;
- }
- public function getField() {
- return [
- 'app_id' => 'app_id',
- 'qq_ids' => 'qq_ids',
- 'wx' => 'wx',
- 'tel' => 'tel',
- 'service_time' => 'service_time',
- 'weibo' => 'weibo',
- 'officesite' => 'officesite',
- 'update_time' => 'update_time',
- 'create_time' => 'create_time',
- ];
- }
- /**
- * 后台获取列表
- *
- * @param array $where
- * @param string $page
- * @param string $order
- *
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function getAdminList($where = [], $page = '1,10', $order = '+app_id') {
- $_map = $this->getWhere($where);
- $_model = new GameHelpModel();
- $_rdata = ['count' => 0, 'list' => []];
- $_count = $_model->where($_map)->count('app_id');
- if (empty($_count)) {
- return $_rdata;
- }
- $_field = $this->getField();
- $_order = $this->orderFilter($order);
- $_gdata = $_model->with('game')
- ->field($_field)
- ->where($_map)
- ->order($_order)
- ->page($page)
- ->select();
- if (is_object($_gdata)) {
- $_gdata = $_gdata->toArray();
- }
- if (empty($_gdata)) {
- return $_rdata;
- }
- $_list = [];
- foreach ($_gdata as $_k => $_v) {
- $_data = [];
- foreach ($_field as $_fk => $_fv) {
- $_data[$_fv] = $_v[$_fk];
- }
- if (!empty($_v['qq_ids'])) {
- list($_data['qq'], $_data['qqgroup']) = (new QqConfLogic())->getQqs($_v['qq_ids']);
- }
- if (!empty($_v['game'])) {
- $_data['game_name'] = isset($_v['game']['game_name']) ? $_v['game']['game_name'] : '';
- } else {
- $_data['game_name'] = '';
- }
- $_list[] = $_data;
- }
- $_rdata = ['count' => $_count, 'list' => $_list];
- return $_rdata;
- }
- }
|