public async Task <PayOrderDto> GetAsync(PayOrderRequestDto input) { if (!input.BillNo.IsNullOrEmptyOrWhiteSpace()) { return(ObjectMapper.Map <PayOrder, PayOrderDto>(await _repository.FindAsync(input.BillNo))); } else { return(ObjectMapper.Map <PayOrder, PayOrderDto>(await _repository.GetQuery().FirstOrDefaultAsync(x => x.Id == input.Id))); } }
public async Task TenPayNotifySubscriber(TenPayNotify tenPayNotify) { using (var uow = _unitOfWorkManager.Begin(requiresNew: true)) { var payOrder = await _payOrderRepository.FindAsync(tenPayNotify.out_trade_no); if (payOrder != null) { if (payOrder.TotalPrice.ToString() == tenPayNotify.total_fee && tenPayNotify.result_code == "SUCCESS") { payOrder.SuccessPay(tenPayNotify.Id); if (payOrder.Type == MallEnums.OrderType.Product) { var productOrders = await _productOrderRepository.Where(x => x.BillNo == payOrder.BillNo).ToListAsync(); foreach (var o in productOrders) { // TODO:实收少于应收多少范围内要发消息 o.SuccessPay(MallEnums.PayType.微信, payOrder.TotalPrice / 100m); } } await uow.SaveChangesAsync(); } else { throw new Exception($"Tenpay Result Fee not equals !!pay is {tenPayNotify.fee_type} , db is {payOrder.TotalPrice} , BillNo is {payOrder.BillNo}"); } } else { //TODO:这里要更多的消息通知管理员 throw new Exception($"cant't find BillNo {tenPayNotify.out_trade_no}"); } await Task.CompletedTask; } }