|
@@ -122,30 +122,76 @@ class HomeDataView(View):
|
|
order_qs = OrdersSummary.objects.filter(time__gte=start_time_stamp,
|
|
order_qs = OrdersSummary.objects.filter(time__gte=start_time_stamp,
|
|
time__lt=end_time_stamp,
|
|
time__lt=end_time_stamp,
|
|
query_type=0).values('total')
|
|
query_type=0).values('total')
|
|
- order_total = order_qs.aggregate(total=Sum('total'))['total']
|
|
|
|
- order_total = round(order_total, 2) if order_total else 0
|
|
|
|
|
|
+ cny_total = 0
|
|
|
|
+ usd_total = 0
|
|
|
|
+ for item in order_qs:
|
|
|
|
+ temp_total = eval(item['total'])
|
|
|
|
+ cny_total = round(cny_total + temp_total.get('CNY', 0), 2)
|
|
|
|
+ usd_total = round(usd_total + temp_total.get('USD', 0), 2)
|
|
|
|
+ order_total = {'cnyTotal': cny_total, 'usdTotal': usd_total}
|
|
# 昨日云存订单销售额
|
|
# 昨日云存订单销售额
|
|
- vod_order_total = order_qs.filter(service_type=0).aggregate(total=Sum('total'))['total']
|
|
|
|
- vod_order_total = round(vod_order_total, 2) if vod_order_total else 0
|
|
|
|
|
|
+ vod_order_total = order_qs.filter(service_type=0)
|
|
|
|
+ vod_cny_total = 0
|
|
|
|
+ vod_usd_total = 0
|
|
|
|
+ for item in vod_order_total:
|
|
|
|
+ temp_total = eval(item['total'])
|
|
|
|
+ vod_cny_total = round(vod_cny_total + temp_total.get('CNY', 0), 2)
|
|
|
|
+ vod_usd_total = round(vod_usd_total + temp_total.get('USD', 0), 2)
|
|
|
|
+ vod_order_total = {'cnyTotal': vod_cny_total, 'usdTotal': vod_usd_total}
|
|
# 昨日AI订单销售额
|
|
# 昨日AI订单销售额
|
|
- ai_order_total = order_qs.filter(service_type=1).aggregate(total=Sum('total'))['total']
|
|
|
|
- ai_order_total = round(ai_order_total, 2) if ai_order_total else 0
|
|
|
|
|
|
+ ai_order_total = order_qs.filter(service_type=1)
|
|
|
|
+ ai_cny_total = 0
|
|
|
|
+ ai_usd_total = 0
|
|
|
|
+ for item in ai_order_total:
|
|
|
|
+ temp_total = eval(item['total'])
|
|
|
|
+ ai_cny_total = round(ai_cny_total + temp_total.get('CNY', 0), 2)
|
|
|
|
+ ai_usd_total = round(ai_usd_total + temp_total.get('USD', 0), 2)
|
|
|
|
+ ai_order_total = {'cnyTotal': ai_cny_total, 'usdTotal': ai_usd_total}
|
|
# 昨日联通订单销售额
|
|
# 昨日联通订单销售额
|
|
- unicom_order_total = order_qs.filter(service_type=2).aggregate(total=Sum('total'))['total']
|
|
|
|
- unicom_order_total = round(unicom_order_total, 2) if unicom_order_total else 0
|
|
|
|
|
|
+ unicom_order_total = order_qs.filter(service_type=2)
|
|
|
|
+ unicom_cny_total = 0
|
|
|
|
+ unicom_usd_total = 0
|
|
|
|
+ for item in unicom_order_total:
|
|
|
|
+ temp_total = eval(item['total'])
|
|
|
|
+ unicom_cny_total = round(unicom_cny_total + temp_total.get('CNY', 0), 2)
|
|
|
|
+ unicom_usd_total = round(unicom_usd_total + temp_total.get('USD', 0), 2)
|
|
|
|
+ unicom_order_total = {'cnyTotal': unicom_cny_total, 'usdTotal': unicom_usd_total}
|
|
# 所有订单销售额
|
|
# 所有订单销售额
|
|
order_all_qs = OrdersSummary.objects.filter(time__lte=start_time_stamp, query_type=0).values('total')
|
|
order_all_qs = OrdersSummary.objects.filter(time__lte=start_time_stamp, query_type=0).values('total')
|
|
- order_all_total = order_all_qs.aggregate(total=Sum('total'))['total']
|
|
|
|
- order_all_total = round(order_all_total, 2) if order_all_total else 0
|
|
|
|
|
|
+ cny_all_total = 0
|
|
|
|
+ usd_all_total = 0
|
|
|
|
+ for item in order_all_qs:
|
|
|
|
+ temp_total = eval(item['total'])
|
|
|
|
+ cny_all_total = round(cny_all_total + temp_total.get('CNY', 0), 2)
|
|
|
|
+ usd_all_total = round(usd_all_total + temp_total.get('USD', 0), 2)
|
|
|
|
+ order_all_total = {'cnyTotal': cny_all_total, 'usdTotal': usd_all_total}
|
|
# 所有云存订单销售额
|
|
# 所有云存订单销售额
|
|
- vod_order_all_total = order_all_qs.filter(service_type=0).aggregate(total=Sum('total'))['total']
|
|
|
|
- vod_order_all_total = round(vod_order_all_total, 2) if vod_order_all_total else 0
|
|
|
|
|
|
+ vod_order_all_total = order_all_qs.filter(service_type=0)
|
|
|
|
+ vod_cny_all_total = 0
|
|
|
|
+ vod_usd_all_total = 0
|
|
|
|
+ for item in vod_order_all_total:
|
|
|
|
+ temp_total = eval(item['total'])
|
|
|
|
+ vod_cny_all_total = round(vod_cny_all_total + temp_total.get('CNY', 0), 2)
|
|
|
|
+ vod_usd_all_total = round(vod_usd_all_total + temp_total.get('USD', 0), 2)
|
|
|
|
+ vod_order_all_total = {'cnyTotal': vod_cny_all_total, 'usdTotal': vod_usd_all_total}
|
|
# 所有AI订单销售额
|
|
# 所有AI订单销售额
|
|
- ai_order_all_total = order_all_qs.filter(service_type=1).aggregate(total=Sum('total'))['total']
|
|
|
|
- ai_order_all_total = round(ai_order_all_total, 2) if ai_order_all_total else 0
|
|
|
|
|
|
+ ai_order_all_total = order_all_qs.filter(service_type=1)
|
|
|
|
+ ai_cny_all_total = 0
|
|
|
|
+ ai_usd_all_total = 0
|
|
|
|
+ for item in ai_order_all_total:
|
|
|
|
+ temp_total = eval(item['total'])
|
|
|
|
+ ai_cny_all_total = round(ai_cny_all_total + temp_total.get('CNY', 0), 2)
|
|
|
|
+ ai_usd_all_total = round(ai_usd_all_total + temp_total.get('USD', 0), 2)
|
|
|
|
+ ai_order_all_total = {'cnyTotal': ai_cny_all_total, 'usdTotal': ai_usd_all_total}
|
|
# 所有联通订单销售额
|
|
# 所有联通订单销售额
|
|
- unicom_order_all_total = order_all_qs.filter(service_type=2).aggregate(total=Sum('total'))['total']
|
|
|
|
- unicom_order_all_total = round(unicom_order_all_total, 2) if unicom_order_all_total else 0
|
|
|
|
|
|
+ unicom_order_all_total = order_all_qs.filter(service_type=2)
|
|
|
|
+ unicom_cny_all_total = 0
|
|
|
|
+ unicom_usd_all_total = 0
|
|
|
|
+ for item in unicom_order_all_total:
|
|
|
|
+ temp_total = eval(item['total'])
|
|
|
|
+ unicom_cny_all_total = round(unicom_cny_all_total + temp_total.get('CNY', 0), 2)
|
|
|
|
+ unicom_usd_all_total = round(unicom_usd_all_total + temp_total.get('USD', 0), 2)
|
|
|
|
+ unicom_order_all_total = {'cnyTotal': unicom_cny_all_total, 'usdTotal': unicom_usd_all_total}
|
|
res = {
|
|
res = {
|
|
'userIncreaseCount': user_increase_count,
|
|
'userIncreaseCount': user_increase_count,
|
|
'userActiveCount': user_active_count,
|
|
'userActiveCount': user_active_count,
|
|
@@ -230,14 +276,14 @@ class HomeDataView(View):
|
|
device_increase_count = 0
|
|
device_increase_count = 0
|
|
device_active_count = 0
|
|
device_active_count = 0
|
|
device_all_count = 0
|
|
device_all_count = 0
|
|
- order_total = 0
|
|
|
|
- vod_order_total = 0
|
|
|
|
- ai_order_total = 0
|
|
|
|
- unicom_order_total = 0
|
|
|
|
- order_all_total = 0
|
|
|
|
- vod_order_all_total = 0
|
|
|
|
- ai_order_all_total = 0
|
|
|
|
- unicom_order_all_total = 0
|
|
|
|
|
|
+ order_total = {'cnyTotal': 0, 'usdTotal': 0}
|
|
|
|
+ vod_order_total = {'cnyTotal': 0, 'usdTotal': 0}
|
|
|
|
+ ai_order_total = {'cnyTotal': 0, 'usdTotal': 0}
|
|
|
|
+ unicom_order_total = {'cnyTotal': 0, 'usdTotal': 0}
|
|
|
|
+ order_all_total = {'cnyTotal': 0, 'usdTotal': 0}
|
|
|
|
+ vod_order_all_total = {'cnyTotal': 0, 'usdTotal': 0}
|
|
|
|
+ ai_order_all_total = {'cnyTotal': 0, 'usdTotal': 0}
|
|
|
|
+ unicom_order_all_total = {'cnyTotal': 0, 'usdTotal': 0}
|
|
user_increase_temp_list = []
|
|
user_increase_temp_list = []
|
|
user_increase_list = []
|
|
user_increase_list = []
|
|
user_increase_other_dict = {'count': 0, 'countryName': '其他', 'rate': 0}
|
|
user_increase_other_dict = {'count': 0, 'countryName': '其他', 'rate': 0}
|
|
@@ -255,14 +301,38 @@ class HomeDataView(View):
|
|
device_increase_count += result['result']['deviceIncreaseCount']
|
|
device_increase_count += result['result']['deviceIncreaseCount']
|
|
device_active_count += result['result']['deviceActiveCount']
|
|
device_active_count += result['result']['deviceActiveCount']
|
|
device_all_count += result['result']['deviceAllCount']
|
|
device_all_count += result['result']['deviceAllCount']
|
|
- order_total += result['result']['orderTotal']
|
|
|
|
- vod_order_total += result['result']['vodOrderTotal']
|
|
|
|
- ai_order_total += result['result']['aiOrderTotal']
|
|
|
|
- unicom_order_total += result['result']['unicomOrderTotal']
|
|
|
|
- order_all_total += result['result']['orderAllTotal']
|
|
|
|
- vod_order_all_total += result['result']['vodOrderAllTotal']
|
|
|
|
- ai_order_all_total += result['result']['aiOrderAllTotal']
|
|
|
|
- unicom_order_all_total += result['result']['unicomOrderAllTotal']
|
|
|
|
|
|
+ order_total['cnyTotal'] = round(
|
|
|
|
+ order_total['cnyTotal'] + result['result']['orderTotal']['cnyTotal'], 2)
|
|
|
|
+ order_total['usdTotal'] = round(
|
|
|
|
+ order_total['usdTotal'] + result['result']['orderTotal']['usdTotal'], 2)
|
|
|
|
+ vod_order_total['cnyTotal'] = round(
|
|
|
|
+ vod_order_total['cnyTotal'] + result['result']['vodOrderTotal']['cnyTotal'], 2)
|
|
|
|
+ vod_order_total['usdTotal'] = round(
|
|
|
|
+ vod_order_total['usdTotal'] + result['result']['vodOrderTotal']['usdTotal'], 2)
|
|
|
|
+ ai_order_total['cnyTotal'] = round(
|
|
|
|
+ ai_order_total['cnyTotal'] + result['result']['aiOrderTotal']['cnyTotal'], 2)
|
|
|
|
+ ai_order_total['usdTotal'] = round(
|
|
|
|
+ ai_order_total['usdTotal'] + result['result']['aiOrderTotal']['usdTotal'], 2)
|
|
|
|
+ unicom_order_total['cnyTotal'] = round(
|
|
|
|
+ unicom_order_total['cnyTotal'] + result['result']['unicomOrderTotal']['cnyTotal'], 2)
|
|
|
|
+ unicom_order_total['usdTotal'] = round(
|
|
|
|
+ unicom_order_total['usdTotal'] + result['result']['unicomOrderTotal']['usdTotal'], 2)
|
|
|
|
+ order_all_total['cnyTotal'] = round(
|
|
|
|
+ order_all_total['cnyTotal'] + result['result']['orderAllTotal']['cnyTotal'], 2)
|
|
|
|
+ order_all_total['usdTotal'] = round(
|
|
|
|
+ order_all_total['usdTotal'] + result['result']['orderAllTotal']['usdTotal'], 2)
|
|
|
|
+ vod_order_all_total['cnyTotal'] = round(
|
|
|
|
+ vod_order_all_total['cnyTotal'] + result['result']['vodOrderAllTotal']['cnyTotal'], 2)
|
|
|
|
+ vod_order_all_total['usdTotal'] = round(
|
|
|
|
+ vod_order_all_total['usdTotal'] + result['result']['vodOrderAllTotal']['usdTotal'], 2)
|
|
|
|
+ ai_order_all_total['cnyTotal'] = round(
|
|
|
|
+ ai_order_all_total['cnyTotal'] + result['result']['aiOrderAllTotal']['cnyTotal'], 2)
|
|
|
|
+ ai_order_all_total['usdTotal'] = round(
|
|
|
|
+ ai_order_all_total['usdTotal'] + result['result']['aiOrderAllTotal']['usdTotal'], 2)
|
|
|
|
+ unicom_order_all_total['cnyTotal'] = round(
|
|
|
|
+ unicom_order_all_total['cnyTotal'] + result['result']['unicomOrderAllTotal']['cnyTotal'], 2)
|
|
|
|
+ unicom_order_all_total['usdTotal'] = round(
|
|
|
|
+ unicom_order_all_total['usdTotal'] + result['result']['unicomOrderAllTotal']['usdTotal'], 2)
|
|
for item in result['result']['userIncreaseRegion']:
|
|
for item in result['result']['userIncreaseRegion']:
|
|
flag = 0
|
|
flag = 0
|
|
for each in user_increase_temp_list:
|
|
for each in user_increase_temp_list:
|