|
@@ -21,17 +21,19 @@ 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
|
|
|
+ AWS_ARN, OAUTH_ACCESS_TOKEN_SECRET, DETECT_PUSH_DOMAINS
|
|
|
from Controller.CheckUserData import DataValid
|
|
|
from Controller.CloudPhoto.CloudServiceController import CloudServiceController
|
|
|
from Controller.PaymentCycle import Paypal
|
|
|
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, \
|
|
|
- VideoPlaybackTimeModel, CouponModel, VodBucketModel, VodHlsSummary, VodHlsTagType
|
|
|
+ VideoPlaybackTimeModel, CouponModel, VodBucketModel, VodHlsSummary, AiService, UidSetModel, UidPushModel, \
|
|
|
+ VodHlsTagType
|
|
|
from Object.AWS.AmazonS3Util import AmazonS3Util
|
|
|
from Object.AWS.S3Email import S3Email
|
|
|
from Object.AliPayObject import AliPayObject
|
|
|
from Object.AliSmsObject import AliSmsObject
|
|
|
+from Object.ETkObject import ETkObject
|
|
|
from Object.RedisObject import RedisObject
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
@@ -96,6 +98,8 @@ class CloudStorageView(View):
|
|
|
return self.do_create_pay_order(request_dict, user_id, ip, response)
|
|
|
elif operation == 'changevodstatus': # 修改云存状态,传送两个url,即getsignsts接口和storeplaylist接口
|
|
|
return self.do_change_vod_status(request_dict, user_id, response)
|
|
|
+ elif operation == 'changevodaistatus': # 修改云存AI状态
|
|
|
+ return self.do_change_vod_ai_status(request_dict, user_id, response)
|
|
|
elif operation == 'queryvodlist': # 获取视频播放列表
|
|
|
return self.do_query_vod_list(request_dict, user_id, response)
|
|
|
elif operation == 'commoditylist': # 查询套餐列表
|
|
@@ -187,7 +191,10 @@ class CloudStorageView(View):
|
|
|
device_info_qs = Device_Info.objects.filter(Q(UID=uid), Q(Type__lte=4) | Q(Type=10001))
|
|
|
if device_info_qs.exists():
|
|
|
return response.json(0)
|
|
|
-
|
|
|
+ uid_set_qs = UidSetModel.objects.filter(uid=uid).values('is_ai')
|
|
|
+ if not uid_set_qs.exists():
|
|
|
+ return response.json(173)
|
|
|
+ is_ai = uid_set_qs[0]['is_ai']
|
|
|
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)
|
|
|
|
|
@@ -199,11 +206,15 @@ 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的套餐
|
|
|
+ store_qs = store_qs.filter(is_ai=1)
|
|
|
+ else: # 返回不支持AI的套餐
|
|
|
+ store_qs = store_qs.filter(is_ai=0)
|
|
|
|
|
|
store_qs = store_qs.annotate(title=F('lang__title'), content=F('lang__content'),
|
|
|
discount_content=F('lang__discount_content'))
|
|
|
store_qs = store_qs.order_by('sort').values("id", "title", "content", "price", "day", "currency",
|
|
|
- "bucket__storeDay",
|
|
|
+ "bucket__storeDay", 'is_beta', 'is_ai',
|
|
|
"bucket__bucket", "bucket__area", "commodity_code",
|
|
|
"commodity_type", "is_discounts", "virtual_price", "expire",
|
|
|
"discount_price", "discount_content", "symbol", "cycle_config_id")
|
|
@@ -402,7 +413,7 @@ class CloudStorageView(View):
|
|
|
"Effect": "Allow",
|
|
|
"Action": "s3:*",
|
|
|
"Resource": ["{aws_arn}:::{bucket_name}/{uid_channel}*".
|
|
|
- format(aws_arn=aws_arn, bucket_name=bucket_name, uid_channel=storage)]
|
|
|
+ format(aws_arn=aws_arn, bucket_name=bucket_name, uid_channel=storage)]
|
|
|
}
|
|
|
]
|
|
|
}
|
|
@@ -694,6 +705,151 @@ class CloudStorageView(View):
|
|
|
store_hls_url = '{}cloudstorage/storeplaylist?uidToken={}'.format(urls, uid_obj.token)
|
|
|
return response.json(0, {'uidTkUrl': uid_tk_url, 'storeHlsUrl': store_hls_url})
|
|
|
|
|
|
+ @staticmethod
|
|
|
+ def do_change_vod_ai_status(request_dict, user_id, response): # 修改云存状态
|
|
|
+ """
|
|
|
+ 修改云存状态
|
|
|
+ @param request_dict: 请求数据
|
|
|
+ @param user_id: 用户id
|
|
|
+ @request_dict uid: uid
|
|
|
+ @request_dict status: 套餐状态
|
|
|
+ @request_dict channel: 通道
|
|
|
+ @param response: 响应
|
|
|
+ @return: response
|
|
|
+ """
|
|
|
+ uid = request_dict.get('uid', None)
|
|
|
+ vod_status = request_dict.get('vod_status', None)
|
|
|
+ channel = request_dict.get('channel', None)
|
|
|
+ domain_name = request_dict.get('domain_name', None)
|
|
|
+ token_val = request_dict.get('token_val', None)
|
|
|
+ appBundleId = request_dict.get('appBundleId', None)
|
|
|
+ app_type = request_dict.get('app_type', None)
|
|
|
+ push_type = request_dict.get('push_type', None)
|
|
|
+ ai_status = request_dict.get('ai_status', None)
|
|
|
+ m_code = request_dict.get('m_code', None)
|
|
|
+ lang = request_dict.get('lang', 'en')
|
|
|
+ tz = request_dict.get('tz', '0')
|
|
|
+ detect_group = request_dict.get('detect_group', None)
|
|
|
+ interval = request_dict.get('interval', None)
|
|
|
+ if not all([uid, vod_status, channel]):
|
|
|
+ return response.json(444, 'uid,vod_status,channel')
|
|
|
+ vod_status = int(vod_status)
|
|
|
+ device_info_qs = Device_Info.objects.filter(userID_id=user_id, UID=uid, isShare=False, isExist=1).values(
|
|
|
+ 'vodPrimaryUserID', 'Type')
|
|
|
+ if not device_info_qs.exists() or device_info_qs[0]['vodPrimaryUserID'] != user_id:
|
|
|
+ return response.json(12)
|
|
|
+ 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 not uid_bucket_qs.exists():
|
|
|
+ return response.json(10030)
|
|
|
+ now_time = int(time.time())
|
|
|
+ end_time = uid_bucket_qs[0].endTime
|
|
|
+ if now_time > end_time:
|
|
|
+ return response.json(10031)
|
|
|
+ try:
|
|
|
+ with transaction.atomic():
|
|
|
+ uid_bucket_qs.update(status=vod_status)
|
|
|
+ if vod_status == 0:
|
|
|
+ ai_status = '0'
|
|
|
+ if uid_set_qs[0].is_ai == 2:
|
|
|
+ return response.json(0)
|
|
|
+ uid_obj = UidTokenObject()
|
|
|
+ uid_obj.generate(data={'uid': uid, 'channel': channel})
|
|
|
+
|
|
|
+ # 欧洲域名固定返回欧洲域名
|
|
|
+ urls = SERVER_DOMAIN_SSL
|
|
|
+ if domain_name in ['api.zositeche.com', 'api.loocam3.com', 'common.neutral3.com']:
|
|
|
+ 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 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')
|
|
|
+
|
|
|
+ # 如果传空上来,就默认为0
|
|
|
+ tz = '0' if tz == '' else tz.replace('GMT', '')
|
|
|
+ ai_status = int(ai_status)
|
|
|
+ ai_service_qs = AiService.objects.filter(uid=uid, use_status=1)
|
|
|
+ if not ai_service_qs.exists():
|
|
|
+ return response.json(10053)
|
|
|
+
|
|
|
+ uid_set_id = uid_set_qs[0].id
|
|
|
+ interval = uid_set_qs[0].new_detect_interval if not interval else interval
|
|
|
+ qs_data = {
|
|
|
+ 'updTime': now_time,
|
|
|
+ }
|
|
|
+ if interval:
|
|
|
+ qs_data['detect_interval'] = int(interval)
|
|
|
+ qs_data['detect_group'] = detect_group if detect_group else ''
|
|
|
+ uid_set_qs.update(**qs_data)
|
|
|
+
|
|
|
+ qs_data['detect_status'] = ai_status # ai开关状态
|
|
|
+ qs_data['endTime'] = end_time
|
|
|
+ ai_service_qs.update(**qs_data)
|
|
|
+ thing_name = CommonService.query_serial_with_uid(uid) # 存在序列号则为使用序列号作为物品名
|
|
|
+ topic_name = 'ansjer/generic/{}'.format(thing_name)
|
|
|
+
|
|
|
+ if ai_status == 0: # 关闭
|
|
|
+ # mqtt通知设备关闭AI识别功能
|
|
|
+ msg = {'commandType': 'AIDisable'}
|
|
|
+ req_success = CommonService.req_publish_mqtt_msg(thing_name, topic_name, msg)
|
|
|
+ if not req_success:
|
|
|
+ return response.json(10044)
|
|
|
+ if vod_status == 0:
|
|
|
+ return response.json(0)
|
|
|
+ return response.json(0, {'uidTkUrl': uid_tk_url, 'storeHlsUrl': store_hls_url})
|
|
|
+ elif ai_status == 1: # 开启
|
|
|
+ # 更新或创建uid_push数据
|
|
|
+ uid_push_qs = UidPushModel.objects.filter(userID_id=user_id, m_code=m_code, uid_set__uid=uid)
|
|
|
+ uid_push_data = {
|
|
|
+ 'appBundleId': appBundleId,
|
|
|
+ 'app_type': app_type,
|
|
|
+ 'push_type': push_type,
|
|
|
+ 'token_val': token_val,
|
|
|
+ 'updTime': now_time,
|
|
|
+ 'lang': lang,
|
|
|
+ 'tz': tz
|
|
|
+ }
|
|
|
+
|
|
|
+ if uid_push_qs.exists():
|
|
|
+ uid_push_qs.update(**uid_push_data)
|
|
|
+ else:
|
|
|
+ uid_push_data['uid_set_id'] = uid_set_id
|
|
|
+ uid_push_data['userID_id'] = user_id
|
|
|
+ uid_push_data['m_code'] = m_code
|
|
|
+ uid_push_data['addTime'] = now_time
|
|
|
+ UidPushModel.objects.create(**uid_push_data)
|
|
|
+
|
|
|
+ etkObj = ETkObject(etk='')
|
|
|
+ etk = etkObj.encrypt(uid)
|
|
|
+
|
|
|
+ # mqtt通知设备开启AI识别功能
|
|
|
+ push_url = DETECT_PUSH_DOMAINS
|
|
|
+ # 欧洲域名固定返回欧洲域名
|
|
|
+ if domain_name in ['api.zositeche.com', 'api.loocam3.com', 'common.neutral3.com']:
|
|
|
+ push_url = 'https://push.zositeche.com/'
|
|
|
+ aiIdentificationUrl = '{}AiService/identification'.format(push_url)
|
|
|
+ msg = {
|
|
|
+ 'commandType': 'AIEnable',
|
|
|
+ 'payload': {
|
|
|
+ 'etk': etk,
|
|
|
+ 'endTime': end_time,
|
|
|
+ 'aiIdentificationUrl': aiIdentificationUrl,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ req_success = CommonService.req_publish_mqtt_msg(thing_name, topic_name, msg)
|
|
|
+ if not req_success:
|
|
|
+ return response.json(10044)
|
|
|
+ return response.json(0, {'uidTkUrl': uid_tk_url, 'storeHlsUrl': store_hls_url,
|
|
|
+ 'aiIdentificationUrl': aiIdentificationUrl, 'endTime': end_time, 'etk': etk})
|
|
|
+
|
|
|
+ return response.json(0, {'uidTkUrl': uid_tk_url, 'storeHlsUrl': store_hls_url})
|
|
|
+ except Exception as e:
|
|
|
+ return response.json(500, repr(e))
|
|
|
+
|
|
|
+
|
|
|
@staticmethod
|
|
|
def do_pay_error():
|
|
|
response = HttpResponse()
|
|
@@ -760,7 +916,8 @@ class CloudStorageView(View):
|
|
|
channel = order_list[0]['channel']
|
|
|
rank = order_list[0]['rank']
|
|
|
|
|
|
- store_qs = Store_Meal.objects.filter(id=rank).values("day", "bucket_id", "bucket__storeDay", "expire")
|
|
|
+ store_qs = Store_Meal.objects.filter(id=rank).values("day", "bucket_id", "bucket__storeDay", "expire",
|
|
|
+ 'is_ai')
|
|
|
bucket_id = store_qs[0]['bucket_id']
|
|
|
if not store_qs.exists():
|
|
|
return response.json(173)
|
|
@@ -819,6 +976,22 @@ class CloudStorageView(View):
|
|
|
order_qs.update(status=1, updTime=now_time, uid_bucket_id=uid_bucket_id,
|
|
|
promotion_rule_id=promotion_rule_id)
|
|
|
date_time = time.strftime("%Y-%m-%d", time.localtime())
|
|
|
+ # 开通AI服务
|
|
|
+ if store_qs[0]['is_ai']:
|
|
|
+ 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)
|
|
|
+ else:
|
|
|
+ ai_service_dict = {
|
|
|
+ 'uid': uid,
|
|
|
+ 'channel': channel,
|
|
|
+ 'detect_status': 1,
|
|
|
+ 'addTime': now_time,
|
|
|
+ 'updTime': now_time,
|
|
|
+ 'use_status': 1,
|
|
|
+ 'endTime': end_time
|
|
|
+ }
|
|
|
+ AiService.objects.create(**ai_service_dict)
|
|
|
# 如果存在序列号,消息提示用序列号
|
|
|
device_info_qs = Device_Info.objects.filter(UID=uid).values('serial_number', 'Type')
|
|
|
serial_number = device_info_qs[0]['serial_number']
|
|
@@ -914,7 +1087,8 @@ class CloudStorageView(View):
|
|
|
uid = order_list[0]['UID']
|
|
|
channel = order_list[0]['channel']
|
|
|
rank = order_list[0]['rank']
|
|
|
- store_qs = Store_Meal.objects.filter(id=rank).values("day", "bucket_id", "bucket__storeDay", "expire")
|
|
|
+ store_qs = Store_Meal.objects.filter(id=rank).values("day", "bucket_id", "bucket__storeDay", "expire",
|
|
|
+ 'is_ai')
|
|
|
bucket_id = store_qs[0]['bucket_id']
|
|
|
if not store_qs.exists():
|
|
|
return response.json(173)
|
|
@@ -973,6 +1147,22 @@ class CloudStorageView(View):
|
|
|
order_qs.update(status=1, updTime=now_time, uid_bucket_id=uid_bucket_id,
|
|
|
promotion_rule_id=promotion_rule_id)
|
|
|
date_time = time.strftime("%Y-%m-%d", time.localtime())
|
|
|
+ # 开通AI服务
|
|
|
+ if store_qs[0]['is_ai']:
|
|
|
+ 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)
|
|
|
+ else:
|
|
|
+ ai_service_dict = {
|
|
|
+ 'uid': uid,
|
|
|
+ 'channel': channel,
|
|
|
+ 'detect_status': 1,
|
|
|
+ 'addTime': now_time,
|
|
|
+ 'updTime': now_time,
|
|
|
+ 'use_status': 1,
|
|
|
+ 'endTime': end_time
|
|
|
+ }
|
|
|
+ AiService.objects.create(**ai_service_dict)
|
|
|
# 如果存在序列号,消息提示用序列号
|
|
|
device_info_qs = Device_Info.objects.filter(UID=uid).values('serial_number', 'Type')
|
|
|
serial_number = device_info_qs[0]['serial_number']
|
|
@@ -1050,7 +1240,8 @@ class CloudStorageView(View):
|
|
|
uid = order_list[0]['UID']
|
|
|
channel = order_list[0]['channel']
|
|
|
rank = order_list[0]['rank']
|
|
|
- store_qs = Store_Meal.objects.filter(id=rank).values("day", "bucket_id", "bucket__storeDay", "expire")
|
|
|
+ store_qs = Store_Meal.objects.filter(id=rank).values("day", "bucket_id", "bucket__storeDay", "expire",
|
|
|
+ 'is_ai')
|
|
|
bucket_id = store_qs[0]['bucket_id']
|
|
|
if not store_qs.exists():
|
|
|
return HttpResponse(pay.xml_to_dict({'return_code': 'FAIL', 'return_msg': '套餐不存在'}))
|
|
@@ -1109,6 +1300,22 @@ class CloudStorageView(View):
|
|
|
order_qs.update(status=1, updTime=now_time, uid_bucket_id=uid_bucket_id,
|
|
|
promotion_rule_id=promotion_rule_id)
|
|
|
date_time = time.strftime("%Y-%m-%d", time.localtime())
|
|
|
+ # 开通AI服务
|
|
|
+ if store_qs[0]['is_ai']:
|
|
|
+ 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)
|
|
|
+ else:
|
|
|
+ ai_service_dict = {
|
|
|
+ 'uid': uid,
|
|
|
+ 'channel': channel,
|
|
|
+ 'detect_status': 1,
|
|
|
+ 'addTime': now_time,
|
|
|
+ 'updTime': now_time,
|
|
|
+ 'use_status': 1,
|
|
|
+ 'endTime': end_time
|
|
|
+ }
|
|
|
+ AiService.objects.create(**ai_service_dict)
|
|
|
# 如果存在序列号,消息提示用序列号
|
|
|
device_info_qs = Device_Info.objects.filter(UID=uid).values('serial_number', 'Type')
|
|
|
serial_number = device_info_qs[0]['serial_number']
|
|
@@ -1181,7 +1388,7 @@ class CloudStorageView(View):
|
|
|
now_time = int(time.time())
|
|
|
store_qs = Store_Meal.objects.filter(id=rank, pay_type=pay_type, lang__lang=lang, is_show=0). \
|
|
|
values('currency', 'price', 'lang__content', 'day', 'commodity_type', 'lang__title', 'expire',
|
|
|
- 'commodity_code', 'discount_price', 'bucket__mold', 'cycle_config_id')
|
|
|
+ 'commodity_code', 'discount_price', 'bucket__mold', 'cycle_config_id', 'is_ai')
|
|
|
if not store_qs.exists():
|
|
|
return response.json(173)
|
|
|
store_meal_qs = Store_Meal.objects.filter(id=rank, lang__lang='cn', is_show=0).values('lang__title',
|
|
@@ -1234,14 +1441,17 @@ class CloudStorageView(View):
|
|
|
sub_info = Paypal.subscriptions(store_info=store_qs[0], lang=lang, orderID=order_id, price=price)
|
|
|
if not sub_info:
|
|
|
return response.json(10048)
|
|
|
- Order_Model.objects.create(orderID=order_id, UID=uid, channel=channel, userID_id=user_id,
|
|
|
- desc=content, payType=pay_type, payTime=now_time,
|
|
|
- price=price, currency=currency, addTime=now_time, updTime=now_time,
|
|
|
- pay_url=sub_info['url'], isSelectDiscounts=is_select_discount,
|
|
|
- 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,
|
|
|
- store_meal_name=store_meal_name)
|
|
|
-
|
|
|
+ order_qs = Order_Model.objects.create(orderID=order_id, UID=uid, channel=channel, userID_id=user_id,
|
|
|
+ desc=content, payType=pay_type, payTime=now_time,
|
|
|
+ price=price, currency=currency, addTime=now_time,
|
|
|
+ updTime=now_time,
|
|
|
+ pay_url=sub_info['url'], isSelectDiscounts=is_select_discount,
|
|
|
+ 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,
|
|
|
+ store_meal_name=store_meal_name)
|
|
|
+ if store_qs[0]['is_ai'] == 1:
|
|
|
+ order_qs.order_type = 1
|
|
|
return response.json(0, {"redirectUrl": sub_info['url'], "orderID": order_id})
|
|
|
# 正常扣款
|
|
|
call_clc_url = "{}web/paid2/fail.html".format(SERVER_DOMAIN_SSL)
|
|
@@ -1268,13 +1478,17 @@ class CloudStorageView(View):
|
|
|
for link in payment.links:
|
|
|
if link.rel == "approval_url":
|
|
|
approval_url = str(link.href)
|
|
|
- Order_Model.objects.create(orderID=order_id, UID=uid, channel=channel, userID_id=user_id,
|
|
|
- desc=content, payType=pay_type, payTime=now_time,
|
|
|
- price=price, currency=currency, addTime=now_time, updTime=now_time,
|
|
|
- pay_url=approval_url, isSelectDiscounts=is_select_discount,
|
|
|
- commodity_code=commodity_code, commodity_type=commodity_type,
|
|
|
- rank_id=rank, paymentID=payment_id, coupon_id=coupon_id, ai_rank_id=1,
|
|
|
- store_meal_name=store_meal_name)
|
|
|
+ order_qs = Order_Model.objects.create(orderID=order_id, UID=uid, channel=channel, userID_id=user_id,
|
|
|
+ desc=content, payType=pay_type, payTime=now_time,
|
|
|
+ price=price, currency=currency, addTime=now_time,
|
|
|
+ updTime=now_time,
|
|
|
+ pay_url=approval_url, isSelectDiscounts=is_select_discount,
|
|
|
+ commodity_code=commodity_code, commodity_type=commodity_type,
|
|
|
+ rank_id=rank, paymentID=payment_id, coupon_id=coupon_id,
|
|
|
+ ai_rank_id=1,
|
|
|
+ store_meal_name=store_meal_name)
|
|
|
+ if store_qs[0]['is_ai'] == 1:
|
|
|
+ order_qs.order_type = 1
|
|
|
return response.json(0, {"redirectUrl": approval_url, "orderID": order_id})
|
|
|
return response.json(10, 'generate_order_false')
|
|
|
elif pay_type == 2:
|
|
@@ -1298,14 +1512,16 @@ class CloudStorageView(View):
|
|
|
else:
|
|
|
if 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,
|
|
|
- desc=content, payType=pay_type, payTime=now_time,
|
|
|
- price=price, currency=currency, addTime=now_time, updTime=now_time,
|
|
|
- pay_url=redirect_url, isSelectDiscounts=is_select_discount,
|
|
|
- commodity_code=commodity_code, commodity_type=commodity_type,
|
|
|
- rank_id=rank, coupon_id=coupon_id, ai_rank_id=1,
|
|
|
- store_meal_name=store_meal_name)
|
|
|
-
|
|
|
+ order_qs = Order_Model.objects.create(orderID=order_id, UID=uid, channel=channel, userID_id=user_id,
|
|
|
+ desc=content, payType=pay_type, payTime=now_time,
|
|
|
+ price=price, currency=currency, addTime=now_time,
|
|
|
+ updTime=now_time,
|
|
|
+ pay_url=redirect_url, isSelectDiscounts=is_select_discount,
|
|
|
+ commodity_code=commodity_code, commodity_type=commodity_type,
|
|
|
+ rank_id=rank, coupon_id=coupon_id, ai_rank_id=1,
|
|
|
+ store_meal_name=store_meal_name)
|
|
|
+ if store_qs[0]['is_ai'] == 1:
|
|
|
+ order_qs.order_type = 1
|
|
|
return JsonResponse(status=200, data={'result_code': 0, 'reason': 'success',
|
|
|
'result': {"redirectUrl": redirect_url, "orderID": order_id},
|
|
|
'error_code': 0})
|
|
@@ -1326,12 +1542,15 @@ class CloudStorageView(View):
|
|
|
if not response:
|
|
|
return response.json(10, '生成订单错误.')
|
|
|
# 回调函数
|
|
|
- Order_Model.objects.create(orderID=order_id, UID=uid, channel=channel, userID_id=user_id,
|
|
|
- desc=content, payType=pay_type, payTime=now_time,
|
|
|
- price=price, currency=currency, addTime=now_time, updTime=now_time,
|
|
|
- pay_url=notify_url, isSelectDiscounts=is_select_discount,
|
|
|
- commodity_code=commodity_code, commodity_type=commodity_type, rank_id=rank,
|
|
|
- ai_rank_id=1, store_meal_name=store_meal_name)
|
|
|
+ order_qs = Order_Model.objects.create(orderID=order_id, UID=uid, channel=channel, userID_id=user_id,
|
|
|
+ desc=content, payType=pay_type, payTime=now_time,
|
|
|
+ price=price, currency=currency, addTime=now_time, updTime=now_time,
|
|
|
+ pay_url=notify_url, isSelectDiscounts=is_select_discount,
|
|
|
+ commodity_code=commodity_code, commodity_type=commodity_type,
|
|
|
+ rank_id=rank,
|
|
|
+ ai_rank_id=1, store_meal_name=store_meal_name)
|
|
|
+ if store_qs[0]['is_ai'] == 1:
|
|
|
+ order_qs.order_type = 1
|
|
|
return JsonResponse(status=200, data={'result_code': 0, 'reason': 'success',
|
|
|
'result': response,
|
|
|
'orderId': order_id,
|
|
@@ -1402,7 +1621,8 @@ class CloudStorageView(View):
|
|
|
|
|
|
order_id = CommonService.createOrderID()
|
|
|
now_time = int(time.time())
|
|
|
- store_qs = Store_Meal.objects.filter(id=rank, lang__lang=lang, is_show=0).values("day", "bucket_id",
|
|
|
+ order_type = 0
|
|
|
+ store_qs = Store_Meal.objects.filter(id=rank, lang__lang=lang, is_show=0).values("day", "bucket_id", 'is_ai',
|
|
|
"bucket__storeDay", "expire",
|
|
|
'lang__content', 'price',
|
|
|
'currency', 'commodity_type')
|
|
@@ -1437,6 +1657,14 @@ class CloudStorageView(View):
|
|
|
endTime=end_time, addTime=now_time, updateTime=now_time,
|
|
|
use_status=1)
|
|
|
uid_bucket_id = uid_bucket.id
|
|
|
+ if store_qs[0]['is_ai']:
|
|
|
+ order_type = 1
|
|
|
+ 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)
|
|
|
+ else:
|
|
|
+ AiService.objects.create(uid=uid, channel=channel, detect_status=1, endTime=end_time,
|
|
|
+ addTime=now_time, updTime=now_time, use_status=1)
|
|
|
store_meal_qs = Store_Meal.objects.filter(id=rank, lang__lang='cn', is_show=0).values('lang__title',
|
|
|
'lang__content')
|
|
|
if store_meal_qs.exists():
|
|
@@ -1446,7 +1674,7 @@ class CloudStorageView(View):
|
|
|
Order_Model.objects.create(orderID=order_id, UID=uid, channel=channel, userID_id=user_id,
|
|
|
desc=store_qs[0]['lang__content'], payType=pay_type, payTime=now_time,
|
|
|
price=store_qs[0]['price'], currency=store_qs[0]['currency'],
|
|
|
- addTime=now_time,
|
|
|
+ addTime=now_time, order_type=order_type,
|
|
|
updTime=now_time,
|
|
|
pay_url="体验版", store_meal_name=store_meal_name,
|
|
|
commodity_code=commodity_code, commodity_type=store_qs[0]['commodity_type'],
|
|
@@ -1529,6 +1757,7 @@ class CloudStorageView(View):
|
|
|
experience_context_qs.delete()
|
|
|
Order_Model.objects.filter(uid_bucket_id=bucket_id).delete()
|
|
|
uid_bucket_qs.delete()
|
|
|
+ AiService.objects.filter(uid=uid_bucket_qs[0].uid).delete()
|
|
|
else:
|
|
|
return response.json(10007)
|
|
|
else:
|
|
@@ -1689,6 +1918,9 @@ class CloudStorageView(View):
|
|
|
Unused_Uid_Meal.objects.filter(id=unused_id).delete()
|
|
|
StsCrdModel.objects.filter(uid=uid).delete() # 删除sts记录
|
|
|
# VodHlsModel.objects.filter(uid=uid).delete() # 删除播放列表,后期数据量多时应该考虑延后删除
|
|
|
+ AiService.objects.filter(uid=uid, channel=unused_uid_bucket['channel']).update(endTime=end_time,
|
|
|
+ updTime=now_time,
|
|
|
+ use_status=1)
|
|
|
return response.json(0)
|
|
|
except Exception:
|
|
|
return response.json(474)
|