Ejemplo n.º 1
0
        /// <summary>
        /// 获得有效的用户名
        /// </summary>
        /// <param name="oUserName">开放用户名</param>
        /// <param name="uNamePrefix">用户名前缀</param>
        /// <returns></returns>
        private static string GetValidUserName(string oUserName, string uNamePrefix)
        {
            if (string.IsNullOrWhiteSpace(uNamePrefix))
            {
                uNamePrefix = "bma";
            }

            string validUserName = uNamePrefix + oUserName;
            int    length        = StringHelper.GetStringLength(validUserName);

            if (length > 20)
            {
                validUserName = validUserName.Substring(0, 20);
            }

            if (!Users.IsExistUserName(validUserName))
            {
                return(validUserName);
            }

            validUserName = StringHelper.SubString(validUserName, 14);
            string temp = validUserName + Randoms.CreateRandomValue(6);

            while (Users.IsExistUserName(temp))
            {
                temp = validUserName + Randoms.CreateRandomValue(6);
            }
            return(temp);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 初始化用户
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="uNamePrefix">用户名前缀</param>
        /// <param name="regionId">区域id</param>
        /// <returns></returns>
        private static UserInfo InitUser(string userName, string uNamePrefix, int regionId)
        {
            UserInfo userInfo = new UserInfo();

            userInfo.Salt          = Randoms.CreateRandomValue(6);
            userInfo.Password      = Users.CreateUserPassword(Randoms.CreateRandomValue(32, false), userInfo.Salt);
            userInfo.StoreId       = 0; //无店铺
            userInfo.MallAGid      = 1; //非管理员组
            userInfo.UserName      = GetValidUserName(userName, uNamePrefix);
            userInfo.Email         = string.Empty;
            userInfo.Mobile        = string.Empty;
            userInfo.NickName      = StringHelper.SubString(userName, 20);
            userInfo.Avatar        = "";
            userInfo.PayCredits    = 0;
            userInfo.RankCredits   = 0;
            userInfo.VerifyEmail   = 0;
            userInfo.VerifyMobile  = 0;
            userInfo.UserRid       = UserRanks.GetUserRankByCredits(userInfo.PayCredits).UserRid;//根据积分判读用户等级
            userInfo.LiftBanTime   = new DateTime(1900, 1, 1);
            userInfo.LastVisitTime = DateTime.Now;
            userInfo.LastVisitIP   = WebHelper.GetIP();
            userInfo.LastVisitRgId = regionId;
            userInfo.RegisterTime  = DateTime.Now;
            userInfo.RegisterIP    = WebHelper.GetIP();
            userInfo.RegisterRgId  = regionId;
            userInfo.Gender        = 0;
            userInfo.RealName      = string.Empty;
            userInfo.Bday          = new DateTime(1900, 1, 1);
            userInfo.IdCard        = string.Empty;
            userInfo.RegionId      = 0;
            userInfo.Address       = string.Empty;
            userInfo.Bio           = string.Empty;

            return(userInfo);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 生成活动专题编号
        /// </summary>
        /// <returns></returns>
        public static string GenerateTopicSN()
        {
            string sn = Randoms.CreateRandomValue(16, false);

            while (IsExistTopicSN(sn))
            {
                sn = Randoms.CreateRandomValue(16, false);
            }
            return(sn);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 生成优惠劵编号
        /// </summary>
        /// <returns></returns>
        public static string GenerateCouponSN()
        {
            string sn = Randoms.CreateRandomValue(16);

            while (IsExistCouponSN(sn))
            {
                sn = Randoms.CreateRandomValue(16);
            }
            return(sn);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 生成用户盐值
 /// </summary>
 /// <returns></returns>
 public static string GenerateUserSalt()
 {
     return(Randoms.CreateRandomValue(6));
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 添加SKU
        /// </summary>
        /// <param name="productInfo">商品信息</param>
        /// <param name="productSKUItemList">商品SKU项列表</param>
        public static void AddSKU(ProductInfo productInfo, List <ProductSKUItemInfo> productSKUItemList)
        {
            List <ProductSKUItemInfo> attrList      = new List <ProductSKUItemInfo>();
            List <ProductSKUItemInfo> attrValueList = new List <ProductSKUItemInfo>();

            foreach (ProductSKUItemInfo productSKUItemInfo in productSKUItemList)
            {
                if (!attrValueList.Exists(x => x.AttrValueId == productSKUItemInfo.AttrValueId && x.InputValue == productSKUItemInfo.InputValue))
                {
                    attrValueList.Add(productSKUItemInfo);
                }
            }
            foreach (ProductSKUItemInfo productSKUItemInfo in attrValueList)
            {
                if (attrList.Find(x => x.AttrId == productSKUItemInfo.AttrId) == null)
                {
                    attrList.Add(productSKUItemInfo);
                }
            }

            //sku数量
            int skuCount = 1;

            for (var i = 0; i < attrList.Count; i++)
            {
                skuCount = skuCount * attrValueList.FindAll(x => x.AttrId == attrList[i].AttrId).Count;
            }


            //sku项数量
            int skuItemCount = productSKUItemList.Count / skuCount;

            //sku组id
            int skuGid = TypeHelper.StringToInt(Randoms.CreateRandomValue(8));

            while (IsExistSKUGid(skuGid))
            {
                skuGid = TypeHelper.StringToInt(Randoms.CreateRandomValue(8));
            }
            productInfo.SKUGid = skuGid;

            //商品原始名称
            string oName = productInfo.Name;

            //循环创建商品,商品属性,商品sku项s
            for (int i = 0; i < skuCount; i++)
            {
                //格式化商品名称
                StringBuilder pName = new StringBuilder(oName);
                for (int j = skuItemCount * i; j < skuItemCount * (i + 1); j++)
                {
                    AttributeValueInfo attributeValueInfo = AdminCategories.GetAttributeValueById(productSKUItemList[j].AttrValueId);
                    if (attributeValueInfo.IsInput == 0)
                    {
                        pName.AppendFormat(" {0}", attributeValueInfo.AttrValue);
                    }
                    else
                    {
                        pName.AppendFormat(" {0}", productSKUItemList[j].InputValue);
                    }
                }
                productInfo.Name = pName.ToString();
                int pid = AddProduct(productInfo, 0, 0, null);//创建商品及其属性
                if (pid > 0)
                {
                    //创建商品sku项
                    for (int j = skuItemCount * i; j < skuItemCount * (i + 1); j++)
                    {
                        productSKUItemList[j].Pid    = pid;
                        productSKUItemList[j].SKUGid = skuGid;
                        CreateProductSKUItem(productSKUItemList[j]);
                    }
                }
            }
        }