|
@@ -48,7 +48,6 @@ from Service.PayService import PaymentService
|
|
|
from Service.VodHlsService import SplitVodHlsObject
|
|
|
from Object.ApplePayObject import ApplePayObject
|
|
|
from Object.UnionPayObject import UnionPayObject
|
|
|
-from Object.AppleInAppPurchaseSubscriptionObject import InAppSubscription
|
|
|
|
|
|
ssl._create_default_https_context = ssl._create_unverified_context
|
|
|
LOGGER = logging.getLogger('info')
|
|
@@ -245,10 +244,10 @@ class CloudStorageView(View):
|
|
|
"517J385BNUGP3CPP111A"] and CONFIG_INFO == CONFIG_TEST:
|
|
|
store_qs = store_qs.exclude(id=88)
|
|
|
elif uid not in ["VXJ267WU5NZ1S89H111A", "18SM4J9DYWB2AEG1111A",
|
|
|
- "517J385BNUGP3CPP111A"] and CONFIG_INFO == CONFIG_US:
|
|
|
+ "517J385BNUGP3CPP111A"] and CONFIG_INFO == CONFIG_US:
|
|
|
store_qs = store_qs.exclude(id=34)
|
|
|
elif uid not in ["VXJ267WU5NZ1S89H111A", "18SM4J9DYWB2AEG1111A",
|
|
|
- "517J385BNUGP3CPP111A"] and CONFIG_INFO == CONFIG_EUR:
|
|
|
+ "517J385BNUGP3CPP111A"] and CONFIG_INFO == CONFIG_EUR:
|
|
|
store_qs = store_qs.exclude(id=34)
|
|
|
else:
|
|
|
is_ai = uid_set_qs[0]['is_ai']
|
|
@@ -1684,40 +1683,7 @@ class CloudStorageView(View):
|
|
|
elif pay_type == 5:
|
|
|
# 内购订阅型订单 之前订阅过任意套餐返回不可再次订阅
|
|
|
if store_qs[0]['cycle_config_id']:
|
|
|
- # 检查Paypal订阅
|
|
|
- check_subscribe_Paypal = Paypal.checkSubscriptions(user_id, uid, rank)
|
|
|
- # 查设备是否有绑定套餐
|
|
|
- device_apple_package_qs = DeviceApplePackage.objects.filter(userID=user_id, uid=uid).values(
|
|
|
- "package_id__product_id", "package_id__subscription_group_id")
|
|
|
- if device_apple_package_qs.exists():
|
|
|
- product_id = device_apple_package_qs[0]["package_id__product_id"]
|
|
|
- subscription_group_id = device_apple_package_qs[0]["package_id__subscription_group_id"]
|
|
|
- # 检查内购订阅
|
|
|
- in_app_subscription = InAppSubscription()
|
|
|
- check_subscribe_InApp = in_app_subscription.check_subscriptions(uid, subscription_group_id)
|
|
|
- if not check_subscribe_Paypal or check_subscribe_InApp:
|
|
|
- logger.info(f'设备订阅过套餐Paypal:{not check_subscribe_Paypal}, AppleInApp:{check_subscribe_InApp}')
|
|
|
- return response.json(10050)
|
|
|
- else:
|
|
|
- # 查询所有符合条件的订阅套餐的 id 列表
|
|
|
- package_list = InAppPurchasePackage.objects.filter(is_ai=is_ai, package_type=1).values_list("id", flat=True)
|
|
|
- # 查询用户和设备已绑定的套餐 id 列表
|
|
|
- bound_packages = DeviceApplePackage.objects.filter(userID=user_id).values_list("package_id", flat=True)
|
|
|
- # 找到未绑定的套餐 id
|
|
|
- unbound_packages = set(package_list) - set(bound_packages)
|
|
|
- if not unbound_packages:
|
|
|
- return response.json(10050)
|
|
|
- # 选择一个未绑定的套餐 id
|
|
|
- package_id = unbound_packages.pop()
|
|
|
- # 绑定一个套餐
|
|
|
- DeviceApplePackage.objects.create(
|
|
|
- userID=user_id,
|
|
|
- uid=uid,
|
|
|
- package_id_id=package_id,
|
|
|
- created_time=int(time.time()),
|
|
|
- update_time=int(time.time())
|
|
|
- )
|
|
|
- product_id = InAppPurchasePackage.objects.filter(id=package_id).values("product_id")[0]["product_id"]
|
|
|
+ return response.json(173)
|
|
|
else:
|
|
|
product_id = InAppPurchasePackage.objects.filter(rank_id=rank).values("product_id")[0]["product_id"]
|
|
|
|