123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- <?php
- /**
- * GamePlayLogic.php UTF-8
- * GameQqLogic
- *
- * @date : 2018/7/12 18:00
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : chenbingling <cbl@huosdk.com>
- * @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;
- }
- }
|