|
@@ -1,7 +1,12 @@
|
|
|
+from django.db.models import Sum
|
|
|
+from rest_framework import status
|
|
|
+from rest_framework.response import Response
|
|
|
+from rest_framework.views import APIView
|
|
|
from rest_framework.viewsets import ModelViewSet
|
|
|
|
|
|
from basic.models import Menu
|
|
|
from basic.serializer import MenuSerializer
|
|
|
+from payment.models import Payment
|
|
|
|
|
|
|
|
|
class MenuView(ModelViewSet):
|
|
@@ -9,3 +14,10 @@ class MenuView(ModelViewSet):
|
|
|
serializer_class = MenuSerializer
|
|
|
pagination_class = None
|
|
|
filter_fields = {'code': ['exact'], 'parent': ['exact']}
|
|
|
+
|
|
|
+
|
|
|
+class StatisticsView(APIView):
|
|
|
+ def get(self, request):
|
|
|
+ data = list(
|
|
|
+ Payment.objects.values('payment_type').annotate(price_sum=Sum('index_price')).order_by('-price_sum'))
|
|
|
+ return Response(data, status=status.HTTP_200_OK)
|