订单id生成,每小时最大6位数订单。
public String getCode() {
String key = "DT" + DateUtils.parseDateToStr("yyyyMMddHH", new Date());
BoundValueOperations<String, Integer> opsForValue = redisTemplate.boundValueOps(key);
Long code = opsForValue.increment(1);
redisTemplate.expire(key, 1L, TimeUnit.HOURS);
return key + String.format("%1$06d", code);
}