用于分布式情况下的订单号的创建:

创建表:

  

CREATE TABLE `shop_uuid_18` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `addTime` datetime DEFAULT NULL,
  `deleteStatus` bit(1) NOT NULL DEFAULT b'0',
  `name` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=132655 DEFAULT CHARSET=utf8;

 你的订单想从哪开始就将sql中 

AUTO_INCREMENT=132655 修改值就行

2.生成唯一的订单号:
UUID18 uuid18 = new UUID18();
uuid18Service.save(uuid18);
String random =   (int)((Math.random()*9+1)*10)+"";
String orderNo = uuid18.getId() + random; //就是符合要求的定单号

 

相关文章:

  • 2021-09-03
  • 2021-10-16
  • 2022-01-11
  • 2021-12-22
  • 2021-10-27
  • 2022-03-09
  • 2022-01-25
  • 2021-12-01
猜你喜欢
  • 2022-12-23
  • 2021-09-21
  • 2022-01-17
  • 2021-08-15
  • 2022-02-19
  • 2021-03-26
  • 2021-06-18
相关资源
相似解决方案