Ejemplo n.º 1
0
        //手工添加更新
        public ActionResult PiliangUpdate()
        {
            //string[] phones = { "15546799887" };
            //string errorMsg = string.Empty;
            //foreach (string phone in phones)
            //{
            //    if (!phone.IsMobilePhoneNum(true))
            //    {
            //        errorMsg += phone + "&&";
            //        continue;
            //    }
            //    string thisPhone = phone.Trim();
            //    //先判定有无注册用户
            //    AccountBll account = new AccountBll();
            //    int UserId = 0;
            //    Random rd = new Random();
            //    string pwd = rd.Next(100000,999999).ToString();
            //    int userType = 0;
            //    if (!account.IsExistsUserName(thisPhone, "86"))
            //    {
            //        //没有就插入用户表
            //        CustomerEntity entity = new CustomerEntity()
            //        {
            //            Mobile = thisPhone,
            //            UserName = thisPhone,
            //            Email = "",
            //            Password = pwd,
            //            Gender = 0,
            //            RegionCode = "86"
            //        };
            //        UserId = account.Insert(entity);
            //        userType = 0;
            //    }
            //    else
            //    {
            //        UserId = account.GetUserInfoByUserName(thisPhone).ID;
            //        userType = 1;
            //        pwd = string.Empty;
            //    }
            //    if (UserId == 0)
            //    {
            //        errorMsg += thisPhone + "&&";
            //        continue;
            //    }
            //    if (account.GetUserTempByUserName(thisPhone) > 0)
            //    {
            //        errorMsg += phone + "||";
            //        continue;
            //    }
            //    //先写入用户临时表
            //    account.InsertTemp(thisPhone, pwd, userType);
            //    //获取到当前的用户ID然后送优惠券
            //    var loginInfo = new CustomerEntity()
            //    {
            //        ID = UserId,
            //        CreateTime = DateTime.Now
            //    };
            //    GiftCardBatchEntity giftcardBatch = new GiftCardBatchEntity()
            //    {
            //        BatchId = 6,
            //        BatchName = "丰满券",
            //        CardType = 2,
            //        CardSum = 20,
            //        SatisfyPrice = 159,
            //        SatisfyProduct = 3,
            //        ExpiryDays = 6
            //    };
            //    GiftCardEntity GiftCardEntity = account.AddGiftCard(giftcardBatch, loginInfo);
            //}
            AccountBll account   = new AccountBll();
            var        userInfos = account.GetUserInfo();
            string     errorMsg  = "成功!";

            foreach (var userInfo in userInfos)
            {
                if (account.GetUserTempByUserName(userInfo.UserName) > 0)
                {
                    errorMsg += userInfo.UserName + "||";
                    continue;
                }
                account.InsertTemp(userInfo.UserName, "", 0);
                var loginInfo = new CustomerEntity()
                {
                    ID         = userInfo.ID,
                    CreateTime = DateTime.Now
                };
                GiftCardBatchEntity giftcardBatch = new GiftCardBatchEntity()
                {
                    BatchId        = 35,
                    BatchName      = "丰满券",
                    CardType       = 2,
                    CardSum        = 20,
                    SatisfyPrice   = 159,
                    SatisfyProduct = 3,
                    ExpiryDays     = 6
                };
                GiftCardEntity GiftCardEntity = account.AddGiftCard(giftcardBatch, loginInfo);
            }
            return(Content(errorMsg));
        }