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.

42 lines
1014 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace app\base\logic\mpweixin;
use app\base\model\mpweixin\MpweixinUser;
use app\base\model\wechat\WechatUser;
class User extends Base
{
/**
* 根据unionid判断是否关注微信在同一微信开放平台下绑定
* @date 2022-12-28
*/
public function isSubscribeWeixin()
{
$mpweixin_user_model = new MpweixinUser();
$weixin_usear_model = new WechatUser();
// 获取微信小程序用户信息
$unionid = $mpweixin_user_model->getOneData([
['openid', '=', $this->openid]
], 'unionid');
if (empty($unionid)) {
return sendErrorArray(3001, '没有获取到unoinid');
}
// 查找微信公众号是否关注
$result = $weixin_usear_model->getOneData([
['unionid', '=', $unionid]
], 'id,openid');
return sendSuccessArray([
// 是否关注公众号
'is_subscribe_weixin' => empty($result) ? 0 : 1
]);
}
}