package com.ruoyi.frequency.mallrefund.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.frequency.mallrefund.entity.MallRefund;
import com.ruoyi.frequency.mallrefund.mapper.MallRefundMapper;
import com.ruoyi.frequency.mallrefund.service.MallRefundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 订单退款Service业务层处理
 *
 * @author liwenlong
 * @date 2024-01-25
 */
@Service
public class MallRefundServiceImpl extends ServiceImpl<MallRefundMapper, MallRefund>  implements MallRefundService
{
    @Autowired
    private MallRefundMapper mallRefundMapper;

    /**
     * 查询订单退款
     *
     * @param id 订单退款主键
     * @return 订单退款
     */
    @Override
    public MallRefund selectMallRefundById(Long id)
    {
        return mallRefundMapper.selectMallRefundById(id);
    }

    /**
     * 查询订单退款列表
     *
     * @param mallRefund 订单退款
     * @return 订单退款
     */
    @Override
    public List<MallRefund> selectMallRefundList(MallRefund mallRefund)
    {
        return mallRefundMapper.selectMallRefundList(mallRefund);
    }

    /**
     * 新增订单退款
     *
     * @param mallRefund 订单退款
     * @return 结果
     */
    @Override
    public int insertMallRefund(MallRefund mallRefund)
    {
        mallRefund.setCreateData();
        return mallRefundMapper.insert(mallRefund);
    }

    /**
     * 修改订单退款
     *
     * @param mallRefund 订单退款
     * @return 结果
     */
    @Override
    public int updateMallRefund(MallRefund mallRefund)
    {
        mallRefund.setUpdateData();
        return mallRefundMapper.updateMallRefund(mallRefund);
    }

    /**
     * 批量删除订单退款
     *
     * @param ids 需要删除的订单退款主键
     * @return 结果
     */
    @Override
    public int deleteMallRefundByIds(Long[] ids,Integer delFlag)
    {
        this.lambdaUpdate().set(MallRefund::getDelFlag,delFlag).in(MallRefund::getId,ids).update();
        return ids.length;
    }

}
