瀏覽代碼

苹果内购认证交易判断,修复bucket_id赋值问题

locky 1 年之前
父節點
當前提交
9e6b378892
共有 1 個文件被更改,包括 11 次插入4 次删除
  1. 11 4
      Controller/InAppPurchaseController.py

+ 11 - 4
Controller/InAppPurchaseController.py

@@ -6,7 +6,7 @@ import time
 import itunesiap
 from django.db.models import Q
 from django.views import View
-
+from Ansjer.config import LOGGER
 from Controller.CheckUserData import DataValid
 from Model.models import Order_Model, Store_Meal, Device_Info, UID_Bucket, Unused_Uid_Meal, AiService, Device_User, \
     SysMsgModel
@@ -29,11 +29,11 @@ class InAppPurchaseView(View):
 
     def validation(self, request_dict, request, operation):
         if operation == 'AppStoreServerNotifications':  # App Store服务器通知
-            pass
+            return self.app_store_server_notifications(request_dict)
         token_code, user_id, response = CommonService.verify_token_get_user_id(request_dict, request)
         if token_code != 0:
             return response.json(token_code)
-        if operation == 'verifyTransaction':  # 获取商品列表
+        if operation == 'verifyTransaction':  # 认证交易
             return self.verify_transaction(user_id, request_dict, response)
 
     @classmethod
@@ -51,6 +51,9 @@ class InAppPurchaseView(View):
         lang = request_dict.get('lang', 'en')
         channel = request_dict.get('channel', None)
 
+        if not all([receipt, uid, channel]):
+            return response.json(444)
+
         # redis加锁,防止订单重复
         redis_obj = RedisObject()
         redis_key = uid + 'in_app_purchase'
@@ -83,7 +86,7 @@ class InAppPurchaseView(View):
                 product_id=product_id, lang__lang=lang, is_show=0).\
                 values(
                 'id', 'currency', 'price', 'lang__content', 'day', 'commodity_type', 'lang__title', 'expire',
-                'commodity_code', 'discount_price', 'bucket__mold', 'cycle_config_id', 'is_ai')
+                'commodity_code', 'discount_price', 'bucket_id', 'bucket__mold', 'cycle_config_id', 'is_ai')
             if not store_qs.exists():
                 return response.json(173)
 
@@ -230,3 +233,7 @@ class InAppPurchaseView(View):
         sign_ms = '周视'
         ali_sms = AliSmsObject()
         ali_sms.send_code_sms_cloud(phone=phone, params=params, sign_name=sign_ms, temp_msg=temp_msg)
+
+    @staticmethod
+    def app_store_server_notifications(request_dict):
+        LOGGER.info('App Store服务器通知参数:{}'.format(request_dict))