优化下载次数展示

dependabot/npm_and_yarn/fir_admin/terser-4.8.1
isummer 2 years ago
parent ec908f0dea
commit 2e240735dc
  1. 6
      fir_ser/api/views/notify.py
  2. 9
      fir_ser/common/libs/sendmsg/template_content.py
  3. 4
      fir_ser/common/libs/sendmsg/templates/download_times_not_enough.html
  4. 6
      fir_ser/common/libs/sendmsg/templates/download_times_over_limit.html
  5. 4
      fir_ser/common/libs/sendmsg/templates/pay_success.html
  6. 15
      fir_ser/common/notify/notify.py
  7. 10
      fir_ser/common/notify/ntasks.py
  8. 4
      mailhtml/src/download_times_not_enough.mjml.html
  9. 6
      mailhtml/src/download_times_over_limit.mjml.html
  10. 3
      mailhtml/src/pay_success.mjml.html

@ -70,7 +70,7 @@ class NotifyConfigView(APIView):
notify_available_signs = threshold.get('notify_available_signs') notify_available_signs = threshold.get('notify_available_signs')
if notify_available_downloads is not None: if notify_available_downloads is not None:
request.user.notify_available_downloads = notify_available_downloads request.user.notify_available_downloads = notify_available_downloads * Config.APP_USE_BASE_DOWNLOAD_TIMES
if notify_available_signs is not None: if notify_available_signs is not None:
request.user.notify_available_signs = notify_available_signs request.user.notify_available_signs = notify_available_signs
if notify_available_downloads is not None or notify_available_signs is not None: if notify_available_downloads is not None or notify_available_signs is not None:
@ -78,8 +78,10 @@ class NotifyConfigView(APIView):
NotifyLoopCache(request.user.uid, 'download_times').del_storage_cache() NotifyLoopCache(request.user.uid, 'download_times').del_storage_cache()
NotifyLoopCache(request.user.uid, 'sign_device_times').del_storage_cache() NotifyLoopCache(request.user.uid, 'sign_device_times').del_storage_cache()
res.data = UserInfo.objects.filter(pk=request.user.pk).values('notify_available_downloads', data = UserInfo.objects.filter(pk=request.user.pk).values('notify_available_downloads',
'notify_available_signs').first() 'notify_available_signs').first()
data['notify_available_downloads'] = data['notify_available_downloads'] // Config.APP_USE_BASE_DOWNLOAD_TIMES
res.data = data
return Response(res.dict) return Response(res.dict)
def put(self, request): def put(self, request):

@ -10,11 +10,12 @@ from django.template import loader
from common.base.baseutils import get_format_time from common.base.baseutils import get_format_time
def get_pay_success_html_content(user_obj, order_obj): def get_pay_success_html_content(user_obj, order_obj, base_download_times=1):
return loader.render_to_string('pay_success.html', return loader.render_to_string('pay_success.html',
{ {
'username': user_obj.first_name, 'username': user_obj.first_name,
'order_obj': order_obj, 'order_obj': order_obj,
'base_download_times': base_download_times
}) })
@ -58,11 +59,12 @@ def get_check_developer_report_html_content(user_obj, developer_obj_list, develo
}) })
def get_user_download_times_over_limit_html_content(user_obj): def get_user_download_times_over_limit_html_content(user_obj, base_download_times=1):
return loader.render_to_string('download_times_over_limit.html', return loader.render_to_string('download_times_over_limit.html',
{ {
'username': user_obj.first_name, 'username': user_obj.first_name,
'user_obj': user_obj, 'user_obj': user_obj,
'base_download_times': base_download_times,
}) })
@ -83,11 +85,12 @@ def get_developer_cert_expired_html_content(user_obj, developer_obj_list):
}) })
def get_user_download_times_not_enough_html_content(user_obj): def get_user_download_times_not_enough_html_content(user_obj, base_download_times=1):
return loader.render_to_string('download_times_not_enough.html', return loader.render_to_string('download_times_not_enough.html',
{ {
'username': user_obj.first_name, 'username': user_obj.first_name,
'user_obj': user_obj, 'user_obj': user_obj,
'base_download_times': base_download_times,
}) })

@ -210,14 +210,14 @@
<td align="left" <td align="left"
style="font-size:0px;padding:10px 25px;word-break:break-word;"> style="font-size:0px;padding:10px 25px;word-break:break-word;">
<div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#525252;"> <div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#525252;">
您当前账户下载次数仅剩 {{ user_obj.download_times }}</div> 您当前账户下载次数仅剩 {% widthratio user_obj.download_times base_download_times 1 %}</div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="left" <td align="left"
style="font-size:0px;padding:10px 25px;word-break:break-word;"> style="font-size:0px;padding:10px 25px;word-break:break-word;">
<div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#525252;"> <div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#525252;">
您当前账户下载次数不足,应用已经无法下载安装。为了避免业务使用,望您尽快充值 您当前账户下载次数不足,应用已经无法下载安装。为了避免业务暂停使用,望您尽快充值
</div> </div>
</td> </td>
</tr> </tr>

@ -210,21 +210,21 @@
<td align="left" <td align="left"
style="font-size:0px;padding:10px 25px;word-break:break-word;"> style="font-size:0px;padding:10px 25px;word-break:break-word;">
<div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#525252;"> <div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#525252;">
您当前账户下载次数仅剩 {{ user_obj.download_times }}</div> 您当前账户下载次数仅剩 {% widthratio user_obj.download_times base_download_times 1 %}</div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="left" <td align="left"
style="font-size:0px;padding:10px 25px;word-break:break-word;"> style="font-size:0px;padding:10px 25px;word-break:break-word;">
<div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#525252;"> <div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#525252;">
已超过您设置的阈值 {{ user_obj.notify_available_downloads }}</div> 已超过您设置的阈值 {% widthratio user_obj.notify_available_downloads base_download_times 1 %}</div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="left" <td align="left"
style="font-size:0px;padding:10px 25px;word-break:break-word;"> style="font-size:0px;padding:10px 25px;word-break:break-word;">
<div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#525252;"> <div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#525252;">
为了避免业务使用,望您尽快充值! 为了避免业务暂停使用,望您尽快充值!
</div> </div>
</td> </td>
</tr> </tr>

@ -239,8 +239,8 @@
<td align="left" <td align="left"
style="font-size:0px;padding:10px 25px;word-break:break-word;"> style="font-size:0px;padding:10px 25px;word-break:break-word;">
<div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#525252;"> <div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#525252;">
订单信息:您充值了 {{ order_obj.actual_download_times }} 订单信息:您充值了 {% widthratio order_obj.actual_download_times base_download_times 1 %}
下载次数,【赠送 {{ order_obj.actual_download_gift_times }}】 下载次数,【赠送 {% widthratio order_obj.actual_download_gift_times base_download_times 1 %}】
</div> </div>
</td> </td>
</tr> </tr>

@ -9,6 +9,7 @@ import logging
from api.utils.modelutils import get_notify_wx_queryset, get_wx_nickname from api.utils.modelutils import get_notify_wx_queryset, get_wx_nickname
from common.base.baseutils import get_format_time from common.base.baseutils import get_format_time
from common.base.magic import magic_call_in_times from common.base.magic import magic_call_in_times
from common.core.sysconfig import Config
from common.libs.mp.wechat import WxTemplateMsg from common.libs.mp.wechat import WxTemplateMsg
from common.libs.sendmsg.template_content import get_pay_success_html_content, get_sign_failed_html_content, \ 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_sign_unavailable_developer_html_content, get_sign_app_over_limit_html_content, \
@ -26,10 +27,9 @@ def pay_success_notify(user_obj, order_obj):
:return: :return:
""" """
message_type = 4 message_type = 4
title = f'{order_obj.actual_download_times // Config.APP_USE_BASE_DOWNLOAD_TIMES} 下载次数'
title = f'{order_obj.actual_download_times} 下载次数'
if order_obj.actual_download_gift_times > 0: if order_obj.actual_download_gift_times > 0:
title = f'{title} 【赠送 {order_obj.actual_download_gift_times}' title = f'{title} 【赠送 {order_obj.actual_download_gift_times // Config.APP_USE_BASE_DOWNLOAD_TIMES}'
for wx_user_obj in get_notify_wx_queryset(user_obj, message_type): 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)).pay_success_msg( res = WxTemplateMsg(wx_user_obj.openid, get_wx_nickname(wx_user_obj.openid)).pay_success_msg(
title, title,
@ -38,8 +38,8 @@ def pay_success_notify(user_obj, order_obj):
order_obj.pay_time.strftime("%Y/%m/%d %H:%M:%S"), order_obj.pay_time.strftime("%Y/%m/%d %H:%M:%S"),
order_obj.order_number, order_obj.description) order_obj.order_number, order_obj.description)
logger.info(f'user_obj {user_obj} weixin notify pay success result: {res}') logger.info(f'user_obj {user_obj} weixin notify pay success result: {res}')
notify_by_email(user_obj, message_type,
notify_by_email(user_obj, message_type, get_pay_success_html_content(user_obj, order_obj)) get_pay_success_html_content(user_obj, order_obj, Config.APP_USE_BASE_DOWNLOAD_TIMES))
@magic_call_in_times(key=lambda *x: x[0].uid) @magic_call_in_times(key=lambda *x: x[0].uid)
@ -138,6 +138,7 @@ def download_times_not_enough(user_obj, msg):
message_type = 1 message_type = 1
for wx_user_obj in get_notify_wx_queryset(user_obj, message_type): 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( 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) user_obj.first_name, user_obj.download_times // Config.APP_USE_BASE_DOWNLOAD_TIMES, msg)
logger.info(f'user_obj {user_obj} download times not enough result: {res}') 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_not_enough_html_content(user_obj, Config.APP_USE_BASE_DOWNLOAD_TIMES))

@ -24,17 +24,19 @@ logger = logging.getLogger(__name__)
def download_times_over_limit(user_obj): def download_times_over_limit(user_obj):
""" """
1, '下载次数不足' 1, '下载次数不足'
:param msg:
:param user_obj: :param user_obj:
:return: :return:
""" """
message_type = 1 message_type = 1
msg = f"您当前账户下载次数仅剩 {user_obj.download_times},已超过您设置的阈值 {user_obj.notify_available_downloads},为了避免业务使用,望您尽快充值!" download_times = user_obj.download_times // Config.APP_USE_BASE_DOWNLOAD_TIMES
notify_available_downloads = user_obj.notify_available_downloads // Config.APP_USE_BASE_DOWNLOAD_TIMES
msg = f"您当前账户下载次数仅剩 {download_times},已超过您设置的阈值 {notify_available_downloads},为了避免业务使用,望您尽快充值!"
for wx_user_obj in get_notify_wx_queryset(user_obj, message_type): 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( 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) user_obj.first_name, download_times, msg)
logger.info(f'user_obj {user_obj} download times not enough result: {res}') logger.info(f'user_obj {user_obj} download times not enough result: {res}')
notify_by_email(user_obj, message_type, get_user_download_times_over_limit_html_content(user_obj)) notify_by_email(user_obj, message_type,
get_user_download_times_over_limit_html_content(user_obj, Config.APP_USE_BASE_DOWNLOAD_TIMES))
def apple_developer_devices_over_limit(user_obj, device_count): def apple_developer_devices_over_limit(user_obj, device_count):

@ -17,10 +17,10 @@
<mj-section> <mj-section>
<mj-column width="100%"> <mj-column width="100%">
<mj-text color="#525252"> <mj-text color="#525252">
您当前账户下载次数仅剩 {{user_obj.download_times}} 您当前账户下载次数仅剩 {% widthratio user_obj.download_times base_download_times 1 %}
</mj-text> </mj-text>
<mj-text color="#525252"> <mj-text color="#525252">
您当前账户下载次数不足,应用已经无法下载安装。为了避免业务使用,望您尽快充值 您当前账户下载次数不足,应用已经无法下载安装。为了避免业务暂停使用,望您尽快充值
</mj-text> </mj-text>
</mj-column> </mj-column>

@ -17,13 +17,13 @@
<mj-section> <mj-section>
<mj-column width="100%"> <mj-column width="100%">
<mj-text color="#525252"> <mj-text color="#525252">
您当前账户下载次数仅剩 {{user_obj.download_times}} 您当前账户下载次数仅剩 {% widthratio user_obj.download_times base_download_times 1 %}
</mj-text> </mj-text>
<mj-text color="#525252"> <mj-text color="#525252">
已超过您设置的阈值 {{user_obj.notify_available_downloads}} 已超过您设置的阈值 {% widthratio user_obj.notify_available_downloads base_download_times 1 %}
</mj-text> </mj-text>
<mj-text color="#525252"> <mj-text color="#525252">
为了避免业务使用,望您尽快充值! 为了避免业务暂停使用,望您尽快充值!
</mj-text> </mj-text>
</mj-column> </mj-column>

@ -29,7 +29,8 @@
支付方式:{{order_obj.get_payment_type_display}} 支付方式:{{order_obj.get_payment_type_display}}
</mj-text> </mj-text>
<mj-text color="#525252"> <mj-text color="#525252">
订单信息:您充值了 {{order_obj.actual_download_times}} 下载次数,【赠送 {{order_obj.actual_download_gift_times}}】 订单信息:您充值了 {% widthratio order_obj.actual_download_times base_download_times 1 %} 下载次数,【赠送
{% widthratio order_obj.actual_download_gift_times base_download_times 1 %}】
</mj-text> </mj-text>
<mj-text color="#525252"> <mj-text color="#525252">
备注:{{order_obj.description}} 备注:{{order_obj.description}}

Loading…
Cancel
Save