package com.qs.mp.utils;


import org.apache.commons.lang3.RandomStringUtils;

/**
 * 营销活动通用工具类
 * @author Cup
 * @date 2022/5/17
 */
public class MarketingUtils {

    public static final long CODE_THRESHOLD = 100000;

    // 生成邀请码
    public static String generateInviteCode(Long userId) {
        return Long.toHexString(CODE_THRESHOLD + userId);
    }

    // 邀请码解码
    public static Long decodeInviteCode(String inviteCode) {
        return Long.parseLong(inviteCode,16) - CODE_THRESHOLD;
    }

    // 生成抽奖码
    public static String generatePrizeCode() {
        return RandomStringUtils.randomAlphanumeric(12);
    }

    public static void main(String[] args) {
        System.out.println(generateInviteCode(1L));
    }
}
