|
@@ -402,50 +402,49 @@ class JianYeReport(object):
|
|
|
:return:
|
|
|
"""
|
|
|
message = {}
|
|
|
- customer = 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 customer:
|
|
|
- try:
|
|
|
- save_path = FileUtil().save_path_create()
|
|
|
- name = customer[1]
|
|
|
- mail = customer[2]
|
|
|
- customer_type = customer[3]
|
|
|
- ids = self.get_house_ids(customer[5])
|
|
|
- region_name = customer[4]
|
|
|
- title = self.get_mail_title(customer_type, region_name, name)
|
|
|
- content = self.get_mail_content(customer_type)
|
|
|
- file_path = save_path + '/' + title + '.xls'
|
|
|
- if customer_type == 1:
|
|
|
- # 项目
|
|
|
- table_2 = self.house_data(self.get_house_ids(ids))
|
|
|
- send_data.append(
|
|
|
- [table_2, self.sheet_names_1, title, [self.head_1, self.head_1, self.head_1], file_path,
|
|
|
- content, name, mail])
|
|
|
- elif customer_type == 2:
|
|
|
- # 集团
|
|
|
- brand_table_one = self.brand_data()
|
|
|
- house_ids = self.get_house_id_by_brand_id('13')
|
|
|
- brand_table_two = self.house_data(house_ids)
|
|
|
- content = self.get_brand_content(content, brand_table_one)
|
|
|
- send_data.append(
|
|
|
- [brand_table_two, self.sheet_names_1, title, [self.head_1, self.head_1, self.head_1],
|
|
|
- file_path, content, name, mail])
|
|
|
- elif customer_type == 3:
|
|
|
- # 区域
|
|
|
- table_2 = self.house_data(self.get_house_ids(ids))
|
|
|
- message['data'] = table_2
|
|
|
- send_data.append(
|
|
|
- [table_2, self.sheet_names_1, title, [self.head_1, self.head_1, self.head_1], file_path,
|
|
|
- content, name, mail])
|
|
|
- else:
|
|
|
- message['customer_type'] = '客户类型错误'
|
|
|
- except Exception as e:
|
|
|
- message['数据查询失败'] = str(e)
|
|
|
- else:
|
|
|
- message['error'] = '客户id错误:{}'.format(customer_id)
|
|
|
+ if customers:
|
|
|
+ for customer in customers:
|
|
|
+ try:
|
|
|
+ save_path = FileUtil().save_path_create()
|
|
|
+ name = customer[1]
|
|
|
+ mail = customer[2]
|
|
|
+ customer_type = customer[3]
|
|
|
+ ids = self.get_house_ids(customer[5])
|
|
|
+ region_name = customer[4]
|
|
|
+ title = self.get_mail_title(customer_type, region_name, name)
|
|
|
+ content = self.get_mail_content(customer_type)
|
|
|
+ file_path = save_path + '/' + title + '.xls'
|
|
|
+ if customer_type == 1:
|
|
|
+ # 项目
|
|
|
+ table_2 = self.house_data(self.get_house_ids(ids))
|
|
|
+ send_data.append(
|
|
|
+ [table_2, self.sheet_names_1, title, [self.head_1, self.head_1, self.head_1], file_path,
|
|
|
+ content, name, mail])
|
|
|
+ elif customer_type == 2:
|
|
|
+ # 集团
|
|
|
+ brand_table_one = self.brand_data()
|
|
|
+ house_ids = self.get_house_id_by_brand_id('13')
|
|
|
+ brand_table_two = self.house_data(house_ids)
|
|
|
+ content = self.get_brand_content(content, brand_table_one)
|
|
|
+ send_data.append(
|
|
|
+ [brand_table_two, self.sheet_names_1, title, [self.head_1, self.head_1, self.head_1],
|
|
|
+ file_path, content, name, mail])
|
|
|
+ elif customer_type == 3:
|
|
|
+ # 区域
|
|
|
+ table_2 = self.house_data(self.get_house_ids(ids))
|
|
|
+ send_data.append(
|
|
|
+ [table_2, self.sheet_names_1, title, [self.head_1, self.head_1, self.head_1], file_path,
|
|
|
+ content, name, mail])
|
|
|
+ else:
|
|
|
+ message['customer_type'] = '客户类型错误'
|
|
|
+ except Exception as e:
|
|
|
+ message['数据查询失败'] = str(e)
|
|
|
+ else:
|
|
|
+ message['error'] = '客户id错误:{}'.format(customer_id)
|
|
|
|
|
|
- message['query_data'] = 'success'
|
|
|
# 生成文件
|
|
|
rfu = ReportFileUtils()
|
|
|
send_mail_log = []
|
|
@@ -477,7 +476,7 @@ class JianYeReport(object):
|
|
|
send_mail_log.append([mail[5], mail[2], mail[3], -1, '邮件发送失败:{}'.format(str(e))])
|
|
|
# 写入日志
|
|
|
self.db.add_some(Sql.sql_12, send_mail_log)
|
|
|
- return message
|
|
|
+ pass
|
|
|
|
|
|
def get_house_ids(self, ids_str):
|
|
|
if str(ids_str).find(',') == -1:
|