Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
introducer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sugar
introducer
Commits
1d1a7b6a
Commit
1d1a7b6a
authored
Jan 16, 2024
by
sugar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
订单统计
parent
c0da0573
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
6 deletions
+25
-6
application/api/controller/Users.php
application/api/controller/Users.php
+19
-1
application/common.php
application/common.php
+6
-5
No files found.
application/api/controller/Users.php
View file @
1d1a7b6a
...
@@ -841,9 +841,27 @@ class Users extends Api
...
@@ -841,9 +841,27 @@ class Users extends Api
$info
=
UsersModel
::
order
(
'id desc'
)
->
field
(
'id'
)
->
find
();
$info
=
UsersModel
::
order
(
'id desc'
)
->
field
(
'id'
)
->
find
();
$lastid
=
$info
[
'id'
];
$lastid
=
$info
[
'id'
];
for
(
$x
=
1
;
$x
<=
$lastid
;
$x
++
){
for
(
$x
=
1
;
$x
<=
$lastid
;
$x
++
){
$random_number
=
$this
->
recursion
();
/* $random_number = createRandomcode();
$info = UsersModel::where(['random_number' =>$random_number])->find();
if($info){
$random_number = createRandomcode();
$random_number = createRandomcode();
}*/
UsersModel
::
where
([
'id'
=>
$x
])
->
update
([
'random_number'
=>
$random_number
]);
UsersModel
::
where
([
'id'
=>
$x
])
->
update
([
'random_number'
=>
$random_number
]);
}
}
$this
->
success
(
'生成成功'
);
$this
->
success
(
'生成成功'
);
}
}
/**
* @return string
* 递归查询
*/
private
function
recursion
(){
$random_number
=
createRandomcode
();
$info
=
UsersModel
::
where
([
'random_number'
=>
$random_number
])
->
find
();
if
(
$info
){
$this
->
recursion
();
}
return
$random_number
;
}
}
}
application/common.php
View file @
1d1a7b6a
...
@@ -722,11 +722,12 @@ EOT;
...
@@ -722,11 +722,12 @@ EOT;
*/
*/
function
createRandomcode
()
function
createRandomcode
()
{
{
// 生成字母和数字组成的7位字符串
/
* /
/ 生成字母和数字组成的7位字符串
$str = range('A', 'Z');
$str = range('A', 'Z');
// 去除大写的O,以防止与0混淆
// 去除大写的O,以防止与0混淆
unset($str[array_search('O', $str)]);
unset($str[array_search('O', $str)]);
$arr
=
array_merge
(
range
(
0
,
9
),
$str
);
$arr = array_merge(range(0, 9), $str);*/
$arr
=
range
(
0
,
9
);
shuffle
(
$arr
);
shuffle
(
$arr
);
$invitecode
=
''
;
$invitecode
=
''
;
$arr_len
=
count
(
$arr
);
$arr_len
=
count
(
$arr
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment