package com.bonus.canteen.core.marketing.coupon.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bonus.canteen.core.marketing.coupon.model.MktCouponTmplBack;
import com.bonus.canteen.core.marketing.coupon.vo.MktCouponTmplBackVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MktCouponTmplBackMapper extends BaseMapper<MktCouponTmplBack> {
   @Select({"SELECT back_id, coupon_name, coupon_amount,company_name FROM mkt_coupon_tmpl_back WHERE back_id = #{backId} ORDER BY id DESC limit 1"})
   MktCouponTmplBack getTmplBackIdByBackId(Long backId);

   @Select({"SELECT back_id, coupon_name, coupon_amount FROM mkt_coupon_tmpl_back WHERE coupon_name = #{couponName} AND coupon_type = #{couponType} ORDER BY id DESC limit 1"})
   MktCouponTmplBack getTmplBackByCouponName(@Param("couponName") String couponName, @Param("couponType") Integer couponType);

   @Select({"SELECT tmpl_id FROM mkt_coupon_tmpl_back WHERE back_id = #{backId}"})
   Long getTmplIdByBackId(Long backId);

   @Select({"SELECT coupon_name FROM mkt_coupon_tmpl_back WHERE back_id = #{backId}"})
   String getCouponNameByBackId(Long backId);

   List<MktCouponTmplBackVO> listBackVO(@Param("backId") Long backId, @Param("couponType") Integer couponType);

   List<Long> getBackIdsByTmplId(Long tmplId);
}
