Commit efecb871 authored by jianghaiming's avatar jianghaiming

Merge branch 'wx_user_20210929' into test

parents 7b4356b1 f5eb1825
...@@ -22,7 +22,7 @@ class UserService ...@@ -22,7 +22,7 @@ class UserService
private static $code = ''; private static $code = '';
private static $grantType = 'authorization_code'; private static $grantType = 'authorization_code';
private static $loginUrl = 'https://api.weixin.qq.com/sns/jscode2session'; private static $loginUrl = 'https://api.weixin.qq.com/sns/jscode2session';
private static $appid = ''; private static $wechatAppId = '';
private static $secret = ""; private static $secret = "";
private static $redis = ""; private static $redis = "";
private static $keyCode = ""; private static $keyCode = "";
...@@ -64,7 +64,7 @@ class UserService ...@@ -64,7 +64,7 @@ class UserService
'activity_type' => $activityType, 'activity_type' => $activityType,
'create_time' => date("Y-m-d H:i:s"), 'create_time' => date("Y-m-d H:i:s"),
'appid' => $appid, 'appid' => $appid,
'wechat_app_id' => self::$appid, 'wechat_app_id' => self::$wechatAppId,
]; ];
$sessionKey = !empty($response['session_key']) ? $response['session_key'] : ''; $sessionKey = !empty($response['session_key']) ? $response['session_key'] : '';
...@@ -122,7 +122,7 @@ class UserService ...@@ -122,7 +122,7 @@ class UserService
public static function setWechatConfig($wechatFrom) public static function setWechatConfig($wechatFrom)
{ {
//需要授权微信 //需要授权微信
self::$appid = \Yaf\Registry::get('config')->wechat->appid->$wechatFrom; self::$wechatAppId = \Yaf\Registry::get('config')->wechat->appid->$wechatFrom;
self::$secret = \Yaf\Registry::get('config')->wechat->secret->$wechatFrom; self::$secret = \Yaf\Registry::get('config')->wechat->secret->$wechatFrom;
} }
...@@ -158,7 +158,7 @@ class UserService ...@@ -158,7 +158,7 @@ class UserService
public static function getJscode2session(){ public static function getJscode2session(){
//请求接口,获取用户openid //请求接口,获取用户openid
$params = [ $params = [
'appid' => self::$appid, 'appid' => self::$wechatAppId,
'secret' => self::$secret, 'secret' => self::$secret,
'js_code' => self::$code, 'js_code' => self::$code,
'grant_type' => self::$grantType, 'grant_type' => self::$grantType,
...@@ -297,7 +297,7 @@ class UserService ...@@ -297,7 +297,7 @@ class UserService
//解密 //解密
$decryptData = []; $decryptData = [];
$wXBizDataCrypt = new WxBizDataCrypt(self::$appid, $sessionKey); $wXBizDataCrypt = new WxBizDataCrypt(self::$wechatAppId, $sessionKey);
$errCode = $wXBizDataCrypt->decryptData($encryptedData, $iv, $decryptData); $errCode = $wXBizDataCrypt->decryptData($encryptedData, $iv, $decryptData);
if ($errCode) { if ($errCode) {
...@@ -314,7 +314,12 @@ class UserService ...@@ -314,7 +314,12 @@ class UserService
$phoneNumber = strval($decryptData['phoneNumber']); $phoneNumber = strval($decryptData['phoneNumber']);
//判断是否已 //判断是否已
if ($params['appid'] == 'merchant-pub-pin') {
$user = UserWechatBind::getRecordMaster(['phone' => $phoneNumber]); $user = UserWechatBind::getRecordMaster(['phone' => $phoneNumber]);
}else{
$user = UserWechatBind::getRecordMaster(['phone' => $phoneNumber,'wechat_app_id' => self::$wechatAppId]);
}
if (!empty($user) && $openid != $user['openid']) { if (!empty($user) && $openid != $user['openid']) {
FileLog::error("bindPhone:该手机号已绑定其他用户不能重复绑定", json_encode($params, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com'); FileLog::error("bindPhone:该手机号已绑定其他用户不能重复绑定", json_encode($params, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
FileLog::error("bindPhone:该手机号已绑定其他用户不能重复绑定--user", json_encode($user, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com'); FileLog::error("bindPhone:该手机号已绑定其他用户不能重复绑定--user", json_encode($user, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
...@@ -410,6 +415,7 @@ class UserService ...@@ -410,6 +415,7 @@ class UserService
$update['openid'] = $params['openid']; $update['openid'] = $params['openid'];
$bindStatus = UserWechatBind::save($update); $bindStatus = UserWechatBind::save($update);
}else{ }else{
$update['update_time'] = date("Y-m-d H:i:s");
$bindStatus = UserWechatBind::save($update,['openid' => $params['openid']]); $bindStatus = UserWechatBind::save($update,['openid' => $params['openid']]);
} }
if (!$bindStatus) { if (!$bindStatus) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment