public function passAction($targetId) { MyTool: simpleView(); if (!MyTool::loginAuth($this)) { return MyTool::onExit($this, MyConst::STATUS_NOT_LOGIN, 'must login first'); } $targetId = @intval($targetId); $uid = @intval(MyTool::getCookie($this, MyConst::COOKIE_UID)); // 查询加群邀请 $invitation = MaTeamInvitation::invited($uid, $targetId); if (empty($invitation)) { return MyTool::onExit($this, MyConst::STATUS_NOT_EXISTS, 'invitation not exists'); } // 判断是否已经是群成员 if (TeamLogic::hasMember($uid, $targetId)) { return MyTool::onExit($this, MyConst::STATUS_EXISTS, 'already member of team'); } if (TeamLogic::isOwner($uid, $targetId)) { return MyTool::onExit($this, MyConst::STATUS_EXISTS, 'owner of team'); } // 更新邀请状态 try { $invitation->pass(); if (true !== $invitation->update()) { return MyTool::onExit($this, MyConst::STATUS_DB, 'update invitation fail'); } } catch (Exceptioni $e) { return MyTool::onExit($this, MyConst::STATUS_DB, $e->getMessage()); } // 添加一个成员 $member = MaTeamMember::addMember($targetId, $uid); try { if (true !== $member->save()) { return MyTool::onExit($this, MyConst::STATUS_DB, 'add new member'); } } catch (Exception $e) { return MyTool::onExit($this, MyConst::STATUS_DB, $e->getMessage()); } MyTool::setVar($this, MyConst::FIELD_STATUS, MyConst::STATUS_OK); return true; }