package com.red.circle.wallet.inner.service.freight.impl;

import com.red.circle.wallet.infra.database.rds.service.freight.FreightBalanceRunningWaterService;
import com.red.circle.wallet.inner.convertor.FreightBalanceRunningWaterInnerConvertor;
import com.red.circle.wallet.inner.model.dto.FreightBalanceRunningWaterDTO;
import com.red.circle.wallet.inner.service.freight.FreightBalanceRunningWaterClientService;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 用户货运账户流水.
 *
 * @author pengliang on 2023/12/26
 */
@Service
@RequiredArgsConstructor
public class FreightBalanceRunningWaterClientServiceImpl implements
    FreightBalanceRunningWaterClientService {

  private final FreightBalanceRunningWaterService freightBalanceRunningWaterService;
  private final FreightBalanceRunningWaterInnerConvertor freightBalanceRunningWaterInnerConvertor;

  @Override
  public List<FreightBalanceRunningWaterDTO> flowByUserId(Long userId, Long lastId) {
    return freightBalanceRunningWaterInnerConvertor.toListFreightBalanceRunningWaterDTO(
        freightBalanceRunningWaterService.flowByUserId(userId, lastId)
    );
  }

  @Override
  public List<FreightBalanceRunningWaterDTO> flowBySellerId(Long sellerId, Long lastId) {
    return freightBalanceRunningWaterInnerConvertor.toListFreightBalanceRunningWaterDTO(
        freightBalanceRunningWaterService.flowBySellerId(sellerId, lastId)
    );
  }

  @Override
  public List<FreightBalanceRunningWaterDTO> flowByUserIdAndDate(Long userId, Long lastId,
      String currentDate) {
    return freightBalanceRunningWaterInnerConvertor.toListFreightBalanceRunningWaterDTO(
        freightBalanceRunningWaterService.flowByUserIdAndDate(userId, lastId, currentDate)
    );
  }

  @Override
  public void save(FreightBalanceRunningWaterDTO dto) {
    freightBalanceRunningWaterService.save(
        freightBalanceRunningWaterInnerConvertor.toFreightBalanceRunningWater(dto)
    );
  }
}
