package com.sckw.payment.service;

import com.sckw.payment.dao.KwpSettlementRecordMapper;
import com.sckw.payment.model.vo.SettlementRecord;
import com.sckw.core.utils.DateTimeUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 归档记录
 *
 * @author xucaiqin
 * @date 2023-08-28 15:38:53
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class KwpSettlementRecordService {
    private final KwpSettlementRecordMapper kwpSettlementRecordMapper;


    public List<SettlementRecord> financeCount(List<String> financeCount, Long entId, Integer circle) {
        //3-月
        if (circle == 3) {
            List<String> timeAll = DateTimeUtil.generateMonthRange(DateTimeUtil.parseYMD(financeCount.get(0)), DateTimeUtil.parseYMD(financeCount.get(1)));
            return kwpSettlementRecordMapper.countMonth(timeAll, financeCount, entId);
        } else {
            List<String> timeAll = DateTimeUtil.generateDateRange(DateTimeUtil.parseYMD(financeCount.get(0)), DateTimeUtil.parseYMD(financeCount.get(1)));
            return kwpSettlementRecordMapper.countByDay(timeAll, financeCount, entId);
        }
    }
}
