Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
95a55752
Commit
95a55752
authored
Apr 01, 2018
by
Junling Bu
Browse files
fix[litemall-db]: 订单编号以当前日期+6位随机数组组成。
parent
ad504bb3
Changes
1
Hide whitespace changes
Inline
Side-by-side
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallOrderService.java
View file @
95a55752
...
...
@@ -8,6 +8,8 @@ import org.springframework.stereotype.Service;
import
org.springframework.util.StringUtils
;
import
javax.annotation.Resource
;
import
java.time.LocalDate
;
import
java.time.format.DateTimeFormatter
;
import
java.util.List
;
import
java.util.Random
;
...
...
@@ -61,9 +63,11 @@ public class LitemallOrderService {
}
public
String
generateOrderSn
(
Integer
userId
)
{
String
orderSn
=
getRandomNum
(
10
);
DateTimeFormatter
df
=
DateTimeFormatter
.
ofPattern
(
"yyyyMMdd"
);
String
now
=
df
.
format
(
LocalDate
.
now
());
String
orderSn
=
now
+
getRandomNum
(
6
);
while
(
countByOrderSn
(
userId
,
orderSn
)
!=
0
){
orderSn
=
getRandomNum
(
10
);
orderSn
=
getRandomNum
(
6
);
}
return
orderSn
;
}
...
...
Write
Preview
Supports
Markdown
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