public static bool InsertRedeemGroupSetting(SqlConnection conn, RedeemGroupSetting model) { const string sql = @" Insert into Tuhu_groupon..RedeemGroupSetting( GroupId, GroupName, BusinessType, SendCodeType, CreateTime, UpdateTime) values( @GroupId, @GroupName, @BusinessType, @SendCodeType, GETDATE(), GETDATE() )"; return(conn.Execute( sql, new { GroupId = model.GroupId, GroupName = model.GroupName, BusinessType = model.BusinessType, SendCodeType = model.SendCodeType }, commandType: CommandType.Text) > 0); }
public Tuple <bool, string> SaveRedeemGroupSetting(RedeemGroupSetting model, string userName) { var result = false; if (model == null) { return(Tuple.Create(result, "")); } try { if (model.GroupId == null || model.GroupId == Guid.Empty) { model.GroupId = Guid.NewGuid(); result = DbTuhuGrouponScopeManager.Execute(conn => DALUnivRedemptionCode.InsertRedeemGroupSetting(conn, model)); if (result) { InsertBeautyOprLog(new { LogType = "InsertRedeemGroupSetting", IdentityID = model.GroupId, NewValue = JsonConvert.SerializeObject(model), OldValue = string.Empty, OperateUser = userName, }); } } else { var oldmodel = DbTuhuGrouponScopeManager.Execute(conn => DALUnivRedemptionCode.GetRedeemGroupSetting(conn, model.GroupId)); if (model.SendCodeType == 1)//自动发码,群组下只能有一个套餐 { if (DbTuhuGrouponScopeManager.Execute(conn => DALUnivRedemptionCode.GetRedemptionConfigCountByGroupId(conn, model.GroupId)) > 1) { return(Tuple.Create(result, "自动发码时,群组下只能有一个套餐")); } } result = DbTuhuGrouponScopeManager.Execute(conn => DALUnivRedemptionCode.UpdateRedeemGroupSetting(conn, model)); if (result) { InsertBeautyOprLog(new { LogType = "UpdateRedeemGroupSetting", IdentityID = model.GroupId, NewValue = JsonConvert.SerializeObject(model), OldValue = JsonConvert.SerializeObject(oldmodel), OperateUser = userName, }); } } } catch (Exception ex) { Logger.Error(ex.Message, ex); } return(Tuple.Create(result, "")); }
public JsonResult DeleteGroupSetting(RedeemGroupSetting model) { if (model == null) { return(Json(new { result = false, msg = "请求参数不能为空!" })); } if (model.GroupId == null || model.GroupId == Guid.Empty) { return(Json(new { result = false, msg = "分组GroupId不能为空!" })); } var result = manager.DeleteRedeemGroupSetting(model, User.Identity.Name); return(Json(new { result = result.Item1, msg = result.Item2 })); }
public JsonResult SaveGroupSetting(RedeemGroupSetting model) { if (model == null) { return(Json(new { result = false, msg = "请求参数不能为空!" })); } if (string.IsNullOrWhiteSpace(model.GroupName)) { return(Json(new { result = false, msg = "分组名称不能为空!" })); } var result = manager.SaveRedeemGroupSetting(model, User.Identity.Name); return(Json(new { result = result.Item1, msg = result.Item2 })); }
public static bool DeleteRedeemGroupSetting(SqlConnection conn, RedeemGroupSetting model) { const string sql = @" Update Tuhu_groupon..RedeemGroupSetting SET IsDeleted=1, UpdateTime=GETDATE() WHERE GroupId=@GroupId"; return(conn.Execute( sql, new { GroupId = model.GroupId }, commandType: CommandType.Text) > 0); }
public static bool UpdateRedeemGroupSetting(SqlConnection conn, RedeemGroupSetting model) { const string sql = @" Update Tuhu_groupon..RedeemGroupSetting SET GroupName=@GroupName, BusinessType=@BusinessType, SendCodeType=@SendCodeType, UpdateTime=GETDATE() WHERE GroupId=@GroupId"; return(conn.Execute( sql, new { GroupName = model.GroupName, GroupId = model.GroupId, BusinessType = model.BusinessType, SendCodeType = model.SendCodeType }, commandType: CommandType.Text) > 0); }
public Tuple <bool, string> DeleteRedeemGroupSetting(RedeemGroupSetting model, string userName) { var result = false; if (model == null) { return(Tuple.Create(result, "")); } try { if (model.GroupId != null && model.GroupId != Guid.Empty) { var oldmodel = DbTuhuGrouponScopeManager.Execute(conn => DALUnivRedemptionCode.GetRedeemGroupSetting(conn, model.GroupId)); if (DbTuhuGrouponScopeManager.Execute(conn => DALUnivRedemptionCode.GetRedemptionConfigCountByGroupId(conn, model.GroupId)) <= 0) { result = DbTuhuGrouponScopeManager.Execute(conn => DALUnivRedemptionCode.DeleteRedeemGroupSetting(conn, model)); if (result) { InsertBeautyOprLog(new { LogType = "UpdateRedeemGroupSetting", IdentityID = model.GroupId, NewValue = JsonConvert.SerializeObject(model), OldValue = JsonConvert.SerializeObject(oldmodel), OperateUser = userName, }); } } else { return(Tuple.Create(result, "该分组下存在套餐无法删除!")); } } } catch (Exception ex) { Logger.Error(ex.Message, ex); } return(Tuple.Create(result, "")); }