/**
   * 获取供应商的详细信息(保证金等信息)
   *
   * @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;
  }
  /**
   * 根据需求信息查询需求对应的阶段下的方案是否符合最终的提交要求
   *
   * @param requirement 需求信息
   * @param requirementSolution 用户的方案信息
   * @return Boolean 返回检验信息
   */
  private Response<Boolean> checkReqStatusWithSol(
      Requirement requirement, RequirementSolution requirementSolution) {
    Response<Boolean> result = new Response<Boolean>();

    // 是否是方案终投阶段
    if (Objects.equal(RequirementStatus.SOL_END, RequirementStatus.from(requirement.getStatus()))) {
      // 技术领先、差异化必须要提交方案(solutionFile:上传的详细的方案文档)其它场景不需要
      if (Objects.equal(Tactics.from(requirement.getTacticsId()), Tactics.TECHNOLOGY_NEW)
          || Objects.equal(Tactics.from(requirement.getTacticsId()), Tactics.DIFFERENTIATION)) {
        if (requirementSolution.getSolutionFile() == null
            || requirementSolution.getSolutionFile().isEmpty()) {
          log.error("jump to requirement solution end need send solution file.");
          result.setError("solution.file.null");
          return result;
        }
      }

      // todo 添加判断用户是否已经提交报价单文档

      // 模块方案信息
      List<ModuleSolution> solutions =
          moduleSolutionDao.findAllSolutions(requirementSolution.getId());

      // 模块报价信息
      List<ModuleQuotation> quotations =
          moduleQuotationDao.findAllQuotations(requirementSolution.getId());

      // 获取需求详细的模块数量
      Integer actualModuleNum = requirement.getModuleNum();

      // 判断模块的TQRD信息是否填写完整
      if (!Objects.equal(actualModuleNum, solutions.size())) {
        log.error("send solution to end status, the module solution info must be enter.");
        result.setError("moduleSol.info.null");
        return result;
      }

      // 判断是否填写完整的模块报价信息
      if (!Objects.equal(actualModuleNum, quotations.size())) {
        log.error("send solution to end status, the module quotation info must be enter.");
        result.setError("moduleQuo.info.null");
        return result;
      }

      // 验证TQRD数据是否已全部填写
      for (ModuleSolution solution : solutions) {
        if (solution.getTechnology() == null
            || solution.getQuality() == null
            || solution.getReaction() == null
            || solution.getDelivery() == null) {
          log.error("send solution to end status, the module solution info must be enter.");
          result.setError("moduleSol.info.null");
          return result;
        }
      }

      // 验证报价数据是否填写完整
      for (ModuleQuotation quotation : quotations) {
        if (quotation.getSolutionId() == null
            || quotation.getModuleId() == null
            || quotation.getPrice() == null
            || Strings.isNullOrEmpty(quotation.getCoinType())
            || quotation.getExchangeRate() == null) {
          log.error("send solution to end status, the module quotation info must be enter.");
          result.setError("moduleQuo.info.null");
          return result;
        }
      }

      result.setResult(true);
    } else {
      log.error("requirement status don't allow requirement solution end.");
      result.setError("solution.status.not.end");
      return result;
    }

    return result;
  }