/**
   * 获取供应商的详细信息(保证金等信息)
   *
   * @param requirementId 需求编号
   * @param solution 需求方案信息
   * @param categoryIds 需求类目信息
   * @return SupplierSolutionDto 供应商详细信息
   */
  private SupplierSolutionDto querySupplierDto(
      Long requirementId, RequirementSolution solution, List<Long> categoryIds) {
    SupplierSolutionDto supplierSolutionDto = new SupplierSolutionDto();

    supplierSolutionDto.setSupplierId(solution.getSupplierId());
    supplierSolutionDto.setSupplierName(solution.getSupplierName());
    supplierSolutionDto.setUserId(solution.getUserId());
    // 是否已提交方案
    supplierSolutionDto.setDealTime(
        solution.getSolutionFile() == null ? null : solution.getUpdatedAt());

    // 写入供应商信用等级信息
    Response<SupplierCreditQualify> creditRes =
        supplierCreditQualifyService.findCreditQualifyByUserId(solution.getUserId());
    supplierSolutionDto.setCreditStatus(
        creditRes.isSuccess() ? creditRes.getResult().getStatus() : null);

    // 写入供应商资质验证信息
    Response<Integer> qualifyRes =
        supplierResourceMaterialService.getInfoInBcIds(solution.getSupplierId(), categoryIds);
    supplierSolutionDto.setQualifyStatus(qualifyRes.isSuccess() ? qualifyRes.getResult() : null);

    // 写入供应商针对需求是否提交保证金
    Response<Integer> depositRes =
        depositService.checkPaid(requirementId, solution.getSupplierId());
    supplierSolutionDto.setPaidStatus(
        depositRes.isSuccess() ? depositRes.getResult() : Deposit.Status.INIT.value());

    // 标注供应商是否可以进入配额流程
    supplierSolutionDto.setSolutionStatus(
        Objects.equal(
            RequirementSolution.Status.from(solution.getStatus()),
            RequirementSolution.Status.SEND_END));

    Response<User> userRes = accountService.findUserById(solution.getUserId());
    supplierSolutionDto.setSupplierTags(
        userRes.isSuccess() ? userRes.getResult().buildTags() : null);

    // 当阶段到达,已上传文件阶段则默认为全部承诺
    Integer interStatus =
        solution.getStatus() == 0 ? 1 : (solution.getStatus() >= 4 ? 2 : solution.getStatus());
    supplierSolutionDto.setInteractiveStatus(interStatus);

    return supplierSolutionDto;
  }
  @Override
  public Response<Boolean> checkSupplierInfo(Long requirementId, BaseUser user) {
    Response<Boolean> result = new Response<Boolean>();

    Requirement requirement = requirementDao.findById(requirementId);

    // 写入供应商信用等级信息
    Response<SupplierCreditQualify> creditRes =
        supplierCreditQualifyService.findCreditQualifyByUserId(user.getId());

    if (!creditRes.isSuccess()) {
      log.error("find supplier credit qualify info failed, error code={}", creditRes.getError());
      result.setError(creditRes.getError());
      return result;
    }

    if (!creditRes.getResult().isCreditQualified()) {
      log.error("supplier credit is not allow to do.");
      result.setError("supplier.credit.failed");
      return result;
    }

    // 获取公司信息
    Response<Company> companyRes = companyService.findCompanyByUserId(user.getId());

    if (!companyRes.isSuccess()) {
      result.setError(companyRes.getError());
      return result;
    }

    // 获取后台三级类目信息
    List<BackendJSON> categoryList =
        JSON_MAPPER.fromJson(
            requirement.getSeriesIds(),
            JSON_MAPPER.createCollectionType(List.class, BackendJSON.class));
    List<Long> categoryIds = Lists.newArrayList();
    for (BackendJSON backendJSON : categoryList) {
      categoryIds.add(backendJSON.getBcId());
    }

    // 获取供应商资质验证信息
    Response<Integer> qualifyRes =
        supplierResourceMaterialService.getInfoInBcIds(companyRes.getResult().getId(), categoryIds);
    if (!qualifyRes.isSuccess()) {
      log.error(
          "find user qualify failed, userId={}, error code={}",
          user.getId(),
          qualifyRes.getError());
      result.setError(qualifyRes.getError());
      return result;
    }

    // 资质是否全部验证通过
    if (!Objects.equal(
        SupplierResourceMaterialInfo.Status.from(qualifyRes.getResult()),
        SupplierResourceMaterialInfo.Status.QUALIFIED)) {
      log.error("supplier resource is not allow to do.");
      result.setError("supplier.resource.failed");
      return result;
    }

    result.setResult(true);

    return result;
  }