from sqlalchemy import Column, Integer, String, DateTime, Text
from datetime import datetime
from database.models import Base

class PromoProduct(Base):
    """
    EDM (限時搶購) 商品資料表
    用於儲存從 MOMO 限時搶購頁面抓取的商品資訊
    """
    __tablename__ = 'promo_products'

    id = Column(Integer, primary_key=True, autoincrement=True)
    batch_id = Column(String(64), index=True)
    crawled_at = Column(DateTime, default=datetime.now)
    
    time_slot = Column(String(20))
    activity_time_text = Column(String(100))
    session_time_text = Column(String(100))
    
    i_code = Column(String(50), index=True)
    name = Column(String(255))
    price = Column(Integer)
    discount_text = Column(String(20))
    url = Column(Text)
    image_url = Column(Text)
    previous_price = Column(Integer)
    remain_qty = Column(Integer)
    
    status_change = Column(String(20), default='NEW')
    page_type = Column(String(50), default='edm', index=True)