auto: sync OpenClaw config 2026-08-08 17:17
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""分析汪礼平2026年(1-7月)转账/红包往来"""
|
||||
import json, pymysql, re
|
||||
from collections import defaultdict
|
||||
cfg = json.load(open('db_config.json'))
|
||||
conn = pymysql.connect(host=cfg['host'], port=cfg['port'], user=cfg['user'],
|
||||
password=str(cfg['password']), database=cfg['database'], charset='utf8mb4')
|
||||
cur = conn.cursor()
|
||||
|
||||
cur.execute("""
|
||||
SELECT recorded_date, amount, note FROM variable_expenses
|
||||
WHERE member_id=1 AND recorded_date BETWEEN '2026-01-01' AND '2026-07-31'
|
||||
AND (category='转账/红包' OR category LIKE '%红包%' OR note LIKE '%微信转账%' OR note LIKE '%微信红包%')
|
||||
ORDER BY recorded_date
|
||||
""")
|
||||
rows = cur.fetchall()
|
||||
|
||||
def peer_of(note):
|
||||
parts = [p.strip() for p in note.replace('[微信] ', '').split('|')]
|
||||
if len(parts) >= 2:
|
||||
return parts[1]
|
||||
return '(未知)'
|
||||
|
||||
by_peer_month = defaultdict(set)
|
||||
by_peer_total = defaultdict(float)
|
||||
by_peer_count = defaultdict(int)
|
||||
by_peer_amounts = defaultdict(list)
|
||||
|
||||
for d, amt, note in rows:
|
||||
p = peer_of(note)
|
||||
m = d.strftime('%Y-%m')
|
||||
a = float(amt)
|
||||
by_peer_month[p].add(m)
|
||||
by_peer_total[p] += a
|
||||
by_peer_count[p] += 1
|
||||
by_peer_amounts[p].append((d.strftime('%m-%d'), a))
|
||||
|
||||
conn.close()
|
||||
|
||||
print(f'2026年1-7月 转账/红包共 {len(rows)} 笔\n')
|
||||
cands = [(by_peer_count[p], by_peer_total[p], p, sorted(by_peer_month[p]), by_peer_amounts[p])
|
||||
for p in by_peer_month]
|
||||
cands.sort(key=lambda x: (-x[1]))
|
||||
print('=== 按累计金额排序 ===')
|
||||
for cnt, tot, p, months, amts in cands:
|
||||
print(f'\n◆ {p} | {cnt}笔 | 累计 ¥{tot:,.0f} | {len(months)}个月 {months}')
|
||||
details = '、'.join(f'{d}¥{a:.0f}' for d, a in amts)
|
||||
print(f' 明细: {details}')
|
||||
Reference in New Issue
Block a user