package org.jeecg.modules.ctop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.ctop.entity.KuaishouMatcostAccountMay;
import org.jeecg.modules.ctop.mapper.KuaishouMatcostAccountMayMapper;
import org.jeecg.modules.ctop.service.IKuaishouMatcostAccountMayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

@Service
public class KuaishouMatcostAccountMayServiceImpl extends ServiceImpl<KuaishouMatcostAccountMayMapper, KuaishouMatcostAccountMay> implements IKuaishouMatcostAccountMayService {
    @Autowired
    private KuaishouMatcostAccountMayMapper kuaishouMatcostAccountMayMapper;
    @Override
    public KuaishouMatcostAccountMay getOne() {
        QueryWrapper<KuaishouMatcostAccountMay>queryWrapper = new QueryWrapper<>();
        queryWrapper.isNull("twcost").isNotNull("end_date").last("limit 1");
        return this.getOne(queryWrapper);
    }

    @Override
    public String getMinDate(String code){
        return kuaishouMatcostAccountMayMapper.getMinDateByCode(code);
    }

    @Override
    public void updateByCode(String code,String minDate) {
        kuaishouMatcostAccountMayMapper.updateByCode(code,minDate);
    }

    @Override
    public void updateCostByCode(String code, BigDecimal cost) {
        kuaishouMatcostAccountMayMapper.updateCostByCode(code,cost);
    }

    @Override
    public BigDecimal getCostByParams(KuaishouMatcostAccountMay matcostAccountMay) {
        return kuaishouMatcostAccountMayMapper.getCostByParams(matcostAccountMay.getVideoCode(),matcostAccountMay.getMinDate(),matcostAccountMay.getEndDate());
    }
}
