| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- from sqlalchemy import String, UniqueConstraint, ForeignKey
- from sqlalchemy.orm import Mapped, mapped_column
- from app.common.enums import PermissionFilterStrategy
- from app.core.base_model import PaymentModelMixin, TenantMixin, EnterpriseMixin
- class OpenTransferModel(PaymentModelMixin, TenantMixin, EnterpriseMixin):
- __tablename__ = "open_transfer"
- __table_args__ = (
- UniqueConstraint('third_biz_no', 'tenant_id', name='uq_third_biz_tenant'),
- {"comment": "三方转账表"} # 字典必须放在元组的最后
- )
- __permission_strategy__ = PermissionFilterStrategy.ENTERPRISE_BASED
- third_biz_no: Mapped[str] = mapped_column(
- String(64), nullable=False, index=True, comment="三方订单号"
- )
- out_biz_no: Mapped[str] = mapped_column(
- String(64),
- # ForeignKey("pay_transfer.out_biz_no", ondelete="RESTRICT", onupdate="CASCADE"),
- nullable=False,
- index=True,
- comment="平台订单号",
- )
- api_key: Mapped[str] = mapped_column(
- String(256),
- comment="API Key",
- index=True,
- )
- class OpenConfModel(PaymentModelMixin, TenantMixin):
- __tablename__ = "open_conf"
- __table_args__ = (
- {"comment": "三方配置表"}
- )
- __permission_strategy__ = PermissionFilterStrategy.ENTERPRISE_BASED
- # 支付宝应用配置
- app_id: Mapped[str] = mapped_column(
- String(64), unique=True, nullable=False, comment="应用ID"
- )
-
- # 密钥配置
- private_key: Mapped[str] = mapped_column(
- String(2048), nullable=True, comment="应用私钥(PKCS8格式)"
- )
-
- public_key: Mapped[str] = mapped_column(
- String(2048), nullable=True, comment="平台公钥"
- )
-
- # 网关配置
- gateway_url: Mapped[str] = mapped_column(
- String(256), nullable=True, comment="支付宝网关地址"
- )
-
- # 签名配置
- sign_type: Mapped[str] = mapped_column(
- String(32), nullable=True, default="RSA2", comment="签名类型: RSA/RSA2"
- )
-
- # 编码配置
- charset: Mapped[str] = mapped_column(
- String(32), nullable=True,default="UTF-8", comment="字符编码"
- )
-
- format: Mapped[str] = mapped_column(
- String(32), nullable=True, default="JSON", comment="数据格式"
- )
-
- # 回调配置
- notify_url: Mapped[str] = mapped_column(
- String(512), nullable=True, comment="异步通知地址"
- )
-
- return_url: Mapped[str] = mapped_column(
- String(512), nullable=True, comment="同步返回地址"
- )
-
- # 证书配置(证书模式)
- app_cert_sn: Mapped[str] = mapped_column(
- String(64), nullable=True, comment="应用证书序列号"
- )
-
- alipay_root_cert_sn: Mapped[str] = mapped_column(
- String(64), nullable=True, comment="支付宝根证书序列号"
- )
-
- # 加密配置
- encrypt_key: Mapped[str] = mapped_column(
- String(64), nullable=True, comment="AES加密密钥"
- )
-
- # 状态配置
- status: Mapped[str] = mapped_column(
- String(16), nullable=False, default="ENABLED", comment="状态: ENABLED/DISABLED"
- )
-
- # 描述
- description: Mapped[str] = mapped_column(
- String(256), nullable=True, comment="配置描述"
- )
|