コード例 #1
0
        /// <summary>
        /// 设置优惠券属性
        /// </summary>
        /// <param name="GiftCardBatchEntity"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        public GiftCardEntity setGiftCardEntity(GiftCardBatchEntity GiftCardBatchEntity, CustomerEntity entity)
        {
            if (GiftCardBatchEntity != null)
            {
                GiftCardEntity GiftCardEntity = new GiftCardEntity();

                GiftCardEntity.BatchId        = GiftCardBatchEntity.BatchId;
                GiftCardEntity.BatchName      = GiftCardBatchEntity.BatchName;
                GiftCardEntity.UserId         = entity.ID;
                GiftCardEntity.CardId         = StringHelper.GenerateRandomCode(8);
                GiftCardEntity.CardSum        = GiftCardBatchEntity.CardSum;
                GiftCardEntity.CardType       = GiftCardBatchEntity.CardType;
                GiftCardEntity.Status         = 0;
                GiftCardEntity.BeginTime      = entity.CreateTime.Date;
                GiftCardEntity.EndTime        = GiftCardEntity.BeginTime.AddDays(GiftCardBatchEntity.ExpiryDays + 1).AddSeconds(-1);
                GiftCardEntity.SatisfyPrice   = GiftCardBatchEntity.SatisfyPrice;
                GiftCardEntity.SatisfyProduct = GiftCardBatchEntity.SatisfyProduct;
                GiftCardEntity.AddTime        = DateTime.Now;

                return(GiftCardEntity);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
ファイル: AccountBll.cs プロジェクト: radtek/Shop
        /// <summary>
        /// 添加优惠券
        /// </summary>
        /// <param name="GiftCardBatchEntity"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        public GiftCardEntity AddGiftCard(GiftCardBatchEntity GiftCardBatchEntity, CustomerEntity entity)
        {
            // 设置优惠券属性
            GiftCardEntity GiftCardEntity = GiftCardBll.setGiftCardEntity(GiftCardBatchEntity, entity);

            // 插入优惠券信息
            bool result = GiftCardBll.SaveGiftCard(GiftCardEntity);

            if (result)
            {
                return(GiftCardEntity);
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
ファイル: AccountBll.cs プロジェクト: radtek/Shop
        /// <summary>
        /// 其他用户类型添加优惠券
        /// </summary>
        /// <param name="GiftCardBatchEntity"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        public GiftCardEntity ChooseUserToAddGiftCard(GiftCardBatchEntity GiftCardBatchEntity, CustomerEntity entity)
        {
            GiftCardEntity GiftCardEntity = null;

            // 根据具体店铺id查询是否有其店铺存在
            bool IsResult = GetDividedPercentStationZDID(entity.ChannelId, entity.SourceValue);

            // 嘿客店用户
            if (entity.ChannelId.ToString()
                .Equals(System.Web.Configuration.WebConfigurationManager.AppSettings["HeiKeChannelId"].ToString()) &&
                IsResult)
            {
                // 添加优惠券
                GiftCardEntity = AddGiftCard(GiftCardBatchEntity, entity);
            }

            return(GiftCardEntity);
        }
コード例 #4
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));
        }