package com.snack.server.module.seckill.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.snack.server.module.seckill.entity.SeckillOrder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;

@Mapper
public interface SeckillOrderMapper extends BaseMapper<SeckillOrder> {

    /**
     * 标记已支付（关联主订单）
     */
    @Update("UPDATE seckill_order SET status = 1, order_id = #{orderId}, pay_time = NOW() " +
            "WHERE id = #{id} AND status = 0")
    int markAsPaid(@Param("id") Long id, @Param("orderId") Long orderId);

    /**
     * 标记已取消（释放 Redis 限购标记时用）
     */
    @Update("UPDATE seckill_order SET status = 2 WHERE id = #{id} AND status = 0")
    int markAsCancelled(@Param("id") Long id);
}
