* @version : HUOSDK 8.0 */ namespace huo\logic\game; use huo\model\common\CommonModel; use huo\model\game\GameQqModel; use huolib\constant\CommonConst; use huolib\constant\GameConst; class GameQqLogic 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']; } if (!empty($param['status'])) { $_map['status'] = $param['status']; } return $_map; } public function getField() { return [ 'id' => 'id', 'app_id' => 'app_id', 'qq_id' => 'qq_id', 'status' => 'status', '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 GameQqModel(); $_rdata = ['count' => 0, 'list' => []]; $_count = $_model->where($_map)->count('id'); if (empty($_count)) { return $_rdata; } $_field = $this->getField(); $_order = $this->orderFilter($order); $_gdata = $_model->with('game') ->with('qq') ->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]; } $_data['status_text'] = GameConst::getQqStatusMsg($_v['status']); if (!empty($_v['game'])) { $_data['game_name'] = isset($_v['game']['game_name']) ? $_v['game']['game_name'] : ''; } if (!empty($_v['qq'])) { $_data['qq'] = isset($_v['qq']['qq']) ? $_v['qq']['qq'] : ''; $_data['idkey'] = isset($_v['qq']['idkey']) ? $_v['qq']['idkey'] : ''; $_data['ios_key'] = isset($_v['qq']['ios_key']) ? $_v['qq']['ios_key'] : ''; $_data['and_key'] = isset($_v['qq']['and_key']) ? $_v['qq']['and_key'] : ''; } $_list[] = $_data; } $_rdata = ['count' => $_count, 'list' => $_list]; return $_rdata; } /** * 获取游戏Qq配置信息 * * @param $app_id * * @return array|false|\PDOStatement|string|\think\Collection * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function getGameQqInfo($app_id) { if (empty($app_id)) { return ''; } $_map = []; $_map['app_id'] = $app_id; $_map['status'] = GameConst::QQ_STATUS_OPEN; $_rdata = (new GameQqModel())->where($_map)->find(); if (is_object($_rdata)) { $_rdata = $_rdata->toArray(); } return $_rdata; } /** * 获取游戏Qq配置信息 * * @param $id * * @return array|false|\PDOStatement|string|\think\Collection * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function getGameQqInfoById($id) { if (empty($id)) { return ''; } $_map = []; $_map['id'] = $id; $_rdata = (new GameQqModel())->where($_map)->find(); if (is_object($_rdata)) { $_rdata = $_rdata->toArray(); } return $_rdata; } /** * 获取游戏QQ配置 * * @param $where * * @return array|bool|false|\PDOStatement|string|\think\Model * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function getGameQqDetail($where) { if (empty($where['app_id']) || empty($where['qq_id'])) { return false; } $_map = []; $_map['app_id'] = $where['app_id']; $_map['qq_id'] = $where['qq_id']; $_rdata = (new GameQqModel())->useGlobalScope(false)->where($_map)->find(); if (is_object($_rdata)) { $_rdata = $_rdata->toArray(); } return $_rdata; } }