public TraOrderCancelResponseModel RequestCancelOrder(int orderId) { TraInterFaceOrderEntity traInterFaceOrderEntity = _traInterFaceOrderDal.Query <TraInterFaceOrderEntity>(n => n.OrderId == orderId.ToString()) .FirstOrDefault(); if (traInterFaceOrderEntity == null) { return(null); } int status = traInterFaceOrderEntity.Status; if (status == (int)OrderTypeEnum.OrderCancel) { return(null); } TraOrderCancelResponseModel responseModel = null; string isServer = AppSettingsHelper.GetAppSettings(AppSettingsEnum.IsServer); if (isServer == "T") { responseModel = _requestCancelOrderBll.RequestCancelOrder(new TraOrderCancelModel() { orderid = orderId.ToString(), transactionid = traInterFaceOrderEntity.Transactionid }); } else { responseModel = new TraOrderCancelResponseModel() { success = true }; } if (responseModel.success) { traInterFaceOrderEntity.Status = (int)OrderTypeEnum.OrderCancel; _traInterFaceOrderDal.Update <TraInterFaceOrderEntity>(traInterFaceOrderEntity, new[] { "Status" }); _traOrderOperateDal.Insert <TraOrderOperateEntity>(new TraOrderOperateEntity() { AfterOperateStatus = (int)OrderTypeEnum.OrderCancel, InterfaceId = traInterFaceOrderEntity.InterfaceId, Operate = (int)OrderTypeEnum.OrderCancel, OperateTime = traInterFaceOrderEntity.CreateTime, BeforOperateStatus = status }); } return(responseModel); }
public TraOrderConfirmResponseModel RequestPrintTicket(int orderId) { TraInterFaceOrderEntity traInterFaceOrderEntity = _traInterFaceOrderDal.Query <TraInterFaceOrderEntity>(n => n.OrderId == orderId.ToString()) .FirstOrDefault(); if (traInterFaceOrderEntity == null) { return(null); } int status = traInterFaceOrderEntity.Status; if (traInterFaceOrderEntity.CreateTime.AddMinutes(30) < DateTime.Now) { return(new TraOrderConfirmResponseModel() { success = false, msg = "该订单已经超过出票时间范围" }); } if (status == (int)OrderTypeEnum.MakingTicket) { return(new TraOrderConfirmResponseModel() { success = false, msg = "该订单已经发起出票请求了" }); } if (status == (int)OrderTypeEnum.TicketSuccess) { return(new TraOrderConfirmResponseModel() { success = false, msg = "该订单已经出票了" }); } if (status == (int)OrderTypeEnum.OrderCancel) { return(new TraOrderConfirmResponseModel() { success = false, msg = "该订单已经取消了" }); } string isServer = AppSettingsHelper.GetAppSettings(AppSettingsEnum.IsServer); TraOrderConfirmResponseModel responseModel = null; if (isServer == "T") { responseModel = _requestPrintTicketBll.RequestPrintTicket(new TraOrderConfirmModel() { orderid = orderId.ToString(), transactionid = traInterFaceOrderEntity.Transactionid }); } else { responseModel = new TraOrderConfirmResponseModel() { success = true, ordernumber = "ETest" + DateTime.Now.ToString("yyyyMMdd") + new Random().Next(1000) }; } if (responseModel.success) { traInterFaceOrderEntity.Status = (int)OrderTypeEnum.MakingTicket; traInterFaceOrderEntity.OrderNumber = responseModel.ordernumber; _traInterFaceOrderDal.Update <TraInterFaceOrderEntity>(traInterFaceOrderEntity, new[] { "Status", "OrderNumber" }); _traOrderOperateDal.Insert <TraOrderOperateEntity>(new TraOrderOperateEntity() { AfterOperateStatus = (int)OrderTypeEnum.TicketSuccess, InterfaceId = traInterFaceOrderEntity.InterfaceId, Operate = (int)OrderTypeEnum.MakingTicket, OperateTime = traInterFaceOrderEntity.CreateTime, BeforOperateStatus = status }); } return(responseModel); }
public TraOrderSubmitResponseModel RequestHoldSeat(TraAddOrderModel addModel) { TraOrderSubmitResponseModel responseModel = null; string isServer = AppSettingsHelper.GetAppSettings(AppSettingsEnum.IsServer); if (isServer == "T") { //请求接口 #region 封装接口请求参数 TraOrderSubmitModel model = new TraOrderSubmitModel() { orderid = addModel.Order.OrderId.ToString(), checi = addModel.OrderDetailList[0].TrainNo, from_station_code = addModel.OrderDetailList[0].StartCode, from_station_name = addModel.OrderDetailList[0].StartName, to_station_code = addModel.OrderDetailList[0].EndCode, to_station_name = addModel.OrderDetailList[0].EndName, train_date = addModel.OrderDetailList[0].StartTime.ToString("yyyy-MM-dd"), passengers = new List <TraOrderSubmitPassengerModel>(), LoginUserName = "", LoginUserPassword = "", is_accept_standing = addModel.IsAcceptStanding, is_choose_seats = addModel.IsChooseSeats, choose_seats = addModel.ChooseSeats }; model.passengers = new List <TraOrderSubmitPassengerModel>(); foreach (var p in addModel.OrderDetailList[0].PassengerList) { TraOrderSubmitPassengerModel pp = new TraOrderSubmitPassengerModel(); pp.passengersename = p.Name.Replace("/", " "); pp.passportseno = p.CardNo; pp.passporttypeseidname = p.CardNoType.ToDescription(); if (p.CardNoType == CardTypeEnum.Certificate) { pp.passporttypeseid = "1"; } else if (p.CardNoType == CardTypeEnum.HongKongAndMacaoPass) { pp.passporttypeseid = "C"; } else if (p.CardNoType == CardTypeEnum.Passport) { pp.passporttypeseid = "B"; } else if (p.CardNoType == CardTypeEnum.TaiwanEntryPermit || p.CardNoType == CardTypeEnum.MTP) { pp.passporttypeseid = "G"; pp.passporttypeseidname = "台湾通行证"; } //pp.passporttypeseid = ((int) p.CardNoType).ToString(); pp.piaotype = "1"; pp.ticket_no = ""; pp.piaotypename = "成人票"; if (addModel.OrderDetailList[0].PlaceGrade != "无座") { pp.zwcode = TrainTypeEnum.GetTypeCodeByName(addModel.OrderDetailList[0].PlaceGrade); pp.zwname = addModel.OrderDetailList[0].PlaceGrade; } else { //如果当前是无座则根据当前车次选择最低座位 List <string> cTypeList = new List <string>() { "G", "C", "D" }; if (!string.IsNullOrEmpty(model.checi) && model.checi.Length > 0 && cTypeList.Contains(model.checi.Substring(0, 1).ToUpper())) { pp.zwcode = TrainTypeEnum.GetTypeCodeByName("二等座"); pp.zwname = "二等座"; } else { pp.zwcode = TrainTypeEnum.GetTypeCodeByName("硬座"); pp.zwname = "硬座"; } } pp.cxin = ""; pp.price = addModel.OrderDetailList[0].FacePrice.ToString("0.00"); model.passengers.Add(pp); } #endregion responseModel = _requestHoldSeatBll.RequestHoldSeatInterface(model); } else { responseModel = new TraOrderSubmitResponseModel() { success = true, orderid = "Test" + DateTime.Now.ToString("yyyyMMddHHmmssfff") }; } #region 请求成功后操作 if (responseModel.success)//请求占位成功 { int count = _traInterFaceOrderDal.Query <TraInterFaceOrderEntity>(a => a.Transactionid == responseModel.orderid, true).Count(); if (count == 0)//如果没有当前接口的订单号,则插入该条信息 { TraInterFaceOrderEntity traInterFaceOrderEntity = new TraInterFaceOrderEntity { CreateTime = DateTime.Now, OrderId = addModel.Order.OrderId.ToString(), Status = (int)OrderTypeEnum.ApplyHoldSeat, Transactionid = responseModel.orderid }; traInterFaceOrderEntity = _traInterFaceOrderDal.Insert <TraInterFaceOrderEntity>(traInterFaceOrderEntity); _traOrderOperateDal.Insert <TraOrderOperateEntity>(new TraOrderOperateEntity() { AfterOperateStatus = (int)OrderTypeEnum.MakingTicket, InterfaceId = traInterFaceOrderEntity.InterfaceId, Operate = (int)OrderTypeEnum.ApplyHoldSeat, OperateTime = traInterFaceOrderEntity.CreateTime }); } } #endregion return(responseModel); }