예제 #1
0
        public bool AddCouponBusinessConfig(PromotionBusinessTypeConfig config)
        {
            var result = false;

            try
            {
                config.PKID = DbTuhuGrouponScopeManager.Execute(conn => DALUnivRedemptionCode.AddCouponBusinessConfig(conn, config));
                result      = config.PKID > 0;
                if (result)
                {
                    InsertBeautyOprLog(new
                    {
                        LogType     = CouponBusinessType,
                        IdentityID  = config.PKID,
                        NewValue    = JsonConvert.SerializeObject(config),
                        OldValue    = string.Empty,
                        OperateUser = config.CreateUser,
                        Remarks     = "添加",
                    });
                }
            }
            catch (Exception ex)
            {
                Logger.Error(nameof(AddCouponBusinessConfig), ex);
            }
            return(result);
        }
예제 #2
0
        public static int AddCouponBusinessConfig(SqlConnection conn, PromotionBusinessTypeConfig config)
        {
            const string sql    = @"INSERT  INTO Tuhu_groupon..PromotionBusinessTypeConfig
        ( BusinessType ,
          Name ,
          GetRuleGuid ,
          CreateUser ,
          CreateTime ,
          UpdateTime
        )
OUTPUT  Inserted.PKID
VALUES  ( @BusinessType ,
          @Name ,
          @GetRuleGuid ,
          @CreateUser ,
          GETDATE() ,
          GETDATE()
        );";
            var          result = conn.ExecuteScalar(sql, new
            {
                config.BusinessType,
                config.Name,
                config.GetRuleGuid,
                config.CreateUser
            }, commandType: CommandType.Text);

            return(Convert.ToInt32(result));
        }
예제 #3
0
        public bool IsExistsCouponBusinessConfig(PromotionBusinessTypeConfig config)
        {
            bool result = true;

            try
            {
                result = DbTuhuGrouponScopeReadManager.Execute(conn => DALUnivRedemptionCode.IsExistsCouponBusinessConfig(conn, config));
            }
            catch (Exception ex)
            {
                Logger.Error(nameof(IsExistsCouponBusinessConfig), ex);
            }
            return(result);
        }
예제 #4
0
        public PromotionBusinessTypeConfig GetCouponBusinessConfig(int id)
        {
            PromotionBusinessTypeConfig result = null;

            try
            {
                result = DbTuhuGrouponScopeReadManager.Execute(conn => DALUnivRedemptionCode.SelectCouponBusinessConfig(conn, id));
            }
            catch (Exception ex)
            {
                Logger.Error(nameof(GetCouponBusinessConfig), ex);
            }
            return(result);
        }
        public ActionResult AddCouponBusinessConfig(PromotionBusinessTypeConfig config)
        {
            Func <string> validatedFun = () =>
            {
                if (config == null ||
                    string.IsNullOrWhiteSpace(config.Name) ||
                    string.IsNullOrWhiteSpace(config.BusinessType) ||
                    config.GetRuleGuid == default(Guid))
                {
                    return("参数不能为空!");
                }
                BusinessType businessType;
                if (!Enum.TryParse(config.BusinessType, out businessType) || businessType == BusinessType.None)
                {
                    return("不是有效的业务类型!");
                }
                if (manager.IsExistsCouponBusinessConfig(config))
                {
                    return("已经存在相同名称或者相同规则的数据!");
                }
                if (string.Equals(config.BusinessType, nameof(BusinessType.BaoYangPackage)) && config.RuleId != 123128)
                {
                    return("保养套餐流程母券选择有误");
                }
                if (string.Equals(config.BusinessType, nameof(BusinessType.PaintPackage)) && config.RuleId != 126177)
                {
                    return("喷漆套餐流程母券选择有误");
                }
                config.CreateUser   = User.Identity.Name;
                config.Name         = config.Name.Trim();
                config.BusinessType = businessType.ToString();
                return(string.Empty);
            };
            var validatedResult = validatedFun();

            if (!string.IsNullOrEmpty(validatedResult))
            {
                return(Json(new { status = false, msg = validatedResult }));
            }
            bool result = manager.AddCouponBusinessConfig(config);

            return(Json(new { status = result }));
        }
예제 #6
0
        public static bool IsExistsCouponBusinessConfig(SqlConnection conn, PromotionBusinessTypeConfig config)
        {
            const string sql   = @"SELECT  COUNT(1)
FROM    Tuhu_groupon..PromotionBusinessTypeConfig AS t WITH ( NOLOCK )
WHERE   t.PKID <> @PKID
        AND t.BusinessType = @BusinessType
        AND ( t.Name = @Name
              OR t.GetRuleGuid = @GetRuleGuid
            );";
            var          count = conn.ExecuteScalar(sql, new
            {
                config.PKID,
                config.Name,
                config.BusinessType,
                config.GetRuleGuid,
            }, commandType: CommandType.Text);

            return(Convert.ToInt32(count) > 0);
        }