Ejemplo n.º 1
0
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="body"></param>
        /// <returns></returns>
        public static MessageSendResponse SendMessage(MessageSendBody body)
        {
            var request = new MessageSendRequest
            {
                Head = new HeadRequest
                {
                    InvokeTime      = DateTime.Now.ToString("yyyy-MM-dd"),
                    InvokeUser      = key,
                    ProtocolVersion = "V1"
                },
                Body = body
            };
            string url    = apiUrl + "message/send";
            var    result = dooPost(request, url).Result;

            if (!string.IsNullOrEmpty(result.Data))
            {
                return(Base64Helper.Base64EncodeToObject <MessageSendResponse>(result.Data));
            }
            return(new MessageSendResponse {
                Head = new HeadResponse {
                    Describe = "数据格式不正确"
                }
            });
        }
Ejemplo n.º 2
0
        public OrderDetailRefundResponse RefundOrderDetail(string data, string sign)
        {
            var request  = Base64Helper.Base64EncodeToObject <OrderDetailRefundRequest>(data);
            var business = _authorizationService.CheckData(request, data, sign);

            return(RefundOrderDetail(request.OrderDetailId));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 验证创建单个产品订单格式是否正确
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public OrderSingleCreateRequest CheckFormatForOrderSingleCreateRequest(string data)
 {
     try
     {
         var request = Base64Helper.Base64EncodeToObject <OrderSingleCreateRequest>(data);
         if (request.Head == null || request.Body == null || request.Body.OrderInfo == null)
         {
             return(null);
         }
         return(request);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 验证产品格式是否正确
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public ProductQueryRequest CheckFormatForProductQueryRequest(string data)
 {
     try
     {
         var request = Base64Helper.Base64EncodeToObject <ProductQueryRequest>(data);
         if (request.Head == null || request.Body == null)
         {
             return(null);
         }
         return(request);
     }
     catch
     {
         return(null);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 发送入园凭证短信 格式验证
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public MessageSendRequest CheckFormatForMessageSendRequest(string data)
 {
     try
     {
         var request = Base64Helper.Base64EncodeToObject <MessageSendRequest>(data);
         if (request.Head == null || request.Body == null || request.Body.OrderInfo == null)
         {
             return(null);
         }
         return(request);
     }
     catch
     {
         return(null);
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// HttpClient实现Get请求(异步)
        /// </summary>
        public static async Task <ProductResponse> dooGet()
        {
            ProductQueryRequest request = new ProductQueryRequest
            {
                Head = new HeadRequest
                {
                    InvokeTime      = DateTime.Now.ToString("yyyy-MM-dd"),
                    InvokeUser      = "******",
                    ProtocolVersion = "V1"
                },
                Body = new Product
                {
                    Type = 0
                }
            };
            var data         = Base64Helper.ObjectToBase64Encode(request);
            var sign         = Md5Helper.Md5Encrypt32(data, "dc0b52fb-c750-44f2-b5dc-f2577fd98c1b");
            var securityType = "MD5";

            string url = "http://192.168.13.43:60110/api/product?data=" + data + "&sign=" + sign + "&securityType=" + securityType;
            //创建HttpClient(注意传入HttpClientHandler)
            var handler = new HttpClientHandler()
            {
                AutomaticDecompression = DecompressionMethods.GZip
            };

            using (var http = new HttpClient(handler))
            {
                //await异步等待回应
                var response = await http.GetAsync(url);

                //确保HTTP成功状态值
                var httpResponseMessage = response.EnsureSuccessStatusCode();
                if (httpResponseMessage.StatusCode == HttpStatusCode.OK)
                {
                    var ddd = await response.Content.ReadAsStringAsync();

                    var result = JsonHelper.JsonToObject <PageResult>(ddd);
                    return(Base64Helper.Base64EncodeToObject <ProductResponse>(result.Data));
                }
                return(null);

                //await异步读取最后的JSON(注意此时gzip已经被自动解压缩了,因为上面的AutomaticDecompression = DecompressionMethods.GZip)
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 创建单个产品订单
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public OrderSingleCreateResponse SingleCreateOrder(OrderSingleCreateRequest request)
        {
            request.Head = RequestHead();
            string url    = _website + "order/singleCreate";
            var    result = PostService(request, url);

            if (!string.IsNullOrEmpty(result.Data))
            {
                return(Base64Helper.Base64EncodeToObject <OrderSingleCreateResponse>(result.Data));
            }
            return(new OrderSingleCreateResponse
            {
                Head = new HeadResponse
                {
                    Code = "900001",
                    Describe = "数据格式不正确"
                }
            });
        }
Ejemplo n.º 8
0
        public ProductResponse GetProduct(ProductQueryRequest request)
        {
            request.Head = RequestHead();
            string url    = _website + "product";
            var    result = PostService(request, url);

            if (!string.IsNullOrEmpty(result.Data))
            {
                return(Base64Helper.Base64EncodeToObject <ProductResponse>(result.Data));
            }
            return(new ProductResponse
            {
                Head = new HeadResponse
                {
                    Code = "900001",
                    Describe = "数据格式不正确"
                }
            });
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 创建单个产品订单
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static OrderSingleCreateResponse SingleCreateOrder(OrderSingleCreateRequest request)
        {
            request.Head = new HeadRequest
            {
                InvokeTime      = DateTime.Now.ToString("yyyy-MM-dd"),
                InvokeUser      = key,
                ProtocolVersion = "V1"
            };
            string url    = apiUrl + "order/singleCreate";
            var    result = dooPost(request, url).Result;

            if (!string.IsNullOrEmpty(result.Data))
            {
                return(Base64Helper.Base64EncodeToObject <OrderSingleCreateResponse>(result.Data));
            }
            return(new OrderSingleCreateResponse {
                Head = new HeadResponse {
                    Describe = "数据格式不正确"
                }
            });
        }
Ejemplo n.º 10
0
        public static ProductResponse GetProduct(ProductQueryRequest request)
        {
            request.Head = new HeadRequest
            {
                InvokeTime      = DateTime.Now.ToString("yyyy-MM-dd"),
                InvokeUser      = key,
                ProtocolVersion = "V1"
            };
            string url    = apiUrl + "product";
            var    result = dooPost(request, url).Result;

            if (!string.IsNullOrEmpty(result.Data))
            {
                return(Base64Helper.Base64EncodeToObject <ProductResponse>(result.Data));
            }
            return(new ProductResponse {
                Head = new HeadResponse {
                    Describe = "数据格式不正确"
                }
            });
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="body"></param>
        /// <returns></returns>
        public MessageSendResponse SendMessage(MessageSendBody body)
        {
            var request = new MessageSendRequest
            {
                Head = RequestHead(),
                Body = body
            };
            string url    = _website + "message/send";
            var    result = PostService(request, url);

            if (!string.IsNullOrEmpty(result.Data))
            {
                return(Base64Helper.Base64EncodeToObject <MessageSendResponse>(result.Data));
            }
            return(new MessageSendResponse
            {
                Head = new HeadResponse
                {
                    Code = "900001",
                    Describe = "数据格式不正确"
                }
            });
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 查询订单
        /// </summary>
        /// <param name="body"></param>
        /// <returns></returns>
        public OrderQueryResponse QueryOrder(OrderQuery body)
        {
            var request = new OrderQueryRequest
            {
                Head = RequestHead(),
                Body = body
            };
            string url    = _website + "order/query";
            var    result = PostService(request, url);

            if (!string.IsNullOrEmpty(result.Data))
            {
                return(Base64Helper.Base64EncodeToObject <OrderQueryResponse>(result.Data));
            }
            return(new OrderQueryResponse
            {
                Head = new HeadResponse
                {
                    Code = "900001",
                    Describe = "数据格式不正确"
                }
            });
        }