|
@@ -40,7 +40,7 @@ from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, OSS_ROLE_AR
|
|
|
from Controller.CheckUserData import DataValid
|
|
|
from Model.models import Device_Info, Order_Model, Store_Meal, VodHlsModel, OssCrdModel, UID_Bucket, StsCrdModel, \
|
|
|
ExperienceContextModel, Pay_Type, CDKcontextModel, Device_User, SysMassModel, SysMsgModel, UidPushModel, \
|
|
|
- Unused_Uid_Meal, UIDMainUser, UserModel
|
|
|
+ Unused_Uid_Meal, UIDMainUser, UserModel, PromotionRuleModel
|
|
|
from Object.AWS.S3Email import S3Email
|
|
|
from Object.AliPayObject import AliPayObject
|
|
|
from Object.AliSmsObject import AliSmsObject
|
|
@@ -52,7 +52,7 @@ from Service.CommonService import CommonService
|
|
|
from Object.m3u8generate import PlaylistGenerator
|
|
|
from Object.WechatPayObject import WechatPayObject
|
|
|
from django.db.models import Q, F, Count
|
|
|
-
|
|
|
+from Ansjer.config import SERVER_TYPE
|
|
|
from Service.ModelService import ModelService
|
|
|
|
|
|
# SERVER_DOMAIN = 'http://test.dvema.com/'
|
|
@@ -232,13 +232,19 @@ class CloudStorageView(View):
|
|
|
|
|
|
res_c = {'area': area, 'items': items_list}
|
|
|
res.append(res_c)
|
|
|
+ #是否促销
|
|
|
+ nowTime = int(time.time())
|
|
|
+ promotion = PromotionRuleModel.objects.filter(status=1, startTime__lte=nowTime,
|
|
|
+ endTime__gte=nowTime).values('id','ruleConfig')
|
|
|
+ is_promotion = 1 if promotion.exists() else 0
|
|
|
result = {
|
|
|
'meals': res,
|
|
|
'extra':
|
|
|
{
|
|
|
'cloud_banner': SERVER_DOMAIN+'web/images/cloud_cn_banner.png',
|
|
|
'cloud_en_baner': SERVER_DOMAIN_SSL+'web/images/cloud_en_banner.png'
|
|
|
- }
|
|
|
+ },
|
|
|
+ 'is_promotion':is_promotion
|
|
|
}
|
|
|
return response.json(0, result)
|
|
|
else:
|
|
@@ -751,6 +757,14 @@ class CloudStorageView(View):
|
|
|
expire = smqs[0]['expire']
|
|
|
if order_list[0]['isSelectDiscounts'] == 1:
|
|
|
expire = smqs[0]['expire'] * 2
|
|
|
+ # 是否有促销
|
|
|
+ nowTime = int(time.time())
|
|
|
+ promotion = PromotionRuleModel.objects.filter(status=1, startTime__gte=nowTime,
|
|
|
+ endTime__lte=nowTime).values('id','ruleConfig')
|
|
|
+ promotion_rule_id = ''
|
|
|
+ if promotion.exists():
|
|
|
+ promotion_rule_id = promotion[0]['id']
|
|
|
+ expire = expire * 2
|
|
|
with transaction.atomic():
|
|
|
if ubqs.exists():
|
|
|
ubq = ubqs[0]
|
|
@@ -762,6 +776,8 @@ class CloudStorageView(View):
|
|
|
else: #已过期或者不相同的套餐加入未使用的关联套餐表
|
|
|
has_unused = Unused_Uid_Meal.objects.filter(uid=UID, bucket_id=bucketId).values("id")
|
|
|
nums = 2 if order_list[0]['isSelectDiscounts'] == 1 else 1
|
|
|
+ if promotion.exists():
|
|
|
+ nums = nums + 1
|
|
|
if has_unused.exists():
|
|
|
Unused_Uid_Meal.objects.filter(id=has_unused[0]['id']).update(num=F('num') + nums)
|
|
|
else:
|
|
@@ -792,7 +808,7 @@ class CloudStorageView(View):
|
|
|
# }
|
|
|
# UIDMainUser.objects.create(**uid_main_dict)
|
|
|
|
|
|
- order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id)
|
|
|
+ order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id, promotion_rule_id=promotion_rule_id)
|
|
|
datetime = time.strftime("%Y-%m-%d", time.localtime())
|
|
|
sys_msg_text_list = ['温馨提示:尊敬的客户,您的'+UID+'设备在'+datetime+'已成功购买云存套餐', 'Dear customer,you already subscribed the cloud storage package successfully for device ' + UID + ' on '+ time.strftime("%b %dth,%Y", time.localtime())]
|
|
|
self.do_vod_msg_Notice(UID, channel, userid, lang, sys_msg_text_list, 'SMS_219738485')
|
|
@@ -803,7 +819,7 @@ class CloudStorageView(View):
|
|
|
return response.json(0, signature)
|
|
|
except Exception as e:
|
|
|
if order_qs:
|
|
|
- order_qs.update(status=10)
|
|
|
+ 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)
|
|
|
if lang != 'cn':
|
|
|
red_url = "{SERVER_DOMAIN_SSL}web/paid2/en_fail.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
|
|
@@ -858,6 +874,14 @@ class CloudStorageView(View):
|
|
|
|
|
|
if order_list[0]['isSelectDiscounts'] == 1:
|
|
|
expire = smqs[0]['expire'] * 2
|
|
|
+ # 是否有促销
|
|
|
+ nowTime = int(time.time())
|
|
|
+ promotion = PromotionRuleModel.objects.filter(status=1, startTime__gte=nowTime,
|
|
|
+ endTime__lte=nowTime).values('id','ruleConfig')
|
|
|
+ promotion_rule_id = ''
|
|
|
+ if promotion.exists():
|
|
|
+ promotion_rule_id = promotion[0]['id']
|
|
|
+ expire = expire * 2
|
|
|
with transaction.atomic():
|
|
|
if ubqs.exists():
|
|
|
ubq = ubqs[0]
|
|
@@ -869,6 +893,8 @@ class CloudStorageView(View):
|
|
|
else: #已过期或者不相同的套餐加入未使用的关联套餐表
|
|
|
has_unused = Unused_Uid_Meal.objects.filter(uid=UID, bucket_id=bucketId).values("id")
|
|
|
nums = 2 if order_list[0]['isSelectDiscounts'] == 1 else 1
|
|
|
+ if promotion.exists():
|
|
|
+ nums = nums + 1
|
|
|
if has_unused.exists():
|
|
|
Unused_Uid_Meal.objects.filter(id=has_unused[0]['id']).update(num=F('num') + nums)
|
|
|
else:
|
|
@@ -899,7 +925,7 @@ class CloudStorageView(View):
|
|
|
# }
|
|
|
# UIDMainUser.objects.create(**uid_main_dict)
|
|
|
|
|
|
- order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id)
|
|
|
+ order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id, promotion_rule_id=promotion_rule_id)
|
|
|
datetime = time.strftime("%Y-%m-%d", time.localtime())
|
|
|
sys_msg_text_list = ['温馨提示:尊敬的客户,您的' + UID + '设备在' + datetime + '已成功购买云存套餐',
|
|
|
'Dear customer,you already subscribed the cloud storage package successfully for device ' + UID + ' on ' + time.strftime(
|
|
@@ -916,7 +942,7 @@ class CloudStorageView(View):
|
|
|
except Exception as e:
|
|
|
print(repr(e))
|
|
|
if order_qs:
|
|
|
- order_qs.update(status=10)
|
|
|
+ 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)
|
|
|
if lang != 'cn':
|
|
|
red_url = "{SERVER_DOMAIN_SSL}web/paid2/en_fail.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
|
|
@@ -962,6 +988,13 @@ class CloudStorageView(View):
|
|
|
expire = smqs[0]['expire']
|
|
|
if order_list[0]['isSelectDiscounts'] == 1:
|
|
|
expire = smqs[0]['expire'] * 2
|
|
|
+ #是否有促销
|
|
|
+ nowTime = int(time.time())
|
|
|
+ promotion = PromotionRuleModel.objects.filter(status=1,startTime__gte=nowTime,endTime__lte=nowTime).values('id','ruleConfig')
|
|
|
+ promotion_rule_id = ''
|
|
|
+ if promotion.exists():
|
|
|
+ promotion_rule_id = promotion[0]['id']
|
|
|
+ expire = expire * 2
|
|
|
with transaction.atomic():
|
|
|
if ubqs.exists():
|
|
|
ubq = ubqs[0]
|
|
@@ -973,6 +1006,8 @@ class CloudStorageView(View):
|
|
|
else: #已过期或者不相同的套餐加入未使用的关联套餐表
|
|
|
has_unused = Unused_Uid_Meal.objects.filter(uid=UID, bucket_id=bucketId).values("id")
|
|
|
nums = 2 if order_list[0]['isSelectDiscounts'] == 1 else 1
|
|
|
+ if promotion.exists():
|
|
|
+ nums = nums + 1
|
|
|
if has_unused.exists():
|
|
|
Unused_Uid_Meal.objects.filter(id=has_unused[0]['id']).update(num=F('num') + nums)
|
|
|
else:
|
|
@@ -1003,7 +1038,7 @@ class CloudStorageView(View):
|
|
|
# }
|
|
|
# UIDMainUser.objects.create(**uid_main_dict)
|
|
|
|
|
|
- order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id)
|
|
|
+ order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id, promotion_rule_id=promotion_rule_id)
|
|
|
datetime = time.strftime("%Y-%m-%d", time.localtime())
|
|
|
sys_msg_text_list = ['温馨提示:尊敬的客户,您的' + UID + '设备在' + datetime + '已成功购买云存套餐',
|
|
|
'Dear customer,you already subscribed the cloud storage package successfully for device ' + UID + ' on ' + time.strftime(
|
|
@@ -1012,11 +1047,11 @@ class CloudStorageView(View):
|
|
|
self.do_vod_msg_Notice(UID, channel, userid, lang, sys_msg_text_list, 'SMS_219738485')
|
|
|
return HttpResponse(pay.xml_to_dict({'return_code': 'SUCCESS', 'return_msg': 'OK'}))
|
|
|
else:
|
|
|
- order_qs.update(status=10)
|
|
|
+ order_qs.update(status=10, promotion_rule_id=promotion_rule_id)
|
|
|
return HttpResponse(pay.xml_to_dict({'return_code': 'FAIL', 'return_msg': '参数格式校验错误'}))
|
|
|
except Exception as e:
|
|
|
if order_qs:
|
|
|
- order_qs.update(status=10)
|
|
|
+ order_qs.update(status=10, promotion_rule_id=promotion_rule_id)
|
|
|
return HttpResponse(pay.xml_to_dict({'return_code': 'FAIL', 'return_msg': repr(e)}))
|
|
|
|
|
|
def do_create_pay_order(self, request_dict, userID, ip, response): # 创建支付订单
|