sub options
This commit is contained in:
@@ -295,6 +295,77 @@ CREATE TABLE members_actions (
|
||||
ALTER TABLE ONLY members_actions
|
||||
ADD CONSTRAINT members_actions_id_key UNIQUE (id);
|
||||
|
||||
|
||||
|
||||
CREATE TABLE subscription_options (
|
||||
id SERIAL,
|
||||
uid uuid DEFAULT uuid_generate_v4(),
|
||||
display_name VARCHAR(25) UNIQUE NOT NULL,
|
||||
option_name VARCHAR(100) UNIQUE NOT NULL,
|
||||
monthly INT DEFAULT 0,
|
||||
status INT DEFAULT 1,
|
||||
added timestamp without time zone DEFAULT now(),
|
||||
updated timestamp without time zone DEFAULT now()
|
||||
);
|
||||
ALTER TABLE ONLY subscription_options
|
||||
ADD CONSTRAINT subscription_options_id_key UNIQUE (id);
|
||||
|
||||
|
||||
ALTER TABLE subscription_options OWNER TO merms_panel;
|
||||
|
||||
|
||||
INSERT INTO subscription_options(display_name,option_name,monthly)
|
||||
VALUES ('Starter','STATRTER001',599);
|
||||
|
||||
INSERT INTO subscription_options(display_name,option_name,monthly)
|
||||
VALUES ('Basic','BASIC001',1299);
|
||||
|
||||
INSERT INTO subscription_options(display_name,option_name,monthly)
|
||||
VALUES ('Premium','PREMIUM001',2099);
|
||||
|
||||
|
||||
CREATE TABLE subscription_options_items (
|
||||
id SERIAL,
|
||||
uid uuid DEFAULT uuid_generate_v4(),
|
||||
option_name VARCHAR(100) REFERENCES subscription_options(option_name),
|
||||
description VARCHAR(100) NOT NULL,
|
||||
list_order INT DEFAULT 0,
|
||||
status INT DEFAULT 1,
|
||||
added timestamp without time zone DEFAULT now()
|
||||
);
|
||||
ALTER TABLE ONLY subscription_options_items
|
||||
ADD CONSTRAINT subscription_options_items_id_key UNIQUE (id);
|
||||
|
||||
ALTER TABLE subscription_options_items OWNER TO merms_panel;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"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']
|
||||
},
|
||||
|
||||
const insertQuery = 'INSERT INTO ss_subs(members_id, members_uid, action_label,action_name,status_description,status ) VALUES($1, $2, $3, $4, $5, %6)'
|
||||
|
||||
var Querydata = {
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
@@ -22,6 +22,7 @@ from .password_reset import PasswordReset
|
||||
from .member_product_refresh import MembersProductsRefresh
|
||||
from .members_products_settings import MembersProductsSettings
|
||||
from .members_profile import MembersProfile
|
||||
from .subscription_options import SubscriptionOptions
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +30,8 @@ from .members_profile import MembersProfile
|
||||
__all__ = ['Members','Customer', 'Account', 'Products',
|
||||
'MembersProducts', 'MembersActions', 'MembersPending', 'ProductsDetails',
|
||||
'ProvisionActions', 'MembersProductsRefresh','MembersProductsSettings',
|
||||
'PasswordReset','MembersProfile',
|
||||
'PasswordReset','MembersProfile','SubscriptionOptions',
|
||||
|
||||
'Loan', 'Transaction', 'Repayment',
|
||||
'LoanCharge', 'Offer', 'Charge', 'RACCheck', 'LoanRepaymentSchedule',
|
||||
'TransactionOffer', 'RepaymentsData', 'Salary']
|
||||
@@ -0,0 +1,39 @@
|
||||
from datetime import datetime, timezone
|
||||
from app.extensions import db
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
|
||||
class SubscriptionOptions(db.Model):
|
||||
__tablename__ = 'subscription_options'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
uid = db.Column(db.String(150), nullable=True)
|
||||
display_name = db.Column(db.String(25), nullable=False)
|
||||
option_name = db.Column(db.String(100), nullable=False)
|
||||
monthly = db.Column(db.Integer, nullable=True, default=0)
|
||||
status = db.Column(db.Integer, nullable=True, default=1)
|
||||
added = db.Column(db.DateTime(timezone=False), server_default=func.now())
|
||||
updated = db.Column(db.DateTime(timezone=False), server_default=func.now(), onupdate=func.now())
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_subscription_options(cls, status):
|
||||
sub_options = cls.query.filter_by(status=status).all()
|
||||
if not sub_options:
|
||||
return None
|
||||
return sub_options
|
||||
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
"uid": self.uid,
|
||||
"display_name": self.display_name,
|
||||
"status": self.status,
|
||||
"monthly": self.monthly,
|
||||
"added": self.added.isoformat() if self.added else None,
|
||||
"updated": self.updated.isoformat() if self.updated else None
|
||||
}
|
||||
|
||||
def __repr__(self):
|
||||
return f'<SubscriptionOptions {self.id} - {self.amount}>'
|
||||
Reference in New Issue
Block a user