Эх сурвалжийг харах

尚云剩余uid数量少于1000,尚云剩余uid数量少于5000,发送邮件提醒

locky 1 жил өмнө
parent
commit
db44887ce4

+ 8 - 7
Controller/SerialNumberController.py

@@ -330,25 +330,26 @@ class SerialNumberView(View):
         # 写入已使用序列号redis列表
         redis_obj.rpush(USED_SERIAL_REDIS_LIST, serial)
 
+        p2p_type = int(p2p_type)
+        platform = '尚云' if p2p_type == 1 else 'tutk'
+        redis_key = 'uid_count_warning_time_limit_' + platform
+
         redis_obj = RedisObject()
-        time_limit = redis_obj.get_data('uid_count_warning_time_limit')
+        time_limit = redis_obj.get_data(redis_key)
         if not time_limit:
             vpg_id = 1
             if CONFIG_INFO == CONFIG_US:
                 vpg_id = 3
             elif CONFIG_INFO == CONFIG_EUR:
                 vpg_id = 4
-            p2p_type = int(p2p_type)
 
             try:
-                # 剩余uid数量少于5000邮件提醒
+                # 尚云剩余uid数量少于1000,尚云剩余uid数量少于5000,发送邮件提醒
                 unused_uid_count = UIDModel.objects.filter(vpg_id=vpg_id, p2p_type=p2p_type, status=0).count()
-                LOGGER.info('uid剩余数量:{}'.format(unused_uid_count))
-                warning_count = 5000
+                warning_count = 1000 if p2p_type == 1 else 5000
                 if unused_uid_count < warning_count:
                     # 限制一天提醒一次
-                    redis_obj.set_data('uid_count_warning_time_limit', 1, 60 * 60 * 24)
-                    platform = '尚云' if p2p_type == 1 else 'tutk'
+                    redis_obj.set_data(redis_key, 1, 60 * 60 * 24)
                     email_content = '{}服{}的uid数量少于{}个,请及时处理'.format(CONFIG_INFO, platform, warning_count)
                     S3Email().faEmail(email_content, 'servers@ansjer.com')
             except Exception as e: