Example #1
0
class QueueList(db.Model):
    __tablename__ = 'queue_list'

    id = db.Column(db.Integer, primary_key=True)
    queue_name = db.Column(db.String(30),
                           nullable=False,
                           server_default=db.FetchedValue())
    data = db.Column(db.String(500),
                     nullable=False,
                     server_default=db.FetchedValue())
    status = 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())

    @staticmethod
    def add_queue(queue_name, data=None):
        model_queue = QueueList()
        model_queue.queue_name = queue_name
        if data:
            model_queue.data = json.dumps(data)

        model_queue.created_time = model_queue.updated_time = get_current_date(
        )
        with db.auto_commit():
            db.session.add(model_queue)
        return True
class StatDailySite(db.Model):
    __tablename__ = 'stat_daily_site'

    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.Date, nullable=False, index=True)
    total_pay_money = db.Column(db.Numeric(10, 2), nullable=False, server_default=db.FetchedValue())
    total_member_count = db.Column(db.Integer, nullable=False)
    total_new_member_count = db.Column(db.Integer, nullable=False)
    total_order_count = db.Column(db.Integer, nullable=False)
    total_shared_count = db.Column(db.Integer, 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 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)
    member_id = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue())
    total_shared_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())
class WxShareHistory(db.Model):
    __tablename__ = 'wx_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())
Example #5
0
class AuthAccessToken(db.Model):
    __tablename__ = 'auth_access_token'

    id = db.Column(db.Integer, primary_key=True)
    access_token = db.Column(db.String(600),
                             nullable=False,
                             server_default=db.FetchedValue())
    expired_time = db.Column(db.DateTime,
                             nullable=False,
                             index=True,
                             server_default=db.FetchedValue())
    created_time = db.Column(db.DateTime,
                             nullable=False,
                             server_default=db.FetchedValue())
Example #6
0
class MemberCart(Base):
    __tablename__ = 'member_cart'

    id = db.Column(db.Integer, primary_key=True)
    member_id = db.Column(db.BigInteger,
                          nullable=False,
                          index=True,
                          server_default=db.FetchedValue())
    food_id = db.Column(db.Integer,
                        nullable=False,
                        server_default=db.FetchedValue())
    quantity = 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())

    @staticmethod
    def set_items(member_id=0, food_id=0, number=0):
        if member_id < 1 or food_id < 1 or number < 1:
            return False
        cart_info = MemberCart.query.filter_by(food_id=food_id,
                                               member_id=member_id).first()
        if cart_info:
            model_cart = cart_info
        else:
            model_cart = MemberCart()
            model_cart.member_id = member_id
            model_cart.created_time = get_current_date()

        model_cart.food_id = food_id
        model_cart.quantity = number
        model_cart.updated_time = get_current_date()
        with db.auto_commit():
            db.session.add(model_cart)
        return True

    @staticmethod
    def delete_item(member_id=0, items=None):
        if member_id < 1 or not items:
            return False
        with db.auto_commit():
            for item in items:
                MemberCart.query.filter_by(food_id=item['id'],
                                           member_id=member_id).delete()
        return True
Example #7
0
class AppErrorLog(db.Model):
    __tablename__ = 'app_error_log'

    id = db.Column(db.Integer, primary_key=True)
    referer_url = db.Column(db.String(255),
                            nullable=False,
                            server_default=db.FetchedValue())
    target_url = db.Column(db.String(255),
                           nullable=False,
                           server_default=db.FetchedValue())
    query_params = db.Column(db.Text, nullable=False)
    content = db.Column(db.String, nullable=False)
    created_time = db.Column(db.DateTime,
                             nullable=False,
                             server_default=db.FetchedValue())
Example #8
0
class PayOrderCallbackData(db.Model):
    __tablename__ = 'pay_order_callback_data'

    id = db.Column(db.Integer, primary_key=True)
    pay_order_id = db.Column(db.Integer,
                             nullable=False,
                             unique=True,
                             server_default=db.FetchedValue())
    pay_data = db.Column(db.Text, nullable=False)
    refund_data = 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())
Example #9
0
class MemberComments(db.Model):
    __tablename__ = 'member_comments'

    id = db.Column(db.Integer, primary_key=True)
    member_id = db.Column(db.Integer,
                          nullable=False,
                          index=True,
                          server_default=db.FetchedValue())
    food_ids = db.Column(db.String(200),
                         nullable=False,
                         server_default=db.FetchedValue())
    pay_order_id = db.Column(db.Integer,
                             nullable=False,
                             server_default=db.FetchedValue())
    score = db.Column(db.Integer,
                      nullable=False,
                      server_default=db.FetchedValue())
    content = db.Column(db.String(200),
                        nullable=False,
                        server_default=db.FetchedValue())
    created_time = db.Column(db.DateTime,
                             nullable=False,
                             server_default=db.FetchedValue())

    @property
    def score_desc(self):
        score_map = {
            "10": "好评",
            "6": "中评",
            "0": "差评",
        }
        return score_map[str(self.score)]
Example #10
0
class AppAccessLog(db.Model):
    __tablename__ = 'app_access_log'

    id = db.Column(db.Integer, primary_key=True)
    uid = db.Column(db.BigInteger, nullable=False, index=True, server_default=db.FetchedValue())
    referer_url = db.Column(db.String(255), nullable=False, server_default=db.FetchedValue())
    target_url = db.Column(db.String(255), nullable=False, server_default=db.FetchedValue())
    query_params = db.Column(db.Text, nullable=False)
    ua = db.Column(db.String(255), nullable=False, server_default=db.FetchedValue())
    ip = db.Column(db.String(32), nullable=False, server_default=db.FetchedValue())
    note = db.Column(db.String(1000), nullable=False, server_default=db.FetchedValue())
    created_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue())
Example #11
0
class MemberAddress(Base):
    __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())

    def keys(self):
        return [
            'nickname', 'mobile', 'province_id', 'province_str', 'city_id',
            'city_str', 'area_id', 'area_str', 'address', 'is_default'
        ]
Example #12
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 current_app.config['PAY_STATUS_DISPLAY_MAPPING'][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