diff --git a/src/routes/payment.py b/src/routes/payment.py index c20130d..5f0b430 100644 --- a/src/routes/payment.py +++ b/src/routes/payment.py @@ -5,7 +5,7 @@ from typing import Annotated from ..messages import MESSAGES from ..dependencies import auth_scheme -from ..schemas.payment import Billings, BillingsResponse,Url, Plans, Settlement, Credit, PlansV2 ,BasaCreditRequest +from ..schemas.payment import Billings, BillingsResponse, BillingAdmin, Url, Plans, Settlement, Credit, PlansV2, BasaCreditRequest from ..services import ( payment as payment_service, auth as auth_service, diff --git a/src/schemas/payment.py b/src/schemas/payment.py index 3903f80..8c77155 100644 --- a/src/schemas/payment.py +++ b/src/schemas/payment.py @@ -59,9 +59,27 @@ class BasaCreditRequest(BaseModel): user_id: UUID amount: int +class BillingUser(BaseModel): + id: UUID | None + name: str | None + mobile_number: str | None + username: str | None + + +class BillingAdmin(BaseModel): + id: int + credit: int + amount: int + ref_id: str | None + type: BillingType + status: BillingStatus + created_at: datetime + user: BillingUser | None + + class BillingsResponse(BaseModel): total: int page: int size: int total_pages: int - items: List[Billing] \ No newline at end of file + items: List[BillingAdmin] \ No newline at end of file diff --git a/src/services/payment.py b/src/services/payment.py index 0fad68c..407f864 100644 --- a/src/services/payment.py +++ b/src/services/payment.py @@ -121,6 +121,7 @@ async def history_admin(page: int = 1, size: int = 10): # گرفتن دیتای فقط همون صفحه billings = ( await base_query + .select_related("user") .order_by("-created_at") .offset(offset) .limit(size) @@ -136,6 +137,12 @@ async def history_admin(page: int = 1, size: int = 10): "type": b.type, "status": b.status, "created_at": b.created_at, + "user": { + "id": b.user_id, + "name": b.user.name if b.user else None, + "mobile_number": b.user.mobile_number if b.user else None, + "username": b.user.username if b.user else None, + }, } for b in billings ]