|
@@ -485,9 +485,7 @@ class CronCollectDataView(View):
|
|
end_time = CommonService.str_to_timestamp(end_time.strftime('%Y-%m-%d %H:%M:%S'))
|
|
end_time = CommonService.str_to_timestamp(end_time.strftime('%Y-%m-%d %H:%M:%S'))
|
|
order_qs = Order_Model.objects.filter(addTime__gte=start_time, addTime__lt=end_time,
|
|
order_qs = Order_Model.objects.filter(addTime__gte=start_time, addTime__lt=end_time,
|
|
status=1).values('UID', 'order_type',
|
|
status=1).values('UID', 'order_type',
|
|
- 'ai_rank', 'price',
|
|
|
|
- 'unify_combo_id',
|
|
|
|
- 'rank',
|
|
|
|
|
|
+ 'store_meal_name', 'price',
|
|
'addTime').order_by(
|
|
'addTime').order_by(
|
|
'addTime')
|
|
'addTime')
|
|
uid_list = []
|
|
uid_list = []
|
|
@@ -505,21 +503,6 @@ class CronCollectDataView(View):
|
|
device_type_dict = {}
|
|
device_type_dict = {}
|
|
for item in device_type_qs:
|
|
for item in device_type_qs:
|
|
device_type_dict[item['type']] = item['name']
|
|
device_type_dict[item['type']] = item['name']
|
|
- # 云存套餐数据
|
|
|
|
- cloud_store_meal_dict = {}
|
|
|
|
- cloud_lang_qs = Lang.objects.filter(lang='cn').values('store_meal__id', 'title', 'content')
|
|
|
|
- for item in cloud_lang_qs:
|
|
|
|
- cloud_store_meal_dict[item['store_meal__id']] = item['title'] + ':' + item['content']
|
|
|
|
- # AI套餐数据
|
|
|
|
- ai_store_meal_dict = {}
|
|
|
|
- ai_lang_qs = Lang.objects.filter(lang='cn').values('aistoremeal__id', 'title', 'content')
|
|
|
|
- for item in ai_lang_qs:
|
|
|
|
- ai_store_meal_dict[item['aistoremeal__id']] = item['title'] + ':' + item['content']
|
|
|
|
- # 4g套餐数据
|
|
|
|
- unicom_combo_store_meal_dict = {}
|
|
|
|
- unicom_combo_qs = UnicomCombo.objects.values('id', 'combo_name')
|
|
|
|
- for item in unicom_combo_qs:
|
|
|
|
- unicom_combo_store_meal_dict[item['id']] = item['combo_name']
|
|
|
|
|
|
|
|
with transaction.atomic():
|
|
with transaction.atomic():
|
|
for item in order_qs:
|
|
for item in order_qs:
|
|
@@ -532,15 +515,7 @@ class CronCollectDataView(View):
|
|
device_info_qs = Device_Info.objects.filter(UID=item['UID']).values('Type')
|
|
device_info_qs = Device_Info.objects.filter(UID=item['UID']).values('Type')
|
|
device_type_id = device_info_qs[0]['Type'] if device_info_qs.exists() else 0
|
|
device_type_id = device_info_qs[0]['Type'] if device_info_qs.exists() else 0
|
|
device_type_name = device_type_dict.get(device_type_id, '未知设备')
|
|
device_type_name = device_type_dict.get(device_type_id, '未知设备')
|
|
- if item['order_type'] == 0:
|
|
|
|
- store_meal_id = item['rank']
|
|
|
|
- store_meal_name = cloud_store_meal_dict.get(store_meal_id, '未知套餐')
|
|
|
|
- elif item['order_type'] == 1:
|
|
|
|
- store_meal_id = item['ai_rank']
|
|
|
|
- store_meal_name = ai_store_meal_dict.get(store_meal_id, '未知套餐')
|
|
|
|
- else:
|
|
|
|
- store_meal_id = item['unify_combo_id']
|
|
|
|
- store_meal_name = unicom_combo_store_meal_dict.get(store_meal_id, '未知套餐')
|
|
|
|
|
|
+ store_meal_name = item['store_meal_name']
|
|
add_time_stamp = item['addTime']
|
|
add_time_stamp = item['addTime']
|
|
add_time_str = datetime.datetime.fromtimestamp(int(add_time_stamp))
|
|
add_time_str = datetime.datetime.fromtimestamp(int(add_time_stamp))
|
|
add_time_str = datetime.datetime(add_time_str.year, add_time_str.month, add_time_str.day)
|
|
add_time_str = datetime.datetime(add_time_str.year, add_time_str.month, add_time_str.day)
|
|
@@ -679,16 +654,20 @@ class CronCollectDataView(View):
|
|
end_time = CommonService.str_to_timestamp(end_time.strftime('%Y-%m-%d %H:%M:%S'))
|
|
end_time = CommonService.str_to_timestamp(end_time.strftime('%Y-%m-%d %H:%M:%S'))
|
|
increase_device_qs = UidSetModel.objects.filter(addTime__gte=start_time, addTime__lt=end_time).values(
|
|
increase_device_qs = UidSetModel.objects.filter(addTime__gte=start_time, addTime__lt=end_time).values(
|
|
'tb_country',
|
|
'tb_country',
|
|
- 'cloud_vod',
|
|
|
|
'uid',
|
|
'uid',
|
|
- 'is_ai', 'mobile_4g',
|
|
|
|
|
|
+ 'device_type',
|
|
|
|
+ 'cloud_vod',
|
|
|
|
+ 'is_ai',
|
|
|
|
+ 'mobile_4g',
|
|
'addTime')
|
|
'addTime')
|
|
video_play_back_time_qs = VideoPlaybackTimeModel.objects.filter(startTime__gte=start_time,
|
|
video_play_back_time_qs = VideoPlaybackTimeModel.objects.filter(startTime__gte=start_time,
|
|
startTime__lt=end_time).values('uid')
|
|
startTime__lt=end_time).values('uid')
|
|
active_device_qs = UidSetModel.objects.filter(uid__in=video_play_back_time_qs).values('tb_country',
|
|
active_device_qs = UidSetModel.objects.filter(uid__in=video_play_back_time_qs).values('tb_country',
|
|
'addTime',
|
|
'addTime',
|
|
|
|
+ 'device_type',
|
|
'cloud_vod',
|
|
'cloud_vod',
|
|
- 'is_ai', 'mobile_4g',
|
|
|
|
|
|
+ 'is_ai',
|
|
|
|
+ 'mobile_4g',
|
|
'uid')
|
|
'uid')
|
|
# 国家表数据
|
|
# 国家表数据
|
|
country_qs = CountryModel.objects.values('id', 'country_name', 'region__name')
|
|
country_qs = CountryModel.objects.values('id', 'country_name', 'region__name')
|
|
@@ -705,8 +684,6 @@ class CronCollectDataView(View):
|
|
with transaction.atomic():
|
|
with transaction.atomic():
|
|
for index, each in enumerate([increase_device_qs, active_device_qs]):
|
|
for index, each in enumerate([increase_device_qs, active_device_qs]):
|
|
for item in each:
|
|
for item in each:
|
|
- device_info_qs = Device_Info.objects.filter(UID=item['uid']).values('Type')
|
|
|
|
- device_type_id = device_info_qs[0]['Type'] if device_info_qs.exists() else 0
|
|
|
|
time_stamp = item['addTime']
|
|
time_stamp = item['addTime']
|
|
time_str = datetime.datetime.fromtimestamp(int(time_stamp))
|
|
time_str = datetime.datetime.fromtimestamp(int(time_stamp))
|
|
this_day_str = datetime.datetime(time_str.year, time_str.month, time_str.day)
|
|
this_day_str = datetime.datetime(time_str.year, time_str.month, time_str.day)
|
|
@@ -714,7 +691,7 @@ class CronCollectDataView(View):
|
|
device_info_summary_qs = DeviceInfoSummary.objects.filter(time=this_day_stamp, query_type=index)
|
|
device_info_summary_qs = DeviceInfoSummary.objects.filter(time=this_day_stamp, query_type=index)
|
|
country_name = country_dict.get(item['tb_country'], '未知国家')
|
|
country_name = country_dict.get(item['tb_country'], '未知国家')
|
|
continent_name = continent_dict.get(country_name, '未知大洲')
|
|
continent_name = continent_dict.get(country_name, '未知大洲')
|
|
- device_type_name = device_type_dict.get(device_type_id, '未知设备类型')
|
|
|
|
|
|
+ device_type_name = device_type_dict.get(item['device_type'], '未知设备类型')
|
|
if device_info_summary_qs.exists():
|
|
if device_info_summary_qs.exists():
|
|
device_info_summary = device_info_summary_qs.first()
|
|
device_info_summary = device_info_summary_qs.first()
|
|
country_temp_dict = eval(device_info_summary.country)
|
|
country_temp_dict = eval(device_info_summary.country)
|