You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
1.7 KiB
79 lines
1.7 KiB
<?php
|
|
|
|
namespace app\base\model\mpweixin;
|
|
|
|
use app\base\model\Base;
|
|
use app\base\model\wechat\WechatUser;
|
|
use think\model\concern\SoftDelete;
|
|
|
|
class MpweixinUser extends Base
|
|
{
|
|
use SoftDelete;
|
|
|
|
// 设置当前模型对应的完整数据表名称
|
|
protected $table = 'base_mpweixin_user';
|
|
|
|
|
|
/**
|
|
* 更新小程序用户信息
|
|
* @param array $data 小程序用户信息
|
|
* @date 2021-03-01
|
|
*/
|
|
public function updateUser($data)
|
|
{
|
|
$where = [
|
|
['openid', '=', $data['openid']]
|
|
];
|
|
$id = $this->getOneData($where, 'id');
|
|
|
|
if (!empty($id)) {
|
|
$data['id'] = $id;
|
|
}
|
|
|
|
return $this->dataUpdate($data);
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取用户会话秘钥session_key
|
|
* @date 2022-10-18
|
|
*/
|
|
public function getSessionKey($openid)
|
|
{
|
|
$where = [
|
|
['uid', '=', $this->mid],
|
|
['openid', '=', $openid]
|
|
];
|
|
return $this->getOneData($where, 'session_key');
|
|
}
|
|
|
|
/**
|
|
* 解除平台绑定
|
|
* @param integer $user_id USER_ID
|
|
* @date 2021-03-01
|
|
*/
|
|
public function unbindPlatform($user_id)
|
|
{
|
|
$where = [
|
|
['user_id', '=', $user_id]
|
|
];
|
|
$id = $this->getOneData($where, 'id');
|
|
|
|
if (!empty($id)) {
|
|
$data['id'] = $id;
|
|
$data['user_id'] = 0;
|
|
return $this->dataUpdate($data);
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public function getUserWechatOpenid($user_id)
|
|
{
|
|
$wehcat_user_model = new WechatUser();
|
|
$unionid = $this->getOneData(['user_id'=>$user_id],'unionid');
|
|
$openid = $wehcat_user_model->getOneData(['unionid'=>$unionid],'openid');
|
|
return $openid;
|
|
}
|
|
}
|