Compare commits

..

2 Commits

@ -9,6 +9,7 @@ namespace app\crm\controller;
use app\common\wework\api\Api;
use app\common\wework\callback\WXBizMsgCrypt;
use think\Cache;
use think\Controller;
use think\Log;
use think\Request;
@ -126,16 +127,33 @@ class Callback extends Controller
$code = Request::instance()->get('code');
$api = new Api(config('wework.corpId'), config('wework.corpSecret'));
$userInfo = $api->getUserInfo($code);
Log::record('用户信息'.json_encode($userInfo));
if (isset($userInfo['userid']) && $userInfo['userid']) {
Session::set('wxuser_id', $userInfo['userid']);
$adminUser = db('admin_user')->where('wxwork_id', $userInfo['userid'])->find();
if ($adminUser) {
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());
} elseif (Session::get('user_id')) {
db('admin_user')->where('id', Session::get('user_id'))->update([
'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());
}
}

Loading…
Cancel
Save