class PayTypeInfo(db.Model): __tablename__ = 't_pay_type_info' id = db.Column('id', db.Integer, primary_key=True) shopId = db.Column('shop_id', db.Integer) typeName = db.Column('type_name', db.String(128)) typeValue = db.Column('type_value', db.String(128)) def __init__(self, shopId, typeName, typeValue): self.shopId = shopId self.typeName = typeName self.typeValue = typeValue def to_json(self): return { "id": self.id, "shopId": self.shopId, "typeName": self.typeName, "typeValue": self.typeValue } def __repr__(self): if self.id: return '<PayTypeInfo@id=%d,shopId=%d,typeName=%s,typeValue=%s>' % ( self.id, self.shopId, self.typeName, self.typeValue) else: return '<PayTypeInfoshopId=%d,typeName=%s,typeValue=%s>' % ( self.shopId, self.typeName, self.typeValue)
class Shop(db.Model): __tablename__ = "t_shop" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(128)) address = db.Column('address', db.String(1024)) userId = db.Column("owner_id", db.Integer) code = db.Column('code', db.String(128)) changedDate = db.Column('changed_date', db.DateTime) def __init__(self, name, userId, code, changedDate=None, address=None): #self.id = 0 self.name = name self.address = address self.userId = userId self.changedDate = changedDate self.code = code # @staticmethod def to_json(self): return { 'name': self.name, 'address': self.address, 'userId': self.userId, 'changeDate': self.changedDate.strftime("%Y-%m-%d %H:%M:%S"), 'code': self.code }
class EmployeeInfo(db.Model): __tablename__ = 't_employee_info' id = db.Column('id', db.Integer, primary_key=True) name = db.Column('name', db.String(128)) password = db.Column('password', db.String(1024)) telephone = db.Column('telephone', db.String(16)) email = db.Column('email', db.String(512)) departmentId = db.Column('department_id', db.Integer) roleId = db.Column('role_id', db.Integer) shopId = db.Column('shop_id', db.Integer) code = db.Column('code', db.Integer) isEnabled = db.Column('is_enabled', db.Boolean) def __init__(self, name, password, shopId, roleId, departmentId, telephone=None, email=None, code=0, isEnabled=True): self.name = name self.shopId = shopId self.password = password self.roleId = roleId self.departmentId = departmentId self.telephone = telephone self.email = email self.code = code self.isEnabled = isEnabled def to_json(self): return { "id": self.id, "name": self.name, "password": self.password, "roleId": self.roleId, "departmentId": self.departmentId, "telephone": telephone, "email": self.email, self.code: self.code, "isEnabled": self.isEnabled } def __repr__(self): if self.id: return '<EmployeeInfo@id=%d,roleId=%d,departmentId=%d,name=%s>' % ( self.id, self.roleId, self.departmentId, self.name) else: return '<EmployeeInfo@roleId=%d,departmentId=%d,name=%s>' % ( self.roleId, self.departmentId, self.name)
class Pinyin(db.Model): __tablename__ = "t_pinyin" id = db.Column('id', db.Integer, primary_key=True) hanzi = db.Column('hanzi', db.String(128)) capital = db.Column('capital', db.String(128)) def __init__(self, hanzi, cap): self.hanzi = hanzi self.capital = cap def __repr__(self): return '<hanzi=%s,cap=%s>' % (self.hanzi, self.capital)
class ProductSKUProperty(db.Model): __tablename__ = 't_product_sku_property' id = db.Column('id', db.Integer, primary_key=True) shopId = db.Column('shop_id', db.Integer) productId = db.Column('product_id', db.Integer) skuId = db.Column('sku_id', db.Integer) productProperties = db.Column('product_prop_id', db.String(128)) def __init__(self, shopId, productId, skuId, productProperties): self.shopId = shopId self.productId = productId self.skuId = skuId self.productProperties = productProperties def to_json(self): return { "id": self.id, "productId": self.productId, "skuId": self.skuId, "productProperties": self.productProperties } def __repr__(self): if self.id: return '<ProductSKUProperty@id=%d,shopId=%d,productId=%d,skuId=%d,productProperties=%s>' % ( self.id, self.shopId, self.productId, self.skuId, self.productProperties) else: return '<ProductSKUProperty@shopId=%d,productId=%d,skuId=%d,productProperties=%s>' % ( self.shopId, self.productId, self.skuId, self.productProperties)
class ProductSKUInfo(db.Model): __tablename__ = 't_product_sku_info' id = db.Column('id', db.Integer, primary_key=True) shopId = db.Column('shop_id', db.Integer) productId = db.Column('product_id', db.Integer) skuCode = db.Column('sku_code', db.String(128)) storeCounts = db.Column('store_counts', db.Integer) def __init__(self, shopId, productId, skuCode, storeCounts=0): self.shopId = shopId self.productId = productId self.skuCode = skuCode self.storeCounts = storeCounts def to_json(self): return { "id": self.id, "shopId": self.shopId, "productId": self.productId, "skuCode": self.skuCode, "storeCounts": self.storeCounts } def __repr__(self): if self.id: return '<ProductSKUInfo@id=%d,shopId=%d,productId=%d,skuCode=%s,storeCounts=%d>' % ( self.id, self.shopId, self.productId, self.skuCode, self.storeCounts) else: return '<ProductSKUInfo@shopId=%d,productId=%d,skuCode=%s,storeCounts=%d>' % ( self.shopId, self.productId, self.skuCode, self.storeCounts)
class ProductPropertyGroup(db.Model): __tablename__ = 't_product_property_group' id = db.Column('id',db.Integer,primary_key = True) shopId = db.Column('shop_id',db.Integer) productId = db.Column('product_id',db.Integer) name = db.Column('name',db.String(128)) def __init__(self,shopId,productId,name): self.shopId = shopId self.productId = productId self.name = name def to_json(self): return { "id":self.id, "shopId":self.shopId, "productId":self.productId, "name":self.name } def __repr__(self): if self.id: return '<ProductPropertyGroup@id=%d,shopId=%d,productId=%d,name=%s>' %( self.id,self.shopId,self.productId,self.name) else: return '<ProductPropertyGroup@shopId=%d,productId=%d,name=%s>' %( self.shopId,self.productId,self.name)
class EmployeeAuthorityGroup(db.Model): __tablename__ = 't_role_authority_group' id = db.Column('id', db.Integer, primary_key=True) name = db.Column('name', db.String(128)) shopId = db.Column('shop_id', db.Integer) authorityId = db.Column('authority_id', db.Integer) isLeaf = True def __init__(self, shopId, name, authorityId): self.shopId = shopId self.name = name self.authorityId = authorityId self.isLeaf = True def to_json(self): return { "id": self.id, "name": self.name, "shopId": self.shopId, "authorityId": self.authorityId, "leaf": True, "text": self.name } def __repr__(self): if self.id: return '<RoleAuthorityGroup@id=%d,shopId=%d,authorityId=%d,name=%s>' % ( self.id, self.shopId, self.authorityId, self.name) else: return '<RoleAuthorityGroushopId=%d,authorityId=%d,name=%s>' % ( self.shopId, self.authorityId, self.name)
class EmployeeRoleAuthority(db.Model): __tablename__ = 't_role_authority' id = db.Column('id',db.Integer,primary_key=True) shopId = db.Column('shop_id',db.Integer) name = db.Column('name',db.String(128)) roleValue = db.Column('role_value',db.Integer) authorityGroup = db.Column('authority_group_id',db.Integer) def __init__(self,shopId,name,roleValue,authorityGroup): self.shopId = shopId self.name = name self.roleValue = roleValue self.authorityGroup = authorityGroup def to_json(self): return { "id":self.id, "name":name, "roleValue":self.roleValue, "authorityGroupId":self.authorityGroup } def __repr__(self): if self.id: return '<EmployeeRoleAuthority@id=%d,shopId=%d,name=%s,roleValue=%d>' %( self.id,self.shopId,self.name,self.roleValue) else: return '<EmployeeRoleAuthority@shopId=%d,name=%s,roleValue=%d>' % ( self.shopId,self.name,self.roleValue)
class ProductCategory(db.Model): __tablename__ = 't_product_category' id = db.Column('id',db.Integer,primary_key = True) name = db.Column('name',db.String(128)) shopId = db.Column('shop_id',db.Integer) parentId = db.Column('category_parent_id',db.Integer) lft = db.Column('lft',db.Integer) rgt = db.Column('rgt',db.Integer) isLeaf = False def __init__(self,name,shopId,parentId,lft = -1,rgt = -1): #self.id = 0 self.name = name self.shopId = shopId self.parentId = parentId self.lft = lft self.rgt = rgt #@staticmethod def to_json(self): # if obj is ProductCategory: return { "id":self.id, "name": self.name, "text": self.name, "shopId":self.shopId, "pid":self.parentId, "leaf":self.isLeaf, "lft":self.lft, "rgt":self.rgt }
class ProductProperty(db.Model): __tablename__ = "t_product_property" id = db.Column('id', db.Integer, primary_key=True) shopId = db.Column('shop_id', db.Integer) productId = db.Column('product_id', db.Integer) propertyType = db.Column('prop_type', db.Integer) propertyName = db.Column('prop_name', db.String(128)) propertyValue = db.Column('prop_value', db.String(1024)) groupId = db.Column('prop_group_id', db.Integer) def __init__(self, shopId, productId, propertyType, propertyName, propertyValue, groupId): self.shopId = shopId self.productId = productId self.propertyType = propertyType self.propertyName = propertyName self.propertyValue = propertyValue self.groupId = groupId def to_json(self): return { "id": self.id, "shopId": self.shopId, "propertyType": self.propertyType, "propertyName": self.propertyName, "propertyValue": self.propertyValue, "groupId": self.groupId } def __repr__(self): if self.id: return '<ProductProperty@id=%d,shopId=%d,productId=%d,propertyName=%s,propertyValue=%s,groupId=%d>' % ( self.id, self.shopId, self.productId, self.propertyName, self.propertyValue, self.groupId) else: return '<ProductProperty@shopId=%d,productId=%d,propertyName=%s,propertyValue=%s,groupId=%d>' % ( self.shopId, self.productId, self.propertyName, self.propertyValue, self.groupId)
class User(db.Model): __tablename__ = "t_user" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(128)) address = db.Column(db.String(1024)) phone = db.Column(db.String(16)) telephone = db.Column(db.String(32)) fax = db.Column(db.String(32)) qq = db.Column(db.String(32)) email = db.Column(db.String(128)) password = db.Column(db.String(1024)) code = db.Column(db.String(128)) changedDate = db.Column('changed_date', db.DateTime) def __init__(self, name, changedDate, password=None, code=None, phone=None, address=None, telephone=None, fax=None, qq=None, email=None): #self.id = 0 self.name = name self.code = code self.address = address self.phone = phone self.telephone = telephone self.fax = fax self.qq = qq self.email = email self.password = password self.changedDate = changedDate def __repr__(self): if self.id: return '<User@id=%d,name=%s>' % (self.id, self.name) else: return '<User@name=%s>' % (self.name)
class Supplier(db.Model): __tablename__ = 't_supplier_info' id = db.Column('id', db.Integer, primary_key=True) name = db.Column('name', db.String(128)) address = db.Column('address', db.String(1024)) mobilePhone = db.Column('phone', db.String(16)) telephone = db.Column('telephone', db.String(32)) fax = db.Column('fax', db.String(32)) qq = db.Column('qq', db.String(16)) shopId = db.Column('shop_id', db.Integer) userId = db.Column('owner_id', db.Integer) email = db.Column('email', db.String(128)) def __init__(self, name, shopId, userId, address=None, mobilePhone=None, telephone=None, fax=None, qq=None, email=None): #self.id = 0 self.name = name self.address = address self.mobilePhone = mobilePhone self.telephone = telephone self.fax = fax self.qq = qq self.shopId = shopId self.userId = userId self.email = email def __repr__(self): if self.id: return '<Supplier@id=%d,userId=%d,shopId=%d,name=%s>' % ( self.id, self.userId, self.shopId, self.name) else: return '<Supplier@userId=%d,shopId=%d,name=%s>' % ( self.userId, self.shopId, self.name)
class Department(db.Model): __tablename__ = 't_department_info' id = db.Column('id', db.Integer, primary_key=True) shopId = db.Column('shop_id', db.Integer) name = db.Column('name', db.String(128)) parentId = db.Column('parent_id', db.Integer) lft = db.Column('lft', db.Integer) rgt = db.Column('rgt', db.Integer) isLeaf = False def __init__(self, shopId, name, parentId, lft=-1, rgt=-1): self.name = name self.shopId = shopId self.parentId = parentId self.lft = lft self.rgt = rgt self.isLeaf = False def to_json(self): print(self.name) return { "id": self.id, "name": self.name, "shopId": self.shopId, "parentId": self.parentId, "lft": self.lft, "rgt": self.rgt, "leaf": self.isLeaf, "text": self.name } def __repr__(self): if self.id: return '<Department@id=%d,shopId=%d,name=%s,parentId=%d>' % ( self.id, self.shopId, self.name, self.parentId) else: return '<Department@shopId=%d,name=%s,parentId=%d>' % ( self.shopId, self.name, self.parentId)
class EmployeeRole(db.Model): __tablename__ = 't_employee_role' id = db.Column('id',db.Integer,primary_key = True) shopId = db.Column('shop_id',db.Integer) name = db.Column('name',db.String(128)) def __init__(self,shopId,name): self.shopId = shopId self.name = name def to_json(self): return{ "id":self.id, "name":self.name, "shopId":self.shopId } def __repr__(self): if self.id: return '<EmployeeRole@id=%d,shopId=%d,name=%s>' % ( self.id,self.shopId,self.name) else: return '<EmployeeRole@shopId=%d,name=%s>'%(self.shopId,self.name)
class ProductBaseInfo(db.Model): __tablename__ = "t_product_base_info" id = db.Column('id', db.Integer, primary_key=True) shopId = db.Column('shop_id', db.Integer) name = db.Column('name', db.String(128)) code = db.Column('code', db.String(128)) barcode = db.Column('barcode', db.String(128)) pinyinCode = db.Column('pinyin_code', db.String(128)) categoryName = db.Column('category_name', db.String(128)) categoryId = db.Column('category_id', db.Integer) unitName = db.Column('unit_name', db.String(128)) puchasePrice = db.Column('puchase_price', db.Float) retailPrice = db.Column('sell_price', db.Float) wholesalePrice = db.Column('wholesale_price', db.Float) supplierName = db.Column('supplier_name', db.String(128)) supplierId = db.Column('supplier_id', db.Integer) isEnabled = db.Column('is_enabled', db.Boolean) createDateTime = db.Column('create_datetime', db.DateTime) modifyDateTime = db.Column('modify_datetime', db.DateTime) def __init__(self, shopId, name, code, barcode, pinyinCode, categoryId, categoryName, unitName, puchasePrice, retailPrice, wholesalePrice, supplierName, supplierId, createDateTime, modifyDateTime, isEnabled=True): self.shopId = shopId self.name = name self.code = code self.barcode = barcode self.pinyinCode = pinyinCode self.categoryId = categoryId self.categoryName = categoryName self.unitName = unitName self.puchasePrice = puchasePrice self.wholesalePrice = wholesalePrice self.retailPrice = retailPrice self.supplierId = supplierId self.supplierName = supplierName self.createDateTime = createDateTime self.modifyDateTime = modifyDateTime self.isEnabled = isEnabled def to_json(self): return { "id": self.id, "shopId": self.shopId, "name": self.name, "code": self.code, "barcode": self.barcode, "pinyinCode": self.pinyinCode, "categoryName": self.categoryName, "categoryId": self.categoryId, "unitName": self.unitName, "purchasePrice": self.puchasePrice, "retailPrice": self.retailPrice, "wholesalePrice": self.wholesalePrice, "supplierName": self.supplierName, "supplierId": self.supplierId, "isEnable": self.isEnabled, "createDateTime": self.createDateTime.strftime("%Y-%m-%d %H:%M:%S"), "modifyDateTime": self.modifyDateTime.strftime("%Y-%m-%d %H:%M:%S") } def __repr__(self): if self.id: return '<ProductBaseInfo@id=%d,name=%s,shopId=%d,categoryId=%d>' % ( self.id, self.name, self.shopId, self.categoryId) else: return '<ProductBaseInfo@name=%s,shopId=%d,categoryId=%d>' % ( self.name, self.shopId, self.categoryId)
class RetailDetail(db.Model): __tablename__ = 't_retail_detail' id = db.Column('id', db.Integer, primary_key=True) shopId = db.Column('shop_id', db.Integer) orderId = db.Column('order_id', db.String(128)) operatorId = db.Column('operator_id', db.Integer) orderType = db.Column('retail_type', db.Integer) orderTotalPrice = db.Column('order_total_price', db.Float) productCounts = db.Column('product_counts', db.Integer) memberId = db.Column('member_id', db.Integer) orderRealTotalPrice = db.Column('order_real_price', db.Float) orderProfit = db.Column('order_profit', db.Float) orderDescription = db.Column('order_desc', db.String(1024)) payType = db.Column('pay_type', db.Integer) retailDate = db.Column('retail_date', db.DateTime) def __init__(self, shopId, operatorId, orderType, orderTotalPrice, productCounts, memberId, orderRealTotalPrice, orderProfit, payType, retailDate, orderId, orderDescription=None): self.shopId = shopId self.operatorId = operatorId self.orderType = orderType self.orderTotalPrice = orderTotalPrice self.productCounts = productCounts self.memberId = memberId self.orderRealTotalPrice = orderRealTotalPrice self.orderProfit = orderProfit self.orderDescription = orderDescription self.payType = payType self.retailDate = retailDate self.orderId = orderId def to_json(self): return { "id": self.id, "shopId": self.shopId, "operatorId": self.operatorId, "orderType": self.orderType, "orderTotalPrice": self.orderTotalPrice, "memberId": self.memberId, "orderProfit": self.orderProfit, "orderDescription": self.orderDescription, "payType": self.payType, "retailDate": self.retailDate.strftime("%Y-%m-%d %H:%M:%S"), "orderId": self.orderId } def __repr__(self): if self.id: return '<RetailOrderInfo@id=%d,shopId=%d,operatorId=%d,orderType=%d,orderTotalPrice=%f,productCount=%d,memberId=%d,orderRealTotalPrice=%f,orderProfit=%f,orderId=%s,orderDescription=%s>' % ( self.id, self.shopId, self.operatorId, self.orderType, self.orderTotalPrice, self.productCounts, self.memberId, self.orderRealTotalPrice, self.orderProfit, self.orderId, self.orderDescription) else: return '<RetailOrderInfo@shopId=%d,operatorId=%d,orderType=%d,orderTotalPrice=%f,productCount=%d,memberId=%d,orderRealTotalPrice=%f,orderProfit=%f,orderId=%s,orderDescription=%s>' % ( self.shopId, self.operatorId, self.orderType, self.orderTotalPrice, self.productCounts, self.memberId, self.orderRealTotalPrice, self.orderProfit, self.orderId, self.orderDescription)