Example #1
0
        /// <summary>
        /// 获取试单前的总金额
        /// </summary>
        /// <param name="checkDto"></param>
        /// <returns></returns>
        public decimal getTotaPrice(BookingCheckInputDto checkDto)
        {
            decimal salePrice = 0;

            try
            {
                long hotelId = Convert.ToInt64(checkDto.HotelId);
                int  rpid    = Convert.ToInt32(checkDto.RatePlanId);
                var  request = new HotelGoodsRequest
                {
                    CheckinDate  = checkDto.CheckIn.ToString("yyyy-MM-dd"),
                    CheckoutDate = checkDto.CheckOut.ToString("yyyy-MM-dd"),
                    GoodsType    = 1,
                    HotelIds     = new List <long> {
                        hotelId
                    }
                };
                var response = new HotelGoodsResponse();
                try
                {
                    response = meiTuanApiClient.Excute(request);
                }
                catch (Exception exstr)
                {
                    response = meiTuanApiClient.Excute(request);
                }
                if (response != null && response.Result != null && response.Result.hotelGoods != null && response.Result.hotelGoods.Count > 0)
                {
                    var rplist    = response.Result.hotelGoods[0].goods;
                    var currentRp = rplist.Where(u => u.hotelId == hotelId && u.goodsId == rpid).FirstOrDefault();
                    if (currentRp != null)
                    {
                        //priceInfo.RatePlanName = string.Format("{0} [{1}早]", priceInfo.RatePlanName, );
                        string  priceStr    = string.Empty;
                        decimal sTotalPrice = 0;
                        decimal sBasePrice  = 0;


                        foreach (var item in currentRp.priceModels)
                        {
                            var     subPricedic = item.subPrice;
                            decimal basePrice   = item.salePrice - item.subPrice;
                            sBasePrice  += basePrice;
                            sTotalPrice += subPricedic;
                            salePrice   += item.salePrice;
                            priceStr    += "price" + basePrice / 100 + "|" + item.salePrice / 100 + "|money" + basePrice / 100 + "|0|";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(salePrice);
        }
Example #2
0
        /// <summary>
        /// 获取价格计划发票
        /// </summary>
        /// <param name="hotelId"></param>
        /// <returns></returns>
        public RatePlanInvoice GetRatePlanInvoice(string hotelId, string ratePlanId, DateTime checkIn, DateTime checkOut)
        {
            var             hid          = Convert.ToInt32(hotelId);
            var             rpid         = Convert.ToInt32(ratePlanId);
            RatePlanInvoice ratePlanInfo = null;
            var             request      = new HotelGoodsRequest
            {
                HotelIds = new List <long> {
                    hid
                },
                CheckinDate  = checkIn.ToString("yyyy-MM-dd"),
                CheckoutDate = checkOut.ToString("yyyy-MM-dd"),
                GoodsType    = 1
            };
            var response = meiTuanApiClient.Excute(request);

            if (response.Result != null && response.Result.hotelGoods != null && response.Result.hotelGoods.Count > 0)
            {
                var hotelDetail = response.Result.hotelGoods.FirstOrDefault();
                var goods       = hotelDetail.goods.Where(u => u.hotelId == hid && u.goodsId == rpid).FirstOrDefault();
                if (goods != null)
                {
                    ratePlanInfo              = new RatePlanInvoice();
                    ratePlanInfo.HotelId      = hid;
                    ratePlanInfo.RoomId       = goods.roomInfoList[0].roomId;
                    ratePlanInfo.InvoiceMode  = (short)goods.invoiceInfo.invoiceMode;
                    ratePlanInfo.IsCommission = goods.thirdParty == 1;//0为非代理
                }
            }
            else
            {
                return(meituanRepository.GetRatePlanInvoice(hotelId, ratePlanId));
            }

            return(ratePlanInfo);
        }
Example #3
0
        /// <summary>
        /// 获取酒店原始信息
        /// </summary>
        /// <param name="checkDto"></param>
        /// <returns></returns>
        public TmallHotelPriceInfo GetHotelPriceInfo(BookingCheckInputDto checkDto)
        {
            long hotelId = Convert.ToInt64(checkDto.HotelId);
            int  rpid    = Convert.ToInt32(checkDto.RatePlanId);
            TmallHotelPriceInfo priceInfo = new TmallHotelPriceInfo();
            var request = new HotelGoodsRequest
            {
                CheckinDate  = checkDto.CheckIn.ToString("yyyy-MM-dd"),
                CheckoutDate = checkDto.CheckOut.ToString("yyyy-MM-dd"),
                GoodsType    = 1,
                HotelIds     = new List <long> {
                    hotelId
                }
            };
            //当失败时重新试单
            var response = new HotelGoodsResponse();

            try
            {
                response = meiTuanApiClient.Excute(request);
            }
            catch (Exception exMt)
            {
                response = meiTuanApiClient.Excute(request);
            }
            if (response != null && response.Result != null && response.Result.hotelGoods != null && response.Result.hotelGoods.Count > 0)
            {
                var rplist    = response.Result.hotelGoods[0].goods;
                var currentRp = rplist.Where(u => u.hotelId == hotelId && u.goodsId == rpid).FirstOrDefault();
                if (currentRp != null)
                {
                    priceInfo.RoomName     = currentRp.roomInfoList[0].roomName;
                    priceInfo.RatePlanName = currentRp.goodsName;
                    int invoiceMode = currentRp.invoiceInfo.invoiceMode;
                    if (invoiceMode == 1)
                    {
                        priceInfo.RatePlanName = string.Format("{0}[酒店开具发票]", priceInfo.RatePlanName);
                    }
                    else if (invoiceMode == 2)
                    {
                        priceInfo.RatePlanName = string.Format("{0}[美团开具发票]", priceInfo.RatePlanName);
                    }
                    else if (invoiceMode == 3)
                    {
                        priceInfo.RatePlanName = string.Format("{0}[第三方开具发票]", priceInfo.RatePlanName);
                    }

                    if (currentRp.thirdParty == 1)
                    {
                        priceInfo.RatePlanName = string.Format("{0}[代理]", priceInfo.RatePlanName);
                    }

                    if (currentRp.goodsType == 2)
                    {
                        priceInfo.RatePlanName = string.Format("{0}[钟点房]", priceInfo.RatePlanName);
                    }

                    //priceInfo.RatePlanName = string.Format("{0} [{1}早]", priceInfo.RatePlanName, );
                    string  priceStr    = string.Empty;
                    decimal sTotalPrice = 0;
                    decimal sBasePrice  = 0;

                    foreach (var item in currentRp.priceModels)
                    {
                        var     subPricedic = item.subPrice;
                        decimal basePrice   = item.salePrice - item.subPrice;
                        sBasePrice  += basePrice;
                        sTotalPrice += subPricedic;
                        priceStr    += "price" + basePrice / 100 + "|" + item.salePrice / 100 + "|money" + basePrice / 100 + "|0|";
                    }
                    priceInfo.DatePrice   = Convert.ToDecimal(sBasePrice / 100);
                    priceInfo.PriceStr    = priceStr;
                    priceInfo.PaymentType = 1;
                    priceInfo.STotalPrice = Convert.ToDecimal(sTotalPrice / 100);


                    var hotel = SqlSugarContext.ChannelInstance.Queryable <MeiTuanHotel>().Where(u => u.HotelId == hotelId).First();
                    if (hotel != null)
                    {
                        priceInfo.HotelName = hotel.HotelName;
                    }
                    else
                    {
                        try
                        {
                            string sql          = string.Format("select top 1 hotelId as HotelId,pointName as HotelName from Mt_hotels where hotelId = {0}", hotelId);
                            var    getHotelInfo = SqlSugarContext.HotelProductInstance.SqlQueryable <MeiTuanHotel>(sql).First();
                            if (getHotelInfo != null && getHotelInfo.HotelName != null)
                            {
                                priceInfo.HotelName = getHotelInfo.HotelName;
                            }
                            else
                            {
                                priceInfo.HotelName = "酒店未获取";
                            }
                        }
                        catch
                        {
                            priceInfo.HotelName = "酒店未获取";
                        }
                    }
                }
            }


            return(priceInfo);
        }