package com.jwipc.finance.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.jwipc.finance.entity.PaymentAdvanceApplyDetail;
import com.jwipc.finance.entity.PaymentAdvanceRefundTransferApplyDetail;
import com.jwipc.finance.mapper.PaymentAdvanceRefundTransferApplyDetailMapper;
import com.jwipc.finance.model.po.PaymentAdvanceRefundTransferApplyDetailPO;
import com.jwipc.finance.service.IPaymentAdvanceRefundTransferApplyDetailService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author qzc
 * @since 2025-07-21
 */
@Service
public class PaymentAdvanceRefundTransferApplyDetailServiceImpl extends ServiceImpl<PaymentAdvanceRefundTransferApplyDetailMapper, PaymentAdvanceRefundTransferApplyDetail> implements IPaymentAdvanceRefundTransferApplyDetailService {

    @Override
    public List<PaymentAdvanceRefundTransferApplyDetailPO> findRefundTransferApplyDetailByRefundId(Long applyId) {
        return baseMapper.findRefundTransferApplyDetailByRefundId(applyId);
    }

    @Override
    public void updateDetailItemNo(Long id) {

        List<PaymentAdvanceRefundTransferApplyDetail> detailList = baseMapper.findByAppId(id);
        List<PaymentAdvanceRefundTransferApplyDetail> updateList = Lists.newArrayList();
        int i = 1;
        for(PaymentAdvanceRefundTransferApplyDetail detail: detailList){
            PaymentAdvanceRefundTransferApplyDetail updateAsd = new PaymentAdvanceRefundTransferApplyDetail();
            updateAsd.setId(detail.getId());
            updateAsd.setItemNo(i+"");
            updateList.add(updateAsd);
            i++;
        }
        this.updateBatchById(updateList);
    }

    @Override
    public void delDetailByApplyId(List<Long> applyIdList) {
        baseMapper.delDetailByApplyId(applyIdList);
    }

    @Override
    public List<PaymentAdvanceRefundTransferApplyDetail> findRefundTransferApplyDetailByDateKey(List<String> dataKeys) {
        return baseMapper.findRefundTransferApplyDetailByDateKey(dataKeys);
    }

    @Override
    public List<PaymentAdvanceRefundTransferApplyDetail> findRefundTransferApplyDetailByChangeId(List<Long> applyIdList) {
        return baseMapper.findRefundTransferApplyDetailByChangeId(applyIdList);
    }

    @Override
    public List<PaymentAdvanceRefundTransferApplyDetail> findRefundTransferApplyDetailByReferOrderKey(List<String> dataKeys) {
        return baseMapper.findRefundTransferApplyDetailByReferOrderKey(dataKeys);
    }

    @Override
    public List<PaymentAdvanceRefundTransferApplyDetail> findRefundTransferApplyDetailSumRefundAmountByDateKey(List<String> prepaymentKeyword) {
        return baseMapper.findRefundTransferApplyDetailSumRefundAmountByDateKey(prepaymentKeyword);
    }

    @Override
    public List<PaymentAdvanceRefundTransferApplyDetail> findRefundTransferApplyDataTypeInfoByDateKey(List<String> dataKeys) {
        return baseMapper.findRefundTransferApplyDataTypeInfoByDateKey(dataKeys);
    }

    @Override
    public List<PaymentAdvanceRefundTransferApplyDetail> findRefundTransferApplyDataTypeInfoByPoCodeAndItem(List<String> poCodeAndItem) {
        return baseMapper.findRefundTransferApplyDataTypeInfoByPoCodeAndItem(poCodeAndItem);
    }

    @Override
    public List<PaymentAdvanceRefundTransferApplyDetail> findRefundTransferApplyDetailDateKey(Integer dataType, List<String> prepaymentKeyword, List<String> dataKeys) {
        return baseMapper.findRefundTransferApplyDetailDateKey(dataType,prepaymentKeyword,dataKeys);
    }

    @Override
    public List<PaymentAdvanceRefundTransferApplyDetail> findRefundTApplyDataByPoCodeAndItemDateKey(List<String> dataKeys) {
        return baseMapper.findRefundTApplyDataByPoCodeAndItemDateKey(dataKeys);
    }
}
