public OrderQueryRequestDTO Build() { var query = new OrderQueryRequestDTO { CustomerId = _wellKnownOrderQuery.CustomerId, DeliveryAddress = _wellKnownOrderQuery.DeliveryAddress, OrderId = _wellKnownOrderQuery.OrderId, ProductId = _wellKnownOrderQuery.ProductId }; if (_withCustomerId) { query.CustomerId = _customerId; } if (_withProductId) { query.ProductId = _productId; } if (_withDeliveryAddress) { query.DeliveryAddress = _deliveryAddress; } return(query); }
public IActionResult Query([FromBody] OrderQueryRequestDTO dto) { var orders = _orderService.GetOrderByQuery(dto); if (orders.Any()) { return(Ok(orders)); } return(NotFound($"No orders matches the current search criteria")); }
public IEnumerable <OrderQueryResponseDTO> GetOrderByQuery(OrderQueryRequestDTO dto) { var queryableOrders = _context.Orders.AsQueryable <Order>(); if (dto == null) { throw new Exception("OrderQuery DTO cannot be null"); } if (dto.CustomerId != 0) { queryableOrders = queryableOrders.Where(x => x.CustomerId == dto.CustomerId); } if (!string.IsNullOrWhiteSpace(dto.DeliveryAddress)) { queryableOrders = queryableOrders.Where(x => x.DeliveryAddress.Contains(dto.DeliveryAddress)); } if (dto.OrderId != 0) { queryableOrders = queryableOrders.Where(x => x.Id == dto.OrderId); } if (dto.ProductId != 0) { queryableOrders = queryableOrders.Where(x => x.ProductId == dto.ProductId); } var orderList = queryableOrders.ToList(); var result = orderList.Select(x => new OrderQueryResponseDTO { ProductId = x.ProductId, CustomerId = x.CustomerId, DeliveryAddress = x.DeliveryAddress, OrderId = x.Id, OrderStatus = x.OrderStatus, Quantity = x.Quantity, UnitPrice = x.UnitPrice }); return(result); }
public async Task <OrderQueryResponseDTO> GetOrder(OrderQueryRequestDTO model) { OrderQueryResponseDTO result = null; var sign = model.ToSign(_configuration.WeChatKey); var api = $"https://api.mch.weixin.qq.com/pay/orderquery?appid={model.AppId}&mch_id={model.MchId}&transaction_id={model.TransactionId}&out_trade_no={model.OutTradeNo}&nonce_str={model.NonceStr}&sign={sign}&sign_type={model.SignType}"; using (var client = new HttpClient()) { var res = await client.GetAsync(api); if (res.IsSuccessStatusCode) { var resultStr = await res.Content.ReadAsStringAsync(); result = JsonConvert.DeserializeObject <OrderQueryResponseDTO>(resultStr); } } //TODO:验签 return(result); }
public async Task <OrderQueryResponseDTO> QueryOrder(OrderQueryRequestDTO model) { return(await _wechatApiProxy.GetOrder(model)); }