package io.renren.service.impl;


import io.renren.dao.ConsumeRecordMapper;
import io.renren.entity.ConsumeRecord;
import io.renren.service.IConsumeRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
 * 消费记录Service业务层处理
 *
 * @author nichun
 * @date 2023-09-08
 */
@Service
public class ConsumeRecordServiceImpl implements IConsumeRecordService
{
    @Autowired
    private ConsumeRecordMapper consumeRecordMapper;

    /**
     * 查询消费记录
     *
     * @param id 消费记录主键
     * @return 消费记录
     */
    @Override
    public ConsumeRecord selectConsumeRecordById(Long id)
    {
        return consumeRecordMapper.selectConsumeRecordById(id);
    }

    /**
     * 查询消费记录列表
     *
     * @param consumeRecord 消费记录
     * @return 消费记录
     */
    @Override
    public List<ConsumeRecord> selectConsumeRecordList(ConsumeRecord consumeRecord)
    {
        return consumeRecordMapper.selectConsumeRecordList(consumeRecord);
    }

    @Override
    public List<ConsumeRecord> selectConsumeRecordAllList(ConsumeRecord consumeRecord)
    {
        return consumeRecordMapper.selectConsumeRecordAllList(consumeRecord);
    }

    /**
     * 新增消费记录
     *
     * @param consumeRecord 消费记录
     * @return 结果
     */
    @Override
    public int insertConsumeRecord(ConsumeRecord consumeRecord)
    {
        consumeRecord.setCreateTime(new Date());
        return consumeRecordMapper.insertConsumeRecord(consumeRecord);
    }

    /**
     * 修改消费记录
     *
     * @param consumeRecord 消费记录
     * @return 结果
     */
    @Override
    public int updateConsumeRecord(ConsumeRecord consumeRecord)
    {
        consumeRecord.setUpdateTime(new Date());
        return consumeRecordMapper.updateConsumeRecord(consumeRecord);
    }

    /**
     * 批量删除消费记录
     *
     * @param ids 需要删除的消费记录主键
     * @return 结果
     */
    @Override
    public int deleteConsumeRecordByIds(Long[] ids)
    {
        return consumeRecordMapper.deleteConsumeRecordByIds(ids);
    }

    /**
     * 删除消费记录信息
     *
     * @param id 消费记录主键
     * @return 结果
     */
    @Override
    public int deleteConsumeRecordById(Long id)
    {
        return consumeRecordMapper.deleteConsumeRecordById(id);
    }

    /**
     * 查询消费记录
     *
     * @param id 消费记录主键
     * @return 消费记录
     */
    @Override
    public ConsumeRecord selectConsumeRecordByOutTradeId(String outTradeId)
    {
        return consumeRecordMapper.selectConsumeRecordByOutTradeId(outTradeId);
    }

    @Override
    public List<Map<String, Object>> selectConsumeRecordSumonline(String devId)
    {
        return consumeRecordMapper.selectConsumeRecordSumonline(devId);
    }

    @Override
    public List<Map<String, Object>> selectConsumeRecordSumonlineMonth(String devId)
    {
        return consumeRecordMapper.selectConsumeRecordSumonlineMonth(devId);
    }

}
