ソースを参照

Merge branch 'lang' into cloud_storage_dev

lang 3 年 前
コミット
7f8ac7dd81
3 ファイル変更20 行追加13 行削除
  1. 1 1
      Controller/CloudStorage.py
  2. 15 8
      Controller/PaymentCycle.py
  3. 4 4
      Controller/UserController.py

+ 1 - 1
Controller/CloudStorage.py

@@ -1879,7 +1879,7 @@ def deleteVodHls(request):
 
     response = ResponseObject()
     i = int(request.GET.get('i', 5))
-    nowTime = int(time.time())
+    nowTime = int(time.time()) - 3 * 30 * 24 * 60 * 60  # 保留3个月的数据
     for i in range(i):
         vh_qs = VodHlsModel.objects.filter(endTime__lte=str(nowTime))[0:10000]
         id_list = vh_qs.values_list("id", flat=True)

+ 15 - 8
Controller/PaymentCycle.py

@@ -70,6 +70,7 @@ class Paypal:
             billing_plan.activate()  # 激活
             plan_id = billing_plan.id
         else:
+            print(billing_plan.error)
             return False
 
         now_time = int(time.time())
@@ -92,7 +93,6 @@ class Paypal:
         if billing_agreement.create():
             for link in billing_agreement.links:
                 if link.rel == "approval_url":
-                    print("-------------------")
                     return {"plan_id": plan_id, "url": link.href}
         else:
             print(billing_agreement.error)
@@ -118,22 +118,26 @@ class PaypalCycleNotify(View):
         elif operation == 'paypalCycleNotify':  # paypal 周期付款回调
             return self.do_paypal_webhook_notify(request_dict, response)
     def do_paypal_cycle_return(self, request_dict, response):
-        paymentId = request_dict.get('paymentId', None)
-        PayerID = request_dict.get('PayerID', None)
         lang = request_dict.get('lang', 'en')
         token = request_dict.get('token',None)
         paypalrestsdk.configure(PAYPAL_CRD)
         billing_agreement = paypalrestsdk.BillingAgreement()
-        billing_agreement_response = billing_agreement.execute("EC-93848356GS252673L")
+        billing_agreement_response = billing_agreement.execute(token)
         if billing_agreement_response.error:
-            return False
+            print(billing_agreement_response.error)
+            red_url = "{SERVER_DOMAIN_SSL}web/paid2/fail.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
+            if lang != 'cn':
+                red_url = "{SERVER_DOMAIN_SSL}web/paid2/en_fail.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
+            return HttpResponseRedirect(red_url)
 
         orderID = billing_agreement_response.description
         agreement_id = billing_agreement_response.id
+        promotion_rule_id = ''
         try:
             order_qs = Order_Model.objects.filter(orderID=orderID, status=0)
 
             if not orderID:
+                print("not orderID")
                 red_url = "{SERVER_DOMAIN_SSL}web/paid2/fail.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
                 if lang != 'cn':
                     red_url = "{SERVER_DOMAIN_SSL}web/paid2/en_fail.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
@@ -151,7 +155,11 @@ class PaypalCycleNotify(View):
                 values("day", "bucket_id", "bucket__storeDay", "expire")
             bucketId = smqs[0]['bucket_id']
             if not smqs.exists():
-                return response.json(173)
+                print("not smqs")
+                red_url = "{SERVER_DOMAIN_SSL}web/paid2/fail.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
+                if lang != 'cn':
+                    red_url = "{SERVER_DOMAIN_SSL}web/paid2/en_fail.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
+                return HttpResponseRedirect(red_url)
             # ##
             ubqs = UID_Bucket.objects.filter(uid=UID).values("id", "bucket_id", "bucket__storeDay", "bucket__region",
                                                              "endTime", "use_status")
@@ -163,7 +171,6 @@ class PaypalCycleNotify(View):
             nowTime = int(time.time())
             promotion = PromotionRuleModel.objects.filter(status=1, startTime__lte=nowTime,
                                                           endTime__gte=nowTime).values('id','ruleConfig')
-            promotion_rule_id = ''
             if promotion.exists():
                 promotion_rule_id = promotion[0]['id']
                 expire = expire * 2
@@ -217,7 +224,7 @@ class PaypalCycleNotify(View):
                                      'Dear customer,you already subscribed the cloud storage package successfully for device ' + UID + ' on ' + time.strftime(
                                          "%b %dth,%Y", time.localtime())]
 
-                CloudStorage.CloudStorageView.do_vod_msg_Notice(UID, channel, userid, lang, sys_msg_text_list, 'SMS_219738485')
+                CloudStorage.CloudStorageView.do_vod_msg_Notice(self, UID, channel, userid, lang, sys_msg_text_list, 'SMS_219738485')
 
                 # return response.json(0)
                 red_url = "{SERVER_DOMAIN_SSL}web/paid2/success.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)

+ 4 - 4
Controller/UserController.py

@@ -2849,10 +2849,10 @@ class alexaUidView(TemplateView):
             uid_dict = {}
             uid_list = []
             for uid_q in uid_qs:
-                # 追加
-                uid_list.append(uid_q['UID'])
-                # 给uid_q['UID']赋值
-                uid_dict[uid_q['UID']] = {'nick': uid_q['NickName'], 'password': uid_q['View_Password']}
+                # uid转大写
+                UID = uid_q['UID'].upper()
+                uid_list.append(UID)
+                uid_dict[UID] = {'nick': uid_q['NickName'], 'password': uid_q['View_Password']}
 
             us_qs = UidSetModel.objects.filter(uid__in=uid_list, is_alexa=1).values('id', 'uid', 'region_alexa', 'channel')
             if not us_qs.exists():