コード例 #1
0
  @Override
  public Response<Paging<SupplierSolutionDto>> findSignByParam(
      final Long requirementId, Integer pageNo, Integer size) {
    Response<Paging<SupplierSolutionDto>> result = new Response<Paging<SupplierSolutionDto>>();

    if (requirementId == null) {
      log.error("find requirement solution need requirementId");
      result.setError("solution.requirementId.null");
      return result;
    }

    try {
      Map<String, Object> params = Maps.newHashMap();
      params.put("requirementId", requirementId);

      PageInfo pageInfo = new PageInfo(pageNo, Objects.firstNonNull(size, 10));
      params.putAll(pageInfo.toMap());

      Requirement requirement = requirementDao.findById(requirementId);

      // 获取需求下的供应商提交的方案
      Paging<RequirementSolution> solutionPaging =
          requirementSolutionDao.findSolutionsByParams(params);

      // 获取后台三级类目信息
      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());
      }

      List<SupplierSolutionDto> supplierSolutionDtoList = Lists.newArrayList();
      for (RequirementSolution solution : solutionPaging.getData()) {
        supplierSolutionDtoList.add(querySupplierDto(requirementId, solution, categoryIds));
      }

      result.setResult(
          new Paging<SupplierSolutionDto>(solutionPaging.getTotal(), supplierSolutionDtoList));
    } catch (Exception e) {
      log.error(
          "find requirement solution have sign secrecy failed , requirementId={} error code={}",
          requirementId,
          Throwables.getStackTraceAsString(e));
      result.setError("solution.supplier.findFailed");
    }

    return result;
  }
コード例 #2
0
  @Override
  public Response<SupplierSolutionDto> findSolutionSupplier(Long requirementId, BaseUser user) {
    Response<SupplierSolutionDto> result = new Response<SupplierSolutionDto>();

    if (requirementId == null) {
      log.error("find supplier info need requirementId");
      result.setError("solution.requirementId.null");
      return result;
    }

    // 验证用户是否已登入
    if (user == null) {
      log.error("find supplier info, user must login.");
      result.setError("user.not.login");
      return result;
    }

    try {
      if (Objects.equal(User.Type.from(user.getType()), User.Type.SUPPLIER)) {
        RequirementSolution solution =
            requirementSolutionDao.findByUserId(requirementId, user.getId());

        Requirement requirement = requirementDao.findById(requirementId);

        // 获取后台三级类目信息
        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());
        }

        result.setResult(querySupplierDto(requirementId, solution, categoryIds));
      } else {
        result.setResult(null);
      }
    } catch (Exception e) {
      log.error(
          "find supplier detail info failed, requirementId={}, error code={}",
          requirementId,
          Throwables.getStackTraceAsString(e));
      result.setError("query.supplier.fail");
    }

    return result;
  }
コード例 #3
0
  @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;
  }