sub office
This commit is contained in:
+2
-35
@@ -123,45 +123,12 @@ class Members(db.Model):
|
||||
|
||||
query = cls.query
|
||||
logger.info(f"Get all customer back")
|
||||
# Apply filters if provided
|
||||
# if id:
|
||||
# query = query.filter(cls.id == id)
|
||||
|
||||
if username:
|
||||
query = query.filter(cls.customer_id == username)
|
||||
query = query.filter(cls.username == username)
|
||||
|
||||
if email:
|
||||
query = query.filter(cls.account_id == email)
|
||||
|
||||
# if status:
|
||||
# query = query.filter(cls.status == status)
|
||||
#
|
||||
# if tenor:
|
||||
# query = query.filter(cls.tenor == tenor)
|
||||
#
|
||||
# if offer_id:
|
||||
# query = query.filter(cls.offer_id == offer_id)
|
||||
#
|
||||
# if product_id:
|
||||
# query = query.filter(cls.product_id == product_id)
|
||||
#
|
||||
# if transaction_id:
|
||||
# query = query.filter(cls.transaction_id == transaction_id)
|
||||
#
|
||||
# if original_transaction:
|
||||
# query = query.filter(cls.original_transaction == original_transaction)
|
||||
#
|
||||
# if start_date:
|
||||
# query = query.filter(cls.created_at >= start_date)
|
||||
#
|
||||
# if end_date:
|
||||
# query = query.filter(cls.created_at <= end_date)
|
||||
#
|
||||
# if due_before:
|
||||
# query = query.filter(cls.due_date <= due_before)
|
||||
#
|
||||
# if due_after:
|
||||
# query = query.filter(cls.due_date >= due_after)
|
||||
query = query.filter(cls.email == email)
|
||||
|
||||
# Order by created_at descending (newest first)
|
||||
query = query.order_by(cls.added.desc())
|
||||
|
||||
@@ -103,6 +103,30 @@ class MembersProducts(db.Model):
|
||||
return subscription
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_all_subscriptions(cls, product_id=None, member_id=None, page=1, limit=20):
|
||||
|
||||
query = cls.query
|
||||
logger.info(f"Get all customer back")
|
||||
|
||||
if member_id:
|
||||
query = query.filter(cls.member_id == member_id)
|
||||
|
||||
if product_id:
|
||||
query = query.filter(cls.product_id == product_id)
|
||||
|
||||
# Order by created_at descending (newest first)
|
||||
query = query.order_by(cls.added.desc())
|
||||
|
||||
# Get total count before pagination
|
||||
total_count = query.count()
|
||||
|
||||
# Apply pagination
|
||||
offset = (page - 1) * limit
|
||||
query = query.limit(limit).offset(offset)
|
||||
|
||||
return query.all(), total_count
|
||||
|
||||
# @classmethod
|
||||
# def save_update_product_settings(cls, member_id,subscription_uid,product_id,settings_key,setting_type,setting_value ):
|
||||
# logger.info(f"settings_key : {settings_key}")
|
||||
|
||||
Reference in New Issue
Block a user