public int Validates() { if (_account.OwnerId.HasValue) { _owner = MembershipService.GetUserById(_account.OwnerId.Value) as AccountUser; } _operatorUser = MembershipService.GetUserById(OperatorUserId); if (_operatorUser == null || !(_operatorUser is AdminUser)) { return(ResponseCode.InvalidateUser); } _dealWay = DealWayService.GetById(this.HowToDeal); if (_dealWay == null || _dealWay.State != DealWayStates.Normal) { return(ResponseCode.InvalidateDealWay); } return(ResponseCode.Success); }
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 ResultMsg Open(int id, DealWay dealWay) { ResultMsg msgResult = new ResultMsg(); try { User operatorUser = SecurityHelper.GetCurrentUser().CurrentUser; using (Transaction tran = TransactionHelper.BeginTransaction()) { string serialNo = SerialNoHelper.Create(); Account account = AccountService.GetById(id); if (account.State != AccountStates.Ready) { msgResult.CodeText = "不好意思,会员状态不对"; } var command = new OpenAccountCommand(serialNo, account.Name, null, null, null, true, dealWay.DealWayId, null, "批量开卡", operatorUser.UserId, 0, Genders.Male, null); UnityContainer.BuildUp(command); int code = command.Validate(); if (code != ResponseCode.Success) { msgResult.CodeText = "不好意思,验证失败"; } command.Execute(operatorUser); decimal?saleFee = 0m; if (command.AccountType != null) { saleFee = HostSite.SaleCardFee; // 手续费 // if (saleFee != null && saleFee.Value != 0m) { account.ChargingAmount += saleFee.Value; AccountService.Update(account); DealWay d = DealWayService.Query().FirstOrDefault(x => x.State == States.Normal); var systemDealLog = new SystemDealLog(serialNo, operatorUser) { Amount = saleFee.Value, DealWayId = (d == null ? 0 : d.DealWayId), DealType = SystemDealLogTypes.SaldCardFee, Addin = account.AccountId.ToString() }; SystemDealLogService.Create(systemDealLog); if (d.IsCash) { CashDealLogService.Create(new CashDealLog(systemDealLog.Amount, 0, operatorUser.UserId, systemDealLog.DealType)); } } } // sale Id // Logger.LogWithSerialNo(LogTypes.AccountOpen, serialNo, command.Account.AccountId, command.Account.Name); if (!string.IsNullOrEmpty(HostSite.TicketTemplateOfOpen)) { DealLog dealLog = command.DealLog; string msg = HostSite.TicketTemplateOfOpen; msg = MessageFormator.FormatForOperator(msg, SecurityHelper.GetCurrentUser()); msg = MessageFormator.Format(msg, dealLog); msg = MessageFormator.FormatHowToDeal(msg, command.DealWay.DisplayName); msg = MessageFormator.Format(msg, command.DealLog); msg = MessageFormator.Format(msg, command.AccountType); msg = MessageFormator.Format(msg, command.Owner); msg = MessageFormator.Format(msg, HostSite); PrintTicketService.Create(new PrintTicket(LogTypes.AccountOpen, serialNo, msg, command.Account)); } tran.Commit(); msgResult.Code = 1; msgResult.CodeText = "会员建卡 " + account.Name + " 成功"; return(msgResult); } } catch (Exception ex) { msgResult.CodeText = "不好意思,系统异常"; Logger.Error("批量发放会员卡", ex); return(msgResult); } }
protected void OnSave(DealWay dealWay) { dealWay.ApplyTo = ApplyTo.GetValue(); dealWay.DisplayName = DisplayName; dealWay.IsCash = IsCash; }
protected void SetInnerObject(DealWay item) { _innerObject = item; ApplyTo = new ApplyToModel(item.ApplyTo); }
public DealWayModelBase(DealWay shop) { _innerObject = shop; }
public DealWayModelBase() { _innerObject = new DealWay(); ApplyTo = new ApplyToModel(); }
public ListDealWay(DealWay innerObject) { _innerObject = innerObject; }
public ListDealWay() { _innerObject = new DealWay(); }
public EditDealWay(DealWay 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); }