/// <summary> /// 充值 /// </summary> /// <param name="id"></param> /// <param name="input"></param> /// <returns></returns> public async Task <AppSrvResult <SimpleDto <string> > > RechargeAsync(long id, CustomerRechargeDto input) { var customer = await _customerRepo.FindAsync(id); if (customer == null) { return(Problem(HttpStatusCode.NotFound, "不存在该账号")); } var cusTransactionLog = new CustomerTransactionLog() { Id = IdGenerater.GetNextId(), CustomerId = customer.Id, Account = customer.Account, ExchangeType = ExchangeTypeEnum.Recharge, Remark = "", Amount = input.Amount, ExchageStatus = ExchageStatusEnum.Processing }; await _cusTransactionLogRepo.InsertAsync(cusTransactionLog); //发布充值事件 var eventId = IdGenerater.GetNextId(); var eventData = new CustomerRechargedEvent.EventData() { CustomerId = cusTransactionLog.CustomerId, TransactionLogId = cusTransactionLog.Id, Amount = cusTransactionLog.Amount }; var eventSource = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName; await _eventPublisher.PublishAsync(new CustomerRechargedEvent(eventId, eventData, eventSource)); return(new SimpleDto <string>(cusTransactionLog.Id.ToString())); }
public virtual async Task RechargeAsync(CustomerTransactionLog cusTransactionLog, CancellationToken cancellationToken = default) { await _cusTransactionLogRepo.InsertAsync(cusTransactionLog); //发布充值事件 var eventId = IdGenerater.GetNextId(IdGenerater.DatacenterId, IdGenerater.WorkerId); var eventData = new CustomerRechargedEvent.EventData() { CustomerId = cusTransactionLog.CustomerId, TransactionLogId = cusTransactionLog.Id, Amount = cusTransactionLog.Amount }; var eventSource = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName; await _eventPublisher.PublishAsync(new CustomerRechargedEvent(eventId, eventData, eventSource)); }