package com.ruoyi.bst.bonusRefund.service.impl;

import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.bst.bonus.domain.Bonus;
import com.ruoyi.bst.bonusRefund.domain.BonusRefund;
import com.ruoyi.bst.bonusRefund.service.BonusRefundConverter;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Service
public class BonusRefundConverterImpl implements BonusRefundConverter {

    @Override
    public List<BonusRefund> toPo(List<Bonus> refundList) {
        if (CollectionUtils.isEmptyElement(refundList)) {
            return Collections.emptyList();
        }

        List<BonusRefund> result = new ArrayList<>();
        for (Bonus refund : refundList) {
            BonusRefund po = new BonusRefund();
            po.setBonusId(refund.getId());
            po.setRefundAmount(refund.getRefundAmount());
            result.add(po);
        }

        return result;
    }

}
