Pārlūkot izejas kodu

阶段总数统计

hujingpei 4 gadi atpakaļ
vecāks
revīzija
74082b9621
1 mainītis faili ar 7 papildinājumiem un 1 dzēšanām
  1. 7 1
      apps/customer/views.py

+ 7 - 1
apps/customer/views.py

@@ -131,6 +131,12 @@ class StageCountView(APIView):
         time_now = timezone.now().strftime('%Y-%m-%d')
         for stage in stage_progress:
             new_customers = NewCustomer.objects.filter(track_user=user, stage_progress=stage)
+            stage_count = {
+                'stage': stage.name,
+                'total': 0,
+                'today_count': 0,
+                'overdue_count': 0,
+            }
             if new_customers:
                 stage_count = {
                     'stage': stage.name,    # 阶段名称
@@ -138,5 +144,5 @@ class StageCountView(APIView):
                     'today_count': new_customers.filter(next_time=time_now).count(),  # 今日人数
                     'overdue_count': new_customers.filter(next_time__lt=time_now).count()  # 逾期人数
                 }
-                data.append(stage_count)
+            data.append(stage_count)
         return response_ok(data)