package com.ruoyi.bst.bonusRefund.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ruoyi.bst.bonusRefund.domain.BonusRefund;
import com.ruoyi.bst.bonusRefund.domain.BonusRefundQuery;
import com.ruoyi.bst.bonusRefund.domain.BonusRefundVO;
import com.ruoyi.bst.bonusRefund.mapper.BonusRefundMapper;
import com.ruoyi.bst.bonusRefund.service.BonusRefundService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.collection.CollectionUtils;

/**
 * 分成退款记录Service业务层处理
 *
 * @author ruoyi
 * @date 2025-01-25
 */
@Service
public class BonusRefundServiceImpl implements BonusRefundService
{
    @Autowired
    private BonusRefundMapper bonusRefundMapper;

    /**
     * 查询分成退款记录
     *
     * @param id 分成退款记录主键
     * @return 分成退款记录
     */
    @Override
    public BonusRefundVO selectBonusRefundById(Long id)
    {
        return bonusRefundMapper.selectBonusRefundById(id);
    }

    /**
     * 查询分成退款记录列表
     *
     * @param bonusRefund 分成退款记录
     * @return 分成退款记录
     */
    @Override
    public List<BonusRefundVO> selectBonusRefundList(BonusRefundQuery bonusRefund)
    {
        return bonusRefundMapper.selectBonusRefundList(bonusRefund);
    }

    /**
     * 新增分成退款记录
     *
     * @param bonusRefund 分成退款记录
     * @return 结果
     */
    @Override
    public int insertBonusRefund(BonusRefund bonusRefund)
    {
        bonusRefund.setCreateTime(DateUtils.getNowDate());
        return bonusRefundMapper.insertBonusRefund(bonusRefund);
    }

    /**
     * 修改分成退款记录
     *
     * @param bonusRefund 分成退款记录
     * @return 结果
     */
    @Override
    public int updateBonusRefund(BonusRefund bonusRefund)
    {
        return bonusRefundMapper.updateBonusRefund(bonusRefund);
    }

    /**
     * 批量删除分成退款记录
     *
     * @param ids 需要删除的分成退款记录主键
     * @return 结果
     */
    @Override
    public int deleteBonusRefundByIds(Long[] ids)
    {
        return bonusRefundMapper.deleteBonusRefundByIds(ids);
    }

    /**
     * 删除分成退款记录信息
     *
     * @param id 分成退款记录主键
     * @return 结果
     */
    @Override
    public int deleteBonusRefundById(Long id)
    {
        return bonusRefundMapper.deleteBonusRefundById(id);
    }

    @Override
    public int batchInsert(List<BonusRefund> list) {
        if (CollectionUtils.isEmptyElement(list)) {
            return 0;
        }
        Date now = DateUtils.getNowDate();
        for (BonusRefund refund : list) {
            refund.setCreateTime(now);
        }
        return bonusRefundMapper.batchInsert(list);
    }
}
