UUIDUtils订单号工具类

package com.jsy.basic.util.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;

public class UUIDUtils {

    public static String getUUID() {
        String uuid = UUID.randomUUID().toString().replaceAll("-","");
        return uuid;
    }

    //金额流水单号
    public static String getAccountNumber() {
        int code = UUID.randomUUID().toString().hashCode();
        code = code < 0 ? -code : code;
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
        String s = format.format(new Date());
        return s + code;
    }
    //订单编号:4位随机数+uninx时间戳(10位)+门店行政区划代码(后2位)+门店编号后2位
    //return   4位随机数+uninx时间戳(10位)
    public static String getOrderNum(){
        String l = String.valueOf(ThreadLocalRandom.current().nextInt(1000,10000-1));
        String s = Long.toString(System.currentTimeMillis() / 1000L);
        return l+s;
    }

    //服务验证码:4位随机数+uninx时间戳后1,2位+订单编号前2位+uninx时间戳后3,4位
    //return   4位随机数+uninx时间戳后1,2位+订单编号前2位+uninx时间戳后3,4位
    public static String getServiceCode(String orderNum){
        String l = String.valueOf(ThreadLocalRandom.current().nextInt(1000,10000-1));
        String s = Long.toString(System.currentTimeMillis() / 1000L);

        return l+s.substring(0,2)+orderNum.substring(0,2)+s.substring(2,4);
    }
    public static String getTimeAndRandomSix(){
        String s = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()).replaceAll("-", "").replaceAll(":", "").replaceAll(" ", "");
        int i = ThreadLocalRandom.current().nextInt(100 * 1000, 1000 * 1000 - 1);
        return s+i;
    }
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序员小小刘

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值