public async Task <WalletRecord> IncomeOfOrderRebate(UserIdentifier userIdentifier, decimal money, string remark, Order order) { WalletRecord walletRecord = BuildWalletRecord(WalletRecordType.Recharge, userIdentifier.UserId, money, remark); WalletRecordRepository.Insert(walletRecord); Wallet wallet = GetWalletOfUser(userIdentifier); wallet.Money += money; WalletRepository.Update(wallet); CurrentUnitOfWork.SaveChanges(); string openid = WechatUserManager.GetOpenid(userIdentifier); if (!string.IsNullOrEmpty(openid)) { OrderRebateTemplateMessageData data = new OrderRebateTemplateMessageData( new TemplateDataItem(remark), new TemplateDataItem(order.Number), new TemplateDataItem(order.PayMoney.ToString()), new TemplateDataItem(order.PaymentDatetime.ToString()), new TemplateDataItem(money.ToString()), new TemplateDataItem(L("ThankYouForYourPatronage")) ); await TemplateMessageManager.SendTemplateMessageOfOrderRebateAsync(order.TenantId, openid, null, data); } return(walletRecord); }
public WalletRecord Transaction(UserIdentifier userIdentifier, decimal money, string remark) { WalletRecord walletRecord = BuildWalletRecord(WalletRecordType.Transaction, userIdentifier.UserId, -money, remark); WalletRecordRepository.Insert(walletRecord); CurrentUnitOfWork.SaveChanges(); return(walletRecord); }
public WalletRecord Recharge(UserIdentifier userIdentifier, decimal money, string remark) { using (CurrentUnitOfWork.SetTenantId(userIdentifier.TenantId)) { WalletRecord walletRecord = BuildWalletRecord(WalletRecordType.Recharge, userIdentifier.UserId, money, remark); WalletRecordRepository.Insert(walletRecord); Wallet wallet = GetWalletOfUser(userIdentifier); wallet.Money += money; WalletRepository.Update(wallet); CurrentUnitOfWork.SaveChanges(); return(walletRecord); } }
public async Task <WalletRecord> WithdrawAsync(UserIdentifier userIdentifier, decimal money, string remark) { using (CurrentUnitOfWork.DisableFilter(DataFilters.MustHaveTenant)) { WalletRecord walletRecord = BuildWalletRecord(WalletRecordType.Withdraw, userIdentifier.UserId, -money, remark); WalletRecordRepository.Insert(walletRecord); Wallet wallet = GetWalletOfUser(userIdentifier); wallet.Money -= money; WalletRepository.Update(wallet); CurrentUnitOfWork.SaveChanges(); await ProcessWithdrawAsync(walletRecord); return(walletRecord); } }