package com.jwipc.finance.service.impl;

import cn.hutool.core.date.LocalDateTimeUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jwipc.finance.mapper.DeductionMapper;
import com.jwipc.finance.model.po.DeductionPO;
import com.jwipc.finance.model.query.DeductionQuery;
import com.jwipc.finance.service.IDeductionService;
import com.jwipc.finance.entity.Deduction;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 对账模块-扣款管理表 服务实现类
 * </p>
 *
 * @author AL
 * @since 2024-02-20
 */
@Service
public class DeductionServiceImpl extends ServiceImpl<DeductionMapper, Deduction> implements IDeductionService {
    @Override
    public List<DeductionPO> findPageByQuery(Page<Deduction> dbPage, DeductionQuery query) {
        if (dbPage==null){
            return baseMapper.findPageByQuery(query);
        }
        return baseMapper.findPageByQuery(dbPage,query);
    }
    @Override
    public DeductionPO getDataById(Long id) {
        DeductionPO deductionPO = baseMapper.getDataById(id);
        if(deductionPO.getDeductionTime() != null){
            deductionPO.setDeductionTimeDesc(LocalDateTimeUtil.format(deductionPO.getDeductionTime(),"yyyy-MM-dd"));
        }
        return deductionPO;
    }

    @Override
    public List<DeductionPO> findDeductionNoticeList() {
        List<DeductionPO> deductionPOList = baseMapper.findDeductionNoticeList();
        return deductionPOList;
    }
}
