package cc.mrbird.febs.common.utils; 
 | 
  
 | 
import cn.hutool.core.util.StrUtil; 
 | 
  
 | 
import java.text.SimpleDateFormat; 
 | 
import java.util.Date; 
 | 
import java.util.Random; 
 | 
  
 | 
/** 
 | 
 * @author wzy 
 | 
 * @date 2021-09-22 
 | 
 **/ 
 | 
public class MallUtils { 
 | 
  
 | 
    public static String getRandomNum(int length) { 
 | 
        String str = "0123456789"; 
 | 
        Random random = new Random(); 
 | 
        StringBuilder sb = new StringBuilder(); 
 | 
        for (int i = 0; i < length; ++i) { 
 | 
            int number = random.nextInt(str.length()); 
 | 
            sb.append(str.charAt(number)); 
 | 
        } 
 | 
  
 | 
        return sb.toString(); 
 | 
    } 
 | 
  
 | 
    public static String getOrderNum(String prefix) { 
 | 
        SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); 
 | 
        String dd=df.format(new Date()); 
 | 
        if (StrUtil.isNotBlank(prefix)) { 
 | 
            return prefix+dd+getRandomNum(5); 
 | 
        } 
 | 
        return dd+getRandomNum(5); 
 | 
    } 
 | 
  
 | 
    public static String getLogisticsNum(String prefix) { 
 | 
        SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); 
 | 
        String dd=df.format(new Date()); 
 | 
        if (StrUtil.isNotBlank(prefix)) { 
 | 
            return prefix+dd+getRandomNum(2); 
 | 
        } 
 | 
        return dd+getRandomNum(2); 
 | 
    } 
 | 
  
 | 
    public static String getOrderNum() { 
 | 
        return getOrderNum(null); 
 | 
    } 
 | 
} 
 |