* @version : HUOSDK 8.0 */ namespace huo\logic\qq; use huo\model\common\CommonModel; use huo\model\conf\QqConfModel; use huolib\constant\GameConst; class QqConfLogic extends CommonModel { protected $base_field = ['id', 'type', 'qq', 'idkey', 'ios_key', 'and_key', 'create_time', 'update_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 getList($where = [], $page = '1,10', $order = '') { $_rdata = [ 'count' => 0, 'list' => [] ]; $_map = []; if (!empty($where['qq'])) { $_map['qq'] = ['like', '%'.$where['qq'].'%']; } if (!empty($where['type'])) { $_map['type'] = $where['type']; } $_map['id'] = array('neq', 0); $_map['is_delete'] = 2; $_param['where'] = $_map; $_param['page'] = $page; $_param['order'] = $order; $_qq_model = new QqConfModel(); $_rdata['count'] = $_qq_model->where($_map)->count(); if (empty($_rdata['count'])) { return $_rdata; } $_field = $this->base_field; $_order = $this->orderFilter($order); $_datas = $_qq_model->field($_field)->where($_map)->page($page)->order($_order)->select(); if (is_object($_datas)) { $_datas = $_datas->toArray(); } if (empty($_datas)) { return $_rdata; } $_rdata['list'] = $_datas; return $_rdata; } /*** * QQ唯一性验证 号码和类型 * * @param $params * * @return array|bool|false|\PDOStatement|string|\think\Model * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\Exception */ public function isUnique($params) { $_where = array( 'qq' => $params['qq'], 'type' => $params['type'], ); $_res = (new QqConfModel())->where($_where)->field('id,is_delete')->find(); if (!empty($_res)) { $_res = $_res->toArray(); } return $_res; } /*** * 获取qq和qq群 * * @param string $ids * * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function getQqs($ids = '') { $_rdata = [0 => [], 1 => []]; if (empty($ids)) { return $_rdata; } $_map = ['id' => ['in', $ids]]; $_data = (new QqConfModel())->where($_map)->field('qq,type')->select(); if (is_object($_data)) { $_data = $_data->toArray(); } if (empty($_data)) { return $_rdata; } $_qq = []; $_qqgroup = []; foreach ($_data as $_k => $_v) { if (GameConst::QQ_TYPE_QQ == $_v['type']) { $_qq[] = $_v['qq']; } else { $_qqgroup[] = $_v['qq']; } } $_rdata[0] = implode(',', $_qq); $_rdata[1] = implode(',', $_qqgroup); return $_rdata; } }