package com.iformall.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxCouponCar;
import com.iformall.domain.vo.WxCouponCarVo;
import com.iformall.mapper.WxCouponCarMapper;
import com.iformall.service.WxCouponCarService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class WxCouponCarServiceImpl implements WxCouponCarService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
    WxCouponCarMapper wxCouponCarMapper;


    @Override
    public PageInfo<WxCouponCar> listAsPage(WxCouponCar record, Integer pageIndex, Integer pageSize) {
        return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponCarMapper.findList(record));
    }

    @Override
    public WxCouponCar getById(Long id) {
        return wxCouponCarMapper.selectById(id);
    }

    @Override
    public void save(WxCouponCar record) {
        wxCouponCarMapper.insert(record);
    }

    @Override
    public void update(WxCouponCar record) {
        wxCouponCarMapper.updateById(record);
    }

    @Override
    public void deleteById(Long id) {
        wxCouponCarMapper.deleteById(id);
    }


    @Override
    public Integer getAmtCountByTemplateId(Long templateId) {
        return wxCouponCarMapper.findTemplateAmtCount(templateId);
    }

    @Override
    public Integer getAvaibleCountByTemplateId(Long templateId) {
        return wxCouponCarMapper.findTemplateAvailCount(templateId);
    }

    @Override
    public Integer getClaimCountByTemplateId(Long templateId) {
        return wxCouponCarMapper.findAmtCountForCouponOrderTakeOff(templateId);
    }

    @Override
    public WxCouponCarVo findDetailVo(Long id) {
        return  wxCouponCarMapper.findVoDetail(id);
    }
    
    
    
    
}
