|  | @@ -19,6 +19,8 @@ import boto3
 | 
	
		
			
				|  |  |  import oss2
 | 
	
		
			
				|  |  |  import paypalrestsdk
 | 
	
		
			
				|  |  |  import threading
 | 
	
		
			
				|  |  | +import calendar
 | 
	
		
			
				|  |  | +import datetime
 | 
	
		
			
				|  |  |  from aliyunsdkcore import client
 | 
	
		
			
				|  |  |  from aliyunsdksts.request.v20150401 import AssumeRoleRequest
 | 
	
		
			
				|  |  |  from boto3.session import Session
 | 
	
	
		
			
				|  | @@ -112,6 +114,8 @@ class CloudStorageView(View):
 | 
	
		
			
				|  |  |                  return self.do_experience_order(request_dict, userID, response)
 | 
	
		
			
				|  |  |              elif operation == 'experiencereset':
 | 
	
		
			
				|  |  |                  return self.do_experience_reset(request_dict, userID, response)
 | 
	
		
			
				|  |  | +            elif operation == 'deletevodlist':
 | 
	
		
			
				|  |  | +                return self.deleteVodList(request_dict, response)
 | 
	
		
			
				|  |  |              else:
 | 
	
		
			
				|  |  |                  return response.json(414)
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -196,7 +200,7 @@ class CloudStorageView(View):
 | 
	
		
			
				|  |  |          qs = qs.values("id", "title", "content", "price",
 | 
	
		
			
				|  |  |                         "day", "currency", "bucket__storeDay",
 | 
	
		
			
				|  |  |                         "bucket__bucket", "bucket__area",
 | 
	
		
			
				|  |  | -                      "commodity_code", "commodity_type")
 | 
	
		
			
				|  |  | +                      "commodity_code", "commodity_type", "is_discounts", "virtual_price", "expire")
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if qs.exists():
 | 
	
		
			
				|  |  |              ql = list(qs)
 | 
	
	
		
			
				|  | @@ -422,7 +426,7 @@ class CloudStorageView(View):
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  print(Policy)
 | 
	
		
			
				|  |  |                  response = boto3_sts.get_federation_token(
 | 
	
		
			
				|  |  | -                    Name='{role_name}'.format(role_name=uid + '_' + channel),
 | 
	
		
			
				|  |  | +                    Name='{role_name}'.format(role_name=uid + '_' + str(channel)),
 | 
	
		
			
				|  |  |                      Policy=json.dumps(Policy),
 | 
	
		
			
				|  |  |                      DurationSeconds=7200
 | 
	
		
			
				|  |  |                  )
 | 
	
	
		
			
				|  | @@ -449,8 +453,9 @@ class CloudStorageView(View):
 | 
	
		
			
				|  |  |                  return JsonResponse(status=200, data=res)
 | 
	
		
			
				|  |  |              else:
 | 
	
		
			
				|  |  |                  res = {'code': 404, 'msg': 'data not exists!'}
 | 
	
		
			
				|  |  | -                return HttpResponse(json.dumps(res, ensure_ascii=False),
 | 
	
		
			
				|  |  | -                                    content_type="application/json,charset=utf-8")
 | 
	
		
			
				|  |  | +                return HttpResponse(json.dumps(res, ensure_ascii=False),content_type="application/json,charset=utf-8")
 | 
	
		
			
				|  |  | +        res = {'code': 405, 'msg': 'Not purchased or expired!'}
 | 
	
		
			
				|  |  | +        return HttpResponse(json.dumps(res, ensure_ascii=False),content_type="application/json,charset=utf-8")
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      def do_query_vod_list(self, request_dict, userID, response):
 | 
	
		
			
				|  |  |          startTime = int(request_dict.get('startTime', None))
 | 
	
	
		
			
				|  | @@ -465,7 +470,7 @@ class CloudStorageView(View):
 | 
	
		
			
				|  |  |          now_time = int(time.time())
 | 
	
		
			
				|  |  |          vh_qs = VodHlsModel.objects.filter \
 | 
	
		
			
				|  |  |              ( uid=uid, channel=channel, time__range=(startTime, endTime), endTime__gte=now_time). \
 | 
	
		
			
				|  |  | -            values("time", "sec", "bucket__bucket", "fg", "bucket__endpoint", "bucket__region", "bucket__mold")
 | 
	
		
			
				|  |  | +            values("id", "time", "sec", "bucket__bucket", "fg", "bucket__endpoint", "bucket__region", "bucket__mold")
 | 
	
		
			
				|  |  |          vod_play_list = []
 | 
	
		
			
				|  |  |          print(int(time.time()))
 | 
	
		
			
				|  |  |          for vod in vh_qs:
 | 
	
	
		
			
				|  | @@ -488,7 +493,8 @@ class CloudStorageView(View):
 | 
	
		
			
				|  |  |                      format(url_start=url_start, url_end=url_end)
 | 
	
		
			
				|  |  |                  thumb = bucket.sign_url('GET', ts, 3600,
 | 
	
		
			
				|  |  |                                          params={'x-oss-process': 'video/snapshot,t_10000,m_fast,w_300'})
 | 
	
		
			
				|  |  | -                vod_play_list.append({'name': vod['time'], 'sign_url': vod_play_url, 'thumb': thumb, 'sec': vod['sec']})
 | 
	
		
			
				|  |  | +                vod_play_list.append({'name': vod['time'], 'sign_url': vod_play_url,
 | 
	
		
			
				|  |  | +                                      'thumb': thumb, 'sec': vod['sec'], 'vod_id': vod['id']})
 | 
	
		
			
				|  |  |              elif bucket__mold == 1:
 | 
	
		
			
				|  |  |                  # aws_access_key_id = 'AKIA2E67UIMD45Y3HL53'
 | 
	
		
			
				|  |  |                  # aws_secret_access_key = 'ckYLg4Lo9ZXJIcJEAKkzf2rWvs8Xth1FCjqiAqUw'
 | 
	
	
		
			
				|  | @@ -521,7 +527,9 @@ class CloudStorageView(View):
 | 
	
		
			
				|  |  |                      'sign_url': vod_url,
 | 
	
		
			
				|  |  |                      # 'thumb': thumb_url,
 | 
	
		
			
				|  |  |                      'sec': vod['sec'],
 | 
	
		
			
				|  |  | -                    'ts_num' : ts_num}),
 | 
	
		
			
				|  |  | +                    'ts_num' : ts_num,
 | 
	
		
			
				|  |  | +                    'vod_id': vod['id']
 | 
	
		
			
				|  |  | +                }),
 | 
	
		
			
				|  |  |          return response.json(0, vod_play_list)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      def do_store_playlist(self, request_dict, response):
 | 
	
	
		
			
				|  | @@ -883,32 +891,32 @@ class CloudStorageView(View):
 | 
	
		
			
				|  |  |          print("Payment execute successfully")
 | 
	
		
			
				|  |  |          order_qs = Order_Model.objects.filter(orderID=orderID)
 | 
	
		
			
				|  |  |          nowTime = int(time.time())
 | 
	
		
			
				|  |  | -        order_list = order_qs.values("UID", "channel", "commodity_code")
 | 
	
		
			
				|  |  | +        order_list = order_qs.values("UID", "channel", "commodity_code", "rank")
 | 
	
		
			
				|  |  |          UID = order_list[0]['UID']
 | 
	
		
			
				|  |  |          channel = order_list[0]['channel']
 | 
	
		
			
				|  |  | -        commodity_code = order_list[0]['commodity_code']
 | 
	
		
			
				|  |  | -        smqs = Store_Meal.objects.filter(commodity_code=commodity_code). \
 | 
	
		
			
				|  |  | -            values("day", "bucket_id", "bucket__storeDay")
 | 
	
		
			
				|  |  | +        rank = order_list[0]['rank']
 | 
	
		
			
				|  |  | +        smqs = Store_Meal.objects.filter(id=rank). \
 | 
	
		
			
				|  |  | +            values("day", "bucket_id", "bucket__storeDay", "expire")
 | 
	
		
			
				|  |  |          bucketId = smqs[0]['bucket_id']
 | 
	
		
			
				|  |  |          if not smqs.exists():
 | 
	
		
			
				|  |  |              return response.json(0, '套餐已删除')
 | 
	
		
			
				|  |  | -        addTime = int(smqs[0]["day"]) * 24 * 3600
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          # ##
 | 
	
		
			
				|  |  | -        ubqs = UID_Bucket.objects.filter(uid=UID, channel=channel, endTime__gte=nowTime). \
 | 
	
		
			
				|  |  | +        ubqs = UID_Bucket.objects.filter(bucket__id=bucketId, uid=UID, channel=channel, endTime__gte=nowTime). \
 | 
	
		
			
				|  |  |              values("bucket__storeDay", "bucket__region", "endTime")
 | 
	
		
			
				|  |  |          if ubqs.exists():
 | 
	
		
			
				|  |  |              ubqs_count = ubqs.count()
 | 
	
		
			
				|  |  |              print(ubqs_count)
 | 
	
		
			
				|  |  |              ubq = ubqs[ubqs_count - 1]
 | 
	
		
			
				|  |  | -            print(ubq)
 | 
	
		
			
				|  |  | -            new_starTime = ubq['endTime'] + 1
 | 
	
		
			
				|  |  | -            ub_cqs = UID_Bucket.objects.create \
 | 
	
		
			
				|  |  | +            endTime = CommonService.calcMonthLater(smqs[0]['expire'],ubq['endTime'])
 | 
	
		
			
				|  |  | +            ub_cqs = ubqs.update \
 | 
	
		
			
				|  |  |                  (uid=UID, channel=channel, bucket_id=bucketId,
 | 
	
		
			
				|  |  | -                 endTime=new_starTime + addTime)
 | 
	
		
			
				|  |  | +                 endTime=endTime)
 | 
	
		
			
				|  |  |              uid_bucket_id = ub_cqs.id
 | 
	
		
			
				|  |  |          else:
 | 
	
		
			
				|  |  | +            endTime = CommonService.calcMonthLater(smqs[0]['expire'])
 | 
	
		
			
				|  |  |              ub_cqs = UID_Bucket.objects.create \
 | 
	
		
			
				|  |  | -                (uid=UID, channel=channel, bucket_id=bucketId, endTime=nowTime + addTime)
 | 
	
		
			
				|  |  | +                (uid=UID, channel=channel, bucket_id=bucketId, endTime=endTime)
 | 
	
		
			
				|  |  |              uid_bucket_id = ub_cqs.id
 | 
	
		
			
				|  |  |          order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id)
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -963,23 +971,23 @@ class CloudStorageView(View):
 | 
	
		
			
				|  |  |      def do_create_pay_order(self, request_dict, userID, response):
 | 
	
		
			
				|  |  |          uid = request_dict.get('uid', None)
 | 
	
		
			
				|  |  |          channel = request_dict.get('channel', None)
 | 
	
		
			
				|  |  | -        commodity_code = request_dict.get('commodity_code', None)
 | 
	
		
			
				|  |  |          pay_type = int(request_dict.get('pay_type', None))
 | 
	
		
			
				|  |  |          rank = request_dict.get('rank', None)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        if not uid or not channel or not commodity_code or not rank:
 | 
	
		
			
				|  |  | +        if not uid or not channel or not pay_type or not rank:
 | 
	
		
			
				|  |  |              return response.json(13, '参数有误.')
 | 
	
		
			
				|  |  |          dv_qs = Device_Info.objects.filter(userID_id=userID, UID=uid, isShare=False, isExist=1)
 | 
	
		
			
				|  |  |          if not dv_qs.exists():
 | 
	
		
			
				|  |  |              return response.json(12)
 | 
	
		
			
				|  |  | -        smqs = Store_Meal.objects.filter(commodity_code=commodity_code, pay_type=pay_type). \
 | 
	
		
			
				|  |  | -            values('currency', 'price', 'content', 'day', 'commodity_type', 'title', 'content')
 | 
	
		
			
				|  |  | +        smqs = Store_Meal.objects.filter(id=rank, pay_type=pay_type). \
 | 
	
		
			
				|  |  | +            values('currency', 'price', 'content', 'day', 'commodity_type', 'title', 'content', 'expire', 'commodity_code')
 | 
	
		
			
				|  |  |          if not smqs.exists():
 | 
	
		
			
				|  |  |              return response.json(10, '套餐不存在')
 | 
	
		
			
				|  |  |          currency = smqs[0]['currency']
 | 
	
		
			
				|  |  |          price = smqs[0]['price']
 | 
	
		
			
				|  |  |          content = smqs[0]['content']
 | 
	
		
			
				|  |  |          day = smqs[0]['day']
 | 
	
		
			
				|  |  | +        commodity_code = smqs[0]['commodity_code']
 | 
	
		
			
				|  |  |          commodity_type = smqs[0]['commodity_type']
 | 
	
		
			
				|  |  |          # ubqs = UID_Bucket.objects.filter(uid=uid, channel=channel, endTime__gte=nowTime). \
 | 
	
		
			
				|  |  |          #     values("bucket__storeDay", "bucket__region", "endTime")
 | 
	
	
		
			
				|  | @@ -1018,7 +1026,7 @@ class CloudStorageView(View):
 | 
	
		
			
				|  |  |                      Order_Model.objects.create(orderID=orderID, UID=uid, channel=channel, userID_id=userID,
 | 
	
		
			
				|  |  |                                                 desc=content, payType=pay_type, payTime=nowTime,
 | 
	
		
			
				|  |  |                                                 price=price, currency=currency, addTime=nowTime, updTime=nowTime,
 | 
	
		
			
				|  |  | -                                               endTime=(nowTime + int(day) * 3600 * 24), pay_url=approval_url,
 | 
	
		
			
				|  |  | +                                               pay_url=approval_url,
 | 
	
		
			
				|  |  |                                                 commodity_code=commodity_code, commodity_type=commodity_type,rank_id=rank)
 | 
	
		
			
				|  |  |                      return response.json(0, {"redirectUrl": approval_url, "orderID": orderID})
 | 
	
		
			
				|  |  |              return response.json(10, 'generate_order_false')
 | 
	
	
		
			
				|  | @@ -1048,7 +1056,7 @@ class CloudStorageView(View):
 | 
	
		
			
				|  |  |                      Order_Model.objects.create(orderID=orderID, UID=uid, channel=channel, userID_id=userID,
 | 
	
		
			
				|  |  |                                                 desc=content, payType=pay_type, payTime=nowTime,
 | 
	
		
			
				|  |  |                                                 price=price, currency=currency, addTime=nowTime, updTime=nowTime,
 | 
	
		
			
				|  |  | -                                               endTime=(nowTime + int(day) * 3600 * 24), pay_url=redirectUrl,
 | 
	
		
			
				|  |  | +                                               pay_url=redirectUrl,
 | 
	
		
			
				|  |  |                                                 commodity_code=commodity_code, commodity_type=commodity_type,rank_id=rank)
 | 
	
		
			
				|  |  |                      return JsonResponse(status=200, data={'result_code': 0, 'reason': 'success',
 | 
	
		
			
				|  |  |                                                            'result': {"redirectUrl": redirectUrl, "orderID": orderID},
 | 
	
	
		
			
				|  | @@ -1075,7 +1083,7 @@ class CloudStorageView(View):
 | 
	
		
			
				|  |  |              Order_Model.objects.create(orderID=orderID, UID=uid, channel=channel, userID_id=userID,
 | 
	
		
			
				|  |  |                                         desc=content, payType=pay_type, payTime=nowTime,
 | 
	
		
			
				|  |  |                                         price=price, currency=currency, addTime=nowTime, updTime=nowTime,
 | 
	
		
			
				|  |  | -                                       endTime=(nowTime + int(day) * 3600 * 24), pay_url=notify_url,
 | 
	
		
			
				|  |  | +                                       pay_url=notify_url,
 | 
	
		
			
				|  |  |                                         commodity_code=commodity_code, commodity_type=commodity_type,rank_id=rank)
 | 
	
		
			
				|  |  |              return JsonResponse(status=200, data={'result_code': 0, 'reason': 'success',
 | 
	
		
			
				|  |  |                                                    'result': response,
 | 
	
	
		
			
				|  | @@ -1117,7 +1125,7 @@ class CloudStorageView(View):
 | 
	
		
			
				|  |  |          Order_Model.objects.create(orderID=orderID, UID=uid, channel=channel, userID_id=userID,
 | 
	
		
			
				|  |  |                                     desc=content, payType=pay_type, payTime=nowTime,
 | 
	
		
			
				|  |  |                                     price=price, currency=currency, addTime=nowTime, updTime=nowTime,
 | 
	
		
			
				|  |  | -                                   endTime=(nowTime + int(day) * 3600 * 24), pay_url="体验版",
 | 
	
		
			
				|  |  | +                                   pay_url="体验版",
 | 
	
		
			
				|  |  |                                     commodity_code=commodity_code, commodity_type=commodity_type,
 | 
	
		
			
				|  |  |                                     rank_id=rank)
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1187,23 +1195,43 @@ class CloudStorageView(View):
 | 
	
		
			
				|  |  |          return response.json(0,'重置云存体验成功')
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    def deleteVodList(self, request_dict, response):
 | 
	
		
			
				|  |  | +        uid = request_dict.get('uid',None)
 | 
	
		
			
				|  |  | +        vod_id_list = json.loads(request_dict.get('vod_id_list', None))
 | 
	
		
			
				|  |  | +        is_del_all = request_dict.get('is_del_all',0)
 | 
	
		
			
				|  |  | +        try:
 | 
	
		
			
				|  |  | +            if is_del_all == 1:
 | 
	
		
			
				|  |  | +                VodHlsModel.objects.filter(uid=uid).delete()
 | 
	
		
			
				|  |  | +            else:
 | 
	
		
			
				|  |  | +                if type(vod_id_list).__name__ != 'list':
 | 
	
		
			
				|  |  | +                    return response.json(424, 'vod_id_list格式错误')
 | 
	
		
			
				|  |  | +                VodHlsModel.objects.filter(id__in=vod_id_list).delete()
 | 
	
		
			
				|  |  | +        except Exception as e:
 | 
	
		
			
				|  |  | +            return response.json(424, repr(e))
 | 
	
		
			
				|  |  | +        else:
 | 
	
		
			
				|  |  | +            return response.json(0, '删除成功.')
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  def deleteVodHls(request):
 | 
	
		
			
				|  |  | -    UID = 'DSXG7481JVA2JM94111A'
 | 
	
		
			
				|  |  | -    channel = 1
 | 
	
		
			
				|  |  | -    ubqs = UID_Bucket.objects.filter(uid=UID, channel=channel). \
 | 
	
		
			
				|  |  | -        values("bucket_id", "endTime", "bucket__storeDay")
 | 
	
		
			
				|  |  | -    nowTime = int(time.time())
 | 
	
		
			
				|  |  | -    if ubqs.exists():
 | 
	
		
			
				|  |  | -        ubqs_count = ubqs.count()
 | 
	
		
			
				|  |  | -        ubq = ubqs[ubqs_count - 1, ubqs_count]
 | 
	
		
			
				|  |  | -        new_starTime = ubq['endTime'] + 1
 | 
	
		
			
				|  |  | -        print(new_starTime)
 | 
	
		
			
				|  |  | -        exit()
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        # ub_cqs = UID_Bucket.objects.create(uid=UID, channel=channel, bucket_id=bucketId,
 | 
	
		
			
				|  |  | -        #                                    endTime=new_starTime + addTime)
 | 
	
		
			
				|  |  | -        # uid_bucket_id = ub_cqs.id
 | 
	
		
			
				|  |  | -    exit()
 | 
	
		
			
				|  |  | +    # UID = 'DSXG7481JVA2JM94111A'
 | 
	
		
			
				|  |  | +    # channel = 1
 | 
	
		
			
				|  |  | +    # ubqs = UID_Bucket.objects.filter(uid=UID, channel=channel). \
 | 
	
		
			
				|  |  | +    #     values("bucket_id", "endTime", "bucket__storeDay")
 | 
	
		
			
				|  |  | +    # nowTime = int(time.time())
 | 
	
		
			
				|  |  | +    # if ubqs.exists():
 | 
	
		
			
				|  |  | +    #     ubqs_count = ubqs.count()
 | 
	
		
			
				|  |  | +    #     ubq = ubqs[ubqs_count - 1, ubqs_count]
 | 
	
		
			
				|  |  | +    #     new_starTime = ubq['endTime'] + 1
 | 
	
		
			
				|  |  | +    #     print(new_starTime)
 | 
	
		
			
				|  |  | +    #     exit()
 | 
	
		
			
				|  |  | +    #
 | 
	
		
			
				|  |  | +    #     # ub_cqs = UID_Bucket.objects.create(uid=UID, channel=channel, bucket_id=bucketId,
 | 
	
		
			
				|  |  | +    #     #                                    endTime=new_starTime + addTime)
 | 
	
		
			
				|  |  | +    #     # uid_bucket_id = ub_cqs.id
 | 
	
		
			
				|  |  | +    # exit()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      response = ResponseObject()
 | 
	
		
			
				|  |  |      i = int(request.GET.get('i', 5))
 |