コード例 #1
0
 public async Task <List <OwnerCertificationRecord> > GetListAsync(OwnerCertificationRecordDto dto, CancellationToken token = default)
 {
     using (var db = new GuoGuoCommunityContext())
     {
         return(await db.OwnerCertificationRecords.Where(x => x.IsDeleted == false && x.UserId == dto.UserId && x.IsInvalid == false).ToListAsync(token));
     }
 }
コード例 #2
0
 public async Task <List <OwnerCertificationRecord> > GetListIncludeAsync(OwnerCertificationRecordDto dto, CancellationToken token = default)
 {
     using (var db = new GuoGuoCommunityContext())
     {
         return(await db.OwnerCertificationRecords.Include(x => x.Owner).Include(x => x.Industry.BuildingUnit.Building.SmallDistrict.Community.StreetOffice).Where(x => x.IsDeleted == false && x.UserId == dto.UserId && x.IsInvalid == false).ToListAsync(token));
     }
 }
コード例 #3
0
        public async Task <OwnerCertificationRecord> UpdateStatusAsync(OwnerCertificationRecordDto dto, CancellationToken token = default)
        {
            using (var db = new GuoGuoCommunityContext())
            {
                if (!Guid.TryParse(dto.Id, out var uid))
                {
                    throw new NotImplementedException("认证信息Id不正确!");
                }
                var ownerCertificationRecord = await db.OwnerCertificationRecords.Where(x => x.Id == uid).FirstOrDefaultAsync(token);

                if (ownerCertificationRecord == null)
                {
                    throw new NotImplementedException("该认证信息不存在!");
                }
                if (Guid.TryParse(dto.OwnerId, out var ownerId))
                {
                    //throw new NotImplementedException("业主Id信息不正确!");
                    ownerCertificationRecord.OwnerId = ownerId;
                }
                //ownerCertificationRecord.OwnerName = dto.OwnerName;
                ownerCertificationRecord.CertificationStatusName  = dto.CertificationStatusName;
                ownerCertificationRecord.CertificationStatusValue = dto.CertificationStatusValue;
                ownerCertificationRecord.CertificationResult      = dto.CertificationResult;
                ownerCertificationRecord.LastOperationTime        = dto.OperationTime;
                ownerCertificationRecord.LastOperationUserId      = dto.OperationUserId;
                ownerCertificationRecord.CertificationTime        = dto.OperationTime;
                OnUpdate(db, dto, token);
                await db.SaveChangesAsync(token);

                return(ownerCertificationRecord);
            }
        }
コード例 #4
0
        public async Task DeleteAsync(OwnerCertificationRecordDto dto, CancellationToken token = default)
        {
            using (var db = new GuoGuoCommunityContext())
            {
                if (!Guid.TryParse(dto.Id, out var uid))
                {
                    throw new NotImplementedException("认证Id信息不正确!");
                }
                var ownerCertificationRecord = await db.OwnerCertificationRecords.Where(x => x.Id == uid && x.IsDeleted == false).FirstOrDefaultAsync(token);

                if (ownerCertificationRecord == null)
                {
                    throw new NotImplementedException("该业主认证Id信息不存在!");
                }

                if (OnDelete(db, dto, token))
                {
                    throw new NotImplementedException("该业主信息下存在下级数据");
                }

                ownerCertificationRecord.LastOperationTime   = dto.OperationTime;
                ownerCertificationRecord.LastOperationUserId = dto.OperationUserId;
                ownerCertificationRecord.DeletedTime         = dto.OperationTime;
                ownerCertificationRecord.IsDeleted           = true;
                await db.SaveChangesAsync(token);
            }
        }
コード例 #5
0
        public async Task UpdateInvalidAsync(OwnerCertificationRecordDto dto, CancellationToken token = default)
        {
            using (var db = new GuoGuoCommunityContext())
            {
                if (!Guid.TryParse(dto.Id, out var uid))
                {
                    throw new NotImplementedException("认证信息Id不正确!");
                }
                var ownerCertificationRecord = await db.OwnerCertificationRecords.Where(x => x.Id == uid).FirstOrDefaultAsync(token);

                if (ownerCertificationRecord == null)
                {
                    throw new NotImplementedException("该认证信息不存在!");
                }

                ownerCertificationRecord.IsInvalid = true;

                ownerCertificationRecord.LastOperationTime   = dto.OperationTime;
                ownerCertificationRecord.LastOperationUserId = dto.OperationUserId;
                OnUpdate(db, dto, token);
                await db.SaveChangesAsync(token);
            }
        }
コード例 #6
0
        /// <summary>
        /// 后台执行校验 上传图片认证信息
        /// </summary>
        /// <param name="annex"></param>
        private async Task <ApiResult> Verification(OwnerCertificationAnnex annex)
        {
            var ownerCertificationRecordEntity = await _ownerCertificationRecordRepository.GetIncludeAsync(annex.ApplicationRecordId.ToString());

            try
            {
                OwnerCertificationRecordDto dto = new OwnerCertificationRecordDto
                {
                    OperationTime   = DateTimeOffset.Now,
                    OperationUserId = "system",
                    Id = ownerCertificationRecordEntity.Id.ToString()
                };

                try
                {
                    var entity = await PostALiYun(annex);

                    JsonModel json = new JsonModel();
                    try
                    {
                        json = JsonConvert.DeserializeObject <JsonModel>(entity.Message);
                        if (string.IsNullOrEmpty(json.Num))
                        {
                            throw new NotImplementedException("未识别到身份证信息,请提交正规清晰的身份证照片!");
                        }
                    }
                    catch (Exception)
                    {
                        throw new NotImplementedException("未识别到身份证信息,请提交正规清晰的身份证照片!");
                    }
                    var owner = (await _ownerRepository.GetListForLegalizeIncludeAsync(new OwnerDto {
                        IndustryId = ownerCertificationRecordEntity.IndustryId.ToString()
                    })).Where(x => x.IDCard == json.Num).FirstOrDefault();

                    if (owner != null)
                    {
                        dto.CertificationStatusValue = OwnerCertificationStatus.Success.Value;
                        dto.CertificationStatusName  = OwnerCertificationStatus.Success.Name;
                        dto.OwnerId             = owner.Id.ToString();
                        dto.OwnerName           = owner.Name.ToString();
                        dto.CertificationResult = "认证通过";
                    }
                    else
                    {
                        dto.CertificationStatusValue = OwnerCertificationStatus.Failure.Value;
                        dto.CertificationStatusName  = OwnerCertificationStatus.Failure.Name;
                        dto.CertificationResult      = "未查询到相关业主信息";
                    }
                }
                catch (Exception e)
                {
                    dto.CertificationStatusValue = OwnerCertificationStatus.Failure.Value;
                    dto.CertificationStatusName  = OwnerCertificationStatus.Failure.Name;
                    dto.CertificationResult      = e.Message;
                    throw new NotImplementedException(e.Message);
                }
                var recordEntity = await _ownerCertificationRecordRepository.UpdateStatusAsync(dto);

                if (string.IsNullOrWhiteSpace(dto.OwnerId))
                {
                    throw new NotImplementedException("未查询到相关业主信息");
                }

                await _ownerRepository.UpdateForLegalizeAsync(new OwnerDto
                {
                    OwnerCertificationRecordId = ownerCertificationRecordEntity.Id.ToString(),
                    Id   = recordEntity.OwnerId.ToString(),
                    Name = dto.OwnerName,
                });

                return(new ApiResult(APIResultCode.Success));
            }
            catch (Exception e)
            {
                await _ownerCertificationRecordRepository.UpdateInvalidAsync(new OwnerCertificationRecordDto
                {
                    Id              = ownerCertificationRecordEntity.Id.ToString(),
                    OperationTime   = DateTimeOffset.Now,
                    OperationUserId = "system",
                });

                await _ownerCertificationRecordRepository.DeleteAsync(new OwnerCertificationRecordDto
                {
                    Id              = ownerCertificationRecordEntity.Id.ToString(),
                    OperationTime   = DateTimeOffset.Now,
                    OperationUserId = "system",
                });

                throw new NotImplementedException(e.Message);
            }
        }
コード例 #7
0
 public Task <List <OwnerCertificationRecord> > GetAllIncludeAsync(OwnerCertificationRecordDto dto, CancellationToken token = default)
 {
     throw new NotImplementedException();
 }
コード例 #8
0
        public async Task <OwnerCertificationRecord> AddAsync(OwnerCertificationRecordDto dto, CancellationToken token = default)
        {
            using (var db = new GuoGuoCommunityContext())
            {
                //用户信息
                if (!Guid.TryParse(dto.UserId, out var userId))
                {
                    throw new NotImplementedException("用户Id不正确!");
                }
                var user = await db.Users.Where(x => x.Id == userId && x.IsDeleted == false).FirstOrDefaultAsync(token);

                if (user == null)
                {
                    throw new NotImplementedException("用户信息不存在!");
                }

                //街道办信息
                if (!Guid.TryParse(dto.StreetOfficeId, out var streetOfficeId))
                {
                    throw new NotImplementedException("街道办Id不正确!");
                }
                var streetOffice = await db.StreetOffices.Where(x => x.Id == streetOfficeId && x.IsDeleted == false).FirstOrDefaultAsync(token);

                if (streetOffice == null)
                {
                    throw new NotImplementedException("街道办信息不存在!");
                }

                //社区信息
                if (!Guid.TryParse(dto.CommunityId, out var communityId))
                {
                    throw new NotImplementedException("社区Id不正确!");
                }
                var communitie = await db.Communities.Where(x => x.Id == communityId && x.IsDeleted == false).FirstOrDefaultAsync(token);

                if (communitie == null)
                {
                    throw new NotImplementedException("社区信息不存在!");
                }

                //小区信息
                if (!Guid.TryParse(dto.SmallDistrictId, out var smallDistrictId))
                {
                    throw new NotImplementedException("小区Id不正确!");
                }
                var smallDistrict = await db.SmallDistricts.Where(x => x.Id == smallDistrictId && x.IsDeleted == false).FirstOrDefaultAsync(token);

                if (smallDistrict == null)
                {
                    throw new NotImplementedException("小区信息不存在!");
                }

                //楼宇信息
                if (!Guid.TryParse(dto.BuildingId, out var buildingId))
                {
                    throw new NotImplementedException("楼宇Id不正确!");
                }
                var building = await db.Buildings.Where(x => x.Id == buildingId && x.IsDeleted == false).FirstOrDefaultAsync(token);

                if (building == null)
                {
                    throw new NotImplementedException("楼宇信息不存在!");
                }

                //单元信息
                if (!Guid.TryParse(dto.BuildingUnitId, out var buildingUnitId))
                {
                    throw new NotImplementedException("楼宇单元Id不正确!");
                }
                var buildingUnit = await db.BuildingUnits.Where(x => x.Id == buildingUnitId && x.IsDeleted == false).FirstOrDefaultAsync(token);

                if (buildingUnit == null)
                {
                    throw new NotImplementedException("楼宇单元信息不存在!");
                }

                //业户信息
                if (!Guid.TryParse(dto.IndustryId, out var industryId))
                {
                    throw new NotImplementedException("业户Id信息不正确!");
                }
                var industrie = await db.Industries.Where(x => x.Id == industryId && x.IsDeleted == false).FirstOrDefaultAsync(token);

                if (industrie == null)
                {
                    throw new NotImplementedException("业户信息不存在!");
                }

                var ownerCertificationRecord = await db.OwnerCertificationRecords.Where(x => x.UserId == dto.UserId && x.IsDeleted == false && x.IsInvalid == false).FirstOrDefaultAsync(token);

                if (ownerCertificationRecord != null)
                {
                    throw new NotImplementedException("该业主信息已存在!");
                }
                var entity = db.OwnerCertificationRecords.Add(new OwnerCertificationRecord
                {
                    CertificationResult = dto.CertificationResult,
                    UserId = dto.UserId,
                    CertificationStatusName  = OwnerCertificationStatus.Executing.Name,
                    CertificationStatusValue = OwnerCertificationStatus.Executing.Value,
                    CreateOperationTime      = dto.OperationTime,
                    CreateOperationUserId    = dto.OperationUserId,
                    LastOperationTime        = dto.OperationTime,
                    LastOperationUserId      = dto.OperationUserId,
                    IndustryId = industrie.Id
                });
                await db.SaveChangesAsync(token);

                return(entity);
            }
        }
コード例 #9
0
 private bool OnDelete(GuoGuoCommunityContext db, OwnerCertificationRecordDto dto, CancellationToken token = default)
 {
     return(false);
 }
コード例 #10
0
 private void OnUpdate(GuoGuoCommunityContext db, OwnerCertificationRecordDto dto, CancellationToken token = default)
 {
 }
コード例 #11
0
 public Task UpdateAsync(OwnerCertificationRecordDto dto, CancellationToken token)
 {
     throw new NotImplementedException();
 }