Exemplo n.º 1
0
        public GetSelectHouseInfoResult Post(GetSelectHouseInfoRequestModel req)
        {
            Logger.LogDebug("GetSelectHouseInfo Request:" + JsonHelper.SerializeObject(req), "GetSelectHouseInfoController", "Post");
            var ret = new GetSelectHouseInfoResult()
            {
                Code   = 0,
                ErrMsg = ""
            };

            try
            {
                if (_projectBLL.GetModels(x => x.ID == req.ProjectID).FirstOrDefault() == null)
                {
                    ret.Code   = 201;
                    ret.ErrMsg = "项目ID不存在!";
                }
                if (_subscriberBLL.GetModels(x => x.ID == req.SubscriberID).FirstOrDefault() == null)
                {
                    ret.Code   = 202;
                    ret.ErrMsg = "认购人ID不存在!";
                }
                else
                {
                    var selectResult = _selectionBLL.GetModels(x => x.ProjectID == req.ProjectID && x.SubscriberID == req.SubscriberID).FirstOrDefault();
                    if (selectResult != null)
                    {
                        var _hs       = _houseBLL.GetModels(x => x.ID == selectResult.HouseID).FirstOrDefault();
                        var houseInfo = new HouseAndEstateEntity()
                        {
                            HouseEstateName     = _hs.HouseEstate.Name,
                            SerialNumber        = _hs.SerialNumber,
                            Group               = _hs.HouseGroup.Name,
                            Block               = _hs.Block,
                            Building            = _hs.Building,
                            Unit                = _hs.Unit,
                            RoomNumber          = _hs.RoomNumber,
                            Toward              = _hs.Toward,
                            RoomType            = _hs.RoomType.Name,
                            EstimateBuiltUpArea = _hs.EstimateBuiltUpArea,
                            EstimateLivingArea  = _hs.EstimateLivingArea,
                            AreaUnitPrice       = _hs.AreaUnitPrice,
                            TotalPrice          = _hs.TotalPrice
                        };
                        ret.HouseInfo = houseInfo;
                    }
                    else
                    {
                        ret.Code   = 203;
                        ret.ErrMsg = "该认购人未在该项目中选房!";
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("获取选房详情发生", "GetSelectHouseInfoController", "Post", ex);
                ret.Code   = 999;
                ret.ErrMsg = ex.Message;
            }
            return(ret);
        }
 public BaseResultEntity Post(ProjectEntity Project)
 {
     Logger.LogDebug("AddProject Request:" + JsonHelper.SerializeObject(Project), "AddProjectController", "Post");
     BaseResultEntity ret = new BaseResultEntity();
     try
     {
         var _existProject = _projectBLL.GetModels(x => x.Number == Project.Number || x.Name == Project.Name).ToList();
         if (_existProject == null || _existProject.Count() == 0)
         {
             var _area = _areaBLL.GetModels(x => x.Name == Project.ProjectArea).FirstOrDefault();
             if (_area != null && _area.ID != 0)
             {
                 if (!string.IsNullOrWhiteSpace(Project.Number) && !string.IsNullOrWhiteSpace(Project.Name))
                 {
                     var _newProject = new Project()
                     {
                         Number = Project.Number,
                         Name = Project.Name,
                         //Address = Project.Address,
                         Address = "",
                         AreaID = _area.ID,
                         DevelopCompany = Project.DevelopCompany,
                         IdentityNumber = Project.IdentityNumber,
                         CreateTime = DateTime.Now,
                         LastUpdate = DateTime.Now,
                         IsEnd = false,
                         EndReason = null
                     };
                     _projectBLL.Add(_newProject);
                     ret.Code = 0;
                     ret.ErrMsg = "";
                 }
                 else
                 {
                     ret.Code = 102;
                     ret.ErrMsg = "创建项目的编号/名称不允许为空!";
                 }
             }
             else
             {
                 ret.Code = 103;
                 ret.ErrMsg = "项目所属区域不存在!";
             }
         }
         else
         {
             ret.Code = 101;
             ret.ErrMsg = "创建项目的编号/名称已经存在!";
         }
     }
     catch (Exception ex)
     {
         Logger.LogException("创建项目发生异常!", "AddProjectController", "Post", ex);
         ret.Code = 999;
         ret.ErrMsg = ex.Message;
     }
     return ret;
 }
Exemplo n.º 3
0
        public GetHouseEstatesByProjectResultEntity Post(GetHouseEstatesByProjectRequestModel req)
        {
            Logger.LogDebug("GetHousesEstateByProject Request:" + JsonHelper.SerializeObject(req), "GetHouseEstatesByProjectController", "Post");
            GetHouseEstatesByProjectResultEntity ret = new GetHouseEstatesByProjectResultEntity
            {
                Code         = 0,
                ErrMsg       = "",
                HouseEstates = new List <HouseEstateEntity>()
            };

            try
            {
                if (req.ProjectId > 0)
                {
                    var project = _projectBLL.GetModels(p => p.ID == req.ProjectId).FirstOrDefault();

                    if (project == null)
                    {
                        throw (new Exception("项目【" + req.ProjectId + "】不存在!请确认项目信息!"));
                    }

                    var _houseEstates = _houseEstateBLL.GetModels(h => h.ProjectID == req.ProjectId).ToList();
                    if (_houseEstates != null && _houseEstates.Count > 0)
                    {
                        _houseEstates.ForEach(h =>
                        {
                            var houseEstate = new HouseEstateEntity()
                            {
                                HouseEstateID   = h.ID,
                                HouseEstateName = h.Name,
                                ProjectName     = project.Name,
                                ProjectNumber   = project.Number
                            };
                            ret.HouseEstates.Add(houseEstate);
                        });
                    }
                }
                else
                {
                    Logger.LogWarning("项目id" + req.ProjectId + "无效,请校验后重新请求。", "GetHouseEstatesByProjectController", "post");
                    ret.Code   = 2;
                    ret.ErrMsg = "参数错误。";
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("获取项目列表时发生异常!", "GetHouseEstatesByProjectController", "Post", ex);
                ret.Code   = 999;
                ret.ErrMsg = ex.Message;
            }

            return(ret);
        }
Exemplo n.º 4
0
        public GetProjectGroupResultEntity Post(GetProjectGroupRequestModel req)
        {
            Logger.LogDebug("GetProjectGroup Request:" + JsonHelper.SerializeObject(req), "GetProjectGroupController", "Post");
            GetProjectGroupResultEntity ret = new GetProjectGroupResultEntity()
            {
                Code   = 0,
                ErrMsg = ""
            };

            try
            {
                var _dbProGrpList = new List <ProjectGroup>();
                if (req.ProjectID == 0)//获取所有
                {
                    _dbProGrpList   = _projectGroupBLL.GetModelsByPage(req.PageSize, req.PageIndex, true, x => x.ID, x => 1 == 1).ToList();
                    ret.RecordCount = _projectGroupBLL.GetModels(x => 1 == 1).Count();
                }
                else
                {
                    if (_projectBLL.GetModels(x => x.ID == req.ProjectID).FirstOrDefault() == null)
                    {
                        ret.Code   = 201;
                        ret.ErrMsg = "项目ID不存在!";
                    }
                    else
                    {
                        _dbProGrpList   = _projectGroupBLL.GetModelsByPage(req.PageSize, req.PageIndex, true, x => x.ID, x => x.ProjectID == req.ProjectID).ToList();
                        ret.RecordCount = _projectGroupBLL.GetModels(x => x.ProjectID == req.ProjectID).Count();
                    }
                }
                var _proGrpList = new List <ProjectGroupEntity>();
                foreach (var proGrp in _dbProGrpList)
                {
                    var grp = new ProjectGroupEntity()
                    {
                        ProjectID        = proGrp.Project.ID,
                        ProjectNumber    = proGrp.Project.Number,
                        ProjectName      = proGrp.Project.Name,
                        ProjectGroupID   = proGrp.ID,
                        ProjectGroupName = proGrp.ProjectGroupName
                    };
                    _proGrpList.Add(grp);
                }
                ret.ProjectGroupList = _proGrpList;
            }
            catch (Exception ex)
            {
                Logger.LogException("获取项目分组时发生异常!", "GetProjectGroupController", "Post", ex);
                ret.Code   = 999;
                ret.ErrMsg = ex.Message;
            }
            return(ret);
        }
Exemplo n.º 5
0
        public ProjectListResultEntity Post(SearchRequestModel Search)
        {
            Logger.LogDebug("GetProjects Request:" + JsonHelper.SerializeObject(Search), "GetProjectsController", "Post");
            ProjectListResultEntity ret = new ProjectListResultEntity();

            try
            {
                var lstProject = _projectBLL.GetModelsByPage(Search.PageSize, Search.PageIndex, true, x => x.ID, x => x.Number.Contains(Search.SearchStr) || x.Name.Contains(Search.SearchStr)).ToList();
                //List<Project> tmp1 = new List<Project>();
                //List<Project> tmp2 = new List<Project>();
                //if (!string.IsNullOrWhiteSpace(Search.SearchStr))
                //{
                //    tmp1 = lstProject.Where(x => x.Number.Contains(Search.SearchStr)).ToList();
                //    tmp2 = lstProject.Where(x => x.Name.Contains(Search.SearchStr)).ToList();
                //}
                ret.ProjectList = new List <ProjectEntity>();
                foreach (var p in lstProject)
                {
                    ProjectEntity retP = new ProjectEntity()
                    {
                        ID             = p.ID,
                        Number         = p.Number,
                        Name           = p.Name,
                        Address        = p.Address,
                        ProjectArea    = p.Area.Name,
                        DevelopCompany = p.DevelopCompany,
                        IdentityNumber = p.IdentityNumber,
                        IsEnd          = p.IsEnd,
                        EndReason      = p.EndReason
                    };
                    ret.ProjectList.Add(retP);
                }
                ret.Code        = 0;
                ret.ErrMsg      = "";
                ret.RecordCount = _projectBLL.GetModels(x => x.Number.Contains(Search.SearchStr) || x.Name.Contains(Search.SearchStr)).Count();
            }
            catch (Exception ex)
            {
                Logger.LogException("获取项目列表发生异常!", "", "", ex);
                ret.Code        = 999;
                ret.ErrMsg      = ex.Message;
                ret.ProjectList = null;
            }
            return(ret);
        }
Exemplo n.º 6
0
        public ProjectResultEntity Post(GetProjectByIDRequestModel ProjectID)
        {
            Logger.LogDebug("GetProjectByID Request:" + JsonHelper.SerializeObject(ProjectID), "GetProjectByIDController", "Post");
            ProjectResultEntity ret = new ProjectResultEntity();

            try
            {
                var _project = _projectBLL.GetModels(x => x.ID == ProjectID.ProjectID).FirstOrDefault();
                if (_project != null)
                {
                    ret.Project = new ProjectEntity()
                    {
                        ID             = _project.ID,
                        Number         = _project.Number,
                        Name           = _project.Name,
                        Address        = _project.Address,
                        ProjectArea    = _project.Area.Name,
                        DevelopCompany = _project.DevelopCompany,
                        IdentityNumber = _project.IdentityNumber,
                        IsEnd          = _project.IsEnd,
                        EndReason      = _project.EndReason
                    };
                    ret.Code   = 0;
                    ret.ErrMsg = "";
                }
                else
                {
                    ret.Code   = 104;
                    ret.ErrMsg = "查询的项目ID不存在";
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("获取项目列表发生异常!", "", "", ex);
                ret.Code    = 999;
                ret.ErrMsg  = ex.Message;
                ret.Project = null;
            }
            return(ret);
        }
Exemplo n.º 7
0
        public ProjectListResultEntity Post(BaseRequestModel baseRequest)
        {
            Logger.LogDebug("GetAllProjects Request:" + JsonHelper.SerializeObject(baseRequest), "GetAllProjectsController", "Post");
            ProjectListResultEntity ret = new ProjectListResultEntity();

            try
            {
                var lstProject = _projectBLL.GetModelsByPage(baseRequest.PageSize, baseRequest.PageIndex, true, p => p.ID, x => 1 == 1).ToList();
                ret.ProjectList = new List <ProjectEntity>();
                foreach (var p in lstProject)
                {
                    ProjectEntity retP = new ProjectEntity()
                    {
                        ID             = p.ID,
                        Number         = p.Number,
                        Name           = p.Name,
                        Address        = p.Address,
                        ProjectArea    = p.Area.Name,
                        DevelopCompany = p.DevelopCompany,
                        IdentityNumber = p.IdentityNumber,
                        IsEnd          = p.IsEnd,
                        EndReason      = p.EndReason
                    };
                    ret.ProjectList.Add(retP);
                }
                ret.Code        = 0;
                ret.ErrMsg      = "";
                ret.RecordCount = _projectBLL.GetModels(x => 1 == 1).Count();
            }
            catch (Exception ex)
            {
                Logger.LogException("获取项目列表发生异常!", "", "", ex);
                ret.Code        = 999;
                ret.ErrMsg      = ex.Message;
                ret.ProjectList = null;
            }
            return(ret);
        }
        public BaseResultEntity Post(CloseProjectRequestModel req)
        {
            var ret = new BaseResultEntity()
            {
                Code   = 0,
                ErrMsg = ""
            };

            try
            {
                var _existProject = _projectBLL.GetModels(x => x.ID == req.ProjectID).FirstOrDefault();
                if (_existProject == null)
                {
                    ret.Code   = 104;
                    ret.ErrMsg = "关闭的项目ID不存在!";
                }
                else if (_existProject.IsEnd)
                {
                    ret.Code   = 105;
                    ret.ErrMsg = "已经结束的项目不允许再次关闭!";
                }
                else
                {
                    _existProject.LastUpdate = DateTime.Now;
                    _existProject.IsEnd      = true;
                    _existProject.EndReason  = req.EndReason;
                    _projectBLL.Update(_existProject);
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("关闭项目时发生异常!", "CloseProjectController", "Post", ex);
                ret.Code   = 999;
                ret.ErrMsg = ex.Message;
            }
            return(ret);
        }
Exemplo n.º 9
0
        public BaseResultEntity Post(AddFrontEndAccountRequestModel req)
        {
            Logger.LogDebug("AddFrontEndAccount Request:" + JsonHelper.SerializeObject(req), "AddFrontEndAccountController", "Post");
            var ret = new BaseResultEntity()
            {
                Code   = 0,
                ErrMsg = ""
            };

            try
            {
                foreach (int i in req.ProjectID)
                {
                    if (_projectBLL.GetModels(x => x.ID == i).FirstOrDefault() == null)
                    {
                        ret.Code   = 201;
                        ret.ErrMsg = "项目ID不存在!";
                        return(ret);
                    }
                }
                if (string.IsNullOrWhiteSpace(req.Account) || string.IsNullOrWhiteSpace(req.Password))
                {
                    ret.Code   = 601;
                    ret.ErrMsg = "账号或密码不允许为空!";
                }
                else if (_frontBLL.GetModels(x => x.Account == req.Account).FirstOrDefault() != null)
                {
                    ret.Code   = 602;
                    ret.ErrMsg = "账号已存在!";
                }
                else
                {
                    var _dbAccount = new FrontEndAccount()
                    {
                        //ProjectID = req.ProjectID,
                        Account    = req.Account,
                        Password   = req.Password.ToUpper(),
                        CreateTime = DateTime.Now,
                        LastUpdate = DateTime.Now
                    };
                    _frontBLL.Add(_dbAccount);

                    var _dbMapList = new List <FrontEndAccountProjectMapping>();
                    foreach (int i in req.ProjectID)
                    {
                        var _dbMap = new FrontEndAccountProjectMapping()
                        {
                            ProjectID         = i,
                            FrontEndAccountID = _dbAccount.ID,
                            CreateTime        = DateTime.Now,
                            LastUpdate        = DateTime.Now
                        };
                        _dbMapList.Add(_dbMap);
                    }
                    _frontMapBLL.AddRange(_dbMapList);
                }
            }
            catch (Exception ex)
            {
                //var acc = _frontBLL.GetModels(x => x.Account == req.Account).FirstOrDefault();
                //if (acc != null)
                //{
                //    _frontBLL.Delete(acc);
                //}
                Logger.LogException("添加前台账号时发生异常!", "AddFrontEndAccountController", "Post", ex);
                ret.Code   = 999;
                ret.ErrMsg = ex.Message;
            }
            return(ret);
        }
        public GetProjectRoleBaseInfoResultEntity Post(GetProjectRoleBaseInfoRequestModel req)
        {
            Logger.LogDebug("GetProjectRoleBaseInfo Request:" + JsonHelper.SerializeObject(req), "GetProjectRoleBaseInfoController", "Post");
            var ret = new GetProjectRoleBaseInfoResultEntity()
            {
                Code   = 0,
                ErrMsg = ""
            };

            try
            {
                if (_projectBLL.GetModels(x => x.ID == req.ProjectID).FirstOrDefault() == null)
                {
                    ret.Code   = 201;
                    ret.ErrMsg = "项目ID不存在!";
                }
                else
                {
                    var _dbprojectGroupList = _projectGroupBLL.GetModels(x => x.ProjectID == req.ProjectID).ToList();
                    var _projectGroupList   = new List <ProjectGroupSingleEntity>();
                    foreach (var proGrp in _dbprojectGroupList)
                    {
                        var _proGrp = new ProjectGroupSingleEntity()
                        {
                            ProjectGroupID   = proGrp.ID,
                            ProjectGroupName = proGrp.ProjectGroupName
                        };
                        _projectGroupList.Add(_proGrp);
                    }
                    ret.ProjectGroupList = _projectGroupList;

                    var _dbroomTypeList = _houseBLL.GetModels(x => x.ProjectID == req.ProjectID).Select(x => x.RoomType).Distinct().OrderBy(x => x.ID).ToList();
                    var _roomTypeList   = new List <RoomTypeEntity>();
                    foreach (var room in _dbroomTypeList)
                    {
                        var _room = new RoomTypeEntity()
                        {
                            RoomTypeID   = room.ID,
                            RoomTypeName = room.Name
                        };
                        _roomTypeList.Add(_room);
                    }
                    ret.RoomTypeList = _roomTypeList;

                    var _dbhouseGroupList = _houseGroupBLL.GetModels(x => x.ProjectID == req.ProjectID).ToList();
                    var _houseGroupList   = new List <HouseGroupEntity>();
                    foreach (var houseGroup in _dbhouseGroupList)
                    {
                        var _houseGroup = new HouseGroupEntity()
                        {
                            HouseGroupID   = houseGroup.ID,
                            HouseGroupName = houseGroup.Name
                        };
                        _houseGroupList.Add(_houseGroup);
                    }
                    ret.HouseGroupList = _houseGroupList;

                    var _dbfamilyNumberList = _subscriberMapping.GetModels(x => x.ProjectID == req.ProjectID).Select(x => x.Subscriber.FamilyMemberNumber + 1).Distinct().ToList();
                    ret.FamilyNumber = _dbfamilyNumberList;
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("", "", "", ex);
                ret.Code   = 999;
                ret.ErrMsg = ex.Message;
            }
            return(ret);
        }
Exemplo n.º 11
0
        public BaseResultEntity Post(EditFrontEndAccountRequestModel req)
        {
            Logger.LogDebug("EditFrontEndAccountPassword Request:" + JsonHelper.SerializeObject(req), "EditFrontEndAccountPasswordController", "Post");
            var ret = new BaseResultEntity()
            {
                Code   = 0,
                ErrMsg = ""
            };

            try
            {
                foreach (int i in req.ProjectID)
                {
                    if (_projectBLL.GetModels(x => x.ID == i).FirstOrDefault() == null)
                    {
                        ret.Code   = 201;
                        ret.ErrMsg = "项目ID不存在!";
                        return(ret);
                    }
                }

                var _dbAccount = _frontBLL.GetModels(x => x.ID == req.AccountID).FirstOrDefault();
                if (string.IsNullOrWhiteSpace(req.Account) || string.IsNullOrWhiteSpace(req.Password) || string.IsNullOrWhiteSpace(req.BeforePassword))
                {
                    ret.Code   = 601;
                    ret.ErrMsg = "账号或密码不允许为空!";
                }
                else if (_dbAccount == null)
                {
                    ret.Code   = 603;
                    ret.ErrMsg = "账号ID不存在!";
                }
                else if (_dbAccount.Account != req.Account)
                {
                    ret.Code   = 604;
                    ret.ErrMsg = "账号名称不匹配!";
                }
                else if (_dbAccount.Password.ToUpper() != req.BeforePassword.ToUpper())
                {
                    ret.Code   = 605;
                    ret.ErrMsg = "原密码错误!";
                }
                else
                {
                    _dbAccount.Password = req.Password.ToUpper();
                    _frontBLL.Update(_dbAccount);
                }

                //先删
                var _dbMapList = _frontMapBLL.GetModels(x => x.FrontEndAccountID == req.AccountID).ToList();
                _frontMapBLL.DeleteRange(_dbMapList);
                //后插
                var _dbNewMapList = new List <FrontEndAccountProjectMapping>();
                foreach (int i in req.ProjectID)
                {
                    var _dbMap = new FrontEndAccountProjectMapping()
                    {
                        ProjectID         = i,
                        FrontEndAccountID = _dbAccount.ID,
                        CreateTime        = DateTime.Now,
                        LastUpdate        = DateTime.Now
                    };
                    _dbNewMapList.Add(_dbMap);
                }
                _frontMapBLL.AddRange(_dbNewMapList);
            }
            catch (Exception ex)
            {
                Logger.LogException("修改前台账号时发生异常!", "EditFrontEndAccountPasswordController", "Post", ex);
                ret.Code   = 999;
                ret.ErrMsg = ex.Message;
            }
            return(ret);
        }
Exemplo n.º 12
0
        public BaseResultEntity Post(AddSelectRoleRequestEntity req)
        {
            Logger.LogDebug("AddSelectRole Request:" + JsonHelper.SerializeObject(req), "AddSelectRoleController", "Post");
            var ret = new BaseResultEntity()
            {
                Code   = 0,
                ErrMsg = ""
            };

            try
            {
                if (_projectBLL.GetModels(x => x.ID == req.ProjectID).FirstOrDefault() == null)
                {
                    ret.Code   = 201;
                    ret.ErrMsg = "项目ID不存在!";
                }
                else if (req.ProjectGroupAndRoomTypeRoleList == null || req.ProjectGroupAndRoomTypeRoleList.Count() == 0)
                {
                    ret.Code   = 801;
                    ret.ErrMsg = "项目分组与户型规则不能为空!";
                }
                else if (req.FamilyNumberAndRoomTypeRoleList == null || req.FamilyNumberAndRoomTypeRoleList.Count() == 0)
                {
                    ret.Code   = 802;
                    ret.ErrMsg = "家庭人数与户型规则不能为空!";
                }
                else if (req.ProjectGroupAndHouseGroupRoleList == null || req.ProjectGroupAndHouseGroupRoleList.Count() == 0)
                {
                    ret.Code   = 803;
                    ret.ErrMsg = "项目分组与房源分组规则不能为空!";
                }
                else if (_role1BLL.GetModels(x => x.ProjectGroup.ProjectID == req.ProjectID).FirstOrDefault() != null || _role2BLL.GetModels(x => x.ProjectID == req.ProjectID).FirstOrDefault() != null || _role3BLL.GetModels(x => x.ProjectGroup.ProjectID == req.ProjectID).FirstOrDefault() != null)
                {
                    ret.Code   = 804;
                    ret.ErrMsg = "该项目已经创建选房规则,请使用修改接口修改!";
                }
                else
                {
                    var dbRole1List = new List <RoleProjectGroupAndRoomType>();
                    foreach (var _role1 in req.ProjectGroupAndRoomTypeRoleList)
                    {
                        var dbRole1 = new RoleProjectGroupAndRoomType()
                        {
                            ProjectGroupID = _role1.ProjectGroupID,
                            RoomTypeID     = _role1.RoomTypeID,
                            CreateTime     = DateTime.Now,
                            LastUpdate     = DateTime.Now
                        };
                        dbRole1List.Add(dbRole1);
                    }

                    var dbRole2List = new List <RoleFamilyNumberAndRoomType>();
                    foreach (var _role2 in req.FamilyNumberAndRoomTypeRoleList)
                    {
                        var dbRole2 = new RoleFamilyNumberAndRoomType()
                        {
                            ProjectID    = req.ProjectID,
                            FamilyNumber = _role2.FamilyNumber,
                            RoomTypeID   = _role2.RoomTypeID,
                            CreateTime   = DateTime.Now,
                            LastUpdate   = DateTime.Now
                        };
                        dbRole2List.Add(dbRole2);
                    }

                    var dbRole3List = new List <RoleProjectGroupAndHouseGroup>();
                    foreach (var _role3 in req.ProjectGroupAndHouseGroupRoleList)
                    {
                        var dbRole3 = new RoleProjectGroupAndHouseGroup()
                        {
                            ProjectGroupID = _role3.ProjectGroupID,
                            HouseGroupID   = _role3.HouseGroupID,
                            CreateTime     = DateTime.Now,
                            LastUpdate     = DateTime.Now
                        };
                        dbRole3List.Add(dbRole3);
                    }

                    _role1BLL.AddRange(dbRole1List);
                    _role2BLL.AddRange(dbRole2List);
                    _role3BLL.AddRange(dbRole3List);
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("创建选房规则时发生异常!", "AddSelectRoleController", "Post", ex);
                ret.Code   = 999;
                ret.ErrMsg = ex.Message;
            }
            return(ret);
        }
        public GetProjectsByAreaResultEntity Post(GetProjectsByAreaRequestModel req)
        {
            Logger.LogDebug("GetProjectsByArea Request:" + JsonHelper.SerializeObject(req), "GetProjectsByAreaController", "Post");
            GetProjectsByAreaResultEntity ret = new GetProjectsByAreaResultEntity
            {
                Code     = 0,
                ErrMsg   = "",
                Projects = new List <ProjectEntity>()
            };

            try
            {
                var _projects = new List <Project>();

                if (req.AreaId > 0)
                {
                    _projects = _projectBLL.GetModels(p => p.AreaID == req.AreaId).ToList();
                }
                else
                {
                    _projects = _projectBLL.GetModels(p => p.ID > 0).ToList();
                }

                if (_projects == null || _projects.Count == 0)
                {
                    ret.Code   = 405;
                    ret.ErrMsg = "没有查询到对应的项目信息。";
                }
                else
                {
                    var areaIds = _projects.Select(p => p.AreaID).Distinct().ToList();
                    var areaDic = new Dictionary <int, string>();
                    areaIds.ForEach(i =>
                    {
                        var areaInfo = _areaBLL.GetModels(a => a.ID == i).FirstOrDefault();
                        if (areaInfo == null)
                        {
                            Logger.LogWarning(string.Format("无法查询到ID为{0}的地区区域信息!请确认数据是否正确!", i), "FetProjectsByAreaController", "Post");
                        }
                        else
                        {
                            areaDic.Add(i, areaInfo.Name);
                        }
                    });

                    _projects.ForEach(p =>
                    {
                        var areaName = string.Empty;
                        areaDic.TryGetValue(p.AreaID, out areaName);

                        var project = new ProjectEntity
                        {
                            ID             = p.ID,
                            Address        = p.Address,
                            Name           = p.Name,
                            Number         = p.Number,
                            ProjectArea    = areaName,
                            IsEnd          = p.IsEnd,
                            EndReason      = p.EndReason,
                            IdentityNumber = p.IdentityNumber,
                            DevelopCompany = p.DevelopCompany
                        };

                        ret.Projects.Add(project);
                    });
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("获取项目列表时发生异常!", "GetProjectsByAreaController", "Post", ex);
                ret.Code   = 999;
                ret.ErrMsg = ex.Message;
            }
            return(ret);
        }
Exemplo n.º 14
0
        public BaseResultEntity Post(ImportSubscriberRequestEntity req)
        {
            Logger.LogDebug("ImportSubscriber Request:" + JsonHelper.SerializeObject(req), "ImportSubscriberController", "Post");
            BaseResultEntity ret = new BaseResultEntity()
            {
                Code   = 0,
                ErrMsg = ""
            };

            try
            {
                #region 请求数据校验
                var _pro = _projectBLL.GetModels(x => x.ID == req.ProjectID).FirstOrDefault();
                if (_pro == null)
                {
                    ret.Code   = 401;
                    ret.ErrMsg = "项目ID不存在!";
                    return(ret);
                }
                else if (req.ProjectGroup == null)
                {
                    ret.Code   = 402;
                    ret.ErrMsg = "项目分组不能为空!";
                    return(ret);
                }
                foreach (var shake in req.ShakingNumberList)
                {
                    if (shake.ShakingNumber == null)
                    {
                        ret.Code   = 403;
                        ret.ErrMsg = "摇号编号不能为空!";
                        return(ret);
                    }
                    if (shake.Subscriber == null)
                    {
                        ret.Code   = 404;
                        ret.ErrMsg = "摇号编号为" + shake.ShakingNumber + "的认购人信息不能为空!";
                        return(ret);
                    }
                    if (shake.ShakingNumberSequance <= 0)
                    {
                        ret.Code   = 405;
                        ret.ErrMsg = "摇号编号为" + shake.ShakingNumber + "摇号序号不能为空或小于1!";
                        return(ret);
                    }
                    if (shake.SelectHouseSequance <= 0)
                    {
                        ret.Code   = 405;
                        ret.ErrMsg = "摇号编号为" + shake.ShakingNumber + "选房序号不能为空或小于1!";
                        return(ret);
                    }
                    if (shake.Subscriber.Name == null || shake.Subscriber.IdentityNumber == null || shake.Subscriber.Telephone == null || shake.Subscriber.Address == null || shake.Subscriber.MaritalStatus == null || shake.Subscriber.ZipCode == null || shake.Subscriber.ResidenceArea == null || shake.Subscriber.WorkArea == null)
                    {
                        ret.Code   = 406;
                        ret.ErrMsg = "摇号编号为" + shake.ShakingNumber + "认购人信息不完整!";
                        return(ret);
                    }
                }
                #endregion

                #region 创建项目分组
                int _projectGroupID = 0;
                try
                {
                    if (_projectGroupBLL.GetModels(x => x.ProjectID == req.ProjectID && x.ProjectGroupName == req.ProjectGroup).FirstOrDefault() == null) //项目分组不存在
                    {
                        var _progrp = new ProjectGroup()
                        {
                            ProjectID        = req.ProjectID,
                            ProjectGroupName = req.ProjectGroup,
                            CreateTime       = DateTime.Now,
                            LastUpdate       = DateTime.Now
                        };
                        _projectGroupBLL.Add(_progrp);
                    }
                    _projectGroupID = _projectGroupBLL.GetModels(x => x.ProjectID == req.ProjectID && x.ProjectGroupName == req.ProjectGroup).FirstOrDefault().ID;
                }
                catch (Exception ex)
                {
                    Logger.LogException("创建项目分组时发生异常!", "ImportSubscriberController", "Post", ex);
                    ret.Code   = 999;
                    ret.ErrMsg = ex.Message;
                    return(ret);
                }
                #endregion

                var _subList      = new List <Subscriber>();
                var _existSubList = new List <Subscriber>();
                var _familyList   = new List <SubscriberFamilyMemberEntity>();
                var _shakeList    = new List <ShakingNumberResult>();
                #region 创建认购人
                var _dbSubList = _subscriberBLL.GetModels(x => 1 == 1).ToList();
                foreach (var shake in req.ShakingNumberList)
                {
                    try
                    {
                        var _sub = _dbSubList.FirstOrDefault(x => x.IdentityNumber == shake.Subscriber.IdentityNumber);
                        if (_sub == null)  //认购人不存在
                        {
                            var _subscriber = new Subscriber()
                            {
                                Name               = shake.Subscriber.Name,
                                IdentityNumber     = shake.Subscriber.IdentityNumber,
                                Telephone          = shake.Subscriber.Telephone,
                                Address            = shake.Subscriber.Address,
                                ZipCode            = shake.Subscriber.ZipCode,
                                MaritalStatus      = shake.Subscriber.MaritalStatus,
                                ResidenceArea      = shake.Subscriber.ResidenceArea,
                                WorkArea           = shake.Subscriber.WorkArea,
                                FamilyMemberNumber = shake.FamilyMemberList == null ? 0 : shake.FamilyMemberList.Count(),
                                CreateTime         = DateTime.Now,
                                LastUpdate         = DateTime.Now
                            };
                            _subList.Add(_subscriber);

                            if (shake.FamilyMemberList != null && shake.FamilyMemberList.Count() > 0)
                            {
                                _familyList.AddRange(shake.FamilyMemberList);
                            }
                        }
                        else
                        {
                            _existSubList.Add(_sub);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogException("创建摇号编号为" + shake.ShakingNumber + "的认购人时发生异常!", "ImportSubscriberController", "Post", ex);
                        ret.Code   = 999;
                        ret.ErrMsg = ex.Message;
                        return(ret);
                    }
                }
                _subscriberBLL.AddRange(_subList);
                #endregion

                #region 创建认购人家庭成员
                var _ttlSubList   = _subscriberBLL.GetModels(x => 1 == 1).ToList();
                var _dbFamilyList = new List <SubscriberFamilyMember>();
                foreach (var family in _familyList)
                {
                    try
                    {
                        var _sub = _ttlSubList.FirstOrDefault(x => x.IdentityNumber == family.SubscriberIdentityNumber);
                        if (_sub != null)
                        {
                            var _fam = new SubscriberFamilyMember()
                            {
                                SubscriberID   = _sub.ID,
                                Name           = family.Name,
                                IdentityNumber = family.IdentityNumber,
                                Relationship   = family.Relationship,
                                Area           = family.Area,
                                CreateTime     = DateTime.Now,
                                LastUpdate     = DateTime.Now
                            };
                            _dbFamilyList.Add(_fam);
                        }
                    }
                    catch (Exception ex)
                    {
                        _subscriberBLL.DeleteRange(_subList);  //回滚新建认购人
                        Logger.LogException("创建身份证为" + family.IdentityNumber + "的认购人家庭成员时发生异常!", "ImportSubscriberController", "Post", ex);
                        ret.Code   = 999;
                        ret.ErrMsg = ex.Message;
                        return(ret);
                    }
                }
                _subscriberFamilyBLL.AddRange(_dbFamilyList);
                #endregion

                #region 创建认购人项目关联关系
                var _subProMapList = new List <SubscriberProjectMapping>();
                foreach (var sub in _subList)//添加新认购人Mapping
                {
                    var _subProMap = new SubscriberProjectMapping()
                    {
                        SubscriberID = sub.ID,
                        ProjectID    = req.ProjectID,
                        CreateTime   = DateTime.Now,
                        LastUpdate   = DateTime.Now
                    };
                    _subProMapList.Add(_subProMap);
                }

                var _existSubMap = _subscriberProjectMapBLL.GetModels(x => x.ProjectID == req.ProjectID).ToList();
                foreach (var sub in _existSubList)//添加已存在认购人Mapping
                {
                    if (!_existSubMap.Any(x => x.SubscriberID == sub.ID))
                    {
                        var _subProMap = new SubscriberProjectMapping()
                        {
                            SubscriberID = sub.ID,
                            ProjectID    = req.ProjectID,
                            CreateTime   = DateTime.Now,
                            LastUpdate   = DateTime.Now
                        };
                        _subProMapList.Add(_subProMap);
                    }
                }
                _subProMapList.OrderBy(x => x.SubscriberID);
                _subscriberProjectMapBLL.AddRange(_subProMapList);
                #endregion

                #region 创建摇号结果
                var _dbSubProMap         = _subscriberProjectMapBLL.GetModels(x => x.ProjectID == req.ProjectID).ToList();
                var _existShakingList    = _shakingNumberBLL.GetModels(x => x.ProjectGroup.ProjectID == req.ProjectID).ToList();
                var _dbshakingNumberList = new List <ShakingNumberResult>();
                foreach (var shake in req.ShakingNumberList)
                {
                    try
                    {
                        var _subProMap = _dbSubProMap.FirstOrDefault(x => x.Subscriber.IdentityNumber == shake.Subscriber.IdentityNumber);
                        if (_subProMap != null && _projectGroupID != 0 && !_existShakingList.Any(x => x.SubscriberProjectMapping.Subscriber.IdentityNumber == shake.Subscriber.IdentityNumber))
                        {
                            var _shake = new ShakingNumberResult()
                            {
                                ProjectGroupID             = _projectGroupID,
                                SubscriberProjectMappingID = _subProMap.ID,
                                ShakingNumberSequance      = shake.ShakingNumberSequance,
                                SelectHouseSequance        = shake.SelectHouseSequance,
                                ShakingNumber = shake.ShakingNumber,
                                NoticeTime    = 0,
                                IsError       = false,
                                IsContacted   = false,
                                IsCallBack    = false,
                                IsMessageSend = false,
                                CreateTime    = DateTime.Now,
                                LastUpdate    = DateTime.Now
                            };
                            _dbshakingNumberList.Add(_shake);
                        }
                    }
                    catch (Exception ex)
                    {
                        _subscriberProjectMapBLL.DeleteRange(_subProMapList);  //回滚新建认购人项目关联
                        Logger.LogException("创建摇号编号为" + shake.ShakingNumber + "的摇号结果时发生异常!", "ImportSubscriberController", "Post", ex);
                        ret.Code   = 999;
                        ret.ErrMsg = ex.Message;
                        return(ret);
                    }
                }
                _shakingNumberBLL.AddRange(_dbshakingNumberList);
                #endregion
            }
            catch (Exception ex)
            {
                Logger.LogException("导入认购人和摇号信息时发生异常!", "ImportSubscriberController", "Post", ex);
                ret.Code   = 999;
                ret.ErrMsg = ex.Message;
            }
            return(ret);
        }
        public SelectHouseLoginResultEntity Post(SelectHouseLoginRequestModel req)
        {
            Logger.LogInfo("SelectHouseLogin Request:" + JsonHelper.SerializeObject(req), "SelectHouseLoginController", "Post");
            var ret = new SelectHouseLoginResultEntity()
            {
                Code              = 0,
                ErrMsg            = string.Empty,
                AcountProjectInfo = new Model.FrontEndAccountEntity()
                {
                    ProjectList = new List <AccountProjectEntity>()
                }
            };

            try
            {
                //var md5Password = MD5Helper.ToMD5(req.LoginPassword);
                var accountInfo = _accountBLL.GetModels(i => i.Account == req.LoginAccount && i.Password == req.LoginPassword).FirstOrDefault();
                if (accountInfo == null)
                {
                    ret.ErrMsg = "登陆失败!账号密码错误";
                }
                else
                {
                    var xxx = HttpContext.Current.Request;
                    // 1.保存登陆记录
                    ret.AcountProjectInfo.Account   = accountInfo.Account;
                    ret.AcountProjectInfo.AccountID = accountInfo.ID;
                    var loginRecord = new FrontEndAccountLoginRecord()
                    {
                        FrontEndAccountID = accountInfo.ID,
                        LoginTime         = DateTime.Now,
                        LoginIP           = HttpContext.Current.Request.UserHostAddress
                    };
                    _loginRecordBLL.Add(loginRecord);

                    // 2.获取项目匹配关系,并获取对应项目信息
                    var mappingProjectIds = _mappingBLL.GetModels(i => i.FrontEndAccountID == accountInfo.ID).Select(i => i.ProjectID).ToList();
                    foreach (var projectId in mappingProjectIds)
                    {
                        var projectInfo = _projectBLL.GetModels(i => i.ID == projectId).FirstOrDefault();
                        if (projectInfo != null)
                        {
                            ret.AcountProjectInfo.ProjectList.Add(new AccountProjectEntity()
                            {
                                ProjectID     = projectInfo.ID,
                                ProjectName   = projectInfo.Name,
                                ProjectNumber = projectInfo.Number,
                                IsEnd         = projectInfo.IsEnd,
                                EndReason     = projectInfo.EndReason
                            });
                        }
                        else
                        {
                            ret.ErrMsg = ret.ErrMsg + "/n" + string.Format("项目{0}没有查询到对应的项目信息,请核对数据。", projectId);
                        }
                    }

                    //3.生成Token
                    var result = new TokenResultEntity();

                    var requestAccount = req.LoginAccount;
                    var requestUserId  = accountInfo.ID;

                    int expiry = 3600;

                    var token = AuthorizeHelper.AddToken(requestUserId, requestAccount, expiry);

                    if (token != null)
                    {
                        result.Code          = (int)InterfaceResultEnum.Success;
                        result.Access_Token  = token.AccessToken;
                        result.Refresh_Token = token.RefreshToken;
                        result.Expiry        = token.Expiry;
                        Logger.LogInfo(string.Format("获取Token成功,AppId:{0},AppSecret:{1},AccessToken:{2}", req.LoginAccount, req.LoginPassword, token.AccessToken), "TokenController", "Post");
                    }
                    else
                    {
                        ret.Code   = (int)InterfaceResultEnum.AppError;
                        ret.ErrMsg = EnumHelper.GetDescription(InterfaceResultEnum.AppError);
                        Logger.LogInfo(string.Format("获取Token失败,AppId:{0},AppSecret:{1}", req.LoginAccount, req.LoginPassword), "TokenController", "Post");
                    }
                    ret.Token = result;
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("前台登陆时发生异常!", "SelectHouseLoginController", "Post", ex);
                ret.Code   = 999;
                ret.ErrMsg = ex.Message;
            }

            return(ret);
        }
Exemplo n.º 16
0
        public BaseResultEntity Post(ProjectEntity req)
        {
            var ret = new BaseResultEntity()
            {
                Code   = 0,
                ErrMsg = ""
            };

            try
            {
                var _existProject = _projectBLL.GetModels(x => x.ID == req.ID).FirstOrDefault();
                if (_existProject == null)
                {
                    ret.Code   = 104;
                    ret.ErrMsg = "修改项目的ID不存在!";
                }
                else if (_existProject.IsEnd)
                {
                    ret.Code   = 105;
                    ret.ErrMsg = "已经结束的项目不允许修改!";
                }
                else
                {
                    if (_projectBLL.GetModels(x => (x.Number == req.Number || x.Name == req.Name) && x.ID != req.ID).FirstOrDefault() != null)
                    {
                        ret.Code   = 106;
                        ret.ErrMsg = "修改项目的编号/名称已经存在!";
                    }
                    else
                    {
                        var _area = _areaBLL.GetModels(x => x.Name == req.ProjectArea).FirstOrDefault();
                        if (_area != null && _area.ID != 0)
                        {
                            if (!string.IsNullOrWhiteSpace(req.Number) && !string.IsNullOrWhiteSpace(req.Name))
                            {
                                _existProject.Number         = req.Number;
                                _existProject.Name           = req.Name;
                                _existProject.Address        = "";
                                _existProject.AreaID         = _area.ID;
                                _existProject.DevelopCompany = req.DevelopCompany;
                                _existProject.IdentityNumber = req.IdentityNumber;
                                _existProject.LastUpdate     = DateTime.Now;
                                _existProject.IsEnd          = false;
                                _existProject.EndReason      = null;
                                _projectBLL.Update(_existProject);
                            }
                            else
                            {
                                ret.Code   = 102;
                                ret.ErrMsg = "修改项目的编号/名称不允许为空!";
                            }
                        }
                        else
                        {
                            ret.Code   = 103;
                            ret.ErrMsg = "项目所属区域不存在!";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("修改项目时发生异常!", "EditProjectController", "Post", ex);
                ret.Code   = 999;
                ret.ErrMsg = ex.Message;
            }
            return(ret);
        }
        public GetSubscriberByIdentityResultEntity Post(GetSubscriberByIdentityRequestModel req)
        {
            Logger.LogDebug("GetSubscriberByIdentity Request:" + JsonHelper.SerializeObject(req), "GetSubscriberByIdentityController", "Post");
            var ret = new GetSubscriberByIdentityResultEntity()
            {
                Code   = 0,
                ErrMsg = ""
            };

            try
            {
                if (_projectBLL.GetModels(x => x.ID == req.ProjectID).FirstOrDefault() == null)
                {
                    ret.Code   = 201;
                    ret.ErrMsg = "项目ID不存在!";
                }
                else
                {
                    var _dbShaking = _shakingBLL.GetModels(x => x.ProjectGroup.ProjectID == req.ProjectID && x.SubscriberProjectMapping.Subscriber.IdentityNumber == req.IdentityNumber).FirstOrDefault();
                    if (_dbShaking == null)
                    {
                        ret.Code   = 202;
                        ret.ErrMsg = "认购人摇号信息不存在!";
                    }
                    else
                    {
                        var _dbPeriod = _selectPeriodBLL.GetModels(x => x.ShakingNumberResultID == _dbShaking.ID).FirstOrDefault();
                        if (_dbPeriod == null)
                        {
                            ret.Code   = 203;
                            ret.ErrMsg = "认购人选房时间段不存在!";
                        }
                        else
                        {
                            var      _selectRecord = _selectRecordBLL.GetModels(x => x.IsAbandon == true && x.SubscriberID == _dbShaking.SubscriberProjectMapping.SubscriberID);
                            DateTime dt            = DateTime.Now.AddMinutes(-30);
                            var      _validPeriod  = _selectPeriodBLL.GetModels(x => x.StartTime >= dt && x.EndTime <= DateTime.Now).FirstOrDefault();

                            ret.ShakingNumberResultID = _dbShaking.ID;
                            ret.Name                  = _dbShaking.SubscriberProjectMapping.Subscriber.Name;
                            ret.IdentityNumber        = _dbShaking.SubscriberProjectMapping.Subscriber.IdentityNumber;
                            ret.ShakingNumberSequance = _dbShaking.ShakingNumberSequance;
                            ret.SelectHouseSequance   = _dbShaking.SelectHouseSequance;
                            ret.ProjectGroup          = _dbShaking.ProjectGroup.ProjectGroupName;
                            ret.StartSelectTime       = _dbPeriod.StartTime.ToString("yyyy-MM-dd HH:mm:ss");
                            ret.EndSelectTime         = _dbPeriod.EndTime.ToString("yyyy-MM-dd HH:mm:ss");
                            ret.IsAuthorized          = _dbShaking.IsAuthorized ? 1 : 0;
                            ret.IsAgent               = _dbShaking.IsAgent ? 1 : 0;
                            if (_dbShaking.IsAuthorized)
                            {
                                ret.Hint = "该认购人已经身份审核过";
                            }
                            else if (_dbShaking.SubscriberProjectMapping.Subscriber.HouseSelectionRecord.Any(x => x.IsConfirm == true && x.IsAbandon == false))
                            {
                                ret.Hint = "该认购人已经确认选房";
                            }
                            else if (_dbShaking.SubscriberProjectMapping.Subscriber.HouseSelectionRecord.Any(x => x.IsAbandon == true))
                            {
                                ret.Hint = "该认购人已经在该项目中发生弃选";
                            }
                            else if (_selectRecord != null && _selectRecord.Count() >= 2)
                            {
                                ret.Hint = "该认购人历史弃选已次超过2次";
                            }
                            else if (_dbPeriod.StartTime < DateTime.Now.AddMinutes(-30) || _dbPeriod.EndTime > DateTime.Now)
                            {
                                ret.Hint = "该认购人不在选房时间段内,实际时间段为" + _dbPeriod.StartTime.ToString("yyyy-MM-dd HH:mm:ss") + " - " + _dbPeriod.EndTime.ToString("yyyy-MM-dd HH:mm:ss");
                            }
                            else if (_validPeriod.ShakingNumberResult.ProjectGroupID != _dbShaking.ProjectGroupID)
                            {
                                ret.Hint = "该认购人不属于该时段分组,实际分组为:" + _validPeriod.ShakingNumberResult.ProjectGroup.ProjectGroupName;
                            }
                            else
                            {
                                ret.Hint = "";
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("按身份证获取认购人信息发生异常!", "GetSubscriberByIdentityController", "Post", ex);
                ret.Code   = 999;
                ret.ErrMsg = ex.Message;
            }
            return(ret);
        }
Exemplo n.º 18
0
        public GetSelectRoleResultEntity Post(GetSelectRoleRequestModel req)
        {
            Logger.LogDebug("GetSelectRoleByProjectID Request:" + JsonHelper.SerializeObject(req), "GetSelectRoleByProjectIDController", "Post");
            var ret = new GetSelectRoleResultEntity()
            {
                Code   = 0,
                ErrMsg = ""
            };

            try
            {
                var role1 = _role1BLL.GetModels(x => x.ProjectGroup.ProjectID == req.ProjectID).ToList();
                var role2 = _role2BLL.GetModels(x => x.ProjectID == req.ProjectID).ToList();
                var role3 = _role3BLL.GetModels(x => x.ProjectGroup.ProjectID == req.ProjectID).ToList();
                if (_projectBLL.GetModels(x => x.ID == req.ProjectID).FirstOrDefault() == null)
                {
                    ret.Code   = 201;
                    ret.ErrMsg = "项目ID不存在!";
                }
                else if (role1.FirstOrDefault() == null || role2.FirstOrDefault() == null || role3.FirstOrDefault() == null)
                {
                    ret.Code   = 805;
                    ret.ErrMsg = "该项目还未创建选房规则!";
                }
                else
                {
                    var role1List = new List <ProjectGroupAndRoomTypeRole>();
                    foreach (var _role1 in role1)
                    {
                        var r1 = new ProjectGroupAndRoomTypeRole()
                        {
                            ProjectGroupID = _role1.ProjectGroupID,
                            RoomTypeID     = _role1.RoomTypeID
                        };
                        role1List.Add(r1);
                    }
                    ret.ProjectGroupAndRoomTypeRoleList = role1List;

                    var role2List = new List <FamilyNumberAndRoomTypeRole>();
                    foreach (var _role2 in role2)
                    {
                        var r2 = new FamilyNumberAndRoomTypeRole()
                        {
                            FamilyNumber = _role2.FamilyNumber,
                            RoomTypeID   = _role2.RoomTypeID
                        };
                        role2List.Add(r2);
                    }
                    ret.FamilyNumberAndRoomTypeRoleList = role2List;

                    var role3List = new List <ProjectGroupAndHouseGroupRole>();
                    foreach (var _role3 in role3)
                    {
                        var r3 = new ProjectGroupAndHouseGroupRole()
                        {
                            ProjectGroupID = _role3.ProjectGroupID,
                            HouseGroupID   = _role3.HouseGroupID
                        };
                        role3List.Add(r3);
                    }
                    ret.ProjectGroupAndHouseGroupRoleList = role3List;
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("获取选房规则时发生异常!", "GetSelectRoleByProjectIDController", "Post", ex);
                ret.Code   = 999;
                ret.ErrMsg = ex.Message;
            }
            return(ret);
        }
        public BaseResultEntity Post(ImportHouseInfoRequestEntity ImportHouse)
        {
            Logger.LogDebug("ImportHouseInfo Request:" + JsonHelper.SerializeObject(ImportHouse), "ImportHouseInfoController", "Post");
            var ret = new BaseResultEntity();

            try
            {
                if (ImportHouse != null && ImportHouse.HouseList != null)
                {
                    if (_projectBLL.GetModels(x => x.ID == ImportHouse.ProjectID) != null)
                    {
                        #region 创建楼盘
                        var _houseEstate = _houseEstateBLL.GetModels(x => x.Name == ImportHouse.HouseEstate);
                        if (_houseEstate == null || _houseEstate.Count() == 0)
                        {
                            _houseEstateBLL.Add(new HouseEstate()
                            {
                                ProjectID = ImportHouse.ProjectID, Name = ImportHouse.HouseEstate, CreateTime = DateTime.Now, LastUpdate = DateTime.Now
                            });
                        }
                        #endregion

                        #region 创建房源分组
                        var           groupList    = ImportHouse.HouseList.GroupBy(x => x.Group).ToList();
                        var           _existGroup  = _houseGroupBLL.GetModels(x => x.ProjectID == ImportHouse.ProjectID);
                        List <string> addGroupList = new List <string>();
                        foreach (var group in groupList)
                        {
                            if (!_existGroup.Any(x => x.Name == group.Key))
                            {
                                if (!addGroupList.Any(x => x == group.Key))
                                {
                                    addGroupList.Add(group.Key);
                                }
                            }
                        }
                        var _hsList = new List <HouseGroup>();
                        foreach (string a in addGroupList)
                        {
                            HouseGroup _hs = new HouseGroup()
                            {
                                ProjectID  = ImportHouse.ProjectID,
                                Name       = a,
                                CreateTime = DateTime.Now,
                                LastUpdate = DateTime.Now
                            };
                            _hsList.Add(_hs);
                        }
                        _houseGroupBLL.AddRange(_hsList);
                        #endregion

                        #region 创建户型
                        var           roomTypeGroupList = ImportHouse.HouseList.GroupBy(x => x.RoomType).ToList();
                        var           _existRoomType    = _roomTypeBLL.GetModels(x => 1 == 1).ToList();
                        List <string> addRoomTypeList   = new List <string>();
                        foreach (var group in roomTypeGroupList)
                        {
                            if (!_existRoomType.Any(x => x.Name == group.Key))
                            {
                                if (!addRoomTypeList.Any(x => x == group.Key))
                                {
                                    addRoomTypeList.Add(group.Key);
                                }
                            }
                        }
                        var _rtList = new List <RoomType>();
                        foreach (string a in addRoomTypeList)
                        {
                            RoomType _rt = new RoomType()
                            {
                                Name       = a,
                                CreateTime = DateTime.Now,
                                LastUpdate = DateTime.Now
                            };
                            _rtList.Add(_rt);
                        }
                        _roomTypeBLL.AddRange(_rtList);
                        #endregion

                        #region 创建房源
                        var _houseGroup    = _houseGroupBLL.GetModels(x => x.ProjectID == ImportHouse.ProjectID);
                        var _roomTypeGroup = _roomTypeBLL.GetModels(x => 1 == 1);
                        var _existhouse    = _houseBLL.GetModels(x => x.ProjectID == ImportHouse.ProjectID);
                        int _houseEstateID = _houseEstateBLL.GetModels(x => x.ProjectID == ImportHouse.ProjectID).FirstOrDefault().ID;

                        List <House> addHouseList = new List <House>();
                        foreach (var house in ImportHouse.HouseList)
                        {
                            if (_existhouse.Any(x => x.SerialNumber == house.SerialNumber))  //去重
                            {
                                continue;
                            }
                            else
                            {
                                int _groupID    = _houseGroup.FirstOrDefault(x => x.Name == house.Group).ID;
                                int _roomTypeID = _roomTypeGroup.FirstOrDefault(x => x.Name == house.RoomType).ID;

                                House _house = new House()
                                {
                                    ProjectID           = ImportHouse.ProjectID,
                                    SerialNumber        = house.SerialNumber,
                                    GroupID             = _groupID,
                                    Block               = house.Block == null ? "" : house.Block,
                                    Building            = house.Building,
                                    Unit                = house.Unit,
                                    RoomNumber          = house.RoomNumber == null ? "" : house.RoomNumber,
                                    RoomTypeID          = _roomTypeID,
                                    Toward              = house.Toward == null ? "" : house.Toward,
                                    RoomTypeCode        = house.RoomType,
                                    EstimateBuiltUpArea = house.EstimateBuiltUpArea,
                                    EstimateLivingArea  = house.EstimateLivingArea,
                                    AreaUnitPrice       = house.AreaUnitPrice,
                                    TotalPrice          = house.TotalPrice,
                                    CreateTime          = DateTime.Now,
                                    LastUpdate          = DateTime.Now,
                                    HouseEstateID       = _houseEstateID
                                };
                                addHouseList.Add(_house);
                            }
                        }
                        _houseBLL.AddRange(addHouseList);
                        #endregion
                    }
                    else
                    {
                        ret.Code   = 302;
                        ret.ErrMsg = "导入的房源信息所属项目不存在!";
                    }
                }
                else
                {
                    ret.Code   = 301;
                    ret.ErrMsg = "导入的房源信息不允许为空!";
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("导入房源信息时发生异常!", "ImportHouseInfoController", "Post", ex);
                ret.Code   = 999;
                ret.ErrMsg = ex.Message;
            }
            return(ret);
        }