Esempio n. 1
0
        /// <summary>
        /// 保存订单
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public ServiceResult SaveOrder(ProductChannel channel, TmallOrderDto order)
        {
            var result = new ServiceResult();

            try
            {
                var tbOrder = new tb_hotelorder();
                Mapper.Map(order, tbOrder);
                tbOrder.orderType = 2;
                var excuteRows = SqlSugarContext.BigTreeInstance.Insertable(tbOrder).ExecuteCommand();
                if (excuteRows == 0)
                {
                    excuteRows = SqlSugarContext.BigTreeInstance.Insertable(tbOrder).ExecuteCommand();
                }

                if (excuteRows > 0)
                {
                    return(result.SetSucess("保存订单成功"));
                }
                else
                {
                    return(result.SetSucess("保存订单失败"));
                }
            }
            catch (Exception ex)
            {
                return(result.SetError("保存订单失败:{0}", ex.Message));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 转换订单
        /// </summary>
        /// <param name="bookRQ"></param>
        /// <returns></returns>
        private TmallOrderDto ParseOrder(BookRQ bookRQ)
        {
            TmallOrderDto order = new TmallOrderDto();

            order.checkInDate      = bookRQ.CheckIn.Date;
            order.checkOutDate     = bookRQ.CheckOut.Date;
            order.contactName      = bookRQ.ContactName;
            order.contactTel       = bookRQ.ContactTel;
            order.orderNO          = GenerateOrderNum(bookRQ.RatePlanCode);
            order.TaoBaoHotelId    = bookRQ.TaoBaoHotelId;
            order.TaoBaoRoomTypeId = bookRQ.TaoBaoRoomTypeId;
            order.TaoBaoRatePlanId = bookRQ.TaoBaoRatePlanId;
            var hotelInfo = GetIdInfoByRpCode(bookRQ.RatePlanCode);

            if (hotelInfo != null)
            {
                order.hotelID    = hotelInfo.HotelId;
                order.roomID     = hotelInfo.RoomTypeId;
                order.ratePlanID = hotelInfo.RatePlanId;
            }
            else
            {
                throw new Exception("价格计划ID有误");
            }

            if (bookRQ.OrderGuests != null)
            {
                List <string> stg = new List <string>();
                for (int i = 0, l = bookRQ.OrderGuests.Count; i < l; i++)
                {
                    stg.Add(bookRQ.OrderGuests[i].Name);
                }
                order.guestName = string.Join(",", stg.ToArray());
            }
            else
            {
                //      order.guestName = order.guestName;
            }
            try
            {
                //  特殊处理单号
                string ns = order.contactTel.Replace("*", "0").Replace("-", "0").Replace("_", "0");
                if (ns.Length > 3)
                {
                    ns            = ns.Substring(ns.Length - 3);
                    order.orderNO = order.orderNO + ns;
                }
            }
            catch
            {
            }

            order.caozuo             = string.Format("system 添加订单 [{0}]  \r\n", DateTime.Now.ToString());
            order.earliestArriveTime = bookRQ.EarliestArriveTime;
            order.lastArriveTime     = bookRQ.LatestArriveTime;
            order.guestMobile        = bookRQ.ContactTel;
            order.roomNum            = bookRQ.RoomNum;
            order.taoBaoGId          = bookRQ.TaoBaoGid;
            order.taoBaoOrderId      = bookRQ.TaoBaoOrderId;
            order.totalPrice         = Convert.ToInt32(bookRQ.TotalPrice / 100);
            order.comment            = bookRQ.Comment;
            order.payTime            = new DateTime(1900, 1, 1);
            order.orderTime          = DateTime.Now;
            order.sCheckInDate       = new DateTime(1990, 1, 1);
            order.sCheckOutDate      = new DateTime(1990, 1, 1);
            order.tradeStatus        = "";
            order.logisticsStatus    = "";
            order.alipayPay          = 0;
            order.state          = Channel == ProductChannel.BigTree ? 66 : 1;
            order.payType        = "t";
            order.shopType       = (short)Shop;
            order.source         = "";
            order.Refuse         = 0;
            order.sentfaxtime    = new DateTime(1900, 1, 1);
            order.orderType      = Convert.ToInt16(Channel.GetDescription());
            order.DailyInfoPrice = JsonConvert.SerializeObject(bookRQ.DailyInfos);
            return(order);
        }
Esempio n. 3
0
        /// <summary>
        /// 通知回调
        /// </summary>
        /// <returns></returns>
        protected override BookRQResult Notice()
        {
            BookRQResult result = new BookRQResult();

            result.ResultCode = "-100";
            result.Message    = "生成订单失败";

            if (Shop == ShopType.ShengLv && Channel == ProductChannel.BigTree)
            {
                return(result);
            }

            try
            {
                #region 异步保存发票信息
                if (Request.InvoiceInfo != null)
                {
                    try
                    {
                        Task.Run(() =>
                        {
                            SaveInvoiceInfo(Request);    //异步保存发票信息
                        });
                    }
                    catch (Exception ex)
                    {
                        logWriter.WriteOrder(Request.TaoBaoOrderId.ToString(), "保存发票信息失败:{0},错误:{1}", JsonConvert.SerializeObject(Request.InvoiceInfo), ex.ToString());
                    }
                }

                #endregion

                FilterRemark(Request);
                TmallOrderDto order = ParseOrder(Request);
                if (Convert.ToInt32(order.hotelID) > 0)
                {
                    string hotelId = order.hotelID;
                    //Task.Factory.StartNew(() =>
                    //{
                    //    if (Shop == ShopType.RenXing || Shop == ShopType.YinJi)
                    //    {
                    //        string url = string.Format("http://47.106.239.82/MtPricePro/AliChek.ashx?key=qoeutpzmbjhsyehgixjsngklzoeuyhbgfs&hid=0&code={0}&checkin={1}&checkout={2}&shop=yj&visit=验单失败或下单成功&invoice=1&addplan=0", hotelId, Request.CheckIn, Request.CheckOut);
                    //        WebHttpRequest.Get(url);
                    //    }
                    //    //TODO 下单失败,关房
                    //});

                    if (orderRepository.IsExists(Request.TaoBaoOrderId))
                    {
                        result.Message    = "重复预定";
                        result.ResultCode = "-106";
                        return(result);
                    }

                    Task <TmallHotelPriceInfo> getHotelPriceInfo = Task.Factory.StartNew(
                        () => productChannel.GetHotelPriceInfo(new BookingCheckInputDto
                    {
                        CheckIn    = Request.CheckIn,
                        CheckOut   = Request.CheckOut,
                        HotelId    = order.hotelID,
                        RatePlanId = order.ratePlanID,
                        RoomNum    = order.roomNum,
                        RoomTypeId = order.roomID
                    }
                                                               ));
                    getHotelPriceInfo.Wait();
                    var simpleOrder = getHotelPriceInfo.Result;
                    if (simpleOrder == null || string.IsNullOrEmpty(simpleOrder.PriceStr))
                    {
                        //Task.Factory.StartNew(() =>
                        //{
                        //    var client = DomesticHotelClient.CreateInstance(Shop, Channel);
                        //    client.RoomRate.UpdateRoomRateByHid(hotelId);
                        //});

                        //Task.Factory.StartNew(() =>
                        //{
                        //    //异步关闭所有房型
                        //    RoomRateService roomRateService = new RoomRateService(Shop, Channel);
                        //    roomRateService.UpdateRoomRateByHid(order.hotelID, true, true);
                        //});
                        Task.Factory.StartNew(() =>
                        {
                            try
                            {
                                AliTripValidate av = new AliTripValidate();
                                av.CheckInTime     = Request.CheckIn;
                                av.CheckOutTime    = Request.CheckOut;
                                av.RatePlanCode    = Request.RatePlanCode;
                                av.HotelId         = hotelId;
                                av.RoomId          = order.roomID;
                                av.RatePlanId      = order.ratePlanID;
                                av.CreateTime      = DateTime.Now;
                                av.IsFull          = true;
                                av.Channel         = (int)Channel;
                                av.Shop            = (int)Shop;
                                av.Remark          = "预订满房";
                                SqlSugarContext.RenNiXingInstance.Insertable(av).ExecuteCommand();

                                string url = string.Format("http://localhost:8097/apiAshx/UpdateRoomRate.ashx?type=RoomRate&hid={0}&source={1}", hotelId, (int)Channel);
                                WebHttpRequest.Get(url);
                            }
                            catch
                            {
                            }
                        });

                        if ((int)Channel == 8)
                        {
                            getHotelPriceInfo = Task.Factory.StartNew(
                                () => productChannel.GetHotelPriceInfo(new BookingCheckInputDto
                            {
                                CheckIn    = DateTime.Now.AddDays(7),
                                CheckOut   = DateTime.Now.AddDays(8),
                                HotelId    = order.hotelID,
                                RatePlanId = order.ratePlanID,
                                RoomNum    = order.roomNum,
                                RoomTypeId = order.roomID
                            }
                                                                       ));
                            getHotelPriceInfo.Wait();
                            simpleOrder = getHotelPriceInfo.Result;
                            if (simpleOrder == null || string.IsNullOrEmpty(simpleOrder.PriceStr))
                            {
                                getHotelPriceInfo = Task.Factory.StartNew(
                                    () => productChannel.GetHotelPriceInfo(new BookingCheckInputDto
                                {
                                    CheckIn    = DateTime.Now.AddDays(8),
                                    CheckOut   = DateTime.Now.AddDays(9),
                                    HotelId    = order.hotelID,
                                    RatePlanId = order.ratePlanID,
                                    RoomNum    = order.roomNum,
                                    RoomTypeId = order.roomID
                                }
                                                                           ));
                                getHotelPriceInfo.Wait();
                                simpleOrder = getHotelPriceInfo.Result;
                            }

                            decimal totalPrice = 0;
                            string  priceStr   = string.Empty;
                            foreach (var item in Request.DailyInfos)
                            {
                                var basePrice = item.Price;

                                priceStr   += "price" + basePrice + "|" + basePrice + "|money" + basePrice + "|0|";
                                totalPrice += basePrice;
                            }
                            string RoomNameCn = simpleOrder.RoomName;
                            if (simpleOrder.RoomName == "获取房型失败")
                            {
                                RoomNameCn = simpleOrder.RatePlanName.Replace("[携程开具发票]", "").Replace("[酒店开具发票]", "").Replace("[金牌]", "");
                            }
                            order.sTotalPrice      = 0;
                            order.priceStr         = "";
                            order.hotelName        = simpleOrder.HotelName;
                            order.roomName         = RoomNameCn;
                            order.ratePlanName     = simpleOrder.RatePlanName;
                            order.totalPrice       = Convert.ToDecimal(totalPrice * Request.RoomNum);
                            order.paymentType      = (short)Request.PaymentType;
                            order.taobaoTotalPrice = Convert.ToDecimal(Request.TotalPrice) / 100;
                            order.CurrencyCode     = "CNY";



                            if (Request.RatePlanCode.Split('_').Length > 3)
                            {
                                order.ratePlanName = string.Format("{0}[虚拟]", order.ratePlanName);
                            }


                            if (Request.ContactName.Length > 20)
                            {
                                order.remark     += string.Format("【系统】[注意:联系人-{0}]     <br/>{1}", order.contactName, order.remark);
                                order.contactName = order.contactName.Substring(0, 20);
                            }

                            if (order.guestName.Length > 64)
                            {
                                order.remark   += string.Format("【系统】[注意:入住人-{0}]     <br/>{1}", order.guestName, order.remark);
                                order.guestName = order.guestName.Substring(0, 64);
                            }
                            order.state = 63;

                            try
                            {
                                var serviceResult = orderRepository.SaveOrder(Channel, order);
                                if (serviceResult.IsSucess)
                                {
                                    //异步更新买家信息
                                    Task.Factory.StartNew(() =>
                                    {
                                        UpdateBuyerInfo(Shop, order.taoBaoOrderId);
                                    });

                                    result.Message    = string.Format("创建订单成功");
                                    result.ResultCode = "0";
                                    result.OrderId    = order.orderNO;
                                }
                                else
                                {
                                    result.Message    = string.Format("系统保存订单失败:{0}", serviceResult.Message);
                                    result.ResultCode = "-105";
                                    logWriter.WriteOrder(Request.TaoBaoOrderId.ToString(), "保存订单表失败");
                                }
                            }
                            catch (Exception ex)
                            {
                                result.Message    = string.Format("系统保存异常");
                                result.ResultCode = "-104";
                                logWriter.WriteOrder(Request.TaoBaoOrderId.ToString(), "保存订单表失败:" + ex.ToString());
                            }
                        }
                        else
                        {
                            result.Message    = string.Format("满房,不可预定");
                            result.ResultCode = "-101";
                            logWriter.WriteOrder(Request.TaoBaoOrderId.ToString(), "::创建订单失败-编号:{0},{1},失败原因{2}", hotelId, Request.RatePlanCode, result.Message);
                        }
                        return(result);
                    }

                    if (string.IsNullOrEmpty(simpleOrder.RoomName))
                    {
                        //Task.Factory.StartNew(() =>
                        //{
                        //    //异步关闭所有房型
                        //    RoomRateService roomRateService = new RoomRateService(Shop, Channel);
                        //    roomRateService.UpdateRoomRateByHid(order.hotelID, true, true);
                        //});
                        logWriter.WriteOrder(Request.TaoBaoOrderId.ToString(), "获取不到房型;");
                        result.Message    = string.Format("房型不存在");
                        result.ResultCode = "-114";
                        return(result);
                    }

                    if (!CheckPrice(Request.TotalPrice, simpleOrder.DatePrice, Request.RoomNum))   //校验价格
                    {
                        Task.Factory.StartNew(() =>
                        {
                            try
                            {
                                AliTripValidate av = new AliTripValidate();
                                av.CheckInTime     = Request.CheckIn;
                                av.CheckOutTime    = Request.CheckOut;
                                av.RatePlanCode    = Request.RatePlanCode;
                                av.HotelId         = hotelId;
                                av.RoomId          = order.roomID;
                                av.RatePlanId      = order.ratePlanID;
                                av.CreateTime      = DateTime.Now;
                                av.IsFull          = true;
                                av.Channel         = (int)Channel;
                                av.Shop            = (int)Shop;
                                av.Remark          = "下单总价校验失败";
                                SqlSugarContext.RenNiXingInstance.Insertable(av).ExecuteCommand();

                                //47.106.132.129:9078
                                string url = string.Format("http://localhost:8097/apiAshx/UpdateRoomRate.ashx?type=RoomRate&hid={0}&source={1}", hotelId, (int)Channel);
                                WebHttpRequest.Get(url);
                            }
                            catch
                            {
                            }
                            ////异步关闭所有房型
                            //RoomRateService roomRateService = new RoomRateService(Shop, Channel);
                            //roomRateService.UpdateRoomRateByHid(order.hotelID, true, true);
                        });

                        logWriter.WriteOrder(Request.TaoBaoOrderId.ToString(), "下单价格异常{0}-{1};完整:{2}", (Request.TotalPrice / 100), simpleOrder.DatePrice * Request.RoomNum, JsonConvert.SerializeObject(simpleOrder));
                        result.Message    = string.Format("下单总价校验失败");
                        result.ResultCode = "-103";
                        return(result);
                    }
                    string RoomName = simpleOrder.RoomName;
                    if (simpleOrder.RoomName == "获取房型失败")
                    {
                        RoomName = simpleOrder.RatePlanName.Replace("[携程开具发票]", "").Replace("[酒店开具发票]", "").Replace("[金牌]", "");
                    }

                    order.sTotalPrice      = simpleOrder.STotalPrice * Request.RoomNum;
                    order.priceStr         = simpleOrder.PriceStr;
                    order.hotelName        = simpleOrder.HotelName;
                    order.roomName         = RoomName;
                    order.ratePlanName     = simpleOrder.RatePlanName;
                    order.totalPrice       = Convert.ToDecimal(simpleOrder.DatePrice * Request.RoomNum);
                    order.paymentType      = (short)simpleOrder.PaymentType;
                    order.taobaoTotalPrice = Convert.ToDecimal(Request.TotalPrice) / 100;
                    order.CurrencyCode     = simpleOrder.CurrencyCode;

                    if (simpleOrder.CurrencyPrice.HasValue)
                    {
                        order.MemberPrice = simpleOrder.CurrencyPrice;
                    }

                    if (string.IsNullOrEmpty(simpleOrder.RatePlanName))
                    {
                        order.remark += " [rp不存在]";
                    }


                    if (Request.RatePlanCode.Split('_').Length > 3)
                    {
                        order.ratePlanName = string.Format("{0}[虚拟]", order.ratePlanName);
                    }


                    if (Request.ContactName.Length > 20)
                    {
                        order.remark     += string.Format("【系统】[注意:联系人-{0}]     <br/>{1}", order.contactName, order.remark);
                        order.contactName = order.contactName.Substring(0, 20);
                    }

                    if (order.guestName.Length > 64)
                    {
                        order.remark   += string.Format("【系统】[注意:入住人-{0}]     <br/>{1}", order.guestName, order.remark);
                        order.guestName = order.guestName.Substring(0, 64);
                    }

                    try
                    {
                        var serviceResult = orderRepository.SaveOrder(Channel, order);
                        if (serviceResult.IsSucess)
                        {
                            //异步更新买家信息
                            Task.Factory.StartNew(() =>
                            {
                                UpdateBuyerInfo(Shop, order.taoBaoOrderId);
                            });

                            result.Message    = string.Format("创建订单成功");
                            result.ResultCode = "0";
                            result.OrderId    = order.orderNO;
                        }
                        else
                        {
                            result.Message    = string.Format("系统保存订单失败:{0}", serviceResult.Message);
                            result.ResultCode = "-105";
                            logWriter.WriteOrder(Request.TaoBaoOrderId.ToString(), "保存订单表失败");
                        }
                    }
                    catch (Exception ex)
                    {
                        result.Message    = string.Format("系统保存异常");
                        result.ResultCode = "-104";
                        logWriter.WriteOrder(Request.TaoBaoOrderId.ToString(), "保存订单表失败:" + ex.ToString());
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                logWriter.WriteOrder(Request.TaoBaoOrderId.ToString(), "创建订单异常:{0}", ex.ToString());
                result.ResultCode = "-104";
                result.Message    = "系统异常";
                return(result);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 保存订单
        /// </summary>
        /// <param name="channel"></param>
        /// <param name="order"></param>
        /// <returns></returns>
        public ServiceResult SaveOrder(ProductChannel channel, TmallOrderDto order)
        {
            var result = new ServiceResult();

            try
            {
                var tbOrder = new TB_hotelcashorder();
                Mapper.Map(order, tbOrder);
                tbOrder.orderCheckoutDate = new DateTime(1990, 1, 1);

                var shop = (ShopType)order.shopType;
                if (channel == ProductChannel.MT)
                {
                    if (shop == ShopType.ShengLv)
                    {
                        tbOrder.orderType = 11;
                    }
                    else if (shop == ShopType.RenNiXing)
                    {
                        tbOrder.orderType = 14;
                    }
                    else
                    {
                        tbOrder.orderType = 13;
                    }
                }
                else if (channel == ProductChannel.Ctrip)
                {
                    if (order.RatePlanCode.Contains("_c"))
                    {
                        tbOrder.orderType = 16;
                    }
                    else
                    {
                        //15 喜玩携程    5辰亿
                        tbOrder.orderType = CtripOrderType();
                    }
                    //if (shop == ShopType.LingZhong)
                    //{
                    //    tbOrder.orderType = 5;
                    //}
                    //else
                    //{
                    //    tbOrder.orderType = 15;
                    //}
                }
                else if (channel == ProductChannel.DDS)
                {
                    //大都市产品
                    tbOrder.orderType = 17;
                }
                else
                {
                    tbOrder.orderType = Int16.Parse(channel.GetDescription());
                }

                tbOrder.serviceTimeount = new DateTime(1990, 1, 1);       // GetDelayTime(dto.checkInDate);
                tbOrder.prePay          = 1;

                if (channel == ProductChannel.Elong)
                {
                    tbOrder.source = "elong";
                }
                else if (channel == ProductChannel.LY)
                {
                    tbOrder.source = "tclj";
                }
                tbOrder.Refuse = 0;   //退款标记

                var isSuccess = sqlSugarClient.Insertable(tbOrder).ExecuteCommand() > 0;
                if (isSuccess)
                {
                    return(result.SetSucess("保存订单成功"));
                }
                else
                {
                    return(result.SetError("保存订单失败"));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 通知回调
        /// </summary>
        /// <returns></returns>
        protected override BookRQResult Notice()
        {
            BookRQResult result = new BookRQResult();

            result.ResultCode = "-100";
            result.Message    = "生成订单失败";

            if (Shop == ShopType.ShengLv && Channel == ProductChannel.BigTree)
            {
                return(result);
            }

            try
            {
                #region 异步保存发票信息
                if (Request.InvoiceInfo != null)
                {
                    try
                    {
                        Task.Run(() =>
                        {
                            SaveInvoiceInfo(Request);    //异步保存发票信息
                        });
                    }
                    catch (Exception ex)
                    {
                        logWriter.WriteOrder(Request.TaoBaoOrderId.ToString(), "保存发票信息失败:{0},错误:{1}", JsonConvert.SerializeObject(Request.InvoiceInfo), ex.ToString());
                    }
                }

                #endregion

                FilterRemark(Request);
                TmallOrderDto order = ParseOrder(Request);
                if (!string.IsNullOrWhiteSpace(order.hotelID))
                {
                    string hotelId = order.hotelID;
                    //Task.Factory.StartNew(() =>
                    //{
                    //    if (Shop == ShopType.RenXing || Shop == ShopType.YinJi)
                    //    {
                    //        string url = string.Format("http://47.106.239.82/MtPricePro/AliChek.ashx?key=qoeutpzmbjhsyehgixjsngklzoeuyhbgfs&hid=0&code={0}&checkin={1}&checkout={2}&shop=yj&visit=验单失败或下单成功&invoice=1&addplan=0", hotelId, Request.CheckIn, Request.CheckOut);
                    //        WebHttpRequest.Get(url);
                    //    }
                    //    //TODO 下单失败,关房
                    //});

                    if (orderRepository.IsExists(Request.TaoBaoOrderId))
                    {
                        result.Message    = "重复预定";
                        result.ResultCode = "-106";
                        return(result);
                    }

                    Task <TmallHotelPriceInfo> getHotelPriceInfo = Task.Factory.StartNew(
                        () => productChannel.GetHotelPriceInfo(new BookingCheckInputDto
                    {
                        CheckIn      = Request.CheckIn,
                        CheckOut     = Request.CheckOut,
                        HotelId      = order.hotelID,
                        RatePlanId   = order.ratePlanID,
                        RoomNum      = order.roomNum,
                        RoomTypeId   = order.roomID,
                        RatePlanCode = Request.RatePlanCode
                    }
                                                               ));
                    getHotelPriceInfo.Wait();
                    var simpleOrder = getHotelPriceInfo.Result;
                    if (simpleOrder == null || string.IsNullOrEmpty(simpleOrder.PriceStr))
                    {
                        //Task.Factory.StartNew(() =>
                        //{
                        //    var client = DomesticHotelClient.CreateInstance(Shop, Channel);
                        //    client.RoomRate.UpdateRoomRateByHid(hotelId);
                        //});

                        //Task.Factory.StartNew(() =>
                        //{
                        //    //异步关闭所有房型
                        //    RoomRateService roomRateService = new RoomRateService(Shop, Channel);
                        //    roomRateService.UpdateRoomRateByHid(order.hotelID, true, true);
                        //});

                        //预订时,进订为不可预订时关房
                        Task.Factory.StartNew(() =>
                        {
                            try
                            {
                                AliTripValidate av = new AliTripValidate();
                                av.CheckInTime     = Request.CheckIn;
                                av.CheckOutTime    = Request.CheckOut;
                                av.RatePlanCode    = Request.RatePlanCode;
                                av.HotelId         = hotelId;
                                av.RoomId          = order.roomID;
                                av.RatePlanId      = order.ratePlanID;
                                av.CreateTime      = DateTime.Now;
                                av.IsFull          = true;
                                av.Channel         = (int)Channel;
                                av.Shop            = (int)Shop;
                                av.Remark          = "预订满房";
                                SqlSugarContext.RenNiXingInstance.Insertable(av).ExecuteCommand();

                                string url = string.Format("http://localhost:8097/apiAshx/UpdateRoomRate.ashx?type=RoomRate&hid={0}&source={1}", hotelId, (int)Channel);
                                WebHttpRequest.Get(url);
                            }
                            catch
                            {
                            }
                        });

                        #region 当携程预订满房时保存数据库返回下单成功为客服提醒客户申请退款
                        if ((int)Channel == 8 || (int)Channel == 10)
                        {
                            string priceStr = string.Empty;

                            string RoomNameCn = simpleOrder.RoomName;


                            order.hotelName = simpleOrder.HotelName;
                            order.roomName  = simpleOrder.RoomName;
                            //order.ratePlanName = simpleOrder.RatePlanName;
                            //order.totalPrice = Convert.ToDecimal(Request.TotalPrice- Request.VoucherInfos[0].VoucherPomotionAmt) / 100;
                            order.paymentType      = (short)Request.PaymentType;
                            order.totalPrice       = 0;
                            order.RatePlanCode     = Request.RatePlanCode;
                            order.taobaoTotalPrice = Convert.ToDecimal(Request.TotalPrice) / 100;
                            order.CurrencyCode     = "CNY";



                            //if (Request.RatePlanCode.Split('_').Length > 3)
                            //{
                            //    order.ratePlanName = string.Format("{0}[虚拟]", order.ratePlanName);
                            //}


                            if (Request.ContactName.Length > 20)
                            {
                                order.remark     += string.Format("【系统】[注意:联系人-{0}]     <br/>{1}", order.contactName, order.remark);
                                order.contactName = order.contactName.Substring(0, 20);
                            }

                            if (order.guestName.Length > 64)
                            {
                                order.remark   += string.Format("【系统】[注意:入住人-{0}]     <br/>{1}", order.guestName, order.remark);
                                order.guestName = order.guestName.Substring(0, 64);
                            }

                            try
                            {
                                var serviceResult = orderRepository.SaveOrder(Channel, order);
                                if (serviceResult.IsSucess)
                                {
                                    result.Message    = string.Format("创建订单成功");
                                    result.ResultCode = "0";
                                    result.OrderId    = order.orderNO;
                                }
                                else
                                {
                                    result.Message    = string.Format("系统保存订单失败:{0}", serviceResult.Message);
                                    result.ResultCode = "-105";
                                    logWriter.WriteOrder(Request.TaoBaoOrderId.ToString(), "保存订单表失败");
                                }
                            }
                            catch (Exception ex)
                            {
                                result.Message    = string.Format("系统保存异常");
                                result.ResultCode = "-104";
                                logWriter.WriteOrder(Request.TaoBaoOrderId.ToString(), "保存订单表失败:" + ex.ToString());
                            }
                        }
                        else
                        {
                            result.Message    = string.Format("满房,不可预定");
                            result.ResultCode = "-101";
                        }
                        #endregion
                        logWriter.WriteOrder(Request.TaoBaoOrderId.ToString(), "::创建订单失败(满房)-编号:{0},{1},失败原因{2}", hotelId, Request.RatePlanCode, result.Message);
                        return(result);
                    }

                    if (string.IsNullOrEmpty(simpleOrder.RoomName))
                    {
                        //Task.Factory.StartNew(() =>
                        //{
                        //    //异步关闭所有房型
                        //    RoomRateService roomRateService = new RoomRateService(Shop, Channel);
                        //    roomRateService.UpdateRoomRateByHid(order.hotelID, true, true);
                        //});
                        logWriter.WriteOrder(Request.TaoBaoOrderId.ToString(), "获取不到房型;");
                        result.Message    = string.Format("房型不存在");
                        result.ResultCode = "-114";
                        return(result);
                    }

                    if (!CheckPrice(Request.TotalPrice, simpleOrder.DatePrice, Request.RoomNum))   //校验价格
                    {
                        Task.Factory.StartNew(() =>
                        {
                            try
                            {
                                AliTripValidate av = new AliTripValidate();
                                av.CheckInTime     = Request.CheckIn;
                                av.CheckOutTime    = Request.CheckOut;
                                av.RatePlanCode    = Request.RatePlanCode;
                                av.HotelId         = hotelId;
                                av.RoomId          = order.roomID;
                                av.RatePlanId      = order.ratePlanID;
                                av.CreateTime      = DateTime.Now;
                                av.IsFull          = true;
                                av.Channel         = (int)Channel;
                                av.Shop            = (int)Shop;
                                av.Remark          = "下单总价校验失败";
                                SqlSugarContext.RenNiXingInstance.Insertable(av).ExecuteCommand();

                                //47.106.132.129:9078
                                string url = string.Format("http://localhost:8097/apiAshx/UpdateRoomRate.ashx?type=RoomRate&hid={0}&source={1}", hotelId, (int)Channel);
                                WebHttpRequest.Get(url);
                            }
                            catch
                            {
                            }
                            ////异步关闭所有房型
                            //RoomRateService roomRateService = new RoomRateService(Shop, Channel);
                            //roomRateService.UpdateRoomRateByHid(order.hotelID, true, true);
                        });

                        logWriter.WriteOrder(Request.TaoBaoOrderId.ToString(), "下单价格异常{0}-{1};完整:{2}", (Request.TotalPrice / 100), simpleOrder.DatePrice * Request.RoomNum, JsonConvert.SerializeObject(simpleOrder));
                        result.Message    = string.Format("下单总价校验失败");
                        result.ResultCode = "-103";
                        return(result);
                    }
                    string RoomName = simpleOrder.RoomName;
                    if (simpleOrder.RoomName == "获取房型失败")
                    {
                        RoomName = simpleOrder.RatePlanName.Replace("[携程开具发票]", "").Replace("[酒店开具发票]", "").Replace("[金牌]", "");
                    }

                    order.sTotalPrice      = simpleOrder.STotalPrice * Request.RoomNum;
                    order.priceStr         = simpleOrder.PriceStr;
                    order.hotelName        = simpleOrder.HotelName;
                    order.roomName         = RoomName;
                    order.ratePlanName     = simpleOrder.RatePlanName;
                    order.totalPrice       = Convert.ToDecimal(simpleOrder.DatePrice * Request.RoomNum);
                    order.paymentType      = (short)simpleOrder.PaymentType;
                    order.taobaoTotalPrice = Convert.ToDecimal(Request.TotalPrice) / 100;
                    order.CurrencyCode     = simpleOrder.CurrencyCode;
                    order.RatePlanCode     = Request.RatePlanCode;
                    //保存客人预订早餐数
                    order.userID = Request.DailyInfos[0].BreakFast;


                    if (simpleOrder.CurrencyPrice.HasValue)
                    {
                        order.MemberPrice = simpleOrder.CurrencyPrice;
                    }

                    if (string.IsNullOrEmpty(simpleOrder.RatePlanName))
                    {
                        order.remark += " [rp不存在]";
                    }


                    //if (Request.RatePlanCode.Split('_').Length > 3)
                    //{
                    //    order.ratePlanName = string.Format("{0}[虚拟]", order.ratePlanName);
                    //}


                    if (Request.ContactName.Length > 20)
                    {
                        order.remark     += string.Format("【系统】[注意:联系人-{0}]     <br/>{1}", order.contactName, order.remark);
                        order.contactName = order.contactName.Substring(0, 20);
                    }

                    if (order.guestName.Length > 64)
                    {
                        order.remark   += string.Format("【系统】[注意:入住人-{0}]     <br/>{1}", order.guestName, order.remark);
                        order.guestName = order.guestName.Substring(0, 64);
                    }

                    //判断大都市早餐数与预订时的早餐数
                    if ((int)Channel == 10 && !string.IsNullOrEmpty(simpleOrder.PriceStr) && order.userID != 0 && order.userID != simpleOrder.BreakFast && simpleOrder.BreakFast != 99)
                    {
                        Task.Factory.StartNew(() =>
                        {
                            try
                            {
                                //当早餐数不对等时更新rp
                                string urlUpdateRp = string.Format("http://localhost:9092/ashx/rnxUpdateRaPlan.ashx?type=rp&source=10&hid={0}", order.hotelID);
                                string getBoby     = WebHttpRequest.Get(urlUpdateRp);
                                if (!getBoby.Contains("更新价格计划成功"))
                                {
                                    WebHttpRequest.Get(urlUpdateRp);
                                }
                            }
                            catch
                            {
                            }
                        });
                        if (order.userID > simpleOrder.BreakFast)
                        {
                            order.hasChange = 1;
                            order.sRoomNum  = simpleOrder.BreakFast;
                            //order.remark += string.Format("【系统】:早餐个数不相等,天猫:{1}, 供应商:{2}  [{0}]<br/>", DateTime.Now.ToString(), order.userID, simpleOrder.BreakFast);
                        }
                    }
                    if ((int)Channel == 10 && simpleOrder.BreakFast != 99)
                    {
                        //保存大都市产品在预订时供应商的早餐数,为判断早餐数是否对等
                        order.sRoomNum = simpleOrder.BreakFast;
                    }

                    try
                    {
                        var serviceResult = orderRepository.SaveOrder(Channel, order);
                        if (serviceResult.IsSucess)
                        {
                            //异步更新买家信息
                            Task.Factory.StartNew(() =>
                            {
                                UpdateBuyerInfo(Shop, order.taoBaoOrderId);
                            });

                            result.Message    = string.Format("创建订单成功");
                            result.ResultCode = "0";
                            result.OrderId    = order.orderNO;
                        }
                        else
                        {
                            result.Message    = string.Format("系统保存订单失败:{0}", serviceResult.Message);
                            result.ResultCode = "-105";
                            logWriter.WriteOrder(Request.TaoBaoOrderId.ToString(), "保存订单表失败");
                        }
                    }
                    catch (Exception ex)
                    {
                        result.Message    = string.Format("系统保存异常");
                        result.ResultCode = "-104";
                        logWriter.WriteOrder(Request.TaoBaoOrderId.ToString(), "保存订单表失败:" + ex.ToString());
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                logWriter.WriteOrder(Request.TaoBaoOrderId.ToString(), "创建订单异常:{0}", ex.ToString());
                result.ResultCode = "-104";
                result.Message    = "系统异常";
                return(result);
            }
        }