package cn.freemud.management.adapter;

import cn.freemud.management.entities.dto.response.pay.PayRefundResponse;
import com.freemud.application.sdk.api.ordercenter.request.OrderCancelReq;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;

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

/**
 * @author Clover.z
 * @version 1.0.0
 * @since 1.0.0
 */
public class OrderCancelReqAdapter {

    public static List<OrderCancelReq.PayRefundItem> convert(List<PayRefundResponse.PayRefundItem> list) {
        List<OrderCancelReq.PayRefundItem> refundItemList = new ArrayList<>();
        if (CollectionUtils.isNotEmpty(list)) {
            list.forEach(item -> {
                OrderCancelReq.PayRefundItem refundItem = new OrderCancelReq.PayRefundItem();
                BeanUtils.copyProperties(item, refundItem);
                refundItemList.add(refundItem);
            });
        }
        return refundItemList;
    }

}
