1.缺失信息提交
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
// 应用公共文件
|
||||
use app\common\service\FileService;
|
||||
use think\helper\Str;
|
||||
|
||||
use think\facade\{Db, Config};
|
||||
/**
|
||||
* @notes 生成密码加密密钥
|
||||
* @param string $plaintext
|
||||
@ -122,6 +122,80 @@ function linear_to_tree($data, $sub_key_name = 'sub', $id_name = 'id', $parent_i
|
||||
return $tree;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成会员码
|
||||
* @return 会员码
|
||||
*/
|
||||
function create_user_sn($prefix = '', $length = 8)
|
||||
{
|
||||
$rand_str = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$rand_str .= mt_rand(0, 9);
|
||||
}
|
||||
$sn = $prefix . $rand_str;
|
||||
if (Db::name('user')->where(['sn' => $sn])->find()) {
|
||||
return create_user_sn($prefix, $length);
|
||||
}
|
||||
return $sn;
|
||||
}
|
||||
|
||||
//生成用户邀请码
|
||||
function generate_invite_code()
|
||||
{
|
||||
|
||||
$letter_all = range('A', 'Z');
|
||||
shuffle($letter_all);
|
||||
//排除I、O字母
|
||||
$letter_array = array_diff($letter_all, ['I', 'O', 'D']);
|
||||
//排除1、0
|
||||
$num_array = range('2', '9');
|
||||
shuffle($num_array);
|
||||
|
||||
$pattern = array_merge($num_array, $letter_array, $num_array);
|
||||
shuffle($pattern);
|
||||
$pattern = array_values($pattern);
|
||||
|
||||
$code = '';
|
||||
for ($i = 0; $i < 6; $i++) {
|
||||
$code .= $pattern[mt_rand(0, count($pattern) - 1)];
|
||||
}
|
||||
|
||||
$code = strtoupper($code);
|
||||
$check = Db::name('user')->where('distribution_code', $code)->find();
|
||||
if ($check) {
|
||||
return generate_invite_code();
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
/**
|
||||
* User: 意象信息科技 mjf
|
||||
* Desc: 用时间生成订单编号
|
||||
* @param $table
|
||||
* @param $field
|
||||
* @param string $prefix
|
||||
* @param int $rand_suffix_length
|
||||
* @param array $pool
|
||||
* @return string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
function createSn($table, $field, $prefix = '', $rand_suffix_length = 4, $pool = [])
|
||||
{
|
||||
$suffix = '';
|
||||
for ($i = 0; $i < $rand_suffix_length; $i++) {
|
||||
if (empty($pool)) {
|
||||
$suffix .= rand(0, 9);
|
||||
} else {
|
||||
$suffix .= $pool[array_rand($pool)];
|
||||
}
|
||||
}
|
||||
$sn = $prefix . date('YmdHis') . $suffix;
|
||||
if (Db::name($table)->where($field, $sn)->find()) {
|
||||
return createSn($table, $field, $prefix, $rand_suffix_length, $pool);
|
||||
}
|
||||
return $sn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除目标目录
|
||||
|
||||
Reference in New Issue
Block a user