|
@@ -177,21 +177,15 @@ class StageCountView(APIView):
|
|
|
data = []
|
|
|
stage_progress = Option.objects.filter(type=Option.STAGE_PROGRESS, enable=True).order_by('sort')
|
|
|
user = request.user
|
|
|
+ users = User.objcets.filter(store_id__in=request.user.get_manager_range())
|
|
|
time_now = timezone.now().strftime('%Y-%m-%d')
|
|
|
for stage in stage_progress:
|
|
|
- new_customers = NewCustomer.objects.filter(track_user=user, stage_progress=stage)
|
|
|
+ new_customers = NewCustomer.objects.filter(Q(track_user=user)|Q(track_user=users), stage_progress=stage)
|
|
|
stage_count = {
|
|
|
- 'stage': stage.name,
|
|
|
- 'total': 0,
|
|
|
- 'today_count': 0,
|
|
|
- 'overdue_count': 0,
|
|
|
+ '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() # 逾期人数
|
|
|
}
|
|
|
- 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)
|