public function update(App_Account_TaobaoUserInfoDm $dm) { if (true !== ($r = $dm->beforeUpdate())) { return $r; } return $this->_loadDao()->update($dm->getUserId(), $dm->getData()); }
/** * 获取淘宝响应信息 如果oauth2正常流程,可以走curl_init */ public function getResponseInfo() { $result = $this->checkStatus(); if ($result !== true) { return new PwError($result); } $sessionId = Pw::getCookie($this->_getLoginSessionService()->getCookieName()); $sessionInfo = App_Account_LoginSessionBo::getInstance($sessionId)->getSession(); if (!$sessionId || !$sessionInfo) { return new PwError('验证会话失败,请重试'); } list($top_parameters, $top_sign) = array(trim($_REQUEST['top_parameters']), trim($_REQUEST['top_sign'])); if ($this->_checkSign() === false) { return new PwError('与淘宝通信失败,请重试'); } $userInfo = $this->_getUserInfo(); if ($userInfo === false) { return new PwError('获取用户信息失败,请重试'); } list($user_id, $nick) = $userInfo; //更新数据库 $info = $this->_getTaobaoUserInfoDs()->get($user_id); if (!$info) { $dm = new App_Account_TaobaoUserInfoDm(); $dm->setUserId($user_id)->setNick($nick)->setCreateAt(Pw::getTime()); $this->_getTaobaoUserInfoDs()->add($dm); } //更新session $this->updateSession($user_id, $nick, 'taobao'); return true; }