|
@@ -549,6 +549,7 @@ class ReportPush(object):
|
|
|
result_data_8.append(x)
|
|
|
|
|
|
# 6: 项目获客来源场景分析
|
|
|
+ result_data_6 = self.house_with_brand_for_share(result_data_7, result_data_8)
|
|
|
|
|
|
customer_data[1] = result_data_1
|
|
|
customer_data[2] = result_data_2
|
|
@@ -561,6 +562,43 @@ class ReportPush(object):
|
|
|
result[name] = customer_data
|
|
|
return result
|
|
|
|
|
|
+ def house_with_brand_for_share(self, house_data, brand_data):
|
|
|
+ house_ids = []
|
|
|
+ result = []
|
|
|
+ for x in house_data:
|
|
|
+ if x[0] not in [x[0] for x in house_ids]:
|
|
|
+ house_ids.append([x[0], x[1]])
|
|
|
+ for x in brand_data:
|
|
|
+ if x[2] not in [x[0] for x in house_ids]:
|
|
|
+ house_ids.append([x[2], x[3]])
|
|
|
+ for id in house_ids:
|
|
|
+ house_id = id[0]
|
|
|
+ house_name = id[1]
|
|
|
+ house_result = [house_name]
|
|
|
+ equal_house = self.equal_by_house_id(house_data, house_id, 0)[2:]
|
|
|
+ equal_brand = self.equal_by_house_id(brand_data, house_id, 2)[4:]
|
|
|
+ house_result_part = []
|
|
|
+ if equal_house and equal_brand:
|
|
|
+ for i in range(0, 10):
|
|
|
+ house_result_part.append(self.add(equal_house[i], equal_brand[i]))
|
|
|
+ elif equal_house and not equal_brand:
|
|
|
+ for i in range(1, 10):
|
|
|
+ house_result_part.append(equal_house[i])
|
|
|
+ elif not equal_house and equal_brand:
|
|
|
+ for i in range(0, 1):
|
|
|
+ house_result_part.append(equal_brand[i])
|
|
|
+ house_result.append(sum(house_result_part))
|
|
|
+ house_result.extend(house_result_part)
|
|
|
+ result.append(house_result)
|
|
|
+ result.sort(key=lambda obj: obj[1])
|
|
|
+ result.reverse()
|
|
|
+ return result
|
|
|
+
|
|
|
+ def equal_by_house_id(self, data, house_id, index):
|
|
|
+ for x in data:
|
|
|
+ if x[index] == house_id:
|
|
|
+ return x
|
|
|
+
|
|
|
def filter_by_brand_ids(self, data, brand_ids):
|
|
|
result = []
|
|
|
for x in data:
|