Commit ccebc0c4 authored by jianghaiming's avatar jianghaiming

update:修改冲突

parents ace9831e 91132a3f
......@@ -9,7 +9,7 @@ use App\Exception\BaseException;
class UserException extends BaseException
{
protected $base_code = Code::USUR;
const APP_ID_NULL = 15;
protected $cus = [
0 => 'code 无效',
1 => '获取openid失败',
......@@ -26,5 +26,6 @@ class UserException extends BaseException
12 => '绑定手机号保存失败',
13 => '请求太频繁,稍后重试',
14 => '手机号格式错误',
self::APP_ID_NULL => 'AppId 不能为空',
];
}
\ No newline at end of file
......@@ -37,19 +37,16 @@ class UserService
public static function wechatLogin($params)
{
self::$code = !empty($params['code']) ? $params['code'] : '';//小程序授权code
$appid = !empty($params['appid']) ? $params['appid'] : 1; //登陆来源
$appid = !empty($params['appid']) ? $params['appid'] : ''; //登陆来源
$inviteUserId = !empty($params['invite_user_id']) ? intval($params['invite_user_id']) : 0;//邀请用户id
$activityType = !empty($params['activity_type']) ? intval($params['activity_type']) : 0;//活动类型
if (empty(self::$code)) {
FileLog::error("wechatLogin:获取参数为空", json_encode($params, JSON_UNESCAPED_UNICODE), '', 'jianghaiming@yidian-inc.com');
throw new UserException(['cus' => 0]);
}
//验证登陆参数
self::checkWechatLoginParams($params);
$lock = self::getWechatLoginLock($params);
if(!empty($lock)){
return $lock;
}
//设置小程序配置
self::setWechatConfig($appid);
//获取小程序用户信息
......@@ -103,6 +100,22 @@ class UserService
return $user;
}
/**
* 验证登陆参数
* @param $params
* @throws UserException
*/
public static function checkWechatLoginParams($params)
{
if (empty(self::$code)) {
FileLog::error("wechatLogin:获取参数为空", json_encode($params, JSON_UNESCAPED_UNICODE), '', 'jianghaiming@yidian-inc.com');
throw new UserException(['cus' => 0]);
}
if (empty($params['appid'])) {
throw new UserException(['cus' => UserException::APP_ID_NULL]);
}
}
/**
* 初始化微信配置
* @param $wechatFrom
......@@ -110,13 +123,8 @@ class UserService
public static function setWechatConfig($wechatFrom)
{
//需要授权微信
if ($wechatFrom == 'merchant-pub-deliverer') {
self::$appid = \Yaf\Registry::get('config')->deliverer->wechat->appid;
self::$secret = \Yaf\Registry::get('config')->deliverer->wechat->secret;
}else{
self::$appid = \Yaf\Registry::get('config')->wechat->appid;
self::$secret = \Yaf\Registry::get('config')->wechat->secret;
}
self::$appid = \Yaf\Registry::get('config')->wechat->appid->$wechatFrom;
self::$secret = \Yaf\Registry::get('config')->wechat->secret->$wechatFrom;
}
/**
......@@ -186,6 +194,8 @@ class UserService
public static function bindPhone($params){
self::$openid = !empty($params['openid']) ? $params['openid'] : '';
$phone = !empty($params['mobile']) ? $params['mobile'] : '';
$wechatFrom = !empty($params['appid']) ? $params['appid'] : '';
self::setWechatConfig($wechatFrom);
if (!empty($phone)){
$userInfo = self::delivererBindPhone($params);
}else{
......@@ -213,9 +223,15 @@ class UserService
if (!empty($check) && $check['status'] == 'failed') {
throw new BaseException(['code' => $check['code'], 'msg' => $check['reason']]);
}
$jwUser = (new JwUser ())->getUserInfo(['mobile' => $mobile]);
$userId = '';
if (!empty($jwUser['data'])) {
$data = $jwUser['data'];
$userId = !empty($data['userId']) ? $data['userId'] : '';
}
$userInfo = UserWechatBind::getRecordMaster(['openid' => self::$openid]);
CommonService::activateDeliverer(['user_id' => $userId,'phone' => $mobile]);
$userInfo = array_merge($userInfo,self::saveWechatPhone($mobile,$userInfo)) ;
CommonService::activateDeliverer(['user_id' => $userInfo['user_id'],'phone' => $userInfo['phone']]);
return $userInfo;
}
......@@ -262,7 +278,6 @@ class UserService
{
$encryptedData = !empty($params['encryptedData']) ? $params['encryptedData'] : '';
$iv = !empty($params['iv']) ? $params['iv'] : '';
$appid = \Yaf\Registry::get('config')->wechat->appid;
if (!$encryptedData) {
FileLog::error("bindPhone:encryptedData 为空", json_encode($params, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
......@@ -284,7 +299,7 @@ class UserService
//解密
$decryptData = [];
$wXBizDataCrypt = new WxBizDataCrypt($appid, $sessionKey);
$wXBizDataCrypt = new WxBizDataCrypt(self::$appid, $sessionKey);
$errCode = $wXBizDataCrypt->decryptData($encryptedData, $iv, $decryptData);
if ($errCode) {
......
......@@ -21,6 +21,16 @@ idgen.key = "5cfdb867e96374c7883b31d6928cc4cb"
wechat.appid = "wx4e0d92499185fb74";
wechat.secret = "731bcf2f7ebb1ebddb677618c2008b25";
wechat.appid.merchant-pub-pin = "wx4e0d92499185fb74"
wechat.secret.merchant-pub-pin = "731bcf2f7ebb1ebddb677618c2008b25"
wechat.appid.merchant-pub-deliverer = "wx91042f2a75f8b994"
wechat.secret.merchant-pub-deliverer = "09d7ea5472d871b4b1a0f3100bdfe1c9"
wechat.appid.merchant-pub-idle = "wx415fe9cb54be1e09"
wechat.secret.merchant-pub-idle = "b1badcd547f47a456f400016af90b46f"
deliverer.wechat.appid = "wx91042f2a75f8b994";
deliverer.wechat.secret = "09d7ea5472d871b4b1a0f3100bdfe1c9";
......
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