ActivityService.py 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. # @Author : Rocky
  2. # @File : ActivityService.py
  3. # @Time : 2025/11/19 16:16
  4. import time
  5. import pytz
  6. from datetime import datetime
  7. class ActivityObj:
  8. """
  9. 临时活动类
  10. """
  11. @staticmethod
  12. def is_in_discount_period(now_time=None):
  13. """
  14. 判断是否在优惠活动期间(东部时间 11.26-12.26)
  15. @param now_time: 当前时间戳(可选,默认为当前时间)
  16. @return: True 表示在活动期间,False 表示不在
  17. """
  18. if now_time is None:
  19. now_time = int(time.time())
  20. # 转换为东部时间(ET)
  21. eastern = pytz.timezone('America/New_York')
  22. current_dt = datetime.fromtimestamp(now_time, tz=eastern)
  23. # 活动开始时间:2025-11-26 00:00:00 ET
  24. start_dt = eastern.localize(datetime(2025, 11, 26, 0, 0, 0))
  25. # 活动结束时间:2025-12-26 23:59:59 ET
  26. end_dt = eastern.localize(datetime(2025, 12, 26, 23, 59, 59))
  27. return start_dt <= current_dt <= end_dt
  28. @staticmethod
  29. def get_discount_email_content(device_name, end_date, days_remaining):
  30. """
  31. 获取优惠活动期间的邮件内容
  32. @param device_name: 设备名称
  33. @param end_date: 到期日期
  34. @param days_remaining: 剩余天数(7 或 3)
  35. @return: {‘subject': 邮件主题, 'html_body': HTML正文}
  36. """
  37. # 根据剩余天数设定不同的紧迫性文案
  38. if days_remaining == 7:
  39. urgency_text = "Your cloud storage plan is expiring soon."
  40. else: # 3 天
  41. urgency_text = "Your plan expires in just 3 days - Act now!"
  42. subject = f"Reminder: Cloud Storage Plan Expiring Soon for {device_name}"
  43. html_body = f"""
  44. <html>
  45. <head>
  46. <style>
  47. body {{ font-family: Arial, sans-serif; line-height: 1.6; color: #333; background-color: #f5f5f5; }}
  48. .container {{ max-width: 650px; margin: 20px auto; background-color: #ffffff; }}
  49. .header {{ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 30px 20px; text-align: center; }}
  50. .header h1 {{ margin: 0; font-size: 24px; font-weight: 600; }}
  51. .content {{ padding: 30px 25px; }}
  52. .notice-box {{ background-color: #FFF3CD; border-left: 4px solid #FFC107; padding: 15px; margin: 20px 0; border-radius: 4px; }}
  53. .notice-box strong {{ color: #856404; }}
  54. .section-title {{ color: #667eea; font-size: 18px; font-weight: 600; margin-top: 25px; margin-bottom: 15px; }}
  55. .pricing-table {{ width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 13px; }}
  56. .pricing-table th {{ background-color: #667eea; color: white; padding: 12px 8px; text-align: center; font-weight: 600; border: 1px solid #ddd; }}
  57. .pricing-table td {{ padding: 10px 8px; text-align: center; border: 1px solid #ddd; }}
  58. .pricing-table tr:nth-child(even) {{ background-color: #f9f9f9; }}
  59. .original-price {{ text-decoration: line-through; color: #999; font-size: 12px; display: block; }}
  60. .discount-price {{ color: #e74c3c; font-weight: bold; font-size: 14px; }}
  61. .highlight {{ color: #667eea; font-weight: bold; }}
  62. .steps {{ background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin: 15px 0; }}
  63. .steps ol {{ margin: 10px 0; padding-left: 20px; }}
  64. .steps li {{ margin: 8px 0; }}
  65. .contact-info {{ background-color: #e8f4f8; padding: 15px; border-radius: 5px; margin: 20px 0; }}
  66. .contact-info p {{ margin: 8px 0; }}
  67. .contact-info a {{ color: #667eea; text-decoration: none; }}
  68. .footer {{ background-color: #f8f9fa; padding: 20px; text-align: center; font-size: 12px; color: #666; border-top: 1px solid #ddd; }}
  69. .footer p {{ margin: 5px 0; }}
  70. .important-note {{ background-color: #d4edda; border-left: 4px solid #28a745; padding: 15px; margin: 20px 0; border-radius: 4px; }}
  71. </style>
  72. </head>
  73. <body>
  74. <div class="container">
  75. <div class="header">
  76. <h1>🔔 Cloud Storage Plan Expiration Reminder</h1>
  77. </div>
  78. <div class="content">
  79. <p>Dear Customer,</p>
  80. <div class="notice-box">
  81. <strong>⚠️ {urgency_text}</strong><br/>
  82. Your cloud storage package for device <strong>{device_name}</strong> will expire on <strong>{end_date}</strong>.
  83. If not renewed in time, your cloud storage service will be unavailable.
  84. </div>
  85. <p>To avoid data service interruption, we have prepared <span class="highlight">exclusive discounts on long-term plans</span> for you — much more cost-effective than monthly plans!</p>
  86. <h3 class="section-title">🎁 Plan Comparison - Choose What Fits Your Needs:</h3>
  87. <table class="pricing-table">
  88. <thead>
  89. <tr>
  90. <th style="width: 28%;">Plan Name</th>
  91. <th style="width: 18%;">1-Year Plan</th>
  92. <th style="width: 18%;">2-Year Plan</th>
  93. <th style="width: 18%;">3-Year Plan</th>
  94. <th style="width: 18%;">5-Year Plan</th>
  95. </tr>
  96. </thead>
  97. <tbody>
  98. <tr>
  99. <td style="text-align: left; font-weight: 600;">Zosi Cloud standard Plan</td>
  100. <td>
  101. <span class="original-price">$47.88</span>
  102. <span class="discount-price">$39.99</span>
  103. <div style="font-size: 11px; color: #28a745;">Save $7.89</div>
  104. </td>
  105. <td>
  106. <span class="original-price">$95.76</span>
  107. <span class="discount-price">$69.99</span>
  108. <div style="font-size: 11px; color: #28a745;">Save $25.77</div>
  109. </td>
  110. <td>
  111. <span class="original-price">$143.64</span>
  112. <span class="discount-price">$103.99</span>
  113. <div style="font-size: 11px; color: #28a745;">Save $39.65</div>
  114. </td>
  115. <td>
  116. <span class="original-price">$239.4</span>
  117. <span class="discount-price">$169.99</span>
  118. <div style="font-size: 11px; color: #28a745;">Save $69.41</div>
  119. </td>
  120. </tr>
  121. <tr>
  122. <td style="text-align: left; font-weight: 600;">Zosi Cloud standard + Al Plan</td>
  123. <td>
  124. <span class="original-price">$71.88</span>
  125. <span class="discount-price">$59.99</span>
  126. <div style="font-size: 11px; color: #28a745;">Save $11.89</div>
  127. </td>
  128. <td>
  129. <span class="original-price">$143.76</span>
  130. <span class="discount-price">$106.99</span>
  131. <div style="font-size: 11px; color: #28a745;">Save $36.77</div>
  132. </td>
  133. <td>
  134. <span class="original-price">$215.64</span>
  135. <span class="discount-price">$149.99</span>
  136. <div style="font-size: 11px; color: #28a745;">Save $65.65</div>
  137. </td>
  138. <td>
  139. <span class="original-price">$359.4</span>
  140. <span class="discount-price">$229.99</span>
  141. <div style="font-size: 11px; color: #28a745;">Save $129.41</div>
  142. </td>
  143. </tr>
  144. <tr>
  145. <td style="text-align: left; font-weight: 600;">Zosi Cloud Premium Plan</td>
  146. <td>
  147. <span class="original-price">$107.88</span>
  148. <span class="discount-price">$89.99</span>
  149. <div style="font-size: 11px; color: #28a745;">Save $17.89</div>
  150. </td>
  151. <td>
  152. <span class="original-price">$215.76</span>
  153. <span class="discount-price">$139.99</span>
  154. <div style="font-size: 11px; color: #28a745;">Save $75.77</div>
  155. </td>
  156. <td>
  157. <span class="original-price">$323.64</span>
  158. <span class="discount-price">$203.99</span>
  159. <div style="font-size: 11px; color: #28a745;">Save $119.65</div>
  160. </td>
  161. <td>
  162. <span class="original-price">$539.4</span>
  163. <span class="discount-price">$335.99</span>
  164. <div style="font-size: 11px; color: #28a745;">Save $203.41</div>
  165. </td>
  166. </tr>
  167. <tr>
  168. <td style="text-align: left; font-weight: 600;">Zosi Cloud Premium + Al Plan</td>
  169. <td>
  170. <span class="original-price">$131.88</span>
  171. <span class="discount-price">$109.99</span>
  172. <div style="font-size: 11px; color: #28a745;">Save $21.89</div>
  173. </td>
  174. <td>
  175. <span class="original-price">$263.76</span>
  176. <span class="discount-price">$199.99</span>
  177. <div style="font-size: 11px; color: #28a745;">Save $63.77</div>
  178. </td>
  179. <td>
  180. <span class="original-price">$395.64</span>
  181. <span class="discount-price">$249.99</span>
  182. <div style="font-size: 11px; color: #28a745;">Save $145.65</div>
  183. </td>
  184. <td>
  185. <span class="original-price">$659.4</span>
  186. <span class="discount-price">$389.99</span>
  187. <div style="font-size: 11px; color: #28a745;">Save $269.41</div>
  188. </td>
  189. </tr>
  190. </tbody>
  191. </table>
  192. <h3 class="section-title">🚀 How to Renew Quickly?</h3>
  193. <div class="steps">
  194. <ol>
  195. <li>Log in to your <strong>Zosi App</strong></li>
  196. <li>Click on the <strong>Cloud Storage</strong> icon</li>
  197. <li>Select <strong>"Cloud Storage Plan"</strong></li>
  198. <li>Choose your preferred plan and complete the payment</li>
  199. </ol>
  200. </div>
  201. <h3 class="section-title">📞 Need Help?</h3>
  202. <div class="contact-info">
  203. <p>If you encounter any issues during the renewal process, feel free to contact our <strong>24/7 Customer Service</strong>:</p>
  204. <p>📧 <strong>Support Email:</strong> <a href="mailto:support@zosisecurity.com">support@zosisecurity.com</a></p>
  205. <p>👥 <strong>Facebook:</strong> <a href="https://www.facebook.com/ZosiTechnology/" target="_blank">https://www.facebook.com/ZosiTechnology/</a></p>
  206. <p>🎫 <strong>Support Center:</strong> <a href="mailto:support@zositechhelp.zendesk.com">support@zositechhelp.zendesk.com</a></p>
  207. </div>
  208. <div class="important-note">
  209. <h4 style="margin-top: 0; color: #155724;">✨ Important Notes:</h4>
  210. <ul style="margin: 10px 0; padding-left: 20px;">
  211. <li>If you have already renewed, you can ignore this email. Your plan validity will be automatically extended.</li>
  212. <li>This discount is a <strong>limited-time offer</strong>. Prices will return to normal after the promotion period, so act now!</li>
  213. </ul>
  214. </div>
  215. <p style="margin-top: 25px;">Thank you for trusting <strong>Zosi Cloud Storage Service</strong>. We will continue to provide you with secure, stable, and convenient file storage experience, keeping your data safe and uninterrupted!</p>
  216. <p style="margin-top: 20px;">
  217. <strong>Best regards,</strong><br/>
  218. <strong>Zosi Technology</strong>
  219. </p>
  220. </div>
  221. <div class="footer">
  222. <p>This is an automated reminder. Please do not reply to this email.</p>
  223. <p>&copy; 2025 Zosi Technology. All rights reserved.</p>
  224. </div>
  225. </div>
  226. </body>
  227. </html>
  228. """
  229. return {'subject': subject, 'html_body': html_body}