package com.cyksj.mapper.market.draw;

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

/*
 *项目名: netflix
 *文件名: LuckyDrawRecordMapper
 *创建者: JavaZou
 *创建时间:2022/12/28 16:39
 */
public interface LuckyDrawRecordMapper extends BaseMapper<LuckyDrawRecord> {
	@Update("update lucky_draw_record set status = #{success},order_id = #{orderId} where id = #{id} and status = 'pending'")
	Integer updateStatus(@Param("id") Long id, @Param("orderId") Long orderId, @Param("success") LuckyDrawRecord.Status success);

	@Select("select count(distinct user_id) from lucky_draw_record where draw_id = #{drawId}")
	Integer getLotteryNum(Long drawId);

	@Update("update lucky_draw_record set status = 'success' where user_id = #{userId} and ex_code = #{code}")
	void updateExCodeStatus(@Param("userId") Long userId, @Param("code") String code);
}
