123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <?php
- /**
- * QqConfModel.php UTF-8
- * QQ配置
- *
- * @date : 2018/4/26 1:17
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : wuyonghong <wyh@huosdk.com>
- * @version : HUOSDK 8.0
- */
- namespace huo\model\conf;
- use huo\model\common\CommonModel;
- use think\db\exception\DataNotFoundException;
- use think\db\exception\ModelNotFoundException;
- use think\Exception;
- use think\exception\DbException;
- class QqConfModel extends CommonModel {
- protected $name = 'qq_conf';
- protected $autoWriteTimestamp = true;
- /**
- * 获取网页访问串
- *
- * @param $value
- *
- * @return string
- */
- public function getIdkeyAttr($value) {
- $_value = $value;
- if (!empty($_value)) {
- $_value = '//shang.qq.com/wpa/qunwpa?idkey='.$_value;
- }
- return $_value;
- }
- /**
- * 获取IOS访问串
- *
- * @param $value
- * @param $data
- *
- * @return string
- */
- public function getIosKeyAttr($value, $data) {
- $_value = $value;
- if (!empty($_value)) {
- $_value
- = 'mqqapi://card/show_pslcard?src_type=internal&version=1&uin='.$data['qq'].'&key='.$_value
- .'&card_type=group&source=external';
- }
- return $_value;
- }
- /**
- * 获取ANDROID访问串
- *
- * @param $value
- *
- * @return string
- */
- public function getAndKeyAttr($value) {
- $_value = $value;
- if (!empty($_value)) {
- $_value
- = 'mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D'
- .$_value;
- }
- return $_value;
- }
- /**
- * @param int $qq_id
- *
- * @param bool $is_origin 是否使用原始数据
- *
- * @return array|null
- */
- public function getInfoByQqId($qq_id, $is_origin = false) {
- if (empty($qq_id)) {
- return null;
- }
- $_map['id'] = $qq_id;
- try {
- $_field = 'type,qq,idkey,ios_key,and_key';
- $_qq_data = $this->field($_field)->where($_map)->find();
- if (is_object($_qq_data)) {
- if ($is_origin) {
- $_qq_data = $_qq_data->getData();
- } else {
- $_qq_data = $_qq_data->toArray();
- }
- }
- return $_qq_data;
- } catch (DataNotFoundException $e) {
- return null;
- } catch (ModelNotFoundException $e) {
- return null;
- } catch (DbException $e) {
- return null;
- } catch (Exception $e) {
- return null;
- }
- }
- /**
- * @param string $qq_ids
- * @param int $type
- *
- * @return array|null
- */
- public function getInfoByQqIds($qq_ids, $type) {
- if (empty($qq_ids)) {
- return null;
- }
- $_map['id'] = ['in', $qq_ids];
- $_map['type'] = $type;
- $_field = 'qq';
- $_qq_data = $this->field($_field)->where($_map)->column($_field);
- return $_qq_data;
- }
- /**
- * 更新QQ信息
- *
- * @param $qq_data
- * @param $qq_id
- *
- * @return bool
- */
- public function updateQq($qq_data, $qq_id) {
- $_map['id'] = $qq_id;
- $_data = $qq_data;
- $_data['update_time'] = time();
- $_rs = self::update($_data, $_map, true);
- if (false == $_rs) {
- return false;
- } else {
- return true;
- }
- }
- /**
- * 获取qq列表
- *
- * @param array $fields
- * @param array $where
- *
- * @return false|\PDOStatement|string|\think\Collection
- * @throws DataNotFoundException
- * @throws DbException
- * @throws ModelNotFoundException
- */
- public function getQqs($fields = [], $where = []) {
- $_model = [];
- if (!empty($fields)) {
- $_model = $this->field($fields);
- }
- if (!empty($where)) {
- $_model = $this->where($where);
- }
- return $_model->select();
- }
- /**
- * 添加QQ
- *
- * @param $data
- *
- * @return bool|mixed
- */
- public function addQqs($data) {
- if (empty($data)) {
- return false;
- }
- $data['create_time'] = time();
- if ($_obj = self::create($data, true)) {
- return $_obj->id;
- } else {
- return false;
- }
- }
- /**
- * 根据类型获得id name
- *
- * @param int $type
- *
- * @return array
- */
- public function getQqIdName($type = 1) {
- return self::where(['type' => $type, 'is_delete' => 2])->column('qq', 'id');
- }
- }
|