//自定义订单编号生成规则 由YYYYMMDD(年月日) + 时间戳的格式组成
let currDate = new Date();
let year = currDate.getFullYear();
let month = currDate.getMonth() + 1 < 10 ? "0" + (currDate.getMonth() + 1): currDate.getMonth() + 1;
let day = currDate.getDate()<10 ? "0"+currDate.getDate() : currDate.getDate();
//获取年月日
let date = year + month + day; //20190524
//获取当时时间戳
let timestamp = Date.parse(currDate); //155866554500
//生成订单
let orderId = date + timestamp; //20190524155866554500
随机生成订单号
最新推荐文章于 2024-03-24 09:00:00 发布