Ejemplo n.º 1
0
 public ActionResult Form(SysRebateEntity model)
 {
     if (model.TipRebate > 100 || model.HourRebate > 100)
     {
         return(Error("返点不能大于100%"));
     }
     if (model.TipRebate < 0 || model.HourRebate < 0)
     {
         return(Error("返点不能小于0"));
     }
     if (model.id == 0)
     {
         var userModel = sysUserLogic.CheckUserName(model.UserAccount);
         if (userModel == null)
         {
             return(Error("当前用户名不存在,请重新输入"));
         }
         var rebateModel = sysRebateLogic.GetRebateByAccount(userModel.Id);
         if (rebateModel != null)
         {
             return(Error("用户已有平台返点信息,不可重复添加"));
         }
         model.ShopID = userModel.ShopID;
         model.UserID = userModel.Id;
         int row = sysRebateLogic.Insert(model);
         return(row > 0 ? Success() : Error());
     }
     else
     {
         int row = sysRebateLogic.Update(model);
         return(row > 0 ? Success() : Error());
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 新增返点
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Insert(SysRebateEntity model)
 {
     try
     {
         using (var db = GetInstance())
         {
             model.CreateTime   = DateTime.Now;
             model.ModifiedBy   = OperatorProvider.Instance.Current.Account;
             model.ModifiedTime = model.CreateTime;
             return(db.Insertable(model).ExecuteReturnIdentity());
         }
     }
     catch (Exception ex)
     {
         new LogLogic().Write(Level.Error, "新增返点", ex.Message, ex.StackTrace);
     }
     return(0);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 更新返点
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Update(SysRebateEntity model)
 {
     try
     {
         using (var db = GetInstance())
         {
             model.ModifiedBy   = OperatorProvider.Instance.Current.Account;
             model.ModifiedTime = DateTime.Now;
             return(db.Updateable(model).UpdateColumns(it => new
             {
                 it.TipRebate,
                 it.HourRebate
             }).ExecuteCommand());
         }
     }
     catch (Exception ex)
     {
         new LogLogic().Write(Level.Error, "修改商户", ex.Message, ex.StackTrace);
     }
     return(0);
 }
Ejemplo n.º 4
0
 public int Insert(SysUser model, string password, string[] roleIds)
 {
     using (var db = GetInstance())
     {
         try
         {
             db.Ado.BeginTran();
             ////新增用户基本信息。
             model.Id         = Guid.NewGuid().ToString().Replace("-", "");
             model.DeleteMark = "0";
             model.CreateUser = OperatorProvider.Instance.Current.Account;
             model.CreateTime = DateTime.Now;
             model.ModifyUser = model.CreateUser;
             model.ModifyTime = model.CreateTime;
             model.Avatar     = "/Content/framework/images/avatar.png";
             int row = db.Insertable <SysUser>(model).ExecuteCommand();
             if (row == 0)
             {
                 db.Ado.RollbackTran();
                 return(row);
             }
             //新增新的角色
             List <SysUserRoleRelation> list = new List <SysUserRoleRelation>();
             foreach (string roleId in roleIds)
             {
                 SysUserRoleRelation roleRelation = new SysUserRoleRelation
                 {
                     Id         = Guid.NewGuid().ToString().Replace("-", ""),
                     UserId     = model.Id,
                     RoleId     = roleId,
                     CreateUser = OperatorProvider.Instance.Current.Account,
                     CreateTime = DateTime.Now
                 };
                 list.Add(roleRelation);
             }
             row = db.Insertable <SysUserRoleRelation>(list).ExecuteCommand();
             if (row == 0)
             {
                 db.Ado.RollbackTran();
                 return(row);
             }
             //新增用户登陆信息。
             SysUserLogOn userLogOnEntity = new SysUserLogOn();
             userLogOnEntity.Id         = Guid.NewGuid().ToString().Replace("-", "");
             userLogOnEntity.UserId     = model.Id;
             userLogOnEntity.SecretKey  = userLogOnEntity.Id.DESEncrypt().Substring(0, 8);
             userLogOnEntity.Password   = password.MD5Encrypt().DESEncrypt(userLogOnEntity.SecretKey).MD5Encrypt();
             userLogOnEntity.LoginCount = 0;
             userLogOnEntity.IsOnLine   = "0";
             row = db.Insertable <SysUserLogOn>(userLogOnEntity).ExecuteCommand();
             //初始化返点
             SysRebateEntity rebateModel = new SysRebateEntity
             {
                 ShopID       = model.ShopID,
                 UserID       = model.Id,
                 TipRebate    = 0,
                 HourRebate   = 0,
                 ModifiedBy   = OperatorProvider.Instance.Current.Account,
                 CreateTime   = DateTime.Now,
                 ModifiedTime = DateTime.Now
             };
             row = db.Insertable <SysRebateEntity>(rebateModel).ExecuteCommand();
             if (row == 0)
             {
                 db.Ado.RollbackTran();
                 return(row);
             }
             db.Ado.CommitTran();
             return(row);
         }
         catch (Exception ex)
         {
             db.Ado.RollbackTran();
             new LogLogic().Write(Level.Error, "新增用户", ex.Message, ex.StackTrace);
             return(0);
         }
     }
 }
Ejemplo n.º 5
0
        public ActionResult GetForm(int primaryKey)
        {
            SysRebateEntity entity = sysRebateLogic.Get(primaryKey);

            return(Content(entity.ToJson()));
        }