Эх сурвалжийг харах

更新检查是否有自动续费

lang 3 жил өмнө
parent
commit
4fa6c597de

+ 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'])