/// <summary>
        /// 下单验证
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public string CreateOrder(string request)
        {
            var     requestBody = _ctripGateway.CheckCreateOrder(request);
            var     data        = requestBody.Data;
            int     productId   = 0;
            decimal price       = data.price.HasValue ? data.price.Value : 0;

            if (!int.TryParse(data.productId, out productId))
            {
                return(_ctripGateway.ErrorResult(ResultCode.CreateOrderForProductNotExist, "产品Id不存在/错误"));
            }
            if (data.payMode != "1")
            {
                return(_ctripGateway.ErrorResult(ResultCode.CreateOrderForParameterIllegality, "付款方式必须网站预付"));
            }
            var response = _ticketGateway.SingleCreateOrder(new OrderSingleCreateRequest
            {
                Body = new OrderSingleCreateBody
                {
                    OrderInfo = new OrderSingleInfo
                    {
                        OrderOtaId     = data.otaOrderId,
                        OrderPayStatus = 1,
                        OrderPrice     = price * data.count,
                        OrderQuantity  = data.count,
                        Ticket         = new ProductItem
                        {
                            ProductId   = productId,
                            Quantity    = data.count,
                            ProductName = data.otaProductName,
                            SellPrice   = price
                        },
                        VisitDate     = data.useDate,
                        ContactPerson = new ContactPerson
                        {
                            BuyName  = data.contactName,
                            Name     = data.contactName,
                            Mobile   = data.contactMobile,
                            CardType = data.contactIdCardType == "1" ? "ID_CARD" : "",
                            CardNo   = data.contactIdCardType == "1" ? data.contactIdCardNo : ""
                        }
                    }
                }
            });

            if (response.Head.Code == "000000")
            {
                var responseBody = new CreateOrderBodyRespose
                {
                    otaOrderId    = response.Body.OtaOrderId,
                    vendorOrderId = response.Body.OrderId,
                    smsCodeType   = 2,
                    smsCode       = response.Body.Code,
                    smsDataStream = "",
                    inventory     = response.Body.Inventory
                };
                return(_ctripGateway.CreateOrder(responseBody));
            }
            else if (response.Head.Code == "113019")
            {
                return(_ctripGateway.ErrorResult(ResultCode.CreateOrderForProductDownline, response.Head.Describe));
            }
            else if (response.Head.Code == "113026")
            {
                var responseBody = new CreateOrderBodyRespose
                {
                    inventory = response.Body.Inventory
                };
                return(_ctripGateway.ErrorResult(ResultCode.CreateOrderForLowStocks, response.Head.Describe, responseBody));
            }
            else if (response.Head.Code == "113021")
            {
                return(_ctripGateway.ErrorResult(ResultCode.SystemError, "系统出错"));
            }
            return(_ctripGateway.ErrorResult(ResultCode.CreateOrderForParameterIllegality, response.Head.Describe));
        }
        /// <summary>
        /// 创建订单
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public object CreateOrder(string request)
        {
            var requestBody = _ctripGateway.CheckCreateOrder(request);

            if (requestBody == null)
            {
                return(_ctripGateway.ErrorResult(ResultCode.JsonParsingFailure, "报文解析失败"));
            }
            var    data         = requestBody.Data;
            bool   isProduct    = true;
            bool   isDate       = true;                       //判断游玩时间是否是同一天
            bool   isCard       = true;
            string useStartDate = data.Items[0].useStartDate; //游玩时间
            var    productItems = new List <ProductItem>();

            foreach (var row in data.Items)
            {
                foreach (var item in row.passengers)
                {
                    if (item.cardType == "0")
                    {
                        isCard = false;
                    }
                }
                if (useStartDate != row.useStartDate)
                {
                    isDate = false;
                }
                int productId = 0;
                if (!int.TryParse(row.PLU, out productId))
                {
                    isProduct = false;
                }
                productItems.Add(new ProductItem
                {
                    ProductId   = productId,
                    Quantity    = row.quantity,
                    ProductName = "",
                    SellPrice   = row.price,
                    ItemId      = row.itemId
                });
            }
            if (!isCard)
            {
                return(_ctripGateway.ErrorResult(ResultCode.CreateOrderForParameterEmpty, "缺失证件"));
            }
            if (!isProduct)
            {
                return(_ctripGateway.ErrorResult(ResultCode.CreateOrderForProductNotExist, "产品Id不存在/错误"));
            }
            if (!isDate)
            {
                return(_ctripGateway.ErrorResult(ResultCode.CreateOrderForDate, "不同的产品,游玩时间不一致"));
            }
            //if (data.payMode != "1")
            //{
            //    return _ctripGateway.ErrorResult(ResultCode.CreateOrderForParameterIllegality, "付款方式必须网站预付");
            //}
            var response = _ticketGateway.CreateOrder(new OrderCreateRequest
            {
                Body = new OrderCreateBody
                {
                    OrderInfo = new OrderInfo
                    {
                        OrderOtaId     = data.otaOrderId,
                        OrderPayStatus = 1,
                        OrderPrice     = productItems.Sum(a => a.SellPrice * a.Quantity),
                        OrderQuantity  = productItems.Sum(a => a.Quantity),
                        TicketList     = productItems,
                        VisitDate      = useStartDate,
                        ContactPerson  = new ContactPerson
                        {
                            BuyName  = data.Contacts[0].name,
                            Name     = data.Contacts[0].name,
                            Mobile   = data.Contacts[0].mobile,
                            CardType = data.Items[0].passengers[0].cardType == "1" ? "ID_CARD" : "",
                            CardNo   = data.Items[0].passengers[0].cardType == "1" ? data.Items[0].passengers[0].cardNo : ""
                        }
                    }
                }
            });

            if (response.Head.Code == "000000")
            {
                var responseBody = new CreateOrderBodyResponse
                {
                    otaOrderId          = response.Body.OtaOrderId,
                    supplierOrderId     = response.Body.OrderId,
                    supplierConfirmType = 1,
                    voucherSender       = 1,
                    items    = new List <CreateOrderitemRespose>(),
                    vouchers = new List <CreateOrderVouchers>()
                };
                foreach (var row in response.Body.Item)
                {
                    responseBody.items.Add(new CreateOrderitemRespose
                    {
                        itemId     = row.OtaOrderDetailId,
                        inventorys = new CreateOrderInventoryRespose
                        {
                            quantity = row.quantity,
                            useDate  = row.useDate
                        }
                    });
                    responseBody.vouchers.Add(new CreateOrderVouchers
                    {
                        itemId      = row.OtaOrderDetailId,
                        voucherType = 2,
                        voucherCode = row.CertificateNo,
                        voucherData = ""
                    });
                }
                return(_ctripGateway.CreateOrder(responseBody));
            }
            else if (response.Head.Code == "113019")
            {
                return(_ctripGateway.ErrorResult(ResultCode.CreateOrderForProductDownline, response.Head.Describe));
            }
            else if (response.Head.Code == "113026")
            {
                //var responseBody = new CreateOrderBodyRespose
                //{
                //    inventory = response.Body.Inventory
                //};
                return(_ctripGateway.ErrorResult(ResultCode.CreateOrderForLowStocks, response.Head.Describe));
            }
            else if (response.Head.Code == "113021")
            {
                return(_ctripGateway.ErrorResult(ResultCode.SystemError, "系统出错"));
            }
            return(_ctripGateway.ErrorResult(ResultCode.CreateOrderForParameterIllegality, response.Head.Describe));
        }