|  | @@ -484,165 +484,177 @@ class ReportPush(object):
 | 
	
		
			
				|  |  |          :param task_key:
 | 
	
		
			
				|  |  |          :return:
 | 
	
		
			
				|  |  |          """
 | 
	
		
			
				|  |  | -        # 根据任务key获取需要推送的客户以及可以的权限
 | 
	
		
			
				|  |  | -        result = {}
 | 
	
		
			
				|  |  | -        customers = self.db.select(self.sql_4, [task_key])
 | 
	
		
			
				|  |  | -        # a.task_key, a.customer_id, b.customer_type, b.`name`, b.mail, GROUP_CONCAT(c.house_or_brand_id)
 | 
	
		
			
				|  |  | -        time_range = self.get_time_range(task_key)
 | 
	
		
			
				|  |  | -        all_time_rang = self.get_time_range(4)
 | 
	
		
			
				|  |  | -        # 有限时间范围内的数据
 | 
	
		
			
				|  |  | -        xcx_top_data = self.xcx_top(time_range)
 | 
	
		
			
				|  |  | -        brand_top_data = self.brand_top(time_range)
 | 
	
		
			
				|  |  | -        customer_channel_details_data = self.customer_channel_details(time_range)
 | 
	
		
			
				|  |  | -        brand_customer_channel_details = self.brand_customer_channel_details(time_range)
 | 
	
		
			
				|  |  | -        # 所有历史数据
 | 
	
		
			
				|  |  | -        xcx_top_data_all = self.xcx_top(all_time_rang)
 | 
	
		
			
				|  |  | -        brand_top_data_all = self.brand_top(all_time_rang)
 | 
	
		
			
				|  |  | -        for customer in customers:
 | 
	
		
			
				|  |  | -            customer_data = {}
 | 
	
		
			
				|  |  | -            name = customer[3]
 | 
	
		
			
				|  |  | -            mail = customer[4]
 | 
	
		
			
				|  |  | -            customer_type = customer[2]
 | 
	
		
			
				|  |  | -            house_ids = []
 | 
	
		
			
				|  |  | -            brand_id_list = []
 | 
	
		
			
				|  |  | -            if customer_type == 1:
 | 
	
		
			
				|  |  | -                # 项目
 | 
	
		
			
				|  |  | -                ids = customer[5]
 | 
	
		
			
				|  |  | -                if str(ids).find(',') != -1:
 | 
	
		
			
				|  |  | -                    house_ids = [x for x in str(ids).split(',')]
 | 
	
		
			
				|  |  | -                else:
 | 
	
		
			
				|  |  | -                    house_ids = [ids]
 | 
	
		
			
				|  |  | -                brand_id_list = self.get_brand_ids_by_house_ids(house_ids)
 | 
	
		
			
				|  |  | -                pass
 | 
	
		
			
				|  |  | -            elif customer_type == 2:
 | 
	
		
			
				|  |  | -                # 集团
 | 
	
		
			
				|  |  | -                brand_ids = customer[5]
 | 
	
		
			
				|  |  | -                if str(brand_ids).find(',') != -1:
 | 
	
		
			
				|  |  | -                    brands = [x for x in str(brand_ids).split(',')]
 | 
	
		
			
				|  |  | -                else:
 | 
	
		
			
				|  |  | -                    brands = [brand_ids]
 | 
	
		
			
				|  |  | -                for id in brands:
 | 
	
		
			
				|  |  | -                    house_ids.extend([x[0] for x in self.get_house_ids_by_brand_id(id)])
 | 
	
		
			
				|  |  | -                brand_id_list = brands
 | 
	
		
			
				|  |  | +        message = []
 | 
	
		
			
				|  |  | +        try:
 | 
	
		
			
				|  |  | +            # 根据任务key获取需要推送的客户以及可以的权限
 | 
	
		
			
				|  |  | +            result = {}
 | 
	
		
			
				|  |  | +            customers = self.db.select(self.sql_4, [task_key])
 | 
	
		
			
				|  |  | +            # a.task_key, a.customer_id, b.customer_type, b.`name`, b.mail, GROUP_CONCAT(c.house_or_brand_id)
 | 
	
		
			
				|  |  | +            time_range = self.get_time_range(task_key)
 | 
	
		
			
				|  |  | +            all_time_rang = self.get_time_range(4)
 | 
	
		
			
				|  |  | +            # 有限时间范围内的数据
 | 
	
		
			
				|  |  | +            xcx_top_data = self.xcx_top(time_range)
 | 
	
		
			
				|  |  | +            message.append(1)
 | 
	
		
			
				|  |  | +            brand_top_data = self.brand_top(time_range)
 | 
	
		
			
				|  |  | +            message.append(2)
 | 
	
		
			
				|  |  | +            customer_channel_details_data = self.customer_channel_details(time_range)
 | 
	
		
			
				|  |  | +            message.append(3)
 | 
	
		
			
				|  |  | +            brand_customer_channel_details = self.brand_customer_channel_details(time_range)
 | 
	
		
			
				|  |  | +            message.append(4)
 | 
	
		
			
				|  |  | +            # 所有历史数据
 | 
	
		
			
				|  |  | +            xcx_top_data_all = self.xcx_top(all_time_rang)
 | 
	
		
			
				|  |  | +            message.append(5)
 | 
	
		
			
				|  |  | +            brand_top_data_all = self.brand_top(all_time_rang)
 | 
	
		
			
				|  |  | +            message.append(5)
 | 
	
		
			
				|  |  | +            for customer in customers:
 | 
	
		
			
				|  |  | +                customer_data = {}
 | 
	
		
			
				|  |  | +                name = customer[3]
 | 
	
		
			
				|  |  | +                mail = customer[4]
 | 
	
		
			
				|  |  | +                customer_type = customer[2]
 | 
	
		
			
				|  |  | +                house_ids = []
 | 
	
		
			
				|  |  | +                brand_id_list = []
 | 
	
		
			
				|  |  | +                if customer_type == 1:
 | 
	
		
			
				|  |  | +                    # 项目
 | 
	
		
			
				|  |  | +                    ids = customer[5]
 | 
	
		
			
				|  |  | +                    if str(ids).find(',') != -1:
 | 
	
		
			
				|  |  | +                        house_ids = [x for x in str(ids).split(',')]
 | 
	
		
			
				|  |  | +                    else:
 | 
	
		
			
				|  |  | +                        house_ids = [ids]
 | 
	
		
			
				|  |  | +                    brand_id_list = self.get_brand_ids_by_house_ids(house_ids)
 | 
	
		
			
				|  |  | +                    pass
 | 
	
		
			
				|  |  | +                elif customer_type == 2:
 | 
	
		
			
				|  |  | +                    # 集团
 | 
	
		
			
				|  |  | +                    brand_ids = customer[5]
 | 
	
		
			
				|  |  | +                    if str(brand_ids).find(',') != -1:
 | 
	
		
			
				|  |  | +                        brands = [x for x in str(brand_ids).split(',')]
 | 
	
		
			
				|  |  | +                    else:
 | 
	
		
			
				|  |  | +                        brands = [brand_ids]
 | 
	
		
			
				|  |  | +                    for id in brands:
 | 
	
		
			
				|  |  | +                        house_ids.extend([x[0] for x in self.get_house_ids_by_brand_id(id)])
 | 
	
		
			
				|  |  | +                    brand_id_list = brands
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            result_data_1 = []
 | 
	
		
			
				|  |  | -            result_data_2 = []
 | 
	
		
			
				|  |  | -            result_data_3 = []
 | 
	
		
			
				|  |  | -            result_data_4 = []
 | 
	
		
			
				|  |  | -            result_data_5 = []
 | 
	
		
			
				|  |  | -            result_data_7 = []
 | 
	
		
			
				|  |  | -            result_data_8 = []
 | 
	
		
			
				|  |  | +                result_data_1 = []
 | 
	
		
			
				|  |  | +                result_data_2 = []
 | 
	
		
			
				|  |  | +                result_data_3 = []
 | 
	
		
			
				|  |  | +                result_data_4 = []
 | 
	
		
			
				|  |  | +                result_data_5 = []
 | 
	
		
			
				|  |  | +                result_data_7 = []
 | 
	
		
			
				|  |  | +                result_data_8 = []
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            all_house_ids = self.get_house_ids_by_brand_ids(brand_id_list)
 | 
	
		
			
				|  |  | -            xcx_top_data_part = self.filter_by_house_ids(xcx_top_data, all_house_ids)
 | 
	
		
			
				|  |  | -            brand_top_data_part = self.filter_by_brand_ids(brand_top_data, brand_id_list)
 | 
	
		
			
				|  |  | -            xcx_top_data_all_part = self.filter_by_house_ids(xcx_top_data_all, all_house_ids)
 | 
	
		
			
				|  |  | -            brand_top_data_all_part = self.filter_by_brand_ids(brand_top_data_all, brand_id_list)
 | 
	
		
			
				|  |  | +                all_house_ids = self.get_house_ids_by_brand_ids(brand_id_list)
 | 
	
		
			
				|  |  | +                xcx_top_data_part = self.filter_by_house_ids(xcx_top_data, all_house_ids)
 | 
	
		
			
				|  |  | +                brand_top_data_part = self.filter_by_brand_ids(brand_top_data, brand_id_list)
 | 
	
		
			
				|  |  | +                xcx_top_data_all_part = self.filter_by_house_ids(xcx_top_data_all, all_house_ids)
 | 
	
		
			
				|  |  | +                brand_top_data_all_part = self.filter_by_brand_ids(brand_top_data_all, brand_id_list)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            # 1 数据总览 12个统计指标
 | 
	
		
			
				|  |  | -            data_overview = self.data_overview(time_range, house_ids, xcx_top_data_part, brand_top_data_part)
 | 
	
		
			
				|  |  | -            result_data_1.extend(data_overview)
 | 
	
		
			
				|  |  | -            # 4:单个项目小程序数据排行榜
 | 
	
		
			
				|  |  | -            # 排名	项目名称	总浏览量	总浏览人数	新增获客	新增获电
 | 
	
		
			
				|  |  | -            for index, x in enumerate(xcx_top_data_part):
 | 
	
		
			
				|  |  | -                if x[0] in house_ids:
 | 
	
		
			
				|  |  | -                    result_data_4.append([index, x[1], x[2], x[3], x[4], x[5]])
 | 
	
		
			
				|  |  | -            # 5: 集团项目数据排行榜
 | 
	
		
			
				|  |  | -            # 排名	项目名称	总浏览量	总浏览人数	新增获客	新增获电
 | 
	
		
			
				|  |  | -            if customer_type == 2:
 | 
	
		
			
				|  |  | -                for index, x2 in enumerate(brand_top_data_part):
 | 
	
		
			
				|  |  | -                    if x2[1] in house_ids or x2[0] in brand_id_list:
 | 
	
		
			
				|  |  | -                        result_data_5.append([index, x2[2], x2[3], x2[4], x2[5], x2[6]])
 | 
	
		
			
				|  |  | +                # 1 数据总览 12个统计指标
 | 
	
		
			
				|  |  | +                data_overview = self.data_overview(time_range, house_ids, xcx_top_data_part, brand_top_data_part)
 | 
	
		
			
				|  |  | +                result_data_1.extend(data_overview)
 | 
	
		
			
				|  |  | +                # 4:单个项目小程序数据排行榜
 | 
	
		
			
				|  |  | +                # 排名	项目名称	总浏览量	总浏览人数	新增获客	新增获电
 | 
	
		
			
				|  |  | +                for index, x in enumerate(xcx_top_data_part):
 | 
	
		
			
				|  |  | +                    if x[0] in house_ids:
 | 
	
		
			
				|  |  | +                        result_data_4.append([index, x[1], x[2], x[3], x[4], x[5]])
 | 
	
		
			
				|  |  | +                # 5: 集团项目数据排行榜
 | 
	
		
			
				|  |  | +                # 排名	项目名称	总浏览量	总浏览人数	新增获客	新增获电
 | 
	
		
			
				|  |  | +                if customer_type == 2:
 | 
	
		
			
				|  |  | +                    for index, x2 in enumerate(brand_top_data_part):
 | 
	
		
			
				|  |  | +                        if x2[1] in house_ids or x2[0] in brand_id_list:
 | 
	
		
			
				|  |  | +                            result_data_5.append([index, x2[2], x2[3], x2[4], x2[5], x2[6]])
 | 
	
		
			
				|  |  | +                        pass
 | 
	
		
			
				|  |  |                      pass
 | 
	
		
			
				|  |  | -                pass
 | 
	
		
			
				|  |  | -            elif customer_type == 1:
 | 
	
		
			
				|  |  | -                for index, x1 in enumerate(brand_top_data_part):
 | 
	
		
			
				|  |  | -                    if x1[1] in house_ids:
 | 
	
		
			
				|  |  | -                        result_data_5.append([index, x1[2], x1[3], x1[4], x1[5], x1[6]])
 | 
	
		
			
				|  |  | -            else:
 | 
	
		
			
				|  |  | -                pass
 | 
	
		
			
				|  |  | -            # 2: 项目数据排行榜
 | 
	
		
			
				|  |  | -            # 排名 项目名称 总浏览量 总浏览人数 新增获客 新增获电
 | 
	
		
			
				|  |  | -            house_with_brand_data = self.house_with_brand(xcx_top_data_part, brand_top_data_part)
 | 
	
		
			
				|  |  | -            for x in house_with_brand_data:
 | 
	
		
			
				|  |  | -                if x[2] in house_ids:
 | 
	
		
			
				|  |  | -                    x.pop(1)
 | 
	
		
			
				|  |  | -                    x.pop(1)
 | 
	
		
			
				|  |  | -                    result_data_2.append(x)
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            # 3: 项目历史累计总数
 | 
	
		
			
				|  |  | -            # 排名 项目名称	总浏览量	总浏览人数 新增获客 新增获电
 | 
	
		
			
				|  |  | -            if customer_type == 2:
 | 
	
		
			
				|  |  | -                all_data_history = self.house_with_brand(xcx_top_data_all_part, brand_top_data_all_part, brand_id_list)
 | 
	
		
			
				|  |  | -                for index, x in enumerate(all_data_history):
 | 
	
		
			
				|  |  | -                    if x[2] in house_ids or x[1] in brand_id_list:
 | 
	
		
			
				|  |  | -                        x.pop(1)
 | 
	
		
			
				|  |  | -                        x.pop(1)
 | 
	
		
			
				|  |  | -                        result_data_3.append(x)
 | 
	
		
			
				|  |  | -            else:
 | 
	
		
			
				|  |  | -                all_data_history = self.house_with_brand(xcx_top_data_all_part, brand_top_data_all_part)
 | 
	
		
			
				|  |  | -                for index, x in enumerate(all_data_history):
 | 
	
		
			
				|  |  | +                elif customer_type == 1:
 | 
	
		
			
				|  |  | +                    for index, x1 in enumerate(brand_top_data_part):
 | 
	
		
			
				|  |  | +                        if x1[1] in house_ids:
 | 
	
		
			
				|  |  | +                            result_data_5.append([index, x1[2], x1[3], x1[4], x1[5], x1[6]])
 | 
	
		
			
				|  |  | +                else:
 | 
	
		
			
				|  |  | +                    pass
 | 
	
		
			
				|  |  | +                # 2: 项目数据排行榜
 | 
	
		
			
				|  |  | +                # 排名 项目名称 总浏览量 总浏览人数 新增获客 新增获电
 | 
	
		
			
				|  |  | +                house_with_brand_data = self.house_with_brand(xcx_top_data_part, brand_top_data_part)
 | 
	
		
			
				|  |  | +                for x in house_with_brand_data:
 | 
	
		
			
				|  |  |                      if x[2] in house_ids:
 | 
	
		
			
				|  |  |                          x.pop(1)
 | 
	
		
			
				|  |  |                          x.pop(1)
 | 
	
		
			
				|  |  | -                        result_data_3.append(x)
 | 
	
		
			
				|  |  | +                        result_data_2.append(x)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            # 7: 单个项目小程序获客来源场景分析
 | 
	
		
			
				|  |  | -            # 项目 合计 长按识别二维码 会话 公众号菜单 公众号文章 小程序历史列表 扫一扫二维码 搜索 相册选取二维码 其他小程序 其他
 | 
	
		
			
				|  |  | -            for x in customer_channel_details_data:
 | 
	
		
			
				|  |  | -                if x[0] in house_ids:
 | 
	
		
			
				|  |  | -                    result_data_7.append(x)
 | 
	
		
			
				|  |  | +                # 3: 项目历史累计总数
 | 
	
		
			
				|  |  | +                # 排名 项目名称	总浏览量	总浏览人数 新增获客 新增获电
 | 
	
		
			
				|  |  | +                if customer_type == 2:
 | 
	
		
			
				|  |  | +                    all_data_history = self.house_with_brand(xcx_top_data_all_part, brand_top_data_all_part, brand_id_list)
 | 
	
		
			
				|  |  | +                    for index, x in enumerate(all_data_history):
 | 
	
		
			
				|  |  | +                        if x[2] in house_ids or x[1] in brand_id_list:
 | 
	
		
			
				|  |  | +                            x.pop(1)
 | 
	
		
			
				|  |  | +                            x.pop(1)
 | 
	
		
			
				|  |  | +                            result_data_3.append(x)
 | 
	
		
			
				|  |  | +                else:
 | 
	
		
			
				|  |  | +                    all_data_history = self.house_with_brand(xcx_top_data_all_part, brand_top_data_all_part)
 | 
	
		
			
				|  |  | +                    for index, x in enumerate(all_data_history):
 | 
	
		
			
				|  |  | +                        if x[2] in house_ids:
 | 
	
		
			
				|  |  | +                            x.pop(1)
 | 
	
		
			
				|  |  | +                            x.pop(1)
 | 
	
		
			
				|  |  | +                            result_data_3.append(x)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            # 8: 集团项目获客来源场景分析
 | 
	
		
			
				|  |  | -            if customer_type == 2:
 | 
	
		
			
				|  |  | -                for x in brand_customer_channel_details:
 | 
	
		
			
				|  |  | -                    if x[2] in house_ids or x[0] in brand_id_list:
 | 
	
		
			
				|  |  | -                        result_data_8.append(x)
 | 
	
		
			
				|  |  | -            elif customer_type == 1:
 | 
	
		
			
				|  |  | -                for x in brand_customer_channel_details:
 | 
	
		
			
				|  |  | -                    if x[2] in house_ids:
 | 
	
		
			
				|  |  | -                        result_data_8.append(x)
 | 
	
		
			
				|  |  | +                # 7: 单个项目小程序获客来源场景分析
 | 
	
		
			
				|  |  | +                # 项目 合计 长按识别二维码 会话 公众号菜单 公众号文章 小程序历史列表 扫一扫二维码 搜索 相册选取二维码 其他小程序 其他
 | 
	
		
			
				|  |  | +                for x in customer_channel_details_data:
 | 
	
		
			
				|  |  | +                    if x[0] in house_ids:
 | 
	
		
			
				|  |  | +                        result_data_7.append(x)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            # 6: 项目获客来源场景分析
 | 
	
		
			
				|  |  | -            result_data_6 = self.house_with_brand_for_share(result_data_7, result_data_8)
 | 
	
		
			
				|  |  | +                # 8: 集团项目获客来源场景分析
 | 
	
		
			
				|  |  | +                if customer_type == 2:
 | 
	
		
			
				|  |  | +                    for x in brand_customer_channel_details:
 | 
	
		
			
				|  |  | +                        if x[2] in house_ids or x[0] in brand_id_list:
 | 
	
		
			
				|  |  | +                            result_data_8.append(x)
 | 
	
		
			
				|  |  | +                elif customer_type == 1:
 | 
	
		
			
				|  |  | +                    for x in brand_customer_channel_details:
 | 
	
		
			
				|  |  | +                        if x[2] in house_ids:
 | 
	
		
			
				|  |  | +                            result_data_8.append(x)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            customer_data[1] = result_data_1
 | 
	
		
			
				|  |  | -            result_data_2.sort(key=lambda obj: obj[0])
 | 
	
		
			
				|  |  | -            customer_data[2] = result_data_2
 | 
	
		
			
				|  |  | -            result_data_3.sort(key=lambda obj: obj[0])
 | 
	
		
			
				|  |  | -            customer_data[3] = result_data_3
 | 
	
		
			
				|  |  | -            result_data_4.sort(key=lambda obj: obj[0])
 | 
	
		
			
				|  |  | -            customer_data[4] = result_data_4
 | 
	
		
			
				|  |  | -            result_data_5.sort(key=lambda obj: obj[0])
 | 
	
		
			
				|  |  | -            customer_data[5] = result_data_5
 | 
	
		
			
				|  |  | -            self.sort(result_data_6, 1)
 | 
	
		
			
				|  |  | -            customer_data[6] = result_data_6
 | 
	
		
			
				|  |  | -            result_data_7_format = []
 | 
	
		
			
				|  |  | -            for x in result_data_7:
 | 
	
		
			
				|  |  | -                house_name = x[1]
 | 
	
		
			
				|  |  | -                ele = [house_name]
 | 
	
		
			
				|  |  | -                data = x[2:]
 | 
	
		
			
				|  |  | -                total = sum(data)
 | 
	
		
			
				|  |  | -                ele.append(total)
 | 
	
		
			
				|  |  | -                ele.extend(data)
 | 
	
		
			
				|  |  | -                result_data_7_format.append(ele)
 | 
	
		
			
				|  |  | -            self.sort(result_data_7_format, 1)
 | 
	
		
			
				|  |  | -            customer_data[7] = result_data_7_format
 | 
	
		
			
				|  |  | -            result_data_8_format = []
 | 
	
		
			
				|  |  | -            for x in result_data_8:
 | 
	
		
			
				|  |  | -                ele = []
 | 
	
		
			
				|  |  | -                house_name = x[3]
 | 
	
		
			
				|  |  | -                data = x[4:]
 | 
	
		
			
				|  |  | -                total = sum(data)
 | 
	
		
			
				|  |  | -                ele.append(house_name)
 | 
	
		
			
				|  |  | -                ele.append(total)
 | 
	
		
			
				|  |  | -                ele.extend(data)
 | 
	
		
			
				|  |  | -                result_data_8_format.append(ele)
 | 
	
		
			
				|  |  | -            self.sort(result_data_8_format, 1)
 | 
	
		
			
				|  |  | -            customer_data[8] = result_data_8_format
 | 
	
		
			
				|  |  | -            customer_data[0] = mail
 | 
	
		
			
				|  |  | -            result[name] = customer_data
 | 
	
		
			
				|  |  | -        return result
 | 
	
		
			
				|  |  | +                # 6: 项目获客来源场景分析
 | 
	
		
			
				|  |  | +                result_data_6 = self.house_with_brand_for_share(result_data_7, result_data_8)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                customer_data[1] = result_data_1
 | 
	
		
			
				|  |  | +                result_data_2.sort(key=lambda obj: obj[0])
 | 
	
		
			
				|  |  | +                customer_data[2] = result_data_2
 | 
	
		
			
				|  |  | +                result_data_3.sort(key=lambda obj: obj[0])
 | 
	
		
			
				|  |  | +                customer_data[3] = result_data_3
 | 
	
		
			
				|  |  | +                result_data_4.sort(key=lambda obj: obj[0])
 | 
	
		
			
				|  |  | +                customer_data[4] = result_data_4
 | 
	
		
			
				|  |  | +                result_data_5.sort(key=lambda obj: obj[0])
 | 
	
		
			
				|  |  | +                customer_data[5] = result_data_5
 | 
	
		
			
				|  |  | +                self.sort(result_data_6, 1)
 | 
	
		
			
				|  |  | +                customer_data[6] = result_data_6
 | 
	
		
			
				|  |  | +                result_data_7_format = []
 | 
	
		
			
				|  |  | +                for x in result_data_7:
 | 
	
		
			
				|  |  | +                    house_name = x[1]
 | 
	
		
			
				|  |  | +                    ele = [house_name]
 | 
	
		
			
				|  |  | +                    data = x[2:]
 | 
	
		
			
				|  |  | +                    total = sum(data)
 | 
	
		
			
				|  |  | +                    ele.append(total)
 | 
	
		
			
				|  |  | +                    ele.extend(data)
 | 
	
		
			
				|  |  | +                    result_data_7_format.append(ele)
 | 
	
		
			
				|  |  | +                self.sort(result_data_7_format, 1)
 | 
	
		
			
				|  |  | +                customer_data[7] = result_data_7_format
 | 
	
		
			
				|  |  | +                result_data_8_format = []
 | 
	
		
			
				|  |  | +                for x in result_data_8:
 | 
	
		
			
				|  |  | +                    ele = []
 | 
	
		
			
				|  |  | +                    house_name = x[3]
 | 
	
		
			
				|  |  | +                    data = x[4:]
 | 
	
		
			
				|  |  | +                    total = sum(data)
 | 
	
		
			
				|  |  | +                    ele.append(house_name)
 | 
	
		
			
				|  |  | +                    ele.append(total)
 | 
	
		
			
				|  |  | +                    ele.extend(data)
 | 
	
		
			
				|  |  | +                    result_data_8_format.append(ele)
 | 
	
		
			
				|  |  | +                self.sort(result_data_8_format, 1)
 | 
	
		
			
				|  |  | +                customer_data[8] = result_data_8_format
 | 
	
		
			
				|  |  | +                customer_data[0] = mail
 | 
	
		
			
				|  |  | +                result[name] = customer_data
 | 
	
		
			
				|  |  | +            # return result
 | 
	
		
			
				|  |  | +        except:
 | 
	
		
			
				|  |  | +            pass
 | 
	
		
			
				|  |  | +        finally:
 | 
	
		
			
				|  |  | +            return message
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      def sort(self, data, idnex):
 | 
	
		
			
				|  |  |          data.sort(key=lambda obj: obj[idnex])
 |