Beispiel #1
0
        /// <summary>
        /// 进行审批
        /// </summary>
        public AuditResultModel RunAudit(AuditTypeQueryModel query)
        {
            int code = 0;

            if (query.OrderSourceType == OrderSourceTypeEnum.Flt)
            {
                AuditFltOrderQueryModel fltOrderQuery = new AuditFltOrderQueryModel().ConvertFatherToSon(query);
                var result = _auditFltOrderBll.RunAudit(fltOrderQuery);
                return(result);
            }
            if (query.OrderSourceType == OrderSourceTypeEnum.FltModApply)
            {
                AuditFltModApplyQueryModel fltModApplyQueryModel =
                    new AuditFltModApplyQueryModel().ConvertFatherToSon(query);
                var result = _auditFltModApplyBll.RunAudit(fltModApplyQueryModel);
                return(result);
            }
            if (query.OrderSourceType == OrderSourceTypeEnum.FltRetApply)
            {
                AuditFltRetApplyQueryModel fltRetApplyQueryModel =
                    new AuditFltRetApplyQueryModel().ConvertFatherToSon(query);
                var result = _auditFltRetApplyBll.RunAudit(fltRetApplyQueryModel);
                return(result);
            }

            throw new Exception("审批类型错误");
        }
Beispiel #2
0
        public AuditFltModApplyQueryModel ConvertFatherToSon(AuditTypeQueryModel entity)
        {
            var parentType = typeof(AuditTypeQueryModel);
            var properties = parentType.GetProperties();

            foreach (var propertie in properties)
            {
                if (propertie.CanRead && propertie.CanWrite)
                {
                    propertie.SetValue(this, propertie.GetValue(entity, null), null);
                }
            }

            return(this);
        }
        public AuditOrderResponseViewModel RunAudit(AuditOrderRequestViewModel request)
        {
            //1.根据Cid查询客户信息
            CustomerModel customerModel = _getCustomerServiceBll.GetCustomerByCid(request.Cid);

            if (string.IsNullOrEmpty(customerModel.IsCheckPerson) || customerModel.IsCheckPerson.ToUpper() != "T")
            {
                throw new Exception("当前用户无权审批");
            }

            AuditOrderResponseViewModel responseViewModel = new AuditOrderResponseViewModel();
            AuditTypeQueryModel         query             = new AuditTypeQueryModel()
            {
                OrderSourceType = request.OrderSourceType,
                Cid             = request.Cid,
                Id            = request.Id,
                AuditCustomer = customerModel,
                IsAgree       = request.IsAgree,
                AuditStep     = request.AuditStep
            };

            //机票类型审批
            List <OrderSourceTypeEnum> fltOrderSourceTypeList = new List <OrderSourceTypeEnum>()
            {
                OrderSourceTypeEnum.Flt,
                OrderSourceTypeEnum.FltModApply,
                OrderSourceTypeEnum.FltRetApply
            };

            if (fltOrderSourceTypeList.Contains(query.OrderSourceType))
            {
                using (var transaction = this.Context.Database.BeginTransaction())
                {
                    try
                    {
                        //1.进行审批
                        AuditResultModel auditResultModel = _auditFltOrderServiceBll.RunAudit(query);
                        responseViewModel.Code = auditResultModel.Code;
                        if (auditResultModel.OwnCid != 0)
                        {
                            #region 推送app信息

                            /**
                             * 这里推送app消息分为两种:
                             * 1.推送审核结果给订单所属用户
                             * 2.如果存在下一级审核并且当前审核通过,则推送审核给下一级审核人
                             * */
                            //1.推送审核结果给订单所属用户
                            _addSendAppMessageServiceBll.AddAppAuditResultMessage(new SendAppAuditResultMessageModel()
                            {
                                IsAgree     = request.IsAgree,
                                AuditResult = auditResultModel.AuditResult,
                                Cid         = auditResultModel.OwnCid,
                                OrderId     = auditResultModel.Id,
                                OrderType   = auditResultModel.OrderType,
                                SendType    = SendAppMessageTypeEnum.AuditResultNotice
                            });

                            //2.如果存在下一级审核并且当前审核通过,则推送审核给下一级审核人
                            if (auditResultModel.NextAuditCid.HasValue && request.IsAgree)
                            {
                                _addSendAppMessageServiceBll.AddAppWaitAuditMessage(new SendAppAuditResultMessageModel()
                                {
                                    Cid       = auditResultModel.NextAuditCid.Value,
                                    OrderId   = auditResultModel.Id,
                                    OrderType = auditResultModel.OrderType,
                                    SendType  = SendAppMessageTypeEnum.WaitAuditNotice
                                });
                            }
                            #endregion
                        }

                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        throw;
                    }
                }
            }
            else
            {
                throw new Exception("审批类型不正确!");
            }



            return(responseViewModel);
        }