Esempio n. 1
0
        public BasicPrice QueryBasicPrice(Guid basicPriceId)
        {
            string     sql    = "SELECT [AIRLINE],[DEPARTURE],[ARRIVAL],[FLIGHTDATE],[ETDZDATE],[PRICE],[MILEAGE],ModifyTime FROM [T_BasicPrice] WHERE [ID]=@Id";
            BasicPrice result = null;

            using (var dbOperator = new DbOperator(Provider, ConnectionString))
            {
                dbOperator.AddParameter("Id", basicPriceId);
                using (var reader = dbOperator.ExecuteReader(sql))
                {
                    while (reader.Read())
                    {
                        result               = new BasicPrice(basicPriceId);
                        result.AirlineCode   = reader.IsDBNull(0) ? string.Empty : reader.GetString(0);
                        result.DepartureCode = reader.GetString(1);
                        result.ArrivalCode   = reader.GetString(2);
                        result.FlightDate    = reader.GetDateTime(3);
                        result.ETDZDate      = reader.GetDateTime(4);
                        result.Price         = reader.GetDecimal(5);
                        result.Mileage       = reader.GetDecimal(6);
                        result.ModifyTime    = reader.IsDBNull(7) ?
                                               new DateTime(2012, 10, 26, 0, 0, 0) : reader.GetDateTime(7);
                    }
                }
            }
            return(result);
        }
Esempio n. 2
0
        public static void AddBasicPrice(BasicPriceView basicPriceView, string account)
        {
            basicPriceView.ModifyTime = DateTime.Now;
            var basicPrice = BasicPrice.GetBasicPrice(basicPriceView);

            BasicPriceCollection.Instance.Add(basicPrice.Id, basicPrice);
            saveAddLog("基础运价", basicPrice.ToString(), basicPrice.Id.ToString(), account);
        }
Esempio n. 3
0
        public int Delete(BasicPrice value)
        {
            string sql = "DELETE FROM [T_BasicPrice] WHERE ID=@ID";

            using (var dbOperator = new DbOperator(Provider, ConnectionString)) {
                dbOperator.AddParameter("ID", value.Id);
                return(dbOperator.ExecuteNonQuery(sql));
            }
        }
Esempio n. 4
0
        public static void UpdateBasicPrice(Guid id, BasicPriceView basicPriceView, string account)
        {
            var originalBasicPrice = QueryBasicPrice(id);

            if (null == originalBasicPrice)
            {
                throw new ChinaPay.Core.CustomException("原基础运价不存在");
            }
            var originalContent = originalBasicPrice.ToString();

            basicPriceView.ModifyTime = DateTime.Now;
            var basicPrice = BasicPrice.GetBasicPrice(id, basicPriceView);

            BasicPriceCollection.Instance.Update(basicPrice.Id, basicPrice);
            saveUpdateLog("基础运价", originalContent, basicPrice.ToString(), basicPrice.Id.ToString(), account);
        }
Esempio n. 5
0
        public int Update(BasicPrice value)
        {
            string sql = "UPDATE [T_BasicPrice] SET [AIRLINE]=@AIRLINE,[DEPARTURE]=@DEPARTURE,[ARRIVAL]=@ARRIVAL,[FLIGHTDATE]=@FLIGHTDATE,[ETDZDATE]=@ETDZDATE,[PRICE]=@PRICE,[MILEAGE]=@MILEAGE,ModifyTime=@MODIFYTIME WHERE [ID]=@ID";

            using (var dbOperator = new DbOperator(Provider, ConnectionString)) {
                dbOperator.AddParameter("ID", value.Id);
                if (value.AirlineCode.IsNullOrEmpty())
                {
                    dbOperator.AddParameter("AIRLINE", DBNull.Value);
                }
                else
                {
                    dbOperator.AddParameter("AIRLINE", value.AirlineCode.Value);
                }
                dbOperator.AddParameter("DEPARTURE", value.DepartureCode.Value);
                dbOperator.AddParameter("ARRIVAL", value.ArrivalCode.Value);
                dbOperator.AddParameter("FLIGHTDATE", value.FlightDate);
                dbOperator.AddParameter("ETDZDATE", value.ETDZDate);
                dbOperator.AddParameter("PRICE", value.Price);
                dbOperator.AddParameter("MILEAGE", value.Mileage);
                dbOperator.AddParameter("MODIFYTIME", value.ModifyTime);
                return(dbOperator.ExecuteNonQuery(sql));
            }
        }
Esempio n. 6
0
        public IEnumerable <KeyValuePair <Guid, BasicPrice> > Query()
        {
            string sql    = "SELECT [ID],[AIRLINE],[DEPARTURE],[ARRIVAL],[FLIGHTDATE],[ETDZDATE],[PRICE],[MILEAGE],[ModifyTime] FROM [T_BasicPrice]";
            var    result = new List <KeyValuePair <Guid, BasicPrice> >();

            using (var dbOperator = new DbOperator(Provider, ConnectionString)) {
                using (var reader = dbOperator.ExecuteReader(sql)) {
                    while (reader.Read())
                    {
                        BasicPrice item = new BasicPrice(reader.GetGuid(0));
                        item.AirlineCode   = reader.IsDBNull(1) ? string.Empty : reader.GetString(1);
                        item.DepartureCode = reader.GetString(2);
                        item.ArrivalCode   = reader.GetString(3);
                        item.FlightDate    = reader.GetDateTime(4);
                        item.ETDZDate      = reader.GetDateTime(5);
                        item.Price         = reader.GetDecimal(6);
                        item.Mileage       = reader.GetDecimal(7);
                        item.ModifyTime    = reader.IsDBNull(8) ? new DateTime(2012, 10, 26, 0, 0, 0) : reader.GetDateTime(8);
                        result.Add(new KeyValuePair <Guid, BasicPrice>(item.Id, item));
                    }
                }
            }
            return(result);
        }
Esempio n. 7
0
        public int Insert(BasicPrice value)
        {
            string sql = "INSERT INTO [T_BasicPrice]([ID],[AIRLINE],[DEPARTURE],[ARRIVAL],[FLIGHTDATE],[ETDZDATE],[PRICE],[MILEAGE],[ModifyTime]) VALUES(@ID,@AIRLINE,@DEPARTURE,@ARRIVAL,@FLIGHTDATE,@ETDZDATE,@PRICE,@MILEAGE,@MODIFYTIME)";

            using (var dbOperator = new DbOperator(Provider, ConnectionString)) {
                dbOperator.AddParameter("ID", value.Id);
                if (value.AirlineCode.IsNullOrEmpty())
                {
                    dbOperator.AddParameter("AIRLINE", DBNull.Value);
                }
                else
                {
                    dbOperator.AddParameter("AIRLINE", value.AirlineCode.Value);
                }
                dbOperator.AddParameter("DEPARTURE", value.DepartureCode.Value);
                dbOperator.AddParameter("ARRIVAL", value.ArrivalCode.Value);
                dbOperator.AddParameter("FLIGHTDATE", value.FlightDate);
                dbOperator.AddParameter("ETDZDATE", value.ETDZDate);
                dbOperator.AddParameter("PRICE", value.Price);
                dbOperator.AddParameter("MILEAGE", value.Mileage);
                dbOperator.AddParameter("MODIFYTIME", value.ModifyTime);
                return(dbOperator.ExecuteNonQuery(sql));
            }
        }
Esempio n. 8
0
 /// <summary>
 /// 计算折扣
 /// </summary>
 public static decimal CalculateDiscount(decimal standardFare, decimal fare)
 {
     return(BasicPrice.CalcDiscount(standardFare, fare));
 }
Esempio n. 9
0
 /// <summary>
 /// 计算票面价
 /// </summary>
 public static decimal CalculateFare(decimal standardFare, decimal discount)
 {
     return(BasicPrice.CalcFare(standardFare, discount));
 }
Esempio n. 10
0
        private BunkInfo constructBunkView(Bunk bunk, MatchedPolicy policy, BasicPrice price)
        {
            var result = new BunkInfo()
            {
                Policy = new PolicyView()
                {
                    Id               = policy.OriginalPolicy == null ? Guid.Empty : policy.OriginalPolicy.Id,
                    Owner            = policy.Provider,
                    Type             = policy.PolicyType,
                    CustomerResource = false
                }
            };

            result.ShowPrice = policy.ParValue != 0;
            if (policy.PolicyType == PolicyType.Special)
            {
                // 特殊票是单独处理的
                var specialPolicy = policy.OriginalPolicy as DataTransferObject.Policy.SpecialPolicyInfo;
                result.Code        = bunk == null ? string.Empty : bunk.Code;
                result.SeatCount   = bunk == null ? specialPolicy.ResourceAmount : bunk.SeatCount; // 剩余位置数 从政策上获取
                result.Fare        = policy.ParValue.TrimInvaidZero();                             // 票面价从政策上取
                result.Rebate      = string.Empty;                                                 // 无返点
                result.Amount      = policy.SettleAmount;
                result.Description = "特殊票";
                result.BunkType    = bunk == null ? new BunkType?() : bunk.Type;
                switch (specialPolicy.Type)
                {
                case SpecialProductType.Singleness:
                case SpecialProductType.Disperse:
                    result.Policy.CustomerResource = true;
                    break;

                case SpecialProductType.CostFree:
                    result.Policy.CustomerResource = !specialPolicy.SynBlackScreen;
                    result.ShowPrice = true;
                    break;
                }
            }
            else
            {
                result.Code      = bunk.Code;
                result.SeatCount = bunk.SeatCount;
                result.Fare      = policy.ParValue.TrimInvaidZero();
                result.Rebate    = policy.Commission.TrimInvaidZero();
                result.Amount    = policy.SettleAmount;

                if (policy.PolicyType == PolicyType.Bargain && bunk is Service.FlightQuery.Domain.GeneralBunk)
                {
                    result.Description = "特价票";
                }
                else
                {
                    if (bunk is Service.FlightQuery.Domain.FirstOrBusinessBunk)
                    {
                        result.Description = (bunk as Service.FlightQuery.Domain.FirstOrBusinessBunk).Description;
                    }
                    else if (bunk is Service.FlightQuery.Domain.EconomicBunk)
                    {
                        result.Description = "经济舱";
                    }
                    else if (bunk is Service.FlightQuery.Domain.PromotionBunk)
                    {
                        result.Description = (bunk as Service.FlightQuery.Domain.PromotionBunk).Description;
                    }
                    else if (bunk is Service.FlightQuery.Domain.ProductionBunk)
                    {
                        result.Description = "往返产品";
                    }
                    else
                    {
                        result.Description = string.Empty;
                    }
                }
                result.BunkType = bunk.Type;
            }
            if (bunk != null && bunk is Service.FlightQuery.Domain.GeneralBunk)
            {
                result.Discount = ((bunk as Service.FlightQuery.Domain.GeneralBunk).Discount).TrimInvaidZero();
                if (policy.PolicyType == PolicyType.Special)
                {
                    result.RenderDiscount = price != null && policy.ParValue != 0 ? Math.Round(policy.ParValue / price.Price, 2).ToString() : string.Empty;
                }
                else
                {
                    result.RenderDiscount = ((bunk as Service.FlightQuery.Domain.GeneralBunk).Discount).TrimInvaidZero();
                }
            }
            else
            {
                result.RenderDiscount = result.Discount = string.Empty;
            }
            // 退改签规定
            // 普通政策时,获取基础数据中普通舱位的退改签信息
            // 其他情况,获取政策上的退改签信息
            if ((policy.PolicyType == PolicyType.Normal || policy.PolicyType == PolicyType.NormalDefault || policy.PolicyType == PolicyType.OwnerDefault) && bunk is Service.FlightQuery.Domain.GeneralBunk)
            {
                result.EI = GetGeneralBunkRegulation(bunk);
            }
            else
            {
                if (policy.OriginalPolicy is DataTransferObject.Policy.IHasRegulation)
                {
                    var regulation = policy.OriginalPolicy as DataTransferObject.Policy.IHasRegulation;
                    result.EI = GetRegulation(regulation);
                }
                else
                {
                    result.EI = string.Empty;
                }
            }
            result.SuportChild = bunk != null && bunk.SuportChild;
            return(result);
        }
Esempio n. 11
0
 private IEnumerable <BunkInfo> constructBunkView(MatchedBunk matchedBunk, BasicPrice basicPrice)
 {
     return(from policy in matchedBunk.Policies
            where policy != null
            select constructBunkView(matchedBunk.OriginalBunk, policy, basicPrice));
 }