aded office call
This commit is contained in:
+71
-1
@@ -22,6 +22,7 @@ class Members(db.Model):
|
||||
lastname = db.Column(db.String(100), nullable=True)
|
||||
country = db.Column(db.String(3), nullable=True)
|
||||
profile_completed = db.Column(db.DateTime(timezone=False))
|
||||
stripe_customer_id = db.Column(db.String(100), nullable=True)
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
@@ -39,7 +40,8 @@ class Members(db.Model):
|
||||
"email": self.email,
|
||||
"account_name": self.account_name,
|
||||
"firstname": self.firstname,
|
||||
"lastname": self.lastname
|
||||
"lastname": self.lastname,
|
||||
"stripe_customer_id": self.stripe_customer_id
|
||||
}
|
||||
|
||||
def __repr__(self):
|
||||
@@ -104,3 +106,71 @@ class Members(db.Model):
|
||||
|
||||
# Update reset_p status and the updated_at timestamp
|
||||
member.password = new_passwprd_hash
|
||||
|
||||
@classmethod
|
||||
def set_user_stripe_id(cls, member_uid, member_id, stripe_customer_id):
|
||||
member = cls.query.filter_by(uid=str(member_uid),id=member_id).first()
|
||||
if not member:
|
||||
raise ValueError(f"Reset with UID {member_uid} does not exist.")
|
||||
# Update stripe_customer_id
|
||||
member.stripe_customer_id = stripe_customer_id
|
||||
|
||||
return stripe_customer_id
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_all_member(cls, email=None, username=None, page=1, limit=20):
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
# 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
|
||||
Reference in New Issue
Block a user