private function GetUserInfo() { $UserModel = new AnymagicUserModel(); $UserInfo = $UserModel->CheckUser($this->WechatOpenId, $this->WechatUnionId); if ($UserInfo !== false && $UserInfo != null) { if ($UserInfo['lasttime'] <= time()) { $JssdkModel = new JSSDKModel(); $UserInfo = $JssdkModel->getUserInfo($this->WechatOpenId); if (isset($UserInfo['errcode'])) { $UserInfo = ''; echo $UserInfo['errmsg'], '<br />'; exit; } $UpResult = $UserModel->UpdateUser($UserInfo); if ($UpResult == false) { echo 'GetUserInfo UpResult False', '<br />'; } } } else { if (!empty($this->WechatOpenId)) { $JssdkModel = new JSSDKModel(); $UserInfo = $JssdkModel->getUserInfo($this->WechatOpenId); if (isset($UserInfo['errcode'])) { $UserInfo = ''; echo $UserInfo['errmsg'], '<br />'; exit; } $AddResult = $UserModel->AddNewUser($UserInfo); if ($AddResult == false) { echo 'GetUserInfo AddResult False', '<br />'; } } else { $UserInfo = false; } } return $UserInfo; }
private function GetUserId() { if (!empty($_SESSION['user']['userid'])) { return $_SESSION['user']['userid']; exit; } $UserModel = new AnymagicUserModel(); $result = $UserModel->GetUserInfo($UserId = '', $_SESSION['user']['openid'], 'userid'); if ($result !== false && $result !== null) { $_SESSION['user']['userid'] = $result['userid']; return $_SESSION['user']['userid']; } else { return false; } }