Пример #1
0
        public TravelAppResponse CreateTrip(BPiaoBao.AppServices.DataContracts.DomesticTicket.TravelAppRequrst req)
        {
            TravelAppResponse response = new TravelAppResponse();

            try
            {
                FlightService flightDestineService = new FlightService(this.m_businessmanRepository, currentUser);
                response = flightDestineService.CreateTrip(req);
                if (response.IsSuc)
                {
                    if (response.PnrAnalysisTripNumber.Trim() != req.TripNumber.Trim())
                    {
                        response.IsSuc = false;
                    }
                    else
                    {
                        if (req.Flag == 0)//如果是正常订单
                        {
                            //更改状态
                            Order       order       = this.orderRepository.FindAll(p => p.OrderId == req.OrderId).FirstOrDefault();
                            TravelPaper travelPaper = this.m_travelPaperRepository.FindAll(p => p.TripNumber == req.TripNumber).FirstOrDefault();
                            if (order != null && travelPaper != null)
                            {
                                order.Passengers.Each(p =>
                                {
                                    if (p.Id == req.PassengerId)
                                    {
                                        p.PassengerTripStatus = EnumPassengerTripStatus.HasCreate;
                                        p.TravelNumber        = req.TripNumber;
                                    }
                                });
                                travelPaper.OrderId      = req.OrderId;
                                travelPaper.PassengerId  = req.PassengerId;
                                travelPaper.TripStatus   = EnumTripStatus.HasCreatedUsed;
                                travelPaper.PrintTime    = System.DateTime.Now;
                                travelPaper.TicketNumber = req.TicketNumber;
                                string strLog = "行程单号:" + response.TripNumber + "票号:" + response.TicketNumber + " Office:" + response.CreateOffice + " " + response.ShowMsg;
                                travelPaper.WriteLog(new TravelPaperLog()
                                {
                                    OperationContent  = strLog,
                                    OperationType     = "创建行程单",
                                    OperationDatetime = System.DateTime.Now,
                                    OperationPerson   = currentUser.OperatorAccount
                                });
                                order.OrderLogs.Add(new OrderLog()
                                {
                                    OperationContent  = strLog,
                                    OperationDatetime = System.DateTime.Now,
                                    OperationPerson   = currentUser.OperatorAccount,
                                    IsShowLog         = true
                                });
                            }
                            unitOfWorkRepository.PersistUpdateOf(order);
                            unitOfWorkRepository.PersistUpdateOf(travelPaper);
                            unitOfWork.Commit();
                        }
                        else//如果是售后订单
                        {
                            //更改状态
                            int            id          = int.Parse(req.OrderId);
                            AfterSaleOrder order       = this.AfterSaleorderRepository.FindAll(p => p.Id == id).FirstOrDefault();
                            TravelPaper    travelPaper = this.m_travelPaperRepository.FindAll(p => p.TripNumber == req.TripNumber).FirstOrDefault();
                            if (order != null && travelPaper != null)
                            {
                                order.Passenger.Each(p =>
                                {
                                    if (p.Id == req.PassengerId)
                                    {
                                        p.PassengerTripStatus      = EnumPassengerTripStatus.HasCreate;
                                        p.AfterSaleTravelNum       = req.TripNumber;
                                        p.AfterSaleTravelTicketNum = req.TicketNumber;
                                    }
                                });
                                travelPaper.OrderId      = req.OrderId;
                                travelPaper.PassengerId  = req.PassengerId;
                                travelPaper.TripStatus   = EnumTripStatus.HasCreatedUsed;
                                travelPaper.PrintTime    = System.DateTime.Now;
                                travelPaper.TicketNumber = req.TicketNumber;
                                string strLog = "改签行程单号:" + response.TripNumber + "改签票号:" + response.TicketNumber + " 改签Office:" + response.CreateOffice + " " + response.ShowMsg;
                                travelPaper.WriteLog(new TravelPaperLog()
                                {
                                    OperationContent  = strLog,
                                    OperationType     = "创建改签行程单",
                                    OperationDatetime = System.DateTime.Now,
                                    OperationPerson   = currentUser.OperatorAccount
                                });
                                order.Order.OrderLogs.Add(new OrderLog()
                                {
                                    OperationContent  = strLog,
                                    OperationDatetime = System.DateTime.Now,
                                    OperationPerson   = currentUser.OperatorAccount,
                                    IsShowLog         = true
                                });
                            }
                            unitOfWorkRepository.PersistUpdateOf(order);
                            unitOfWorkRepository.PersistUpdateOf(travelPaper);
                            unitOfWork.Commit();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new CustomException(111, ex.Message);
            }
            return(response);
        }