Esempio n. 1
0
        public static int CreateMultiplePromotionCode(PromotionCodeModel promotionCodeModel, int num)
        {
            if (num == -1)
            {
                num = promotionCodeModel.Number;
            }

            return(CreateMultiplePromotionCode2(promotionCodeModel, num));
        }
Esempio n. 2
0
        public static void CreateOrYzPromotion(string userId, decimal money, int OrderID)
        {
            if (money > 1000)
            {
                money = 1000;
            }

            var promotionCodeModel = new PromotionCodeModel();

            promotionCodeModel.OrderId     = 0;
            promotionCodeModel.Status      = 0;
            promotionCodeModel.Description = "满" + (money + 1) + "元可用,仅限保养产品使用";
            promotionCodeModel.Discount    = (int)Math.Ceiling(money);
            promotionCodeModel.MinMoney    = (money + 1);
            promotionCodeModel.EndTime     = DateTime.Now.AddMonths(6).Date;
            promotionCodeModel.StartTime   = DateTime.Now.Date;
            promotionCodeModel.UserId      = new Guid(userId);
            promotionCodeModel.CodeChannel = "途虎免单券";
            promotionCodeModel.BatchId     = OrderID;
            promotionCodeModel.RuleId      = 23;
            var result = CreateMultiplePromotionCode(promotionCodeModel, 1);
        }
Esempio n. 3
0
        public static int CreateMultiplePromotionCode2(PromotionCodeModel promotionCodeModel, int num)
        {
            try
            {
                using (var cmd = new SqlCommand("[Gungnir].[dbo].[Beautify_CreatePromotionCode]"))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@StartTime", promotionCodeModel.StartTime.ToString());
                    cmd.Parameters.AddWithValue("@EndDateTime", promotionCodeModel.EndTime.ToString());
                    cmd.Parameters.AddWithValue("@Type", promotionCodeModel.Type);
                    cmd.Parameters.AddWithValue("@Description", promotionCodeModel.Description);
                    cmd.Parameters.AddWithValue("@Discount", promotionCodeModel.Discount);
                    cmd.Parameters.AddWithValue("@MinMoney", promotionCodeModel.MinMoney);
                    cmd.Parameters.AddWithValue("@Number", num);
                    cmd.Parameters.AddWithValue("@CodeChannel", promotionCodeModel.CodeChannel);
                    cmd.Parameters.AddWithValue("@UserID", promotionCodeModel.UserId);
                    cmd.Parameters.AddWithValue("@BatchID", promotionCodeModel.BatchId == null ? 0 : promotionCodeModel.BatchId.Value);
                    cmd.Parameters.AddWithValue("@RuleID", promotionCodeModel.RuleId);

                    cmd.Parameters.Add(new SqlParameter()
                    {
                        ParameterName = "@Results",
                        DbType        = DbType.Int32,
                        Direction     = ParameterDirection.Output,
                        Value         = 0
                    });

                    DbHelper.ExecuteNonQuery(cmd);
                    var result = Convert.ToInt32(cmd.Parameters["@Results"].Value);
                    return(result);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                return(-99);
            }
        }
Esempio n. 4
0
        public static void CreateOrYzPromotion(string userId)
        {
            var lPro = new List <PromotionCodeModel>();

            for (var i = 0; i < 6; i++)
            {
                var promotionCodeModel = new PromotionCodeModel();
                promotionCodeModel.OrderId = 0;
                promotionCodeModel.Status  = 0;
                switch (i)
                {
                case 0:    //轮胎券
                    promotionCodeModel.Type        = 1;
                    promotionCodeModel.Description = "满599元可用,仅限轮胎产品使用";
                    promotionCodeModel.Discount    = 10;
                    promotionCodeModel.MinMoney    = 599;
                    promotionCodeModel.EndTime     = DateTime.Now.AddDays(14);
                    promotionCodeModel.RuleId      = 25;
                    break;

                case 1:    //保养券
                    promotionCodeModel.Type        = 2;
                    promotionCodeModel.Description = "满299元可用,仅限保养产品使用";
                    promotionCodeModel.Discount    = 20;
                    promotionCodeModel.MinMoney    = 299;
                    promotionCodeModel.EndTime     = DateTime.Now.AddDays(14);
                    promotionCodeModel.RuleId      = 23;
                    break;

                case 2:    //车品券
                    promotionCodeModel.Type        = 8;
                    promotionCodeModel.Description = "满79元可用,仅限车品产品使用";
                    promotionCodeModel.Discount    = 5;
                    promotionCodeModel.MinMoney    = 79;
                    promotionCodeModel.EndTime     = DateTime.Now.AddDays(14);
                    promotionCodeModel.RuleId      = 30;
                    break;

                case 3:    //美容券
                    promotionCodeModel.Type        = 5;
                    promotionCodeModel.Description = "可用于洗车、打蜡产品使用";
                    promotionCodeModel.Discount    = 5;
                    promotionCodeModel.MinMoney    = 5;
                    promotionCodeModel.EndTime     = DateTime.Now.AddDays(14);
                    promotionCodeModel.RuleId      = 32;
                    break;

                case 4:    //保养券
                    promotionCodeModel.Type        = 2;
                    promotionCodeModel.Description = "满199元可用,仅限保养产品使用";
                    promotionCodeModel.Discount    = 10;
                    promotionCodeModel.MinMoney    = 199;
                    promotionCodeModel.EndTime     = DateTime.Now.AddDays(14);
                    promotionCodeModel.RuleId      = 23;
                    break;

                case 5:    //洗车券
                    promotionCodeModel.Type        = 3;
                    promotionCodeModel.Description = "可用于标准洗车5座";
                    promotionCodeModel.Discount    = 0;
                    promotionCodeModel.MinMoney    = 0;
                    promotionCodeModel.EndTime     = DateTime.Now.AddDays(14);
                    promotionCodeModel.RuleId      = 42;
                    break;
                }
                promotionCodeModel.StartTime   = DateTime.Now;
                promotionCodeModel.UserId      = new Guid(userId);
                promotionCodeModel.CodeChannel = "途虎新手大礼包";
                promotionCodeModel.BatchId     = -1;

                lPro.Add(promotionCodeModel);
            }
            using (var helper = DbHelper.CreateDbHelper())
            {
                helper.BeginTransaction();
                for (var i = 0; i < lPro.Count; i++)
                {
                    var promotionCodeModel = new PromotionCodeModel();
                    promotionCodeModel = lPro[i];

                    #region 创建优惠券

                    var result = 0;
                    try
                    {
                        result = CreateMultiplePromotionCode(promotionCodeModel, 1);
                        if (result > 0)
                        {
                        }
                        else
                        {
                            helper.Rollback();
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Error(ex);
                        helper.Rollback();
                    }

                    #endregion 创建优惠券
                }
            }
        }