package com.sqx.modules.discSpinning.service.impl;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sqx.modules.discSpinning.dao.DiscSpinningRecordDao;
import com.sqx.modules.discSpinning.entity.DiscSpinningRecord;
import com.sqx.modules.discSpinning.service.DiscSpinningRecordService;
import com.sqx.modules.userSign.entity.UserSignRecord;
import org.springframework.stereotype.Service;
import org.apache.commons.lang3.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;

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

@Service
public class DiscSpinningRecordServiceImpl extends ServiceImpl<DiscSpinningRecordDao, DiscSpinningRecord> implements DiscSpinningRecordService {

    @Autowired
    private DiscSpinningRecordDao discSpinningRecordDao;

    @Override
    public Integer countDraw(Long userId) {
        return discSpinningRecordDao.countDraw(userId);
    }

    @Override
    public Integer countSourceRecord(Long sourceId) {
        QueryWrapper<DiscSpinningRecord> recordQuery = new QueryWrapper<>();
        recordQuery.eq("source_id", sourceId);
        recordQuery.eq("source", "taskM");
        recordQuery.gt("create_time", DateUtil.beginOfMonth(new Date()));
        return discSpinningRecordDao.selectCount(recordQuery);
    }
}

