Преглед на файлове

更新检查是否有自动续费

lang преди 3 години
родител
ревизия
4fa6c597de
променени са 1 файла, в които са добавени 3 реда и са изтрити 2 реда
  1. 3 2
      Controller/PaymentCycle.py

+ 3 - 2
Controller/PaymentCycle.py

@@ -24,8 +24,9 @@ from paypalrestsdk import BillingPlan
 class Paypal:
     #检查是否有重复订阅
     def checkSubscriptions(userID,uid,rank):
-        hasOrder = Order_Model.objects.filter(userID=userID,UID=uid,rank=rank).values('agreement_id','orderID').order_by('addTime')[0:1]
-        if not hasOrder.exists() or hasOrder[0]['agreement_id'] == '':
+        hasOrder = Order_Model.objects.filter(UID=uid,rank=rank)
+        hasOrder = hasOrder.filter(~Q(agreement_id='')).values('agreement_id','orderID').order_by('addTime')[0:1]
+        if not hasOrder.exists():
             return True
         paypalrestsdk.configure(PAYPAL_CRD)
         billing_agreement = paypalrestsdk.BillingAgreement.find(hasOrder[0]['agreement_id'])