class RechargeOrder(db.Model):
    __tablename__ = 'recharge_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())
    Cid = db.Column(db.BigInteger,
                    nullable=False,
                    server_default=db.FetchedValue())
    money = 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())
    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())
Example #2
0
class Prosessi(Base):

    prosessin_nimi = db.Column(db.String(144), nullable=False)
    pvm_alku = db.Column(db.DateTime)
    pvm_loppu = db.Column(db.DateTime)

    owner_id = db.Column(db.Integer,
                         db.ForeignKey('kayttaja.id'),
                         nullable=False)

    prosessitehtavat = db.relationship("Prosessitehtava",
                                       backref='prosessi',
                                       lazy=True)

    db.Index('idx_prosessi', prosessin_nimi, owner_id)

    def __init__(self, prosessin_nimi, owner_id, pvm_alku, pvm_loppu):
        self.prosessin_nimi = prosessin_nimi
        self.owner_id = owner_id
        self.pvm_alku = pvm_alku
        self.pvm_loppu = pvm_loppu

    @staticmethod
    def listaa_prosessin_tehtavat(prosessi_id):

        stmt = text(
            "SELECT Tehtava.id as id, Tehtava.nimi as nimi, Tehtava.kuvaus as kuvaus FROM Tehtava"
            " INNER JOIN Prosessitehtava ON Prosessitehtava.prosessi_id = :prosessi_id"
        ).params(prosessi_id=prosessi_id)

        res = db.engine.execute(stmt)

        return res
Example #3
0
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(),
                          info='会员id')
    client_type = db.Column(db.String(20),
                            nullable=False,
                            server_default=db.FetchedValue(),
                            info='客户端来源类型。qq,weibo,weixin')
    type = db.Column(db.Integer,
                     nullable=False,
                     server_default=db.FetchedValue(),
                     info='类型 type 1:wechat ')
    openid = db.Column(db.String(80),
                       nullable=False,
                       server_default=db.FetchedValue(),
                       info='第三方id')
    unionid = db.Column(db.String(100),
                        nullable=False,
                        server_default=db.FetchedValue())
    extra = db.Column(db.Text, nullable=False, info='额外字段')
    updated_time = db.Column(db.DateTime,
                             nullable=False,
                             server_default=db.FetchedValue(),
                             info='最后更新时间')
    created_time = db.Column(db.DateTime,
                             nullable=False,
                             server_default=db.FetchedValue(),
                             info='插入时间')
Example #4
0
class StatDailyMember(db.Model):
    __tablename__ = 'stat_daily_member'
    __table_args__ = (db.Index('idx_date_member_id', 'date', 'member_id'), )

    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.Date, nullable=False, info='日期')
    member_id = db.Column(db.Integer,
                          nullable=False,
                          server_default=db.FetchedValue(),
                          info='会员id')
    total_shared_count = db.Column(db.Integer,
                                   nullable=False,
                                   server_default=db.FetchedValue(),
                                   info='当日分享总次数')
    total_pay_money = db.Column(db.Numeric(10, 2),
                                nullable=False,
                                server_default=db.FetchedValue(),
                                info='当日付款总金额')
    updated_time = db.Column(db.DateTime,
                             nullable=False,
                             server_default=db.FetchedValue(),
                             info='最后一次更新时间')
    created_time = db.Column(db.DateTime,
                             nullable=False,
                             server_default=db.FetchedValue(),
                             info='插入时间')
Example #5
0
class OauthMemberBind(db.Model):
    __tablename__ = 'oauth_member_bind'
    __table_args__ = (db.Index('idx_type_openid', 'Type', 'Openid'), )

    Id = db.Column(Integer, primary_key=True)
    Member_id = db.Column(Integer,
                          nullable=False,
                          server_default=FetchedValue())
    Client_type = db.Column(String(20),
                            nullable=False,
                            server_default=FetchedValue())
    Type = db.Column(Integer, nullable=False, server_default=FetchedValue())
    Openid = db.Column(String(80),
                       nullable=False,
                       server_default=FetchedValue())
    Unionid = db.Column(String(100),
                        nullable=False,
                        server_default=FetchedValue())
    Extra = db.Column(Text, nullable=False)
    UpdateTime = db.Column(DateTime,
                           nullable=False,
                           server_default=FetchedValue())
    CreatTime = db.Column(DateTime,
                          nullable=False,
                          server_default=FetchedValue())
class CommonwealOrder(db.Model):
    __tablename__ = 'commonweal_order'
    __table_args__ = (
        db.Index('idx_member_id_status', 'order_member_id', 'status'),
    )

    id = db.Column(db.Integer, primary_key=True)
    order_sn = db.Column(db.String(40, 'utf8mb4_0900_ai_ci'), nullable=False, unique=True, server_default=db.FetchedValue())
    order_member_id = db.Column(db.BigInteger, nullable=False, server_default=db.FetchedValue())
    receipt_member_id = db.Column(db.BigInteger, nullable=False, server_default=db.FetchedValue())
    pay_price = db.Column(db.BigInteger, nullable=False, server_default=db.FetchedValue())
    pay_sn = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue())
    prepay_id = db.Column(db.String(128, 'utf8mb4_0900_ai_ci'), nullable=False, server_default=db.FetchedValue())
    note = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), nullable=False, server_default=db.FetchedValue())
    status = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue())
    needplaceid = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue())
    needplace = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), nullable=False, server_default=db.FetchedValue())
    needtime = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue())
    commonweal_conment = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), nullable=False, server_default=db.FetchedValue())
    commonweal_name = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), nullable=False, server_default=db.FetchedValue())
    commonweal_type_id = db.Column(db.Integer)
    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())
    receipt_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue())
    delivery_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue())
    success_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue())
Example #7
0
class StatDailyFood(db.Model):
    __tablename__ = 'stat_daily_food'
    __table_args__ = (db.Index('date_food_id', 'date', 'food_id'), )

    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.Date, nullable=False)
    food_id = db.Column(db.Integer,
                        nullable=False,
                        server_default=db.FetchedValue(),
                        info='菜品id')
    total_count = db.Column(db.Integer,
                            nullable=False,
                            server_default=db.FetchedValue(),
                            info='售卖总数量')
    total_pay_money = db.Column(db.Numeric(10, 2),
                                nullable=False,
                                server_default=db.FetchedValue(),
                                info='总售卖金额')
    updated_time = db.Column(db.DateTime,
                             nullable=False,
                             server_default=db.FetchedValue(),
                             info='最后一次更新时间')
    created_time = db.Column(db.DateTime,
                             nullable=False,
                             server_default=db.FetchedValue(),
                             info='插入时间')
Example #8
0
class RoleAction(db.Model):
    __tablename__ = 'role_action'
    __table_args__ = (db.Index('uk_role_action_id', 'role_id', 'action_id'), )

    id = db.Column(db.Integer, primary_key=True, info='角色权限ID')
    role_id = db.Column(db.Integer,
                        nullable=False,
                        server_default=db.FetchedValue(),
                        info='角色ID')
    action_id = db.Column(db.Integer,
                          nullable=False,
                          server_default=db.FetchedValue(),
                          info='权限ID')
    status = db.Column(db.Integer,
                       nullable=False,
                       server_default=db.FetchedValue(),
                       info='1有效 0无效')
    updated_time = db.Column(db.DateTime,
                             nullable=False,
                             server_default=db.FetchedValue(),
                             info='最后一次更新时间')
    created_time = db.Column(db.DateTime,
                             nullable=False,
                             server_default=db.FetchedValue(),
                             info='插入时间')
Example #9
0
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 GoldCrossResult(db.Model):
    __tablename__ = 'gold_cross_result'
    __table_args__ = (
        db.Index('SYMBOL_DATE', 'symbol', 'date'),
    )

    id = db.Column(db.BigInteger, primary_key=True, info='result id')
    symbol = db.Column(db.String(20), nullable=False, server_default=db.FetchedValue(), info='选股结果')
    name = db.Column(db.String(20), nullable=False, server_default=db.FetchedValue(), info='选股名称')
    date = db.Column(db.String(20), nullable=False, server_default=db.FetchedValue(), info='选股日期')
    price = db.Column(db.Float, nullable=False, server_default=db.FetchedValue(), info='买入价格')
Example #11
0
class PayOrder(db.Model):  # 在线购买订单表
    __tablename__ = 'pay_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())
Example #12
0
class StatDailyQuant(db.Model):
    __tablename__ = 'stat_daily_quant'
    __table_args__ = (
        db.Index('date_quant_id', 'date', 'quant_id'),
    )

    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.Date, nullable=False)
    quant_id = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue())
    total_count = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue())
    total_pay_money = db.Column(db.Numeric(10, 2), 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())
Example #13
0
class MemberAddres(db.Model):
    __tablename__ = 'member_address'
    __table_args__ = (
        db.Index('idx_member_id_status', 'member_id', 'status'),
    )

    id = db.Column(db.Integer, primary_key=True)
    member_id = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue())
    nickname = db.Column(db.String(20), nullable=False, server_default=db.FetchedValue())
    mobile = db.Column(db.String(11), nullable=False, server_default=db.FetchedValue())
    address = db.Column(db.String(50), nullable=False, server_default=db.FetchedValue())
    status = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue())
    is_default = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue())
Example #14
0
class User(Base):

    __tablename__ = "account"
    name = db.Column(db.String(144), nullable=False)
    username = db.Column(db.String(144), nullable=False)
    password = db.Column(db.String(144), nullable=False)
    points= db.Column(db.Integer, nullable=False)
    household= db.Column(db.Integer, db.ForeignKey('household.id'),nullable=False)
    nameIndex= db.Index("name_index", name)

    def __init__(self, name, username, password, household):
        self.name = name
        self.username = username
        self.password = password
        self.points=0
        self.household= household
  
    def get_id(self):
        return self.id

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def is_authenticated(self):
        return True
    
    def roles(self):
        if self.id==1:
            return ["Boss"]
        return ["Peon"]
    
    @staticmethod
    def find_lazy_users():
        time= datetime.datetime.now(timezone('Europe/Helsinki'))- timedelta(days=7)
        res=""
        try:
            stmt = text("SELECT Account.id, Account.name, Household.name FROM Account "
                        "INNER JOIN Household ON Account.household=Household.id "
                        " WHERE Account.id NOT IN (SELECT userid FROM done_chore WHERE done_chore.date_created > '"+ str(time) + "')")
            res = db.engine.execute(stmt)
        except Exception as e:
            return render_template("/error.html", message=e.message)
        response = []
        for row in res:
            response.append({"id":row[0], "name":row[1], "household": row[2]})
        return response
Example #15
0
class MemberAddress(db.Model):
    __tablename__ = 'member_address'
    __table_args__ = (db.Index('idx_member_id_status', 'member_id',
                               'status'), )

    id = db.Column(db.Integer, primary_key=True)
    member_id = db.Column(db.Integer,
                          nullable=False,
                          server_default=db.FetchedValue())
    nickname = db.Column(db.String(20),
                         nullable=False,
                         server_default=db.FetchedValue())
    mobile = db.Column(db.String(11),
                       nullable=False,
                       server_default=db.FetchedValue())
    province_id = db.Column(db.Integer,
                            nullable=False,
                            server_default=db.FetchedValue())
    province_str = db.Column(db.String(50),
                             nullable=False,
                             server_default=db.FetchedValue())
    city_id = db.Column(db.Integer,
                        nullable=False,
                        server_default=db.FetchedValue())
    city_str = db.Column(db.String(50),
                         nullable=False,
                         server_default=db.FetchedValue())
    area_id = db.Column(db.Integer,
                        nullable=False,
                        server_default=db.FetchedValue())
    area_str = db.Column(db.String(50),
                         nullable=False,
                         server_default=db.FetchedValue())
    address = db.Column(db.String(100),
                        nullable=False,
                        server_default=db.FetchedValue())
    status = db.Column(db.Integer,
                       nullable=False,
                       server_default=db.FetchedValue())
    is_default = 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())
Example #16
0
class PayOrder(db.Model):
    __tablename__ = 'pay_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(100), 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
Example #17
0
class UserInfo(db.Model):
    __tablename__ = 'user_info'
    __table_args__ = (
        db.Index('USER_STOCK_DATE', 'user_id', 'hold_stock', 'buy_date'),
    )

    id = db.Column(db.BigInteger, primary_key=True, info='id')
    hold_stock = db.Column(db.String(20), nullable=False, server_default=db.FetchedValue(), info='持有股票代码')
    name = db.Column(db.String(20), nullable=False, server_default=db.FetchedValue(), info='股票名称')
    user_id = db.Column(db.ForeignKey('user.uid'), nullable=False, server_default=db.FetchedValue(), info='用户id fk')
    buy_price = db.Column(db.Float, nullable=False, server_default=db.FetchedValue(), info='卖出价格')
    sold_price = db.Column(db.Float, info='卖出价格')
    sale_point = db.Column(db.Float, info='卖点')
    strategy = db.Column(db.String(2000), info='当前交易策略')
    buy_date = db.Column(db.String(20), info='买入日期')
    hold_time = db.Column(db.Float, info='卖出日期')

    user = db.relationship('User', primaryjoin='UserInfo.user_id == User.uid', backref='user_infos')
Example #18
0
class PayOrder(db.Model):
    __tablename__ = 'pay_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(), info='随机订单号')
    member_id = db.Column(db.BigInteger, nullable=False, server_default=db.FetchedValue(), info='会员id')
    total_price = db.Column(db.Numeric(10, 2), nullable=False, server_default=db.FetchedValue(), info='订单应付金额')
    yun_price = db.Column(db.Numeric(10, 2), nullable=False, server_default=db.FetchedValue(), info='运费金额')
    pay_price = db.Column(db.Numeric(10, 2), nullable=False, server_default=db.FetchedValue(), info='订单实付金额')
    pay_sn = db.Column(db.String(128), nullable=False, server_default=db.FetchedValue(), info='第三方流水号')
    prepay_id = db.Column(db.String(128), nullable=False, server_default=db.FetchedValue(), info='第三方预付id')
    note = db.Column(db.Text, nullable=False, info='备注信息')
    status = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue(), info='1:支付完成 0 无效 -1 申请退款 -2 退款中 -9 退款成功  -8 待支付  -7 完成支付待确认')
    express_status = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue(), info='快递状态,-8 待支付 -7 已付款待发货 1:确认收货 0:失败')
    express_address_id = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue(), info='快递地址id')
    express_info = db.Column(db.String(1000), nullable=False, server_default=db.FetchedValue(), info='快递信息')
    comment_status = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue(), info='评论状态')
    pay_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue(), info='付款到账时间')
    updated_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue(), info='最近一次更新时间')
    created_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue(), info='插入时间')

    @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
Example #19
0
class PayOrder(db.Model):
    __tablename__ = 'pay_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())
    note = db.Column(db.Text, nullable=False)
    status = db.Column(db.Integer,
                       nullable=False,
                       server_default=db.FetchedValue())
    express_address_id = db.Column(db.Integer,
                                   nullable=False,
                                   server_default=db.FetchedValue())
    pay_time = db.Column(db.DateTime,
                         nullable=False,
                         server_default=db.FetchedValue())
    comment_score = db.Column(db.Integer,
                              nullable=False,
                              server_default=db.FetchedValue())
    comment_content = db.Column(db.String(80),
                                nullable=False,
                                server_default=db.FetchedValue())

    @property
    def status_desc(self):
        return app.config['PAY_STATUS_MAPPING'][str(self.status)]
Example #20
0
class StatDailyMember(db.Model):
    __tablename__ = 'stat_daily_member'
    __table_args__ = (db.Index('idx_date_member_id', 'date', 'member_id'), )

    id = db.Column(Integer, primary_key=True)
    date = db.Column(Date, nullable=False)
    member_id = db.Column(Integer,
                          nullable=False,
                          server_default=FetchedValue())
    total_shared_count = db.Column(Integer,
                                   nullable=False,
                                   server_default=FetchedValue())
    total_pay_money = db.Column(Numeric(10, 2),
                                nullable=False,
                                server_default=FetchedValue())
    updated_time = db.Column(DateTime,
                             nullable=False,
                             server_default=FetchedValue())
    created_time = db.Column(DateTime,
                             nullable=False,
                             server_default=FetchedValue())
Example #21
0
class MemberAddress(db.Model):
    __tablename__ = 'member_address'
    __table_args__ = (
        db.Index('idx_member_id_status', 'member_id', 'status'),
    )

    id = db.Column(db.Integer, primary_key=True)
    member_id = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue(), info='会员id')
    nickname = db.Column(db.String(20), nullable=False, server_default=db.FetchedValue(), info='收货人姓名')
    mobile = db.Column(db.String(11), nullable=False, server_default=db.FetchedValue(), info='收货人手机号码')
    province_id = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue(), info='省id')
    province_str = db.Column(db.String(50), nullable=False, server_default=db.FetchedValue(), info='省名称')
    city_id = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue(), info='城市id')
    city_str = db.Column(db.String(50), nullable=False, server_default=db.FetchedValue(), info='市名称')
    area_id = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue(), info='区域id')
    area_str = db.Column(db.String(50), nullable=False, server_default=db.FetchedValue(), info='区域名称')
    address = db.Column(db.String(100), nullable=False, server_default=db.FetchedValue(), info='详细地址')
    status = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue(), info='是否有效 1:有效 0:无效')
    is_default = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue(), info='默认地址')
    updated_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue(), info='最后一次更新时间')
    created_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue(), info='插入时间')
Example #22
0
class AvailableChore(Base):
    __tablename__ = "chore"
    householdid = db.Column(db.Integer,
                            db.ForeignKey('household.id'),
                            nullable=False)
    points = db.Column(db.Integer, nullable=False)
    maxpoints = db.Column(db.Integer, nullable=False)
    choretype = db.Column(db.Integer,
                          db.ForeignKey('choretype.id'),
                          nullable=False)
    message = db.Column(db.String(144), nullable=True)
    type_index = db.Index("type_index", choretype)

    def __init__(self, householdid, points, choretype):
        self.householdid = householdid
        self.points = points
        self.maxpoints = points
        self.choretype = choretype

    @staticmethod
    def list_chores(household):
        res = ""
        try:
            stmt = text(
                "SELECT chore.id, chore.points, chore.maxpoints, choretype.name "
                "FROM chore INNER JOIN choretype ON chore.choretype=choretype.id "
                " WHERE chore.householdid= " + str(household) +
                " AND chore.points>0;")
            res = db.engine.execute(stmt)
        except Exception as e:
            return render_template("/error.html", message=e.message)
        response = []
        for row in res:
            response.append({
                "id": row[0],
                "points": row[1],
                "maxpoints": row[2],
                "choretype": row[3]
            })
        return response
Example #23
0
class StockInfo(db.Model):
    __tablename__ = 'stock_info'
    __table_args__ = (db.Index('SYMBOL_TRADE_DATE', 'symbol', 'trade_date'), )

    id = db.Column(db.BigInteger, primary_key=True, info='stock id')
    symbol = db.Column(db.String(30),
                       nullable=False,
                       server_default=db.FetchedValue(),
                       info='????')
    trade_date = db.Column(db.String(20),
                           nullable=False,
                           server_default=db.FetchedValue(),
                           info='????')
    name = db.Column(db.String(30),
                     nullable=False,
                     server_default=db.FetchedValue(),
                     info='????')
    open = db.Column(db.Float, info='???')
    close = db.Column(db.Float, info='???')
    high = db.Column(db.Float, info='???')
    low = db.Column(db.Float, info='???')
    vol = db.Column(db.Float, info='???')
Example #24
0
class Tag(Base):
    __tablename__ = 'tag'

    name = db.Column(db.String(30), nullable=False, unique=True)

    tasks = db.relationship('Task', secondary=tagtask, back_populates='tags')

    db.Index('indexname', 'name')

    def __init__(self, name):
        self.name = name

    @staticmethod
    def find_used_tags():
        stmt = text("SELECT Tag.name, COUNT(*), SUM (Task.used_time) FROM Tag "
                    "INNER JOIN Tagtask ON Tagtask.tag_id = Tag.id "
                    "INNER JOIN Task ON Task.id = Tagtask.task_id "
                    "GROUP BY Tag.name "
                    "LIMIT (10);")

        res = db.engine.execute(stmt)

        response = []
        for row in res:
            response.append({"name": row[0], "count": row[1], "sum": row[2]})

        return response

    @staticmethod
    def unique_name(name=name):
        stmt = text("SELECT COUNT(*) FROM Tag "
                    "WHERE (Tag.name = :name) "
                    "GROUP BY Tag.name").params(name=name)
        res = db.engine.execute(stmt)

        response = []
        for row in res:
            response.append({"count": row[0]})
        return response
Example #25
0
class Notify(db.Model):
    __tablename__ = 'notify'
    __table_args__ = (db.Index('SYMBOL_DATE_UID', 'symbol', 'date',
                               'user_id'), )

    id = db.Column(db.BigInteger, primary_key=True, info='id')
    symbol = db.Column(db.String(20),
                       nullable=False,
                       server_default=db.FetchedValue(),
                       info='持有股票代码')
    date = db.Column(db.String(20),
                     nullable=False,
                     server_default=db.FetchedValue(),
                     info='交易日期')
    user_id = db.Column(db.ForeignKey('user.uid'),
                        nullable=False,
                        index=True,
                        server_default=db.FetchedValue(),
                        info='用户id fk')

    user = db.relationship('User',
                           primaryjoin='Notify.user_id == User.uid',
                           backref='notifies')
Example #26
0
class MemberAddress(db.Model):
    __tablename__ = 'member_address'
    __table_args__ = (db.Index('idx_member_id_status', 'member_id',
                               'status'), )

    id = db.Column(db.Integer, primary_key=True)
    member_id = db.Column(db.Integer,
                          nullable=False,
                          server_default=db.FetchedValue(),
                          info='??id')
    contact_name = db.Column(db.String(20),
                             nullable=False,
                             server_default=db.FetchedValue(),
                             info='?????')
    mobile = db.Column(db.String(11),
                       nullable=False,
                       server_default=db.FetchedValue(),
                       info='???????')
    province_id = db.Column(db.Integer,
                            nullable=False,
                            server_default=db.FetchedValue(),
                            info='?id')
    province_str = db.Column(db.String(50),
                             nullable=False,
                             server_default=db.FetchedValue(),
                             info='???')
    city_id = db.Column(db.Integer,
                        nullable=False,
                        server_default=db.FetchedValue(),
                        info='??id')
    city_str = db.Column(db.String(50),
                         nullable=False,
                         server_default=db.FetchedValue(),
                         info='???')
    district_id = db.Column(db.Integer,
                            nullable=False,
                            server_default=db.FetchedValue(),
                            info='??id')
    district_str = db.Column(db.String(50),
                             nullable=False,
                             server_default=db.FetchedValue(),
                             info='????')
    address = db.Column(db.String(100),
                        nullable=False,
                        server_default=db.FetchedValue(),
                        info='????')
    status = db.Column(db.Integer,
                       nullable=False,
                       server_default=db.FetchedValue(),
                       info='???? 1??? 0???')
    is_default = db.Column(db.Integer,
                           nullable=False,
                           server_default=db.FetchedValue(),
                           info='????')
    updated_time = db.Column(db.DateTime,
                             nullable=False,
                             server_default=db.FetchedValue(),
                             info='????????')
    created_time = db.Column(db.DateTime,
                             nullable=False,
                             server_default=db.FetchedValue(),
                             info='????')
Example #27
0
class WHMCSclients(db.Model):
    ''' Table inside WHMCS Database (the billing system)
        This table contains a list of all users in the billing system.
    '''

    def __init__(self, firstname=None, lastname=None, email=None):
        self.firstname = firstname
        self.lastname = lastname
        self.email = email

    __tablename__ = u'tblclients'
    __table_args__ = (
        db.Index(u'firstname_lastname', u'firstname', u'lastname', mysql_length=10),
        db.Index(u'email_index', u'email', mysql_length=10),
        {'schema': 'dms-whmcs'}
    )

    id = db.Column(db.Integer, primary_key=True)
    firstname = db.Column(db.Text, nullable=False)
    lastname = db.Column(db.Text, nullable=False)
    email = db.Column(db.Text, nullable=False)

    badges = db.relationship('Badges', backref='tblclients')
    badges_history = db.relationship('BadgesHistory', backref='tblclients')
    products = db.relationship('WHMCSproducts', backref='tblclients')
    addons = association_proxy('products', 'addons')

    @hybrid_property
    def full_name(self):
        return self.firstname + ' ' + self.lastname

    @hybrid_property
    def active_badges(self):
        return len([badge for badge in self.badges if badge.status == "Active"])

    @active_badges.expression
    def active_badges(cls):
        return db.select([
                    db.func.count(Badges.id),
                    Badges.status == 'Active'
                ]).as_scalar()

    @hybrid_property
    def deactivated_badges(self):
        return len([badge for badge in self.badges if badge.status == "Deactivated"])

    @deactivated_badges.expression
    def deactivated_badges(cls):
        return db.select([
                    db.func.count(Badges.id),
                    Badges.status == 'Deactivated'
                ]).as_scalar()

    @hybrid_property
    def active_products_and_addons(self):
        product_count = 0
        for product in self.products:
            if (product.domainstatus == "Active") and ((not product.nextduedate) or (product.nextduedate > date.today())):
                product_count += 1
            for addon in product.addons:
                if (addon.status == "Active") and ((not addon.nextduedate) or (addon.nextduedate > date.today())):
                    product_count += 1
        return product_count

    '''
    @hybrid_property
    def active_products(self):
        product_count = 0
        for product in self.products:
            if (product.domainstatus == "Active") and ((not product.nextduedate) or (product.nextduedate > date.today())):
                product_count += 1
        return product_count

    @active_products.expression
    def active_products(self):
        return db.select([
                db.func.count(WHMCSproducts)
            ]).where(db.or_(WHMCSproducts.domainstatus=='Active', WHMCSproducts.nextduedate > date.today())).as_scalar()

    @hybrid_property
    def active_addons(self):
        addon_count = 0
        for association in self.addons:
            for addon in association:
                if (addon.status == "Active") and ((not addon.nextduedate) or (addon.nextduedate > date.today())):
                    addon_count += 1

        return addon_count

    @active_addons.expression
    def active_addons(self):
        return db.select([
                db.func.count(WHMCSaddons)
            ]).where(db.or_(WHMCSaddons.status=='Active', WHMCSaddons.nextduedate > date.today())).as_scalar()
    '''

    def __str__(self):
        return self.firstname + ' ' + self.lastname + ' - ' + self.email

    def __unicode__(self):
        return self.firstname + ' ' + self.lastname + ' - ' + self.email
Example #28
0
    def mention_notification(cls, user, mention_by, mention_in_msg):
        if user.is_banned() or user.get_id() == mention_by.get_id():
            return None
        return cls(3, user.get_id(), mention_by.get_id(), mention_in_msg.get_id())

    @staticmethod
    def clean_up_old():
        db.engine.execute(text("DELETE FROM " + Notification.__tablename__ + " WHERE notificationdate < now() - interval '{} hours'".format(int(application.config.NOTIFICATIONS_MAX_AGE))))

    def add_itself(self):
        db.session.add(self)
        db.session.commit()

    def terminate(self):
        db.session.delete(self)
        db.session.commit()

    def update(self):
        db.session.commit()

    def mark_as_read(self):
        self.read = True
        self.update()

db.Index("idx_user_from_id", User.userid, unique = True)
db.Index("idx_msg_from_id", Message.msgid, unique = True)
db.Index("idx_msgs_from_user", Message.author)
db.Index("idx_followeds_from_user", table_Follows.c.follower)
db.Index("idx_likes_from_msg", table_Likes.c.msg)
db.Index("idx_notifs_from_user", Notification.userid)
Example #29
0
from application import db
from application.types.models import Type
from sqlalchemy.sql import text

speciestype = db.Table(
    "speciestype", db.metadata, db.Column("id", db.Integer, primary_key=True),
    db.Column("species_id", db.Integer, db.ForeignKey("species.id")),
    db.Column("type_id", db.Integer, db.ForeignKey("type.id")))
db.Index("link", speciestype.c.species_id, speciestype.c.type_id, unique=True)


class Species(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(144), nullable=False)
    description = db.Column(db.String(512))
    legendary = db.Column(db.Boolean, nullable=False)
    types = db.relationship("Type",
                            secondary=speciestype,
                            lazy="subquery",
                            backref=db.backref("typespecies", lazy=True))

    def __init__(self, name, description):
        self.name = name
        self.description = description
        self.legendary = False

    @staticmethod
    def get_types(s):
        stmt = text(
            "SELECT Type.name FROM Type JOIN SpeciesType ON Type.id = SpeciesType.type_id"
            " JOIN Species ON SpeciesType.species_id = Species.id"
Example #30
0
"""
Application data storage models
"""
from slugify import slugify

from application import db

import pickle
import datetime
import time

video_tags = db.Table('mylust_tag_to_video',
	db.Column('tag_id', db.BigInteger, db.ForeignKey('mylust_video_tag.id')),
	db.Column('video_id', db.BigInteger, db.ForeignKey('mylust_video.id')),
	db.Index('tag_to_video_index', 'tag_id', 'video_id', unique=True)
)

video_stars = db.Table('mylust_star_to_video',
	db.Column('star_id', db.BigInteger, db.ForeignKey('mylust_video_star.id')),
	db.Column('video_id', db.BigInteger, db.ForeignKey('mylust_video.id')),
	db.Index('star_to_video_index', 'star_id', 'video_id', unique=True)
)

class Video(db.Model):
	"""
	Main video model
	"""
	__tablename__ = 'mylust_video'
	__table_args__ = (
		db.UniqueConstraint('masturbator', 'remote_id', name='masturbator_remote_id_uc'),