コード例 #1
0
        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);
        }
コード例 #2
0
        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"));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: IWeChatApiProxy.cs プロジェクト: Crazyers/gooios
        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);
        }
コード例 #5
0
 public async Task <OrderQueryResponseDTO> QueryOrder(OrderQueryRequestDTO model)
 {
     return(await _wechatApiProxy.GetOrder(model));
 }