Exemple #1
0
        public MatchCorpPolicyAndAduitResultModel Match(MatchCorpPolicyAndAduitModel model)
        {
            BaseMatchBll matchBll = null;

            if (model.PassengerCidList == null || model.PassengerCidList.Count == 0) //都是临时客人的情况
            {
                CustomerModel bookingCustomerModel = _getCustomerBll.GetCustomerByCid(model.BookingCid);
                matchBll = new AllTemporaryBll(null, null, bookingCustomerModel, model.IsAllowUserInsurance);
            }
            else
            {
                //根据乘客人id获取部门Id
                List <CustomerModel> customerModels = _getCustomerBll.GetCustomerByCidList(model.PassengerCidList);
                List <int>           departIdList   = new List <int>();
                customerModels.ForEach(n =>
                {
                    if (n.CorpDepartID.HasValue)
                    {
                        departIdList.Add(n.CorpDepartID.Value);
                    }
                });

                departIdList = departIdList.Distinct().ToList();
                if (departIdList.Count == 1) //只有一个部门id,则认为是相同部门
                {
                    matchBll = new SameDepartmentBll(model.PassengerCidList, customerModels, model.IsAllowUserInsurance);
                }
                else
                {
                    matchBll = new DiffDepartmentBll(model.PassengerCidList, customerModels, model.IsAllowUserInsurance);
                }
            }

            IMatchVisitor matchVisitor = new MatchVisitor(_changeInfoFactory, _projectNameDal);

            return(matchBll.DoMatch(matchVisitor));
        }
Exemple #2
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);
        }