using System;

namespace JiaZhiQuan.Common.Utils
{
    /// <summary>
    /// 业务编码生成
    /// </summary>
    public static class BusinessPrimaryCodeUtils
    {

        public static string BuildBusinessPrimaryKey()
        {
            return Guid.NewGuid().ToString("N");
        }

        /// <summary>
        /// 创建用户邀请码
        /// 32进制（用户id）
        /// </summary>
        /// <returns></returns>
        public static string BuildInvitationCode(long userId)
        {
            return userId.ConvertToBase34();
        }

        /// <summary>
        /// 用户邀请码转换用户id
        /// </summary>
        /// <returns></returns>
        public static long ParseInvitationCode(string code)
        {
            return code.ConvertFromBase34();
        }

        /// <summary>
        /// 创建用户邀请连接
        /// </summary>
        /// <returns></returns>
        public static string BuildInvitationUrl(string h5address, long userId)
        {
            return $"{h5address}/invite?code={BuildInvitationCode(userId)}";
        }
    }
}
