签名共有池实现

publicsignpoll
fxC 3 years ago
parent 9b7590146a
commit b3637c6844
  1. 12
      fir_ser/api/models.py
  2. 44
      fir_ser/api/utils/app/supersignutils.py

@ -519,3 +519,15 @@ class UserAdDisplayInfo(models.Model):
def __str__(self):
return "%s-%s-%s" % (self.user_id, self.description, self.is_enable)
class IosDeveloperPublicPoolBill(models.Model):
user_id = models.ForeignKey(to="UserInfo", verbose_name="用户ID", on_delete=models.CASCADE)
action_choices = ((0, 'used'), (1, 'add'))
action = models.SmallIntegerField(choices=action_choices, default=1, verbose_name="消费类型",
help_text="0 表示消耗 1表示充值")
number = models.IntegerField(verbose_name="消耗次数", default=1)
app_id = models.ForeignKey(to="Apps", on_delete=models.CASCADE, verbose_name="属于哪个APP")
udid = models.ForeignKey(to="AppUDID", on_delete=models.CASCADE, verbose_name="所消耗的udid")
developerid = models.ForeignKey(to="AppIOSDeveloperInfo", on_delete=models.CASCADE, verbose_name="所使用苹果开发者账户")
created_time = models.DateTimeField(auto_now_add=True, verbose_name="添加时间")

@ -11,7 +11,7 @@ from api.utils.response import BaseResponse
from fir_ser.settings import SUPER_SIGN_ROOT, MEDIA_ROOT, SERVER_DOMAIN, MOBILE_CONFIG_SIGN_SSL, MSGTEMPLATE
from api.utils.app.iossignapi import ResignApp, AppDeveloperApiV2
from api.models import APPSuperSignUsedInfo, AppUDID, AppIOSDeveloperInfo, AppReleaseInfo, Apps, APPToDeveloper, \
UDIDsyncDeveloper, DeveloperAppID, DeveloperDevicesID
UDIDsyncDeveloper, DeveloperAppID, DeveloperDevicesID, IosDeveloperPublicPoolBill, UserInfo
from api.utils.app.randomstrings import make_app_uuid, make_from_user_uuid
from api.utils.storage.caches import del_cache_response_by_short, send_msg_over_limit, check_app_permission, \
consume_user_download_times_by_app_obj
@ -21,6 +21,7 @@ from api.utils.baseutils import file_format_path, delete_app_profile_file, get_p
get_user_default_domain_name, get_min_default_domain_cname_obj, format_apple_date, get_format_time
from api.utils.storage.storage import Storage
from django.core.cache import cache
from django.db.models import Sum
logger = logging.getLogger(__name__)
@ -216,6 +217,21 @@ def get_http_server_domain(request):
return get_server_domain_from_request(request, server_domain)
def get_ios_developer_public_num(user_obj):
ios_developer_base_obj = IosDeveloperPublicPoolBill.objects.filter(user_id=user_obj)
add_number = ios_developer_base_obj.filter(action=1).aggregate(number=Sum('number'))
used_number = ios_developer_base_obj.filter(action=0).aggregate(number=Sum('number'))
if add_number:
add_number = add_number.get("number", 0)
if not used_number:
used_number = 0
else:
used_number = used_number.get("number", 0)
if add_number - used_number > 0:
return True
return False
def get_redirect_server_domain(request, user_obj=None, app_domain_name=None):
is_https = False
if user_obj:
@ -260,7 +276,9 @@ class IosUtils(object):
else:
logger.error(f"user {self.user_obj} send msg failed. over limit")
def get_developer_user_by_app_udid(self):
def get_developer_user_by_app_udid(self, user_obj_list=None):
if user_obj_list is None:
user_obj_list = []
use_device_obj = APPSuperSignUsedInfo.objects.filter(udid__udid=self.udid_info.get('udid'),
user_id=self.user_obj, developerid__is_actived=True,
developerid__certid__isnull=False).first()
@ -278,7 +296,27 @@ class IosUtils(object):
certid__isnull=False).order_by("created_time"):
if get_developer_udided(developer_obj)[1] < developer_obj.usable_number:
return developer_obj
return None
if get_ios_developer_public_num(self.user_obj):
if user_obj_list == 'end':
return None
if not user_obj_list and isinstance(user_obj_list, list):
user_obj_list = UserInfo.objects.filter(is_active=True, role=3, is_staff=True).all()
for admin_user_obj in user_obj_list:
if admin_user_obj:
self.user_obj = admin_user_obj
user_obj_list.remove(admin_user_obj)
if len(user_obj_list) == 0:
user_obj_list = 'end'
result = self.get_developer_user_by_app_udid(user_obj_list)
if user_obj_list and isinstance(user_obj_list, list) and result is None:
return self.get_developer_user_by_app_udid(user_obj_list)
else:
return result
else:
return None
return None
else:
return None
return developer_obj
# def download_profile(self, developer_app_id, device_id_list):

Loading…
Cancel
Save