Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
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
youjj
cloud-platform
Commits
1ba8ba26
Commit
1ba8ba26
authored
Nov 06, 2020
by
周健威
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master-tiande' into dev-tiande
parents
0e6f3180
fc0e230d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
10 deletions
+13
-10
OrderUtil.java
...va/com/github/wxiaoqi/security/common/util/OrderUtil.java
+13
-10
No files found.
ace-common/src/main/java/com/github/wxiaoqi/security/common/util/OrderUtil.java
View file @
1ba8ba26
...
...
@@ -6,14 +6,16 @@ import cn.hutool.core.util.StrUtil;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Random
;
import
java.util.concurrent.atomic.AtomicInteger
;
public
class
OrderUtil
{
public
static
final
String
DEFAULT_MID
=
"00"
;
public
static
final
String
APP_MID
=
"01"
;
public
static
final
String
COMPANY_MID
=
"05"
;
static
Date
today
=
new
Date
();
static
int
orderIndex
=
0
;
static
AtomicInteger
orderIndex
=
new
AtomicInteger
(
0
)
;
@SuppressWarnings
(
"deprecation"
)
private
static
String
getIndex
(
String
midFix
)
{
...
...
@@ -24,19 +26,19 @@ public class OrderUtil {
SimpleDateFormat
outFormat
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
String
currTime
=
outFormat
.
format
(
n
);
if
(
orderIndex
>
0
)
{
if
(
orderIndex
.
intValue
()
>
0
)
{
if
(
n
.
getYear
()
==
today
.
getYear
()
&&
n
.
getMonth
()
==
today
.
getMonth
()
&&
n
.
getDay
()
==
today
.
getDay
())
{
orderIndex
+=
1
;
orderIndex
.
getAndIncrement
()
;
}
else
{
today
=
n
;
orderIndex
=
1
;
orderIndex
=
new
AtomicInteger
(
1
)
;
}
}
else
{
today
=
n
;
orderIndex
=
1
;
orderIndex
=
new
AtomicInteger
(
1
)
;
}
if
(
orderIndex
>
9999
)
{
orderIndex
=
1
;
if
(
orderIndex
.
intValue
()
>
9999
)
{
orderIndex
=
new
AtomicInteger
(
1
)
;
}
String
indexString
=
String
.
format
(
"%s%s%04d"
,
currTime
,
midFix
,
orderIndex
);
return
indexString
;
...
...
@@ -44,7 +46,7 @@ public class OrderUtil {
/**
* 生成订单号
*
*
* @param preFixString
* @return
*/
...
...
@@ -66,7 +68,7 @@ public class OrderUtil {
/**
* 获取时间戳
*
*
* @return
*/
public
static
String
GetTimestamp
()
{
...
...
@@ -75,7 +77,7 @@ public class OrderUtil {
/**
* 生成随机数
*
*
* @return
*/
public
static
String
CreateNoncestr
()
{
...
...
@@ -83,3 +85,4 @@ public class OrderUtil {
return
MD5
.
GetMD5String
(
String
.
valueOf
(
random
.
nextInt
(
10000
)));
}
}
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