class ProductPrice(db.Model): __tablename__ = 'mtt_md_product_prices' product_no = db.Column(INTEGER, primary_key=True) account_type = db.Column(SMALLINT, primary_key=True) unit_price = db.Column(DECIMAL(12, 2), nullable=False) updated_at = db.Column(DateTime, nullable=False) def __init__(self, product_no, account_type, unit_price): self.product_no = product_no self.account_type = account_type self.unit_price = unit_price self.updated_at = get_current_datetime_str() def to_dict(self, output_attrs=None): """Returns the model attributes as a dict :output_attrs: list that includes attributes to convert """ if output_attrs: return { col.name: getattr(self, col.name) for col in self.__table__.columns if col.name in output_attrs } return { col.name: getattr(self, col.name) for col in self.__table__.columns }
class Cart(db.Model): __tablename__ = 'mtt_tx_carts' user_no = db.Column(INTEGER, primary_key=True) product_no = db.Column(INTEGER, primary_key=True) product_quantity = db.Column(INTEGER, nullable=False) created_at = db.Column(DateTime, nullable=False) updated_at = db.Column(DateTime, nullable=False) def __init__(self, user_no, product_no, product_quantity): self.user_no = user_no self.product_no = product_no self.product_quantity = product_quantity self.created_at = get_current_datetime_str() self.updated_at = get_current_datetime_str() def to_dict(self, output_attrs=None): """Returns the model attributes as a dict :output_attrs: list that includes attributes to convert """ if output_attrs: return {col.name: getattr(self, col.name) for col in self.__table__.columns if col.name in output_attrs} return {col.name: getattr(self, col.name) for col in self.__table__.columns}
class Partner(db.Model): __tablename__ = 'mtt_md_partners' partner_id = db.Column(String(50), primary_key=True) partner_status = db.Column(SMALLINT, nullable=False) partner_name = db.Column(String(50), nullable=False) created_at = db.Column(DateTime, nullable=False) updated_at = db.Column(DateTime, nullable=False) def __init__(self, partner_id, partner_name, partner_status=200): self.partner_id = partner_id self.partner_status = partner_status self.partner_name = partner_name self.created_at = get_current_datetime_str() self.updated_at = get_current_datetime_str() #def __repr__(self): # return "<{0} partner_id: {1}, partner_status: {2}, partner_name: {3}, created_at: {4}, updated_at:{5}>".\ # format(self.__class__.name, self.partner_id, self.partner_status, self.partner_name, str(self.created_at), str(self.updated_at)) def to_dict(self, output_attrs=None): """Returns the model attributes as a dict :output_attrs: list that includes attributes to convert """ if output_attrs: return { col.name: getattr(self, col.name) for col in self.__table__.columns if col.name in output_attrs } return { col.name: getattr(self, col.name) for col in self.__table__.columns }
class PaymentMethodProperty(db.Model): __tablename__ = 'mtt_md_payment_method_properties' method_code = db.Column(String(10), primary_key=True) property_type = db.Column(SMALLINT, primary_key=True) property_value = db.Column(String(250), nullable=True) created_at = db.Column(DateTime, nullable=False) updated_at = db.Column(DateTime, nullable=False) def __init__(self, method_code, property_type, property_value=None): self.method_code = method_code self.property_type = property_type self.property_value = property_value self.created_at = get_current_datetime_str() self.updated_at = get_current_datetime_str() def to_dict(self, output_attrs=None): """Returns the model attributes as a dict :output_attrs: list that includes attributes to convert """ if output_attrs: return { col.name: getattr(self, col.name) for col in self.__table__.columns if col.name in output_attrs } return { col.name: getattr(self, col.name) for col in self.__table__.columns }
class Product(db.Model): __tablename__ = 'mtt_md_products' product_no = db.Column(INTEGER, primary_key=True, autoincrement=True) product_id = db.Column(String(50), nullable=False, unique=True) product_status = db.Column(SMALLINT, nullable=False) product_name = db.Column(String(50), nullable=False) product_type = db.Column(String(20), nullable=False) created_at = db.Column(DateTime, nullable=False) updated_at = db.Column(DateTime, nullable=False) product_description = db.Column(TEXT, nullable=True) def __init__(self, product_id, product_status, product_name, product_type, product_description=None): if not product_id: product_id = str(uuid.uuid4()) self.product_id = product_id self.product_status = product_status self.product_name = product_name self.product_type = product_type self.product_description = product_description self.created_at = get_current_datetime_str() self.updated_at = get_current_datetime_str() def to_dict(self, output_attrs=None): """Returns the model attributes as a dict :output_attrs: list that includes attributes to convert """ if output_attrs: return {col.name: getattr(self, col.name) for col in self.__table__.columns if col.name in output_attrs} return {col.name: getattr(self, col.name) for col in self.__table__.columns}
class OrderProduct(db.Model): __tablename__ = "mtt_tx_order_products" order_no = db.Column(INTEGER, primary_key=True) product_no = db.Column(INTEGER, primary_key=True) account_type = db.Column(SMALLINT, primary_key=True) unit_price = db.Column(DECIMAL(12, 2), nullable=False) order_quantity = db.Column(INTEGER, nullable=False) total_product_amount = db.Column(DECIMAL(12, 2), nullable=False) def __init__(self, order_no, product_no, account_type, unit_price, order_quantity, total_product_amount): self.order_no = order_no self.product_no = product_no self.account_type = account_type self.unit_price = unit_price self.order_quantity = order_quantity self.total_product_amount = total_product_amount def to_dict(self, output_attrs=None): """Returns the model attributes as a dict :output_attrs: list that includes attributes to convert """ if output_attrs: return { col.name: getattr(self, col.name) for col in self.__table__.columns if col.name in output_attrs } return { col.name: getattr(self, col.name) for col in self.__table__.columns }
class PaymentMethodResponseType(db.Model): __tablename__ = 'mtt_md_payment_method_response_types' method_code = db.Column(String(10), primary_key=True) paymenet_response = db.Column(String(50), primary_key=True) payment_status = db.Column(SMALLINT, primary_key=True) created_at = db.Column(DateTime, nullable=False) updated_at = db.Column(DateTime, nullable=False) type_description = db.Column(TEXT, nullable=True) def __init__(self, method_code, payment_response, payment_status, type_description=None): self.method_code = method_code self.paymenet_response = payment_response self.payment_status = payment_status self.type_description = type_description self.created_at = get_current_datetime_str() self.updated_at = get_current_datetime_str() def to_dict(self, output_attrs=None): """Returns the model attributes as a dict :output_attrs: list that includes attributes to convert """ if output_attrs: return {col.name: getattr(self, col.name) for col in self.__table__.columns if col.name in output_attrs} return {col.name: getattr(self, col.name) for col in self.__table__.columns}
class User(db.Model): __tablename__ = 'mtt_uw_users' user_no = db.Column(INTEGER, primary_key=True, autoincrement=True) user_id = db.Column(String(50), nullable=False, unique=True) partner_id = db.Column(String(50), nullable=False) user_status = db.Column(SMALLINT, nullable=False) user_type = db.Column(SMALLINT, nullable=False) user_level = db.Column(SMALLINT, nullable=False) first_name = db.Column(String(50), nullable=False) last_name = db.Column(String(50), nullable=False) created_at = db.Column(DateTime, nullable=False) updated_at = db.Column(DateTime, nullable=False) def __init__(self, user_id, partner_id, user_status, user_type, user_level, first_name, last_name): self.user_id = user_id self.partner_id = partner_id self.user_status = user_status self.user_type = user_type self.user_level = user_level self.first_name = first_name self.last_name = last_name self.created_at = get_current_datetime_str() self.updated_at = get_current_datetime_str() def to_dict(self, output_attrs=None): """Returns the model attributes as a dict :output_attrs: list that includes attributes to convert """ if output_attrs: return { col.name: getattr(self, col.name) for col in self.__table__.columns if col.name in output_attrs } return { col.name: getattr(self, col.name) for col in self.__table__.columns }
class Transaction(db.Model): __tablename__ = 'mtt_tx_transactions' trx_no = db.Column(INTEGER, primary_key=True, autoincrement=True) trx_id = db.Column(String(50), nullable=False, index=True) account_no = db.Column(INTEGER, nullable=False, index=True) trx_type = db.Column(SMALLINT, nullable=False) trx_status = db.Column(SMALLINT, nullable=False) created_at = db.Column(DateTime, nullable=False) updated_at = db.Column(DateTime, nullable=False) trx_amount = db.Column(DECIMAL(12, 2), nullable=False) sender_no = db.Column(INTEGER, nullable=True) trx_note = db.Column(String(50), nullable=True) def __init__(self, trx_id, account_no, trx_type, trx_status, trx_amount, sender_no=None, trx_note=None): self.trx_id = trx_id self.account_no = account_no self.trx_type = trx_type self.trx_status = trx_status self.created_at = get_current_datetime_str() self.updated_at = get_current_datetime_str() self.trx_amount = trx_amount self.sender_no = sender_no self.trx_note = trx_note def to_dict(self, output_attrs=None): """Returns the model attributes as a dict :output_attrs: list that includes attributes to convert """ if output_attrs: return {col.name: getattr(self, col.name) for col in self.__table__.columns if col.name in output_attrs} return {col.name: getattr(self, col.name) for col in self.__table__.columns}
class UserAccount(db.Model): __tablename__ = 'mtt_uw_user_accounts' __table_args__ = (Index('mtd_uw_user_accounts_user_no', 'user_no', 'account_type', unique=True), ) account_no = db.Column(INTEGER, primary_key=True, autoincrement=True) account_id = db.Column(String(50), nullable=False, unique=True) user_no = db.Column(INTEGER, nullable=False) account_type = db.Column(SMALLINT, nullable=False) account_status = db.Column(SMALLINT, nullable=False) balance_amount = db.Column(INTEGER, nullable=False) created_at = db.Column(DateTime, nullable=False) updated_at = db.Column(DateTime, nullable=False) def __init__(self, account_type=None, balance_amount=None): #self.user_no = user_no self.account_type = account_type self.account_status = 200 self.balance_amount = balance_amount self.created_at = get_current_datetime_str() self.updated_at = get_current_datetime_str() def to_dict(self, output_attrs=None): """Returns the model attributes as a dict s :output_attrs: list that includes attributes to convert """ if output_attrs: return { col.name: getattr(self, col.name) for col in self.__table__.columns if col.name in output_attrs } return { col.name: getattr(self, col.name) for col in self.__table__.columns }
class TransactionType(db.Model): __tablename__ = 'mtt_tx_transaction_types' trx_type = db.Column(SMALLINT, primary_key=True) trx_type_name = db.Column(String(50), nullable=False) io_type = db.Column(TINYINT, nullable=False) parent_trx_type = db.Column(SMALLINT, nullable=True) created_at = db.Column(DateTime, nullable=False) updated_at = db.Column(DateTime, nullable=False) trx_type_description = db.Column(String(250), nullable=True) def __init__(self, trx_type, trx_type_name, io_type, parent_trx_type=None, trx_type_description=None): self.trx_type = trx_type self.trx_type_name = trx_type_name self.io_type = io_type self.parent_trx_type = parent_trx_type self.created_at = get_current_datetime_str() self.updated_at = get_current_datetime_str() self.trx_type_description = trx_type_description def to_dict(self, output_attrs=None): """Returns the model attributes as a dict :output_attrs: list that includes attributes to convert """ if output_attrs: return { col.name: getattr(self, col.name) for col in self.__table__.columns if col.name in output_attrs } return { col.name: getattr(self, col.name) for col in self.__table__.columns }
class OrderPaymentLog(db.Model): __tablename__ = "mtt_tx_order_payment_logs" log_no = db.Column(INTEGER, primary_key=True, autoincrement=True) payment_no = db.Column(INTEGER, nullable=False, Index=True) payment_status = db.Column(SMALLINT, nullable=False) created_at = db.Column(DateTime, nullable=False) remote_ip = db.Column(String(50), nullable=True) log_text = db.Column(Text, nullable=True) def __init__(self, order_no, method_code, payment_status, remote_ip=None, log_text=None): self.order_no = order_no self.method_code = method_code self.payment_status = payment_status self.remote_ip = remote_ip self.log_text = log_text self.created_at = get_current_datetime_str() def to_dict(self, output_attrs=None): """Returns the model attributes as a dict :output_attrs: list that includes attributes to convert """ if output_attrs: return { col.name: getattr(self, col.name) for col in self.__table__.columns if col.name in output_attrs } return { col.name: getattr(self, col.name) for col in self.__table__.columns }
class AccountType(db.Model): __tablename__ = 'mtt_md_account_types' account_type = db.Column(SMALLINT, primary_key=True) account_type_name = db.Column(String(50), nullable=False) account_type_status = db.Column(SMALLINT, nullable=False) created_at = db.Column(DateTime, nullable=False) updated_at = db.Column(DateTime, nullable=False) account_type_description = db.Column(String(250), nullable=True) def __init__(self, account_type, account_type_name, account_type_status=200, account_type_description=None): self.account_type = account_type self.account_type_name = account_type_name self.account_type_status = account_type_status self.created_at = get_current_datetime_str() self.updated_at = get_current_datetime_str() self.account_type_description = account_type_description def to_dict(self, output_attrs=None): """Returns the model attributes as a dict :output_attrs: list that includes attributes to convert """ if output_attrs: return { col.name: getattr(self, col.name) for col in self.__table__.columns if col.name in output_attrs } return { col.name: getattr(self, col.name) for col in self.__table__.columns }
class OrderPayment(db.Model): __tablename__ = "mtt_tx_order_payments" payment_no = db.Column(INTEGER, primary_key=True, autoincrement=True) order_no = db.Column(INTEGER, nullable=False) method_code = db.Column(String(10), nullable=False) payment_status = db.Column(SMALLINT, nullable=False) created_at = db.Column(DateTime, nullable=False) updated_at = db.Column(DateTime, nullable=False) payment_currency = db.Column(String(3), nullable=False) payment_amount = db.Column(DECIMAL(12, 2), nullable=False) trx_id = db.Column(String(50), nullable=True) ref_id = db.Column(String(50), nullable=True) approval_code = db.Column(String(50), nullable=True) reason_code = db.Column(String(50), nullable=True) avs_result = db.Column(String(50), nullable=True) cvv_result = db.Column(String(50), nullable=True) def __init__(self, order_no, method_code, payment_status, payment_currency, payment_amount, trx_id, ref_id, approval_code, reason_code, cvv_result): self.order_no = order_no self.method_code = method_code self.payment_status = payment_status self.payment_currency = payment_currency self.payment_amount = payment_amount self.trx_id = trx_id self.ref_id = ref_id self.approval_code = approval_code self.reason_code = reason_code self.cvv_result = cvv_result self.created_at = get_current_datetime_str() self.updated_at = get_current_datetime_str() def to_dict(self, output_attrs=None): """Returns the model attributes as a dict :output_attrs: list that includes attributes to convert """ if output_attrs: return {col.name: getattr(self, col.name) for col in self.__table__.columns if col.name in output_attrs} return {col.name: getattr(self, col.name) for col in self.__table__.columns}
class Order(db.Model): __tablename__ = "mtt_tx_orders" order_no = db.Column(INTEGER, primary_key=True, autoincrement=True) order_id = db.Column(String(50), nullable=False, unique=True) user_no = db.Column(INTEGER, nullable=False) order_status = db.Column(SMALLINT, nullable=False) created_at = db.Column(DateTime, nullable=False) updated_at = db.Column(DateTime, nullable=False) order_amount = db.Column(DECIMAL(12, 2), nullable=False) tax_amount = db.Column(DECIMAL(12, 2), nullable=False) total_amount = db.Column(DECIMAL(12, 2), nullable=False) platform_type = db.Column(String(50), nullable=True) app_type = db.Column(String(50), nullable=True) def __init__(self, order_id, user_no, order_status, order_amount, tax_amount, total_amount, platform_type=None, app_type=None): self.order_id = order_id self.user_no = user_no self.order_status = order_status self.order_amount = order_amount self.tax_amount = tax_amount self.total_amount = total_amount self.platform_type = platform_type self.app_type = app_type self.created_at = get_current_datetime_str() self.updated_at = get_current_datetime_str() def to_dict(self, output_attrs=None): """Returns the model attributes as a dict :output_attrs: list that includes attributes to convert """ if output_attrs: return { col.name: getattr(self, col.name) for col in self.__table__.columns if col.name in output_attrs } return { col.name: getattr(self, col.name) for col in self.__table__.columns }