Exemple #1
0
        public UserContract(CustomerInfo CustomerInfo, string Name, string IdCard, ContractUserType UserType = ContractUserType.Adult) : base()
        {
            this.Name     = Name;
            this.IdCard   = IdCard;
            this.UserType = UserType;

            this.CustomerInfo = CustomerInfo;
            CustomerInfo?.AddUserContract(this);
        }
Exemple #2
0
        //public UserContract()
        //{
        //}
        public UserContract(string Name, string IdCard, ContractUserType UserType = ContractUserType.Adult)
        {
            Id            = Guid.NewGuid();
            this.Name     = Name;
            this.IdCard   = IdCard;
            this.UserType = UserType;


            AddTime      = DateTimeOffset.Now;
            UpdateTime   = DateTimeOffset.Now;
            AddUserId    = UserHelper.User.Id;
            UpdateUserId = UserHelper.User.Id;
        }
        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);
        }