Exemplo n.º 1
0
        public AuditResultModel RunAudit(AuditFltOrderQueryModel query)
        {
            FltOrderEntity orderEntity = _fltOrderDal.Find <FltOrderEntity>(query.Id);
            FltOrderModel  orderModel  = Mapper.Map <FltOrderEntity, FltOrderModel>(orderEntity);

            if (orderModel == null)
            {
                throw new MojoryException(MojoryApiResponseCode.NoFindOrder);
            }
            query.FltOrder = orderModel;
            //进行验证
            _validataAuditInfoBll.Validata(query);


            //进行审批
            AuditResultModel code    = new AuditResultModel();
            IRunAuditVisitor visitor = new RunAuditVisitor(_fltOrderDal, _fltOrderLogDal, query);

            if (query.AuditStep == FltOrderCheckStatusEnum.T.ToString())//待一级审批
            {
                AuditOrderAbstract auditOrderFirst = new AuditOrderFirst();
                code = auditOrderFirst.RunAudit(visitor);
            }
            else if (query.AuditStep == FltOrderCheckStatusEnum.S.ToString())//待二级审批
            {
                AuditOrderAbstract auditOrderSecond = new AuditOrderSecond();
                code = auditOrderSecond.RunAudit(visitor);
            }

            return(code);
        }
Exemplo n.º 2
0
 private string SendEmail(FltOrderEntity fltOrderEntity)
 {
     return(null);
     //string url = AppSettingsHelper.GetAppSettings(AppSettingsEnum.FltOrderSecondAuditEmail);
     //url = string.Format("{0}&odid={1}&Oid={2}", url, fltOrderEntity.OrderId, fltOrderEntity.CreateOid);
     //return GetHelper.GetUrl(url);
 }
Exemplo n.º 3
0
        /// <summary>
        /// 按照乘机人拆分订单
        /// </summary>
        /// <returns></returns>
        public List <int> SplitFltOrderByPassenger(int orderId, string oid)
        {
            #region 源数据
            FltOrderEntity splitFromOrderEntity = _fltOrderDal.Find <FltOrderEntity>(orderId);
            if (splitFromOrderEntity == null)
            {
                throw new Exception("未找到源订单");
            }
            List <FltFlightEntity> splitFromFlightEntities =
                _fltFlightDal.Query <FltFlightEntity>(n => n.OrderId == orderId, true).ToList();
            List <FltPassengerEntity> splitFromPassengerEntities =
                _fltPassengerDal.Query <FltPassengerEntity>(n => n.OrderId == orderId, true)
                .ToList();
            if (splitFromPassengerEntities.Count == 1)
            {
                throw new Exception("只有一个乘机人不能拆单");
            }

            FltOrderUnionEntity     splitFromOrderUnionEntity = _fltOrderUnionDal.Find <FltOrderUnionEntity>(orderId);
            FltCorpCostCenterEntity splitFromCostCenterEntity =
                _fltCorpCostCenterDal.Find <FltCorpCostCenterEntity>(orderId);
            #endregion

            List <int> orderIdList = new List <int>();

            for (int i = 0; i < splitFromPassengerEntities.Count; i++)
            {
                int id = AddOrder(splitFromOrderEntity, splitFromOrderUnionEntity, splitFromCostCenterEntity,
                                  splitFromFlightEntities,
                                  splitFromPassengerEntities[i], (i == 0), oid);
                orderIdList.Add(id);
            }

            return(orderIdList);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 判断当前审批单中的单据是否被取消
        /// </summary>
        private bool CheckOrderIsCancel(CorpAduitOrderEntity corpAduitOrderEntity)
        {
            bool isCancel = false;

            List <CorpAduitOrderDetailEntity> corpAduitOrderDetailEntities =
                _corpAduitOrderDetailDal.Query <CorpAduitOrderDetailEntity>(n => n.AduitOrderId == corpAduitOrderEntity.AduitOrderId,
                                                                            true).ToList();
            List <BaseDealAduitResultDetailModel> list = new List <BaseDealAduitResultDetailModel>();

            corpAduitOrderDetailEntities.ForEach(n =>
            {
                list.Add(new BaseDealAduitResultDetailModel()
                {
                    OrderId         = n.OrderId,
                    OrderSourceType = n.OrderType.ValueToEnum <OrderSourceTypeEnum>()
                });
            });

            foreach (BaseDealAduitResultDetailModel orderModel in list)
            {
                if (orderModel.OrderSourceType == OrderSourceTypeEnum.Flt)
                {
                    FltOrderEntity orderEntity =
                        base.Context.Set <FltOrderEntity>().Find(orderModel.OrderId);
                    if (orderEntity?.Orderstatus == "C" || orderEntity?.Orderstatus == "c")
                    {
                        isCancel = true;
                    }
                }
                else if (orderModel.OrderSourceType == OrderSourceTypeEnum.FltModApply ||
                         orderModel.OrderSourceType == OrderSourceTypeEnum.FltRetApply)
                {
                    FltRetModApplyEntity flightApplyEntity = base.Context.Set <FltRetModApplyEntity>().Find(orderModel.OrderId);
                    if (flightApplyEntity?.OrderStatus == "C" || flightApplyEntity?.OrderStatus == "c")
                    {
                        isCancel = true;
                    }
                }
                else if (orderModel.OrderSourceType == OrderSourceTypeEnum.Tra)
                {
                    TraOrderStatusEntity orderStatusEntity =
                        base.Context.Set <TraOrderStatusEntity>().FirstOrDefault(n => n.OrderId == orderModel.OrderId);
                    if (orderStatusEntity?.IsCancle == 1)
                    {
                        isCancel = true;
                    }
                }
            }

            if (isCancel)
            {
                corpAduitOrderEntity.IsDel = 1;
                _corpAduitOrderDal.Update <CorpAduitOrderEntity>(corpAduitOrderEntity, new string[] { "IsDel" });
                return(false);
            }

            return(true);
        }
 /// <summary>
 /// 获取机票出票推送内容
 /// </summary>
 /// <returns></returns>
 private void GetFltPrintTicketMessage(SendAppMessageModel sendAppMessageModel)
 {
     if (sendAppMessageModel.OrderType == OrderSourceTypeEnum.Flt &&
         sendAppMessageModel.SendType == SendAppMessageTypeEnum.PrintTicketNotice)
     {
         FltOrderEntity fltOrderEntity = _fltOrderDal.Find <FltOrderEntity>(sendAppMessageModel.OrderId);
         sendAppMessageModel.SendContent = string.Format("您的机票订单{0}已经出票,请确认", fltOrderEntity.OrderId);
     }
 }
 /// <summary>
 /// 机票待审批通知
 /// </summary>
 /// <param name="sendAppMessageModel"></param>
 private void GetFltWaitAuditMessage(SendAppMessageModel sendAppMessageModel)
 {
     if (sendAppMessageModel.OrderType == OrderSourceTypeEnum.Flt &&
         sendAppMessageModel.SendType == SendAppMessageTypeEnum.WaitAuditNotice)
     {
         FltOrderEntity fltOrderEntity = _fltOrderDal.Find <FltOrderEntity>(sendAppMessageModel.OrderId);
         sendAppMessageModel.SendContent = string.Format("机票订单{0}需要您进行审批", fltOrderEntity.OrderId);
     }
 }
Exemplo n.º 7
0
        public int AddRetModApply(AddRetModApplyModel addRetModApplyModel)
        {
            FltOrderEntity       fltOrderEntity = _fltOrderDal.Find <FltOrderEntity>(addRetModApplyModel.OrderId);
            FltRetModApplyEntity applyEntity    = Mapper.Map <AddRetModApplyModel, FltRetModApplyEntity>(addRetModApplyModel);

            applyEntity.CorpPolicyId = fltOrderEntity.CorpPolicyId;
            applyEntity.CorpAduitId  = fltOrderEntity.CorpAduitId;


            if (!applyEntity.ProcessStatus.HasValue)
            {
                applyEntity.ProcessStatus = 0;
            }
            if (string.IsNullOrEmpty(applyEntity.RefundType))
            {
                applyEntity.RefundType = "实退";
            }
            applyEntity = _fltRetModApplyDal.Insert(applyEntity);

            List <FltRetModFlightApplyEntity> flightApplyEntities =
                Mapper.Map <List <FltRetModFlightApplyModel>, List <FltRetModFlightApplyEntity> >(addRetModApplyModel.DetailList);

            foreach (var fltRetModFlightApplyEntity in flightApplyEntities)
            {
                fltRetModFlightApplyEntity.Rmid        = applyEntity.Rmid;
                fltRetModFlightApplyEntity.OrderStatus = applyEntity.OrderStatus;
                if (string.IsNullOrEmpty(fltRetModFlightApplyEntity.FlightNo))
                {
                    FltFlightEntity flightEntity = _fltFlightDal.Query <FltFlightEntity>(
                        n => n.OrderId == applyEntity.OrderId && n.Sequence == fltRetModFlightApplyEntity.Sequence, true)
                                                   .FirstOrDefault();
                    if (flightEntity != null)
                    {
                        fltRetModFlightApplyEntity.FlightNo = flightEntity.FlightNo;
                    }
                }
                _fltRetModFlightApplyDal.Insert(fltRetModFlightApplyEntity);
            }
            string orderType            = (addRetModApplyModel.OrderType == "R" ? "退票" : "改签");
            FltRetModApplyLogEntity log = new FltRetModApplyLogEntity()
            {
                Rmid    = applyEntity.Rmid,
                Oid     = applyEntity.CreateOid,
                LogTime = DateTime.Now,
                Remark  = addRetModApplyModel.Oid + "新增" + orderType + "申请",
                LogType = "新增"
            };

            _fltRetModApplyLogDal.Insert(log);

            return(applyEntity.Rmid);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 二级审核
        /// </summary>
        /// <param name="secondAudit"></param>
        /// <returns></returns>
        public AuditResultModel DoSecondAudit(AuditOrderSecond secondAudit)
        {
            FltOrderEntity    fltOrderEntity = _fltOrderDal.Find <FltOrderEntity>(_query.Id);
            FltOrderLogEntity log            = new FltOrderLogEntity()
            {
                OrderId = fltOrderEntity.OrderId,
                LogTime = DateTime.Now,
                LogType = "审批订单"
            };

            #region 审批操作
            List <string> properties = new List <string>();
            if (IsAgree)
            {
                //1.通过审批
                fltOrderEntity.CheckStatus = FltOrderCheckStatusEnum.W.ToString();
                log.Remark = "订单审核状态:二级审核通过。二级审核人:" + _query.AuditCustomer?.RealName;
                properties.Add("CheckStatus");
            }
            else
            {
                if ((fltOrderEntity.ProcessStatus & 8) == 8)
                {
                    throw new Exception("该订单已经出票,不能否决,请联系客服");
                }
                //2.否决审批
                fltOrderEntity.CheckStatus = FltOrderCheckStatusEnum.J.ToString();
                fltOrderEntity.Orderstatus = "C";
                fltOrderEntity.CancelType  = "C";
                log.Remark = "订单审核状态:一级审核不通过。一级审核人:" + _query.AuditCustomer?.RealName;
                properties.Add("CheckStatus");
                properties.Add("CancelType");
                properties.Add("Orderstatus");
            }

            #endregion

            _fltOrderDal.Update(fltOrderEntity);
            _fltOrderLogDal.Insert(log);

            return(new AuditResultModel()
            {
                Code = 0,
                AuditResult = log.Remark,
                OwnCid = fltOrderEntity.Cid,
                Id = fltOrderEntity.OrderId,
                OrderType = OrderSourceTypeEnum.Flt
            });
        }
Exemplo n.º 9
0
        public string GetPnrNo(int orderid, string email)
        {
            string isServer = AppSettingsHelper.GetAppSettings(AppSettingsEnum.IsServer);

            if (isServer != "T")//如果不是生产环境,不定位
            {
                return(string.Empty);
            }
            FltOrderEntity orderEntity = _fltOrderDal.Find <FltOrderEntity>(orderid);

            if ((orderEntity.ProcessStatus & 1) == 1)//如果已经定位,则不再定位
            {
                return(string.Empty);
            }
            string pnrNo = _doPnrNoBll.DoPnrNo(orderid, orderEntity.CreateOid);

            if (!string.IsNullOrEmpty(pnrNo))
            {
                //定位成功之后,设置已定位
                orderEntity.ProcessStatus = orderEntity.ProcessStatus + 1;
                _fltOrderDal.Update(orderEntity, new string[] { "ProcessStatus" });
                _fltOrderLogDal.Insert(new FltOrderLogEntity()
                {
                    OrderId = orderEntity.OrderId,
                    LogTime = DateTime.Now,
                    LogType = "修改订单",
                    Oid     = "sys",
                    Remark  = "线上订单,设置已定位" + pnrNo
                });
            }
            else
            {
                if (!string.IsNullOrEmpty(email))
                {
                    string url = string.Format("http://192.168.1.188/orderprocess/Flt_order.asp?orderid={0}",
                                               orderid);
                    string content = string.Format("订单号:<a  href='{0}' >{1}</a>", url, orderid);
                    new TaskFactory().StartNew(() =>
                    {
                        EmailHelper.SendEmail("", "国内机票定位异常", null, null, content, email);
                    });
                }
            }
            return(pnrNo);
        }
Exemplo n.º 10
0
        public int CancelOnlineCorpOrder(int orderId, int cid, string remark)
        {
            FltOrderEntity orderEntity = _fltOrderDal.Find <FltOrderEntity>(orderId);

            if (orderEntity == null)
            {
                throw new Exception("查无此订单");
            }
            if (cid != orderEntity.Cid)
            {
                throw new Exception("查无此订单");
            }
            if (orderEntity.Orderstatus == "C")
            {
                throw new Exception("此订单已取消");
            }

            if ((orderEntity.ProcessStatus & 8) == 8)
            {
                throw new Exception("此订单已经出票,不能取消");
            }


            FltOrderLogEntity log = new FltOrderLogEntity()
            {
                OrderId = orderEntity.OrderId,
                LogTime = DateTime.Now,
                LogType = "修改订单"
            };

            orderEntity.Orderstatus = "C";
            orderEntity.CancelType  = "C";
            orderEntity.Remark      = (orderEntity.Remark ?? "") + ",客户自行取消";
            orderEntity.Oid         = "sys";
            log.Remark = "操作人:" + cid + ",原因:" + remark;

            _fltOrderDal.Update(orderEntity, new string[] { "Orderstatus", "CancelType", "Remark", "Oid" });

            _fltOrderLogDal.Insert(log);

            return(0);
        }
        /// <summary>
        /// 机票审批通知
        /// </summary>
        /// <param name="sendAppMessageModel"></param>
        private void GetFltAuditResultMessage(SendAppMessageModel sendAppMessageModel)
        {
            if (sendAppMessageModel.OrderType == OrderSourceTypeEnum.Flt &&
                sendAppMessageModel.SendType == SendAppMessageTypeEnum.AuditResultNotice)
            {
                FltOrderEntity fltOrderEntity = _fltOrderDal.Find <FltOrderEntity>(sendAppMessageModel.OrderId);

                /**
                 * 审批共分为如下情况:
                 * 1.只存在一级审核
                 * 2.存在二级审核
                 */
                if (fltOrderEntity.CPId.HasValue && !fltOrderEntity.CPIdSecond.HasValue)
                {
                    if (fltOrderEntity.CheckStatus == "W")
                    {
                        sendAppMessageModel.SendContent = string.Format("您的机票订单{0}已经通过审批,准备出票", fltOrderEntity.OrderId);
                    }
                    else if (fltOrderEntity.CheckStatus == "J")
                    {
                        sendAppMessageModel.SendContent = string.Format("您的机票订单{0}被审批人驳回,请您确认", fltOrderEntity.OrderId);
                    }
                }
                else if (fltOrderEntity.CPId.HasValue && fltOrderEntity.CPIdSecond.HasValue)
                {
                    if (fltOrderEntity.CheckStatus == "S")
                    {
                        sendAppMessageModel.SendContent = string.Format("您的机票订单{0}已经通过一级审批,进入二级审批", fltOrderEntity.OrderId);
                    }
                    if (fltOrderEntity.CheckStatus == "W")
                    {
                        sendAppMessageModel.SendContent = string.Format("您的机票订单{0}已经通过二级审批,准备出票", fltOrderEntity.OrderId);
                    }
                    else if (fltOrderEntity.CheckStatus == "J")
                    {
                        sendAppMessageModel.SendContent = string.Format("您的机票订单{0}被审批人驳回,请您确认", fltOrderEntity.OrderId);
                    }
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// 针对订单审批后发邮件提醒
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public BaseDealAduitResultDetailModel GetCorpAduitOrderDetailmail(DoAduitOrderRequestViewModel request)
        {
            List <BaseDealAduitResultDetailModel> dorder      = _corpAduitBll.GetCorpAduitOrderDetail(request.AduitOrderId);
            BaseDealAduitResultDetailModel        detailorder = new BaseDealAduitResultDetailModel();

            if (dorder.Count > 0)
            {
                string type     = dorder[0].OrderSourceType.ToString();
                bool   isFly    = false;
                string orderOid = "0";
                switch (type)
                {
                //飞机正单
                case "Flt":
                    detailorder.OrderId = dorder[0].OrderId;
                    FltOrderEntity orderentity = base.Context.Set <FltOrderEntity>().Find(detailorder.OrderId);
                    orderOid = orderentity.CreateOid;
                    isFly    = true;
                    break;

                //飞机改签
                case "FltModApply":
                    detailorder.OrderId = dorder[0].OrderId;
                    FltRetModApplyEntity FltRetentity = base.Context.Set <FltRetModApplyEntity>().Find(detailorder.OrderId);
                    detailorder.OrderId = FltRetentity.OrderId;
                    orderOid            = FltRetentity.CreateOid;
                    isFly = true;
                    break;

                //飞机退票
                case "FltRetApply":
                    detailorder.OrderId = dorder[0].OrderId;
                    FltRetModApplyEntity Retentity = base.Context.Set <FltRetModApplyEntity>().Find(detailorder.OrderId);
                    detailorder.OrderId = Retentity.OrderId;
                    orderOid            = Retentity.CreateOid;
                    isFly = true;
                    break;
                }
                OperatorModel operatorModel = _getOperatorServiceBll.GetOperatorByOid(orderOid);
                string        mail          = operatorModel.Email;
                string        approve       = "";
                if (!request.IsAgree)
                {
                    approve = "审批未通过";
                }
                else
                {
                    approve = "审批已通过";
                }
                StringBuilder mailContent = new StringBuilder();
                mailContent.Append("<b>客户审批提醒:<b/>");
                mailContent.Append("<br/>");
                mailContent.Append("客户已经审批了订单,订单编号:" + detailorder.OrderId.ToString() + "," + approve + "。");
                mailContent.Append("<br/>");
                mailContent.Append("<b>下单时间:" + DateTime.Now + ",请及时关注~<b/>");
                //发送邮件
                if (!string.IsNullOrEmpty(mail) && isFly)
                {
                    bool flag = EmailHelper.SendEmail("", "客户审批提醒", null, null, mailContent.ToString(), mail);
                }
            }
            return(detailorder);
        }
        /// <summary>
        /// 获取机票出票通知邮件
        /// </summary>
        /// <param name="sendAppMessageModel"></param>
        private void GetFltPrintTicketEmail(SendAppMessageModel sendAppMessageModel)
        {
            CustomerInfoEntity customerInfoEntity = base.Context.Set <CustomerInfoEntity>().Find(sendAppMessageModel.Cid);

            if (string.IsNullOrEmpty(customerInfoEntity?.Email))
            {
                return;
            }

            sendAppMessageModel.Email = customerInfoEntity.Email;

            FltOrderEntity fltOrderEntity = _fltOrderDal.Find <FltOrderEntity>(sendAppMessageModel.OrderId);

            List <FltPassengerEntity> fltPassengerEntities =
                _fltPassengerDal.Query <FltPassengerEntity>(n => n.OrderId == fltOrderEntity.OrderId, true).ToList();

            List <FltFlightEntity> fltFlightEntities =
                _fltFlightDal.Query <FltFlightEntity>(n => n.OrderId == fltOrderEntity.OrderId, true).ToList();
            //判断是否是同一个编码
            bool isSamePnr = fltFlightEntities.Select(n => n.RecordNo).Distinct().Count() == 1;

            if (fltFlightEntities.Count == 1)
            {
                isSamePnr = false;
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("<p>{0}:</p>", customerInfoEntity.RealName);
            sb.Append("<p>&nbsp;</p>");
            sb.Append("<p>您好!</p>");

            foreach (var fltPassengerEntity in fltPassengerEntities)
            {
                sb.Append("<p>&nbsp; </p>");
                sb.AppendFormat("<p>{0}:{1}已成功预订!</p>", fltPassengerEntity.Name, fltPassengerEntity.CardNo);
                if (!isSamePnr)
                {
                    //不同编码的行程
                    foreach (var fltFlightEntity in fltFlightEntities)
                    {
                        string dportName =
                            _airPortDal.Query <AirPortEntity>(n => n.AirportCode == fltFlightEntity.Dport, true)
                            .FirstOrDefault()?
                            .AirportName;
                        string aportName =
                            _airPortDal.Query <AirPortEntity>(n => n.AirportCode == fltFlightEntity.Aport, true)
                            .FirstOrDefault()?
                            .AirportName;

                        string s1 = fltFlightEntity.Airportson.Length >= 2
                            ? fltFlightEntity.Airportson.Substring(0, 2)
                            : "--";
                        string s2 = fltFlightEntity.Airportson.Length >= 4
                            ? fltFlightEntity.Airportson.Substring(2, 2)
                            : "--";

                        sb.AppendFormat("<p>行程:{0} {1}{2}-{3}{4}</p>", fltFlightEntity.FlightNo, dportName, s1,
                                        aportName,
                                        s2);
                        sb.AppendFormat("<p>出行时间:{0} {1} 起飞 {2} 到达</p>", fltFlightEntity.TackoffTime.ToString("MM月dd日"),
                                        fltFlightEntity.TackoffTime.ToString("HH:mm"),
                                        fltFlightEntity.ArrivalsTime.ToString("HH:mm"));
                        sb.AppendFormat("<p>价格:{0}元</p>",
                                        fltFlightEntity.SalePrice + fltFlightEntity.TaxFee + fltFlightEntity.OilFee +
                                        (fltFlightEntity.ServiceFee ?? 0));
                    }
                }
                else
                {
                    //第一段
                    string f1         = fltFlightEntities[0].FlightNo;
                    string dport1     = fltFlightEntities[0].Dport;
                    string dportName1 =
                        _airPortDal.Query <AirPortEntity>(n => n.AirportCode == dport1, true)
                        .FirstOrDefault()?
                        .AirportName;
                    string aport1     = fltFlightEntities[0].Aport;
                    string aportName1 =
                        _airPortDal.Query <AirPortEntity>(n => n.AirportCode == aport1, true)
                        .FirstOrDefault()?
                        .AirportName;

                    string d1 = fltFlightEntities[0].Airportson.Length >= 2
                       ? fltFlightEntities[0].Airportson.Substring(0, 2)
                       : "--";
                    string a1 = fltFlightEntities[0].Airportson.Length >= 4
                        ? fltFlightEntities[0].Airportson.Substring(2, 2)
                        : "--";

                    //第二段
                    string f2         = fltFlightEntities[1].FlightNo;
                    string dport2     = fltFlightEntities[1].Dport;
                    string dportName2 =
                        _airPortDal.Query <AirPortEntity>(n => n.AirportCode == dport2, true)
                        .FirstOrDefault()?
                        .AirportName;

                    string aport2     = fltFlightEntities[1].Aport;
                    string aportName2 =
                        _airPortDal.Query <AirPortEntity>(n => n.AirportCode == aport2, true)
                        .FirstOrDefault()?
                        .AirportName;
                    string d2 = fltFlightEntities[1].Airportson.Length >= 2
                      ? fltFlightEntities[1].Airportson.Substring(0, 2)
                      : "--";
                    string a2 = fltFlightEntities[1].Airportson.Length >= 4
                        ? fltFlightEntities[1].Airportson.Substring(2, 2)
                        : "--";

                    sb.AppendFormat("<p>行程:去 {0} {1}{2}-{3}{4},回 {5} {6}{7}-{8}{9}</p>", f1, dportName1, d1,
                                    aportName1, a1, f2, dportName2, d2,
                                    aportName2, a2);

                    sb.AppendFormat("<p>出行时间:去 {0} {1} 起飞 {2} 到达,回 {3} {4} 起飞 {5} 到达</p>",
                                    fltFlightEntities[0].TackoffTime.ToString("MM月dd日"),
                                    fltFlightEntities[0].TackoffTime.ToString("HH:mm"),
                                    fltFlightEntities[0].ArrivalsTime.ToString("HH:mm"),
                                    fltFlightEntities[1].TackoffTime.ToString("MM月dd日"),
                                    fltFlightEntities[1].TackoffTime.ToString("HH:mm"),
                                    fltFlightEntities[1].ArrivalsTime.ToString("HH:mm"));

                    sb.AppendFormat("<p>价格:{0}元</p>",
                                    fltFlightEntities.Sum(n => n.SalePrice) + fltFlightEntities.Sum(n => n.TaxFee) +
                                    fltFlightEntities.Sum(n => n.OilFee) +
                                    fltFlightEntities.Sum(n => (n.ServiceFee ?? 0)));
                }
            }


            sb.Append("<p></p>");
            sb.Append("<p>退改签规则:</p>");

            if (fltFlightEntities.Count == 1)
            {
                sb.AppendFormat("<p>退票:{0}</p>", fltFlightEntities[0].RetDes);
                sb.AppendFormat("<p>改期:{0}</p>", fltFlightEntities[0].ModDes);
            }
            else
            {
                sb.AppendFormat("<p>去程:</p>");
                sb.AppendFormat("<p>退票:{0}</p>", fltFlightEntities[0].RetDes);
                sb.AppendFormat("<p>改期:{0}</p>", fltFlightEntities[0].ModDes);
                sb.AppendFormat("<p>回程:</p>");
                sb.AppendFormat("<p>退票:{0}</p>", fltFlightEntities[1].RetDes);
                sb.AppendFormat("<p>改期:{0}</p>", fltFlightEntities[1].ModDes);
            }
            sb.Append("<p>温馨提醒:请提前90分钟到达机场,祝您一路平安,旅途愉快!</p>");
            sendAppMessageModel.SendContent = sb.ToString();
        }
Exemplo n.º 14
0
        /// <summary>
        /// 根据订单号获取订单信息
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public FltOrderInfoModel GetFltOrderById(int orderId)
        {
            FltOrderEntity fltOrderEntity = _fltOrderDal.Find <FltOrderEntity>(orderId);

            if (fltOrderEntity == null)
            {
                return(null);
            }

            //1.根据订单号 获取航段信息
            List <FltFlightEntity> flightEntities =
                _fltFlightDal.Query <FltFlightEntity>(n => n.OrderId == orderId, true).ToList();
            //2.根据订单号 获取乘机人信息
            List <FltPassengerEntity> passengerEntities =
                _fltPassengerDal.Query <FltPassengerEntity>(n => n.OrderId == orderId, true).ToList();
            //3.根据订单号 获取成本中心
            FltCorpCostCenterEntity costCenterEntity =
                _fltCorpCostCenterDal.Query <FltCorpCostCenterEntity>(n => n.Orderid == orderId, true).FirstOrDefault();
            //4.获取仓等信息
            List <FltClassNameModel> classNameModels = _getClassNameBll.GetFlightClassName();
            //5.获取机场信息
            List <SearchCityModel>    cityModels    = AportInfo?.CountryList.SelectMany(n => n.CityList).ToList();
            List <SearchAirportModel> airportModels = cityModels?.SelectMany(n => n.AirportList).ToList();
            //6.机票订单扩展表
            FltOrderUnionEntity fltOrderUnionEntity = _fltOrderUnionDal.Find <FltOrderUnionEntity>(orderId);

            FltOrderInfoModel result = Mapper.Map <FltOrderEntity, FltOrderInfoModel>(fltOrderEntity);

            if (!string.IsNullOrEmpty(costCenterEntity?.Depart))
            {
                result.CostCenter = costCenterEntity.Depart;
            }
            if (fltOrderUnionEntity?.ProjectId != null && ProjectNameList != null)
            {
                ProjectNameModel projectNameModel = ProjectNameList.Find(n => n.ProjectId == fltOrderUnionEntity.ProjectId.Value);
                result.ProjectName = projectNameModel?.ProjectName;
            }
            //result.CorpPolicy = fltOrderUnionEntity?.CorpPolicy;
            result.PassengerList =
                Mapper.Map <List <FltPassengerEntity>, List <FltPassengerModel> >(
                    passengerEntities.FindAll(n => n.OrderId == fltOrderEntity.OrderId));
            result.FlightList =
                Mapper.Map <List <FltFlightEntity>, List <FltFlightModel> >(
                    flightEntities.FindAll(n => n.OrderId == fltOrderEntity.OrderId));

            result.PassengerList.ForEach(n =>
            {
                if (n.InsCompanyId.HasValue)
                {
                    n.InsuranceName = InsuranceCompanyList?.Find(x => x.CompanyID == n.InsCompanyId.Value)?.ProductName;
                }
            });
            #region 行程信息

            result.CorpPolicy   = string.Empty;
            result.ChoiceReason = string.Empty;
            foreach (var n in result.FlightList)
            {
                if (!string.IsNullOrEmpty(n.CorpPolicy) && n.CorpPolicy.ToLower() != "undefined")
                {
                    result.CorpPolicy += ";" + n.CorpPolicy;
                }
                if (!string.IsNullOrEmpty(n.ChoiceReason) && n.ChoiceReason.ToLower() != "undefined")
                {
                    result.ChoiceReason += ";" + n.ChoiceReason;
                }
                SearchAirportModel airportModel = airportModels?.Find(x => x.AirportCode.ToLower() == n.Dport.ToLower());
                if (airportModel != null)
                {
                    n.DportName = airportModel.AirportLongName;
                    SearchCityModel cityModel = cityModels.Find(x => x.CityCode.ToLower() == airportModel.CityCode.ToLower());
                    n.DportCity = cityModel.CityName;
                }

                SearchAirportModel airportModel2 = airportModels?.Find(x => x.AirportCode.ToLower() == n.Aport.ToLower());
                if (airportModel2 != null)
                {
                    n.AportName = airportModel2.AirportLongName;
                    SearchCityModel cityModel2 = cityModels.Find(x => x.CityCode.ToLower() == airportModel2.CityCode.ToLower());
                    n.AportCity = cityModel2.CityName;
                }

                FltClassNameModel classNameModel =
                    classNameModels.Find(
                        x =>
                        !string.IsNullOrEmpty(x.MClass) && !string.IsNullOrEmpty(n.Class) &&
                        x.MClass.ToLower() == n.Class.ToLower() &&
                        !string.IsNullOrEmpty(x.AirlineCode) && !string.IsNullOrEmpty(n.AirlineNo) &&
                        x.AirlineCode.ToLower() == n.AirlineNo.ToLower());

                if (classNameModel != null)
                {
                    n.ClassName   = classNameModel.ClassName;
                    n.ClassEnName = classNameModel.ClassEnName;
                }
            }

            if (!string.IsNullOrEmpty(result.CorpPolicy))
            {
                result.CorpPolicy = result.CorpPolicy.Substring(1);
            }

            if (!string.IsNullOrEmpty(result.ChoiceReason))
            {
                result.ChoiceReason = result.ChoiceReason.Substring(1);
            }

            #endregion

            return(result);
        }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
        /// <summary>
        /// 审批结果通知
        /// </summary>
        /// <param name="sendAppMessageModel"></param>
        private void GetAuditResultMessage(SendAppMessageModel sendAppMessageModel)
        {
            if (sendAppMessageModel.OrderType == OrderSourceTypeEnum.AduitOrder)
            {
                CorpAduitOrderEntity corpAduitOrderEntity =
                    _corpAduitOrderDal.Find <CorpAduitOrderEntity>(sendAppMessageModel.OrderId);

                if (corpAduitOrderEntity == null)
                {
                    return;
                }

                List <CorpAduitOrderDetailEntity> corpAduitOrderDetailEntities =
                    _corpAduitOrderDetailDal.Query <CorpAduitOrderDetailEntity>(
                        n => n.AduitOrderId == sendAppMessageModel.OrderId, true).ToList();
                if (corpAduitOrderDetailEntities == null || corpAduitOrderDetailEntities.Count == 0)
                {
                    return;
                }

                string orderType = corpAduitOrderDetailEntities[0].OrderType.ValueToDescription <OrderSourceTypeEnum>();
                string orderId   = corpAduitOrderDetailEntities[0].OrderId.ToString();
                if (sendAppMessageModel.SendType == SendAppMessageTypeEnum.AuditResultNotice)
                {
                    if (corpAduitOrderEntity.Status == (int)CorpAduitOrderStatusEnum.J)
                    {
                        sendAppMessageModel.SendContent = string.Format("您的{0}{1}{2}被审批人驳回,请您确认", orderType,
                                                                        (orderType.Contains("申请") ? "" : "订单"), orderId);
                    }
                    else if (corpAduitOrderEntity.Status == (int)CorpAduitOrderStatusEnum.F)
                    {
                        sendAppMessageModel.SendContent = string.Format("您的{0}{1}{2}已完成审批,准备为您{3}", orderType,
                                                                        (orderType.Contains("申请") ? "" : "订单"), orderId, (orderType.Contains("退票") ? "退票" : "出票"));

                        if (!orderType.Contains("退票") && orderType.Contains("机票") &&
                            sendAppMessageModel.SendAppMessageType == SendAppMessageTypeEnum.SendRunPrintFltTicketEmail)
                        {
                            FltOrderEntity fltOrderEntity =
                                base.Context.Set <FltOrderEntity>().Find(Convert.ToInt32(orderId));
                            if (fltOrderEntity != null)
                            {
                                string oid = string.IsNullOrEmpty(fltOrderEntity.CreateOid)
                                    ? "sys"
                                    : fltOrderEntity.CreateOid.ToUpper();

                                OperatorEntity operatorEntity =
                                    base.Context.Set <OperatorEntity>().Where(n =>
                                                                              n.Oid.ToUpper() == oid).FirstOrDefault();

                                sendAppMessageModel.IsRunOutTicket = true;
                                sendAppMessageModel.Email          = operatorEntity?.Email;

                                string isServer = AppSettingsHelper.GetAppSettings(AppSettingsEnum.IsServer);
                                string url      = string.Format(
                                    "http://192.168.1.117/orderprocess/Flt_order.asp?orderid={0}",
                                    orderId);
                                if (isServer == "T")
                                {
                                    url = string.Format("http://192.168.1.188/orderprocess/Flt_order.asp?orderid={0}",
                                                        orderId);
                                }
                                sendAppMessageModel.SendContent = string.Format("订单<a href='{0}'>{1}</a>已审核,请出票", url,
                                                                                orderId);
                                sendAppMessageModel.EmailTitle = string.Format("订单{0}已审核,请出票", orderId);
                            }
                        }
                    }
                    else if (corpAduitOrderEntity.Status > (int)CorpAduitOrderStatusEnum.N)
                    {
                        sendAppMessageModel.SendContent = string.Format("您的{0}{1}{2}已通过审批,待下级为您继续审批", orderType,
                                                                        (orderType.Contains("申请") ? "" : "订单"), orderId);
                    }
                }
                else if (sendAppMessageModel.SendType == SendAppMessageTypeEnum.AuditOrderDeleteNotice)
                {
                    sendAppMessageModel.SendContent = string.Format("您的{0}{1}{2}由于已经取消,所以审批自动过期", orderType,
                                                                    (orderType.Contains("申请") ? "" : "订单"), orderId);
                }
            }
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
0
        public QueryFlightOrderDataModel QueryFlightOrder(QueryFlightOrderQueryModel query)
        {
            var            select         = _fltOrderDal.Query <FltOrderEntity>(n => n.OrderId == query.OrderId, true);
            FltOrderEntity fltOrderEntity = select.FirstOrDefault();

            if (fltOrderEntity == null)
            {
                throw new Exception("查无此订单");
            }
            //如果登录用户没有查看全部订单的权限
            if ((query.Customer.IsShowAllOrder ?? 0) == 0)
            {
                if (!query.IsFromAduitQuery)//不是来自审批人查询
                {
                    if (!string.IsNullOrEmpty(query.Customer?.UserID) && query.Customer.UserID.ToLower() != "administrator" &&
                        query.Customer.Cid != fltOrderEntity.Cid)
                    {
                        throw new Exception("查无此订单");
                    }
                }
            }
            if (!string.IsNullOrEmpty(query.Customer?.UserID) && query.Customer.UserID.ToLower() == "administrator")
            {
                if ((query.CidList != null && !query.CidList.Contains(fltOrderEntity.Cid)) || query.CidList == null)
                {
                    throw new Exception("查无此订单");
                }
            }

            //1.根据订单号 获取航段信息
            List <FltFlightEntity> flightEntities = _fltFlightDal.Query <FltFlightEntity>(n => n.OrderId == query.OrderId, true).ToList();
            //2.根据订单号 获取乘机人信息
            List <FltPassengerEntity> passengerEntities = _fltPassengerDal.Query <FltPassengerEntity>(n => n.OrderId == query.OrderId, true).ToList();
            //3.根据订单号 获取成本中心
            FltCorpCostCenterEntity costCenterEntity = _fltCorpCostCenterDal.Query <FltCorpCostCenterEntity>(n => n.Orderid == query.OrderId, true).FirstOrDefault();
            //4.获取仓等信息
            List <FltClassNameModel> classNameModels = _getClassNameBll.GetFlightClassName();
            //5.获取机场信息
            List <SearchCityModel>    cityModels    = query.AportInfo.CountryList.SelectMany(n => n.CityList).ToList();
            List <SearchAirportModel> airportModels = cityModels.SelectMany(n => n.AirportList).ToList();

            FltOrderUnionEntity fltOrderUnionEntity = _fltOrderUnionDal.Find <FltOrderUnionEntity>(query.OrderId);

            #region 机票正单信息
            QueryFlightOrderDataModel result = Mapper.Map <FltOrderEntity, QueryFlightOrderDataModel>(fltOrderEntity);
            if (!string.IsNullOrEmpty(costCenterEntity?.Depart))
            {
                result.CostCenter = costCenterEntity.Depart;
            }
            if (fltOrderUnionEntity?.ProjectId != null && query.ProjectName != null)
            {
                ProjectNameModel projectNameModel = query.ProjectName.Find(n => n.ProjectId == fltOrderUnionEntity.ProjectId.Value);
                result.ProjectName = projectNameModel?.ProjectName;
                result.ProjectId   = fltOrderUnionEntity.ProjectId;
            }
            result.PassengerList =
                Mapper.Map <List <FltPassengerEntity>, List <FltPassengerModel> >(
                    passengerEntities.FindAll(n => n.OrderId == fltOrderEntity.OrderId));


            result.FlightList =
                Mapper.Map <List <FltFlightEntity>, List <FltFlightModel> >(
                    flightEntities.FindAll(n => n.OrderId == fltOrderEntity.OrderId));

            #region 行程
            int index1 = 0;
            foreach (var n in result.FlightList)
            {
                SearchAirportModel airportModel = airportModels.Find(x => x.AirportCode.ToLower() == n.Dport.ToLower());
                if (airportModel != null)
                {
                    n.DportName = airportModel.AirportLongName;
                    SearchCityModel cityModel = cityModels.Find(x => x.CityCode.ToLower() == airportModel.CityCode.ToLower());
                    n.DportCity = cityModel.CityName;
                }

                SearchAirportModel airportModel2 = airportModels.Find(x => x.AirportCode.ToLower() == n.Aport.ToLower());
                if (airportModel2 != null)
                {
                    n.AportName = airportModel2.AirportLongName;
                    SearchCityModel cityModel2 = cityModels.Find(x => x.CityCode.ToLower() == airportModel2.CityCode.ToLower());
                    n.AportCity = cityModel2.CityName;
                }

                FltClassNameModel classNameModel =
                    classNameModels.Find(
                        x =>
                        !string.IsNullOrEmpty(x.MClass) && !string.IsNullOrEmpty(n.Class) &&
                        x.MClass.ToLower() == n.Class.ToLower() &&
                        !string.IsNullOrEmpty(x.AirlineCode) && !string.IsNullOrEmpty(n.AirlineNo) &&
                        x.AirlineCode.ToLower() == n.AirlineNo.ToLower());

                if (classNameModel != null)
                {
                    n.ClassName   = classNameModel.ClassName;
                    n.ClassEnName = classNameModel.ClassEnName;
                }

                index1++;
            }
            #endregion
            #endregion

            #region 机票退改签订单信息

            //改签订单
            List <string> modName         = new List <string>();
            List <string> modSequenceList = new List <string>();
            _getFlightModOrderBll.AportInfo = query.AportInfo;
            List <FltModOrderModel> fltModOrderList = _getFlightModOrderBll.GetModOrderByOrderId(query.OrderId);
            if (fltModOrderList != null && fltModOrderList.Count > 0)
            {
                fltModOrderList = fltModOrderList.FindAll(n => (n.ProcessStatus & 8) == 8);
                fltModOrderList.ForEach(n =>
                {
                    n.FltModFlightList.ForEach(x =>
                    {
                        n.FltModPassengerList.ForEach(m =>
                        {
                            modSequenceList.Add(x.Sequence + "|" + m.Name);
                        });

                        FltClassNameModel classNameModel =
                            classNameModels.Find(
                                m =>
                                !string.IsNullOrEmpty(m.MClass) && !string.IsNullOrEmpty(x.Class) &&
                                m.MClass.ToLower() == x.Class.ToLower() &&
                                !string.IsNullOrEmpty(m.AirlineCode) && !string.IsNullOrEmpty(x.AirlineNo) &&
                                m.AirlineCode.ToLower() == x.AirlineNo.ToLower());

                        if (classNameModel != null)
                        {
                            x.ClassName   = classNameModel.ClassName;
                            x.ClassEnName = classNameModel.ClassEnName;
                        }
                    });
                });
                modSequenceList = modSequenceList.Distinct().ToList();
            }

            //退票订单
            List <string> retName            = new List <string>();
            List <string> refundSequenceList = new List <string>();
            List <FltRefundOrderModel> fltRefundOrderList = _getFlighRefundOrderBll.GetFlighRefundOrderByOrderId(query.OrderId);
            if (fltRefundOrderList != null && fltRefundOrderList.Count > 0)
            {
                fltRefundOrderList = fltRefundOrderList.FindAll(n => n.RefundCustomer == "T");
                fltRefundOrderList.ForEach(n =>
                {
                    n.DetailList.ForEach(x =>
                    {
                        FltFlightModel flightTemp = result.FlightList.Find(m => m.Sequence == x.Sequence);
                        x.Dport     = flightTemp.Dport;
                        x.DportName = flightTemp.DportName;
                        x.DportCity = flightTemp.DportCity;
                        x.Aport     = flightTemp.Aport;
                        x.AportName = flightTemp.AportName;
                        x.AportCity = flightTemp.AportCity;
                        x.FlightNo  = flightTemp.FlightNo;
                        x.Class     = flightTemp.Class;
                        refundSequenceList.Add(x.Sequence + "|" + x.PassengerName);
                        retName.Add(x.PassengerName);
                    });
                });
                refundSequenceList        = refundSequenceList.Distinct().ToList();
                result.FltRefundOrderList = fltRefundOrderList;
            }

            #region 先处理改签情况
            if (fltModOrderList != null)
            {
                List <FltModOrderModel> tempList = new List <FltModOrderModel>();

                foreach (string modSequence in modSequenceList)
                {
                    int    sequence      = Convert.ToInt32(modSequence.Split('|')[0]);
                    string passengerName = modSequence.Split('|')[1];

                    var flightRmidList =
                        fltModOrderList.SelectMany(n => n.FltModFlightList)
                        .Where(n => n.Sequence == sequence)
                        .Select(n => n.Rmid)
                        .ToList();
                    var passengerRmidList =
                        fltModOrderList.SelectMany(n => n.FltModPassengerList)
                        .Where(n => n.Name == passengerName)
                        .Select(n => n.Rmid)
                        .ToList();

                    int maxRmid = fltModOrderList.Where(
                        n => flightRmidList.Contains(n.Rmid) && passengerRmidList.Contains(n.Rmid))
                                  .Max(n => n.Rmid);

                    var temp = fltModOrderList.Find(n => n.Rmid == maxRmid);
                    if (tempList.Find(n => n.Rmid == temp.Rmid) == null)
                    {
                        tempList.Add(temp);
                    }
                }

                result.FltModOrderList = tempList;
                result.FltModOrderList.ForEach(n =>
                {
                    n.FltModPassengerList.ForEach(x =>
                    {
                        modName.Add(x.Name);
                    });
                });
            }
            #endregion

            #region 既有改签又有退票

            if (fltModOrderList != null && refundSequenceList.Count > 0)
            {
                foreach (string refundSequence in refundSequenceList)
                {
                    //将相同行程号,并且是相同人名的改签行程删除
                    int    sequence      = Convert.ToInt32(refundSequence.Split('|')[0]);
                    string passengerName = refundSequence.Split('|')[1];

                    for (int i = 0; i < fltModOrderList.Count; i++)
                    {
                        List <FltModPassengerModel> fltModPassengerModels =
                            fltModOrderList[i].FltModPassengerList.FindAll(n => n.Name == passengerName);
                        FltModFlightModel fltModFlightModel =
                            fltModOrderList[i].FltModFlightList.Find(n => n.Sequence == sequence);

                        if (fltModPassengerModels != null && fltModPassengerModels.Count > 0 &&
                            fltModFlightModel != null)
                        {
                            fltModOrderList[i].FltModFlightList.Remove(fltModFlightModel);
                        }
                    }
                }


                if (fltModOrderList != null && fltModOrderList.Count > 0)
                {
                    List <FltModOrderModel> index = new List <FltModOrderModel>();
                    for (int i = 0; i < fltModOrderList.Count; i++)
                    {
                        if (fltModOrderList[i].FltModFlightList.Count == 0)
                        {
                            index.Add(fltModOrderList[i]);
                        }
                    }

                    foreach (var i in index)
                    {
                        fltModOrderList.Remove(i);
                    }

                    modName = new List <string>();
                    result.FltModOrderList = fltModOrderList;
                    result.FltModOrderList.ForEach(n =>
                    {
                        n.FltModPassengerList.ForEach(x =>
                        {
                            modName.Add(x.Name);
                        });
                    });
                }
            }
            #endregion
            #endregion
            result.PassengerList.ForEach(n =>
            {
                if (n.InsCompanyId.HasValue)
                {
                    n.InsuranceName = query.InsuranceCompany?.Find(x => x.CompanyID == n.InsCompanyId.Value)?.ProductName;
                }
                if (modName.Count > 0)
                {
                    n.IsMod = (modName.Find(x => x == n.Name) != null ? true : false);
                }

                if (retName.Count > 0)
                {
                    n.IsRet = (retName.Find(x => x == n.Name) != null ? true : false);
                }
            });
            return(result);
        }
Exemplo n.º 19
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);
        }
Exemplo n.º 20
0
        public GetModApplyModel GetModApplyView(GetModApplyQueryModel query)
        {
            //1.判断是否已经出票
            FltOrderEntity fltOrderEntity = _fltOrderDal.Find <FltOrderEntity>(query.OrderId);

            if (fltOrderEntity == null)
            {
                throw new Exception("查无此订单");
            }

            if ((fltOrderEntity.ProcessStatus & 8) != 8)
            {
                throw new Exception("该订单未出票,不能提交改签申请");
            }

            if (fltOrderEntity.Cid != query.Cid && query.Customer != null &&
                query.Customer.UserID.ToLower() != "administrator")
            {
                throw new Exception("查无此订单");
            }


            List <FltFlightEntity> flightEntities =
                _fltFlightDal.Query <FltFlightEntity>(n => n.OrderId == query.OrderId).ToList();
            List <FltPassengerEntity> passengerEntities =
                _fltPassengerDal.Query <FltPassengerEntity>(n => n.OrderId == query.OrderId).ToList();
            List <FltTicketNoEntity> fltTicketNoEntities =
                _fltTicketNoDal.Query <FltTicketNoEntity>(n => n.OrderId == query.OrderId).ToList();

            //5.获取机场信息
            List <SearchCityModel>    cityModels      = query.AportInfo.CountryList.SelectMany(n => n.CityList).ToList();
            List <SearchAirportModel> airportModels   = cityModels.SelectMany(n => n.AirportList).ToList();
            List <FltClassNameModel>  classNameModels = _getClassNameBll.GetFlightClassName();

            GetModApplyModel result = new GetModApplyModel();

            result.CName        = fltOrderEntity.Cname;
            result.Mobile       = fltOrderEntity.Mobile;
            result.Email        = fltOrderEntity.Email;
            result.Cid          = fltOrderEntity.Cid;
            result.CorpAduitId  = fltOrderEntity.CorpAduitId;
            result.CorpPolicyId = fltOrderEntity.CorpPolicyId;

            result.PassengerList = Mapper.Map <List <FltPassengerEntity>, List <FltPassengerModel> >(passengerEntities);

            result.FlightList = Mapper.Map <List <FltFlightEntity>, List <FltFlightModel> >(flightEntities);

            result.FlightList.ForEach(n =>
            {
                SearchAirportModel airportModel = airportModels.Find(x => x.AirportCode.ToLower() == n.Dport.ToLower());
                if (airportModel != null)
                {
                    n.DportName = airportModel.AirportLongName;
                    SearchCityModel cityModel = cityModels.Find(x => x.CityCode.ToLower() == airportModel.CityCode.ToLower());
                    n.DportCity = cityModel.CityName;
                }

                SearchAirportModel airportModel2 = airportModels.Find(x => x.AirportCode.ToLower() == n.Aport.ToLower());
                if (airportModel2 != null)
                {
                    n.AportName = airportModel2.AirportLongName;
                    SearchCityModel cityModel2 = cityModels.Find(x => x.CityCode.ToLower() == airportModel2.CityCode.ToLower());
                    n.AportCity = cityModel2.CityName;
                }

                FltClassNameModel classNameModel =
                    classNameModels.Find(
                        x =>
                        !string.IsNullOrEmpty(x.MClass) && !string.IsNullOrEmpty(n.Class) &&
                        x.MClass.ToLower() == n.Class.ToLower() &&
                        !string.IsNullOrEmpty(x.AirlineCode) && !string.IsNullOrEmpty(n.AirlineNo) &&
                        x.AirlineCode.ToLower() == n.AirlineNo.ToLower());

                if (classNameModel != null)
                {
                    n.ClassName   = classNameModel.ClassName;
                    n.ClassEnName = classNameModel.ClassEnName;
                }
            });

            List <int> pidList = result.PassengerList.Select(n => n.PId).ToList();

            #region 判断该乘机人是否有未处理的改签申请
            List <string> orderStatusList = new List <string>()
            {
                "C", "F"
            };
            var select = from flight in Context.Set <FltRetModFlightApplyEntity>()
                         join apply in Context.Set <FltRetModApplyEntity>() on flight.Rmid equals apply.Rmid into c
                         from apply in c.DefaultIfEmpty()
                         where !orderStatusList.Contains(apply.OrderStatus) && pidList.Contains(flight.Pid) && apply.OrderType.ToUpper() == "M"
                         select flight;

            List <FltRetModFlightApplyEntity> listMod = select.ToList();//已经改签人
            if (listMod != null && listMod.Count > 0)
            {
                result.PassengerList.ForEach(n =>
                {
                    FltRetModFlightApplyEntity l = listMod.Find(x => x.Pid == n.PId);
                    if (l != null)
                    {
                        n.IsMod = true;
                    }
                });
            }
            #endregion

            #region 判断该乘机人是否有存在退票申请
            List <string> refundStatusList = new List <string>()
            {
                "C"
            };
            var selectRefund = from flight in Context.Set <FltRetModFlightApplyEntity>()
                               join apply in Context.Set <FltRetModApplyEntity>() on flight.Rmid equals apply.Rmid into c
                               from apply in c.DefaultIfEmpty()
                               where !refundStatusList.Contains(apply.OrderStatus) && pidList.Contains(flight.Pid) && apply.OrderType.ToUpper() == "R"
                               select flight;

            List <FltRetModFlightApplyEntity> listRefund = selectRefund.ToList();//已经退票
            if (listRefund != null && listRefund.Count > 0)
            {
                result.PassengerList.ForEach(n =>
                {
                    FltRetModFlightApplyEntity l = listRefund.Find(x => x.Pid == n.PId);
                    if (l != null)
                    {
                        n.IsRet = true;
                    }
                });
            }
            #endregion

            //获取航程允许改签的乘机人Id
            foreach (var fltFlightModel in result.FlightList)
            {
                fltFlightModel.AllowModPidList = new List <int>();

                foreach (var fltPassengerModel in result.PassengerList)
                {
                    //判断当前是否已经退票
                    FltRetModFlightApplyEntity isRefund = listRefund.Find(n => n.Sequence == fltFlightModel.Sequence && fltPassengerModel.PId == n.Pid);

                    //判断票号使用情况
                    FltTicketNoEntity fltTicketNoEntity =
                        fltTicketNoEntities.Find(
                            x => x.PassengerName == fltPassengerModel.Name && x.Sequence == fltFlightModel.Sequence);
                    if (fltTicketNoEntity != null && fltTicketNoEntity.TicketNoStatus == "R")//如果当前乘机人对应航段票号已经退票了
                    {
                        isRefund = new FltRetModFlightApplyEntity();
                    }

                    if (isRefund == null)
                    {
                        //再判断是否已经改签
                        FltRetModFlightApplyEntity isMod =
                            listMod.Find(n => n.Sequence == fltFlightModel.Sequence && fltPassengerModel.PId == n.Pid);
                        if (isMod == null)
                        {
                            fltFlightModel.AllowModPidList.Add(fltPassengerModel.PId);
                        }
                    }
                }

                if (fltFlightModel.AllowModPidList.Count > 1)
                {
                    fltFlightModel.AllowModPidList = fltFlightModel.AllowModPidList.Distinct().ToList();
                }
            }

            return(result);
        }
Exemplo n.º 21
0
        public GetRetApplyModel GetRetApply(GetRetApplyQueryModel query)
        {
            FltOrderEntity fltOrderEntity = _fltOrderDal.Find <FltOrderEntity>(query.OrderId);

            if (fltOrderEntity == null)
            {
                throw new Exception("查无此订单");
            }
            if ((fltOrderEntity.ProcessStatus & 8) != 8)
            {
                throw new Exception("该订单未出票,不能提交改签申请");
            }
            if (fltOrderEntity.Cid != query.Cid && query.Customer != null &&
                query.Customer.UserID.ToLower() != "administrator")
            {
                throw new Exception("查无此订单");
            }


            GetRetApplyModel result = new GetRetApplyModel();

            List <FltFlightEntity> flightEntities =
                _fltFlightDal.Query <FltFlightEntity>(n => n.OrderId == query.OrderId).ToList();
            List <FltPassengerEntity> passengerEntities =
                _fltPassengerDal.Query <FltPassengerEntity>(n => n.OrderId == query.OrderId).ToList();
            List <FltTicketNoEntity> fltTicketNoEntities =
                _fltTicketNoDal.Query <FltTicketNoEntity>(n => n.OrderId == query.OrderId).ToList();
            List <SearchCityModel>    cityModels      = query.AportInfo.CountryList.SelectMany(n => n.CityList).ToList();
            List <SearchAirportModel> airportModels   = cityModels.SelectMany(n => n.AirportList).ToList();
            List <FltClassNameModel>  classNameModels = _getClassNameBll.GetFlightClassName();

            /*
             * 判断是否来回程开在一个票号上
             * 如果乘机人的票数=行程数量,则代表分开开;不等于则开在同一票上
             * **/
            int  nameTicketCount = fltTicketNoEntities.FindAll(n => n.PassengerName == passengerEntities[0].Name).Count;
            int  flightCount     = flightEntities.Count;
            bool isSame          = (nameTicketCount != flightCount); //是否开在同一票号上

            result.FlightList = new List <FltFlightModel>();

            result.CName        = fltOrderEntity.Cname;
            result.Mobile       = fltOrderEntity.Mobile;
            result.Email        = fltOrderEntity.Email;
            result.Cid          = fltOrderEntity.Cid;
            result.CorpAduitId  = fltOrderEntity.CorpAduitId;
            result.CorpPolicyId = fltOrderEntity.CorpPolicyId;

            result.FlightList = Mapper.Map <List <FltFlightEntity>, List <FltFlightModel> >(flightEntities);
            result.FlightList.ForEach(n =>
            {
                SearchAirportModel airportModel = airportModels.Find(x => x.AirportCode.ToLower() == n.Dport.ToLower());
                if (airportModel != null)
                {
                    n.DportName = airportModel.AirportLongName;
                    SearchCityModel cityModel = cityModels.Find(x => x.CityCode.ToLower() == airportModel.CityCode.ToLower());
                    n.DportCity = cityModel.CityName;
                }

                SearchAirportModel airportModel2 = airportModels.Find(x => x.AirportCode.ToLower() == n.Aport.ToLower());
                if (airportModel2 != null)
                {
                    n.AportName = airportModel2.AirportLongName;
                    SearchCityModel cityModel2 = cityModels.Find(x => x.CityCode.ToLower() == airportModel2.CityCode.ToLower());
                    n.AportCity = cityModel2.CityName;
                }

                FltClassNameModel classNameModel =
                    classNameModels.Find(
                        x =>
                        !string.IsNullOrEmpty(x.MClass) && !string.IsNullOrEmpty(n.Class) &&
                        x.MClass.ToLower() == n.Class.ToLower() &&
                        !string.IsNullOrEmpty(x.AirlineCode) && !string.IsNullOrEmpty(n.AirlineNo) &&
                        x.AirlineCode.ToLower() == n.AirlineNo.ToLower());

                if (classNameModel != null)
                {
                    n.ClassName   = classNameModel.ClassName;
                    n.ClassEnName = classNameModel.ClassEnName;
                }
            });

            List <FltPassengerModel> fltPassengerModels =
                Mapper.Map <List <FltPassengerEntity>, List <FltPassengerModel> >(passengerEntities);

            result.PassengerList = new List <FltPassengerModel>();


            foreach (var ticketNo in fltTicketNoEntities)
            {
                FltPassengerModel fltPassengerModel2 = fltPassengerModels.Find(n => n.Name == ticketNo.PassengerName);

                FltPassengerModel fltPassengerModel = Mapper.Map <FltPassengerModel, FltPassengerModel>(fltPassengerModel2);
                fltPassengerModel.RetApplyTicketNo = ticketNo.AirlineNo + "-" + ticketNo.TicketNo;

                if (isSame)
                {
                    #region 开同一票号的行程

                    List <string> dportList = result.FlightList.Select(n => n.Dport).ToList();
                    List <string> aportList = result.FlightList.Select(n => n.Aport).ToList();
                    List <string> lineList  = new List <string>();
                    List <string> lineList2 = new List <string>();

                    for (int i = 0; i < dportList.Count; i++)
                    {
                        string             dport         = dportList[i];
                        string             aport         = aportList[i];
                        SearchAirportModel airportModel  = airportModels.Find(x => x.AirportCode.ToLower() == dport.ToLower());
                        SearchCityModel    cityModel     = cityModels.Find(n => n.CityCode.ToLower() == airportModel.CityCode.ToLower());
                        SearchAirportModel airportModel2 = airportModels.Find(x => x.AirportCode.ToLower() == aport.ToLower());
                        SearchCityModel    cityModel2    = cityModels.Find(n => n.CityCode.ToLower() == airportModel2.CityCode.ToLower());
                        lineList.Add(cityModel.CityName + "-" + cityModel2.CityName);

                        lineList2.Add(dport + "-" + aport);
                    }

                    fltPassengerModel.RetApplyFlightLine = Convert(lineList);
                    fltPassengerModel.RetApplyDAportList = lineList2;
                    fltPassengerModel.RetApplySequence   = 1;
                    fltPassengerModel.RetApplyFlightNo   =
                        result.FlightList.Select(n => n.FlightNo).ToList().FirstOrDefault();

                    #endregion
                }
                else
                {
                    #region 没有开在同一票号

                    var flight = result.FlightList.Find(n => n.Sequence == ticketNo.Sequence);
                    SearchAirportModel airportModel  = airportModels.Find(x => x.AirportCode.ToLower() == flight.Dport.ToLower());
                    SearchAirportModel airportModel2 = airportModels.Find(x => x.AirportCode.ToLower() == flight.Aport.ToLower());
                    if (airportModel != null && airportModel2 != null)
                    {
                        SearchCityModel cityModel  = cityModels.Find(n => n.CityCode.ToLower() == airportModel.CityCode.ToLower());
                        SearchCityModel cityModel2 = cityModels.Find(n => n.CityCode.ToLower() == airportModel2.CityCode.ToLower());
                        fltPassengerModel.RetApplyFlightLine = cityModel.CityName + "-" + cityModel2.CityName;
                    }

                    fltPassengerModel.RetApplyDAportList = new List <string>()
                    {
                        flight.Dport + "-" + flight.Aport
                    };
                    fltPassengerModel.RetApplySequence = flight.Sequence;
                    fltPassengerModel.RetApplyFlightNo = flight.FlightNo;

                    #endregion
                }

                result.PassengerList.Add(fltPassengerModel);
            }

            List <int>    pidList         = result.PassengerList.Select(n => n.PId).ToList();
            List <string> orderStatusList = new List <string>()
            {
                "C"
            };
            var select = from flight in Context.Set <FltRetModFlightApplyEntity>()
                         join apply in Context.Set <FltRetModApplyEntity>() on flight.Rmid equals apply.Rmid into c
                         from apply in c.DefaultIfEmpty()
                         where
                         !orderStatusList.Contains(apply.OrderStatus) && pidList.Contains(flight.Pid) &&
                         apply.OrderType.ToUpper() == "R"
                         select flight;
            List <FltRetModFlightApplyEntity> list = select.ToList();
            if (list != null && list.Count > 0)
            {
                result.PassengerList.ForEach(n =>
                {
                    FltRetModFlightApplyEntity l = list.Find(x => x.Pid == n.PId && x.Sequence == n.RetApplySequence);
                    if (l != null)
                    {
                        n.IsRet = true;
                    }
                });
            }
            else
            {
                result.PassengerList.ForEach(n =>
                {
                    FltTicketNoEntity fltTicketNoEntity =
                        fltTicketNoEntities.Find(x => x.PassengerName == n.Name && x.Sequence == n.RetApplySequence);
                    if (fltTicketNoEntity != null && fltTicketNoEntity.TicketNoStatus == "R")
                    {
                        n.IsRet = true;
                    }
                });
            }

            return(result);
        }
Exemplo n.º 22
0
        /// <summary>
        /// 一级审核
        /// </summary>
        /// <param name="firstAudit"></param>
        /// <returns></returns>
        public AuditResultModel DoFirstAudit(AuditOrderFirst firstAudit)
        {
            FltOrderEntity    fltOrderEntity = _fltOrderDal.Find <FltOrderEntity>(_query.Id);
            FltOrderLogEntity log            = new FltOrderLogEntity()
            {
                OrderId = fltOrderEntity.OrderId,
                LogTime = DateTime.Now,
                LogType = "审批订单",
                Oid     = "sys"
            };



            #region 审批操作

            bool          isSendEmail = false;
            List <string> properties  = new List <string>();
            if (IsAgree)
            {
                bool isHasSecond = _query.FltOrder.CPIdSecond.HasValue; //是否存在二级审批

                if (!isHasSecond)
                {
                    //1.2 如果不存在二级审批,则直接通过
                    fltOrderEntity.CheckStatus = FltOrderCheckStatusEnum.W.ToString();
                    log.Remark = string.Format("已通过{0}审批", _query.AuditCustomer?.RealName);
                }
                else
                {
                    isSendEmail = true;
                    //1.2 如果存在二级审批,则发送二级审批邮件
                    fltOrderEntity.CheckStatus = FltOrderCheckStatusEnum.S.ToString();
                    log.Remark = string.Format("已通过{0}审批,待二级审核", _query.AuditCustomer?.RealName);
                }
                properties.Add("CheckStatus");
            }
            else
            {
                //2.否决审批
                //2.1 取消订单
                if ((fltOrderEntity.ProcessStatus & 8) == 8)
                {
                    throw new Exception("该订单已经出票,不能否决,请联系客服");
                }
                fltOrderEntity.CheckStatus = FltOrderCheckStatusEnum.J.ToString();
                fltOrderEntity.Orderstatus = "C";
                fltOrderEntity.CancelType  = "C";
                //log.Remark = "订单审核状态:一级审核不通过。一级审核人:" + _query.AuditCustomer?.RealName;
                log.Remark = string.Format("已被{0}拒绝", _query.AuditCustomer?.RealName);
                properties.Add("CheckStatus");
                properties.Add("CancelType");
                properties.Add("Orderstatus");
            }

            #endregion



            _fltOrderDal.Update(fltOrderEntity, properties.ToArray());
            _fltOrderLogDal.Insert(log);

            //发送邮件
            if (isSendEmail)
            {
                SendEmail(fltOrderEntity);
            }

            return(new AuditResultModel()
            {
                Code = 0,
                AuditResult = log.Remark,
                NextAuditCid = fltOrderEntity.CPIdSecond,
                OwnCid = fltOrderEntity.Cid,
                Id = fltOrderEntity.OrderId,
                OrderType = OrderSourceTypeEnum.Flt
            });
        }