class OauthMemberBind(db.Model): __tablename__ = 'oauth_member_bind' __table_args__ = (db.Index('idx_type_openid', 'type', 'openid'), ) id = db.Column(db.Integer, primary_key=True) member_id = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue()) client_type = db.Column(db.String(20), nullable=False, server_default=db.FetchedValue()) type = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue()) openid = db.Column(db.String(80), nullable=False, server_default=db.FetchedValue()) unionid = db.Column(db.String(100), nullable=False, server_default=db.FetchedValue()) extra = db.Column(db.Text, nullable=False) updated_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue()) created_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue())
class Member(db.Model): __tablename__ = 'members' id = db.Column(db.Integer, primary_key=True) nickname = db.Column(db.String(100), nullable=False) mobile = db.Column(db.String(11), nullable=False) sex = db.Column(db.Integer, nullable=False) avatar = db.Column(db.String(200), nullable=False) salt = db.Column(db.String(32), nullable=False) reg_ip = db.Column(db.String(100), nullable=False) status = db.Column(db.Integer, nullable=False) updated_time = db.Column(db.DateTime, nullable=False) created_time = db.Column(db.DateTime, nullable=False) remain = db.Column(db.Numeric(10, 2), nullable=False)
class Admin(db.Model): __tablename__ = 'Admin' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20)) #用户名 password_hash = db.Column(db.String(256)) #密码散列值 # 设置密码 def set_password(self, password): # 将生成的密码保持到对应字段 self.password_hash = generate_password_hash(password) # 验证密码 def check_password(self, password): # 返回bool return check_password_hash(self.password_hash, password)
class Category(db.Model): __tablename__ = 'category' id = db.Column(db.Integer, primary_key=True, unique=True) name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), nullable=False, server_default=db.FetchedValue()) updated_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue()) created_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue())
class Food(db.Model): __tablename__ = 'food' id = db.Column(db.Integer, primary_key=True) category = db.Column(db.String(100, 'utf8mb4_0900_ai_ci'), nullable=False, server_default=db.FetchedValue()) name = db.Column(db.String(100, 'utf8mb4_0900_ai_ci'), nullable=False, server_default=db.FetchedValue()) price = db.Column(db.Numeric(10, 2), nullable=False, server_default=db.FetchedValue()) priced = db.Column(db.Numeric(10, 2), nullable=False) imageName = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), nullable=False) imageURL = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), nullable=False, server_default=db.FetchedValue()) description = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), nullable=False, server_default=db.FetchedValue()) stock = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue()) status = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue()) cover = db.Column(db.Integer, nullable=False) month_count = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue()) total_count = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue()) view_count = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue()) comment_count = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue()) updated_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue()) created_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue())
class ShareHistory(db.Model): __tablename__ = 'share_history' id = db.Column(db.Integer, primary_key=True) member_id = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue()) share_url = db.Column(db.String(200), nullable=False, server_default=db.FetchedValue()) created_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue())
class FoodStockChangeLog(db.Model): __tablename__ = 'food_stock_change_log' id = db.Column(db.Integer, primary_key=True) food_id = db.Column(db.Integer, nullable=False, index=True) unit = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue()) total_stock = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue()) note = db.Column(db.String(100), nullable=False, server_default=db.FetchedValue()) created_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue())
class PaymentOrder(db.Model): __tablename__ = 'payment_order' __table_args__ = (db.Index('idx_member_id_status', 'member_id', 'status'), ) id = db.Column(db.Integer, primary_key=True) order_sn = db.Column(db.String(40), nullable=False, unique=True, server_default=db.FetchedValue()) member_id = db.Column(db.BigInteger, nullable=False, server_default=db.FetchedValue()) total_price = db.Column(db.Numeric(10, 2), nullable=False, server_default=db.FetchedValue()) yun_price = db.Column(db.Numeric(10, 2), nullable=False, server_default=db.FetchedValue()) pay_price = db.Column(db.Numeric(10, 2), nullable=False, server_default=db.FetchedValue()) pay_sn = db.Column(db.String(128), nullable=False, server_default=db.FetchedValue()) prepay_id = db.Column(db.String(128), nullable=False, server_default=db.FetchedValue()) note = db.Column(db.Text, nullable=False) status = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue()) express_status = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue()) express_address_id = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue()) express_info = db.Column(db.String(1000), nullable=False, server_default=db.FetchedValue()) comment_status = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue()) pay_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue()) updated_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue()) created_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue()) @property def pay_status(self): tmp_status = self.status if self.status == 1: tmp_status = self.express_status if self.express_status == 1 and self.comment_status == 0: tmp_status = -5 if self.express_status == 1 and self.comment_status == 1: tmp_status = 1 return tmp_status @property def status_desc(self): return app.config['PAY_STATUS_DISPLAY_MAPPING'][str(self.pay_status)] @property def order_number(self): order_number = self.created_time.strftime("%Y%m%d%H%M%S") order_number = order_number + str(self.id).zfill(5) return order_number