| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- # app/models/payment_event.py
- from sqlalchemy import (
- Column, Integer, String, Text, DateTime, JSON, BigInteger
- )
- from datetime import datetime
- from app.core.database import Base
- class VasPaymentEvent(Base):
- __tablename__ = "vas_payment_event"
- id = Column(BigInteger, primary_key=True, autoincrement=True)
- # ---- 来源 ----
- provider = Column(String(32), nullable=False) # wechat | alipay | stripe
- event_type = Column(String(64)) # payment_received | checkout.session.completed
- event_id = Column(String(128), unique=True) # Stripe event.id / 自生成 hash
- # ---- 原始内容 ----
- title = Column(Text)
- content = Column(Text)
- raw_payload = Column(JSON)
- # ---- 解析结果 ----
- parsed_amount = Column(BigInteger) # 最小货币单位
- parsed_currency = Column(String(8))
- parsed_device = Column(String(64))
- # ---- 业务关联 ----
- matched_payment_id = Column(BigInteger)
- matched_order_id = Column(String(128))
- # ---- 状态 ----
- status = Column(
- String(32), # received | matched | applied | duplicate | failed
- nullable=False,
- default="received"
- )
- error_message = Column(Text)
- created_at = Column(DateTime, default=datetime.utcnow)
|