Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
projecttwo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangtao
projecttwo
Commits
beae8456
Commit
beae8456
authored
May 16, 2025
by
wangzhengwen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
订单号生成优化
parent
d7fa8090
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
UtilService.php
app/api/service/UtilService.php
+6
-5
No files found.
app/api/service/UtilService.php
View file @
beae8456
...
@@ -19,13 +19,14 @@ class UtilService
...
@@ -19,13 +19,14 @@ class UtilService
// return $str.'-'. $timestamp . $random . ($userPart ? ('-' . $userPart) : '');
// return $str.'-'. $timestamp . $random . ($userPart ? ('-' . $userPart) : '');
// }
// }
public
static
function
generateCompactOrderNo
(
$userId
=
null
,
$str
=
null
)
//生成订单号 示例 ORD-042-230815123456789
public
static
function
generateCompactOrderNo
(
$userId
=
null
,
$prefix
=
null
)
{
{
$time
=
substr
(
time
(),
-
6
);
// 取时间戳后6位
$time
=
date
(
'ymdHis'
);
$rand
=
mt_rand
(
100
000
,
999999
);
// 6位随机数
$rand
=
mt_rand
(
100
,
999
);
$user
=
$userId
?
chr
(
65
+
(
$userId
%
26
))
:
''
;
// 用户标识转A-Z
$user
Code
=
$userId
?
str_pad
(
$userId
%
1000
,
3
,
'0'
,
STR_PAD_LEFT
)
:
''
;
return
$str
.
$user
.
$time
.
$rand
;
return
trim
(
implode
(
'-'
,
array_filter
([
$prefix
,
$userCode
,
$time
.
$rand
])),
'-'
)
;
}
}
public
static
function
listWithTags
(
$list
,
string
$modelClass
,
string
$tagIdsField
=
'tag_ids'
)
:
array
public
static
function
listWithTags
(
$list
,
string
$modelClass
,
string
$tagIdsField
=
'tag_ids'
)
:
array
...
...
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