class RefundServiceImpl implements RefundService {

    @Override
    @Transactional
    public void refundProcessed(final RefundProcessedCommand command) {
        final List<RefundRequest> refundRequests = refundRequestRepository.findAllByRequestIdAndStatusIn(command.getRequestId(), APPROVED);
        refundRequests.forEach(refundRequest -> {
            refundRequest.setStatus(PROCESSED);
            refundRequest.setTransactionHash(command.getTransactionHash());
        });
        refundRequestRepository.save(refundRequests);

        final Refund refund = Refund.builder()
                                    .requestId(command.getRequestId())
                                    .funderAddress(command.getFunderAddress())
                                    .blockchainEventId(command.getBlockchainEventId())
                                    .requestedBy(resolveRequestedBy(command, refundRequests).orElse(null))
                                    .tokenValue(TokenValue.builder()
                                                          .amountInWei(new BigDecimal(command.getAmount()))
                                                          .tokenAddress(command.getTokenHash())
                                                          .build())
                                    .build();
        refundRepository.save(refund);
        cacheManager.getCache ("funds").evict(command.getRequestId());
        applicationEventPublisher.publishEvent(new RefundProcessedEvent(refund));
    }

    public  RefundServiceImpl(final RefundRequestRepository refundRequestRepository,
                             final RefundRepository refundRepository,
                             final RefundRequestDtoMapper refundRequestDtoMapper,
                             final CacheManager cacheManager,
                             final ApplicationEventPublisher applicationEventPublisher);

}