private void Update(AccountLevelPolicy policy) { List <DbParameter> parameters = new List <DbParameter>(); var sql = "update Accounts set AccountLevelName = @name, accountLevel = @level where accountLevel <= @level and TotalPoint >= @TotalPointStart and accountTypeId = @accountTypeId"; _databaseInstance.ExecuteNonQuery(sql, new { name = policy.DisplayName, level = policy.Level, TotalPointStart = policy.TotalPointStart, accountTypeId = policy.AccountTypeId }); }
public int Validate() { _account = AccountService.GetByName(AccountName); if (_account == null || (_account.State != AccountStates.Ready && _account.State != AccountStates.Saled)) { return(ResponseCode.NonFoundAccount); } _operator = MembershipService.GetUserById(OperatorUserId) as AdminUser; if (_operator == null) { return(ResponseCode.InvalidateUser); } _dealWay = DealWayService.GetById(DealWayId); _accountType = AccountTypeService.GetById(_account.AccountTypeId); _accountLevel = AccountLevelPolicyService.Query().FirstOrDefault(x => x.Level == 0 && x.State == States.Normal && x.AccountTypeId == _account.AccountTypeId); _dealLog = new DealLog(SerialNo, DealTypes.Open, -_account.Amount, 0, null, null, _account, null, 0); // 用户 if (!string.IsNullOrEmpty(UserDisplayName)) { _owner = new AccountUser(); _owner.DisplayName = UserDisplayName; _owner.IdentityCard = Identify; _owner.BirthDate = BirthDate; _owner.Mobile = Mobile; if (!string.IsNullOrWhiteSpace(Mobile)) { _owner.IsMobileAvailable = true; } _owner.Gender = Gender; } return(ResponseCode.Success); }
public ListAccountLevelPolicy() { _innerObject = new AccountLevelPolicy(); }
public ListAccountLevelPolicy(AccountLevelPolicy adminUser) { _innerObject = adminUser; }
public CreateAccountLevelPolicy(AccountLevelPolicy item) : base(item) { InnerObject.State = AccountLevelPolicyStates.Normal; }
protected void SetInnerObject(AccountLevelPolicy item) { _innerObject = item; }
protected void OnSave(AccountLevelPolicy level) { level.DiscountRate = InnerObject.DiscountRate; }
public AccountLevelPolicyModelBase(AccountLevelPolicy shop) { _innerObject = shop; }
public AccountLevelPolicyModelBase() { _innerObject = new AccountLevelPolicy(); }
public EditAccountLevelPolicy(AccountLevelPolicy item) : base(item) { }
public int Execute(User user) { if (_dealWay == null) { _dealWay = new DealWay() { IsCash = false } } ; user = user ?? OperatorUser; if (!string.IsNullOrWhiteSpace(Password)) { _account.SetPassword(Password); } _account.State = IsActived ? States.Normal : States.Invalid; _account.ExpiredDate = DateTime.Now.AddMonths(_account.ExpiredMonths).Date; _account.LastDealTime = DateTime.Now; _account.OpenTime = DateTime.Now; _account.Remark1 = Remark1; // 售卡 // var systemDealLog = new SystemDealLog(SerialNo, _operator) { Amount = _account.Amount, DealWayId = DealWayId, DealType = SystemDealLogTypes.SaldCard, Addin = _account.AccountId.ToString() }; SystemDealLogService.Create(systemDealLog); if (_dealWay.IsCash) { CashDealLogService.Create(new CashDealLog(systemDealLog.Amount, 0, user.UserId, systemDealLog.DealType)); } // 押金 // if (_account.DepositAmount != 0m) { systemDealLog = new SystemDealLog(SerialNo, _operator) { Amount = _account.DepositAmount, DealWayId = DealWayId, DealType = SystemDealLogTypes.Deposit, Addin = _account.AccountId.ToString() }; SystemDealLogService.Create(systemDealLog); if (_dealWay.IsCash) { CashDealLogService.Create(new CashDealLog(systemDealLog.Amount, 0, user.UserId, systemDealLog.DealType)); } } AccountLevelPolicy accountLevel = AccountLevelPolicyService.Query().FirstOrDefault(x => x.Level == 0 && x.State == States.Normal && x.AccountTypeId == _account.AccountTypeId && _account.TotalPoint >= x.TotalPointStart); if (accountLevel != null) { _account.AccountLevelName = accountLevel.DisplayName; _account.AccountLevel = accountLevel.Level; } // 用户 //if (_owner != null) //{ // _owner.Name = Guid.NewGuid().ToString("N"); // var roles = MembershipService.QueryRoles(new RoleRequest() { Name = RoleNames.Account }).ToList(); // MembershipService.CreateUser(_owner); // MembershipService.AssignRoles(_owner, roles.Select(x => x.RoleId).ToArray()); // _account.OwnerId = _owner.UserId; //} // sale Id // if (SaleId > 0) { var sale = MembershipService.GetUserById(SaleId) as AdminUser; if (sale != null && sale.IsSale == true) { _account.SalerId = sale.UserId; } } DealLogService.Create(_dealLog); AccountService.Update(_account); return(ResponseCode.Success); }