From 7ad5bc8161baf81ec2ff1d8a07de8b96f09f5a23 Mon Sep 17 00:00:00 2001 From: MMXX Date: Tue, 28 Dec 2021 20:01:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=AD=BE=E5=90=8D=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fir_ser/api/models.py | 5 +++-- fir_ser/api/utils/app/supersignutils.py | 19 ++++++++++++++----- fir_ser/api/views/download.py | 4 ++-- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/fir_ser/api/models.py b/fir_ser/api/models.py index bbb0080..8c68484 100644 --- a/fir_ser/api/models.py +++ b/fir_ser/api/models.py @@ -280,8 +280,9 @@ class AppIOSDeveloperInfo(models.Model): description = models.TextField('备注', blank=True, null=True, default='') auth_type_choices = ((0, 'p8key认证'),) auth_type = models.SmallIntegerField(choices=auth_type_choices, default=0, verbose_name="认证类型") - status_choices = ( - (0, '未激活'), (1, '已激活'), (2, '协议待同意'), (3, '维护中'), (4, '证书过期'), (5, '状态异常')) # 协议待同意和维护中:代表只读,不可创建和注册新设备号 + + # 协议待同意和维护中:代表只读,不可创建和注册新设备号 + status_choices = ((0, '未激活'), (1, '已激活'), (2, '协议待同意'), (3, '维护中'), (4, '证书过期'), (5, '状态异常')) status = models.SmallIntegerField(choices=status_choices, verbose_name="账户状态", default=0) class Meta: diff --git a/fir_ser/api/utils/app/supersignutils.py b/fir_ser/api/utils/app/supersignutils.py index c01b4ac..9067639 100644 --- a/fir_ser/api/utils/app/supersignutils.py +++ b/fir_ser/api/utils/app/supersignutils.py @@ -252,8 +252,17 @@ def get_new_developer_by_app_obj(app_obj, obj_base_filter, apple_to_app=False): def filter_developer_by_pk_list(developer_pk_list, f_key, app_search_flag=True): developer_obj_dict = AppIOSDeveloperInfo.objects.filter(pk__in=developer_pk_list).values( f_key, 'pk').annotate(count=Count('pk')) - if not app_search_flag: - developer_obj_dict = developer_obj_dict.filter(count__lt=F('app_limit_number')) + if app_search_flag: + return developer_obj_dict + else: + apple_filter = {f'{f_key}__isnull': False, 'pk__in': developer_pk_list} + developer_obj_dict = AppIOSDeveloperInfo.objects.filter(**apple_filter).values(f_key, 'pk').annotate( + count=Count('pk')).filter(count__lt=F('app_limit_number')) + if not developer_obj_dict: + apple_filter = {f'{f_key}__isnull': True, 'pk__in': developer_pk_list} + developer_obj_dict = AppIOSDeveloperInfo.objects.filter(**apple_filter).values(f_key, 'pk').annotate( + count=Count('pk')) + return developer_obj_dict @@ -727,7 +736,7 @@ class IosUtils(object): with cache.lock(register_devices_prefix, timeout=360): if CleanErrorBundleIdSignDataState(add_new_bundles_prefix).get_state(): return True, True # 程序错误,进行清理的时候,拦截多余的设备注册 - if not get_developer_obj_by_others(self.user_obj, self.udid, self.app_obj): + if not get_developer_obj_by_others(self.user_obj, self.udid, self.app_obj, False): d_result['code'] = 1005 return False, d_result status, did_udid_result = IosUtils.check_or_register_devices(self.app_obj, self.user_obj, @@ -971,7 +980,7 @@ class IosUtils(object): status, result = app_api_obj.create_cert(user_obj) if status: cert_id = result.id - AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=auth.get("issuer_id")).update( + AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=developer_obj.issuer_id).update( status=1, certid=cert_id, cert_expire_time=format_apple_date(result.expirationDate)) resign_app_obj = IosUtils.get_resign_obj(user_obj, developer_obj) @@ -995,7 +1004,7 @@ class IosUtils(object): app_api_obj = get_api_obj(developer_obj) status, result = app_api_obj.get_cert_obj_by_cid() if not status: - AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=auth.get("issuer_id")).update( + AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=developer_obj.issuer_id).update( certid=None, cert_expire_time=None) return status, result diff --git a/fir_ser/api/views/download.py b/fir_ser/api/views/download.py index 8e80ca9..ebb2649 100644 --- a/fir_ser/api/views/download.py +++ b/fir_ser/api/views/download.py @@ -20,7 +20,7 @@ from api.utils.modelutils import get_filename_form_file, check_app_domain_name_a ad_random_weight, get_app_download_uri from api.utils.response import BaseResponse from api.utils.serializer import AppsShortSerializer, AppAdInfoSerializer -from api.utils.storage.caches import del_cache_response_by_short, check_app_permission, get_app_download_url +from api.utils.storage.caches import check_app_permission, get_app_download_url from api.utils.storage.storage import Storage, get_local_storage from api.utils.throttle import VisitShortThrottle, InstallShortThrottle, InstallThrottle1, InstallThrottle2 from common.base.baseutils import get_profile_full_path, make_random_uuid, get_origin_domain_name, \ @@ -176,7 +176,7 @@ class ShortDownloadView(APIView): res.code = 1002 res.msg = "参数有误" return Response(res.dict) - del_cache_response_by_short(app_obj.app_id, udid=udid) + # del_cache_response_by_short(app_obj.app_id, udid=udid) app_serializer = AppsShortSerializer(app_obj, context={"key": "ShortDownloadView", "release_id": release_id, "storage": Storage(user_obj)})