package com.cyksj.mapper.market.draw;

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

/*
 *项目名: netflix
 *文件名: LuckyDrawSpecificChanceMapper
 *创建者: JavaZou
 *创建时间:2023/2/20 15:36
 */
public interface LuckyDrawSpecificChanceMapper extends BaseMapper<LuckyDrawSpecificChance> {
	@Update("update lucky_draw_specific_chance set num = num - 1 where user_id = #{userId} and num = #{num} and num > 0")
	Integer subChanceNum(@Param("userId") Long userId, @Param("num") Integer num);

	@Update("update lucky_draw_specific_chance set num = num - 1 where user_id = #{userId} and num > 0")
	Integer subChanceNumNoRepeat(@Param("userId") Long userId);

	@Update("update lucky_draw_specific_chance set num = num + 1 where user_id = #{userId} and num >= 0")
	void addChanceNum(Long userId);
}
