예제 #1
0
        /// <summary>
        /// 针对所有临时客人的匹配规则
        /// </summary>
        /// <param name="matchBll"></param>
        /// <returns></returns>
        public MatchCorpPolicyAndAduitResultModel DoMatch(AllTemporaryBll matchBll)
        {
            /**
             * 不存在冲突,允许下一步
             * 如果要选择差旅政策或审批规则,按照当前预定人的政策和审批规则
             * **/

            MatchCorpPolicyAndAduitResultModel resultModel = new MatchCorpPolicyAndAduitResultModel()
            {
                IsConflict     = false,
                ChangeInfoList = new List <CorpPolicyAndAduitChangeModel>()
            };

            //按照当前预定人的政策和审批规则
            if (matchBll.BookingCustomerModel.CorpDepartID.HasValue &&
                !string.IsNullOrEmpty(matchBll.BookingCustomerModel.DepartmentName))
            {
                CorpPolicyAndAduitChangeModel changeInfo = new CorpPolicyAndAduitChangeModel();
                changeInfo.DepartmentId         = matchBll.BookingCustomerModel.CorpDepartID;
                changeInfo.DepartmentName       = matchBll.BookingCustomerModel.DepartmentName;
                changeInfo.CorpPolicyChangeList =
                    _changeInfoFactory.GetCorpPolicyChangeInfo(matchBll.BookingCustomerModel.Cid,
                                                               matchBll.BookingCustomerModel.CorpDepartID.Value, matchBll.IsAllowUserInsurance);
                changeInfo.CorpAduitChangeList =
                    _changeInfoFactory.GetCorpAduitChangeInfo(matchBll.BookingCustomerModel.Cid,
                                                              matchBll.BookingCustomerModel.CorpDepartID.Value);
                resultModel.ChangeInfoList.Add(changeInfo);

                //放开部门限制
                AddOtherChangeInfo(matchBll.BookingCustomerModel.CorpID,
                                   new List <int>()
                {
                    matchBll.BookingCustomerModel.CorpDepartID.Value
                }, resultModel.ChangeInfoList,
                                   matchBll.IsAllowUserInsurance);


                #region 获取项目成本中心
                List <ProjectNameEntity> projectNameEntities = _projectNameDal.Query <ProjectNameEntity>(
                    n => n.CorpId.ToLower() == matchBll.BookingCustomerModel.CorpID.ToLower() && n.IsDelete == "F")
                                                               .ToList();
                List <int> projectIdList = projectNameEntities.Select(n => n.ProjectId)
                                           .Distinct()
                                           .ToList();



                if (projectIdList != null && projectIdList.Count > 0)
                {
                    resultModel.ProjectChangeInfoList = new List <CorpPolicyAndAduitChangeProjectModel>();

                    foreach (var projectId in projectIdList)
                    {
                        var project = projectNameEntities.Find(n => n.ProjectId == projectId);
                        CorpPolicyAndAduitChangeProjectModel p = new CorpPolicyAndAduitChangeProjectModel();
                        p.ProjectId            = projectId;
                        p.ProjectName          = project.ProjectName;
                        p.CorpPolicyChangeList =
                            _changeInfoFactory.GetCorpPolicyChangeInfoByProjectId(projectId,
                                                                                  matchBll.IsAllowUserInsurance);
                        p.CorpAduitChangeList = _changeInfoFactory.GetCorpAduitChangeInfoByProjectId(projectId);

                        resultModel.ProjectChangeInfoList.Add(p);
                    }
                }
                #endregion
            }



            return(resultModel);
        }