提交 a19878be 编写于 作者: G gongfuxiang

wx pay

上级 62edc518
......@@ -23,6 +23,19 @@ use app\plugins\weixinwebauthorization\service\Service;
*/
class Auth extends Controller
{
/**
* 支付授权
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-05-25T14:44:32+0800
* @param [array] $params [输入参数]
*/
public function Pay($params = [])
{
return $this->Index($params);
}
/**
* 授权
* @author Devil
......@@ -92,7 +105,7 @@ class Auth extends Controller
}
// 处理用户数据
$ret = Service::WeixinAuthReg($ret['data']);
$ret = Service::WeixinAuthBind($ret['data']);
if($ret['code'] == 0)
{
$this->assign('msg', $ret['msg']);
......@@ -186,6 +199,5 @@ class Auth extends Controller
return DataReturn($ret['msg'], -1);
}
}
}
?>
\ No newline at end of file
......@@ -24,7 +24,7 @@ use app\service\PluginsService;
class Service
{
/**
* 微信登录注册
* 微信绑定
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
......@@ -32,26 +32,38 @@ class Service
* @desc description
* @param [array] $params [输入参数]
*/
public static function WeixinAuthReg($params = [])
public static function WeixinAuthBind($params = [])
{
// openid
if(empty($params['openid']))
{
return DataReturn('用户openid为空', -1);
}
// 获取登录用户
$user = UserService::LoginUserInfo();
if(!empty($user))
{
return DataReturn('已登录,请先退出', -1);
}
// 是否已绑定
if(!empty($user['weixin_web_openid']))
{
return DataReturn('该帐号已绑定微信,请先解绑', -1);
}
// 是否有登录纪录
if(!empty($params['openid']))
{
$user = UserService::UserInfo('weixin_web_openid', $params['openid']);
if(!empty($user))
// 绑定
if(Db::name('User')->where(['id'=>$user['id']])->update(['weixin_web_openid'=>$params['openid'], 'upd_time'=>time()]))
{
// 用户登录
return UserService::UserLoginHandle($user['id'], $params);
return DataReturn('绑定成功', 0);
}
} else {
return DataReturn('用户openid为空', -1);
return DataReturn('绑定失败', -100);
}
// openid登录
$user = UserService::UserInfo('weixin_web_openid', $params['openid']);
if(!empty($user))
{
// 用户登录
return UserService::UserLoginHandle($user['id'], $params);
}
// 用户名
......
......@@ -143,21 +143,10 @@ class Weixin
}
// 微信中打开
// if(!empty($_SERVER['HTTP_USER_AGENT']) && stripos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false)
// {
// $input = input();
// if(empty($input['code']))
// {
// $this->GetUserOpenId($params);
// } else {
// $ret = $this->Callback($input);
// if($ret['code'] != 0)
// {
// return $ret;
// }
// $params['user']['weixin_web_openid'] = $ret['data'];
// }
// }
if(!empty($_SERVER['HTTP_USER_AGENT']) && stripos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false && empty($params['user']['weixin_web_openid']))
{
exit(header('location:'.PluginsHomeUrl('weixinwebauthorization', 'auth', 'pay', input())));
}
// 获取支付参数
$ret = $this->GetPayParams($params);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册