//递归推荐码不重复
public function getcode(){
$code = $this->myRand();
$isexist = Db::name('tuijian_code')->where('code',$code)->find();
if(empty($isexist)){
return $code;
}else{
return $this->getWelcode();
}
}
//生成推荐码
public function myRand(){
if(PHP_VERSION < '4.2.0'){
srand();
}
$randArr = array();
for($i = 0; $i < 3; $i++){
$randArr[$i] = rand(0, 9);
$randArr[$i + 3] = chr(rand(0, 25) + 97);
}
shuffle($randArr);
return implode('', $randArr);
}