|
@@ -76,9 +76,15 @@ class ServiceDataView(View):
|
|
|
service_type=store_meal_type).values('count', 'country', 'total',
|
|
|
'device_type', 'store_meal')
|
|
|
all_order_qs = OrdersSummary.objects.filter(time__gte=start_time, time__lt=end_time).filter(
|
|
|
- Q(query_type=0) | Q(query_type=1)).aggregate(total=Sum('total'), count=Sum('count'))
|
|
|
- all_order_count = all_order_qs['count'] if all_order_qs['count'] else 0
|
|
|
- all_order_total = all_order_qs['total'] if all_order_qs['total'] else 0
|
|
|
+ Q(query_type=0) | Q(query_type=1)).values('total', 'count')
|
|
|
+ all_order_count = 0
|
|
|
+ all_order_cny_total = 0
|
|
|
+ all_order_usd_total = 0
|
|
|
+ for item in all_order_qs:
|
|
|
+ all_order_count += item['count']
|
|
|
+ temp_total = eval(item['total'])
|
|
|
+ all_order_cny_total += temp_total.get('CNY', 0)
|
|
|
+ all_order_usd_total += temp_total.get('USD', 0)
|
|
|
start_time = datetime.datetime.fromtimestamp(int(start_time))
|
|
|
end_time = datetime.datetime.fromtimestamp(int(end_time))
|
|
|
time_list = CommonService.cutting_time(start_time, end_time, time_unit)
|
|
@@ -89,8 +95,16 @@ class ServiceDataView(View):
|
|
|
order_temp_qs = order_qs.filter(time__gte=item[0], time__lt=item[1])
|
|
|
temp_count = order_temp_qs.aggregate(count=Sum('count'))['count']
|
|
|
temp_count = temp_count if temp_count else 0
|
|
|
+ temp_cny_total = 0
|
|
|
+ temp_usd_total = 0
|
|
|
+ for each in order_temp_qs:
|
|
|
+ temp_total = eval(each['total'])
|
|
|
+ temp_cny_total += temp_total.get('CNY', 0)
|
|
|
+ temp_usd_total += temp_total.get('USD', 0)
|
|
|
order_dict = {
|
|
|
'count': temp_count,
|
|
|
+ 'cnyTotal': temp_cny_total,
|
|
|
+ 'usdTotal': temp_usd_total,
|
|
|
'startTime': item[0],
|
|
|
'endTime': item[1]
|
|
|
}
|
|
@@ -105,56 +119,78 @@ class ServiceDataView(View):
|
|
|
store_meal_temp_dict = eval(each['store_meal'])
|
|
|
for k, v in device_type_temp_dict.items():
|
|
|
if k in device_type_dict:
|
|
|
- device_type_dict[k]['数量'] += v['数量']
|
|
|
- device_type_dict[k]['销售额'] = round(device_type_dict[k]['销售额'] + v['销售额'], 2)
|
|
|
+ for a, b in v.items():
|
|
|
+ if a not in device_type_dict[k]:
|
|
|
+ device_type_dict[k][a] = b
|
|
|
+ else:
|
|
|
+ device_type_dict[k][a] += b
|
|
|
else:
|
|
|
device_type_dict[k] = v
|
|
|
for k, v in country_temp_dict.items():
|
|
|
if k in country_dict:
|
|
|
- country_dict[k] += v
|
|
|
+ for a, b in v.items():
|
|
|
+ if a not in country_dict[k]:
|
|
|
+ country_dict[k][a] = b
|
|
|
+ else:
|
|
|
+ country_dict[k][a] += b
|
|
|
else:
|
|
|
country_dict[k] = v
|
|
|
for k, v in store_meal_temp_dict.items():
|
|
|
if k in store_meal_dict:
|
|
|
- store_meal_dict[k]['数量'] += v['数量']
|
|
|
- store_meal_dict[k]['销售额'] = round(store_meal_dict[k]['销售额'] + v['销售额'], 2)
|
|
|
+ for a, b in v.items():
|
|
|
+ if a not in store_meal_dict[k]:
|
|
|
+ store_meal_dict[k][a] = b
|
|
|
+ else:
|
|
|
+ store_meal_dict[k][a] += b
|
|
|
else:
|
|
|
store_meal_dict[k] = v
|
|
|
# 设备类型订单统计
|
|
|
device_type_list = []
|
|
|
for k, v in device_type_dict.items():
|
|
|
type_rate = round(v['数量'] / all_order_count * 100, 2) if all_order_count else 0
|
|
|
- total_rate = round(v['销售额'] / all_order_total * 100, 2) if all_order_total else 0
|
|
|
+ cny_total_rate = round(v.get('CNY', 0) / all_order_cny_total * 100, 2) if all_order_cny_total else 0
|
|
|
+ usd_total_rate = round(v.get('USD', 0) / all_order_usd_total * 100, 2) if all_order_usd_total else 0
|
|
|
device_temp_dict = {
|
|
|
'typeName': k,
|
|
|
'count': v['数量'],
|
|
|
'typeRate': type_rate,
|
|
|
- 'totalMoney': v['销售额'],
|
|
|
- 'totalRate': total_rate
|
|
|
+ 'cnyTotalMoney': v.get('CNY', 0),
|
|
|
+ 'usdTotalMoney': v.get('USD', 0),
|
|
|
+ 'cnyTotalRate': cny_total_rate,
|
|
|
+ 'usdTotalRate': usd_total_rate,
|
|
|
}
|
|
|
device_type_list.append(device_temp_dict)
|
|
|
|
|
|
# 区域订单统计
|
|
|
region_list = []
|
|
|
for k, v in country_dict.items():
|
|
|
- rate = round(v / all_order_count * 100, 2) if all_order_count else 0
|
|
|
+ rate = round(v['数量'] / all_order_count * 100, 2) if all_order_count else 0
|
|
|
+ cny_total_rate = round(v.get('CNY', 0) / all_order_cny_total * 100, 2) if all_order_cny_total else 0
|
|
|
+ usd_total_rate = round(v.get('USD', 0) / all_order_usd_total * 100, 2) if all_order_usd_total else 0
|
|
|
region_temp_dict = {
|
|
|
'countryName': k,
|
|
|
- 'count': v,
|
|
|
- 'rate': rate
|
|
|
+ 'count': v['数量'],
|
|
|
+ 'rate': rate,
|
|
|
+ 'cnyTotalMoney': v.get('CNY', 0),
|
|
|
+ 'usdTotalMoney': v.get('USD', 0),
|
|
|
+ 'cnyTotalRate': cny_total_rate,
|
|
|
+ 'usdTotalRate': usd_total_rate,
|
|
|
}
|
|
|
region_list.append(region_temp_dict)
|
|
|
|
|
|
# 套餐订单统计
|
|
|
store_meal_list = []
|
|
|
for k, v in store_meal_dict.items():
|
|
|
- total_rate = round(float(v['销售额']) / all_order_total * 100, 2) if all_order_total else 0
|
|
|
count_rate = round(v['数量'] / all_order_count * 100, 2) if all_order_count else 0
|
|
|
+ cny_total_rate = round(v.get('CNY', 0) / all_order_cny_total * 100, 2) if all_order_cny_total else 0
|
|
|
+ usd_total_rate = round(v.get('USD', 0) / all_order_usd_total * 100, 2) if all_order_usd_total else 0
|
|
|
store_temp_dict = {
|
|
|
'count': v['数量'],
|
|
|
'storeMealName': k,
|
|
|
- 'storeMealTotal': v['销售额'],
|
|
|
- 'totalRate': total_rate,
|
|
|
+ 'cnyTotalMoney': v.get('CNY', 0),
|
|
|
+ 'usdTotalMoney': v.get('USD', 0),
|
|
|
+ 'cnyTotalRate': cny_total_rate,
|
|
|
+ 'usdTotalRate': usd_total_rate,
|
|
|
'rate': count_rate
|
|
|
}
|
|
|
store_meal_list.append(store_temp_dict)
|
|
@@ -164,7 +200,8 @@ class ServiceDataView(View):
|
|
|
'deviceType': device_type_list,
|
|
|
'storeMeal': store_meal_list,
|
|
|
'allOrderCount': all_order_count,
|
|
|
- 'allOrderTotal': all_order_total
|
|
|
+ 'allCnyOrderTotal': all_order_cny_total,
|
|
|
+ 'allUsdOrderTotal': all_order_usd_total,
|
|
|
}
|
|
|
return response.json(0, res)
|
|
|
except Exception as e:
|
|
@@ -299,11 +336,18 @@ class ServiceDataView(View):
|
|
|
return response.json(444, {'error param': 'startTime or endTime or timeUnit or storeMealType'})
|
|
|
try:
|
|
|
order_qs = OrdersSummary.objects.filter(time__gte=start_time, time__lt=end_time, query_type=2,
|
|
|
- service_type=store_meal_type).values('count', 'country',
|
|
|
+ service_type=store_meal_type).values('count', 'country', 'total',
|
|
|
'device_type')
|
|
|
all_order_qs = OrdersSummary.objects.filter(time__gte=start_time, time__lt=end_time).filter(
|
|
|
- Q(query_type=0) | Q(query_type=1)).aggregate(count=Sum('count'))
|
|
|
- all_order_count = all_order_qs['count'] if all_order_qs['count'] else 0 # 所有订单数量
|
|
|
+ Q(query_type=0) | Q(query_type=1)).values('total', 'count')
|
|
|
+ all_order_count = 0
|
|
|
+ all_order_cny_total = 0
|
|
|
+ all_order_usd_total = 0
|
|
|
+ for item in all_order_qs:
|
|
|
+ all_order_count += item['count']
|
|
|
+ temp_total = eval(item['total'])
|
|
|
+ all_order_cny_total += temp_total.get('CNY', 0)
|
|
|
+ all_order_usd_total += temp_total.get('USD', 0)
|
|
|
start_time = datetime.datetime.fromtimestamp(int(start_time))
|
|
|
end_time = datetime.datetime.fromtimestamp(int(end_time))
|
|
|
time_list = CommonService.cutting_time(start_time, end_time, time_unit)
|
|
@@ -314,8 +358,16 @@ class ServiceDataView(View):
|
|
|
order_temp_qs = order_qs.filter(time__gte=item[0], time__lt=item[1])
|
|
|
temp_count = order_temp_qs.aggregate(count=Sum('count'))['count']
|
|
|
temp_count = temp_count if temp_count else 0
|
|
|
+ temp_cny_total = 0
|
|
|
+ temp_usd_total = 0
|
|
|
+ for each in order_temp_qs:
|
|
|
+ temp_total = eval(each['total'])
|
|
|
+ temp_cny_total += temp_total.get('CNY', 0)
|
|
|
+ temp_usd_total += temp_total.get('USD', 0)
|
|
|
order_dict = {
|
|
|
'count': temp_count,
|
|
|
+ 'cnyTotal': temp_cny_total,
|
|
|
+ 'usdTotal': temp_usd_total,
|
|
|
'startTime': item[0],
|
|
|
'endTime': item[1]
|
|
|
}
|
|
@@ -328,34 +380,54 @@ class ServiceDataView(View):
|
|
|
device_type_temp_dict = eval(each['device_type'])
|
|
|
for k, v in country_temp_dict.items():
|
|
|
if k in country_dict:
|
|
|
- country_dict[k] += v
|
|
|
+ for a, b in v.items():
|
|
|
+ if a not in country_dict[k]:
|
|
|
+ country_dict[k][a] = b
|
|
|
+ else:
|
|
|
+ country_dict[k][a] += b
|
|
|
else:
|
|
|
country_dict[k] = v
|
|
|
for k, v in device_type_temp_dict.items():
|
|
|
if k in device_type_dict:
|
|
|
- device_type_dict[k] += v
|
|
|
+ for a, b in v.items():
|
|
|
+ if a not in device_type_dict[k]:
|
|
|
+ device_type_dict[k][a] = b
|
|
|
+ else:
|
|
|
+ device_type_dict[k][a] += b
|
|
|
else:
|
|
|
device_type_dict[k] = v
|
|
|
|
|
|
# 设备类型订单统计
|
|
|
device_type_list = []
|
|
|
for k, v in device_type_dict.items():
|
|
|
- type_rate = round(v / all_order_count * 100, 2) if all_order_count else 0
|
|
|
+ type_rate = round(v['数量'] / all_order_count * 100, 2) if all_order_count else 0
|
|
|
+ cny_total_rate = round(v.get('CNY', 0) / all_order_cny_total * 100, 2) if all_order_cny_total else 0
|
|
|
+ usd_total_rate = round(v.get('USD', 0) / all_order_usd_total * 100, 2) if all_order_usd_total else 0
|
|
|
device_temp_qs = {
|
|
|
'typeName': k,
|
|
|
- 'count': v,
|
|
|
+ 'count': v['数量'],
|
|
|
+ 'cnyTotalRate': cny_total_rate,
|
|
|
+ 'usdTotalRate': usd_total_rate,
|
|
|
'typeRate': type_rate,
|
|
|
+ 'cnyTotalMoney': v.get('CNY', 0),
|
|
|
+ 'usdTotalMoney': v.get('USD', 0),
|
|
|
}
|
|
|
device_type_list.append(device_temp_qs)
|
|
|
|
|
|
# 区域订单统计
|
|
|
region_list = []
|
|
|
for k, v in country_dict.items():
|
|
|
- rate = round(v / all_order_count * 100, 2) if all_order_count else 0
|
|
|
+ rate = round(v['数量'] / all_order_count * 100, 2) if all_order_count else 0
|
|
|
+ cny_total_rate = round(v.get('CNY', 0) / all_order_cny_total * 100, 2) if all_order_cny_total else 0
|
|
|
+ usd_total_rate = round(v.get('USD', 0) / all_order_usd_total * 100, 2) if all_order_usd_total else 0
|
|
|
region_temp_dict = {
|
|
|
'countryName': k,
|
|
|
- 'count': v,
|
|
|
- 'rate': rate
|
|
|
+ 'count': v['数量'],
|
|
|
+ 'rate': rate,
|
|
|
+ 'cnyTotalMoney': v.get('CNY', 0),
|
|
|
+ 'usdTotalMoney': v.get('USD', 0),
|
|
|
+ 'cnyTotalRate': cny_total_rate,
|
|
|
+ 'usdTotalRate': usd_total_rate,
|
|
|
}
|
|
|
region_list.append(region_temp_dict)
|
|
|
|
|
@@ -363,7 +435,9 @@ class ServiceDataView(View):
|
|
|
'orders': order_list,
|
|
|
'regions': region_list,
|
|
|
'deviceType': device_type_list,
|
|
|
- 'allOrderCount': all_order_count
|
|
|
+ 'allOrderCount': all_order_count,
|
|
|
+ 'allOrderUsdTotal': all_order_usd_total,
|
|
|
+ 'allOrderCnyTotal': all_order_cny_total,
|
|
|
}
|
|
|
return response.json(0, res)
|
|
|
except Exception as e:
|
|
@@ -389,14 +463,20 @@ class ServiceDataView(View):
|
|
|
return response.json(444, {'error param': 'startTime or endTime or timeUnit or storeMealType'})
|
|
|
try:
|
|
|
order_qs = OrdersSummary.objects.filter(time__gte=start_time, time__lt=end_time, query_type=3,
|
|
|
- service_type=store_meal_type).values('count', 'country',
|
|
|
+ service_type=store_meal_type).values('count', 'country', 'total',
|
|
|
'device_type')
|
|
|
repeat_pay_order_count = order_qs.aggregate(count=Sum('count'))['count']
|
|
|
repeat_pay_order_count = repeat_pay_order_count if repeat_pay_order_count else 0
|
|
|
all_order_qs = OrdersSummary.objects.filter(time__gte=start_time, time__lt=end_time).filter(
|
|
|
- Q(query_type=0) | Q(query_type=1)).aggregate(count=Sum('count'))
|
|
|
- all_order_count = all_order_qs['count'] if all_order_qs['count'] else 0 # 所有订单数量
|
|
|
-
|
|
|
+ Q(query_type=0) | Q(query_type=1)).values('total', 'count')
|
|
|
+ all_order_count = 0 # 所有订单数量
|
|
|
+ all_order_cny_total = 0
|
|
|
+ all_order_usd_total = 0
|
|
|
+ for item in all_order_qs:
|
|
|
+ all_order_count += item['count']
|
|
|
+ temp_total = eval(item['total'])
|
|
|
+ all_order_cny_total += temp_total.get('CNY', 0)
|
|
|
+ all_order_usd_total += temp_total.get('USD', 0)
|
|
|
# 订单复购率
|
|
|
repeat_rate = round(repeat_pay_order_count / all_order_count * 100, 2) if all_order_count else 0
|
|
|
start_time = datetime.datetime.fromtimestamp(int(start_time))
|
|
@@ -408,8 +488,16 @@ class ServiceDataView(View):
|
|
|
order_temp_qs = order_qs.filter(time__gte=item[0], time__lt=item[1])
|
|
|
temp_count = order_temp_qs.aggregate(count=Sum('count'))['count']
|
|
|
temp_count = temp_count if temp_count else 0
|
|
|
+ temp_cny_total = 0
|
|
|
+ temp_usd_total = 0
|
|
|
+ for each in order_temp_qs:
|
|
|
+ temp_total = eval(each['total'])
|
|
|
+ temp_cny_total += temp_total.get('CNY', 0)
|
|
|
+ temp_usd_total += temp_total.get('USD', 0)
|
|
|
order_dict = {
|
|
|
'count': temp_count,
|
|
|
+ 'cnyTotal': temp_cny_total,
|
|
|
+ 'usdTotal': temp_usd_total,
|
|
|
'startTime': item[0],
|
|
|
'endTime': item[1]
|
|
|
}
|
|
@@ -421,34 +509,54 @@ class ServiceDataView(View):
|
|
|
device_type_temp_dict = eval(each['device_type'])
|
|
|
for k, v in country_temp_dict.items():
|
|
|
if k in country_dict:
|
|
|
- country_dict[k] += v
|
|
|
+ for a, b in v.items():
|
|
|
+ if a not in country_dict[k]:
|
|
|
+ country_dict[k][a] = b
|
|
|
+ else:
|
|
|
+ country_dict[k][a] += b
|
|
|
else:
|
|
|
country_dict[k] = v
|
|
|
for k, v in device_type_temp_dict.items():
|
|
|
if k in device_type_dict:
|
|
|
- device_type_dict[k] += v
|
|
|
+ for a, b in v.items():
|
|
|
+ if a not in device_type_dict[k]:
|
|
|
+ device_type_dict[k][a] = b
|
|
|
+ else:
|
|
|
+ device_type_dict[k][a] += b
|
|
|
else:
|
|
|
device_type_dict[k] = v
|
|
|
|
|
|
# 设备类型订单统计
|
|
|
device_type_list = []
|
|
|
for k, v in device_type_dict.items():
|
|
|
- type_rate = round(v / all_order_count * 100, 2) if all_order_count else 0
|
|
|
+ type_rate = round(v['数量'] / all_order_count * 100, 2) if all_order_count else 0
|
|
|
+ cny_total_rate = round(v.get('CNY', 0) / all_order_cny_total * 100, 2) if all_order_cny_total else 0
|
|
|
+ usd_total_rate = round(v.get('USD', 0) / all_order_usd_total * 100, 2) if all_order_usd_total else 0
|
|
|
device_temp_qs = {
|
|
|
'typeName': k,
|
|
|
- 'count': v,
|
|
|
+ 'count': v['数量'],
|
|
|
'typeRate': type_rate,
|
|
|
+ 'cnyTotalMoney': v.get('CNY', 0),
|
|
|
+ 'usdTotalMoney': v.get('USD', 0),
|
|
|
+ 'cnyTotalRate': cny_total_rate,
|
|
|
+ 'usdTotalRate': usd_total_rate,
|
|
|
}
|
|
|
device_type_list.append(device_temp_qs)
|
|
|
|
|
|
# 区域订单统计
|
|
|
region_list = []
|
|
|
for k, v in country_dict.items():
|
|
|
- rate = round(v / all_order_count * 100, 2) if all_order_count else 0
|
|
|
+ rate = round(v['数量'] / all_order_count * 100, 2) if all_order_count else 0
|
|
|
+ cny_total_rate = round(v.get('CNY', 0) / all_order_cny_total * 100, 2) if all_order_cny_total else 0
|
|
|
+ usd_total_rate = round(v.get('USD', 0) / all_order_usd_total * 100, 2) if all_order_usd_total else 0
|
|
|
region_temp_dict = {
|
|
|
'countryName': k,
|
|
|
- 'count': v,
|
|
|
- 'rate': rate
|
|
|
+ 'count': v['数量'],
|
|
|
+ 'rate': rate,
|
|
|
+ 'cnyTotalMoney': v.get('CNY', 0),
|
|
|
+ 'usdTotalMoney': v.get('USD', 0),
|
|
|
+ 'cnyTotalRate': cny_total_rate,
|
|
|
+ 'usdTotalRate': usd_total_rate,
|
|
|
}
|
|
|
region_list.append(region_temp_dict)
|
|
|
res = {
|
|
@@ -457,7 +565,10 @@ class ServiceDataView(View):
|
|
|
'deviceType': device_type_list,
|
|
|
'repeatRate': repeat_rate,
|
|
|
'repeatOrderCount': repeat_pay_order_count,
|
|
|
- 'allOrderCount': all_order_count
|
|
|
+ 'allOrderCount': all_order_count,
|
|
|
+ 'allOrderCnyTotal': all_order_cny_total,
|
|
|
+ 'allOrderUsdTotal': all_order_usd_total,
|
|
|
+
|
|
|
}
|
|
|
return response.json(0, res)
|
|
|
except Exception as e:
|
|
@@ -481,7 +592,8 @@ class ServiceDataView(View):
|
|
|
region_list = []
|
|
|
device_type_list = []
|
|
|
all_order_count = 0
|
|
|
- all_order_total = 0
|
|
|
+ all_cny_order_total = 0
|
|
|
+ all_usd_order_total = 0
|
|
|
store_meal_list = []
|
|
|
for url in url_list:
|
|
|
url = url + request.path.replace('global/', '')
|
|
@@ -494,6 +606,8 @@ class ServiceDataView(View):
|
|
|
for each in order_list:
|
|
|
if each['startTime'] == item['startTime'] and each['endTime'] == item['endTime']:
|
|
|
each['count'] += int(item['count'])
|
|
|
+ each['cnyTotal'] += item['cnyTotal']
|
|
|
+ each['usdTotal'] += item['usdTotal']
|
|
|
flag = 1
|
|
|
break
|
|
|
if flag == 0:
|
|
@@ -504,6 +618,8 @@ class ServiceDataView(View):
|
|
|
for each in region_list:
|
|
|
if each['countryName'] == item['countryName']:
|
|
|
each['count'] += int(item['count'])
|
|
|
+ each['cnyTotalMoney'] += item['cnyTotalMoney']
|
|
|
+ each['usdTotalMoney'] += item['usdTotalMoney']
|
|
|
flag = 1
|
|
|
break
|
|
|
if flag == 0:
|
|
@@ -515,7 +631,8 @@ class ServiceDataView(View):
|
|
|
for each in device_type_list:
|
|
|
if each['typeName'] == item['typeName']:
|
|
|
each['count'] += int(item['count'])
|
|
|
- item['totalMoney'] += item['totalMoney']
|
|
|
+ each['cnyTotalMoney'] += item['cnyTotalMoney']
|
|
|
+ each['usdTotalMoney'] += item['usdTotalMoney']
|
|
|
flag = 1
|
|
|
break
|
|
|
if flag == 0:
|
|
@@ -527,23 +644,44 @@ class ServiceDataView(View):
|
|
|
for each in store_meal_list:
|
|
|
if each['storeMealName'] == item['storeMealName']:
|
|
|
each['count'] += int(item['count'])
|
|
|
- each['storeMealTotal'] += item['storeMealTotal']
|
|
|
+ each['cnyTotalMoney'] += item['cnyTotalMoney']
|
|
|
+ each['usdTotalMoney'] += item['usdTotalMoney']
|
|
|
flag = 1
|
|
|
break
|
|
|
if flag == 0:
|
|
|
store_meal_list.append(item)
|
|
|
|
|
|
- all_order_total += result['result']['allOrderTotal']
|
|
|
+ all_cny_order_total += result['result']['allCnyOrderTotal']
|
|
|
+ all_usd_order_total += result['result']['allUsdOrderTotal']
|
|
|
all_order_count += result['result']['allOrderCount']
|
|
|
else:
|
|
|
return response.json(result['result_code'], result['result'])
|
|
|
+ for item in order_list:
|
|
|
+ item['cnyTotal'] = round(item['cnyTotal'], 2)
|
|
|
+ item['usdTotal'] = round(item['usdTotal'], 2)
|
|
|
for item in region_list:
|
|
|
item['rate'] = round(item['count'] / all_order_count * 100, 2) if all_order_count else 0
|
|
|
+ item['cnyTotalMoney'] = round(item['cnyTotalMoney'], 2)
|
|
|
+ item['usdTotalMoney'] = round(item['usdTotalMoney'], 2)
|
|
|
+ item['cnyTotalRate'] = round(item['cnyTotalMoney'] / all_cny_order_total * 100,
|
|
|
+ 2) if all_cny_order_total else 0
|
|
|
+ item['usdTotalRate'] = round(item['usdTotalMoney'] / all_usd_order_total * 100,
|
|
|
+ 2) if all_usd_order_total else 0
|
|
|
for item in device_type_list:
|
|
|
item['typeRate'] = round(item['count'] / all_order_count * 100, 2) if all_order_count else 0
|
|
|
- item['totalRate'] = round(item['totalMoney'] / all_order_total * 100, 2) if all_order_total else 0
|
|
|
+ item['cnyTotalMoney'] = round(item['cnyTotalMoney'], 2)
|
|
|
+ item['usdTotalMoney'] = round(item['usdTotalMoney'], 2)
|
|
|
+ item['cnyTotalRate'] = round(item['cnyTotalMoney'] / all_cny_order_total * 100,
|
|
|
+ 2) if all_cny_order_total else 0
|
|
|
+ item['usdTotalRate'] = round(item['usdTotalMoney'] / all_usd_order_total * 100,
|
|
|
+ 2) if all_usd_order_total else 0
|
|
|
for item in store_meal_list:
|
|
|
- item['totalRate'] = round(item['storeMealTotal'] / all_order_total * 100, 2) if all_order_total else 0
|
|
|
+ item['cnyTotalRate'] = round(item['cnyTotalMoney'] / all_cny_order_total * 100,
|
|
|
+ 2) if all_cny_order_total else 0
|
|
|
+ item['usdTotalRate'] = round(item['usdTotalMoney'] / all_usd_order_total * 100,
|
|
|
+ 2) if all_usd_order_total else 0
|
|
|
+ item['cnyTotalMoney'] = round(item['cnyTotalMoney'], 2)
|
|
|
+ item['usdTotalMoney'] = round(item['usdTotalMoney'], 2)
|
|
|
item['rate'] = round(item['count'] / all_order_count * 100, 2) if all_order_count else 0
|
|
|
res = {
|
|
|
'orders': order_list,
|
|
@@ -628,8 +766,6 @@ class ServiceDataView(View):
|
|
|
'orders': order_list,
|
|
|
'regions': CommonService.list_sort(region_list),
|
|
|
'deviceType': CommonService.list_sort(device_type_list),
|
|
|
- 'newDeviceCount': new_device_count,
|
|
|
- 'allOrderCount': all_order_count,
|
|
|
'inversionRate': inversion_rate
|
|
|
}
|
|
|
return response.json(0, res)
|
|
@@ -654,6 +790,8 @@ class ServiceDataView(View):
|
|
|
region_list = []
|
|
|
device_type_list = []
|
|
|
all_order_count = 0
|
|
|
+ all_usd_order_total = 0
|
|
|
+ all_cny_order_total = 0
|
|
|
for url in url_list:
|
|
|
url = url + request.path.replace('global/', '')
|
|
|
res = requests.get(url=url, params=request_dict, headers=headers)
|
|
@@ -665,6 +803,8 @@ class ServiceDataView(View):
|
|
|
for each in order_list:
|
|
|
if each['startTime'] == item['startTime'] and each['endTime'] == item['endTime']:
|
|
|
each['count'] += int(item['count'])
|
|
|
+ each['cnyTotal'] += item['cnyTotal']
|
|
|
+ each['usdTotal'] += item['usdTotal']
|
|
|
flag = 1
|
|
|
break
|
|
|
if flag == 0:
|
|
@@ -675,6 +815,8 @@ class ServiceDataView(View):
|
|
|
for each in region_list:
|
|
|
if each['countryName'] == item['countryName']:
|
|
|
each['count'] += int(item['count'])
|
|
|
+ each['cnyTotalMoney'] += item['cnyTotalMoney']
|
|
|
+ each['usdTotalMoney'] += item['usdTotalMoney']
|
|
|
flag = 1
|
|
|
break
|
|
|
if flag == 0:
|
|
@@ -686,16 +828,35 @@ class ServiceDataView(View):
|
|
|
for each in device_type_list:
|
|
|
if each['typeName'] == item['typeName']:
|
|
|
each['count'] += int(item['count'])
|
|
|
+ each['cnyTotalMoney'] += item['cnyTotalMoney']
|
|
|
+ each['usdTotalMoney'] += item['usdTotalMoney']
|
|
|
flag = 1
|
|
|
break
|
|
|
if flag == 0:
|
|
|
device_type_list.append(item)
|
|
|
all_order_count += result['result']['allOrderCount']
|
|
|
+ all_cny_order_total += result['result']['allOrderCnyTotal']
|
|
|
+ all_usd_order_total += result['result']['allOrderUsdTotal']
|
|
|
else:
|
|
|
return response.json(result['result_code'], result['result'])
|
|
|
+ for item in order_list:
|
|
|
+ item['cnyTotal'] = round(item['cnyTotal'], 2)
|
|
|
+ item['usdTotal'] = round(item['usdTotal'], 2)
|
|
|
for item in region_list:
|
|
|
+ item['cnyTotalRate'] = round(item['cnyTotalMoney'] / all_cny_order_total * 100,
|
|
|
+ 2) if all_cny_order_total else 0
|
|
|
+ item['usdTotalRate'] = round(item['usdTotalMoney'] / all_usd_order_total * 100,
|
|
|
+ 2) if all_usd_order_total else 0
|
|
|
+ item['cnyTotalMoney'] = round(item['cnyTotalMoney'], 2)
|
|
|
+ item['usdTotalMoney'] = round(item['usdTotalMoney'], 2)
|
|
|
item['rate'] = round(item['count'] / all_order_count * 100, 2) if all_order_count else 0
|
|
|
for item in device_type_list:
|
|
|
+ item['cnyTotalRate'] = round(item['cnyTotalMoney'] / all_cny_order_total * 100,
|
|
|
+ 2) if all_cny_order_total else 0
|
|
|
+ item['usdTotalRate'] = round(item['usdTotalMoney'] / all_usd_order_total * 100,
|
|
|
+ 2) if all_usd_order_total else 0
|
|
|
+ item['cnyTotalMoney'] = round(item['cnyTotalMoney'], 2)
|
|
|
+ item['usdTotalMoney'] = round(item['usdTotalMoney'], 2)
|
|
|
item['typeRate'] = round(item['count'] / all_order_count * 100, 2) if all_order_count else 0
|
|
|
res = {
|
|
|
'orders': order_list,
|
|
@@ -725,6 +886,8 @@ class ServiceDataView(View):
|
|
|
repeat_order_count = 0
|
|
|
device_type_list = []
|
|
|
all_order_count = 0
|
|
|
+ all_usd_order_total = 0
|
|
|
+ all_cny_order_total = 0
|
|
|
for url in url_list:
|
|
|
url = url + request.path.replace('global/', '')
|
|
|
res = requests.get(url=url, params=request_dict, headers=headers)
|
|
@@ -736,6 +899,8 @@ class ServiceDataView(View):
|
|
|
for each in order_list:
|
|
|
if each['startTime'] == item['startTime'] and each['endTime'] == item['endTime']:
|
|
|
each['count'] += int(item['count'])
|
|
|
+ each['cnyTotal'] += item['cnyTotal']
|
|
|
+ each['usdTotal'] += item['usdTotal']
|
|
|
flag = 1
|
|
|
break
|
|
|
if flag == 0:
|
|
@@ -746,6 +911,8 @@ class ServiceDataView(View):
|
|
|
for each in region_list:
|
|
|
if each['countryName'] == item['countryName']:
|
|
|
each['count'] += int(item['count'])
|
|
|
+ each['cnyTotalMoney'] += item['cnyTotalMoney']
|
|
|
+ each['usdTotalMoney'] += item['usdTotalMoney']
|
|
|
flag = 1
|
|
|
break
|
|
|
if flag == 0:
|
|
@@ -757,6 +924,8 @@ class ServiceDataView(View):
|
|
|
for each in device_type_list:
|
|
|
if each['typeName'] == item['typeName']:
|
|
|
each['count'] += int(item['count'])
|
|
|
+ each['cnyTotalMoney'] += item['cnyTotalMoney']
|
|
|
+ each['usdTotalMoney'] += item['usdTotalMoney']
|
|
|
flag = 1
|
|
|
break
|
|
|
if flag == 0:
|
|
@@ -765,20 +934,35 @@ class ServiceDataView(View):
|
|
|
# 处理订单复购率
|
|
|
repeat_order_count += result['result']['repeatOrderCount']
|
|
|
all_order_count += result['result']['allOrderCount']
|
|
|
+ all_usd_order_total += result['result']['allOrderUsdTotal']
|
|
|
+ all_cny_order_total += result['result']['allOrderCnyTotal']
|
|
|
else:
|
|
|
return response.json(result['result_code'], result['result'])
|
|
|
repeat_rate = round(repeat_order_count / all_order_count * 100, 2) if all_order_count else 0
|
|
|
+ for item in order_list:
|
|
|
+ item['cnyTotal'] = round(item['cnyTotal'], 2)
|
|
|
+ item['usdTotal'] = round(item['usdTotal'], 2)
|
|
|
for item in device_type_list:
|
|
|
+ item['cnyTotalRate'] = round(item['cnyTotalMoney'] / all_cny_order_total * 100,
|
|
|
+ 2) if all_cny_order_total else 0
|
|
|
+ item['usdTotalRate'] = round(item['usdTotalMoney'] / all_usd_order_total * 100,
|
|
|
+ 2) if all_usd_order_total else 0
|
|
|
+ item['cnyTotalMoney'] = round(item['cnyTotalMoney'], 2)
|
|
|
+ item['usdTotalMoney'] = round(item['usdTotalMoney'], 2)
|
|
|
item['typeRate'] = round(item['count'] / all_order_count * 100, 2) if all_order_count else 0
|
|
|
for item in region_list:
|
|
|
+ item['cnyTotalMoney'] = round(item['cnyTotalMoney'], 2)
|
|
|
+ item['usdTotalMoney'] = round(item['usdTotalMoney'], 2)
|
|
|
+ item['cnyTotalRate'] = round(item['cnyTotalMoney'] / all_cny_order_total * 100,
|
|
|
+ 2) if all_cny_order_total else 0
|
|
|
+ item['usdTotalRate'] = round(item['usdTotalMoney'] / all_usd_order_total * 100,
|
|
|
+ 2) if all_usd_order_total else 0
|
|
|
item['rate'] = round(item['count'] / all_order_count * 100, 2) if all_order_count else 0
|
|
|
res = {
|
|
|
'orders': order_list,
|
|
|
'regions': CommonService.list_sort(region_list),
|
|
|
'deviceType': CommonService.list_sort(device_type_list),
|
|
|
'repeatRate': repeat_rate,
|
|
|
- 'repeatOrderCount': repeat_order_count,
|
|
|
- 'allOrderCount': all_order_count
|
|
|
}
|
|
|
return response.json(0, res)
|
|
|
except Exception as e:
|