package com.jwipc.finance.logic.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jwipc.finance.entity.PayableRefund;
import com.jwipc.finance.entity.PaymentChange;
import com.jwipc.finance.logic.PayableRefundLogic;
import com.jwipc.finance.model.po.PayableRefundPO;
import com.jwipc.finance.model.po.PaymentChangePO;
import com.jwipc.finance.model.query.PayableRefundQuery;
import com.jwipc.finance.service.IPayableRefundService;
import com.jwipc.page.PageUtil;
import com.jwipc.page.PageView;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author shenyang.ou
 * @date 2025/12/11 18:21
 * @desc
 */
@Service
@RequiredArgsConstructor
public class PayableRefundLogicImpl implements PayableRefundLogic {
    private final IPayableRefundService payableRefundService;
    @Override
    public PageView findByPage(PayableRefundQuery query) {
        final Page<PayableRefund> dbPage = PageUtil.toPage(query);

        List<PayableRefundPO> paymentChanges = payableRefundService.findPageByQuery(dbPage, query);

        return PageUtil.getPV(paymentChanges, dbPage.getTotal());
    }
}
