sub options

This commit is contained in:
CHIEFSOFT\ameye
2025-08-23 06:03:36 -04:00
parent 6ea518c791
commit d68a4d9667
4 changed files with 140 additions and 38 deletions
+27 -37
View File
@@ -4,11 +4,12 @@ from app.api.services.base_service import BaseService
from sqlalchemy import func, desc
from app.api.helpers.response_helper import ResponseHelper
from app.api.schemas.user import UserSchema
from app.models import Members, MembersProducts
from app.models import Members, MembersProducts, SubscriptionOptions
from app.extensions import db
class SubscriptionService(BaseService):
# def get_all_subscriptions(cls, product_id=None, member_id=None, page=1, limit=20):
# def get_all_subscriptions(cls, product_id=None, member_id=None, page=1, limit=20):
@staticmethod
def get_subscription_data(filters=None):
try:
@@ -29,7 +30,7 @@ class SubscriptionService(BaseService):
if limit < 1 or limit > 100:
limit = 20
membersSubList, total_count = MembersProducts.get_all_subscriptions(product_id,member_id,page,limit)
membersSubList, total_count = MembersProducts.get_all_subscriptions(product_id, member_id, page, limit)
# Convert loans to dictionary format
member_sub_data = []
for subs in membersSubList:
@@ -78,45 +79,35 @@ class SubscriptionService(BaseService):
uid = validated_data.get('uid')
member_data = Members.get_member_by_uid(uid)
member_id = member_data.id
res_options = []
sub_options = SubscriptionOptions.get_subscription_options(1)
for t in sub_options:
res_options.append({
'option_id': t.id,
'package_uid': t.uid,
'display_name': t.display_name,
'option_name': t.option_name,
'monthly': round(t.monthly*0.01, 2),
"items": ['Post Jobs', 'advanced instructors search', 'invite candidates', 'post events',
'Cancel anytime'],
'added': t.added.isoformat() if t.added else None,
'updated': t.updated.isoformat() if t.updated else None
})
subscription_products_data = {
"current_product": {
"display_name": "Subscriptions",
"subs":[
"display_name": "BASIC001",
"subs": [
'Post Jobs',
'advanced instructors search',
'invite candidates',
'post events',
'Cancel anythime'
'Cancel Anytime'
],
"next_payment":'2025-10-15 11:00:07.47214'
"next_payment": '2025-10-15 11:00:07.47214'
},
"options": {
"starter":{
"package_uid" : "cd2c0a4d-9ad4-472e-96f5-28d10c06916f",
"display_name" : "Starter",
"monthly" : 5.99,
"items" : ['Post Jobs','advanced instructors search','invite candidates','post events',
'Cancel anythime']
},
"basic": {
"package_uid": "ef2ffa1c-9272-42cd-9d33-0e614047b4f8",
"display_name": "Basic",
"monthly": 12.99,
"items": ['Post Jobs', 'advanced instructors search', 'invite candidates', 'post events',
'Cancel anythime']
},
"premium": {
"package_uid": "64bf48f6-1e7f-402e-8ff0-76f4ce0f2055",
"display_name": "Premium",
"monthly": 20.99,
"items": ['Post Jobs', 'advanced instructors search', 'invite candidates', 'post events',
'Cancel anythime']
},
}
}
"options": res_options
}
return ResponseHelper.success(data=subscription_products_data)
@@ -124,7 +115,6 @@ class SubscriptionService(BaseService):
logger.error(f"An error occurred while getting dashboard data: {str(e)}", exc_info=True)
return jsonify({"message": "Internal Server Error"}), 500
#
#
#
#
#
#