|
@@ -27,7 +27,7 @@ from Model.models import VodBucketModel, CDKcontextModel, Store_Meal, Order_Mode
|
|
|
UID_Bucket, ExperienceContextModel, Lang, CloudLogModel, UidSetModel, Unused_Uid_Meal, \
|
|
UID_Bucket, ExperienceContextModel, Lang, CloudLogModel, UidSetModel, Unused_Uid_Meal, \
|
|
|
Device_Info, DeviceTypeModel, UnicomComboOrderInfo, AiService, CountryModel, CouponLang, CouponConfigModel, \
|
|
Device_Info, DeviceTypeModel, UnicomComboOrderInfo, AiService, CountryModel, CouponLang, CouponConfigModel, \
|
|
|
CouponCombo, CouponModel, Device_User, AbnormalOrder, DailyReconciliation, StsCrdModel, LogModel, \
|
|
CouponCombo, CouponModel, Device_User, AbnormalOrder, DailyReconciliation, StsCrdModel, LogModel, \
|
|
|
- InAppPurchasePackage, InAppRefund
|
|
|
|
|
|
|
+ InAppPurchasePackage, InAppRefund, VodHlsSummary
|
|
|
from Object.AppleInAppPurchaseSubscriptionObject import InAppPurchase
|
|
from Object.AppleInAppPurchaseSubscriptionObject import InAppPurchase
|
|
|
from Object.Enums.RedisKeyConstant import RedisKeyConstant
|
|
from Object.Enums.RedisKeyConstant import RedisKeyConstant
|
|
|
from Object.RedisObject import RedisObject
|
|
from Object.RedisObject import RedisObject
|
|
@@ -36,6 +36,7 @@ from Object.TokenObject import TokenObject
|
|
|
from Object.UnicomObject import UnicomObjeect
|
|
from Object.UnicomObject import UnicomObjeect
|
|
|
from Object.utils.PayPalUtil import PayPalService
|
|
from Object.utils.PayPalUtil import PayPalService
|
|
|
from Service.CommonService import CommonService
|
|
from Service.CommonService import CommonService
|
|
|
|
|
+from Service.VodHlsService import SplitVodHlsObject
|
|
|
|
|
|
|
|
LOGGER = logging.getLogger('info')
|
|
LOGGER = logging.getLogger('info')
|
|
|
|
|
|
|
@@ -132,6 +133,8 @@ class serveManagement(View):
|
|
|
# 云存用户信息
|
|
# 云存用户信息
|
|
|
elif operation == 'getCloudUserList': # 获取云存用户信息
|
|
elif operation == 'getCloudUserList': # 获取云存用户信息
|
|
|
return self.getCloudUserList(request_dict, response)
|
|
return self.getCloudUserList(request_dict, response)
|
|
|
|
|
+ elif operation == 'getCloudStorageStatusByUid': # 获取云存用户信息
|
|
|
|
|
+ return self.get_cloud_storage_status_by_uid(request_dict, response)
|
|
|
elif operation == 'deviceAttritionAlert': # 流失预警
|
|
elif operation == 'deviceAttritionAlert': # 流失预警
|
|
|
return self.deviceAttritionAlert(request_dict, response)
|
|
return self.deviceAttritionAlert(request_dict, response)
|
|
|
elif operation == 'deactivationPackage': # 停用套餐
|
|
elif operation == 'deactivationPackage': # 停用套餐
|
|
@@ -1963,6 +1966,95 @@ class serveManagement(View):
|
|
|
print(e)
|
|
print(e)
|
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
|
|
|
|
|
+ @classmethod
|
|
|
|
|
+ def get_cloud_storage_status_by_uid(cls, request_dict, response):
|
|
|
|
|
+ """
|
|
|
|
|
+ 根据用户ID获取云存储状态
|
|
|
|
|
+ :param request_dict: 请求参数,包含用户ID和日期
|
|
|
|
|
+ :param response: 响应对象
|
|
|
|
|
+ :return: 云存储状态数据
|
|
|
|
|
+ """
|
|
|
|
|
+ # 解析请求参数
|
|
|
|
|
+ uid = request_dict.get('uid')
|
|
|
|
|
+ date_time = request_dict.get('date_time')
|
|
|
|
|
+
|
|
|
|
|
+ # 验证参数有效性
|
|
|
|
|
+ if not uid or not date_time:
|
|
|
|
|
+ return response.json(444, "缺少必要参数: uid 或 date_time")
|
|
|
|
|
+
|
|
|
|
|
+ try:
|
|
|
|
|
+ # 解析日期参数
|
|
|
|
|
+ date_obj = datetime.datetime.strptime(date_time, '%Y-%m-%d')
|
|
|
|
|
+ start_time = int(datetime.datetime(date_obj.year, date_obj.month, 1).timestamp())
|
|
|
|
|
+ end_time = int(datetime.datetime(date_obj.year, date_obj.month + 1, 1).timestamp())
|
|
|
|
|
+
|
|
|
|
|
+ # 查询云存储数据
|
|
|
|
|
+ vod_hls_summary_qs = VodHlsSummary.objects.filter(
|
|
|
|
|
+ time__gte=start_time,
|
|
|
|
|
+ time__lt=end_time
|
|
|
|
|
+ ).values('time', 'upload_duration', 'upload_frequency')
|
|
|
|
|
+
|
|
|
|
|
+ # 查询用户请求数据
|
|
|
|
|
+ sts_crd_qs = StsCrdModel.objects.filter(uid=uid).values('addTime', 'channel')
|
|
|
|
|
+
|
|
|
|
|
+ # 初始化响应数据
|
|
|
|
|
+ res_data = {
|
|
|
|
|
+ 'last_request_time': 0,
|
|
|
|
|
+ 'sts_count': 0,
|
|
|
|
|
+ 'channel': 0,
|
|
|
|
|
+ 'upload_duration': 0,
|
|
|
|
|
+ 'upload_frequency': 0,
|
|
|
|
|
+ 'time': 0,
|
|
|
|
|
+ 'cloud_video_count': 0,
|
|
|
|
|
+ 'total_duration_seconds': 0,
|
|
|
|
|
+ 'bucket_vod_location': 0
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ # 填充用户请求数据
|
|
|
|
|
+ if sts_crd_qs.exists():
|
|
|
|
|
+ sts_crd = sts_crd_qs[0]
|
|
|
|
|
+ res_data['last_request_time'] = sts_crd['addTime']
|
|
|
|
|
+ res_data['channel'] = sts_crd['channel']
|
|
|
|
|
+
|
|
|
|
|
+ # 填充云存储数据
|
|
|
|
|
+ if vod_hls_summary_qs.exists():
|
|
|
|
|
+ vod_hls_summary = vod_hls_summary_qs[0]
|
|
|
|
|
+ res_data['upload_duration'] = vod_hls_summary['upload_duration']
|
|
|
|
|
+ res_data['upload_frequency'] = vod_hls_summary['upload_frequency']
|
|
|
|
|
+ res_data['time'] = vod_hls_summary['time']
|
|
|
|
|
+
|
|
|
|
|
+ # 查询aws+oss分表数据
|
|
|
|
|
+ now_time = int(time.time())
|
|
|
|
|
+ split_vod_hls_obj = SplitVodHlsObject()
|
|
|
|
|
+ # 获取当天的开始时间戳(00:00:00)
|
|
|
|
|
+ start_timestamp = int(date_obj.timestamp())
|
|
|
|
|
+
|
|
|
|
|
+ # 获取当天的结束时间戳(23:59:59)
|
|
|
|
|
+ end_timestamp = int((date_obj + datetime.timedelta(days=1)).timestamp()) - 1
|
|
|
|
|
+ vod_hls_qs = split_vod_hls_obj.get_vod_hls_data(
|
|
|
|
|
+ uid=uid, end_time__gte=now_time, start_time__range=(start_timestamp, end_timestamp)) \
|
|
|
|
|
+ .values("id", "start_time", "sec", "fg", "bucket_id", "channel", "tab_val")
|
|
|
|
|
+
|
|
|
|
|
+ count = vod_hls_qs.count()
|
|
|
|
|
+ if count > 0:
|
|
|
|
|
+ res_data['cloud_video_count'] = count
|
|
|
|
|
+ sec_values = vod_hls_qs.values_list('sec', flat=True)
|
|
|
|
|
+ res_data['total_duration_seconds'] = sum(sec_values) if sec_values else 0
|
|
|
|
|
+
|
|
|
|
|
+ # 从Redis获取请求计数
|
|
|
|
|
+ redis_obj = RedisObject()
|
|
|
|
|
+ key = f'sts_count_{uid}'
|
|
|
|
|
+ sts_count = redis_obj.get_data(key)
|
|
|
|
|
+ if sts_count:
|
|
|
|
|
+ res_data['sts_count'] = sts_count
|
|
|
|
|
+
|
|
|
|
|
+ return response.json(0, res_data)
|
|
|
|
|
+
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ LOGGER.error(f'获取云存储状态失败 - uid: {uid}, 错误: {repr(e)}')
|
|
|
|
|
+ return response.json(500, f'服务器错误: {repr(e)}')
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
def exportCloudUserList(self, request_dict, response):
|
|
def exportCloudUserList(self, request_dict, response):
|
|
|
# UID_Bucket表查询数据
|
|
# UID_Bucket表查询数据
|
|
|
uid = request_dict.get('uid', None)
|
|
uid = request_dict.get('uid', None)
|