package com.cyksj.mapper.manage.coupon;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cyksj.model.entity.CouponActive;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/*
 *项目名: netflix
 *文件名: CouponActiveMapper
 *创建者: JavaZou
 *创建时间:2022/11/17 17:33
 */
public interface CouponActiveMapper extends BaseMapper<CouponActive> {
	@Update("update coupon_active set deleted = false where coupon_id = #{id}")
	void deleteByCouponId(Long id);

	@Update("update coupon_active set remain_num = remain_num - 1 where id = #{id} and  remain_num = #{remainNum} and remain_num > 0")
	Integer subRemainNum(@Param("id") Long id, @Param("remainNum") Integer remainNum);
}
