package com.ruoyi.cs.service.impl;

import java.util.List;

import cn.hutool.core.util.IdUtil;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.cs.mapper.CsRenewalRecordMapper;
import com.ruoyi.cs.domain.CsRenewalRecord;
import com.ruoyi.cs.service.ICsRenewalRecordService;

import javax.annotation.Resource;

/**
 * 续期记录Service业务层处理
 *
 * @author ruoyi
 * @date 2024-05-29
 */
@Service
public class CsRenewalRecordServiceImpl implements ICsRenewalRecordService
{
    @Resource
    private CsRenewalRecordMapper csRenewalRecordMapper;

    /**
     * 查询续期记录
     *
     * @param renewalRecordId 续期记录主键
     * @return 续期记录
     */
    @Override
    public CsRenewalRecord selectCsRenewalRecordByRenewalRecordId(String renewalRecordId)
    {
        return csRenewalRecordMapper.selectCsRenewalRecordByRenewalRecordId(renewalRecordId);
    }

    /**
     * 查询续期记录列表
     *
     * @param csRenewalRecord 续期记录
     * @return 续期记录
     */
    @Override
    public List<CsRenewalRecord> selectCsRenewalRecordList(CsRenewalRecord csRenewalRecord)
    {
        return csRenewalRecordMapper.selectCsRenewalRecordList(csRenewalRecord);
    }

    /**
     * 新增续期记录
     *
     * @param csRenewalRecord 续期记录
     * @return 结果
     */
    @Override
    public int insertCsRenewalRecord(CsRenewalRecord csRenewalRecord)
    {
        csRenewalRecord.setRenewalRecordId(IdUtil.getSnowflakeNextIdStr());
        csRenewalRecord.setCreateAt(DateUtils.getNowDate());
        csRenewalRecord.setDelFlag("0");
        return csRenewalRecordMapper.insertCsRenewalRecord(csRenewalRecord);
    }

    /**
     * 修改续期记录
     *
     * @param csRenewalRecord 续期记录
     * @return 结果
     */
    @Override
    public int updateCsRenewalRecord(CsRenewalRecord csRenewalRecord)
    {
        csRenewalRecord.setUpdateAt(DateUtils.getNowDate());
        return csRenewalRecordMapper.updateCsRenewalRecord(csRenewalRecord);
    }

    /**
     * 批量删除续期记录
     *
     * @param renewalRecordIds 需要删除的续期记录主键
     * @return 结果
     */
    @Override
    public int deleteCsRenewalRecordByRenewalRecordIds(String[] renewalRecordIds)
    {
        return csRenewalRecordMapper.deleteCsRenewalRecordByRenewalRecordIds(renewalRecordIds);
    }

    /**
     * 删除续期记录信息
     *
     * @param renewalRecordId 续期记录主键
     * @return 结果
     */
    @Override
    public int deleteCsRenewalRecordByRenewalRecordId(String renewalRecordId)
    {
        return csRenewalRecordMapper.deleteCsRenewalRecordByRenewalRecordId(renewalRecordId);
    }

    /**
     * 查询到期的续期记录列表
     *
     * @return
     */
    @Override
    public List<CsRenewalRecord> searchRenewalRecordList(){
        return csRenewalRecordMapper.searchRenewalRecordList();
    }

}
