Example #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(OrderPassenger model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("INSERT INTO tbl_OrderPassenger( OrderCode, PsrName ,PsrType ,IdentityType, IdentityCard ,Mobile) VALUES ( @OrderCode, @PsrName,@PsrType,@IdentityType, @IdentityCard,@Mobile)");
            DbCommand cmd = this._db.GetSqlStringCommand(strSql.ToString());

            this._db.AddInParameter(cmd, "OrderCode", DbType.String, model.OrderCode);
            this._db.AddInParameter(cmd, "PsrName", DbType.String, model.PsrName);
            this._db.AddInParameter(cmd, "PsrType", DbType.Byte, model.PsrType);
            this._db.AddInParameter(cmd, "IdentityType", DbType.Byte, model.IdentityType);
            this._db.AddInParameter(cmd, "IdentityCard", DbType.String, model.IdentityCard);
            this._db.AddInParameter(cmd, "Mobile", DbType.String, model.Mobile);

            return(DbHelper.ExecuteSql(cmd, this._db));
        }
Example #2
0
        public Order CreateOrder(int dailyRouteId, int startStationId, int destinationStationId, int carId, int passengerId, int minSeat, int maxSeat)
        {
            var dailyRoute = context.DailyRoutes.Find(dailyRouteId);
            var car        = context.Cars.Find(carId);

            //todo: lock -> сохранение заказа с указанным местом

            var seatIndex = GetAvailableSeatNumbers(car).FirstOrDefault(x => x >= minSeat && x <= maxSeat);

            if (seatIndex == 0)
            {
                return(null);
            }

            var orderPassenger = new OrderPassenger
            {
                CarId       = car.CarId,
                Cost        = CalculateCost(dailyRoute, startStationId, destinationStationId, car.CarType),
                PassengerId = passengerId,
                SeatIndex   = seatIndex
            };

            var orderPassengers = new List <OrderPassenger> {
                orderPassenger
            };

            var order = new Order
            {
                UserId                   = Constants.DefaultUserId,
                TrainNumber              = dailyRoute.Route.Train.TrainNumber,
                DailyRouteId             = dailyRoute.DailyRouteId,
                TripStartStationId       = startStationId,
                TripDestinationStationId = destinationStationId,
                TripStartDate            = CalculateArrivalDepartureTime(dailyRoute, startStationId),
                TripDestinationDate      = CalculateArrivalDepartureTime(dailyRoute, destinationStationId),
                OrderDate                = DateTime.Now,
                TotalCost                = orderPassengers.Select(x => x.Cost).Sum(),
                OrderPassengers          = orderPassengers
            };

            context.Orders.Add(order);

            context.SaveChanges();

            return(order);
        }
Example #3
0
        /// <summary>
        /// 订单保存
        /// </summary>
        void SaveOrder()
        {
            string[] insArr = new string[] { };//提交订单成功后需要提交的保险XML

            queryJpModel = Session["HBModel"] != null ? (HBModel)Session["HBModel"] : queryJpModel;
            StringBuilder orderXML  = new StringBuilder();
            decimal       cPrice    = Utils.GetDecimal(Utils.GetFormValue("pPrice"));
            string        classcode = Utils.GetFormValue("classcode");
            decimal       Jpmoney   = Convert.ToDecimal(Utils.GetQueryStringValue("jpmoney"));

            orderXML.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            orderXML.Append("<OrderFlight_1_6>");
            orderXML.Append("<Flights><Flight>");


            orderXML.AppendFormat("<ID>{0}</ID>", "");
            orderXML.AppendFormat("<Type>{0}</Type>", "");
            orderXML.AppendFormat("<TypeCode>{0}</TypeCode>", "");

            orderXML.AppendFormat("<ActionCode>{0}</ActionCode>", "");
            orderXML.AppendFormat("<Farebasis>{0}</Farebasis>", "");
            orderXML.AppendFormat("<Carrier>{0}</Carrier>", queryJpModel.Carrier);
            orderXML.AppendFormat("<FlightNo>{0}</FlightNo>", queryJpModel.FlightNo);
            orderXML.AppendFormat("<ShareCarrier>{0}</ShareCarrier>", "");
            orderXML.AppendFormat("<ShareFlight>{0}</ShareFlight>", "");
            orderXML.AppendFormat("<FromCity>{0}</FromCity>", queryJpModel.BoardPoint);
            orderXML.AppendFormat("<ArriveCity>{0}</ArriveCity>", queryJpModel.OffPoint);
            //orderXML.AppendFormat("<Mileage>{0}</Mileage>", 1178);//测试定义
            orderXML.AppendFormat("<Mileage>{0}</Mileage>", queryJpModel.Mileage);
            //orderXML.AppendFormat("<ClassCode>{0}</ClassCode>", "Y");//测试定义
            orderXML.AppendFormat("<ClassCode>{0}</ClassCode>", classcode);
            orderXML.AppendFormat("<YPrice>{0}</YPrice>", queryJpModel.YPrice);
            //orderXML.AppendFormat("<ClassPrice>{0}</ClassPrice>", 1130);//测试定义
            orderXML.AppendFormat("<ClassPrice>{0}</ClassPrice>", cPrice);
            orderXML.AppendFormat("<BasePrice>{0}</BasePrice>", "");
            orderXML.AppendFormat("<FuelSurTax>{0}</FuelSurTax>", queryJpModel.FuelSurTax);
            orderXML.AppendFormat("<AirportTax>{0}</AirportTax>", queryJpModel.AirportTax);
            orderXML.AppendFormat("<DepartureDate>{0}</DepartureDate>", queryJpModel.DepartureDate.ToString("yyyy-MM-dd"));
            orderXML.AppendFormat("<DepartureTime>{0}</DepartureTime>", queryJpModel.DepartureTime.ToString("HH:mm"));
            orderXML.AppendFormat("<ArrivalDate>{0}</ArrivalDate>", queryJpModel.ArrivalDate.ToString("yyyy-MM-dd"));
            orderXML.AppendFormat("<ArrivalTime>{0}</ArrivalTime>", queryJpModel.ArrivalTime.ToString("HH:mm"));
            orderXML.AppendFormat("<Aircraft>{0}</Aircraft>", queryJpModel.Aircraft);
            orderXML.AppendFormat("<OverstepPriceReason>{0}</OverstepPriceReason>", "");
            orderXML.AppendFormat("<BoardPointAT>{0}</BoardPointAT>", "");
            orderXML.AppendFormat("<OffPointAT>{0}</OffPointAT>", "");
            orderXML.AppendFormat("<MinPrice>{0}</MinPrice>", "");
            orderXML.Append("</Flight>");
            orderXML.Append("</Flights>");

            //获取订单信息
            string[] strNames    = Utils.GetFormValues("ckName");
            string[] strYKLXs    = Utils.GetFormValues("ckYKLX");
            string[] strZJLXs    = Utils.GetFormValues("ckZJLX");
            string[] strCards    = Utils.GetFormValues("ckCard");
            string[] strMobiles  = Utils.GetFormValues("ckMobile");
            string[] strBaoXians = Utils.GetFormValues("ckBaoXian");
            string   jpAdress    = Utils.GetFormValue("jpadress");

            #region 游客信息拼接
            if (strNames != null && strNames.Length > 0)
            {
                orderXML.Append("<Passengers>");
                for (int i = 0; i < strNames.Length; i++)
                {
                    orderXML.Append("<Passenger>");
                    orderXML.AppendFormat("<PsgID>{0}</PsgID>", i + 1);
                    orderXML.AppendFormat("<Name>{0}</Name>", strNames[i]);
                    //orderXML.AppendFormat("<Type>{0}</Type>", 0);
                    orderXML.AppendFormat("<PsgType>{0}</PsgType>", strYKLXs[i]);
                    orderXML.AppendFormat("<IdentityType>{0}</IdentityType>", strZJLXs[i]);
                    orderXML.AppendFormat("<CardType>{0}</CardType>", strZJLXs[i]);
                    orderXML.AppendFormat("<CardNo>{0}</CardNo>", strCards[i]);
                    if (strYKLXs[i] == "ADT")
                    {
                        orderXML.AppendFormat("<BirthDay>{0}</BirthDay>", "2001-10-10");
                    }
                    else if (strYKLXs[i] == "CHD")
                    {
                        orderXML.AppendFormat("<BirthDay>{0}</BirthDay>", "2003-10-10");
                    }
                    else
                    {
                        orderXML.AppendFormat("<BirthDay>{0}</BirthDay>", "2013-10-10");
                    }

                    orderXML.AppendFormat("<CarrierPsgID>{0}</CarrierPsgID>", "");
                    orderXML.AppendFormat("<Country>{0}</Country>", "中国");
                    orderXML.AppendFormat("<MobilePhone>{0}</MobilePhone>", strMobiles[i]);
                    if (strBaoXians.Length <= 0)
                    {
                        orderXML.AppendFormat("<InsueSum>{0}</InsueSum>", 0);
                    }
                    else
                    {
                        //orderXML.AppendFormat("<InsueSum>{0}</InsueSum>", Utils.GetInt(strBaoXians[i]));
                        orderXML.AppendFormat("<InsueSum>{0}</InsueSum>", 1);
                    }

                    orderXML.AppendFormat("<CarrierCard>{0}</CarrierCard>", "");
                    orderXML.AppendFormat("<CardVaildDate>{0}</CardVaildDate>", "");
                    orderXML.Append("</Passenger>");
                }
                orderXML.Append("</Passengers>");
            }
            #endregion

            #region 价格信息拼接
            var           hats = ViewState["hats"] as Dictionary <string, object>;
            List <string> test = new List <string>(hats.Keys);
            if (strNames != null && strNames.Length > 0)
            {
                orderXML.Append("<Prices>");
                for (int i = 0; i < strNames.Length; i++)
                {
                    orderXML.Append("<Price>");
                    orderXML.AppendFormat("<PriceID>{0}</PriceID>", i + 1);
                    orderXML.AppendFormat("<TktOffice>{0}</TktOffice>", "TYN202");
                    orderXML.AppendFormat("<PsgType>{0}</PsgType>", test[i].ToString());
                    orderXML.AppendFormat("<PsgID>{0}</PsgID>", "");
                    orderXML.AppendFormat("<YPrice>{0}</YPrice>", queryJpModel.YPrice);
                    orderXML.AppendFormat("<Fare>{0}</Fare>", hats[test[i]]);
                    orderXML.AppendFormat("<TaxAmount>{0}</TaxAmount>", hats["TaxAmount"]);
                    orderXML.AppendFormat("<FuelSurTax>{0}</FuelSurTax>", hats["FuelSurTax"]);
                    orderXML.AppendFormat("<AirportTax>{0}</AirportTax>", hats["AirportTax"]);
                    orderXML.AppendFormat("<SalePrice>{0}</SalePrice>", hats["SalePrice"]);
                    orderXML.Append("</Price>");
                }
                orderXML.Append("</Prices>");
            }
            #endregion

            orderXML.Append("<OrderInfo>");//订单描述
            orderXML.AppendFormat("<Linker>{0}</Linker>", userInfo.ContactName);
            orderXML.AppendFormat("<Address>{0}</Address>", jpAdress);
            orderXML.AppendFormat("<Telephone>{0}</Telephone>", userInfo.UserName);
            orderXML.AppendFormat("<IsDomc>{0}</IsDomc>", "D");
            orderXML.AppendFormat("<TicketLimitDate>{0}</TicketLimitDate>", DateTime.Now.AddDays(5).ToString("yyyy-MM-dd"));
            orderXML.AppendFormat("<TicketLimitTime>{0}</TicketLimitTime>", DateTime.Now.AddDays(5).ToString("HH:mm"));
            orderXML.AppendFormat("<PayPlatform>{0}</PayPlatform>", 0);
            orderXML.AppendFormat("<BankCode>{0}</BankCode>", 0);
            orderXML.AppendFormat("<NotifyURL>{0}</NotifyURL>", 0);
            orderXML.AppendFormat("<NotifyType>{0}</NotifyType>", 0);
            orderXML.AppendFormat("<Remark>{0}</Remark>", "惠旅游微信端");
            orderXML.AppendFormat("<BalanceMoney>{0}</BalanceMoney>", 1000);
            orderXML.AppendFormat("<TripDays>{0}</TripDays>", 0);
            orderXML.AppendFormat("<CustomerOrderNo>{0}</CustomerOrderNo>", 0);
            orderXML.AppendFormat("<CustomerSettlementDepID>{0}</CustomerSettlementDepID>", 0);
            orderXML.AppendFormat("<CustomerNo>{0}</CustomerNo>", "");
            orderXML.Append("</OrderInfo>");

            orderXML.Append("<LinkerInfo>");//联系信息
            orderXML.AppendFormat("<IsETiket>{0}</IsETiket>", "Y");
            orderXML.AppendFormat("<PayType>{0}</PayType>", "WZ");
            orderXML.AppendFormat("<Address>{0}</Address>", 0);
            orderXML.AppendFormat("<LinkerName>{0}</LinkerName>", userInfo.ContactName);
            orderXML.AppendFormat("<Zip>{0}</Zip>", "410000");
            orderXML.AppendFormat("<Telphone>{0}</Telphone>", userInfo.UserName);
            orderXML.AppendFormat("<MobilePhone>{0}</MobilePhone>", userInfo.UserName);
            orderXML.AppendFormat("<SendTime>{0}</SendTime>", DateTime.Now.AddDays(10));
            orderXML.AppendFormat("<NeedInvoices>{0}</NeedInvoices>", "Y");
            orderXML.AppendFormat("<InvoicesSendType>{0}</InvoicesSendType>", "A");
            orderXML.AppendFormat("<SendTktsTypeCode>{0}</SendTktsTypeCode>", "ZQ");
            orderXML.AppendFormat("<IsPrintSerial>{0}</IsPrintSerial>", "");
            orderXML.AppendFormat("<SendTktDepID>{0}</SendTktDepID>", "");
            orderXML.AppendFormat("<SendTktDepName>{0}</SendTktDepName>", "");
            orderXML.AppendFormat("<LinkerEmail>{0}</LinkerEmail>", "*****@*****.**");

            orderXML.Append("</LinkerInfo>");

            orderXML.Append("<InsuranceInfo>");//保险信息
            orderXML.AppendFormat("<InsuranceId>{0}</InsuranceId>", "CESHI");
            orderXML.AppendFormat("<ShouldGath>{0}</ShouldGath>", 100);
            orderXML.AppendFormat("<ShouldPay>{0}</ShouldPay>", 10);
            orderXML.AppendFormat("<RetMoney>{0}</RetMoney>", 10);
            orderXML.AppendFormat("<Gain>{0}</Gain>", 10);
            orderXML.AppendFormat("<InsuranceCount>{0}</InsuranceCount>", 10);
            orderXML.AppendFormat("<InsuranceSummary>{0}</InsuranceSummary>", 10);
            orderXML.Append("</InsuranceInfo>");


            orderXML.Append("</OrderFlight_1_6>");

            var list = new com._8222666.fxb2b.Service().XmlSubmit(getIdentityXMLString(), orderXML.ToString(), "");

            XmlDocument dom = new XmlDocument();
            dom.LoadXml(list);
            if (dom.SelectSingleNode("ErrorInfo_1_0") != null && !string.IsNullOrEmpty(dom.SelectSingleNode("ErrorInfo_1_0").InnerText))
            {
                Utils.RCWE(UtilsCommons.AjaxReturnJson("0", "下单失败"));
                return;
            }


            Eyousoft_yhq.BLL.BJiPiaoBaoCun BaoSevice = new Eyousoft_yhq.BLL.BJiPiaoBaoCun();
            XmlNodeList nodes = dom.SelectNodes("OrderFlight_1_6");

            for (int i = 0; i < nodes.Count; i++)
            {
                MJiPiaoBaoCun jOrder = new MJiPiaoBaoCun();
                jOrder.OpeatorName = userInfo.ContactName;
                jOrder.OpeatorID   = userInfo.UserID;
                jOrder.OrderCode   = nodes[i].SelectSingleNode("SubsOrderNo").InnerText;
                jOrder.ModifyTag   = nodes[i].SelectSingleNode("ModifyTag").InnerText;
                DateTime Jtime;
                bool     bt = DateTime.TryParse(nodes[i].SelectSingleNode("TicketLimitDt").InnerText + " " + nodes[i].SelectSingleNode("TicketLimitDt").InnerText, out Jtime);
                jOrder.IssueTime = bt ? Jtime : DateTime.Now;
                jOrder.JpAdress  = jpAdress;
                //jOrder.OrderPrice = Convert.ToDecimal(nodes[i].SelectSingleNode("BalanceMoney").InnerText);
                jOrder.OrderPrice = Jpmoney;
                jOrder.WeiDianId  = WeiDianId;
                // jOrder.ModifyTag=
                if (BaoSevice.Add(jOrder))
                {
                    //保存订单联系人信息
                    List <OrderPassenger>     plist = new List <OrderPassenger>();
                    Eyousoft_yhq.BLL.Bpersner bll   = new Eyousoft_yhq.BLL.Bpersner();

                    if (strNames != null && strNames.Length > 0)
                    {
                        //string ordercode = nodes[j].SelectSingleNode("SubsOrderNo").InnerText;
                        try
                        {
                            for (int j = 0; j < strNames.Length; j++)
                            {
                                //FormValues("ckName");
                                //string[] strYKLXs = Utils.GetFormValues("ckYKLX");
                                //string[] strZJLXs = Utils.GetFormValues("ckZJLX");
                                //string[] strCards = Utils.GetFormValues("ckCard");
                                //string[] strMobiles = Utils.GetFormValues("ckMobile");
                                //string[] strBaoXians = Utils.GetFormValues("ckBaoXian");

                                var pasner = new OrderPassenger();
                                pasner.PsrName      = strNames[j];
                                pasner.IdentityType = (Eyousoft_yhq.Model.CartType)getXBySF(strZJLXs[j]);
                                pasner.IdentityCard = strCards[j];
                                pasner.PsrType      = (Eyousoft_yhq.Model.PerType)getXBySF(strYKLXs[j]);
                                pasner.Mobile       = strMobiles[j];
                                pasner.OrderCode    = nodes[i].SelectSingleNode("SubsOrderNo").InnerText;
                                bll.Add(pasner);
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }


                    Utils.RCWE(UtilsCommons.AjaxReturnJson("1", "下单成功"));
                }
                else
                {
                    Utils.RCWE(UtilsCommons.AjaxReturnJson("0", "下单失败"));
                }
            }
        }
Example #4
0
 public int Add(OrderPassenger model)
 {
     return(dal.Add(model));
 }