Beispiel #1
0
        /// <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);
        }
        private int AddOrder(FltOrderEntity splitFromOrderEntity, FltOrderUnionEntity splitFromOrderUnionEntity,
                             FltCorpCostCenterEntity splitFromCostCenterEntity, List <FltFlightEntity> splitFromFlightEntities,
                             FltPassengerEntity splitFromPassengerEntity, bool isFirst, string oid)
        {
            FltOrderEntity      fltOrderEntity      = Mapper.Map <FltOrderEntity, FltOrderEntity>(splitFromOrderEntity);
            FltOrderUnionEntity fltOrderUnionEntity =
                Mapper.Map <FltOrderUnionEntity, FltOrderUnionEntity>(splitFromOrderUnionEntity);
            List <FltFlightEntity> fltFlightEntities =
                Mapper.Map <List <FltFlightEntity>, List <FltFlightEntity> >(splitFromFlightEntities);
            FltCorpCostCenterEntity fltCorpCostCenterEntity =
                Mapper.Map <FltCorpCostCenterEntity, FltCorpCostCenterEntity>(splitFromCostCenterEntity);
            FltPassengerEntity fltPassengerEntity =
                Mapper.Map <FltPassengerEntity, FltPassengerEntity>(splitFromPassengerEntity);

            fltOrderEntity.Payamount =
                fltFlightEntities.Sum(n => (n.SalePrice ?? 0) + n.TaxFee + (n.OilFee ?? 0) + (n.ServiceFee ?? 0));

            if (fltPassengerEntity.InsuranceCount.HasValue && fltPassengerEntity.InsuranceCount.Value > 0)
            {
                fltOrderEntity.Payamount = fltOrderEntity.Payamount +
                                           (fltPassengerEntity.InsuranceCount.Value * (fltPassengerEntity.Insurance ?? 0));
            }

            if (!isFirst)
            {
                fltOrderEntity.CreditcardfeeAmount = 0;
                fltOrderEntity.Voucheramount       = 0;
                fltOrderEntity.SendTicketAmount    = 0;
            }

            fltOrderEntity.Totalamount = fltOrderEntity.Payamount + fltOrderEntity.CreditcardfeeAmount;

            if (string.IsNullOrEmpty(fltOrderEntity.Remark))
            {
                fltOrderEntity.Remark = "无";
            }

            fltOrderEntity.ReturnAccountOid  = "";
            fltOrderEntity.ReturnAccountTime = null;
            fltOrderEntity.OutTicketStatus   = "N";
            fltOrderEntity.ProcessStatus     = 1;
            fltOrderEntity.Orderstatus       = "P";
            fltOrderEntity.CreateOid         = oid;

            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;
            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)
            {
                fltFlightEntity.OrderId = fltOrderEntity.OrderId;
                if (string.IsNullOrEmpty(fltFlightEntity.RecordNo))
                {
                    fltFlightEntity.RecordNo = "AAAAAA";
                }
                if (string.IsNullOrEmpty(fltFlightEntity.Airportson))
                {
                    fltFlightEntity.Airportson = "----";
                }
                _fltFlightDal.Insert(fltFlightEntity);
            }

            fltPassengerEntity.OrderId = fltOrderEntity.OrderId;
            if (string.IsNullOrEmpty(fltPassengerEntity.Remark))
            {
                fltPassengerEntity.Remark = "无";
            }
            _fltPassengerDal.Insert(fltPassengerEntity);

            if (fltCorpCostCenterEntity != null)
            {
                fltCorpCostCenterEntity.Orderid = fltOrderEntity.OrderId;
                _fltCorpCostCenterDal.Insert <FltCorpCostCenterEntity>(fltCorpCostCenterEntity);
            }

            FltOrderLogEntity log = new FltOrderLogEntity()
            {
                OrderId = fltOrderEntity.OrderId,
                LogTime = DateTime.Now,
                LogType = "新建订单",
                Remark  = "拆分订单,来源订单号:" + splitFromOrderEntity.OrderId,
                Oid     = fltOrderEntity.CreateOid
            };

            _fltOrderLogDal.Insert(log);

            return(fltOrderEntity.OrderId);
        }
Beispiel #3
0
        public int AddOrder(AddOrderModel fltAddOrderModel)
        {
            string json = JsonConvert.SerializeObject(fltAddOrderModel);

            LogHelper.WriteLog(json, "MojoryApiAddDomesticOrder");

            FltOrderEntity fltOrderEntity = Mapper.Map <AddOrderModel, FltOrderEntity>(fltAddOrderModel);

            fltOrderEntity.OrderDate   = DateTime.Now;
            fltOrderEntity.IsInter     = "N";
            fltOrderEntity.Oid         = fltOrderEntity.CreateOid;
            fltOrderEntity.Orderstatus = "W";

            if (!string.IsNullOrEmpty(fltOrderEntity.CreateOid) && fltOrderEntity.CreateOid.ToLower() != "sys")
            {
                fltOrderEntity.Orderstatus = "P";
            }


            fltOrderEntity.OrderType      = "T";
            fltOrderEntity.IsModandChange = "F";
            fltOrderEntity.IsTA           = "F";

            fltOrderEntity.CorpAduitId  = fltAddOrderModel.CorpAduitId;
            fltOrderEntity.CorpPolicyId = fltAddOrderModel.CorpPolicyId;

            if (string.IsNullOrEmpty(fltOrderEntity.Description))
            {
                fltOrderEntity.Description = ",";
            }
            if (string.IsNullOrEmpty(fltOrderEntity.Remark))
            {
                fltOrderEntity.Remark = "无";
            }
            if (string.IsNullOrEmpty(fltOrderEntity.IsOnLinePay))
            {
                fltOrderEntity.IsOnLinePay = "F";
            }
            if (string.IsNullOrEmpty(fltOrderEntity.SendTicketType))
            {
                fltOrderEntity.SendTicketType = SendTicketTypeEnum.Not.ToString();
            }

            string choiceReason = string.Concat(
                fltAddOrderModel.FlightList.Select(n => string.IsNullOrEmpty(n.ChoiceReason) ? "" : "/" + n.ChoiceReason)
                );

            if (!string.IsNullOrEmpty(choiceReason))
            {
                choiceReason = choiceReason.Substring(1);
            }
            if (!string.IsNullOrEmpty(choiceReason) && !choiceReason.Contains("/"))
            {
                choiceReason = "/" + choiceReason;
            }

            fltOrderEntity.ChoiceReason = choiceReason;
            fltOrderEntity.Totalamount  = fltOrderEntity.Payamount + fltOrderEntity.Voucheramount;//订单总价加上优惠的金额
            fltAddOrderModel.FlightList.ForEach(n =>
            {
                fltOrderEntity.Allport += "-" + n.Dport + n.Aport;//SHAPEK-PEKSHA
            });
            if (!string.IsNullOrEmpty(fltOrderEntity.Allport))
            {
                fltOrderEntity.Allport = fltOrderEntity.Allport.Substring(1);
            }
            fltOrderEntity.OutTicketStatus = "N";

            if (!string.IsNullOrEmpty(fltAddOrderModel.Customer?.CorpID) &&
                fltAddOrderModel.Customer?.CorpID.ToLower() == "mzl")
            {
                fltOrderEntity.BuyRemark       = fltOrderEntity.BuyRemark + "测试订单,请勿出票";
                fltOrderEntity.IsAutoOutTicket = 1;//测试公司下的订单统一转为人工出票,防止自动出票直接出票了
            }

            fltOrderEntity = _fltOrderDal.Insert(fltOrderEntity);



            FltOrderUnionEntity fltOrderUnionEntity = new FltOrderUnionEntity();

            fltOrderUnionEntity.OrderId = fltOrderEntity.OrderId;
            if (string.IsNullOrEmpty(fltOrderUnionEntity.IsMobile))
            {
                fltOrderUnionEntity.IsMobile = "F";
            }
            fltOrderUnionEntity.IsAutoInsurance = "F";
            fltOrderUnionEntity.CorpId          = fltAddOrderModel.Customer != null
                ? fltAddOrderModel.Customer.CorpID
                : string.Empty;

            fltOrderUnionEntity.CorpDepartId = fltAddOrderModel.CorpDepartId;

            string corpPolicy = string.Concat(
                fltAddOrderModel.FlightList.Select(n => string.IsNullOrEmpty(n.CorpPolicy) ? "" : "|" + n.CorpPolicy)
                );

            if (!string.IsNullOrEmpty(corpPolicy))
            {
                corpPolicy = corpPolicy.Substring(1);
            }
            if (!string.IsNullOrEmpty(corpPolicy) && !corpPolicy.Contains("|"))
            {
                corpPolicy = "|" + corpPolicy;
            }

            fltOrderUnionEntity.CorpPolicy = corpPolicy;
            if (!string.IsNullOrEmpty(fltOrderUnionEntity.CorpPolicy))
            {
                if (fltOrderUnionEntity.CorpPolicy.Contains("提前"))
                {
                    fltOrderUnionEntity.IsPolicyT = "T";
                }
                if (fltOrderUnionEntity.CorpPolicy.Contains("折以下的航班"))
                {
                    fltOrderUnionEntity.IsPolicyR = "T";
                }
                if (fltOrderUnionEntity.CorpPolicy.Contains("分钟内最低航班"))
                {
                    fltOrderUnionEntity.IsPolicyL = "T";
                }
            }
            fltOrderUnionEntity.LostAmount  = fltAddOrderModel.FlightList.Sum(n => n.LostAmount);
            fltOrderUnionEntity.ProjectId   = fltAddOrderModel.ProjectId;
            fltOrderUnionEntity.BalanceType = fltAddOrderModel.BalanceType;
            fltOrderUnionEntity.TravelType  = fltAddOrderModel.TravelType;
            _fltOrderUnionDal.Insert(fltOrderUnionEntity);

            List <FltFlightEntity> fltFlightEntities =
                Mapper.Map <List <FltFlightModel>, List <FltFlightEntity> >(fltAddOrderModel.FlightList);

            foreach (var f in fltFlightEntities)
            {
                f.OrderId  = fltOrderEntity.OrderId;
                f.RecordNo = "AAAAAA";//默认编码
                if (string.IsNullOrEmpty(f.Airportson))
                {
                    f.Airportson = "----";
                }
                f.IsInter = fltOrderEntity.IsInter;
                if (f.Class.Length > 1)
                {
                    f.Class = f.Class.Substring(0, 1);
                }
                if (!string.IsNullOrEmpty(f.ChoiceReason) && f.ChoiceReason.Trim().ToLower() == "undefined")
                {
                    f.ChoiceReason = string.Empty;
                }

                if (f.Rate.HasValue && f.Rate.Value > 1)
                {
                    f.Rate = f.Rate / 10;
                }
                if (f.FRate > 1)
                {
                    f.FRate = f.FRate / 10;
                }

                _fltFlightDal.Insert(f);
            }
            List <FltPassengerEntity> fltPassengerEntities =
                Mapper.Map <List <FltPassengerModel>, List <FltPassengerEntity> >(fltAddOrderModel.PassengerList);

            foreach (var p in fltPassengerEntities)
            {
                p.IsAvailable = "T";
                if (string.IsNullOrEmpty(p.Remark))
                {
                    p.Remark = "无";
                }
                p.OrderId = fltOrderEntity.OrderId;
                _fltPassengerDal.Insert(p);
            }

            FltOrderLogEntity log = new FltOrderLogEntity()
            {
                OrderId = fltOrderEntity.OrderId,
                LogTime = DateTime.Now,
                LogType = "新建订单",
                Remark  =
                    "新建订单" + (string.IsNullOrEmpty(fltOrderEntity.BuyRemark) ? "" : "采购备注:" + fltOrderEntity.BuyRemark),
                Oid = "sys"
            };

            _fltOrderLogDal.Insert(log);

            return(fltOrderEntity.OrderId);
        }