Commit 95a55752 authored by Junling Bu's avatar Junling Bu
Browse files

fix[litemall-db]: 订单编号以当前日期+6位随机数组组成。

parent ad504bb3
......@@ -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;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment