/// <summary> /// 复制国内机票订单 /// </summary> /// <param name="request"></param> /// <returns></returns> public CopyFltDomesticOrderResponseViewModel CopyFltDomesticOrder(CopyFltDomesticOrderRequestViewModel request) { if (request.CopyFromOrderId == 0) { throw new Exception("请传入复制来源订单号"); } //1.获取原始订单详情 //2.新增新订单(订单主体信息,行程信息,乘机人信息,保险信息,票号信息,审批信息),并关联原始订单号 //3.如果是虚退复制,则将原订单设置线上隐藏 CopyFltOrderModel copyFltOrderModel = Mapper.Map <CopyFltDomesticOrderRequestViewModel, CopyFltOrderModel>(request); int orderid = 0; using (var transaction = this.Context.Database.BeginTransaction()) { try { orderid = _copyFltDomesticOrderServiceBll.CopyOrder(copyFltOrderModel); _corpAduitOrderServiceBll.Copy(copyFltOrderModel.CopyFromOrderId, orderid); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw; } } return(new CopyFltDomesticOrderResponseViewModel() { OrderId = orderid }); }
/// <summary> /// 复制差旅订单 /// </summary> /// <param name="copyFltOrderModel"></param> /// <returns></returns> public int CopyOrder(CopyFltOrderModel copyFltOrderModel) { FltOrderEntity copyFromOrderEntity = _fltOrderDal.Find <FltOrderEntity>(copyFltOrderModel.CopyFromOrderId); if (copyFromOrderEntity == null) { throw new Exception("复制来源订单异常"); } List <FltFlightEntity> copyFromFlightEntities = _fltFlightDal.Query <FltFlightEntity>(n => n.OrderId == copyFltOrderModel.CopyFromOrderId, true).ToList(); List <FltPassengerEntity> copyFromPassengerEntities = _fltPassengerDal.Query <FltPassengerEntity>(n => n.OrderId == copyFltOrderModel.CopyFromOrderId, true) .ToList(); List <FltTicketNoEntity> copyFromTicketNoEntities = _fltTicketNoDal.Query <FltTicketNoEntity>(n => n.OrderId == copyFltOrderModel.CopyFromOrderId, true) .ToList(); FltOrderUnionEntity copyFromOrderUnionEntity = _fltOrderUnionDal.Find <FltOrderUnionEntity>(copyFltOrderModel.CopyFromOrderId); FltCorpCostCenterEntity copyFromCostCenterEntity = _fltCorpCostCenterDal.Find <FltCorpCostCenterEntity>(copyFltOrderModel.CopyFromOrderId); FltOrderEntity fltOrderEntity = Mapper.Map <FltOrderEntity, FltOrderEntity>(copyFromOrderEntity); FltOrderUnionEntity fltOrderUnionEntity = Mapper.Map <FltOrderUnionEntity, FltOrderUnionEntity>(copyFromOrderUnionEntity); FltCorpCostCenterEntity fltCorpCostCenterEntity = Mapper.Map <FltCorpCostCenterEntity, FltCorpCostCenterEntity>(copyFromCostCenterEntity); List <FltFlightEntity> fltFlightEntities = Mapper.Map <List <FltFlightEntity>, List <FltFlightEntity> >(copyFromFlightEntities); List <FltPassengerEntity> fltPassengerEntities = Mapper.Map <List <FltPassengerEntity>, List <FltPassengerEntity> >(copyFromPassengerEntities); List <FltTicketNoEntity> fltTicketNoEntities = Mapper.Map <List <FltTicketNoEntity>, List <FltTicketNoEntity> >(copyFromTicketNoEntities); fltOrderEntity.Payamount = copyFltOrderModel.PayAmount; fltOrderEntity.CreditcardfeeAmount = copyFltOrderModel.CreditCardfeeamount; fltOrderEntity.Voucheramount = copyFltOrderModel.Voucheramount; fltOrderEntity.SendTicketAmount = copyFltOrderModel.SendTicketamount; fltOrderEntity.Totalamount = fltOrderEntity.Payamount + fltOrderEntity.CreditcardfeeAmount; fltOrderEntity.CreateOid = copyFltOrderModel.CreateOid; if (string.IsNullOrEmpty(fltOrderEntity.Remark)) { fltOrderEntity.Remark = "无"; } fltOrderEntity.ReturnAccountOid = ""; fltOrderEntity.ReturnAccountTime = null; fltOrderEntity.OutTicketStatus = "N"; fltOrderEntity.ProcessStatus = 1; fltOrderEntity.Orderstatus = "P"; if (string.IsNullOrEmpty(fltOrderEntity.Description)) { fltOrderEntity.Description = ","; } if (string.IsNullOrEmpty(fltOrderEntity.IsOnLinePay)) { fltOrderEntity.IsOnLinePay = "F"; } if (string.IsNullOrEmpty(fltOrderEntity.SendTicketType)) { fltOrderEntity.SendTicketType = SendTicketTypeEnum.Not.ToString(); } fltOrderEntity.RealAcceptDatetime = null; fltOrderEntity.RealPayDatetime = null; fltOrderEntity.Collectiontime = null; fltOrderEntity.CollectionOid = string.Empty; fltOrderEntity.PrintTicketOid = null; fltOrderEntity.PrintTicketTime = null; fltOrderEntity.PrintOrderTime = null; if (copyFltOrderModel.CopyType == "X")//虚出复制 { //判断当前原始订单是否有虚退 int xuTuiCount = _fltRetModApplyDal.Query <FltRetModApplyEntity>( n => n.OrderType.ToUpper() == "R" && n.OrderId == copyFltOrderModel.CopyFromOrderId && n.OrderStatus.ToUpper() != "C" && n.RefundType == "虚退").Count(); if (xuTuiCount == 0) { throw new Exception("当前订单不存在虚退,不允许虚退复制"); } fltOrderEntity.OrderDate = copyFromOrderEntity.OrderDate; fltOrderEntity.CopyType = "X"; //如果当前原始订单不是虚退复制的订单 if (string.IsNullOrEmpty(copyFromOrderEntity.CopyType)) { fltOrderEntity.CopyFromOrderId = copyFltOrderModel.CopyFromOrderId; } else { if (copyFromOrderEntity.CopyType == "X" && copyFromOrderEntity.CopyFromOrderId.HasValue) { fltOrderEntity.CopyFromOrderId = copyFromOrderEntity.CopyFromOrderId; } else { fltOrderEntity.CopyFromOrderId = copyFltOrderModel.CopyFromOrderId; } } } else { fltOrderEntity.CopyType = "C"; fltOrderEntity.CopyFromOrderId = copyFltOrderModel.CopyFromOrderId; fltOrderEntity.OrderDate = DateTime.Now; } fltOrderEntity = _fltOrderDal.Insert(fltOrderEntity); if (fltOrderUnionEntity != null) { fltOrderUnionEntity.OrderId = fltOrderEntity.OrderId; fltOrderUnionEntity.FivePrintId = null; fltOrderUnionEntity.FivePrintLastTime = null; fltOrderUnionEntity.IsNeedPrintTime = null; if (string.IsNullOrEmpty(fltOrderUnionEntity.IsMobile)) { fltOrderUnionEntity.IsMobile = "F"; } _fltOrderUnionDal.Insert(fltOrderUnionEntity); } foreach (var fltFlightEntity in fltFlightEntities) { CopyFltFlightModel copyFltFlightModel = copyFltOrderModel.FlightList.Find(n => n.Sequence == fltFlightEntity.Sequence); if (string.IsNullOrEmpty(fltFlightEntity.RecordNo)) { fltFlightEntity.RecordNo = "AAAAAA"; } fltFlightEntity.OrderId = fltOrderEntity.OrderId; fltFlightEntity.Sequence = copyFltFlightModel.Sequence; fltFlightEntity.OilFee = copyFltFlightModel.OilFee; fltFlightEntity.Rate = copyFltFlightModel.Rate; fltFlightEntity.SalePrice = copyFltFlightModel.SalePrice; fltFlightEntity.TaxFee = copyFltFlightModel.TaxFee; if (string.IsNullOrEmpty(fltFlightEntity.Airportson)) { fltFlightEntity.Airportson = "----"; } _fltFlightDal.Insert(fltFlightEntity); } foreach (var fltPassengerEntity in fltPassengerEntities) { fltPassengerEntity.OrderId = fltOrderEntity.OrderId; if (string.IsNullOrEmpty(fltPassengerEntity.Remark)) { fltPassengerEntity.Remark = "无"; } _fltPassengerDal.Insert(fltPassengerEntity); } if (fltTicketNoEntities != null && fltTicketNoEntities.Count > 0) { foreach (var fltTicketNoEntity in fltTicketNoEntities) { fltTicketNoEntity.OrderId = fltOrderEntity.OrderId; _fltTicketNoDal.Insert(fltTicketNoEntity); } } if (fltCorpCostCenterEntity != null) { fltCorpCostCenterEntity.Orderid = fltOrderEntity.OrderId; _fltCorpCostCenterDal.Insert <FltCorpCostCenterEntity>(fltCorpCostCenterEntity); } FltOrderLogEntity log = new FltOrderLogEntity() { OrderId = fltOrderEntity.OrderId, LogTime = DateTime.Now, LogType = "新建订单", Remark = "复制订单,来源订单号:" + copyFltOrderModel.CopyFromOrderId + ",马甲订单号:" + fltOrderEntity.CopyFromOrderId, Oid = fltOrderEntity.CreateOid }; _fltOrderLogDal.Insert(log); //将原始订单设置为线上隐藏 if (copyFltOrderModel.CopyType == "X") { copyFromOrderEntity.IsOnlineShow = 1; _fltOrderDal.Update(copyFromOrderEntity, new string[] { "IsOnlineShow" }); } return(fltOrderEntity.OrderId); }