Exemplo n.º 1
0
from app.model.currency import Currency
from app.model.assets import Assets, g_assets_record_type
from app.type.typedef_const import TypedefConst

g_order_status = TypedefConst()

g_order_status.PENDING = 1  # 挂单中
g_order_status.MATCH = 2  # 匹配中
g_order_status.PAID = 4  # 已付款
g_order_status.CONFIRMED = 8  # 已确认
g_order_status.CANCELLED = 16  # 已取消
g_order_status.DELETE = 32  # 删除

g_order_side = TypedefConst()

g_order_side.BUY = 1  # 买单
g_order_side.SELL = 2  # 卖单


class Order(AutoIncrementBase):
    match_order_id = db.Column(db.Integer, db.ForeignKey('match_order.id'), nullable=True)  # 匹配订单

    user_id = db.Column(db.String(36), db.ForeignKey('user.id'), nullable=False)  # 用户
    side = db.Column(db.SmallInteger, nullable=False)  # 单类型 参见 g_order_side
    number = db.Column(db.String(16), nullable=False)

    amount = db.Column(db.Numeric(24, 8), nullable=False)  # 数量

    status = db.Column(db.SmallInteger, default=g_order_status.PENDING, nullable=False)  # 订单状态参见 g_order_status

    priority = db.Column(db.SmallInteger, default=0)  # 订单优先级 数值越大优先级越高
Exemplo n.º 2
0
from app.model import UuidBase, AutoIncrementBase, db

from app.model.setting import Setting
from app.type.typedef_const import TypedefConst

g_assets_type = TypedefConst()

g_assets_type.TOTAL = 1  # 总资产钱包 冻结
g_assets_type.COMMUNITY = 2  # 社区钱包 用于交易
g_assets_type.TRANSACTION = 4  # 交易钱包 用于冻结释放

g_assets_record_type = TypedefConst()

g_assets_record_type.EVALUATION = 1  # 测评奖励
g_assets_record_type.RECHARGE = 2  # 充值
g_assets_record_type.BUY = 4  # 买
g_assets_record_type.SELL = 8  # 卖
g_assets_record_type.SPONSOR = 16  # 推荐奖励
g_assets_record_type.BUY_SELL_FREE = 32  # 买卖释放
g_assets_record_type.ACCELERATE_FREE = 64  # 加速释放
g_assets_record_type.EXCHANGE = 128  # 兑换
g_assets_record_type.TRANSACTION = 256  # 转账
g_assets_record_type.DIVIDEND = 512  # 分红


class Assets(UuidBase):
    user_id = db.Column(db.String(36), db.ForeignKey('user.id'), nullable=False)

    total_balance = db.Column(db.Numeric(24, 8), default=0, nullable=False)  # 总资产钱包 冻结
    community_balance = db.Column(db.Numeric(24, 8), default=0, nullable=False)  # 社区钱包 用于交易
    community_today_balance = db.Column(db.Numeric(24, 8), default=0, nullable=False)  # 社区钱包 今日买入的冻结值 用于交易