|
@@ -6,14 +6,16 @@ import hashlib
|
|
import time
|
|
import time
|
|
import uuid
|
|
import uuid
|
|
|
|
|
|
|
|
+import paypalrestsdk
|
|
import xlrd
|
|
import xlrd
|
|
import xlwt
|
|
import xlwt
|
|
from django.db import transaction, connection
|
|
from django.db import transaction, connection
|
|
-from django.db.models import F, Sum, Count
|
|
|
|
|
|
+from django.db.models import F, Sum, Count, Q
|
|
from django.http import HttpResponse, StreamingHttpResponse
|
|
from django.http import HttpResponse, StreamingHttpResponse
|
|
from django.utils.encoding import escape_uri_path
|
|
from django.utils.encoding import escape_uri_path
|
|
from django.views.generic.base import View
|
|
from django.views.generic.base import View
|
|
|
|
|
|
|
|
+from Ansjer.config import PAYPAL_CRD
|
|
from Controller.Cron.CronTaskController import CronUpdateDataView
|
|
from Controller.Cron.CronTaskController import CronUpdateDataView
|
|
from Model.models import VodBucketModel, CDKcontextModel, Store_Meal, Order_Model, \
|
|
from Model.models import VodBucketModel, CDKcontextModel, Store_Meal, Order_Model, \
|
|
UID_Bucket, ExperienceContextModel, Lang, CloudLogModel, UidSetModel, Unused_Uid_Meal, \
|
|
UID_Bucket, ExperienceContextModel, Lang, CloudLogModel, UidSetModel, Unused_Uid_Meal, \
|
|
@@ -98,9 +100,41 @@ class serveManagement(View):
|
|
return self.deviceAttritionAlert(request_dict, response, request)
|
|
return self.deviceAttritionAlert(request_dict, response, request)
|
|
elif operation == 'deactivationPackage': # 停用套餐
|
|
elif operation == 'deactivationPackage': # 停用套餐
|
|
return self.deactivationPackage(request_dict, response)
|
|
return self.deactivationPackage(request_dict, response)
|
|
|
|
+ elif operation == 'paypal-cycle-cancel': # 取消循环扣款
|
|
|
|
+ return self.paypal_cycle_cancel(request_dict, response)
|
|
else:
|
|
else:
|
|
return response.json(404)
|
|
return response.json(404)
|
|
|
|
|
|
|
|
+ @staticmethod
|
|
|
|
+ def paypal_cycle_cancel(request_dict, response):
|
|
|
|
+ """
|
|
|
|
+ 取消云存循环扣款
|
|
|
|
+ """
|
|
|
|
+ order_id = request_dict.get('orderID', None)
|
|
|
|
+ if not order_id:
|
|
|
|
+ return response.json(444)
|
|
|
|
+ order_qs = Order_Model.objects.filter(orderID=order_id)
|
|
|
|
+ order_qs = order_qs.filter(~Q(agreement_id='')).values("agreement_id")
|
|
|
|
+ if not order_qs.exists():
|
|
|
|
+ return response.json(800)
|
|
|
|
+ paypalrestsdk.configure(PAYPAL_CRD)
|
|
|
|
+ agreement_id = order_qs[0]['agreement_id']
|
|
|
|
+ try:
|
|
|
|
+ now_time = int(time.time())
|
|
|
|
+ billing_agreement = paypalrestsdk.BillingAgreement.find(agreement_id)
|
|
|
|
+ if billing_agreement.state != 'Active':
|
|
|
|
+ Order_Model.objects.filter(agreement_id=agreement_id, updTime=now_time).update(agreement_id='')
|
|
|
|
+ return response.json(0)
|
|
|
|
+ cancel_note = {"note": "Canceling the agreement"}
|
|
|
|
+ if billing_agreement.cancel(cancel_note):
|
|
|
|
+ Order_Model.objects.filter(agreement_id=agreement_id, updTime=now_time).update(agreement_id='')
|
|
|
|
+ return response.json(0)
|
|
|
|
+ else:
|
|
|
|
+ return response.json(10052)
|
|
|
|
+ except Exception as e:
|
|
|
|
+ print(repr(e))
|
|
|
|
+ return response.json(10052)
|
|
|
|
+
|
|
def getVodBucketList(self, userID, request_dict, response):
|
|
def getVodBucketList(self, userID, request_dict, response):
|
|
# 查询存储桶数据
|
|
# 查询存储桶数据
|
|
print('request_dict: ', request_dict)
|
|
print('request_dict: ', request_dict)
|
|
@@ -688,7 +722,7 @@ class serveManagement(View):
|
|
if data['payType'] == 1:
|
|
if data['payType'] == 1:
|
|
data['trade_no'] = order['trade_no']
|
|
data['trade_no'] = order['trade_no']
|
|
else:
|
|
else:
|
|
- data['trade_no'] = ''
|
|
|
|
|
|
+ data['trade_no'] = 'N/A'
|
|
order_list.append(data)
|
|
order_list.append(data)
|
|
return response.json(
|
|
return response.json(
|
|
0, {'list': order_list, 'total': count})
|
|
0, {'list': order_list, 'total': count})
|