Exemple #1
0
        public async Task <ResponseBaseViewModel <DoAduitOrderResponseViewModel> > DoAduitOrder(
            [FromBody] DoAduitOrderRequestViewModel request)
        {
            request.Cid         = this.GetCid();
            request.Oid         = this.GetOid();
            request.OrderSource = this.GetOrderSource();
            DoAduitOrderResponseViewModel viewModel = new DoAduitOrderResponseViewModel();

            await new TaskFactory().StartNew(() =>
            {
                viewModel = _doAduitOrderApplication.DoAduitOrder(request);
            });

            ResponseBaseViewModel <DoAduitOrderResponseViewModel> v = new ResponseBaseViewModel
                                                                      <DoAduitOrderResponseViewModel>
            {
                Flag = new ResponseCodeViewModel()
                {
                    Code = 0, MojoryToken = this.GetToken()
                },
                Data = viewModel
            };

            return(v);
        }
Exemple #2
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);
        }
        public DoAduitOrderResponseViewModel DoAduitOrder(DoAduitOrderRequestViewModel request)
        {
            DoAduitOrderResultModel resultModel = null;
            List <int> traOrderIdList           = new List <int>();

            using (var transaction = this.Context.Database.BeginTransaction())
            {
                try
                {
                    resultModel = _doAduitOrderServiceBll.DoAduitOrder(new DoAduitOrderModel()
                    {
                        AduitOrderId = request.AduitOrderId,
                        IsAgree      = request.IsAgree,
                        CurrentFlow  = request.CurrentFlow,
                        DealCid      = request.Cid,
                        DealOid      = request.Oid,
                        AduitReason  = request.AduitReason,
                        DealSource   = request.OrderSource
                    });
                    if (resultModel.IsSuccessed)
                    {
                        if (!request.IsAgree)
                        {
                            #region 审批不通过,则取消对应的订单

                            foreach (var detail in resultModel.DetailList)
                            {
                                if (detail.OrderSourceType == OrderSourceTypeEnum.Flt)
                                {
                                    _cancelFltOrderServiceBll.CancelOnlineCorpOrder(detail.OrderId,
                                                                                    resultModel.CreateAduitOrderCid, "审批不通过");
                                }
                                if (detail.OrderSourceType == OrderSourceTypeEnum.FltModApply ||
                                    detail.OrderSourceType == OrderSourceTypeEnum.FltRetApply)
                                {
                                    _cancelRetModOrderServiceBll.CancelFltRetModApply(detail.OrderId);
                                }
                                if (detail.OrderSourceType == OrderSourceTypeEnum.Tra)
                                {
                                    traOrderIdList.Add(detail.OrderId);
                                    //取消火车订单
                                    _cancelTraOrderServiceBll.CancelTraOrder(new CancelTraOrderModel()
                                    {
                                        OrderId      = detail.OrderId,
                                        CancelReason = "审批不通过,取消订单"
                                    });
                                }
                            }

                            #endregion
                        }
                        else
                        {
                            if (resultModel.IsFinished)
                            {
                                //审批通过,并且当前审批流程已经结束,将审批通过的火车订单加入list
                                traOrderIdList.AddRange(from detail in resultModel.DetailList
                                                        where detail.OrderSourceType == OrderSourceTypeEnum.Tra
                                                        select detail.OrderId);
                            }
                        }
                    }

                    transaction.Commit();
                }
                catch (MojoryException ex)
                {
                    if (ex.Code == MojoryApiResponseCode.AduitCancelOrder)//如果是返回这种类型的异常,还是提交事务,但是异常抛出
                    {
                        transaction.Commit();
                        throw;
                    }

                    transaction.Rollback();
                    throw;
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    throw;
                }
            }
            foreach (var orderId in traOrderIdList)
            {
                if (!request.IsAgree)
                {
                    //取消火车订单后,访问第三方接口取消对应的订单,这里以后可以用mq替换
                    _requestCancelOrderServiceBll.RequestCancelOrder(orderId);
                }
                else
                {
                    //访问第三方出票接口,进行出票,这里以后可以用mq替换
                    TraOrderConfirmResponseModel confirmResponseModel = _requestPrintTicketServiceBll.RequestPrintTicket(orderId);
                    if (confirmResponseModel != null && !confirmResponseModel.success)
                    {
                        throw new Exception("审批通过,但是火车出票已过时限,请转线下处理");
                    }
                }
            }
            //2.发送提醒邮件
            _doAduitOrderServiceBll.GetCorpAduitOrderDetailmail(request);
            return(new DoAduitOrderResponseViewModel()
            {
                IsSuccessed = resultModel.IsSuccessed,
                IsFinished = resultModel.IsFinished
            });
        }