|
@@ -1,39 +1,42 @@
|
|
|
#!/usr/bin/env python3
|
|
|
# -*- coding: utf-8 -*-
|
|
|
import base64
|
|
|
+import datetime
|
|
|
import json
|
|
|
+import logging
|
|
|
+import sys
|
|
|
import time
|
|
|
-from urllib.parse import quote, parse_qs, unquote
|
|
|
-from operator import itemgetter
|
|
|
+from decimal import Decimal
|
|
|
from itertools import groupby
|
|
|
+from operator import itemgetter
|
|
|
+from urllib.parse import quote, parse_qs, unquote
|
|
|
+
|
|
|
import boto3
|
|
|
import paypalrestsdk
|
|
|
-import datetime
|
|
|
-import logging
|
|
|
-import sys
|
|
|
-from django.http import JsonResponse, HttpResponseRedirect, HttpResponse
|
|
|
from django.db import transaction
|
|
|
+from django.db.models import Q, F, Count
|
|
|
+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
|
|
|
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
|
|
|
-from Object.AWS.S3Email import S3Email
|
|
|
from Object.AWS.AmazonS3Util import AmazonS3Util
|
|
|
+from Object.AWS.S3Email import S3Email
|
|
|
from Object.AliPayObject import AliPayObject
|
|
|
from Object.AliSmsObject import AliSmsObject
|
|
|
from Object.RedisObject import RedisObject
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
|
from Object.UidTokenObject import UidTokenObject
|
|
|
-from Service.CommonService import CommonService
|
|
|
-from Object.m3u8generate import PlaylistGenerator
|
|
|
from Object.WechatPayObject import WechatPayObject
|
|
|
-from django.db.models import Q, F, Count
|
|
|
-from Controller.PaymentCycle import Paypal
|
|
|
-from decimal import Decimal
|
|
|
+from Object.m3u8generate import PlaylistGenerator
|
|
|
+from Service.CommonService import CommonService
|
|
|
from Service.PayService import PaymentService
|
|
|
|
|
|
|
|
@@ -90,7 +93,7 @@ class CloudStorageView(View):
|
|
|
elif operation == 'queryvodlist': # 获取视频播放列表
|
|
|
return self.do_query_vod_list(request_dict, user_id, response)
|
|
|
elif operation == 'commoditylist': # 查询套餐列表
|
|
|
- return self.do_commodity_list(request_dict, response)
|
|
|
+ return self.do_commodity_list(request_dict, user_id, response)
|
|
|
elif operation == 'queryorder': # 查询订单列表
|
|
|
return self.do_query_order(request_dict, user_id, response)
|
|
|
elif operation == 'experienceorder': # 生成体验订单
|
|
@@ -157,9 +160,10 @@ class CloudStorageView(View):
|
|
|
return response.json(0, {'data': data, 'count': count})
|
|
|
|
|
|
@staticmethod
|
|
|
- def do_commodity_list(request_dict, response): # 查询套餐列表
|
|
|
+ def do_commodity_list(request_dict, user_id, response): # 查询套餐列表
|
|
|
"""
|
|
|
查询套餐列表
|
|
|
+ @param user_id: 用户id
|
|
|
@param request_dict: 请求数据
|
|
|
@request_dict mold: 存储区域类型
|
|
|
@request_dict uid: uid
|
|
@@ -203,6 +207,7 @@ class CloudStorageView(View):
|
|
|
store_list = list(store_qs)
|
|
|
store_list.sort(key=itemgetter('bucket__area'))
|
|
|
res = []
|
|
|
+ coupon_qs = '' if not user_id else CloudServiceController.get_user_coupon_list(user_id)
|
|
|
for area, items in groupby(store_list, key=itemgetter('bucket__area')):
|
|
|
items_list = list(items)
|
|
|
for item in items_list:
|
|
@@ -210,6 +215,8 @@ class CloudStorageView(View):
|
|
|
item['pay_type'] = list(pay_type_qs)
|
|
|
item['is_pay_cycle'] = 1 if item['cycle_config_id'] else 0
|
|
|
del item['cycle_config_id']
|
|
|
+ item['isCoupon'] = False if not coupon_qs or not coupon_qs.exists() else \
|
|
|
+ CloudStorageView.check_user_coupon_is_available(coupon_qs, item['id'])
|
|
|
res_c = {'area': area, 'items': items_list}
|
|
|
res.append(res_c)
|
|
|
# 是否促销
|
|
@@ -242,6 +249,27 @@ class CloudStorageView(View):
|
|
|
}
|
|
|
return response.json(0, result)
|
|
|
|
|
|
+ @staticmethod
|
|
|
+ def check_user_coupon_is_available(coupon_qs, combo_id):
|
|
|
+ """
|
|
|
+ 查看用户优惠券是否可用
|
|
|
+ @param coupon_qs: 优惠券列表
|
|
|
+ @param combo_id: 套餐id
|
|
|
+ @return:
|
|
|
+ """
|
|
|
+ if not coupon_qs.exists():
|
|
|
+ return False
|
|
|
+ result = False
|
|
|
+ for item in coupon_qs:
|
|
|
+ if result:
|
|
|
+ break
|
|
|
+ combo_list = CloudServiceController.get_combo_list(0, item['coupon_config__id'])
|
|
|
+ if not combo_list:
|
|
|
+ continue
|
|
|
+ if combo_id in combo_list:
|
|
|
+ result = True
|
|
|
+ return result
|
|
|
+
|
|
|
@staticmethod
|
|
|
def do_sign_play_m3u8(request_dict, response): # 根据sts播放m3u8 视频流
|
|
|
"""
|
|
@@ -361,7 +389,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)]
|
|
|
}
|
|
|
]
|
|
|
}
|
|
@@ -1640,7 +1668,8 @@ 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(
|
|
|
+ uid_bucket_qs = UID_Bucket.objects.filter(uid=uid, endTime__gte=now_time, channel=channel).values(
|
|
|
+ 'bucket_id').order_by(
|
|
|
'addTime')
|
|
|
if not uid_bucket_qs.exists():
|
|
|
return response.json(10030)
|