Beispiel #1
0
class Seller(SurrogatePK, Model):

    __tablename__ = 'sellers'

    user_id = reference_col('users')

    #店铺名称
    name = Column(db.String(100))
    #店铺地址
    address = Column(db.String(255))
    #店铺LOGO
    logo = Column(db.String(255))
    #是否自营 1自营  默认0
    self_business = Column(db.Integer(), default=0)
    #评价总分数
    evaluate = Column(db.Integer())
    #评价总商品数量,得出平均店铺评分
    evaluate_count = Column(db.Integer())
    #店铺位置  地图坐标
    address_map = Column(db.String(100))
    #店铺状态,默认1
    status = Column(db.Integer(), default=1)
    #是否启用
    active = Column(db.Boolean(), default=True)
    #店铺备注
    note = Column(db.String(255))
    #创建时间
    created_at = Column(db.DateTime, nullable=False, default=dt.datetime.now)

    #联系方式
    contact = Column(db.String(255))

    seller_banner_id = relationship('SellerBanner', backref='seller')
    #订单
    user_order_id = relationship('UserOrder', backref='seller')
    #进货单
    receipt_id = relationship('Receipt', backref='seller')

    seller_info_id = relationship('SellerInfo', backref='seller')
    sale_id = relationship('Sale', backref='seller')
    #申请店铺默认不启用,管理员同意
    enable = Column(db.Boolean, default=False)

    #每日最大订单
    max_order = Column(db.Integer, default=10)
    #每日最大交易额
    max_price = Column(db.Integer, default=500)
    #最大仓库
    max_warehouse = Column(db.Integer, default=1)
    #最大货位
    max_goods_location = Column(db.Integer, default=2)
    #商品数量
    max_goods_count = Column(db.Integer, default=20)
    #level等级
    level = Column(db.String(20), default=u'免费会员')
Beispiel #2
0
class User(UserMixin, SurrogatePK, Model):
    """A user of the app."""

    __tablename__ = 'users'
    username = Column(db.String(80), unique=True, nullable=False)
    #: The hashed password
    password = Column(db.Binary(128), nullable=True)
    created_at = Column(db.DateTime, nullable=False, default=dt.datetime.now)
    first_name = Column(db.String(30), nullable=True)
    last_name = Column(db.String(30), nullable=True)
    active = Column(db.Boolean(), default=False)
    is_admin = Column(db.Boolean(), default=False)

    #位置
    address_map = Column(db.String(100))
    #手机号,也可以用于登陆
    phone = Column(db.String(20), index=True, unique=True)
    #最后一次登陆时间
    last_time = Column(db.DateTime, default=dt.datetime.now)

    wechat_id = Column(db.String(100))

    role = relationship('Role', backref='roles')
    #店铺一对一
    seller_id = relationship('Seller', backref='users', uselist='False')
    user_address_id = relationship('UserAddress', backref='users')
    user_order_id = relationship('UserOrder', backref='users_buy')

    # car_session_id = relationship('CarSession', backref='users')

    def __init__(self, username, password=None, **kwargs):
        """Create instance."""
        db.Model.__init__(self, username=username, **kwargs)
        if password:
            self.set_password(password)
        else:
            self.password = None

    def set_password(self, password):
        """Set password."""
        self.password = bcrypt.generate_password_hash(password)

    def check_password(self, value):
        """Check password."""
        return bcrypt.check_password_hash(self.password, value)

    @property
    def full_name(self):
        """Full user name."""
        return '{0} {1}'.format(self.first_name, self.last_name)

    def __repr__(self):
        """Represent instance as a unique string."""
        return '<User({username!r})>'.format(username=self.username)
Beispiel #3
0
class Goods(SurrogatePK, Model):

    __tablename__ = 'goodsed'

    #所属店铺
    sellers_id = reference_col('sellers')
    #产品分类
    category_id = reference_col('categorys')

    #商品名称
    title = Column(db.String(100))
    #销售价
    original_price = Column(db.Numeric(precision=10,scale=2,\
     asdecimal=True, decimal_return_scale=None))
    #优惠价进货价
    special_price = Column(db.Numeric(precision=10,scale=2,\
     asdecimal=True, decimal_return_scale=None))
    #详情
    note = Column(db.UnicodeText())
    # 附加字段
    attach_key = Column(db.String(500))
    #附加值
    attach_value = Column(db.String(500))
    #商品状态
    active = Column(db.Boolean(), default=True)
    #是否出售
    is_sell = Column(db.Boolean(), default=True)
    #热门 0 不热门 1热门
    hot = Column(db.Boolean(), default=True)
    #查看次数
    click_count = Column(db.Integer(), default=0)
    #累计购买总数
    buy_count = Column(db.Integer(), default=0)
    #条码
    ean = Column(db.String(50))
    #规格
    unit = Column(db.Integer, default=1)
    #创建时间
    created_at = Column(db.DateTime, nullable=False, default=dt.datetime.now)
    #首页展示图
    main_photo = Column(db.String(200))

    #出售记录
    # sale_id = relationship('Sale', backref='goodsed')
    #库存
    inventory_id = relationship('Inventory', backref='goodsed')
    #进货的商品
    # stock_id = relationship('Stock', backref='goodsed')
    #购物车中的商品
    buys_car_id = relationship('BuysCar', backref='goodsed')
Beispiel #4
0
class Category(SurrogatePK, Model):

    __tablename__ = 'categorys'

    #:自身上级,引用自身无限级分类
    parent_id = reference_col('categorys')

    children = relationship("Category", lazy="joined", join_depth=2)
    goods_id = relationship('Goods', backref='category')

    #分类名称
    name = Column(db.String(100))
    #分类图标
    ico = Column(db.String(100))
    #排序
    sort = Column(db.Integer(), default=100)
    #状态
    status = Column(db.Integer(), default=1)
    #是否启用
    active = Column(db.Boolean, default=True)
Beispiel #5
0
class UserOrder(SurrogatePK,Model):

	__tablename__ = 'user_order'

	#购买者
	user_id = reference_col('users')
	#收货人地址
	receive = reference_col('user_address')

	#卖家
	seller_id = reference_col('sellers')

	#订单号
	number = db.Column(db.String(100)) 
	#下单时间
	buy_time = Column(db.DateTime,default=dt.datetime.now)
    
	#发货时间
	send_time =  db.Column(db.DateTime) 
	#配送费
	freight = db.Column(db.Numeric(15,2),default=0)

	#优惠金额
	discount = db.Column(db.Numeric(15,2))
	#支付金额
	pay_price = db.Column(db.Numeric(15,2))
	#支付时间
	pay_time =  db.Column(db.DateTime) 

	#积分
	integral = db.Column(db.Integer())
	#备注
	note = db.Column(db.String(255)) 

	#买家是否评价
	evaluate_buyers = Column(db.Boolean(),default=False)
	#买家评价时间
	evaluate_buyers_time = db.Column(db.DateTime) 
	#评价内容
	evaluate_buyers_note = db.Column(db.UnicodeText())

	#卖家是否评价
	evaluate_seller = Column(db.Boolean(),default=False)
	#评价时间
	evaluate_seller_time = db.Column(db.DateTime) 
	#评价内容
	evaluate_seller_note = db.Column(db.UnicodeText())
	
	#状态默认0
	order_state = db.Column(db.Integer(),default=0)

	#出售的商品
	sale_id = relationship('Sale', backref='user_order')
Beispiel #6
0
class GoodsAllocation(SurrogatePK, Model):

    __tablename__ = 'goods_allocation'
    #货位名称
    title = Column(db.String(50))
    #排序
    sort = Column(db.Integer, default=100)
    #货位备注
    note = Column(db.String(100))

    warehouse_id = reference_col('warehouses')

    sale_id = relationship('Sale', backref='goodsed_allocation')
Beispiel #7
0
class Warehouse(SurrogatePK, Model):

    __tablename__ = 'warehouses'
    #仓库名称
    name = Column(db.String(20))
    #仓库状态0正常仓,1库存仓,2退货仓
    state = Column(db.Integer, default=1)
    #仓库别名
    nickname = Column(db.String(20))
    #是否可用
    active = Column(db.Boolean, default=1)
    #创建时间
    created_at = Column(db.DateTime, nullable=False, default=dt.datetime.now)

    goods_allocation_id = relationship('GoodsAllocation', backref='warehouse')
Beispiel #8
0
class UserAddress(SurrogatePK, Model):

	__tablename__ = 'user_address'

	user_id = reference_col('users')

	#姓名
	username = Column(db.String(20)) 
	#地址
	address = Column(db.String(255)) 
	#电话
	phone = Column(db.String(20)) 
	#状态  1为默认  默认0  
	state = Column(db.Integer())

	user_order_id = relationship('UserOrder', backref='users_address')
Beispiel #9
0
class QuantityCheck(SurrogatePK, Model):
    __tablename__ = 'quantity_check'

    #盘点标题
    title = Column(db.String(50))

    seller_id = reference_col('sellers')
    users_id = reference_col('users')

    created_at = Column(db.DateTime, default=dt.datetime.now)
    #商品种类数量
    count = Column(db.Integer, default=0)

    #盘点表
    quantity_check_id = relationship('QuantityCheckGoods',
                                     backref='quantity_checks')
Beispiel #10
0
class GoodsAllocation(SurrogatePK, Model):

    __tablename__ = 'goods_allocation'
    #货位名称
    name = Column(db.String(50))
    #排序
    sort = Column(db.Integer, default=100)
    #货位备注
    note = Column(db.String(100))
    #所属仓库
    warehouse_id = reference_col('warehouses')
    #所属用户,不然每次查询都要join很多关联
    user_id = reference_col('users')

    # sale_id = relationship('Sale', backref='goodsed_allocation')
    #库存
    inventory_id = relationship('Inventory', backref='goods_allocation')
Beispiel #11
0
class Receipt(SurrogatePK, Model):
    __tablename__ = 'receipts'

    #供应商
    supplier = Column(db.String(100))

    #卖家
    user_id = reference_col('users')

    #订单号
    number = Column(db.String(100), unique=True)
    #下单时间
    buy_time = Column(db.DateTime, default=dt.datetime.now)

    #送货时间
    send_time = Column(db.DateTime)
    #配送费
    freight = Column(db.Numeric(15, 2), default=0)

    #优惠金额
    discount = Column(db.Numeric(15, 2))
    #支付金额
    pay_price = Column(db.Numeric(15, 2))
    #支付时间
    pay_time = Column(db.DateTime)
    #支付类型 微信 现金  银行卡 其他
    pay_type = Column(db.String(100))
    #备注
    note = Column(db.String(255))
    #状态默认0
    order_state = Column(db.Integer(), default=1)

    #商品种类
    variety = Column(db.Integer)
    #商品总数量
    goods_sum = Column(db.Integer)
    #总价
    price_sum = Column(db.Numeric(15, 2), default=0)

    #进货的商品
    stock_id = relationship('Stock', backref='receipts')
Beispiel #12
0
class Goods(SurrogatePK, Model):
    __tablename__ = 'goodsed'

    sellers_id = reference_col('sellers')
    category_id = reference_col('categorys')

    #商品名称
    title = Column(db.String(100))
    #原价
    original_price = Column(db.Numeric(precision=10,scale=2,\
     asdecimal=True, decimal_return_scale=None))
    #优惠价
    special_price = Column(db.Numeric(precision=10,scale=2,\
     asdecimal=True, decimal_return_scale=None))
    #详情
    note = Column(db.UnicodeText())
    #数量
    count = Column(db.Integer(), default=0)
    #发布时间
    create_time = Column(db.DateTime, default=dt.datetime.now)
    #商品状态
    active = Column(db.Boolean(), default=True)
    #是否出售
    is_sell = Column(db.Boolean(), default=True)
    #热门 0 不热门 1热门
    hot = Column(db.Boolean(), default=True)
    #查看次数
    click_count = Column(db.Integer(), default=0)
    #购买总数
    buy_count = Column(db.Integer(), default=0)
    #排序
    sort = Column(db.Integer(), default=100)
    #创建时间
    created_at = Column(db.DateTime, nullable=False, default=dt.datetime.now)

    sale_id = relationship('Sale', backref='goodsed')
Beispiel #13
0
class Receipt(SurrogatePK, Model):
    __tablename__ = 'receipts'

    #供应商
    supplier = Column(db.String(100))

    #卖家
    seller_id = reference_col('sellers')

    #订单号
    number = db.Column(db.String(100))
    #下单时间
    buy_time = Column(db.DateTime, default=dt.datetime.now)

    #送货时间
    send_time = db.Column(db.DateTime)
    #配送费
    freight = db.Column(db.Numeric(15, 2), default=0)

    #优惠金额
    discount = db.Column(db.Numeric(15, 2))
    #支付金额
    pay_price = db.Column(db.Numeric(15, 2))
    #支付时间
    pay_time = db.Column(db.DateTime)
    #支付类型
    pay_type = db.Column(db.String(100))

    #备注
    note = db.Column(db.String(255))

    #状态默认0
    order_state = db.Column(db.Integer(), default=1)

    #进货的商品
    stock_id = relationship('Stock', backref='receipts')
Beispiel #14
0
class Seller(SurrogatePK, Model):

    __tablename__ = 'sellers'

    user_id = reference_col('users')

    #店铺名称
    name = Column(db.String(100))
    #店铺地址
    address = Column(db.String(255))
    #店铺LOGO
    logo = Column(db.String(255))
    #是否自营 1自营  默认0
    self_business = Column(db.Integer(), default=0)
    #评价总分数
    evaluate = Column(db.Integer())
    #评价总商品数量,得出平均店铺评分
    evaluate_count = Column(db.Integer())
    #店铺位置  地图坐标
    address_map = Column(db.String(100))
    #店铺状态,默认1
    status = Column(db.Integer(), default=1)
    #是否启用
    active = Column(db.Boolean(), default=True)
    #店铺备注
    note = Column(db.String(255))
    #创建时间
    created_at = Column(db.DateTime, nullable=False, default=dt.datetime.now)
    #联系方式
    contact = Column(db.String(255))
    #申请店铺默认不启用,管理员同意
    enable = Column(db.Boolean, default=False)

    #每日最大订单
    max_order = Column(db.Integer, default=10)
    #每日最大交易额
    max_price = Column(db.Integer, default=500)
    #最大仓库
    max_warehouse = Column(db.Integer, default=1)
    #最大货位
    max_goods_location = Column(db.Integer, default=2)
    #商品数量
    max_goods_count = Column(db.Integer, default=20)
    #level等级
    level = Column(db.String(20), default=u'免费会员')

    email = Column(db.String(100), index=True, unique=True)

    #运费
    freight = Column(db.Numeric(precision=10,scale=2,\
     asdecimal=True, decimal_return_scale=None),default=0)
    #满多少免运费
    max_price_no_freight = Column(db.Numeric(precision=10,scale=2,\
     asdecimal=True, decimal_return_scale=None),default=0)

    #店铺横幅
    seller_banner_id = relationship('SellerBanner', backref='seller')
    #店铺记录
    seller_msg_id = relationship('SellerMsg', backref='seller')
    #仓库
    warehouse_id = relationship('Warehouse', backref='seller')

    #订单
    user_order_id = relationship('UserOrder', backref='seller')
    goods_id = relationship('Goods', backref='seller')

    seller_info_id = relationship('SellerInfo', backref='seller')
    sale_id = relationship('Sale', backref='seller')
    follow_id = relationship('Follow', backref='seller')
    #盘点表
    quantity_check_id = relationship('QuantityCheck', backref='seller')
Beispiel #15
0
class UserOrder(SurrogatePK, Model):

    __tablename__ = 'user_order'

    #购买者
    user_id = reference_col('users')
    #收货人地址
    # receive = reference_col('user_address')

    #卖家
    seller_id = reference_col('sellers')
    #收货人信息
    receive_name = Column(db.String(100))
    receive_phone = Column(db.String(100))
    receive_address = Column(db.String(100))

    #订单号
    number = Column(db.String(100), unique=True)
    #下单时间
    buy_time = Column(db.DateTime, default=dt.datetime.now)

    #发货时间
    send_time = Column(db.DateTime)
    #配送费
    freight = Column(db.Numeric(15, 2), default=0)

    #优惠金额
    discount = Column(db.Numeric(15, 2))
    #支付金额
    pay_price = Column(db.Numeric(15, 2))
    #支付时间
    pay_time = Column(db.DateTime)
    #支付类型
    pay_type = Column(db.String(100))

    #积分
    integral = Column(db.Integer())
    #备注
    note = Column(db.String(255))

    #买家是否评价
    evaluate_buyers = Column(db.Boolean(), default=False)
    #买家评价时间
    evaluate_buyers_time = Column(db.DateTime)
    #评价内容
    evaluate_buyers_note = Column(db.UnicodeText())

    #卖家是否评价
    evaluate_seller = Column(db.Boolean(), default=False)
    #评价时间
    evaluate_seller_time = Column(db.DateTime)
    #评价内容
    evaluate_seller_note = Column(db.UnicodeText())
    #商品总类数量
    goods_number = Column(db.Integer())

    #状态默认0 0提交 1已查看开始送货 2完成 3关闭
    order_state = Column(db.Integer(), default=0)

    #是否已经查看 用于微信通知 初次查看微信客服通知
    is_see = Column(db.Boolean, default=False)
    #是否已付款
    is_pay = Column(db.Boolean, default=False)

    #出售的商品
    sale_id = relationship('Sale', backref='user_order')