优化通知提醒,增加批量设置开发者账户自动检测,定时任务修改为 【0,1,3,7】自动提醒,同步设备支持条件

dependabot/npm_and_yarn/fir_admin/async-2.6.4
nineven 3 years ago
parent 04ae8cccc4
commit 747d2b3dfa
  1. 7
      fir_client/src/components/user/FirSuperSignBase.vue
  2. 6
      fir_ser/api/utils/ctasks.py
  3. 2
      fir_ser/common/libs/sendmsg/template_content.py
  4. 17
      fir_ser/common/notify/notify.py
  5. 26
      fir_ser/common/notify/ntasks.py
  6. 3
      fir_ser/common/utils/caches.py
  7. 23
      fir_ser/xsign/views/supersign.py

@ -1927,7 +1927,12 @@ export default {
syncalldevices() {
this.iosdeveloperFun({
"methods": "PUT",
"data": {"issuer_id": this.appidseach, "act": "syncalldevice"}
"data": {
"issuer_id": this.appidseach,
"act": "syncalldevice",
"devicestatus": this.devicestatus,
"udidsearch": this.udidsearch
}
});
},
cleandevices() {

@ -55,14 +55,14 @@ def auto_clean_remote_client_log(clean_day=30 * 6):
def notify_check_user_download_times():
for user_obj in UserInfo.objects.filter(is_active=True, notify_available_downloads__gt=0).all():
check_user_download_times(user_obj, days=[0, 3, 7])
check_user_download_times(user_obj, days=[0, 1, 3, 7])
def notify_check_apple_developer_devices():
for user_obj in UserInfo.objects.filter(is_active=True, supersign_active=True, notify_available_signs__gt=0).all():
check_apple_developer_devices(user_obj, days=[0, 3, 7])
check_apple_developer_devices(user_obj, days=[0, 1, 3, 7])
def notify_check_apple_developer_cert():
for user_obj in UserInfo.objects.filter(is_active=True, supersign_active=True).all():
check_apple_developer_cert(user_obj, expire_day=7)
check_apple_developer_cert(user_obj, expire_day=7, days=[0, 1, 3, 7])

@ -66,7 +66,7 @@ def get_user_download_times_over_limit_html_content(user_obj):
})
def get_developer_devices_not_enough_html_content(user_obj, device_count):
def get_developer_devices_over_limit_html_content(user_obj, device_count):
return loader.render_to_string('xsign/apple_developer_devices_over_limit.html',
{
'username': user_obj.first_name,

@ -11,7 +11,7 @@ from common.base.baseutils import get_format_time
from common.libs.mp.wechat import WxTemplateMsg
from common.libs.sendmsg.template_content import get_pay_success_html_content, get_sign_failed_html_content, \
get_sign_unavailable_developer_html_content, get_sign_app_over_limit_html_content, \
get_check_developer_report_html_content
get_check_developer_report_html_content, get_user_download_times_not_enough_html_content
from common.notify.utils import notify_by_email
logger = logging.getLogger(__name__)
@ -121,3 +121,18 @@ def check_developer_status_notify(user_obj, developer_obj_list, developer_used_i
notify_by_email(user_obj, message_type,
get_check_developer_report_html_content(user_obj, developer_obj_list, developer_used_info,
yesterday_used_number))
def download_times_not_enough(user_obj, msg):
"""
1, '下载次数不足'
:param msg:
:param user_obj:
:return:
"""
message_type = 1
for wx_user_obj in get_notify_wx_queryset(user_obj, message_type):
res = WxTemplateMsg(wx_user_obj.openid, get_wx_nickname(wx_user_obj.openid)).download_times_not_enough_msg(
user_obj.first_name, user_obj.download_times, msg)
logger.info(f'user_obj {user_obj} download times not enough result: {res}')
notify_by_email(user_obj, message_type, get_user_download_times_not_enough_html_content(user_obj))

@ -12,9 +12,8 @@ from common.base.magic import magic_wrapper, magic_notify
from common.cache.storage import NotifyLoopCache
from common.core.sysconfig import Config
from common.libs.mp.wechat import WxTemplateMsg
from common.libs.sendmsg.template_content import get_user_download_times_not_enough_html_content, \
get_developer_devices_not_enough_html_content, get_developer_cert_expired_html_content, \
get_user_download_times_over_limit_html_content
from common.libs.sendmsg.template_content import get_developer_devices_over_limit_html_content, \
get_developer_cert_expired_html_content, get_user_download_times_over_limit_html_content
from common.notify.utils import notify_by_email
from xsign.models import AppIOSDeveloperInfo
from xsign.utils.modelutils import get_developer_devices
@ -22,7 +21,7 @@ from xsign.utils.modelutils import get_developer_devices
logger = logging.getLogger(__name__)
def download_times_not_enough(user_obj, msg):
def download_times_over_limit(user_obj):
"""
1, '下载次数不足'
:param msg:
@ -30,16 +29,18 @@ def download_times_not_enough(user_obj, msg):
:return:
"""
message_type = 1
msg = f"您当前账户下载次数仅剩 {user_obj.download_times},已超过您设置的阈值 {user_obj.notify_available_downloads},为了避免业务使用,望您尽快充值!"
for wx_user_obj in get_notify_wx_queryset(user_obj, message_type):
res = WxTemplateMsg(wx_user_obj.openid, get_wx_nickname(wx_user_obj.openid)).download_times_not_enough_msg(
user_obj.first_name, user_obj.download_times, msg)
logger.info(f'user_obj {user_obj} download times not enough result: {res}')
notify_by_email(user_obj, message_type, get_user_download_times_not_enough_html_content(user_obj))
notify_by_email(user_obj, message_type, get_user_download_times_over_limit_html_content(user_obj))
def apple_developer_devices_not_enough(user_obj, device_count):
def apple_developer_devices_over_limit(user_obj, device_count):
"""
0, '签名余额不足'
:param device_count:
:param user_obj:
:return:
"""
@ -50,7 +51,7 @@ def apple_developer_devices_not_enough(user_obj, device_count):
get_wx_nickname(wx_user_obj.openid)).apple_developer_devices_not_enough_msg(
user_obj.first_name, device_count, msg)
logger.info(f'user_obj {user_obj} sign devices not enough result: {res}')
notify_by_email(user_obj, message_type, get_developer_devices_not_enough_html_content(user_obj, device_count))
notify_by_email(user_obj, message_type, get_developer_devices_over_limit_html_content(user_obj, device_count))
def apple_developer_cert_expired(user_obj, developer_queryset):
@ -85,13 +86,12 @@ def check_user_download_times(user_obj, days=None):
days = [0, 3, 7]
if user_obj.notify_available_downloads == 0 or user_obj.notify_available_downloads < user_obj.download_times:
return
msg = get_user_download_times_over_limit_html_content(user_obj)
notify_rules = [
{
'func': magic_wrapper(lambda obj: obj.download_times < obj.notify_available_downloads, user_obj),
'notify': days,
'cache': NotifyLoopCache(user_obj.uid, 'download_times'),
'notify_func': [magic_wrapper(download_times_not_enough, user_obj, msg)]
'notify_func': [magic_wrapper(download_times_over_limit, user_obj)]
}
]
magic_notify(notify_rules)
@ -112,13 +112,15 @@ def check_apple_developer_devices(user_obj, days=None):
'func': magic_wrapper(lambda obj: device_count < obj.notify_available_signs, user_obj),
'notify': days,
'cache': NotifyLoopCache(user_obj.uid, 'sign_device_times'),
'notify_func': [magic_wrapper(apple_developer_devices_not_enough, user_obj, device_count)]
'notify_func': [magic_wrapper(apple_developer_devices_over_limit, user_obj, device_count)]
}
]
magic_notify(notify_rules)
def check_apple_developer_cert(user_obj, expire_day=7):
def check_apple_developer_cert(user_obj, expire_day=7, days=None):
if days is None:
days = [0, 3, 7]
expire_time = datetime.datetime.now() + datetime.timedelta(days=expire_day)
developer_queryset = AppIOSDeveloperInfo.objects.filter(user_id=user_obj, status__in=Config.DEVELOPER_USE_STATUS,
cert_expire_time__lte=expire_time).order_by(
@ -129,7 +131,7 @@ def check_apple_developer_cert(user_obj, expire_day=7):
notify_rules = [
{
'func': magic_wrapper(lambda: True),
'notify': [0, 3, 7],
'notify': days,
'cache': NotifyLoopCache(user_obj.uid, 'developer_cert'),
'notify_func': [magic_wrapper(apple_developer_cert_expired, user_obj, developer_queryset)]
}

@ -20,8 +20,7 @@ from common.cache.storage import AppDownloadTodayTimesCache, AppDownloadTimesCac
UploadTmpFileNameCache, RedisCacheBase, UserCanDownloadCache, UserFreeDownloadTimesCache, WxTicketCache, \
SignUdidQueueCache, CloudStorageCache
from common.core.sysconfig import Config
from common.notify.notify import pay_success_notify
from common.notify.ntasks import download_times_not_enough
from common.notify.notify import pay_success_notify, download_times_not_enough
from fir_ser.settings import CACHE_KEY_TEMPLATE, SYNC_CACHE_TO_DATABASE
logger = logging.getLogger(__name__)

@ -83,6 +83,10 @@ class DeveloperView(APIView):
res.data = developer_serializer.data
res.count = developer_obj.count()
res.status_choices = get_choices_dict(AppIOSDeveloperInfo.status_choices, Config.DEVELOPER_DISABLED_STATUS)
res.status_choices.extend([
{'id': 'open_auto_check', 'name': '开启自动检测', 'disabled': False},
{'id': 'close_auto_check', 'name': '关闭自动检测', 'disabled': False},
])
res.apple_auth_list = get_choices_dict(AppIOSDeveloperInfo.auth_type_choices)
return Response(res.dict)
@ -105,8 +109,16 @@ class DeveloperView(APIView):
if not status:
result_list.append({'issuer_id': developer_obj.issuer_id, 'msg': result.get("return_info")})
for developer_s_obj in AppIOSDeveloperInfo.objects.filter(user_id=request.user,
status__in=Config.DEVELOPER_USE_STATUS).all():
run_queryset = AppIOSDeveloperInfo.objects.filter(user_id=request.user,
status__in=Config.DEVELOPER_USE_STATUS).all()
devicestatus = data.get("devicestatus", '').strip()
udidsearch = data.get("udidsearch", '').strip()
if udidsearch:
run_queryset = run_queryset.filter(udidsyncdeveloper__udid=udidsearch)
if devicestatus:
run_queryset = run_queryset.filter(udidsyncdeveloper__status=devicestatus)
for developer_s_obj in run_queryset:
pools.submit(run_task, developer_s_obj)
pools.shutdown()
@ -140,6 +152,13 @@ class DeveloperView(APIView):
elif act == "setstatus":
issuer_ids = data.get("issuer_ids", [])
status = data.get("status", None)
if status and status in ['open_auto_check', 'close_auto_check']:
auto_check = False
if status == 'open_auto_check':
auto_check = True
AppIOSDeveloperInfo.objects.filter(user_id=request.user, issuer_id__in=issuer_ids).update(
auto_check=auto_check)
return Response(res.dict)
if issuer_ids and status is not None and status not in Config.DEVELOPER_DISABLED_STATUS:
status_text = get_choices_name_from_key(AppIOSDeveloperInfo.status_choices, status)
if status_text:

Loading…
Cancel
Save