コード例 #1
0
        public int Copy(int copyFromOrderId, int newOrderId)
        {
            CorpAduitOrderDetailEntity copyAduitOrderDetailEntity =
                _corpAduitOrderDetailDal.Query <CorpAduitOrderDetailEntity>(
                    n => n.OrderId == copyFromOrderId, true).FirstOrDefault();

            if (copyAduitOrderDetailEntity != null)
            {
                #region 获取原始审批单
                CorpAduitOrderEntity copyCorpAduitOrderEntity =
                    _corpAduitOrderDal.Find <CorpAduitOrderEntity>(copyAduitOrderDetailEntity.AduitOrderId);

                List <CorpAduitOrderDetailEntity> copyCorpAduitOrderDetailEntities =
                    _corpAduitOrderDetailDal.Query <CorpAduitOrderDetailEntity>(
                        n => n.AduitOrderId == copyCorpAduitOrderEntity.AduitOrderId, true).ToList();

                List <CorpAduitOrderFlowEntity> copyCorpAduitOrderFlowEntities =
                    _corpAduitOrderFlowDal.Query <CorpAduitOrderFlowEntity>(
                        n => n.AduitOrderId == copyCorpAduitOrderEntity.AduitOrderId, true).ToList();

                List <CorpAduitOrderLogEntity> copyCorpAduitOrderLogEntities =
                    _corpAduitOrderLogDal.Query <CorpAduitOrderLogEntity>(
                        n => n.AduitOrderId == copyCorpAduitOrderEntity.AduitOrderId, true).ToList();
                #endregion

                #region  制原始审批单
                CorpAduitOrderEntity corpAduitOrderEntity =
                    Mapper.Map <CorpAduitOrderEntity, CorpAduitOrderEntity>(copyCorpAduitOrderEntity);
                corpAduitOrderEntity = _corpAduitOrderDal.Insert(corpAduitOrderEntity);

                List <CorpAduitOrderDetailEntity> corpAduitOrderDetailEntities =
                    Mapper.Map <List <CorpAduitOrderDetailEntity>, List <CorpAduitOrderDetailEntity> >(
                        copyCorpAduitOrderDetailEntities);
                foreach (var corpAduitOrderDetailEntity in corpAduitOrderDetailEntities)
                {
                    corpAduitOrderDetailEntity.AduitOrderId = corpAduitOrderEntity.AduitOrderId;
                    corpAduitOrderDetailEntity.OrderId      = newOrderId;
                    _corpAduitOrderDetailDal.Insert(corpAduitOrderDetailEntity);
                }

                List <CorpAduitOrderFlowEntity> corpAduitOrderFlowEntities =
                    Mapper.Map <List <CorpAduitOrderFlowEntity>, List <CorpAduitOrderFlowEntity> >(
                        copyCorpAduitOrderFlowEntities);
                foreach (var corpAduitOrderFlowEntity in corpAduitOrderFlowEntities)
                {
                    corpAduitOrderFlowEntity.AduitOrderId = corpAduitOrderEntity.AduitOrderId;
                    _corpAduitOrderFlowDal.Insert(corpAduitOrderFlowEntity);
                }

                List <CorpAduitOrderLogEntity> corpAduitOrderLogEntities =
                    Mapper.Map <List <CorpAduitOrderLogEntity>, List <CorpAduitOrderLogEntity> >(
                        copyCorpAduitOrderLogEntities);
                foreach (var corpAduitOrderLogEntity in corpAduitOrderLogEntities)
                {
                    corpAduitOrderLogEntity.AduitOrderId = corpAduitOrderEntity.AduitOrderId;
                    _corpAduitOrderLogDal.Insert(corpAduitOrderLogEntity);
                }
                #endregion

                return(corpAduitOrderEntity.AduitOrderId);
            }

            return(0);
        }
コード例 #2
0
        public GetAppMessageResultModel GetUnReadMessage(GetAppMessageQueryModel query)
        {
            int type = (int)SendAppMessageTypeEnum.SendRunPrintFltTicketEmail;
            GetAppMessageResultModel          resultModel = new GetAppMessageResultModel();
            IQueryable <SendAppMessageEntity> iQueryable  =
                _sendAppMessageDal.Query <SendAppMessageEntity>(
                    n =>
                    n.Cid == query.Cid && n.SendStatus == 1 && !string.IsNullOrEmpty(n.SendContent) &&
                    n.SendType != type, true);

            resultModel.TotalCount = iQueryable.Count();//查询所有结果的数量

            iQueryable =
                iQueryable.OrderBy(n => n.IsRead ?? 0).ThenByDescending(n => n.SendLastTime).Skip(query.PageSize * (query.PageIndex - 1)).Take(query.PageSize);

            List <SendAppMessageEntity> sendAppMessageEntities = iQueryable.ToList();

            resultModel.AppMessageList =
                Mapper.Map <List <SendAppMessageEntity>, List <SendAppMessageModel> >(sendAppMessageEntities);

            if (resultModel.AppMessageList != null && resultModel.AppMessageList.Count > 0)
            {
                foreach (var sendAppMessageModel in resultModel.AppMessageList)
                {
                    if (sendAppMessageModel.OrderType == OrderSourceTypeEnum.FltMod)
                    {
                        FltModOrderEntity fltModOrderEntity =
                            base.Context
                            .Set <FltModOrderEntity>()
                            .FirstOrDefault(n => n.Rmid == sendAppMessageModel.OrderId);
                        if (fltModOrderEntity != null && fltModOrderEntity.RootRmid.HasValue)
                        {
                            sendAppMessageModel.OrderId = fltModOrderEntity.RootRmid.Value;
                        }
                    }
                    else if (sendAppMessageModel.OrderType == OrderSourceTypeEnum.FltRet)
                    {
                        FltRefundOrderEntity fltRefundOrderEntity =
                            base.Context
                            .Set <FltRefundOrderEntity>()
                            .FirstOrDefault(n => n.RefundId == sendAppMessageModel.OrderId);
                        if (fltRefundOrderEntity != null && fltRefundOrderEntity.Rmid.HasValue)
                        {
                            sendAppMessageModel.OrderId = fltRefundOrderEntity.Rmid.Value;
                        }
                    }
                    else if (sendAppMessageModel.OrderType == OrderSourceTypeEnum.AduitOrder)
                    {
                        if (sendAppMessageModel.SendType == SendAppMessageTypeEnum.AuditResultNotice ||
                            sendAppMessageModel.SendType == SendAppMessageTypeEnum.AuditOrderDeleteNotice)
                        {
                            CorpAduitOrderDetailEntity corpAduitOrderDetailEntity =
                                base.Context.Set <CorpAduitOrderDetailEntity>()
                                .FirstOrDefault(n => n.AduitOrderId == sendAppMessageModel.OrderId);
                            if (corpAduitOrderDetailEntity != null)
                            {
                                sendAppMessageModel.OrderId = corpAduitOrderDetailEntity.OrderId;
                            }
                        }
                    }
                    else if (sendAppMessageModel.OrderType == OrderSourceTypeEnum.TraRet)
                    {
                        TraOrderEntity traRetOrderEntity =
                            base.Context.Set <TraOrderEntity>()
                            .FirstOrDefault(n => n.OrderId == sendAppMessageModel.OrderId);
                        if (traRetOrderEntity != null && traRetOrderEntity.OrderRoot.HasValue)
                        {
                            sendAppMessageModel.OrderId = traRetOrderEntity.OrderRoot.Value;
                        }
                    }
                    else if (sendAppMessageModel.OrderType == OrderSourceTypeEnum.TraMod)
                    {
                        TraModOrderEntity traModOrderEntity =
                            base.Context.Set <TraModOrderEntity>()
                            .FirstOrDefault(n => n.CorderId == sendAppMessageModel.OrderId);

                        if (traModOrderEntity != null && traModOrderEntity.OrderId.HasValue)
                        {
                            sendAppMessageModel.OrderId = traModOrderEntity.OrderId.Value;
                        }
                    }
                }
            }

            //if (query.PageIndex == 1)
            //{
            //    //获取未读信息
            //    List<SendAppMessageEntity> unReadList =
            //        _sendAppMessageDal.Query<SendAppMessageEntity>(
            //            n => n.Cid == query.Cid && n.SendStatus == 1 && (n.IsRead ?? 0) == 0, true).ToList();
            //    List<int> unReadIdList = unReadList.Select(n => n.SendId).ToList();
            //    //将未读信息设置为已读
            //    if (unReadIdList != null && unReadIdList.Count > 0)
            //    {
            //        foreach (var unReadId in unReadIdList)
            //        {
            //            _sendAppMessageDal.Update<SendAppMessageEntity>(new SendAppMessageEntity()
            //            {
            //                SendId = unReadId,
            //                IsRead = 1
            //            }, new[] {"IsRead"});
            //        }
            //    }

            //}

            return(resultModel);
        }