Beispiel #1
0
 public void RemoveTrainTicketPrice(TrainTicketPrice TrainTicketPrice)
 {
     if (TrainTicketPrices.Where(o => o.StartTrainStation == TrainTicketPrice.StartTrainStation && o.EndTrainStation == TrainTicketPrice.EndTrainStation).Count() == 0)
     {
         throw new Exception("not exsit  TrainTicketPrice");
     }
     TrainTicketPrices.Remove(TrainTicketPrice);
 }
Beispiel #2
0
 public void AddTrainTicketPrice(TrainTicketPrice TrainTicketPrice)
 {
     if (TrainTicketPrices.Where(o => o.StartTrainStation == TrainTicketPrice.StartTrainStation && o.EndTrainStation == TrainTicketPrice.EndTrainStation).Count() > 0)
     {
         throw new Exception("exsit same TrainTicketPrice");
     }
     TrainTicketPrices.Add(TrainTicketPrice);
 }
Beispiel #3
0
        public decimal GetTrainStationWayPrice(TrainStationWay TrainStationWay, SeatTypeConfig SeatType, ContractUserType TicketUserType = ContractUserType.Adult)
        {
            if (TrainStationWay == null)
            {
                throw new ArgumentNullException("TrainStationWay");
            }
            decimal price      = 0;
            decimal decutPrice = 0;


            var list = TrainTicketPrices.Where(o => o.StartTrainStation >= TrainStationWay.StartTrainStation && o.EndTrainStation <= TrainStationWay.EndTrainStation);


            foreach (var item in list)
            {
                var trainSeatPrices = item.TrainSeatPrices.Where(o => o.SeatType == SeatType).FirstOrDefault();
                if (trainSeatPrices == null)
                {
                    throw new Exception($"车次{Code} {item}未配置{SeatType.Name}座位类型");
                }
                price += trainSeatPrices.Price;

                if (TicketUserType == ContractUserType.Children)
                {
                    decutPrice += trainSeatPrices.Price / 2;
                }

                if (TicketUserType == ContractUserType.Student)
                {
                    var defaultTrainSeatPrice = item.TrainSeatPrices.Where(o => o.IsDefault).FirstOrDefault();
                    if (defaultTrainSeatPrice == null)
                    {
                        throw new Exception($"车次{Code} {item}");
                    }
                    decutPrice += defaultTrainSeatPrice.Price;
                }
            }

            price -= decutPrice;

            //待处理学生价格
            return(price);
        }