/// <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 = nameof(RechargeAsync); await _eventPublisher.PublishAsync(new CustomerRechargedEvent(eventId, eventData, eventSource)); return(new SimpleDto <string>(cusTransactionLog.Id.ToString())); }
public async Task <AppSrvResult <SimpleDto <string> > > Recharge(CustomerRechargeDto inputDto) { var customer = await _customerRepo.FindAsync(inputDto.ID); if (customer == null) { return(Problem(HttpStatusCode.NotFound, "不存在该账号")); } var cusTransactionLog = new CusTransactionLog() { Id = IdGenerater.GetNextId(IdGenerater.DatacenterId, IdGenerater.WorkerId) , CustomerId = customer.Id , Account = customer.Account , ExchangeType = "100" , Remark = "" , Amount = inputDto.Amount , ExchageStatus = "10" }; await _cusManagerService.RechargeAsync(cusTransactionLog); return(new SimpleDto <string>(cusTransactionLog.Id.ToString())); }
public async Task <ActionResult <SimpleDto <string> > > RechargeAsync([FromRoute] long id, [FromBody] CustomerRechargeDto input) { return(Result(await _cusService.RechargeAsync(id, input))); }
/// <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 _cusManagerService.RechargeAsync(cusTransactionLog); return(new SimpleDto <string>(cusTransactionLog.Id.ToString())); }