Commit ee72d935 authored by xianyang's avatar xianyang

优化消费类型再分类汇总

parent 1dac305d
...@@ -231,7 +231,7 @@ class ReferenceTypeClassification(): ...@@ -231,7 +231,7 @@ class ReferenceTypeClassification():
def classification_summary(self): def classification_summary(self):
data_sql = f"select uuid,type,amount/1000 as amount,create_time from {self.date} where reference_type='{self.reference_type}' GROUP BY uuid,type" data_sql = f"select uuid,type,sum(amount)/1000 as amount,create_time from {self.date} where reference_type='{self.reference_type}' GROUP BY uuid,type"
guild_sql = f"select uuid from guild" guild_sql = f"select uuid from guild"
account_sql = f"select uuid,name from fi_account" account_sql = f"select uuid,name from fi_account"
anchor_sql = f"select uuid from v2_user where is_achor in(1,2)" anchor_sql = f"select uuid from v2_user where is_achor in(1,2)"
...@@ -257,9 +257,9 @@ class ReferenceTypeClassification(): ...@@ -257,9 +257,9 @@ class ReferenceTypeClassification():
op['money'] = round(float(op['amount']), 2) op['money'] = round(float(op['amount']), 2)
if op.get('uuid') in guild_data: if op.get('uuid') in guild_data:
op['nickname'] = '公会' op['nickname'] = '公会'
if op.get('uuid') in anchor_data: elif op.get('uuid') in anchor_data:
op['nickname'] = '主播' op['nickname'] = '主播'
if account_dict.get(op['uuid']): elif account_dict.get(op['uuid']):
op['nickname'] = account_dict.get(op['uuid']) op['nickname'] = account_dict.get(op['uuid'])
else: else:
op['nickname'] = '用户' op['nickname'] = '用户'
...@@ -277,6 +277,6 @@ class ReferenceTypeClassification(): ...@@ -277,6 +277,6 @@ class ReferenceTypeClassification():
if self.income: if self.income:
income = pd.DataFrame(self.income) income = pd.DataFrame(self.income)
igs = income.groupby("nickname").sum() igs = income.groupby("nickname").sum()
for k,v in igs.to_dict().get('money').items(): for k, v in igs.to_dict().get('money').items():
res_list.append({"type": "入账", "name": k, "money": v}) res_list.append({"type": "入账", "name": k, "money": v})
return res_list return res_list
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment