find(array('uid' => $uid)); if ($info) { return $info['value']; } else { //$code = Dever::uid($uid); $code = Str::rand(5, 0); return $this->createCode($uid, $code); } } private function createCode($uid, $code) { $info = Dever::db('code', 'invite')->find(array('value' => $code)); if ($info) { $code = Str::rand(5, 0); return $this->createCode($uid, $code); } else { Dever::db('code', 'invite')->insert(array('value' => $code, 'uid' => $uid)); return $code; } } # 根据邀请码获取邀请人uid public function getUid($code) { $info = Dever::db('code', 'invite')->find(array('value' => $code)); if ($info) { return $info['uid']; } return false; } }