|
@@ -4,7 +4,6 @@ import base64
|
|
|
import datetime
|
|
|
import json
|
|
|
import logging
|
|
|
-import ssl
|
|
|
import sys
|
|
|
import time
|
|
|
from decimal import Decimal
|
|
@@ -27,7 +26,7 @@ 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, VodHlsTag
|
|
|
+ VideoPlaybackTimeModel, CouponModel, VodBucketModel, VodHlsSummary
|
|
|
from Object.AWS.AmazonS3Util import AmazonS3Util
|
|
|
from Object.AWS.S3Email import S3Email
|
|
|
from Object.AliPayObject import AliPayObject
|
|
@@ -42,9 +41,6 @@ from Service.CommonService import CommonService
|
|
|
from Service.PayService import PaymentService
|
|
|
from Service.VodHlsService import SplitVodHlsObject
|
|
|
|
|
|
-ssl._create_default_https_context = ssl._create_unverified_context
|
|
|
-LOGGER = logging.getLogger('info')
|
|
|
-
|
|
|
|
|
|
# 设备信息添加
|
|
|
class CloudStorageView(View):
|
|
@@ -402,7 +398,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)]
|
|
|
}
|
|
|
]
|
|
|
}
|
|
@@ -669,6 +665,7 @@ class CloudStorageView(View):
|
|
|
uid = request_dict.get('uid', None)
|
|
|
status = request_dict.get('status', None)
|
|
|
channel = request_dict.get('channel', None)
|
|
|
+ domain_name = request_dict.get('domain_name', None)
|
|
|
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(
|
|
@@ -686,10 +683,13 @@ class CloudStorageView(View):
|
|
|
return response.json(0)
|
|
|
uid_obj = UidTokenObject()
|
|
|
uid_obj.generate(data={'uid': uid, 'channel': channel})
|
|
|
- uid_tk_url = "{SERVER_DOMAIN_SSL}cloudstorage/getsignsts?uidToken={uidToken}". \
|
|
|
- format(uidToken=uid_obj.token, SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
|
|
|
- store_hls_url = "{SERVER_DOMAIN_SSL}cloudstorage/storeplaylist?uidToken={uidToken}". \
|
|
|
- format(uidToken=uid_obj.token, SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
|
|
|
+
|
|
|
+ # 欧洲域名固定返回欧洲域名
|
|
|
+ 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)
|
|
|
return response.json(0, {'uidTkUrl': uid_tk_url, 'storeHlsUrl': store_hls_url})
|
|
|
|
|
|
@staticmethod
|
|
@@ -825,11 +825,12 @@ class CloudStorageView(View):
|
|
|
device_name = CommonService.get_full_serial_number(uid, serial_number, device_type)
|
|
|
else:
|
|
|
device_name = uid
|
|
|
- sys_msg_text_list = ['温馨提示:尊敬的客户,您的' + device_name + '设备在' + date_time + '已成功购买云存套餐',
|
|
|
- 'Dear customer,you already subscribed the cloud storage package successfully for device ' + device_name + ' on ' + time.strftime(
|
|
|
- "%b %dth,%Y", time.localtime())]
|
|
|
+ sys_msg_text_list = [
|
|
|
+ '温馨提示:尊敬的客户,您的' + device_name + '设备在' + date_time + '已成功购买云存套餐',
|
|
|
+ 'Dear customer,you already subscribed the cloud storage package successfully for device ' + device_name + ' on ' + time.strftime(
|
|
|
+ "%b %dth,%Y", time.localtime())]
|
|
|
self.do_vod_msg_notice(uid, channel, userid, lang, sys_msg_text_list, 'SMS_219738485')
|
|
|
- red_url = "{SERVER_DOMAIN_SSL}web/paid2/success.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
|
|
|
+ red_url = "{}web/paid2/success.html".format(SERVER_DOMAIN_SSL)
|
|
|
if lang != 'cn':
|
|
|
red_url = red_url.replace('success.html', 'en_success.html')
|
|
|
redis_obj.del_data(key=order_id + 'do_notify')
|
|
@@ -846,7 +847,7 @@ class CloudStorageView(View):
|
|
|
if order_qs:
|
|
|
order_qs.update(status=10, promotion_rule_id=promotion_rule_id)
|
|
|
redis_obj.del_data(key=order_id + 'do_notify')
|
|
|
- red_url = "{SERVER_DOMAIN_SSL}web/paid2/fail.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
|
|
|
+ red_url = "{}web/paid2/fail.html".format(SERVER_DOMAIN_SSL)
|
|
|
if lang != 'cn':
|
|
|
red_url = red_url.replace('fail.html', 'en_fail.html')
|
|
|
return HttpResponseRedirect(red_url)
|
|
@@ -884,7 +885,7 @@ class CloudStorageView(View):
|
|
|
promotion_rule_id = ''
|
|
|
try:
|
|
|
if not order_id:
|
|
|
- red_url = "{SERVER_DOMAIN_SSL}web/paid2/fail.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
|
|
|
+ red_url = "{}web/paid2/fail.html".format(SERVER_DOMAIN_SSL)
|
|
|
if lang != 'cn':
|
|
|
red_url = red_url.replace('fail.html', 'en_fail.html')
|
|
|
return HttpResponseRedirect(red_url)
|
|
@@ -898,7 +899,7 @@ class CloudStorageView(View):
|
|
|
payers = payment.execute({"payer_id": payer_id})
|
|
|
logger.info(payers)
|
|
|
if not payers:
|
|
|
- red_url = "{SERVER_DOMAIN_SSL}web/paid2/fail.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
|
|
|
+ red_url = "{}web/paid2/fail.html".format(SERVER_DOMAIN_SSL)
|
|
|
if lang != 'cn':
|
|
|
red_url = red_url.replace('fail.html', 'en_fail.html')
|
|
|
redis_obj.del_data(key=order_id + 'do_notify')
|
|
@@ -978,13 +979,14 @@ class CloudStorageView(View):
|
|
|
device_name = CommonService.get_full_serial_number(uid, serial_number, device_type)
|
|
|
else:
|
|
|
device_name = uid
|
|
|
- sys_msg_text_list = ['温馨提示:尊敬的客户,您的' + device_name + '设备在' + date_time + '已成功购买云存套餐',
|
|
|
- 'Dear customer,you already subscribed the cloud storage package successfully for device ' + device_name + ' on ' + time.strftime(
|
|
|
- "%b %dth,%Y", time.localtime())]
|
|
|
+ sys_msg_text_list = [
|
|
|
+ '温馨提示:尊敬的客户,您的' + device_name + '设备在' + date_time + '已成功购买云存套餐',
|
|
|
+ 'Dear customer,you already subscribed the cloud storage package successfully for device ' + device_name + ' on ' + time.strftime(
|
|
|
+ "%b %dth,%Y", time.localtime())]
|
|
|
|
|
|
self.do_vod_msg_notice(uid, channel, userid, lang, sys_msg_text_list, 'SMS_219738485')
|
|
|
|
|
|
- red_url = "{SERVER_DOMAIN_SSL}web/paid2/success.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
|
|
|
+ red_url = "{}web/paid2/success.html".format(SERVER_DOMAIN_SSL)
|
|
|
if lang != 'cn':
|
|
|
red_url = red_url.replace('success.html', 'en_success.html')
|
|
|
redis_obj.del_data(key=order_id + 'do_notify')
|
|
@@ -995,7 +997,7 @@ class CloudStorageView(View):
|
|
|
logger.info(repr(e))
|
|
|
if order_qs:
|
|
|
order_qs.update(status=10, promotion_rule_id=promotion_rule_id)
|
|
|
- red_url = "{SERVER_DOMAIN_SSL}web/paid2/fail.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
|
|
|
+ red_url = "{}web/paid2/fail.html".format(SERVER_DOMAIN_SSL)
|
|
|
if lang != 'cn':
|
|
|
red_url = red_url.replace('fail.html', 'en_fail.html')
|
|
|
redis_obj.del_data(key=order_id + 'do_notify')
|
|
@@ -1113,9 +1115,10 @@ class CloudStorageView(View):
|
|
|
device_name = CommonService.get_full_serial_number(uid, serial_number, device_type)
|
|
|
else:
|
|
|
device_name = uid
|
|
|
- sys_msg_text_list = ['温馨提示:尊敬的客户,您的' + device_name + '设备在' + date_time + '已成功购买云存套餐',
|
|
|
- 'Dear customer,you already subscribed the cloud storage package successfully for device ' + device_name + ' on ' + time.strftime(
|
|
|
- "%b %dth,%Y", time.localtime())]
|
|
|
+ sys_msg_text_list = [
|
|
|
+ '温馨提示:尊敬的客户,您的' + device_name + '设备在' + date_time + '已成功购买云存套餐',
|
|
|
+ 'Dear customer,you already subscribed the cloud storage package successfully for device ' + device_name + ' on ' + time.strftime(
|
|
|
+ "%b %dth,%Y", time.localtime())]
|
|
|
self.do_vod_msg_notice(uid, channel, userid, lang, sys_msg_text_list, 'SMS_219738485')
|
|
|
redis_obj.del_data(key=order_id + 'do_notify')
|
|
|
return HttpResponse("<xml>\
|
|
@@ -1239,11 +1242,11 @@ class CloudStorageView(View):
|
|
|
|
|
|
return response.json(0, {"redirectUrl": sub_info['url'], "orderID": order_id})
|
|
|
# 正常扣款
|
|
|
- call_clc_url = "{SERVER_DOMAIN_SSL}web/paid2/fail.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
|
|
|
+ call_clc_url = "{}web/paid2/fail.html".format(SERVER_DOMAIN_SSL)
|
|
|
if lang != 'cn':
|
|
|
call_clc_url = call_clc_url.replace('fail.html', 'en_fail.html')
|
|
|
- call_sub_url = "{SERVER_DOMAIN_SSL}cloudstorage/dopaypalcallback?orderID={orderID}&lang={lang}". \
|
|
|
- format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL, orderID=order_id, lang=lang)
|
|
|
+ call_sub_url = "{}cloudstorage/dopaypalcallback?orderID={}&lang={}".format(SERVER_DOMAIN_SSL, order_id,
|
|
|
+ lang)
|
|
|
|
|
|
paypalrestsdk.configure(PAYPAL_CRD)
|
|
|
payment = paypalrestsdk.Payment({
|
|
@@ -1281,10 +1284,9 @@ class CloudStorageView(View):
|
|
|
out_trade_no=order_id,
|
|
|
total_amount=price,
|
|
|
subject=subject,
|
|
|
- return_url="{SERVER_DOMAIN_SSL}web/paid2/success.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL),
|
|
|
- notify_url="{SERVER_DOMAIN_SSL}cloudstorage/doalicallback".format(
|
|
|
- SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL),
|
|
|
- quit_url="{SERVER_DOMAIN_SSL}web/paid2/fail.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL),
|
|
|
+ return_url="{}web/paid2/success.html".format(SERVER_DOMAIN_SSL),
|
|
|
+ notify_url="{}cloudstorage/doalicallback".format(SERVER_DOMAIN_SSL),
|
|
|
+ quit_url="{}web/paid2/fail.html".format(SERVER_DOMAIN_SSL),
|
|
|
passback_params=quote("lang=" + lang)
|
|
|
)
|
|
|
|
|
@@ -1310,7 +1312,7 @@ class CloudStorageView(View):
|
|
|
|
|
|
elif pay_type == 3:
|
|
|
pay = WechatPayObject()
|
|
|
- notify_url = "{SERVER_DOMAIN_SSL}cloudstorage/dowechatnotify".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
|
|
|
+ notify_url = "{}cloudstorage/dowechatnotify".format(SERVER_DOMAIN_SSL)
|
|
|
content = CommonService.Package_Type(0, content) # 云存套餐
|
|
|
# 获取参数
|
|
|
parameter_dict = pay.get_parameter(order_id, content, float(price) * 100, ip, notify_url,
|
|
@@ -1468,35 +1470,35 @@ class CloudStorageView(View):
|
|
|
device_name = CommonService.get_full_serial_number(uid, serial_number, device_type)
|
|
|
else:
|
|
|
device_name = uid
|
|
|
- sys_msg_text_list = ['温馨提示:尊敬的客户,您的' + device_name + '设备在' + date_time + '已成功购买云存套餐',
|
|
|
- 'Dear customer,you already subscribed the cloud storage package successfully for device ' + device_name + ' on ' + time.strftime(
|
|
|
- "%b %dth,%Y", time.localtime())]
|
|
|
+ sys_msg_text_list = [
|
|
|
+ '温馨提示:尊敬的客户,您的' + device_name + '设备在' + date_time + '已成功购买云存套餐',
|
|
|
+ 'Dear customer,you already subscribed the cloud storage package successfully for device ' + device_name + ' on ' + time.strftime(
|
|
|
+ "%b %dth,%Y", time.localtime())]
|
|
|
|
|
|
- return_url = "{SERVER_DOMAIN_SSL}cloudstorage/payOK?lang={lang}".format(
|
|
|
- SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL, lang=lang)
|
|
|
+ return_url = "{}cloudstorage/payOK?lang={}".format(SERVER_DOMAIN_SSL, lang)
|
|
|
if pay_type == 10:
|
|
|
ExperienceContextModel.objects.create(
|
|
|
experience_type=0,
|
|
|
uid=uid,
|
|
|
do_time=now_time
|
|
|
)
|
|
|
- return_url = "{SERVER_DOMAIN_SSL}cloudstorage/payOK?paytype=10&lang={lang}".format(
|
|
|
- SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL, lang=lang)
|
|
|
+ return_url = "{}cloudstorage/payOK?paytype=10&lang={}".format(SERVER_DOMAIN_SSL, lang)
|
|
|
date_time = time.strftime("%Y-%m-%d", time.localtime())
|
|
|
- sys_msg_text_list = ['温馨提示:尊敬的客户,您的' + device_name + '设备在' + date_time + '已成功开通云存体验套餐',
|
|
|
- 'Dear customer,you already subscribed the free trial cloud storage service successfully for device ' + device_name + ' on ' + time.strftime(
|
|
|
- "%b %dth,%Y", time.localtime())]
|
|
|
+ sys_msg_text_list = [
|
|
|
+ '温馨提示:尊敬的客户,您的' + device_name + '设备在' + date_time + '已成功开通云存体验套餐',
|
|
|
+ 'Dear customer,you already subscribed the free trial cloud storage service successfully for device ' + device_name + ' on ' + time.strftime(
|
|
|
+ "%b %dth,%Y", time.localtime())]
|
|
|
sms = 'SMS_222870823'
|
|
|
if pay_type == 11:
|
|
|
update_dict = {'is_activate': 1, 'order': order_id}
|
|
|
CDKcontextModel.objects.filter(cdk=cdk).update(**update_dict)
|
|
|
- return_url = "{SERVER_DOMAIN_SSL}cloudstorage/payOK?paytype=11&lang={lang}".format(
|
|
|
- SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL, lang=lang)
|
|
|
+ return_url = "{}cloudstorage/payOK?paytype=11&lang={}".format(SERVER_DOMAIN_SSL, lang)
|
|
|
|
|
|
date_time = time.strftime("%Y-%m-%d", time.localtime())
|
|
|
- sys_msg_text_list = ['温馨提示:尊敬的客户,您的' + device_name + '设备在' + date_time + '已成功兑换云存套餐',
|
|
|
- 'Dear customer, you already redeemed for the cloud storage package successfully for device ' + device_name + ' on ' + time.strftime(
|
|
|
- "%b %dth,%Y", time.localtime())]
|
|
|
+ sys_msg_text_list = [
|
|
|
+ '温馨提示:尊敬的客户,您的' + device_name + '设备在' + date_time + '已成功兑换云存套餐',
|
|
|
+ 'Dear customer, you already redeemed for the cloud storage package successfully for device ' + device_name + ' on ' + time.strftime(
|
|
|
+ "%b %dth,%Y", time.localtime())]
|
|
|
sms = 'SMS_219748439'
|
|
|
|
|
|
self.do_vod_msg_notice(uid, channel, user_id, lang, sys_msg_text_list, sms)
|
|
@@ -2000,6 +2002,6 @@ class CloudStorageView(View):
|
|
|
order_qs.update(**update_dict)
|
|
|
return response.json(0)
|
|
|
except Exception as e:
|
|
|
- LOGGER.info('异常详情,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
- print(e)
|
|
|
+ logger = logging.getLogger('info')
|
|
|
+ logger.info('异常详情,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
return response.json(500, repr(e))
|