diff --git a/fir_client/src/components/user/FirSuperSignBase.vue b/fir_client/src/components/user/FirSuperSignBase.vue index 9c64d4c..c669ba3 100644 --- a/fir_client/src/components/user/FirSuperSignBase.vue +++ b/fir_client/src/components/user/FirSuperSignBase.vue @@ -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() { diff --git a/fir_ser/api/utils/ctasks.py b/fir_ser/api/utils/ctasks.py index 302be60..c03995a 100644 --- a/fir_ser/api/utils/ctasks.py +++ b/fir_ser/api/utils/ctasks.py @@ -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]) diff --git a/fir_ser/common/libs/sendmsg/template_content.py b/fir_ser/common/libs/sendmsg/template_content.py index f02bc53..1e1b00b 100644 --- a/fir_ser/common/libs/sendmsg/template_content.py +++ b/fir_ser/common/libs/sendmsg/template_content.py @@ -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, diff --git a/fir_ser/common/notify/notify.py b/fir_ser/common/notify/notify.py index e4692b0..e458a15 100644 --- a/fir_ser/common/notify/notify.py +++ b/fir_ser/common/notify/notify.py @@ -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)) diff --git a/fir_ser/common/notify/ntasks.py b/fir_ser/common/notify/ntasks.py index b25ddd2..7d7df22 100644 --- a/fir_ser/common/notify/ntasks.py +++ b/fir_ser/common/notify/ntasks.py @@ -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)] } diff --git a/fir_ser/common/utils/caches.py b/fir_ser/common/utils/caches.py index 2441988..4c3719d 100644 --- a/fir_ser/common/utils/caches.py +++ b/fir_ser/common/utils/caches.py @@ -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__) diff --git a/fir_ser/xsign/views/supersign.py b/fir_ser/xsign/views/supersign.py index bca2e1e..0699752 100644 --- a/fir_ser/xsign/views/supersign.py +++ b/fir_ser/xsign/views/supersign.py @@ -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: