|
@@ -21,7 +21,7 @@ from django.http import JsonResponse, HttpResponseRedirect, HttpResponse
|
|
|
from django.views.generic.base import View
|
|
|
|
|
|
from Ansjer.config import SERVER_DOMAIN, PAYPAL_CRD, SERVER_DOMAIN_SSL, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, \
|
|
|
- AWS_ARN, OAUTH_ACCESS_TOKEN_SECRET, DETECT_PUSH_DOMAINS
|
|
|
+ AWS_ARN, OAUTH_ACCESS_TOKEN_SECRET, DETECT_PUSH_DOMAINS, CONFIG_INFO, CONFIG_CN
|
|
|
from Controller.CheckUserData import DataValid
|
|
|
from Controller.CloudPhoto.CloudServiceController import CloudServiceController
|
|
|
from Controller.PaymentCycle import Paypal
|
|
@@ -206,7 +206,7 @@ class CloudStorageView(View):
|
|
|
store_qs = store_qs.filter(~Q(pay_type='10'))
|
|
|
else:
|
|
|
store_qs = store_qs.filter(pay_type='10')
|
|
|
- if is_ai != 2: # 返回支持AI的套餐
|
|
|
+ if CONFIG_INFO != CONFIG_CN and is_ai != 2: # 返回支持AI的套餐
|
|
|
store_qs = store_qs.filter(is_ai=1)
|
|
|
else: # 返回不支持AI的套餐
|
|
|
store_qs = store_qs.filter(is_ai=0)
|
|
@@ -477,11 +477,10 @@ class CloudStorageView(View):
|
|
|
})
|
|
|
|
|
|
device_info_qs = Device_Info.objects.filter(userID_id=user_id, UID=uid, isShare=False).values(
|
|
|
- 'vodPrimaryUserID',
|
|
|
- 'vodPrimaryMaster')
|
|
|
+ 'vodPrimaryUserID', 'Type', 'vodPrimaryMaster')
|
|
|
if not device_info_qs.exists():
|
|
|
return response.json(12)
|
|
|
-
|
|
|
+ device_type = device_info_qs[0]['Type']
|
|
|
device_info_qs_time_over = int(time.time())
|
|
|
if uid == 'UWE2ZJ52SE4FX75U111A':
|
|
|
logger.info({
|
|
@@ -492,8 +491,10 @@ class CloudStorageView(View):
|
|
|
if device_info_qs[0]['vodPrimaryUserID'] != user_id:
|
|
|
return response.json(10034)
|
|
|
now_time = int(time.time())
|
|
|
- uid_bucket_qs = UID_Bucket.objects.filter(uid=uid, endTime__gte=now_time, channel=channel).values(
|
|
|
- 'bucket_id').order_by('addTime')
|
|
|
+ if device_type == 34: # 枪球设备开通云存不区分通道
|
|
|
+ uid_bucket_qs = UID_Bucket.objects.filter(uid=uid, endTime__gte=now_time)
|
|
|
+ else:
|
|
|
+ uid_bucket_qs = UID_Bucket.objects.filter(uid=uid, endTime__gte=now_time, channel=channel)
|
|
|
if not uid_bucket_qs.exists():
|
|
|
return response.json(10030)
|
|
|
|
|
@@ -682,18 +683,23 @@ class CloudStorageView(View):
|
|
|
if not all([uid, status, channel]):
|
|
|
return response.json(444, 'uid,status,channel')
|
|
|
device_info_qs = Device_Info.objects.filter(userID_id=user_id, UID=uid, isShare=False, isExist=1).values(
|
|
|
- 'vodPrimaryUserID')
|
|
|
+ 'vodPrimaryUserID', 'Type')
|
|
|
if not device_info_qs.exists() or device_info_qs[0]['vodPrimaryUserID'] != user_id:
|
|
|
return response.json(12)
|
|
|
- uid_bucket_qs = UID_Bucket.objects.filter(channel=channel, uid=uid)
|
|
|
+ device_type = device_info_qs[0]['Type']
|
|
|
+ if device_type == 34: # 枪球设备开通云存不区分通道
|
|
|
+ uid_bucket_qs = UID_Bucket.objects.filter(uid=uid)
|
|
|
+ else:
|
|
|
+ uid_bucket_qs = UID_Bucket.objects.filter(channel=channel, uid=uid)
|
|
|
if not uid_bucket_qs.exists():
|
|
|
return response.json(10030)
|
|
|
now_time = int(time.time())
|
|
|
if now_time > uid_bucket_qs[0].endTime:
|
|
|
return response.json(10031)
|
|
|
- uid_bucket_qs.update(status=status)
|
|
|
if status == 0:
|
|
|
+ uid_bucket_qs.update(status=status)
|
|
|
return response.json(0)
|
|
|
+ uid_bucket_qs.update(status=status, channel=channel)
|
|
|
uid_obj = UidTokenObject()
|
|
|
uid_obj.generate(data={'uid': uid, 'channel': channel})
|
|
|
|
|
@@ -738,10 +744,14 @@ class CloudStorageView(View):
|
|
|
'vodPrimaryUserID', 'Type')
|
|
|
if not device_info_qs.exists() or device_info_qs[0]['vodPrimaryUserID'] != user_id:
|
|
|
return response.json(12)
|
|
|
+ device_type = device_info_qs[0]['Type']
|
|
|
uid_set_qs = UidSetModel.objects.filter(uid=uid)
|
|
|
if not uid_set_qs.exists():
|
|
|
return response.json(12)
|
|
|
- uid_bucket_qs = UID_Bucket.objects.filter(channel=channel, uid=uid)
|
|
|
+ if device_type == 34: # 枪球设备开通云存不区分通道
|
|
|
+ uid_bucket_qs = UID_Bucket.objects.filter(uid=uid)
|
|
|
+ else:
|
|
|
+ uid_bucket_qs = UID_Bucket.objects.filter(channel=channel, uid=uid)
|
|
|
if not uid_bucket_qs.exists():
|
|
|
return response.json(10030)
|
|
|
now_time = int(time.time())
|
|
@@ -750,11 +760,12 @@ class CloudStorageView(View):
|
|
|
return response.json(10031)
|
|
|
try:
|
|
|
with transaction.atomic():
|
|
|
- uid_bucket_qs.update(status=vod_status)
|
|
|
if vod_status == 0:
|
|
|
+ uid_bucket_qs.update(status=vod_status)
|
|
|
ai_status = '0'
|
|
|
if uid_set_qs[0].is_ai == 2:
|
|
|
return response.json(0)
|
|
|
+ uid_bucket_qs.update(status=vod_status, channel=channel)
|
|
|
uid_obj = UidTokenObject()
|
|
|
uid_obj.generate(data={'uid': uid, 'channel': channel})
|
|
|
|
|
@@ -764,7 +775,7 @@ class CloudStorageView(View):
|
|
|
urls = 'https://api.zositeche.com/'
|
|
|
uid_tk_url = '{}cloudstorage/getsignsts?uidToken={}'.format(urls, uid_obj.token)
|
|
|
store_hls_url = '{}cloudstorage/storeplaylist?uidToken={}'.format(urls, uid_obj.token)
|
|
|
- if uid_set_qs[0].is_ai != 2:
|
|
|
+ if uid_set_qs[0].is_ai != 2 and CONFIG_INFO != CONFIG_CN:
|
|
|
if not all([appBundleId, app_type, token_val, uid, m_code, ai_status]):
|
|
|
return response.json(444, 'appBundleId, app_type, token_val, uid,m_code, ai_status')
|
|
|
|
|
@@ -921,7 +932,7 @@ class CloudStorageView(View):
|
|
|
if not store_qs.exists():
|
|
|
return response.json(173)
|
|
|
bucket_id = store_qs[0]['bucket_id']
|
|
|
- uiu_bucket_qs = UID_Bucket.objects.filter(uid=uid).values("id", "bucket_id", "bucket__storeDay",
|
|
|
+ uid_bucket_qs = UID_Bucket.objects.filter(uid=uid).values("id", "bucket_id", "bucket__storeDay",
|
|
|
"bucket__region", "endTime", "use_status")
|
|
|
expire = store_qs[0]['expire']
|
|
|
# icloud_store_meal_id = store_qs[0]['icloud_store_meal_id']
|
|
@@ -938,15 +949,17 @@ class CloudStorageView(View):
|
|
|
if promotion.exists():
|
|
|
promotion_rule_id = promotion[0]['id']
|
|
|
expire = expire * 2
|
|
|
+ unuse_meal_flag = False # 是否关联未使用套餐
|
|
|
with transaction.atomic():
|
|
|
- if uiu_bucket_qs.exists():
|
|
|
- uid_bucket = uiu_bucket_qs.first()
|
|
|
+ if uid_bucket_qs.exists():
|
|
|
+ uid_bucket = uid_bucket_qs.first()
|
|
|
if uid_bucket['use_status'] == 1 and uid_bucket['bucket_id'] == bucket_id: # 套餐使用中并且相同套餐叠加过期时间
|
|
|
end_time = CommonService.calcMonthLater(expire, uid_bucket['endTime'])
|
|
|
UID_Bucket.objects.filter(id=uid_bucket['id']).update(uid=uid, channel=channel,
|
|
|
bucket_id=bucket_id, endTime=end_time,
|
|
|
updateTime=now_time)
|
|
|
else: # 已过期或者不相同的套餐加入未使用的关联套餐表
|
|
|
+ unuse_meal_flag = True
|
|
|
unused_uid_qs = Unused_Uid_Meal.objects.filter(uid=uid, bucket_id=bucket_id)
|
|
|
nums = 2 if order_list[0]['isSelectDiscounts'] == 1 else 1
|
|
|
if promotion.exists():
|
|
@@ -982,7 +995,7 @@ class CloudStorageView(View):
|
|
|
promotion_rule_id=promotion_rule_id)
|
|
|
date_time = time.strftime("%Y-%m-%d", time.localtime())
|
|
|
# 开通AI服务
|
|
|
- if store_qs[0]['is_ai']:
|
|
|
+ if store_qs[0]['is_ai'] and CONFIG_INFO != CONFIG_CN and not unuse_meal_flag:
|
|
|
ai_service_qs = AiService.objects.filter(uid=uid, channel=channel)
|
|
|
if ai_service_qs.exists(): # 有正在使用的套餐,套餐结束时间保存为套餐有效期
|
|
|
ai_service_qs.update(endTime=end_time, use_status=1, updTime=now_time)
|
|
@@ -1128,6 +1141,7 @@ class CloudStorageView(View):
|
|
|
if promotion_rule_qs.exists():
|
|
|
promotion_rule_id = promotion_rule_qs[0]['id']
|
|
|
expire = expire * 2
|
|
|
+ unuse_meal_flag = False # 是否关联未使用套餐
|
|
|
with transaction.atomic():
|
|
|
if uid_bucket_qs.exists():
|
|
|
uid_bucket = uid_bucket_qs.first()
|
|
@@ -1137,6 +1151,7 @@ class CloudStorageView(View):
|
|
|
endTime=end_time,
|
|
|
bucket_id=bucket_id, updateTime=now_time)
|
|
|
else: # 已过期或者不相同的套餐加入未使用的关联套餐表
|
|
|
+ unuse_meal_flag = True
|
|
|
unused_uid_qs = Unused_Uid_Meal.objects.filter(uid=uid, bucket_id=bucket_id)
|
|
|
nums = 2 if order_list[0]['isSelectDiscounts'] == 1 else 1
|
|
|
if promotion_rule_qs.exists():
|
|
@@ -1171,7 +1186,7 @@ class CloudStorageView(View):
|
|
|
promotion_rule_id=promotion_rule_id)
|
|
|
date_time = time.strftime("%Y-%m-%d", time.localtime())
|
|
|
# 开通AI服务
|
|
|
- if store_qs[0]['is_ai']:
|
|
|
+ if store_qs[0]['is_ai'] and CONFIG_INFO != CONFIG_CN and not unuse_meal_flag:
|
|
|
ai_service_qs = AiService.objects.filter(uid=uid, channel=channel)
|
|
|
if ai_service_qs.exists(): # 有正在使用的套餐,套餐结束时间保存为套餐有效期
|
|
|
ai_service_qs.update(endTime=end_time, use_status=1, updTime=now_time)
|
|
@@ -1299,6 +1314,7 @@ class CloudStorageView(View):
|
|
|
if promotion_rule_qs.exists():
|
|
|
promotion_rule_id = promotion_rule_qs[0]['id']
|
|
|
expire = expire * 2
|
|
|
+ unuse_meal_flag = False # 是否关联未使用套餐
|
|
|
with transaction.atomic():
|
|
|
if uid_bucket_qs.exists():
|
|
|
uid_bucket = uid_bucket_qs.first()
|
|
@@ -1308,6 +1324,7 @@ class CloudStorageView(View):
|
|
|
bucket_id=bucket_id,
|
|
|
endTime=end_time, updateTime=now_time)
|
|
|
else: # 已过期或者不相同的套餐加入未使用的关联套餐表
|
|
|
+ unuse_meal_flag = True
|
|
|
unused_uid_qs = Unused_Uid_Meal.objects.filter(uid=uid, bucket_id=bucket_id)
|
|
|
nums = 2 if order_list[0]['isSelectDiscounts'] == 1 else 1
|
|
|
if promotion_rule_qs.exists():
|
|
@@ -1343,7 +1360,7 @@ class CloudStorageView(View):
|
|
|
promotion_rule_id=promotion_rule_id)
|
|
|
date_time = time.strftime("%Y-%m-%d", time.localtime())
|
|
|
# 开通AI服务
|
|
|
- if store_qs[0]['is_ai']:
|
|
|
+ if store_qs[0]['is_ai'] and CONFIG_INFO != CONFIG_CN and not unuse_meal_flag:
|
|
|
ai_service_qs = AiService.objects.filter(uid=uid, channel=channel)
|
|
|
if ai_service_qs.exists(): # 有正在使用的套餐,套餐结束时间保存为套餐有效期
|
|
|
ai_service_qs.update(endTime=end_time, use_status=1, updTime=now_time)
|
|
@@ -1689,7 +1706,8 @@ class CloudStorageView(View):
|
|
|
uid_bucket_qs = UID_Bucket.objects.filter(uid=uid).values("id", "bucket_id", "bucket__storeDay",
|
|
|
"bucket__region", "endTime", "use_status")
|
|
|
expire = store_qs[0]['expire']
|
|
|
- icloud_store_meal_id = store_qs[0]['icloud_store_meal_id']
|
|
|
+ unuse_meal_flag = False # 是否关联未使用套餐
|
|
|
+ # icloud_store_meal_id = store_qs[0]['icloud_store_meal_id']
|
|
|
# icloud_meal_qs = ICloudStoreMeal.objects.filter(id=icloud_store_meal_id).values('size')
|
|
|
# if not icloud_meal_qs.exists():
|
|
|
# return response.json(173)
|
|
@@ -1704,6 +1722,7 @@ class CloudStorageView(View):
|
|
|
bucket_id=bucket_id,
|
|
|
endTime=end_time, updateTime=now_time)
|
|
|
else: # 已过期或者不相同的套餐加入未使用的关联套餐表
|
|
|
+ unuse_meal_flag = True
|
|
|
unused_uid_qs = Unused_Uid_Meal.objects.filter(uid=uid, bucket_id=bucket_id)
|
|
|
nums = 1
|
|
|
if unused_uid_qs.exists():
|
|
@@ -1720,7 +1739,7 @@ class CloudStorageView(View):
|
|
|
use_status=1)
|
|
|
uid_bucket_id = uid_bucket.id
|
|
|
# 开通AI体验
|
|
|
- if store_qs[0]['is_ai']:
|
|
|
+ if store_qs[0]['is_ai'] and CONFIG_INFO != CONFIG_CN and not unuse_meal_flag:
|
|
|
order_type = 1
|
|
|
ai_service_qs = AiService.objects.filter(uid=uid, channel=channel)
|
|
|
if ai_service_qs.exists():
|