Browse Source

PayPal和苹果内购检查是否云服务代理订单

locky 2 months ago
parent
commit
23d6ce02ad
2 changed files with 37 additions and 3 deletions
  1. 19 1
      Controller/InAppPurchaseController.py
  2. 18 2
      Controller/PaymentCycle.py

+ 19 - 1
Controller/InAppPurchaseController.py

@@ -24,6 +24,7 @@ from appstoreserverlibrary.receipt_utility import ReceiptUtility
 from django.views import View
 from django.http import HttpResponse
 
+from AdminController.CloudServiceManage.AgentOrderController import AgentOrderView
 from Ansjer.config import LOGGER, CONFIG_INFO, CONFIG_TEST, PAY_TYPE_IN_APP_PURCHASE, BASE_DIR, CONFIG_US
 from Controller.CheckUserData import DataValid
 from Model.models import Order_Model, Store_Meal, Device_Info, UID_Bucket, Unused_Uid_Meal, AiService, Device_User, \
@@ -261,6 +262,12 @@ class InAppPurchaseView(View):
                                    args=(uid, user_id, lang, sys_msg_text_list))
             asy.start()
 
+            # 检查是否云服务代理订单
+            check_thread = threading.Thread(
+                target=AgentOrderView.check_agent_service_package, args=(order_id, uid, order_qs[0]['rank_id'])
+            )
+            check_thread.start()
+
             redis_obj.del_data(redis_key)
             pay_result_url = CommonService.get_payment_status_url(lang, 'success')
 
@@ -540,6 +547,12 @@ class InAppPurchaseView(View):
                 order.original_transaction_id = original_transaction_id
                 order.save()
 
+                # 检查是否云服务代理订单
+                check_thread = threading.Thread(
+                    target=AgentOrderView.check_agent_service_package, args=(order_id, uid, ord_order[0]["rank_id"])
+                )
+                check_thread.start()
+
                 # 构建云存套餐消息
                 sys_msg_text_list = cls.cloud_storage_message(uid)
                 cls.do_vod_msg_notice(uid, user_id, lang, sys_msg_text_list)
@@ -636,9 +649,14 @@ class InAppPurchaseView(View):
                     DeviceApplePackage.objects.filter(userID=user_id, uid=uid).update(subscription_status=1,
                                                                                       update_time=int(time.time()))
 
+                    # 检查是否云服务代理订单
+                    check_thread = threading.Thread(
+                        target=AgentOrderView.check_agent_service_package, args=(order_id, uid, ord_order[0]["rank_id"])
+                    )
+                    check_thread.start()
+
                     # 构建云存套餐消息
                     sys_msg_text_list = cls.cloud_storage_message(uid)
-
                     cls.do_vod_msg_notice(uid, user_id, lang, sys_msg_text_list)
                 return HttpResponse(status=200)
 

+ 18 - 2
Controller/PaymentCycle.py

@@ -1,6 +1,7 @@
 import datetime as date_time
 import json
 import logging
+import threading
 import time
 import traceback
 
@@ -10,6 +11,7 @@ from django.db.models import Q, F
 from django.http import HttpResponseRedirect, HttpResponse
 from django.views.generic.base import View
 
+from AdminController.CloudServiceManage.AgentOrderController import AgentOrderView
 from Ansjer.config import PAYPAL_CRD, SERVER_DOMAIN_SSL, PAYPAL_WEB_HOOK_ID, CONFIG_INFO, \
     CONFIG_US, CONFIG_EUR
 from Controller import CloudStorage
@@ -436,7 +438,7 @@ class PaypalCycleNotify(View):
                     order_qs = Order_Model.objects.filter(paymentID=paymentID).values('UID', 'userID__region_country',
                                                                                       'create_vod', 'orderID',
                                                                                       'channel', 'rank__is_ai',
-                                                                                      'rank__expire',
+                                                                                      'rank__expire', 'rank_id',
                                                                                       'rank__bucket__id',
                                                                                       'isSelectDiscounts',
                                                                                       'userID__username',
@@ -451,6 +453,14 @@ class PaypalCycleNotify(View):
                     if not self.config_match_region(uid, country_id):
                         return HttpResponse('Fail', status=500)
 
+                    # 检查是否云服务代理订单
+                    order_id = order_qs[0]['orderID']
+                    rank = order_qs[0]['rank_id']
+                    check_thread = threading.Thread(
+                        target=AgentOrderView.check_agent_service_package, args=(order_id, uid, rank)
+                    )
+                    check_thread.start()
+
                     if order_qs[0]['create_vod']:
                         order_qs.update(status=1, trade_no=paypal_transaction_id, updTime=nowTime, fee=fee)
                     else:
@@ -462,7 +472,6 @@ class PaypalCycleNotify(View):
                         bucketId = order_qs[0]['rank__bucket__id']
                         userid = order_qs[0]['userID__userID']
                         username = order_qs[0]['userID__username']
-                        order_id = order_qs[0]['orderID']
                         coupon_id = order_qs[0]['coupon_id']
                         promotion = PromotionRuleModel.objects.filter(status=1, startTime__lte=nowTime,
                                                                       endTime__gte=nowTime).values('id', 'ruleConfig')
@@ -668,6 +677,13 @@ class PaypalCycleNotify(View):
                 # 记录新订单号和更新状态
                 PaypalWebHookEvent.objects.filter(id=paypal_webhook_event_qs.id).update(newOrderID=orderID,
                                                                                         update_status=update_status)
+
+                # 检查是否云服务代理订单
+                check_thread = threading.Thread(
+                    target=AgentOrderView.check_agent_service_package, args=(orderID, UID, rank)
+                )
+                check_thread.start()
+
                 PAY_LOGGER.info('{} PayPal周期扣款成功'.format(UID))
                 return HttpResponse('success')
         except Exception as e: