|
@@ -23,6 +23,7 @@ from apps.account.consts import PermissionMenu
|
|
from collections import OrderedDict
|
|
from collections import OrderedDict
|
|
from apps.agent.models import Store, Agent,GeneralAgent
|
|
from apps.agent.models import Store, Agent,GeneralAgent
|
|
from utils.exceptions import CustomError
|
|
from utils.exceptions import CustomError
|
|
|
|
+from apps.customer.models import ReportCustomer
|
|
|
|
|
|
class LoginView(ObtainJSONWebToken):
|
|
class LoginView(ObtainJSONWebToken):
|
|
serializer_class = JWTSerializer
|
|
serializer_class = JWTSerializer
|
|
@@ -377,3 +378,26 @@ class EmployeeTreeView(APIView):
|
|
# if len(data) == 1:
|
|
# if len(data) == 1:
|
|
# data = data[0]['children']
|
|
# data = data[0]['children']
|
|
return response_ok(data)
|
|
return response_ok(data)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+class HomeStatisticsView(APIView):
|
|
|
|
+ # 首页统计
|
|
|
|
+ permission_classes = [isLogin, ]
|
|
|
|
+
|
|
|
|
+ def get(self, request):
|
|
|
|
+ print(111111111111,request.user)
|
|
|
|
+ statistics = {
|
|
|
|
+ 'today_report': 0, # 本日新增报备
|
|
|
|
+ 'mouth_report': 0, # 本月新增报备
|
|
|
|
+ 'general_report': 0, # 总报备
|
|
|
|
+ }
|
|
|
|
+ if request.user or request.user.is_authenticated:
|
|
|
|
+ today = timezone.now().date()
|
|
|
|
+ reports = ReportCustomer.objects.filter(store__in=request.user.get_manager_range(),
|
|
|
|
+ report_status=ReportCustomer.CHECKED)
|
|
|
|
+ statistics['today_report'] = reports.filter(check_time__gte=str(today) + ' 00:00:00').count()
|
|
|
|
+ statistics['mouth_report'] = reports.filter(check_time__year=today.year, check_time__month=today.month).count()
|
|
|
|
+ statistics['general_report'] = reports.count()
|
|
|
|
+ return response_ok(statistics)
|
|
|
|
+ else:
|
|
|
|
+ return response_ok(statistics)
|