37 lines
1.8 KiB
Python
Executable File
37 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
from typing import Optional
|
|
|
|
from sqlalchemy import String, Column, BigInteger, SmallInteger, Boolean, DateTime, Index, func, JSON, Text, Numeric
|
|
from sqlalchemy.dialects.mysql import JSON as MySQLJSON
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from backend.common.model import snowflake_id_key, Base
|
|
|
|
|
|
class WxUser(Base):
|
|
__tablename__ = 'wx_user'
|
|
|
|
id: Mapped[snowflake_id_key] = mapped_column(BigInteger, init=False, primary_key=True)
|
|
openid: Mapped[str] = mapped_column(String(64), unique=True, nullable=False, comment='微信OpenID')
|
|
session_key: Mapped[str] = mapped_column(String(128), nullable=False, comment='会话密钥')
|
|
unionid: Mapped[Optional[str]] = mapped_column(String(64), default=None, index=True, comment='微信UnionID')
|
|
mobile: Mapped[Optional[str]] = mapped_column(String(15), default=None, index=True, comment='加密手机号')
|
|
profile: Mapped[Optional[dict]] = mapped_column(MySQLJSON, default=None, comment='用户资料JSON')
|
|
|
|
|
|
# class WxPayment(Base):
|
|
# __tablename__ = 'wx_payments'
|
|
#
|
|
# id: Mapped[snowflake_id_key] = mapped_column(init=False, primary_key=True)
|
|
# user_id: Mapped[int] = mapped_column(BigInteger, index=True, nullable=False)
|
|
# prepay_id: Mapped[str] = mapped_column(String(64), nullable=False, comment='预支付ID')
|
|
# transaction_id: Mapped[Optional[str]] = mapped_column(String(32), comment='微信支付单号')
|
|
# amount: Mapped[float] = mapped_column(Numeric, nullable=False, comment='分单位金额')
|
|
# status: Mapped[str] = mapped_column(String(16), default='pending', comment='支付状态')
|
|
#
|
|
# __table_args__ = (
|
|
# Index('idx_payment_user', 'user_id', 'status'),
|
|
# {'comment': '支付记录表'}
|
|
# )
|