|
@@ -21,13 +21,13 @@ from django.http import JsonResponse, HttpResponseRedirect, HttpResponse
|
|
from django.views.generic.base import View
|
|
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, \
|
|
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
|
|
|
|
|
|
+ AWS_ARN, OAUTH_ACCESS_TOKEN_SECRET, DETECT_PUSH_DOMAINS, CONFIG_INFO, CONFIG_CN
|
|
from Controller.CheckUserData import DataValid
|
|
from Controller.CheckUserData import DataValid
|
|
from Controller.CloudPhoto.CloudServiceController import CloudServiceController
|
|
from Controller.CloudPhoto.CloudServiceController import CloudServiceController
|
|
from Controller.PaymentCycle import Paypal
|
|
from Controller.PaymentCycle import Paypal
|
|
from Model.models import Device_Info, Order_Model, Store_Meal, VodHlsModel, UID_Bucket, StsCrdModel, \
|
|
from Model.models import Device_Info, Order_Model, Store_Meal, VodHlsModel, UID_Bucket, StsCrdModel, \
|
|
ExperienceContextModel, Pay_Type, CDKcontextModel, Device_User, SysMsgModel, Unused_Uid_Meal, PromotionRuleModel, \
|
|
ExperienceContextModel, Pay_Type, CDKcontextModel, Device_User, SysMsgModel, Unused_Uid_Meal, PromotionRuleModel, \
|
|
- VideoPlaybackTimeModel, CouponModel, VodBucketModel, VodHlsSummary, VodHlsTagType, UidSetModel
|
|
|
|
|
|
+ VideoPlaybackTimeModel, CouponModel, VodBucketModel, VodHlsSummary, VodHlsTagType, UidSetModel, AiService
|
|
from Object.AWS.AmazonS3Util import AmazonS3Util
|
|
from Object.AWS.AmazonS3Util import AmazonS3Util
|
|
from Object.AWS.S3Email import S3Email
|
|
from Object.AWS.S3Email import S3Email
|
|
from Object.AliPayObject import AliPayObject
|
|
from Object.AliPayObject import AliPayObject
|
|
@@ -180,21 +180,21 @@ class CloudStorageView(View):
|
|
mold = request_dict.get('mold', None)
|
|
mold = request_dict.get('mold', None)
|
|
uid = request_dict.get('uid', None)
|
|
uid = request_dict.get('uid', None)
|
|
lang = request_dict.get('lang', 'en')
|
|
lang = request_dict.get('lang', 'en')
|
|
|
|
+ is_ai = request_dict.get('is_ai', 0)
|
|
if not all([uid]):
|
|
if not all([uid]):
|
|
return response.json(444)
|
|
return response.json(444)
|
|
|
|
+ is_ai = int(is_ai)
|
|
now_time = int(time.time())
|
|
now_time = int(time.time())
|
|
# DVR/NVR设备暂不返回云存套餐列表
|
|
# DVR/NVR设备暂不返回云存套餐列表
|
|
device_info_qs = Device_Info.objects.filter(Q(UID=uid), Q(Type__lte=4) | Q(Type=10001))
|
|
device_info_qs = Device_Info.objects.filter(Q(UID=uid), Q(Type__lte=4) | Q(Type=10001))
|
|
if device_info_qs.exists():
|
|
if device_info_qs.exists():
|
|
return response.json(0)
|
|
return response.json(0)
|
|
# 查询设备像素
|
|
# 查询设备像素
|
|
- uid_set_qs = UidSetModel.objects.filter(uid=uid).values('ucode')
|
|
|
|
|
|
+ uid_set_qs = UidSetModel.objects.filter(uid=uid).values('ucode', 'is_ai')
|
|
if not uid_set_qs.exists():
|
|
if not uid_set_qs.exists():
|
|
return response.json(173)
|
|
return response.json(173)
|
|
ucode = uid_set_qs[0]['ucode']
|
|
ucode = uid_set_qs[0]['ucode']
|
|
- pixel_level = 0
|
|
|
|
- if ucode and int(ucode[-5]) >= 8:
|
|
|
|
- pixel_level = 1
|
|
|
|
|
|
+ pixel_level = 1 if ucode and int(ucode[-5]) >= 8 else 0
|
|
store_qs = Store_Meal.objects.filter(Q(lang__lang=lang), Q(is_show=0), ~Q(pay_type='11')) # 过滤激活码、隐藏套餐
|
|
store_qs = Store_Meal.objects.filter(Q(lang__lang=lang), Q(is_show=0), ~Q(pay_type='11')) # 过滤激活码、隐藏套餐
|
|
experience_context_qs = ExperienceContextModel.objects.filter(uid=uid, experience_type=0)
|
|
experience_context_qs = ExperienceContextModel.objects.filter(uid=uid, experience_type=0)
|
|
|
|
|
|
@@ -203,7 +203,14 @@ class CloudStorageView(View):
|
|
|
|
|
|
# 没体验过的设备只返回体验套餐,体验过的不返回体验套餐
|
|
# 没体验过的设备只返回体验套餐,体验过的不返回体验套餐
|
|
if experience_context_qs.exists():
|
|
if experience_context_qs.exists():
|
|
- store_qs = store_qs.filter(~Q(pay_type='10'), Q(pixel_level=pixel_level)) # 筛选像素等级
|
|
|
|
|
|
+ if not is_ai: # 返回云存套餐
|
|
|
|
+ store_qs = store_qs.filter(~Q(pay_type='10'), Q(pixel_level=pixel_level), Q(is_ai=0)) # 筛选像素等级
|
|
|
|
+ else: # 返回云存+AI套餐
|
|
|
|
+ is_ai = uid_set_qs[0]['is_ai']
|
|
|
|
+ is_ai = 1 if is_ai != 2 and CONFIG_INFO != CONFIG_CN else 0 # 国内不支持AI服务
|
|
|
|
+ if not is_ai:
|
|
|
|
+ return response.json(0)
|
|
|
|
+ store_qs = store_qs.filter(~Q(pay_type='10'), Q(pixel_level=pixel_level), Q(is_ai=1)) # 筛选像素等级
|
|
else:
|
|
else:
|
|
store_qs = store_qs.filter(pay_type='10') # 体验套餐不区分像素等级
|
|
store_qs = store_qs.filter(pay_type='10') # 体验套餐不区分像素等级
|
|
|
|
|
|
@@ -777,13 +784,14 @@ class CloudStorageView(View):
|
|
channel = order_list[0]['channel']
|
|
channel = order_list[0]['channel']
|
|
rank = order_list[0]['rank']
|
|
rank = order_list[0]['rank']
|
|
|
|
|
|
- store_qs = Store_Meal.objects.filter(id=rank).values("day", "bucket_id", "bucket__storeDay", "expire")
|
|
|
|
- bucket_id = store_qs[0]['bucket_id']
|
|
|
|
|
|
+ store_qs = Store_Meal.objects.filter(id=rank).values('day', 'bucket_id', 'expire')
|
|
if not store_qs.exists():
|
|
if not store_qs.exists():
|
|
return response.json(173)
|
|
return response.json(173)
|
|
- uiu_bucket_qs = UID_Bucket.objects.filter(uid=uid).values("id", "bucket_id", "bucket__storeDay",
|
|
|
|
- "bucket__region", "endTime", "use_status")
|
|
|
|
|
|
+ bucket_id = store_qs[0]['bucket_id']
|
|
expire = store_qs[0]['expire']
|
|
expire = store_qs[0]['expire']
|
|
|
|
+ uid_bucket_qs = UID_Bucket.objects.filter(uid=uid).values("id", "bucket_id",
|
|
|
|
+ "bucket__region", "endTime", "use_status")
|
|
|
|
+
|
|
if order_list[0]['isSelectDiscounts'] == 1:
|
|
if order_list[0]['isSelectDiscounts'] == 1:
|
|
expire = store_qs[0]['expire'] * 2
|
|
expire = store_qs[0]['expire'] * 2
|
|
# 是否有促销
|
|
# 是否有促销
|
|
@@ -793,28 +801,20 @@ class CloudStorageView(View):
|
|
if promotion.exists():
|
|
if promotion.exists():
|
|
promotion_rule_id = promotion[0]['id']
|
|
promotion_rule_id = promotion[0]['id']
|
|
expire = expire * 2
|
|
expire = expire * 2
|
|
|
|
+ end_time = CommonService.calcMonthLater(expire)
|
|
with transaction.atomic():
|
|
with transaction.atomic():
|
|
- if uiu_bucket_qs.exists():
|
|
|
|
- uid_bucket = uiu_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: # 已过期或者不相同的套餐加入未使用的关联套餐表
|
|
|
|
- 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():
|
|
|
|
- nums = nums + 1
|
|
|
|
- if unused_uid_qs.exists():
|
|
|
|
- unused_uid_qs.update(num=F('num') + nums)
|
|
|
|
- else:
|
|
|
|
- Unused_Uid_Meal.objects.create(uid=uid, channel=channel, addTime=now_time, num=nums,
|
|
|
|
- expire=store_qs[0]['expire'], bucket_id=bucket_id)
|
|
|
|
- UID_Bucket.objects.filter(id=uid_bucket['id']).update(has_unused=1)
|
|
|
|
|
|
+ if uid_bucket_qs.exists():
|
|
|
|
+ uid_bucket = uid_bucket_qs.first()
|
|
uid_bucket_id = uid_bucket['id']
|
|
uid_bucket_id = uid_bucket['id']
|
|
|
|
+ if uid_bucket['use_status'] == 1 and uid_bucket['endTime'] > now_time: # 套餐使用中并且相同套餐叠加过期时间
|
|
|
|
+ Unused_Uid_Meal.objects.create(uid=uid, channel=channel, addTime=now_time, is_ai=0,
|
|
|
|
+ expire=expire, bucket_id=bucket_id, order_id=order_id)
|
|
|
|
+ UID_Bucket.objects.filter(id=uid_bucket_id).update(has_unused=1)
|
|
|
|
+ else:
|
|
|
|
+ UID_Bucket.objects.filter(id=uid_bucket_id).update(channel=channel, bucket_id=bucket_id,
|
|
|
|
+ endTime=end_time, updateTime=now_time,
|
|
|
|
+ use_status=1)
|
|
else:
|
|
else:
|
|
- end_time = CommonService.calcMonthLater(expire)
|
|
|
|
uid_bucket = UID_Bucket.objects.create(uid=uid, channel=channel, bucket_id=bucket_id,
|
|
uid_bucket = UID_Bucket.objects.create(uid=uid, channel=channel, bucket_id=bucket_id,
|
|
endTime=end_time, addTime=now_time, updateTime=now_time,
|
|
endTime=end_time, addTime=now_time, updateTime=now_time,
|
|
use_status=1)
|
|
use_status=1)
|
|
@@ -931,13 +931,14 @@ class CloudStorageView(View):
|
|
uid = order_list[0]['UID']
|
|
uid = order_list[0]['UID']
|
|
channel = order_list[0]['channel']
|
|
channel = order_list[0]['channel']
|
|
rank = order_list[0]['rank']
|
|
rank = order_list[0]['rank']
|
|
- store_qs = Store_Meal.objects.filter(id=rank).values("day", "bucket_id", "bucket__storeDay", "expire")
|
|
|
|
- bucket_id = store_qs[0]['bucket_id']
|
|
|
|
|
|
+ store_qs = Store_Meal.objects.filter(id=rank).values("day", "bucket_id", "expire", "is_ai")
|
|
if not store_qs.exists():
|
|
if not store_qs.exists():
|
|
return response.json(173)
|
|
return response.json(173)
|
|
- uid_bucket_qs = UID_Bucket.objects.filter(uid=uid).values("id", "bucket_id", "bucket__storeDay",
|
|
|
|
- "bucket__region", "endTime", "use_status")
|
|
|
|
|
|
+ bucket_id = store_qs[0]['bucket_id']
|
|
|
|
+ is_ai = store_qs[0]['is_ai']
|
|
expire = store_qs[0]['expire']
|
|
expire = store_qs[0]['expire']
|
|
|
|
+ uid_bucket_qs = UID_Bucket.objects.filter(uid=uid).values("id", "bucket_id",
|
|
|
|
+ "bucket__region", "endTime", "use_status")
|
|
|
|
|
|
if order_list[0]['isSelectDiscounts'] == 1:
|
|
if order_list[0]['isSelectDiscounts'] == 1:
|
|
expire = store_qs[0]['expire'] * 2
|
|
expire = store_qs[0]['expire'] * 2
|
|
@@ -948,28 +949,22 @@ class CloudStorageView(View):
|
|
if promotion_rule_qs.exists():
|
|
if promotion_rule_qs.exists():
|
|
promotion_rule_id = promotion_rule_qs[0]['id']
|
|
promotion_rule_id = promotion_rule_qs[0]['id']
|
|
expire = expire * 2
|
|
expire = expire * 2
|
|
|
|
+ end_time = CommonService.calcMonthLater(expire)
|
|
|
|
+ use_flag = True
|
|
with transaction.atomic():
|
|
with transaction.atomic():
|
|
if uid_bucket_qs.exists():
|
|
if uid_bucket_qs.exists():
|
|
uid_bucket = uid_bucket_qs.first()
|
|
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,
|
|
|
|
- endTime=end_time,
|
|
|
|
- bucket_id=bucket_id, updateTime=now_time)
|
|
|
|
- else: # 已过期或者不相同的套餐加入未使用的关联套餐表
|
|
|
|
- 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():
|
|
|
|
- nums = nums + 1
|
|
|
|
- if unused_uid_qs.exists():
|
|
|
|
- unused_uid_qs.update(num=F('num') + nums)
|
|
|
|
- else:
|
|
|
|
- Unused_Uid_Meal.objects.create(uid=uid, channel=channel, addTime=now_time, num=nums,
|
|
|
|
- expire=store_qs[0]['expire'], bucket_id=bucket_id)
|
|
|
|
- UID_Bucket.objects.filter(id=uid_bucket['id']).update(has_unused=1)
|
|
|
|
uid_bucket_id = uid_bucket['id']
|
|
uid_bucket_id = uid_bucket['id']
|
|
|
|
+ if uid_bucket['use_status'] == 1 and uid_bucket['endTime'] > now_time: # 套餐使用中并且相同套餐叠加过期时间
|
|
|
|
+ Unused_Uid_Meal.objects.create(uid=uid, channel=channel, addTime=now_time, order_id=order_id,
|
|
|
|
+ expire=expire, is_ai=is_ai, bucket_id=bucket_id)
|
|
|
|
+ UID_Bucket.objects.filter(id=uid_bucket_id).update(has_unused=1)
|
|
|
|
+ use_flag = False
|
|
|
|
+ else:
|
|
|
|
+ UID_Bucket.objects.filter(id=uid_bucket_id).update(channel=channel, bucket_id=bucket_id,
|
|
|
|
+ endTime=end_time, updateTime=now_time,
|
|
|
|
+ use_status=1)
|
|
else:
|
|
else:
|
|
- end_time = CommonService.calcMonthLater(expire)
|
|
|
|
uid_bucket = UID_Bucket.objects.create(uid=uid, channel=channel, bucket_id=bucket_id,
|
|
uid_bucket = UID_Bucket.objects.create(uid=uid, channel=channel, bucket_id=bucket_id,
|
|
endTime=end_time, addTime=now_time, updateTime=now_time,
|
|
endTime=end_time, addTime=now_time, updateTime=now_time,
|
|
use_status=1)
|
|
use_status=1)
|
|
@@ -990,6 +985,14 @@ class CloudStorageView(View):
|
|
order_qs.update(status=1, updTime=now_time, uid_bucket_id=uid_bucket_id,
|
|
order_qs.update(status=1, updTime=now_time, uid_bucket_id=uid_bucket_id,
|
|
promotion_rule_id=promotion_rule_id)
|
|
promotion_rule_id=promotion_rule_id)
|
|
date_time = time.strftime("%Y-%m-%d", time.localtime())
|
|
date_time = time.strftime("%Y-%m-%d", time.localtime())
|
|
|
|
+ # 开通AI服务
|
|
|
|
+ if is_ai and use_flag:
|
|
|
|
+ ai_service = AiService.objects.filter(uid=uid, channel=channel)
|
|
|
|
+ if ai_service.exists(): # 有正在使用的套餐,套餐结束时间保存为套餐有效期
|
|
|
|
+ ai_service.update(updTime=now_time, use_status=1, orders_id=order_id, endTime=end_time)
|
|
|
|
+ else:
|
|
|
|
+ AiService.objects.create(uid=uid, channel=channel, detect_status=1, addTime=now_time,
|
|
|
|
+ updTime=now_time, endTime=end_time, use_status=1, orders_id=order_id)
|
|
# 如果存在序列号,消息提示用序列号
|
|
# 如果存在序列号,消息提示用序列号
|
|
device_info_qs = Device_Info.objects.filter(UID=uid).values('serial_number', 'Type')
|
|
device_info_qs = Device_Info.objects.filter(UID=uid).values('serial_number', 'Type')
|
|
serial_number = device_info_qs[0]['serial_number']
|
|
serial_number = device_info_qs[0]['serial_number']
|
|
@@ -1024,7 +1027,7 @@ class CloudStorageView(View):
|
|
|
|
|
|
def do_pay_by_wechat_callback(self, request, response): # 微信支付回调
|
|
def do_pay_by_wechat_callback(self, request, response): # 微信支付回调
|
|
"""
|
|
"""
|
|
- 查询套餐列表
|
|
|
|
|
|
+ 微信支付回调
|
|
@param request: 请求体
|
|
@param request: 请求体
|
|
@request_dict result_code: 业务结果
|
|
@request_dict result_code: 业务结果
|
|
@request_dict out_trade_no: 商户订单号
|
|
@request_dict out_trade_no: 商户订单号
|
|
@@ -1067,13 +1070,13 @@ class CloudStorageView(View):
|
|
uid = order_list[0]['UID']
|
|
uid = order_list[0]['UID']
|
|
channel = order_list[0]['channel']
|
|
channel = order_list[0]['channel']
|
|
rank = order_list[0]['rank']
|
|
rank = order_list[0]['rank']
|
|
- store_qs = Store_Meal.objects.filter(id=rank).values("day", "bucket_id", "bucket__storeDay", "expire")
|
|
|
|
- bucket_id = store_qs[0]['bucket_id']
|
|
|
|
|
|
+ store_qs = Store_Meal.objects.filter(id=rank).values("day", "bucket_id", "expire")
|
|
if not store_qs.exists():
|
|
if not store_qs.exists():
|
|
return HttpResponse(pay.xml_to_dict({'return_code': 'FAIL', 'return_msg': '套餐不存在'}))
|
|
return HttpResponse(pay.xml_to_dict({'return_code': 'FAIL', 'return_msg': '套餐不存在'}))
|
|
- uid_bucket_qs = UID_Bucket.objects.filter(uid=uid).values("id", "bucket_id", "bucket__storeDay",
|
|
|
|
- "bucket__region", "endTime", "use_status")
|
|
|
|
|
|
+ bucket_id = store_qs[0]['bucket_id']
|
|
expire = store_qs[0]['expire']
|
|
expire = store_qs[0]['expire']
|
|
|
|
+ uid_bucket_qs = UID_Bucket.objects.filter(uid=uid).values("id", "bucket_id",
|
|
|
|
+ "bucket__region", "endTime", "use_status")
|
|
if order_list[0]['isSelectDiscounts'] == 1:
|
|
if order_list[0]['isSelectDiscounts'] == 1:
|
|
expire = store_qs[0]['expire'] * 2
|
|
expire = store_qs[0]['expire'] * 2
|
|
# 是否有促销
|
|
# 是否有促销
|
|
@@ -1083,28 +1086,20 @@ class CloudStorageView(View):
|
|
if promotion_rule_qs.exists():
|
|
if promotion_rule_qs.exists():
|
|
promotion_rule_id = promotion_rule_qs[0]['id']
|
|
promotion_rule_id = promotion_rule_qs[0]['id']
|
|
expire = expire * 2
|
|
expire = expire * 2
|
|
|
|
+ end_time = CommonService.calcMonthLater(expire)
|
|
with transaction.atomic():
|
|
with transaction.atomic():
|
|
if uid_bucket_qs.exists():
|
|
if uid_bucket_qs.exists():
|
|
uid_bucket = uid_bucket_qs.first()
|
|
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: # 已过期或者不相同的套餐加入未使用的关联套餐表
|
|
|
|
- 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():
|
|
|
|
- nums = nums + 1
|
|
|
|
- if unused_uid_qs.exists():
|
|
|
|
- unused_uid_qs.update(num=F('num') + nums)
|
|
|
|
- else:
|
|
|
|
- Unused_Uid_Meal.objects.create(uid=uid, channel=channel, addTime=now_time, num=nums,
|
|
|
|
- expire=store_qs[0]['expire'], bucket_id=bucket_id)
|
|
|
|
- UID_Bucket.objects.filter(id=uid_bucket['id']).update(has_unused=1)
|
|
|
|
uid_bucket_id = uid_bucket['id']
|
|
uid_bucket_id = uid_bucket['id']
|
|
|
|
+ if uid_bucket['use_status'] == 1 and uid_bucket['endTime'] > now_time: # 套餐使用中并且相同套餐叠加过期时间
|
|
|
|
+ Unused_Uid_Meal.objects.create(uid=uid, channel=channel, addTime=now_time, is_ai=0,
|
|
|
|
+ expire=expire, bucket_id=bucket_id, order_id=order_id)
|
|
|
|
+ UID_Bucket.objects.filter(id=uid_bucket['id']).update(has_unused=1)
|
|
|
|
+ else:
|
|
|
|
+ UID_Bucket.objects.filter(id=uid_bucket_id).update(channel=channel, bucket_id=bucket_id,
|
|
|
|
+ endTime=end_time, updateTime=now_time,
|
|
|
|
+ use_status=1)
|
|
else:
|
|
else:
|
|
- end_time = CommonService.calcMonthLater(expire)
|
|
|
|
uid_bucket = UID_Bucket.objects.create(uid=uid, channel=channel, bucket_id=bucket_id,
|
|
uid_bucket = UID_Bucket.objects.create(uid=uid, channel=channel, bucket_id=bucket_id,
|
|
endTime=end_time, addTime=now_time,
|
|
endTime=end_time, addTime=now_time,
|
|
updateTime=now_time, use_status=1)
|
|
updateTime=now_time, use_status=1)
|
|
@@ -1253,12 +1248,13 @@ class CloudStorageView(View):
|
|
return response.json(10048)
|
|
return response.json(10048)
|
|
Order_Model.objects.create(orderID=order_id, UID=uid, channel=channel, userID_id=user_id,
|
|
Order_Model.objects.create(orderID=order_id, UID=uid, channel=channel, userID_id=user_id,
|
|
desc=content, payType=pay_type, payTime=now_time,
|
|
desc=content, payType=pay_type, payTime=now_time,
|
|
- price=price, currency=currency, addTime=now_time, updTime=now_time,
|
|
|
|
|
|
+ price=price, currency=currency, addTime=now_time,
|
|
|
|
+ updTime=now_time,
|
|
pay_url=sub_info['url'], isSelectDiscounts=is_select_discount,
|
|
pay_url=sub_info['url'], isSelectDiscounts=is_select_discount,
|
|
commodity_code=commodity_code, commodity_type=commodity_type,
|
|
commodity_code=commodity_code, commodity_type=commodity_type,
|
|
- rank_id=rank, plan_id=sub_info['plan_id'], coupon_id=coupon_id, ai_rank_id=1,
|
|
|
|
|
|
+ rank_id=rank, plan_id=sub_info['plan_id'], coupon_id=coupon_id,
|
|
|
|
+ ai_rank_id=1,
|
|
store_meal_name=store_meal_name)
|
|
store_meal_name=store_meal_name)
|
|
-
|
|
|
|
return response.json(0, {"redirectUrl": sub_info['url'], "orderID": order_id})
|
|
return response.json(0, {"redirectUrl": sub_info['url'], "orderID": order_id})
|
|
# 正常扣款
|
|
# 正常扣款
|
|
call_clc_url = "{}web/paid2/fail.html".format(SERVER_DOMAIN_SSL)
|
|
call_clc_url = "{}web/paid2/fail.html".format(SERVER_DOMAIN_SSL)
|
|
@@ -1287,10 +1283,12 @@ class CloudStorageView(View):
|
|
approval_url = str(link.href)
|
|
approval_url = str(link.href)
|
|
Order_Model.objects.create(orderID=order_id, UID=uid, channel=channel, userID_id=user_id,
|
|
Order_Model.objects.create(orderID=order_id, UID=uid, channel=channel, userID_id=user_id,
|
|
desc=content, payType=pay_type, payTime=now_time,
|
|
desc=content, payType=pay_type, payTime=now_time,
|
|
- price=price, currency=currency, addTime=now_time, updTime=now_time,
|
|
|
|
|
|
+ price=price, currency=currency, addTime=now_time,
|
|
|
|
+ updTime=now_time,
|
|
pay_url=approval_url, isSelectDiscounts=is_select_discount,
|
|
pay_url=approval_url, isSelectDiscounts=is_select_discount,
|
|
commodity_code=commodity_code, commodity_type=commodity_type,
|
|
commodity_code=commodity_code, commodity_type=commodity_type,
|
|
- rank_id=rank, paymentID=payment_id, coupon_id=coupon_id, ai_rank_id=1,
|
|
|
|
|
|
+ rank_id=rank, paymentID=payment_id, coupon_id=coupon_id,
|
|
|
|
+ ai_rank_id=1,
|
|
store_meal_name=store_meal_name)
|
|
store_meal_name=store_meal_name)
|
|
return response.json(0, {"redirectUrl": approval_url, "orderID": order_id})
|
|
return response.json(0, {"redirectUrl": approval_url, "orderID": order_id})
|
|
return response.json(10, 'generate_order_false')
|
|
return response.json(10, 'generate_order_false')
|
|
@@ -1317,7 +1315,8 @@ class CloudStorageView(View):
|
|
redirect_url = ali_pay_obj.alipay_prefix + order_string
|
|
redirect_url = ali_pay_obj.alipay_prefix + order_string
|
|
Order_Model.objects.create(orderID=order_id, UID=uid, channel=channel, userID_id=user_id,
|
|
Order_Model.objects.create(orderID=order_id, UID=uid, channel=channel, userID_id=user_id,
|
|
desc=content, payType=pay_type, payTime=now_time,
|
|
desc=content, payType=pay_type, payTime=now_time,
|
|
- price=price, currency=currency, addTime=now_time, updTime=now_time,
|
|
|
|
|
|
+ price=price, currency=currency, addTime=now_time,
|
|
|
|
+ updTime=now_time,
|
|
pay_url=redirect_url, isSelectDiscounts=is_select_discount,
|
|
pay_url=redirect_url, isSelectDiscounts=is_select_discount,
|
|
commodity_code=commodity_code, commodity_type=commodity_type,
|
|
commodity_code=commodity_code, commodity_type=commodity_type,
|
|
rank_id=rank, coupon_id=coupon_id, ai_rank_id=1,
|
|
rank_id=rank, coupon_id=coupon_id, ai_rank_id=1,
|
|
@@ -1347,7 +1346,8 @@ class CloudStorageView(View):
|
|
desc=content, payType=pay_type, payTime=now_time,
|
|
desc=content, payType=pay_type, payTime=now_time,
|
|
price=price, currency=currency, addTime=now_time, updTime=now_time,
|
|
price=price, currency=currency, addTime=now_time, updTime=now_time,
|
|
pay_url=notify_url, isSelectDiscounts=is_select_discount,
|
|
pay_url=notify_url, isSelectDiscounts=is_select_discount,
|
|
- commodity_code=commodity_code, commodity_type=commodity_type, rank_id=rank,
|
|
|
|
|
|
+ commodity_code=commodity_code, commodity_type=commodity_type,
|
|
|
|
+ rank_id=rank,
|
|
ai_rank_id=1, store_meal_name=store_meal_name)
|
|
ai_rank_id=1, store_meal_name=store_meal_name)
|
|
return JsonResponse(status=200, data={'result_code': 0, 'reason': 'success',
|
|
return JsonResponse(status=200, data={'result_code': 0, 'reason': 'success',
|
|
'result': response,
|
|
'result': response,
|
|
@@ -1422,36 +1422,36 @@ class CloudStorageView(View):
|
|
order_id = CommonService.createOrderID()
|
|
order_id = CommonService.createOrderID()
|
|
now_time = int(time.time())
|
|
now_time = int(time.time())
|
|
store_qs = Store_Meal.objects.filter(id=rank, lang__lang=lang, is_show=0).values("day", "bucket_id",
|
|
store_qs = Store_Meal.objects.filter(id=rank, lang__lang=lang, is_show=0).values("day", "bucket_id",
|
|
- "bucket__storeDay", "expire",
|
|
|
|
|
|
+ "expire",
|
|
'lang__content', 'price',
|
|
'lang__content', 'price',
|
|
'currency', 'commodity_type')
|
|
'currency', 'commodity_type')
|
|
if not store_qs.exists():
|
|
if not store_qs.exists():
|
|
return response.json(173)
|
|
return response.json(173)
|
|
bucket_id = store_qs[0]['bucket_id']
|
|
bucket_id = store_qs[0]['bucket_id']
|
|
- uid_bucket_qs = UID_Bucket.objects.filter(uid=uid).values("id", "bucket_id", "bucket__storeDay",
|
|
|
|
- "bucket__region", "endTime", "use_status")
|
|
|
|
|
|
+ uid_bucket_qs = UID_Bucket.objects.filter(uid=uid).values("id", "bucket_id", "bucket__region",
|
|
|
|
+ "endTime", "use_status")
|
|
expire = store_qs[0]['expire']
|
|
expire = store_qs[0]['expire']
|
|
|
|
+ uid_set_qs = UidSetModel.objects.filter(uid=uid, channel=channel).values('is_ai')
|
|
|
|
+ if not uid_set_qs.exists():
|
|
|
|
+ return response.json(173)
|
|
|
|
+ is_ai = 1 if uid_set_qs[0]['is_ai'] != 2 else 0
|
|
|
|
+ use_flag = True
|
|
|
|
+ end_time = CommonService.calcMonthLater(expire)
|
|
try:
|
|
try:
|
|
with transaction.atomic():
|
|
with transaction.atomic():
|
|
if uid_bucket_qs.exists():
|
|
if uid_bucket_qs.exists():
|
|
uid_bucket = uid_bucket_qs.first()
|
|
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: # 已过期或者不相同的套餐加入未使用的关联套餐表
|
|
|
|
- unused_uid_qs = Unused_Uid_Meal.objects.filter(uid=uid, bucket_id=bucket_id)
|
|
|
|
- nums = 1
|
|
|
|
- if unused_uid_qs.exists():
|
|
|
|
- unused_uid_qs.update(num=F('num') + nums)
|
|
|
|
- else:
|
|
|
|
- Unused_Uid_Meal.objects.create(uid=uid, channel=channel, addTime=now_time, num=nums,
|
|
|
|
- expire=store_qs[0]['expire'], bucket_id=bucket_id)
|
|
|
|
- UID_Bucket.objects.filter(id=uid_bucket['id']).update(has_unused=1)
|
|
|
|
uid_bucket_id = uid_bucket['id']
|
|
uid_bucket_id = uid_bucket['id']
|
|
|
|
+ if uid_bucket['use_status'] == 1 and uid_bucket['endTime'] > now_time:
|
|
|
|
+ Unused_Uid_Meal.objects.create(uid=uid, channel=channel, addTime=now_time, is_ai=is_ai,
|
|
|
|
+ order_id=order_id, expire=expire, bucket_id=bucket_id)
|
|
|
|
+ UID_Bucket.objects.filter(id=uid_bucket_id).update(has_unused=1)
|
|
|
|
+ use_flag = False
|
|
|
|
+ else:
|
|
|
|
+ UID_Bucket.objects.filter(id=uid_bucket_id).update(channel=channel, bucket_id=bucket_id,
|
|
|
|
+ endTime=end_time, updateTime=now_time,
|
|
|
|
+ use_status=1)
|
|
else:
|
|
else:
|
|
- end_time = CommonService.calcMonthLater(expire)
|
|
|
|
uid_bucket = UID_Bucket.objects.create(uid=uid, channel=channel, bucket_id=bucket_id,
|
|
uid_bucket = UID_Bucket.objects.create(uid=uid, channel=channel, bucket_id=bucket_id,
|
|
endTime=end_time, addTime=now_time, updateTime=now_time,
|
|
endTime=end_time, addTime=now_time, updateTime=now_time,
|
|
use_status=1)
|
|
use_status=1)
|
|
@@ -1470,6 +1470,14 @@ class CloudStorageView(View):
|
|
pay_url="体验版", store_meal_name=store_meal_name,
|
|
pay_url="体验版", store_meal_name=store_meal_name,
|
|
commodity_code=commodity_code, commodity_type=store_qs[0]['commodity_type'],
|
|
commodity_code=commodity_code, commodity_type=store_qs[0]['commodity_type'],
|
|
rank_id=rank, status=1, uid_bucket_id=uid_bucket_id, ai_rank_id=1)
|
|
rank_id=rank, status=1, uid_bucket_id=uid_bucket_id, ai_rank_id=1)
|
|
|
|
+ # 开通AI服务,国内不支持AI
|
|
|
|
+ if is_ai and use_flag and CONFIG_INFO != CONFIG_CN:
|
|
|
|
+ ai_service = AiService.objects.filter(uid=uid, channel=channel)
|
|
|
|
+ if ai_service.exists(): # 有正在使用的套餐,套餐结束时间保存为套餐有效期
|
|
|
|
+ ai_service.update(updTime=now_time, use_status=1, orders_id=order_id, endTime=end_time)
|
|
|
|
+ else:
|
|
|
|
+ AiService.objects.create(uid=uid, channel=channel, detect_status=1, addTime=now_time,
|
|
|
|
+ updTime=now_time, endTime=end_time, use_status=1, orders_id=order_id)
|
|
|
|
|
|
device_user_qs = Device_User.objects.filter(userID=user_id).values('username')
|
|
device_user_qs = Device_User.objects.filter(userID=user_id).values('username')
|
|
device_info_qs = Device_Info.objects.filter(UID=uid, vodPrimaryUserID='', vodPrimaryMaster='')
|
|
device_info_qs = Device_Info.objects.filter(UID=uid, vodPrimaryUserID='', vodPrimaryMaster='')
|
|
@@ -1638,12 +1646,11 @@ class CloudStorageView(View):
|
|
unused_uid_qs = Unused_Uid_Meal.objects.filter(uid=uid).annotate(unused_id=F('id')).values("unused_id",
|
|
unused_uid_qs = Unused_Uid_Meal.objects.filter(uid=uid).annotate(unused_id=F('id')).values("unused_id",
|
|
"uid",
|
|
"uid",
|
|
"bucket__content",
|
|
"bucket__content",
|
|
- "num",
|
|
|
|
"bucket__id",
|
|
"bucket__id",
|
|
"expire")
|
|
"expire")
|
|
month = 'month' if lang != 'cn' else '个月'
|
|
month = 'month' if lang != 'cn' else '个月'
|
|
for unused_uid in unused_uid_qs:
|
|
for unused_uid in unused_uid_qs:
|
|
- storage_time = unused_uid['num'] * unused_uid['expire']
|
|
|
|
|
|
+ storage_time = unused_uid['expire']
|
|
if lang != 'cn' and storage_time > 1: # 英文大于一个月使用复数
|
|
if lang != 'cn' and storage_time > 1: # 英文大于一个月使用复数
|
|
month += 's'
|
|
month += 's'
|
|
storage = str(storage_time) + month
|
|
storage = str(storage_time) + month
|
|
@@ -1691,7 +1698,8 @@ class CloudStorageView(View):
|
|
using_uid_bucket_qs = UID_Bucket.objects.filter(uid=uid, has_unused=1).values("id", "uid", "endTime",
|
|
using_uid_bucket_qs = UID_Bucket.objects.filter(uid=uid, has_unused=1).values("id", "uid", "endTime",
|
|
"bucket__content", "addTime")
|
|
"bucket__content", "addTime")
|
|
unused_uid_bucket_qs = Unused_Uid_Meal.objects.filter(id=unused_id).values("id", "uid", "channel", "addTime",
|
|
unused_uid_bucket_qs = Unused_Uid_Meal.objects.filter(id=unused_id).values("id", "uid", "channel", "addTime",
|
|
- "expire", "num", "bucket_id")
|
|
|
|
|
|
+ "expire", "is_ai", "bucket_id",
|
|
|
|
+ "order_id")
|
|
if not unused_uid_bucket_qs.exists() or not using_uid_bucket_qs.exists():
|
|
if not unused_uid_bucket_qs.exists() or not using_uid_bucket_qs.exists():
|
|
return response.json(10030)
|
|
return response.json(10030)
|
|
unused_uid_bucket = unused_uid_bucket_qs.first()
|
|
unused_uid_bucket = unused_uid_bucket_qs.first()
|
|
@@ -1700,11 +1708,21 @@ class CloudStorageView(View):
|
|
with transaction.atomic():
|
|
with transaction.atomic():
|
|
count_unused = Unused_Uid_Meal.objects.filter(uid=uid).count()
|
|
count_unused = Unused_Uid_Meal.objects.filter(uid=uid).count()
|
|
has_unused = 1 if count_unused > 1 else 0
|
|
has_unused = 1 if count_unused > 1 else 0
|
|
- end_time = CommonService.calcMonthLater(unused_uid_bucket['expire'] * unused_uid_bucket['num'])
|
|
|
|
|
|
+ end_time = CommonService.calcMonthLater(unused_uid_bucket['expire'])
|
|
UID_Bucket.objects.filter(uid=uid).update(channel=unused_uid_bucket['channel'], endTime=end_time,
|
|
UID_Bucket.objects.filter(uid=uid).update(channel=unused_uid_bucket['channel'], endTime=end_time,
|
|
bucket_id=unused_uid_bucket['bucket_id']
|
|
bucket_id=unused_uid_bucket['bucket_id']
|
|
, updateTime=now_time, use_status=1,
|
|
, updateTime=now_time, use_status=1,
|
|
has_unused=has_unused)
|
|
has_unused=has_unused)
|
|
|
|
+ # 开通AI服务
|
|
|
|
+ if unused_uid_bucket['is_ai']:
|
|
|
|
+ ai_service = AiService.objects.filter(uid=uid, channel=unused_uid_bucket['channel'])
|
|
|
|
+ if ai_service.exists(): # 有正在使用的套餐,套餐结束时间保存为套餐有效期
|
|
|
|
+ ai_service.update(updTime=now_time, use_status=1, orders_id=unused_uid_bucket['order_id'],
|
|
|
|
+ endTime=end_time)
|
|
|
|
+ else:
|
|
|
|
+ AiService.objects.create(uid=uid, channel=unused_uid_bucket['channel'], detect_status=1,
|
|
|
|
+ addTime=now_time, updTime=now_time, endTime=end_time, use_status=1,
|
|
|
|
+ orders_id=unused_uid_bucket['order_id'])
|
|
Unused_Uid_Meal.objects.filter(id=unused_id).delete()
|
|
Unused_Uid_Meal.objects.filter(id=unused_id).delete()
|
|
StsCrdModel.objects.filter(uid=uid).delete() # 删除sts记录
|
|
StsCrdModel.objects.filter(uid=uid).delete() # 删除sts记录
|
|
# VodHlsModel.objects.filter(uid=uid).delete() # 删除播放列表,后期数据量多时应该考虑延后删除
|
|
# VodHlsModel.objects.filter(uid=uid).delete() # 删除播放列表,后期数据量多时应该考虑延后删除
|