public int Execute(User @operatorUser) { _operatorUser = @operatorUser ?? _operatorUser; _account.Amount += Amount; AccountService.Update(_account); var systemDealLog = new SystemDealLog(SerialNo, _operatorUser) { Amount = Amount, DealType = SystemDealLogTypes.Recharge, HasReceipt = HasReceipt, Addin = _account.AccountId.ToString(), DealWayId = this.HowToDeal }; SystemDealLogService.Create(systemDealLog); DealLog dealLog = CreateDealLog(); dealLog.Addin = systemDealLog.SystemDealLogId; DealLogService.Create(dealLog); if (!string.IsNullOrWhiteSpace(CurrentSite.MessageTemplateOfRecharge)) { if (_owner != null && _accountType.IsSmsRecharge && _owner.IsMobileAvailable) { string message = MessageFormator.FormatTickForRecharging(CurrentSite.MessageTemplateOfRecharge, CurrentSite, HasReceipt, Amount, _dealWay != null?_dealWay.DisplayName:"", dealLog, _account, AccountType, _owner, _operatorUser); SmsHelper.Send(_owner.Mobile, message); } } return(ResponseCode.Success); }
public static AccountServiceResponse ValidateDealItem(DealLog dealLog, string shopName, string posName, decimal dealAmount, bool isForce) { switch (dealLog.DealType) { case DealTypes.PayIntegral: { if (dealLog == null || dealLog.LiquidateDealLogId != 0 || dealLog.SourceShopName != shopName || dealLog.SourcePosName != posName || dealLog.State != DealLogStates.Normal || Math.Abs(dealLog.Point) != Math.Round(dealAmount, 0, MidpointRounding.AwayFromZero)) { return(new AccountServiceResponse(ResponseCode.NonFoundDeal)); } break; } // case DealTypes. default: { if (dealLog == null || dealLog.LiquidateDealLogId != 0 || dealLog.SourceShopName != shopName || dealLog.SourcePosName != posName || dealLog.State != DealLogStates.Normal ) { return(new AccountServiceResponse(ResponseCode.NonFoundDeal)); } break; } } return(new AccountServiceResponse(ResponseCode.Success)); }
private AccountServiceResponse DoCall(PayRequest request) { var account = _accountList.FirstOrDefault(x => x.Name == request.AccountName); if (account == null) { return(new AccountServiceResponse(ResponseCode.NonFoundAccount)); } var shop = _shopList.FirstOrDefault(x => x.Name == request.ShopName); if (shop == null) { return(new AccountServiceResponse(ResponseCode.InvalidateShop)); } var pos = _posList.FirstOrDefault(x => x.Name == request.PosName); if (pos == null) { return(new AccountServiceResponse(ResponseCode.InvalidatePos)); } var dealLog = new DealLog("123456789012", DealTypes.Deal, request.Amount, (int)(request.Amount / 10), pos, shop, account, shop, 0); return(new AccountServiceResponse(ResponseCode.Success, dealLog, shop, account, null) { SerialServerNo = "123456789012" }); }
public void Notify(Account account, AccountUser owner, DealLog dealItem) { foreach (var tracker in _trackers) { tracker.Notify(account, owner, dealItem); } }
public void Notify(Account account, AccountUser owner, DealLog dealItem) { try { var site = _siteService.GetSite(); if (site != null && !string.IsNullOrWhiteSpace(site.MessageTemplateOfDeal)) { if (owner != null && owner.IsMobileAvailable) { var text = ""; switch (dealItem.DealType) { case DealTypes.Deal: text = site.MessageTemplateOfDeal; break; case DealTypes.Integral: text = site.MessageTemplateOfDeal; break; case DealTypes.Recharging: text = site.MessageTemplateOfRecharge; break; case DealTypes.DonePrePay: text = site.MessageTemplateOfDonePrePay; break; case DealTypes.PrePay: text = site.MessageTemplateOfPrePay; break; default: break; } if (string.IsNullOrWhiteSpace(text)) { return; } text = MessageFormator.Format(text, owner); text = MessageFormator.Format(text, dealItem); text = MessageFormator.Format(text, account); text = MessageFormator.Format(text, _site); _smsHelper.Send(owner.Mobile, text); _log.Info("send sms for " + account.Name); } } } catch (Exception ex) { _log.Error("send message failed!", ex); } }
public IMessageProvider Save() { TransactionHelper.BeginTransaction(); var serialNo = SerialNoHelper.Create(); var pointRebate = PointRebateService.GetById(this.PointRebate); if (pointRebate == null) { AddError(LogTypes.AccountRebate, "NoPointRebate"); return(this); } var account = AccountService.GetById(AccountId); if (account == null || account.Point < pointRebate.Point) { AddError(LogTypes.AccountRebate, "NoPointRebate"); return(this); } var accountLevel = AccountLevelPolicyService.Query().FirstOrDefault( x => x.State == AccountLevelPolicyStates.Normal && x.Level == account.AccountLevel && x.AccountTypeId == account.AccountTypeId); var owner = (AccountUser)(_innerObject.OwnerId.HasValue ? this.MembershipService.GetUserById(_innerObject.OwnerId.Value) : null); var pointRebates = PointRebateService.Query().Where(x => x.IsFor(account, owner, accountLevel, DateTime.Now) && x.Point < account.Point).ToList(); if (pointRebates.Count == 0) { AddError(LogTypes.AccountRebate, "NoPointRebate"); return(this); } if (!pointRebates.Any(x => x.PointRebateId == pointRebate.PointRebateId)) { AddError(LogTypes.AccountRebate, "NoPointRebate"); return(this); } account.Amount += pointRebate.Amount; account.Point -= pointRebate.Point; AccountService.Update(account); var dealLog = new DealLog(serialNo, DealTypes.Rebate, -pointRebate.Amount, -pointRebate.Point, null, null, account, null, pointRebate.PointRebateId); DealLogService.Create(dealLog); SystemDealLogService.Create(new SystemDealLog(serialNo, SecurityHelper.GetCurrentUser()) { Amount = pointRebate.Amount, DealType = SystemDealLogTypes.Rebate, Addin = dealLog.DealLogId.ToString() }); Logger.LogWithSerialNo(LogTypes.AccountRebate, serialNo, account.AccountId, account.Name, pointRebate.DisplayName); PointRebateLogService.Create(new PointRebateLog(serialNo, account, SecurityHelper.GetCurrentUser().CurrentUser, pointRebate)); AddMessage("success", pointRebate.Amount, pointRebate.Point); return(TransactionHelper.CommitAndReturn(this)); }
//public DealLog GetDealItemWithAddin(int addInId, int dealType) //{ // const string sql = "SELECT * FROM dealLogs WHERE AddIn = @AddIn and dealType = @dealType and state = 1"; // return _databaseInstance.Query<DealLog>(sql, new { AddIn = addInId, dealType = dealType }).FirstOrDefault(); //} public int Save(DealLog dealLog) { if (dealLog.DealLogId != 0) { return(_databaseInstance.Update(dealLog, "DealLogs")); } else { dealLog.DealLogId = _databaseInstance.Insert(dealLog, "DealLogs"); return(dealLog.DealLogId); } }
public void Ready() { DealLog = DealLogService.GetById(Convert.ToInt32(ServerSerialNo)); if (!DealLog.IsCancelEnabled) { DealLog = null; } else { ShopName = DealLog.ShopName; AccountName = DealLog.AccountName; } }
public void Ready() { var id = 0; if (!int.TryParse(ServerSerialNo, out id)) { return; } DealLog = DealLogService.GetById(id); if (DealLog == null) { return; } if (DealLog.State != DealLogStates.Normal || DealLog.DealType != DealTypes.Deal) { DealLog = null; return; } var user = SecurityHelper.GetCurrentUser().CurrentUser; AdminUser adminUser = user as AdminUser; if (adminUser != null) { if (DealLog.SourceShopName != Constants.SystemShopName) { DealLog = null; return; } } ShopUser shopUser = user as ShopUser; if (shopUser != null) { var shop = ShopService.GetById(shopUser.ShopId); if (DealLog.SourceShopName != shop.Name) { DealLog = null; return; } } }
public DealLog CreateDealLog() { var dealLog = new DealLog(SerialNo) { Account = _account, Addin = 0, Amount = -Amount, DealType = DealTypes.Recharging, Point = 0, SourcePosId = 0, SourcePosName = "", SourceShopDisplayName = "", State = DealLogStates.Normal, SourceShopId = 0, SourceShopName = "", SubmitTime = DateTime.Now, }; return(dealLog); }
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 void Update(DealLog item) { _databaseInstance.Update(item, TableName); }
public OpenAccountServiceResponse(int code, DealLog dealLog, Shop accountShop, Account account, User user) : base(code, dealLog, accountShop, account, user, null, null) { }
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); } }
public void Delete(DealLog item) { _databaseInstance.Delete(item, TableName); }
public void Notify(Account account, AccountUser owner, DealLog dealItem) { }
public AccountServiceResponse Save() { var serialNo = SerialNoHelper.Create(); TransactionHelper.BeginTransaction(); var accountName = AccountName.TrimSafty(); var account = AccountService.GetByName(accountName); if (account == null || (account.State != AccountStates.Normal && account.State != AccountStates.Invalid)) { return(new AccountServiceResponse(ResponseCode.NonFoundAccount)); } User owner = null; if (account.OwnerId.HasValue) { owner = MembershipService.GetUserById(account.OwnerId.Value); } var amount = account.Amount; // Ó¦Í˽ð¶î var depositAmount = account.DepositAmount; account.Amount = 0; account.DepositAmount = 0; account.State = AccountStates.Closed; account.LastDealTime = DateTime.Now; account.ExpiredDate = DateTime.Now; account.OwnerId = null; // ÍË¿¨ // var currentUser = SecurityHelper.GetCurrentUser().CurrentUser; var systemDealLog = new SystemDealLog(serialNo, currentUser) { Amount = -amount, DealType = SystemDealLogTypes.CloseCard }; SystemDealLogService.Create(systemDealLog); CashDealLogService.Create(new CashDealLog(systemDealLog.Amount, 0, currentUser.UserId, systemDealLog.DealType)); var dealLog1 = new DealLog(SerialNoHelper.Create()) { DealType = DealTypes.Close, AccountAmount = 0, AccountId = account.AccountId, AccountName = account.Name, Point = 0, Amount = amount, SubmitTime = DateTime.Now, State = DealLogStates.Normal }; DealLogService.Create(dealLog1); // Ѻ½ð // if (depositAmount != 0m) { var dealLog = new SystemDealLog(serialNo, currentUser) { Amount = -depositAmount, DealType = SystemDealLogTypes.CloseDeposit }; SystemDealLogService.Create(dealLog); CashDealLogService.Create(new CashDealLog(dealLog.Amount, 0, currentUser.UserId, dealLog.DealType)); } AccountService.Update(account); if (owner != null) { MembershipService.DeleteUser(owner); } Logger.LogWithSerialNo(LogTypes.AccountClose, serialNo, account.AccountId, accountName); TransactionHelper.Commit(); var response = new MyAccountServiceResponse(ResponseCode.Success, dealLog1, ShopService.GetById(account.ShopId), account, owner) { DepositAmount = depositAmount, Amount = amount }; if (!string.IsNullOrWhiteSpace(CurrentSite.TicketTemplateOfClose)) { var message = MessageFormator.Format(CurrentSite.TicketTemplateOfClose, account); message = MessageFormator.Format(message, amount); message = MessageFormator.Format(message, CurrentSite); message = message.Replace("#deposit-amount#", depositAmount.ToString()); message = message.Replace("#total-amount#", (depositAmount + amount).ToString()); message = MessageFormator.Format(message, owner); response.CodeText = message.FormatForJavascript(); } return(response); }
public SimpleAjaxResult Save() { try { var serialNo = SerialNoHelper.Create(); if (Amount < 0) { return(new SimpleAjaxResult(Localize("invalidAmount"))); } TransactionHelper.BeginTransaction(); var account1 = AccountService.GetByName(AccountName); if (account1 == null || (account1.State != AccountStates.Normal && account1.State != AccountStates.Invalid)) { return(new SimpleAjaxResult(string.Format(Localize("accountNonFound"), AccountName))); } var account2 = AccountService.GetByName(AccountNameTo); if (account2 == null || (account2.State != AccountStates.Normal && account2.State != AccountStates.Invalid)) { return(new SimpleAjaxResult(string.Format(Localize("accountNonFound"), AccountNameTo))); } var accountType = AccountTypeService.GetById(account1.AccountTypeId); if (accountType == null || !accountType.IsRecharging) { return(new SimpleAjaxResult(string.Format(Localize("accountCannotRecharging"), AccountName))); } accountType = AccountTypeService.GetById(account2.AccountTypeId); if (accountType == null || !accountType.IsRecharging) { return(new SimpleAjaxResult(string.Format(Localize("accountCannotRecharging"), AccountNameTo))); } if (Amount == 0) { Amount = account1.Amount; } if (account1.Amount < Amount) { return(new SimpleAjaxResult(Localize("invalidAmount"))); } var passSvc = UnityContainer.Resolve <IPasswordService>(HostSite.PasswordType); var password = passSvc.Decrypto(Password); if (User.SaltAndHash(password, account1.PasswordSalt) != account1.Password) { return(new SimpleAjaxResult(Localize("invalidPassword", "ÃÜÂë´íÎó"))); } account1.Amount -= Amount; account2.Amount += Amount; AccountService.Update(account1); AccountService.Update(account2); // transfer in DealLog dealLog = new DealLog(serialNo); dealLog.Account = account1; dealLog.Addin = account1.AccountId; dealLog.Amount = Amount; dealLog.DealType = DealTypes.TransferOut; DealLogService.Create(dealLog); // transfer out dealLog = new DealLog(serialNo); dealLog.Account = account2; dealLog.Addin = account2.AccountId; dealLog.Amount = -Amount; dealLog.DealType = DealTypes.TransferIn; DealLogService.Create(dealLog); Logger.LogWithSerialNo(LogTypes.AccountTransfer, serialNo, account1.AccountId, account1.Name, account2.Name, Amount); var r = new DataAjaxResult(); if (!string.IsNullOrWhiteSpace(HostSite.TicketTemplateOfTransfer)) { r.Data1 = MessageFormator.FormatTickForTransfer(HostSite.TicketTemplateOfTransfer, serialNo, account1, account1.OwnerId.HasValue ? MembershipService.GetUserById(account1.OwnerId.Value) : null, AccountTypeService.GetById(account1.AccountTypeId), account2, account2.OwnerId.HasValue ? MembershipService.GetUserById(account2.OwnerId.Value) : null, AccountTypeService.GetById(account2.AccountTypeId), SecurityHelper.GetCurrentUser().CurrentUser ); PrintTicketService.Create(new PrintTicket(LogTypes.AccountTransfer, serialNo, r.Data1.ToString(), account1)); } return(TransactionHelper.CommitAndReturn(r)); } catch (System.Exception ex) { Logger.Error(LogTypes.AccountTransfer, ex); return(new SimpleAjaxResult(Localize("SystemError"))); } }
/// <summary> /// /// </summary> /// <param name="code"><see cref="ResponseCode"/></param> /// <param name="deallog"></param> /// <param name="accountShop"></param> /// <param name="account"></param> /// <param name="owner"></param> /// <param name="shop"></param> /// <param name="shopOwner"></param> public AccountServiceResponse(int code, DealLog deallog, Shop accountShop, Account account, User owner, Shop shop = null, User shopOwner = null) { Code = code; if (account != null) { this.Amount = Math.Abs(account.Amount + account.FreezeAmount); this.Point = Math.Abs(account.Point); this.ExpiredDate = account.ExpiredDate.ToString("yyyy-MM-dd"); this.AccountName = account.Name; switch (account.State) { case AccountStates.Closed: State = "注销"; break; case AccountStates.Normal: State = "正常"; break; case AccountStates.Invalid: State = "停用"; break; default: State = "未激活"; break; } } if (owner != null) { this.OwnerDisplayName = owner.DisplayName; this.Photo = owner.Photo; this.Identity = owner.IdentityCard; this.Mobile = owner.Mobile; if (owner.Gender.HasValue == true) { if (owner.Gender == Genders.Female) { Sex = "女"; } else { Sex = "男"; } } else { Sex = ""; } } if (shop != null) { this.ShopToAddress = shop.Address; this.ShopToName = shop.Name; this.ShopToDisplayName = shop.DisplayName; this.ShopToPhoneNumber = shop.PhoneNumber; this.ShopType = shop.ShopType; this.ShopToDescription = shop.Description; this.ShopToAccountName = shop.BankAccountName; this.ShopToDealTime = ""; } if (shopOwner != null) { this.ShopToMobile = shopOwner.Mobile; } if (accountShop != null) { AccountShopName = accountShop.DisplayName; } SerialServerNo = "000000000000"; if (deallog != null) { SerialServerNo = deallog.SerialServerNo; this.ThisTimePoint = deallog.Point; } }
public ListDealLog() { _innerObject = new DealLog(); }
public ListDealLog(DealLog adminUser) { _innerObject = adminUser; }
public void Create(DealLog item) { item.DealLogId = _databaseInstance.Insert(item, TableName); }