Browse Source

邮件发送调整为测试邮件

Signed-off-by: binren <zhangbr@elab-plus.com>
binren 4 years ago
parent
commit
816663ad08
2 changed files with 15 additions and 20 deletions
  1. 1 2
      flask_app.py
  2. 14 18
      jianye_report.py

+ 1 - 2
flask_app.py

@@ -272,8 +272,7 @@ def send_mail_to_customer():
     try:
         customer_id = request.args.get('id', default=0, type=int)
         mail = request.args.get('mail', default=None, type=str)
-        task_key = request.args.get('key', default=None, type=str)
-        data = rj.send_mail_for_customer_id(customer_id, task_key, mail)
+        data = rj.send_mail_for_customer_id(customer_id, mail)
         result['data'] = data
         pass
     except Exception as e:

+ 14 - 18
jianye_report.py

@@ -12,7 +12,7 @@ class JianYeReport(object):
         建业报表数据处理
     """
     # customer_mails = ['liutt@elab-plus.com', 'binrenzhang@qq.com', 'plf@centralchina.com']
-    customer_mails = ['liutt@elab-plus.com', 'binrenzhang@qq.com', 'zhuyl@elab-plus.com', 'lijm@elab-plus.com', 'xuanxc@elab-plus.com']
+    customer_mails = ['liutt@elab-plus.com', 'binrenzhang@qq.com', 'lijm@elab-plus.com', 'xuanxc@elab-plus.com']
 
     #
     index_type = [
@@ -385,7 +385,7 @@ class JianYeReport(object):
     def get_customer_info_by_id(self, customer_id):
         return self.db.select(Sql.sql_14, [customer_id])
 
-    def send_mail_for_customer_id(self, customer_id, task_key=None, new_mail=None):
+    def send_mail_for_customer_id(self, customer_id, new_mail=None):
         """
             获取指定客户的邮件信息
         :param customer_id:
@@ -393,11 +393,7 @@ class JianYeReport(object):
         :return:
         """
         message = {}
-        customers = []
-        if task_key:
-            customers = self.get_report_customers(task_key)
-        else:
-            customers = self.get_customer_info_by_id(customer_id)
+        customers = self.get_customer_info_by_id(customer_id)
         message['customer'] = str(customer_id)
         send_data = []
         if customers:
@@ -491,17 +487,17 @@ class JianYeReport(object):
 
     def send_mail(self, mail, send_mail_log):
         result = None
-        # for m in self.customer_mails:
-        if len(mail) == 6:
-            result = self.mail_util.send_mail_by_admin(mail[0], mail[1], mail[2], mail[3], mail[4])
-        elif len(mail) == 8:
-            result = self.mail_util.send_mail_by_admin(mail[0], mail[1], mail[2], mail[3], mail[4], mail[6],
-                                                  mail[7])
-        if result:
-            # name, mail, report_name, push_time, send_status, status, error_message
-            send_mail_log.append([mail[5], mail[2], mail[3], 1, 'success'])
-        else:
-            send_mail_log.append([mail[5], mail[2], mail[3], -1, '调用邮件接口失败:{}'.format(str(result))])
+        for m in self.customer_mails:
+            if len(mail) == 6:
+                result = self.mail_util.send_mail_by_admin(mail[0], mail[1], m, mail[3], mail[4])
+            elif len(mail) == 8:
+                result = self.mail_util.send_mail_by_admin(mail[0], mail[1], m, mail[3], mail[4], mail[6],
+                                                      mail[7])
+            if result:
+                # name, mail, report_name, push_time, send_status, status, error_message
+                send_mail_log.append([mail[5], mail[2], mail[3], 1, 'success'])
+            else:
+                send_mail_log.append([mail[5], mail[2], mail[3], -1, '调用邮件接口失败:{}'.format(str(result))])
         return send_mail_log
 
     def get_house_ids(self, ids_str):