生成订单号 、生成优惠券号 前四位大写字母 后六位数字

时间:2014-06-11 12:07:04   收藏:0   阅读:262
bubuko.com,布布扣
// 生成订单号
    public static String setRandomChar() {
        String str = "";
        for (int i = 0; i < 10; i++) {
            int ch = (int) (10 * (Math.random()));
            str = str + ch;
        }

        return str;

    }
    
    // 生成优惠券号 前四位大写字母 后六位数字
    public static String genCouponCode() {
        String str = "";
        for (int i = 0; i < 4; i++) {
            int ch = ((int)‘A‘)+ (int) (26 * (Math.random()));
            str = str +(char)ch; 
        }
        for (int i = 0; i < 6; i++) {
            int ch = (int) (10 * (Math.random()));
            str = str + ch;
        }

        return str;

    }
bubuko.com,布布扣

 

生成订单号 、生成优惠券号 前四位大写字母 后六位数字,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!