package cn.com.ctop.toutiao.modules.report.service.impl;

import cn.com.ctop.toutiao.modules.report.entity.BytedanceAdvertiserDailyReport;
import cn.com.ctop.toutiao.modules.report.mapper.BytedanceAdvertiserDailyReportMapper;
import cn.com.ctop.toutiao.modules.report.service.IBytedanceAdvertiserDailyReportService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

/**
 * @Description: 广告主日报表
 * @Author: jeecg-boot
 * @Date: 2019-09-10
 * @Version: V1.0
 */
@Service
@Primary

public class BytedanceAdvertiserDailyReportServiceImpl extends ServiceImpl<BytedanceAdvertiserDailyReportMapper, BytedanceAdvertiserDailyReport> implements IBytedanceAdvertiserDailyReportService {
    @Override
    public BytedanceAdvertiserDailyReport getByParams(Long accountId, String stateDate) {
        QueryWrapper<BytedanceAdvertiserDailyReport> queryWrapper = new QueryWrapper<>();
        if(null!=accountId&&accountId!=0){
            queryWrapper.eq("advertiser_id",accountId);
        }
        if(null!=stateDate&&!"".equals(stateDate.trim())){
            queryWrapper.eq("stat_datetime",stateDate+" 00:00:00");
        }
        queryWrapper.orderByDesc("id").last("limit 1");
        return this.getOne(queryWrapper);
    }
}
