added reports

This commit is contained in:
CHIEFSOFT\ameye
2026-02-15 17:32:42 -05:00
parent a6fbce89a1
commit 2b58b8b0a6
2 changed files with 57 additions and 7 deletions
+1
View File
@@ -1088,6 +1088,7 @@ CREATE TABLE members_webfiles (
ALTER TABLE members ADD profile_picture VARCHAR(100);
+56 -7
View File
@@ -9,7 +9,7 @@ from marshmallow import ValidationError
# from app.api.enums import TransactionType
# from app.api.integrations import SimbrellaIntegration
from app.extensions import db
from app.models import MembersProducts, Products, Members
from app.models import MembersProducts, Products, Members, Payments, MembersActions
# from app.api.services.offer_analysis import OfferAnalysis
from app.api.helpers.response_helper import ResponseHelper
@@ -89,25 +89,74 @@ class ReportService(BaseService):
member_id = member_data.id
response_data =[]
if report_type == "Payment":
if report_type == "PAYMENT":
member_payments = Payments.get_member_payments_by_member_id(member_id)
member_payments_data = []
for t in member_payments:
member_payments_data.append({
'id': t.id,
'uid': t.uid,
'option_name': t.option_name,
'option_type': t.option_type,
'payment_uid': t.payment_uid,
'amount': round(t.amount * 0.01, 2),
'currency': '$',
'status': t.status,
'added': t.added
})
response_data = {
"last_update": datetime.datetime.utcnow(),
"member_id": member_id,
"payment": [],
"payment": member_payments_data,
}
if report_type == "Product":
if report_type == "PRODUCT":
sub_status = []
member_subs = MembersProducts.get_member_productlist_by_member_id(member_id)
for tt in member_subs:
sub_status.append({
'product_id': tt.product_id,
'product_name': "Name for - " + tt.product_id,
'added': tt.added,
'subscription_uid': tt.uid,
'status': tt.status,
'internal_url': tt.internal_url,
'dns_group': tt.dns_group,
})
logger.info(f"Member Product Sub Data ****** *****: {sub_status}")
response_data = {
"last_update": datetime.datetime.utcnow(),
"member_id": member_id,
"product": [],
"product": sub_status,
}
if report_type == "System":
if report_type == "SYSTEM":
member_actions = MembersActions.get_recent_member_actions(member_id)
member_actions_data = []
if member_actions:
for t in member_actions:
member_actions_data.append({
'id': t.id,
'uid': t.uid,
'member_id': t.member_id,
'member_uid': t.member_uid,
'action_label': t.action_label,
'action_name': t.action_name,
'status_description': t.status_description,
'status': t.status,
'added': t.added,
'updated': t.updated
})
response_data = {
"last_update": datetime.datetime.utcnow(),
"member_id": member_id,
"system": [],
"system": member_actions_data,
}
return ResponseHelper.success(data=response_data)