123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <?php
- /**
- * QqConfLogic.php UTF-8
- * QQ处理逻辑
- *
- * @date : 2018/5/24 11:38
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : chenbingling <cbl@huosdk.com>
- * @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;
- }
- }
|