# -*- encoding: utf-8 -*-
# -----------------------------------------------------------------------------
# @File Name  : order.py
# @Time       : 2020/11/18 下午3:11
# @Author     : X. Peng
# @Email      : acepengxiong@163.com
# @Software   : PyCharm
# -----------------------------------------------------------------------------
from sqlalchemy import Column, BigInteger, Integer, String, DateTime, Float, text
from sqlalchemy.sql import func
from app.model.base import Base
from app.model.base import BaseModel


class OrderInfo(Base, BaseModel):
    """订单信息表"""
    __tablename__ = 'order_info'

    id = Column(BigInteger, primary_key=True)
    order_no = Column(String(50), comment='订单号')
    transaction_serial_no = Column(String(50), server_default='', comment='交易流水号')
    prod_name = Column(String(200), comment='商品名称')
    prod_type = Column(String(200), comment='商品类型')
    prod_id = Column(String(200), comment='商品ID')
    prod_quantity = Column(Integer, server_default=text('1'), comment='数量')
    amount = Column(Float, comment='订单总额')
    user_id = Column(String(100), comment='用户ID')
    user_apple_id = Column(String(100), comment='用户苹果ID')
    order_status = Column(Integer, server_default=text('0'), comment='订单状态：0:未支付，1:已支付，2:已退款')
    pay_method = Column(Integer, server_default=text('1'), comment='支付方式：1:苹果支付，2:微信支付，3:支付宝支付')
    create_time = Column(DateTime(timezone=True), server_default=func.now(), comment='下单时间')
    pay_time = Column(DateTime(timezone=True), server_default=func.now(), comment='支付时间')
    del_flag = Column(Integer, server_default=text('0'), comment='是否删除,0:未删除,1:已删除')

