Exemplo n.º 1
0
        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 });
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public ListAccountLevelPolicy()
 {
     _innerObject = new AccountLevelPolicy();
 }
Exemplo n.º 4
0
 public ListAccountLevelPolicy(AccountLevelPolicy adminUser)
 {
     _innerObject = adminUser;
 }
Exemplo n.º 5
0
 public CreateAccountLevelPolicy(AccountLevelPolicy item)
     : base(item)
 {
     InnerObject.State = AccountLevelPolicyStates.Normal;
 }
Exemplo n.º 6
0
 protected void SetInnerObject(AccountLevelPolicy item)
 {
     _innerObject = item;
 }
Exemplo n.º 7
0
 protected void OnSave(AccountLevelPolicy level)
 {
     level.DiscountRate = InnerObject.DiscountRate;
 }
Exemplo n.º 8
0
 public AccountLevelPolicyModelBase(AccountLevelPolicy shop)
 {
     _innerObject = shop;
 }
Exemplo n.º 9
0
 public AccountLevelPolicyModelBase()
 {
     _innerObject = new AccountLevelPolicy();
 }
Exemplo n.º 10
0
 public EditAccountLevelPolicy(AccountLevelPolicy item)
     : base(item)
 {
 }
Exemplo n.º 11
0
        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);
        }