public function alipayCallbackAction() { $alipay = new \Ucenter\Utils\AlipayApi($this->di); $acInfo = $alipay->verifyReturn(); if (!$acInfo) { header('Location: /'); } $openId = $_GET['user_id']; if ($this->session->has('uid') && isset($openId)) { $user = new Users(); // 校验该第三方账号是否已存在 if ($user->getUinfo($openId, 'alipay')) { echo '<script>alert("绑定失败,该账号已绑定其他用户");window.location.href="/user/accountbind";</script>'; return; } else { if ($user->bindAlipay($this->session->get('uid'), $openId)) { $this->response->redirect('user/accountbind'); } else { throw new E('Ailpay bind failed'); } } } else { $user = new Users(); if ($uinfo = $user->getUinfo($openId, 'alipay')) { $cas = new \Ucenter\Utils\cas\CAServer(); $this->session->set('uid', $uinfo['u_id']); $this->session->set('uinfo', array('name' => $uinfo['u_name'], 'mobile' => $uinfo['u_mobi'])); $cas->casSave(0, 0); $this->response->redirect('user/index'); } else { //获取用户信息 $uidInfo = $_GET; if (!isset($uidInfo['user_id'])) { header('Location: /'); } $info = array('type' => 'alipay', 'name' => $uidInfo['real_name'], 'uids' => $openId, 'pic' => ''); setcookie(substr(md5('tmpQqWb'), 8, 20), base64_encode(json_encode($info)), $_SERVER['REQUEST_TIME'] + 1800, '/'); $this->response->redirect('index/addUserInfo'); } } }