QqConfLogic.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. /**
  3. * QqConfLogic.php UTF-8
  4. * QQ处理逻辑
  5. *
  6. * @date : 2018/5/24 11:38
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : chenbingling <cbl@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\logic\qq;
  13. use huo\model\common\CommonModel;
  14. use huo\model\conf\QqConfModel;
  15. use huolib\constant\GameConst;
  16. class QqConfLogic extends CommonModel {
  17. protected $base_field = ['id', 'type', 'qq', 'idkey', 'ios_key', 'and_key', 'create_time', 'update_time'];
  18. /**
  19. * @param array $where
  20. * @param string $page
  21. * @param string $order
  22. *
  23. * @return array
  24. * @throws \think\db\exception\DataNotFoundException
  25. * @throws \think\db\exception\ModelNotFoundException
  26. * @throws \think\exception\DbException
  27. */
  28. public function getList($where = [], $page = '1,10', $order = '') {
  29. $_rdata = [
  30. 'count' => 0,
  31. 'list' => []
  32. ];
  33. $_map = [];
  34. if (!empty($where['qq'])) {
  35. $_map['qq'] = ['like', '%'.$where['qq'].'%'];
  36. }
  37. if (!empty($where['type'])) {
  38. $_map['type'] = $where['type'];
  39. }
  40. $_map['id'] = array('neq', 0);
  41. $_map['is_delete'] = 2;
  42. $_param['where'] = $_map;
  43. $_param['page'] = $page;
  44. $_param['order'] = $order;
  45. $_qq_model = new QqConfModel();
  46. $_rdata['count'] = $_qq_model->where($_map)->count();
  47. if (empty($_rdata['count'])) {
  48. return $_rdata;
  49. }
  50. $_field = $this->base_field;
  51. $_order = $this->orderFilter($order);
  52. $_datas = $_qq_model->field($_field)->where($_map)->page($page)->order($_order)->select();
  53. if (is_object($_datas)) {
  54. $_datas = $_datas->toArray();
  55. }
  56. if (empty($_datas)) {
  57. return $_rdata;
  58. }
  59. $_rdata['list'] = $_datas;
  60. return $_rdata;
  61. }
  62. /***
  63. * QQ唯一性验证 号码和类型
  64. *
  65. * @param $params
  66. *
  67. * @return array|bool|false|\PDOStatement|string|\think\Model
  68. * @throws \think\db\exception\DataNotFoundException
  69. * @throws \think\db\exception\ModelNotFoundException
  70. * @throws \think\exception\DbException
  71. * @throws \think\Exception
  72. */
  73. public function isUnique($params) {
  74. $_where = array(
  75. 'qq' => $params['qq'],
  76. 'type' => $params['type'],
  77. );
  78. $_res = (new QqConfModel())->where($_where)->field('id,is_delete')->find();
  79. if (!empty($_res)) {
  80. $_res = $_res->toArray();
  81. }
  82. return $_res;
  83. }
  84. /***
  85. * 获取qq和qq群
  86. *
  87. * @param string $ids
  88. *
  89. * @return array
  90. * @throws \think\db\exception\DataNotFoundException
  91. * @throws \think\db\exception\ModelNotFoundException
  92. * @throws \think\exception\DbException
  93. */
  94. public function getQqs($ids = '') {
  95. $_rdata = [0 => [], 1 => []];
  96. if (empty($ids)) {
  97. return $_rdata;
  98. }
  99. $_map = ['id' => ['in', $ids]];
  100. $_data = (new QqConfModel())->where($_map)->field('qq,type')->select();
  101. if (is_object($_data)) {
  102. $_data = $_data->toArray();
  103. }
  104. if (empty($_data)) {
  105. return $_rdata;
  106. }
  107. $_qq = [];
  108. $_qqgroup = [];
  109. foreach ($_data as $_k => $_v) {
  110. if (GameConst::QQ_TYPE_QQ == $_v['type']) {
  111. $_qq[] = $_v['qq'];
  112. } else {
  113. $_qqgroup[] = $_v['qq'];
  114. }
  115. }
  116. $_rdata[0] = implode(',', $_qq);
  117. $_rdata[1] = implode(',', $_qqgroup);
  118. return $_rdata;
  119. }
  120. }