1.代客下单,支付,挂起,下单接口开发
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package cn.ysk.cashier.utils;
|
||||
|
||||
import cn.hutool.core.lang.Snowflake;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author Exrickx
|
||||
*/
|
||||
@Slf4j
|
||||
public class SnowFlakeUtil {
|
||||
|
||||
/**
|
||||
* 派号器workid:0~31
|
||||
* 机房datacenterid:0~31
|
||||
*/
|
||||
private static Snowflake snowflake = IdUtil.createSnowflake(1, 1);
|
||||
|
||||
public static Long nextId() {
|
||||
return snowflake.nextId();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static String generateOrderNo(){
|
||||
String dateFormat="yyyyMMddHHmmssSSS";
|
||||
SimpleDateFormat sm=new SimpleDateFormat(dateFormat);
|
||||
|
||||
String currentDate=sm.format(new Date());
|
||||
|
||||
Random rm=new Random();
|
||||
int suffix=rm.nextInt(9999999);
|
||||
|
||||
return currentDate.concat(String.format("%07d",suffix));
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
for(int i=0;i<10;i++){
|
||||
System.out.println(SnowFlakeUtil.generateOrderNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user