✨ feat(transaction)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from datetime import UTC, datetime
|
||||
from decimal import Decimal
|
||||
from enum import StrEnum
|
||||
from typing import Annotated, Self
|
||||
from typing import Annotated, Literal, Self
|
||||
|
||||
from pydantic import BaseModel, Field, model_validator
|
||||
from pydantic_extra_types.country import CountryAlpha2
|
||||
@@ -128,33 +128,35 @@ class BaseTransaction(BaseModel):
|
||||
class MiscInTransaction(BaseTransaction):
|
||||
"""其他收入交易"""
|
||||
|
||||
txn_scene = "MISC_IN"
|
||||
txn_scene: Annotated[Literal["MISC_IN"], "交易场景"] = "MISC_IN"
|
||||
dc_flag: Annotated[DcFlag, "借贷方向"] = DcFlag.CREDIT
|
||||
|
||||
|
||||
class MiscOutTransaction(BaseTransaction):
|
||||
"""其他支出交易"""
|
||||
|
||||
txn_scene = "MISC_OUT"
|
||||
txn_scene: Annotated[Literal["MISC_OUT"], "交易场景"] = "MISC_OUT"
|
||||
dc_flag: Annotated[DcFlag, "借贷方向"] = DcFlag.DEBIT
|
||||
|
||||
|
||||
class PaymentTransaction(MiscOutTransaction):
|
||||
"""支付交易"""
|
||||
|
||||
txn_scene = "PAYMENT"
|
||||
txn_scene: Annotated[Literal["PAYMENT"], "交易场景"] = "PAYMENT"
|
||||
merchant_name: Annotated[str | None, "商户名称", Field(default=None)]
|
||||
|
||||
|
||||
class EcomPaymentTransaction(PaymentTransaction):
|
||||
"""电子商务支付交易"""
|
||||
|
||||
txn_scene = "ECOM_PAYMENT"
|
||||
txn_scene: Annotated[Literal["ECOM_PAYMENT"], "交易场景"] = "ECOM_PAYMENT"
|
||||
order_id: Annotated[str | None, "订单ID", Field(default=None)]
|
||||
|
||||
|
||||
class PosPaymentTransaction(PaymentTransaction):
|
||||
"""POS支付交易"""
|
||||
|
||||
txn_scene = "POS_PAYMENT"
|
||||
txn_scene: Annotated[Literal["POS_PAYMENT"], "交易场景"] = "POS_PAYMENT"
|
||||
geo: Annotated[
|
||||
tuple[CountryAlpha2] | tuple[CountryAlpha2, str] | None, "地理信息", Field(default=None)
|
||||
]
|
||||
@@ -163,7 +165,7 @@ class PosPaymentTransaction(PaymentTransaction):
|
||||
class ATMTransaction(BaseTransaction):
|
||||
"""ATM交易"""
|
||||
|
||||
txn_scene = "ATM"
|
||||
txn_scene: Annotated[Literal["ATM"], "交易场景"] = "ATM"
|
||||
geo: Annotated[
|
||||
tuple[CountryAlpha2] | tuple[CountryAlpha2, str] | None, "地理信息", Field(default=None)
|
||||
]
|
||||
@@ -172,7 +174,7 @@ class ATMTransaction(BaseTransaction):
|
||||
class TransferTransaction(BaseTransaction):
|
||||
"""转账交易"""
|
||||
|
||||
txn_scene = "TRANSFER"
|
||||
txn_scene: Annotated[Literal["TRANSFER"], "交易场景"] = "TRANSFER"
|
||||
|
||||
|
||||
type Transaction = Annotated[
|
||||
|
||||
Reference in New Issue
Block a user