|
@@ -9,7 +9,6 @@
|
|
|
|
|
|
from django.db.models import Q, Count, Sum
|
|
from django.db.models import Q, Count, Sum
|
|
from django.views.generic.base import View
|
|
from django.views.generic.base import View
|
|
-from Ansjer.config import DEVICE_TYPE
|
|
|
|
import datetime
|
|
import datetime
|
|
import requests
|
|
import requests
|
|
|
|
|
|
@@ -93,24 +92,6 @@ class ServiceDataView(View):
|
|
}
|
|
}
|
|
order_list.append(order_dict)
|
|
order_list.append(order_dict)
|
|
|
|
|
|
- # 区域订单统计
|
|
|
|
- region_list = []
|
|
|
|
- region_qs = order_qs.values('userID__region_country').annotate(count=Count('UID')).order_by('-count')
|
|
|
|
- for item in region_qs:
|
|
|
|
- country_id = item['userID__region_country']
|
|
|
|
- country_qs = CountryModel.objects.filter(id=country_id).values('country_name')
|
|
|
|
- country_name = country_qs[0]['country_name'] if country_qs.exists() else '未知区域'
|
|
|
|
- if count:
|
|
|
|
- rate = round(item['count'] / count * 100, 2)
|
|
|
|
- else:
|
|
|
|
- rate = 0
|
|
|
|
- region_dict = {
|
|
|
|
- 'countryName': country_name,
|
|
|
|
- 'count': item['count'],
|
|
|
|
- 'rate': rate
|
|
|
|
- }
|
|
|
|
- region_list.append(region_dict)
|
|
|
|
-
|
|
|
|
# 设备类型订单统计
|
|
# 设备类型订单统计
|
|
device_type_list = []
|
|
device_type_list = []
|
|
device_type_qs = order_qs.values('UID').annotate(count=Count('UID')).order_by('count')
|
|
device_type_qs = order_qs.values('UID').annotate(count=Count('UID')).order_by('count')
|
|
@@ -123,21 +104,16 @@ class ServiceDataView(View):
|
|
if device_temp_qs[0]['Type'] not in uid_type_dict:
|
|
if device_temp_qs[0]['Type'] not in uid_type_dict:
|
|
uid_type_dict[device_temp_qs[0]['Type']] = []
|
|
uid_type_dict[device_temp_qs[0]['Type']] = []
|
|
uid_type_dict[device_temp_qs[0]['Type']].append(item['UID'])
|
|
uid_type_dict[device_temp_qs[0]['Type']].append(item['UID'])
|
|
- # device_qs = Device_Info.objects.filter(UID__in=uid_list).values('Type').annotate(
|
|
|
|
- # count=Count('Type', distinct=True)).order_by('-count')
|
|
|
|
for k, v in uid_type_dict.items():
|
|
for k, v in uid_type_dict.items():
|
|
- type_name = DEVICE_TYPE.get(k, '未知类型')
|
|
|
|
- type_name = type_name if type_name != 'UNKOWN' else '未知类型'
|
|
|
|
|
|
+ type_qs = DeviceTypeModel.objects.filter(type=k).values('name')
|
|
|
|
+ type_name = type_qs[0]['name'] if type_qs.exists() else '未知类型'
|
|
device_count = order_qs.filter(UID__in=v).count()
|
|
device_count = order_qs.filter(UID__in=v).count()
|
|
if count:
|
|
if count:
|
|
type_rate = round(device_count / count * 100, 2)
|
|
type_rate = round(device_count / count * 100, 2)
|
|
else:
|
|
else:
|
|
type_rate = 0
|
|
type_rate = 0
|
|
temp_total = order_qs.filter(UID__in=v).aggregate(total=Sum('price'))['total']
|
|
temp_total = order_qs.filter(UID__in=v).aggregate(total=Sum('price'))['total']
|
|
- if total:
|
|
|
|
- total_rate = round(temp_total / total * 100, 2)
|
|
|
|
- else:
|
|
|
|
- total_rate = 0
|
|
|
|
|
|
+ total_rate = round(temp_total / total * 100, 2)
|
|
device_temp_qs = {
|
|
device_temp_qs = {
|
|
'typeName': type_name,
|
|
'typeName': type_name,
|
|
'count': device_count,
|
|
'count': device_count,
|
|
@@ -147,6 +123,32 @@ class ServiceDataView(View):
|
|
}
|
|
}
|
|
device_type_list.append(device_temp_qs)
|
|
device_type_list.append(device_temp_qs)
|
|
|
|
|
|
|
|
+ # 区域订单统计
|
|
|
|
+ region_list = []
|
|
|
|
+ region_dict = {}
|
|
|
|
+ for item in uid_list:
|
|
|
|
+ uidset_qs = UidSetModel.objects.filter(uid=item).values('tb_country')
|
|
|
|
+ if uidset_qs.exists():
|
|
|
|
+ country_qs = CountryModel.objects.filter(id=uidset_qs[0]['tb_country']).values('country_name')
|
|
|
|
+ country_name = country_qs[0]['country_name'] if country_qs.exists() else '未知区域'
|
|
|
|
+ else:
|
|
|
|
+ country_name = '未知区域'
|
|
|
|
+ if country_name not in region_dict:
|
|
|
|
+ region_dict[country_name] = []
|
|
|
|
+ region_dict[country_name].append(item)
|
|
|
|
+ for k, v in region_dict.items():
|
|
|
|
+ region_order_count = order_qs.filter(UID__in=v).count()
|
|
|
|
+ if count:
|
|
|
|
+ rate = round(region_order_count / count * 100, 2)
|
|
|
|
+ else:
|
|
|
|
+ rate = 0
|
|
|
|
+ region_temp_dict = {
|
|
|
|
+ 'countryName': k,
|
|
|
|
+ 'count': region_order_count,
|
|
|
|
+ 'rate': rate
|
|
|
|
+ }
|
|
|
|
+ region_list.append(region_temp_dict)
|
|
|
|
+
|
|
# 套餐订单统计
|
|
# 套餐订单统计
|
|
store_meal_list = []
|
|
store_meal_list = []
|
|
if store_meal_type == 0:
|
|
if store_meal_type == 0:
|
|
@@ -163,6 +165,7 @@ class ServiceDataView(View):
|
|
'rank__lang__content')
|
|
'rank__lang__content')
|
|
store_meal_name = store_meal_content_qs[0][
|
|
store_meal_name = store_meal_content_qs[0][
|
|
'rank__lang__content'] if store_meal_content_qs.exists() else '未知套餐'
|
|
'rank__lang__content'] if store_meal_content_qs.exists() else '未知套餐'
|
|
|
|
+ store_meal_total = order_qs.filter(rank=store_meal_id).aggregate(total=Sum('price'))['total']
|
|
elif store_meal_type == 1:
|
|
elif store_meal_type == 1:
|
|
store_meal_id = item['ai_rank']
|
|
store_meal_id = item['ai_rank']
|
|
store_meal_content_qs = store_meal_qs.filter(ai_rank=store_meal_id,
|
|
store_meal_content_qs = store_meal_qs.filter(ai_rank=store_meal_id,
|
|
@@ -170,12 +173,17 @@ class ServiceDataView(View):
|
|
'ai_rank__lang__content')
|
|
'ai_rank__lang__content')
|
|
store_meal_name = store_meal_content_qs[0][
|
|
store_meal_name = store_meal_content_qs[0][
|
|
'ai_rank__lang__content'] if store_meal_content_qs.exists() else '未知套餐'
|
|
'ai_rank__lang__content'] if store_meal_content_qs.exists() else '未知套餐'
|
|
|
|
+ store_meal_total = order_qs.filter(ai_rank=store_meal_id).aggregate(total=Sum('price'))[
|
|
|
|
+ 'total']
|
|
else:
|
|
else:
|
|
store_meal_id = item['unify_combo_id']
|
|
store_meal_id = item['unify_combo_id']
|
|
store_meal_content_qs = UnicomCombo.objects.filter(id=store_meal_id).values(
|
|
store_meal_content_qs = UnicomCombo.objects.filter(id=store_meal_id).values(
|
|
'combo_name')
|
|
'combo_name')
|
|
store_meal_name = store_meal_content_qs[0][
|
|
store_meal_name = store_meal_content_qs[0][
|
|
'combo_name'] if store_meal_content_qs.exists() else '未知套餐'
|
|
'combo_name'] if store_meal_content_qs.exists() else '未知套餐'
|
|
|
|
+ store_meal_total = order_qs.filter(unify_combo_id=store_meal_id).aggregate(total=Sum('price'))[
|
|
|
|
+ 'total']
|
|
|
|
+ total_rate = round(store_meal_total / total * 100, 2)
|
|
if count:
|
|
if count:
|
|
rate = round(item['count'] / count * 100, 2)
|
|
rate = round(item['count'] / count * 100, 2)
|
|
else:
|
|
else:
|
|
@@ -184,6 +192,8 @@ class ServiceDataView(View):
|
|
'storeMealId': store_meal_id,
|
|
'storeMealId': store_meal_id,
|
|
'count': item['count'],
|
|
'count': item['count'],
|
|
'storeMealName': store_meal_name,
|
|
'storeMealName': store_meal_name,
|
|
|
|
+ 'storeMealTotal': store_meal_total,
|
|
|
|
+ 'totalRate': total_rate,
|
|
'rate': rate
|
|
'rate': rate
|
|
}
|
|
}
|
|
store_meal_list.append(store_meal_dict)
|
|
store_meal_list.append(store_meal_dict)
|
|
@@ -227,7 +237,7 @@ class ServiceDataView(View):
|
|
time_list = CommonService.cutting_time(start_time, end_time, time_unit)
|
|
time_list = CommonService.cutting_time(start_time, end_time, time_unit)
|
|
# 转化率
|
|
# 转化率
|
|
if store_meal_type == 0:
|
|
if store_meal_type == 0:
|
|
- uidset_count = uidset_qs.filter(is_vod=1).count()
|
|
|
|
|
|
+ uidset_count = uidset_qs.filter(~Q(cloud_vod=2)).count()
|
|
elif store_meal_type == 1:
|
|
elif store_meal_type == 1:
|
|
uidset_count = uidset_qs.filter(is_ai=1).count()
|
|
uidset_count = uidset_qs.filter(is_ai=1).count()
|
|
else:
|
|
else:
|
|
@@ -248,29 +258,13 @@ class ServiceDataView(View):
|
|
}
|
|
}
|
|
order_list.append(order_dict)
|
|
order_list.append(order_dict)
|
|
|
|
|
|
- # 区域订单统计
|
|
|
|
- region_list = []
|
|
|
|
- region_qs = order_qs.values('userID__region_country').annotate(count=Count('UID')).order_by('-count')
|
|
|
|
- for item in region_qs:
|
|
|
|
- country_id = item['userID__region_country']
|
|
|
|
- country_qs = CountryModel.objects.filter(id=country_id).values('country_name')
|
|
|
|
- country_name = country_qs[0]['country_name'] if country_qs.exists() else '未知区域'
|
|
|
|
- if count:
|
|
|
|
- rate = round(item['count'] / count * 100, 2)
|
|
|
|
- else:
|
|
|
|
- rate = 0
|
|
|
|
- region_dict = {
|
|
|
|
- 'countryName': country_name,
|
|
|
|
- 'count': item['count'],
|
|
|
|
- 'rate': rate
|
|
|
|
- }
|
|
|
|
- region_list.append(region_dict)
|
|
|
|
-
|
|
|
|
# 设备类型订单统计
|
|
# 设备类型订单统计
|
|
device_type_list = []
|
|
device_type_list = []
|
|
device_type_qs = order_qs.values('UID').annotate(count=Count('UID')).order_by('count')
|
|
device_type_qs = order_qs.values('UID').annotate(count=Count('UID')).order_by('count')
|
|
uid_dict = {}
|
|
uid_dict = {}
|
|
|
|
+ uid_list = []
|
|
for item in device_type_qs:
|
|
for item in device_type_qs:
|
|
|
|
+ uid_list.append(item['UID'])
|
|
device_qs = Device_Info.objects.filter(UID=item['UID']).values('Type')
|
|
device_qs = Device_Info.objects.filter(UID=item['UID']).values('Type')
|
|
device_type = device_qs[0]['Type'] if device_qs.exists() else 0
|
|
device_type = device_qs[0]['Type'] if device_qs.exists() else 0
|
|
if device_type not in uid_dict:
|
|
if device_type not in uid_dict:
|
|
@@ -278,8 +272,8 @@ class ServiceDataView(View):
|
|
uid_dict[device_type].append(item['UID'])
|
|
uid_dict[device_type].append(item['UID'])
|
|
|
|
|
|
for k, v in uid_dict.items():
|
|
for k, v in uid_dict.items():
|
|
- type_name = DEVICE_TYPE.get(k, '未知类型')
|
|
|
|
- type_name = type_name if type_name != 'UNKOWN' else '未知类型'
|
|
|
|
|
|
+ type_qs = DeviceTypeModel.objects.filter(type=k).values('name')
|
|
|
|
+ type_name = type_qs[0]['name'] if type_qs.exists() else '未知类型'
|
|
device_count = order_qs.filter(UID__in=v).count()
|
|
device_count = order_qs.filter(UID__in=v).count()
|
|
if count:
|
|
if count:
|
|
type_rate = round(device_count / count * 100, 2)
|
|
type_rate = round(device_count / count * 100, 2)
|
|
@@ -292,6 +286,32 @@ class ServiceDataView(View):
|
|
}
|
|
}
|
|
device_type_list.append(device_temp_qs)
|
|
device_type_list.append(device_temp_qs)
|
|
|
|
|
|
|
|
+ # 区域订单统计
|
|
|
|
+ region_list = []
|
|
|
|
+ region_dict = {}
|
|
|
|
+ for item in uid_list:
|
|
|
|
+ uidset_qs = UidSetModel.objects.filter(uid=item).values('tb_country')
|
|
|
|
+ if uidset_qs.exists():
|
|
|
|
+ country_qs = CountryModel.objects.filter(id=uidset_qs[0]['tb_country']).values('country_name')
|
|
|
|
+ country_name = country_qs[0]['country_name'] if country_qs.exists() else '未知区域'
|
|
|
|
+ else:
|
|
|
|
+ country_name = '未知区域'
|
|
|
|
+ if country_name not in region_dict:
|
|
|
|
+ region_dict[country_name] = []
|
|
|
|
+ region_dict[country_name].append(item)
|
|
|
|
+ for k, v in region_dict.items():
|
|
|
|
+ region_order_count = order_qs.filter(UID__in=v).count()
|
|
|
|
+ if count:
|
|
|
|
+ rate = round(region_order_count / count * 100, 2)
|
|
|
|
+ else:
|
|
|
|
+ rate = 0
|
|
|
|
+ region_temp_dict = {
|
|
|
|
+ 'countryName': k,
|
|
|
|
+ 'count': region_order_count,
|
|
|
|
+ 'rate': rate
|
|
|
|
+ }
|
|
|
|
+ region_list.append(region_temp_dict)
|
|
|
|
+
|
|
res = {
|
|
res = {
|
|
'orders': order_list,
|
|
'orders': order_list,
|
|
'regions': region_list,
|
|
'regions': region_list,
|
|
@@ -349,37 +369,21 @@ class ServiceDataView(View):
|
|
}
|
|
}
|
|
order_list.append(order_dict)
|
|
order_list.append(order_dict)
|
|
|
|
|
|
- # 区域订单统计
|
|
|
|
- region_list = []
|
|
|
|
- region_qs = order_qs.values('userID__region_country').annotate(count=Count('UID')).order_by('-count')
|
|
|
|
- for item in region_qs:
|
|
|
|
- country_id = item['userID__region_country']
|
|
|
|
- country_qs = CountryModel.objects.filter(id=country_id).values('country_name')
|
|
|
|
- country_name = country_qs[0]['country_name'] if country_qs.exists() else '未知区域'
|
|
|
|
- if count:
|
|
|
|
- rate = round(item['count'] / count * 100, 2)
|
|
|
|
- else:
|
|
|
|
- rate = 0
|
|
|
|
- region_dict = {
|
|
|
|
- 'countryName': country_name,
|
|
|
|
- 'count': item['count'],
|
|
|
|
- 'rate': rate
|
|
|
|
- }
|
|
|
|
- region_list.append(region_dict)
|
|
|
|
-
|
|
|
|
# 设备类型订单统计
|
|
# 设备类型订单统计
|
|
device_type_list = []
|
|
device_type_list = []
|
|
device_type_qs = order_qs.values('UID').annotate(count=Count('UID')).order_by('count')
|
|
device_type_qs = order_qs.values('UID').annotate(count=Count('UID')).order_by('count')
|
|
uid_dict = {}
|
|
uid_dict = {}
|
|
|
|
+ uid_list = []
|
|
for item in device_type_qs:
|
|
for item in device_type_qs:
|
|
|
|
+ uid_list.append(item['UID'])
|
|
device_qs = Device_Info.objects.filter(UID=item['UID']).values('Type')
|
|
device_qs = Device_Info.objects.filter(UID=item['UID']).values('Type')
|
|
device_type = device_qs[0]['Type'] if device_qs.exists() else 0
|
|
device_type = device_qs[0]['Type'] if device_qs.exists() else 0
|
|
if device_type not in uid_dict:
|
|
if device_type not in uid_dict:
|
|
uid_dict[device_type] = []
|
|
uid_dict[device_type] = []
|
|
uid_dict[device_type].append(item['UID'])
|
|
uid_dict[device_type].append(item['UID'])
|
|
for k, v in uid_dict.items():
|
|
for k, v in uid_dict.items():
|
|
- type_name = DEVICE_TYPE.get(k, '未知类型')
|
|
|
|
- type_name = type_name if type_name != 'UNKOWN' else '未知类型'
|
|
|
|
|
|
+ type_qs = DeviceTypeModel.objects.filter(type=k).values('name')
|
|
|
|
+ type_name = type_qs[0]['name'] if type_qs.exists() else '未知类型'
|
|
device_count = order_qs.filter(UID__in=v).count()
|
|
device_count = order_qs.filter(UID__in=v).count()
|
|
if count:
|
|
if count:
|
|
type_rate = round(device_count / count * 100, 2)
|
|
type_rate = round(device_count / count * 100, 2)
|
|
@@ -392,11 +396,38 @@ class ServiceDataView(View):
|
|
}
|
|
}
|
|
device_type_list.append(device_temp_qs)
|
|
device_type_list.append(device_temp_qs)
|
|
|
|
|
|
|
|
+ # 区域订单统计
|
|
|
|
+ region_list = []
|
|
|
|
+ region_dict = {}
|
|
|
|
+ for item in uid_list:
|
|
|
|
+ uidset_qs = UidSetModel.objects.filter(uid=item).values('tb_country')
|
|
|
|
+ if uidset_qs.exists():
|
|
|
|
+ country_qs = CountryModel.objects.filter(id=uidset_qs[0]['tb_country']).values('country_name')
|
|
|
|
+ country_name = country_qs[0]['country_name'] if country_qs.exists() else '未知区域'
|
|
|
|
+ else:
|
|
|
|
+ country_name = '未知区域'
|
|
|
|
+ if country_name not in region_dict:
|
|
|
|
+ region_dict[country_name] = []
|
|
|
|
+ region_dict[country_name].append(item)
|
|
|
|
+ for k, v in region_dict.items():
|
|
|
|
+ region_order_count = order_qs.filter(UID__in=v).count()
|
|
|
|
+ if count:
|
|
|
|
+ rate = round(region_order_count / count * 100, 2)
|
|
|
|
+ else:
|
|
|
|
+ rate = 0
|
|
|
|
+ region_temp_dict = {
|
|
|
|
+ 'countryName': k,
|
|
|
|
+ 'count': region_order_count,
|
|
|
|
+ 'rate': rate
|
|
|
|
+ }
|
|
|
|
+ region_list.append(region_temp_dict)
|
|
|
|
+
|
|
res = {
|
|
res = {
|
|
'orders': order_list,
|
|
'orders': order_list,
|
|
'regions': region_list,
|
|
'regions': region_list,
|
|
'deviceType': device_type_list,
|
|
'deviceType': device_type_list,
|
|
}
|
|
}
|
|
|
|
+
|
|
return response.json(0, res)
|
|
return response.json(0, res)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
return response.json(500, repr(e))
|
|
return response.json(500, repr(e))
|
|
@@ -452,37 +483,21 @@ class ServiceDataView(View):
|
|
}
|
|
}
|
|
order_list.append(order_dict)
|
|
order_list.append(order_dict)
|
|
|
|
|
|
- # 区域订单统计
|
|
|
|
- region_list = []
|
|
|
|
- region_qs = order_qs.values('userID__region_country').annotate(count=Count('UID')).order_by('-count')
|
|
|
|
- for item in region_qs:
|
|
|
|
- country_id = item['userID__region_country']
|
|
|
|
- country_qs = CountryModel.objects.filter(id=country_id).values('country_name')
|
|
|
|
- country_name = country_qs[0]['country_name'] if country_qs.exists() else '未知区域'
|
|
|
|
- if count:
|
|
|
|
- rate = round(item['count'] / count * 100, 2)
|
|
|
|
- else:
|
|
|
|
- rate = 0
|
|
|
|
- region_dict = {
|
|
|
|
- 'countryName': country_name,
|
|
|
|
- 'count': item['count'],
|
|
|
|
- 'rate': rate
|
|
|
|
- }
|
|
|
|
- region_list.append(region_dict)
|
|
|
|
-
|
|
|
|
# 设备类型订单统计
|
|
# 设备类型订单统计
|
|
device_type_list = []
|
|
device_type_list = []
|
|
device_type_qs = order_qs.values('UID').annotate(count=Count('UID')).order_by('count')
|
|
device_type_qs = order_qs.values('UID').annotate(count=Count('UID')).order_by('count')
|
|
uid_dict = {}
|
|
uid_dict = {}
|
|
|
|
+ uid_list = []
|
|
for item in device_type_qs:
|
|
for item in device_type_qs:
|
|
|
|
+ uid_list.append(item['UID'])
|
|
device_qs = Device_Info.objects.filter(UID=item['UID']).values('Type')
|
|
device_qs = Device_Info.objects.filter(UID=item['UID']).values('Type')
|
|
device_type = device_qs[0]['Type'] if device_qs.exists() else 0
|
|
device_type = device_qs[0]['Type'] if device_qs.exists() else 0
|
|
if device_type not in uid_dict:
|
|
if device_type not in uid_dict:
|
|
uid_dict[device_type] = []
|
|
uid_dict[device_type] = []
|
|
uid_dict[device_type].append(item['UID'])
|
|
uid_dict[device_type].append(item['UID'])
|
|
for k, v in uid_dict.items():
|
|
for k, v in uid_dict.items():
|
|
- type_name = DEVICE_TYPE.get(k, '未知类型')
|
|
|
|
- type_name = type_name if type_name != 'UNKOWN' else '未知类型'
|
|
|
|
|
|
+ type_qs = DeviceTypeModel.objects.filter(type=k).values('name')
|
|
|
|
+ type_name = type_qs[0]['name'] if type_qs.exists() else '未知类型'
|
|
device_count = order_qs.filter(UID__in=v).count()
|
|
device_count = order_qs.filter(UID__in=v).count()
|
|
if count:
|
|
if count:
|
|
if count:
|
|
if count:
|
|
@@ -498,6 +513,31 @@ class ServiceDataView(View):
|
|
}
|
|
}
|
|
device_type_list.append(device_temp_qs)
|
|
device_type_list.append(device_temp_qs)
|
|
|
|
|
|
|
|
+ # 区域订单统计
|
|
|
|
+ region_list = []
|
|
|
|
+ region_dict = {}
|
|
|
|
+ for item in uid_list:
|
|
|
|
+ uidset_qs = UidSetModel.objects.filter(uid=item).values('tb_country')
|
|
|
|
+ if uidset_qs.exists():
|
|
|
|
+ country_qs = CountryModel.objects.filter(id=uidset_qs[0]['tb_country']).values('country_name')
|
|
|
|
+ country_name = country_qs[0]['country_name'] if country_qs.exists() else '未知区域'
|
|
|
|
+ else:
|
|
|
|
+ country_name = '未知区域'
|
|
|
|
+ if country_name not in region_dict:
|
|
|
|
+ region_dict[country_name] = []
|
|
|
|
+ region_dict[country_name].append(item)
|
|
|
|
+ for k, v in region_dict.items():
|
|
|
|
+ region_order_count = order_qs.filter(UID__in=v).count()
|
|
|
|
+ if count:
|
|
|
|
+ rate = round(region_order_count / count * 100, 2)
|
|
|
|
+ else:
|
|
|
|
+ rate = 0
|
|
|
|
+ region_temp_dict = {
|
|
|
|
+ 'countryName': k,
|
|
|
|
+ 'count': region_order_count,
|
|
|
|
+ 'rate': rate
|
|
|
|
+ }
|
|
|
|
+ region_list.append(region_temp_dict)
|
|
res = {
|
|
res = {
|
|
'orders': order_list,
|
|
'orders': order_list,
|
|
'regions': region_list,
|
|
'regions': region_list,
|
|
@@ -529,7 +569,7 @@ class ServiceDataView(View):
|
|
region_count = 0
|
|
region_count = 0
|
|
device_type_list = []
|
|
device_type_list = []
|
|
device_type_count = 0
|
|
device_type_count = 0
|
|
- device_type_total = 0
|
|
|
|
|
|
+ total = 0
|
|
store_meal_list = []
|
|
store_meal_list = []
|
|
store_meal_count = 0
|
|
store_meal_count = 0
|
|
for url in url_list:
|
|
for url in url_list:
|
|
@@ -573,22 +613,19 @@ class ServiceDataView(View):
|
|
each['count'] += int(item['count'])
|
|
each['count'] += int(item['count'])
|
|
item['totalMoney'] += item['totalMoney']
|
|
item['totalMoney'] += item['totalMoney']
|
|
device_type_count += int(item['count'])
|
|
device_type_count += int(item['count'])
|
|
- device_type_total += item['totalMoney']
|
|
|
|
|
|
+ total += item['totalMoney']
|
|
flag = 1
|
|
flag = 1
|
|
break
|
|
break
|
|
if flag == 0:
|
|
if flag == 0:
|
|
device_type_list.append(item)
|
|
device_type_list.append(item)
|
|
device_type_count += int(item['count'])
|
|
device_type_count += int(item['count'])
|
|
- device_type_total += item['totalMoney']
|
|
|
|
|
|
+ total += item['totalMoney']
|
|
for item in device_type_list:
|
|
for item in device_type_list:
|
|
if device_type_count:
|
|
if device_type_count:
|
|
type_rate = round(item['count'] / device_type_count * 100, 2)
|
|
type_rate = round(item['count'] / device_type_count * 100, 2)
|
|
else:
|
|
else:
|
|
type_rate = 0
|
|
type_rate = 0
|
|
- if device_type_total:
|
|
|
|
- total_rate = round(item['totalMoney'] / device_type_total * 100, 2)
|
|
|
|
- else:
|
|
|
|
- total_rate = 0
|
|
|
|
|
|
+ total_rate = round(item['totalMoney'] / total * 100, 2)
|
|
item['typeRate'] = type_rate
|
|
item['typeRate'] = type_rate
|
|
item['totalRate'] = total_rate
|
|
item['totalRate'] = total_rate
|
|
# 处理套餐
|
|
# 处理套餐
|
|
@@ -597,6 +634,7 @@ class ServiceDataView(View):
|
|
for each in store_meal_list:
|
|
for each in store_meal_list:
|
|
if each['storeMealId'] == item['storeMealId']:
|
|
if each['storeMealId'] == item['storeMealId']:
|
|
each['count'] += int(item['count'])
|
|
each['count'] += int(item['count'])
|
|
|
|
+ each['storeMealTotal'] += item['storeMealTotal']
|
|
store_meal_count += int(item['count'])
|
|
store_meal_count += int(item['count'])
|
|
flag = 1
|
|
flag = 1
|
|
break
|
|
break
|
|
@@ -604,13 +642,15 @@ class ServiceDataView(View):
|
|
store_meal_list.append(item)
|
|
store_meal_list.append(item)
|
|
store_meal_count += int(item['count'])
|
|
store_meal_count += int(item['count'])
|
|
for item in store_meal_list:
|
|
for item in store_meal_list:
|
|
|
|
+ total_rate = round(item['storeMealTotal'] / total * 100, 2)
|
|
if store_meal_count:
|
|
if store_meal_count:
|
|
rate = round(item['count'] / store_meal_count * 100, 2)
|
|
rate = round(item['count'] / store_meal_count * 100, 2)
|
|
else:
|
|
else:
|
|
rate = 0
|
|
rate = 0
|
|
item['rate'] = rate
|
|
item['rate'] = rate
|
|
|
|
+ item['totalRate'] = total_rate
|
|
else:
|
|
else:
|
|
- return response.json(result['result_code'])
|
|
|
|
|
|
+ return response.json(result['result_code'], result['result'])
|
|
res = {
|
|
res = {
|
|
'orders': order_list,
|
|
'orders': order_list,
|
|
'regions': CommonService.list_sort(region_list),
|
|
'regions': CommonService.list_sort(region_list),
|
|
@@ -697,7 +737,7 @@ class ServiceDataView(View):
|
|
new_device_count += int(result['result']['newDeviceCount'])
|
|
new_device_count += int(result['result']['newDeviceCount'])
|
|
order_device_count += int(result['result']['orderDeviceCount'])
|
|
order_device_count += int(result['result']['orderDeviceCount'])
|
|
else:
|
|
else:
|
|
- return response.json(result['result_code'])
|
|
|
|
|
|
+ return response.json(result['result_code'], result['result'])
|
|
if new_device_count:
|
|
if new_device_count:
|
|
inversion_rate = round(order_device_count / new_device_count * 100, 2)
|
|
inversion_rate = round(order_device_count / new_device_count * 100, 2)
|
|
else:
|
|
else:
|
|
@@ -785,7 +825,7 @@ class ServiceDataView(View):
|
|
type_rate = 0
|
|
type_rate = 0
|
|
item['typeRate'] = type_rate
|
|
item['typeRate'] = type_rate
|
|
else:
|
|
else:
|
|
- return response.json(result['result_code'])
|
|
|
|
|
|
+ return response.json(result['result_code'], result['result'])
|
|
res = {
|
|
res = {
|
|
'orders': order_list,
|
|
'orders': order_list,
|
|
'regions': CommonService.list_sort(region_list),
|
|
'regions': CommonService.list_sort(region_list),
|
|
@@ -871,7 +911,7 @@ class ServiceDataView(View):
|
|
repeat_count += result['result']['repeatCount']
|
|
repeat_count += result['result']['repeatCount']
|
|
order_count += result['result']['orderCount']
|
|
order_count += result['result']['orderCount']
|
|
else:
|
|
else:
|
|
- return response.json(result['result_code'])
|
|
|
|
|
|
+ return response.json(result['result_code'], result['result'])
|
|
if order_count:
|
|
if order_count:
|
|
repeat_rate = round(repeat_count / order_count * 100, 2)
|
|
repeat_rate = round(repeat_count / order_count * 100, 2)
|
|
else:
|
|
else:
|