|
@@ -89,12 +89,12 @@ class ReportCustomerDictView(APIView):
|
|
|
permission_classes = [isLogin]
|
|
|
|
|
|
def get(self, request):
|
|
|
- scouce = Option.objects.filter(type=Option.CUSTOMER_SOURCE, enable=True)
|
|
|
+ source = Option.objects.filter(type=Option.CUSTOMER_SOURCE, enable=True)
|
|
|
project = Option.objects.filter(type=Option.CATEGORY, enable=True)
|
|
|
- serializer_scouce = OptionComboboxSerializer(scouce, many=True)
|
|
|
+ serializer_source = OptionComboboxSerializer(source, many=True)
|
|
|
serializer_project = OptionComboboxSerializer(project, many=True)
|
|
|
return response_ok({
|
|
|
- 'source': serializer_scouce.data,
|
|
|
+ 'source': serializer_source.data,
|
|
|
'project': serializer_project.data,
|
|
|
})
|
|
|
|
|
@@ -119,3 +119,24 @@ class NewCustomerViewSet(CustomModelViewSet):
|
|
|
queryset = queryset.filter()
|
|
|
f = NewCustomerFilter(self.request.GET, queryset=queryset)
|
|
|
return f.qs
|
|
|
+
|
|
|
+
|
|
|
+class StageCountView(APIView):
|
|
|
+ permission_classes = [isLogin]
|
|
|
+
|
|
|
+ def get(self,request):
|
|
|
+ data = []
|
|
|
+ stage_progress = Option.objects.filter(type=Option.STAGE_PROGRESS, enable=True).order_by('sort')
|
|
|
+ user = request.user
|
|
|
+ time_now = timezone.now().strftime('%Y-%m-%d')
|
|
|
+ for stage in stage_progress:
|
|
|
+ new_customers = NewCustomer.objects.filter(track_user=user, stage_progress=stage)
|
|
|
+ if new_customers:
|
|
|
+ stage_count = {
|
|
|
+ 'stage': stage.name, # 阶段名称
|
|
|
+ 'total': new_customers.count(), # 总人数
|
|
|
+ '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)
|
|
|
+ return response_ok(data)
|