//生成邀请码(8位)
function invite_code() {
$code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$rand = $code[rand(0, 25)]
. strtoupper(dechex(date('m')))
. date('d') . substr(time(), -5)
. substr(microtime(), 2, 5)
. sprintf('%02d', rand(0, 99));
$a = md5($rand, true);
$s = '0123456789ABCDEFGHIJKLMNOPQRSTUV';
$d = '';
for ($f = 0; $f < 8; $f++) {
$g = ord($a[$f]);
$d .= $s[($g ^ ord($a[$f + 8])) - $g & 0x1F];
}
return $d;
}
//生成指定长度随机字符串
function randstrs($length) {
$pattern = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLOMNOPQRSTUVWXYZ';
$length = strlen($pattern);
$key = '';
for ($i = 0; $i < $length; $i++) {
$key .= $pattern{mt_rand(0, $length)}; //生成php随机数
}
return $key;
}
//获取订单号
function getOrderNo($prefix='OD')
{
$orderno = $prefix . date('YmdHis',time()). mt_rand(10000, 99999);
return $orderno;
}