yy-4.20
杨赟 2 years ago
parent c61dd5910e
commit 8b2d951a88

@ -9,6 +9,7 @@ namespace app\crm\controller;
use app\common\wework\api\Api; use app\common\wework\api\Api;
use app\common\wework\callback\WXBizMsgCrypt; use app\common\wework\callback\WXBizMsgCrypt;
use think\Cache;
use think\Controller; use think\Controller;
use think\Log; use think\Log;
use think\Request; use think\Request;
@ -126,16 +127,33 @@ class Callback extends Controller
$code = Request::instance()->get('code'); $code = Request::instance()->get('code');
$api = new Api(config('wework.corpId'), config('wework.corpSecret')); $api = new Api(config('wework.corpId'), config('wework.corpSecret'));
$userInfo = $api->getUserInfo($code); $userInfo = $api->getUserInfo($code);
Log::record('用户信息'.json_encode($userInfo));
if (isset($userInfo['userid']) && $userInfo['userid']) { if (isset($userInfo['userid']) && $userInfo['userid']) {
Session::set('wxuser_id', $userInfo['userid']); Session::set('wxuser_id', $userInfo['userid']);
$adminUser = db('admin_user')->where('wxwork_id', $userInfo['userid'])->find(); $adminUser = db('admin_user')->where('wxwork_id', $userInfo['userid'])->find();
if ($adminUser) { if ($adminUser) {
Session::set('user_id', $adminUser['id']); Session::set('user_id', $adminUser['id']);
$info['userInfo'] = $adminUser;
$info['sessionId'] = session_id();
// $info['_AUTH_LIST_'] = $dataList['rulesList'];
$info['authKey'] = 'wxwork';
if (!Cache::get('Auth_wxwork')) {
Cache::set('Auth_wxwork', $info);
}
return redirect('http://web.lbschem.com:8088/?authkey=wxwork&sessionid='.session_id()); return redirect('http://web.lbschem.com:8088/?authkey=wxwork&sessionid='.session_id());
} elseif (Session::get('user_id')) { } elseif (Session::get('user_id')) {
db('admin_user')->where('id', Session::get('user_id'))->update([ db('admin_user')->where('id', Session::get('user_id'))->update([
'wxwork_id' => $userInfo['userid'] 'wxwork_id' => $userInfo['userid']
]); ]);
$adminUser = db('admin_user')->where('id', Session::get('user_id'))->find();
$info['userInfo'] = $adminUser;
$info['sessionId'] = session_id();
// $info['_AUTH_LIST_'] = $dataList['rulesList'];
$info['authKey'] = 'wxwork';
if (!Cache::get('Auth_wxwork')) {
Cache::set('Auth_wxwork', $info);
}
return redirect('http://web.lbschem.com:8088/?authkey=wxwork&sessionid='.session_id()); return redirect('http://web.lbschem.com:8088/?authkey=wxwork&sessionid='.session_id());
} }
} }

Loading…
Cancel
Save