Files
tw/legacy/scripts/init_designer_roster.py

46 lines
1.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""
初始化设计师派单数据SQLite
同一设计师在不同店铺对应不同 group_id。
用法:
python scripts/init_designer_roster.py
# 按提示添加设计师和店铺分组,或直接修改下方示例后运行
"""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from db.designer_roster_db import add_designer, set_designer_shop, list_designers, update_online
def init_example():
"""示例:添加设计师,同一人在不同店铺不同分组"""
# 设计师A在 小威哥1216 用分组 20252916034在 另一店铺 用 12345678
aid = add_designer("设计师A", "user_a")
set_designer_shop(aid, "小威哥1216", "20252916034")
set_designer_shop(aid, "另一店铺", "12345678")
# 设计师B只在 小威哥1216
bid = add_designer("设计师B", "user_b")
set_designer_shop(bid, "小威哥1216", "99998888")
# 可选:手动标记上线(否则等企微群解析)
update_online("user_a", True)
update_online("user_b", True)
print("示例数据已写入")
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == "example":
init_example()
elif len(sys.argv) > 1 and sys.argv[1] == "list":
for d in list_designers():
print(f"{d['name']} ({d['wechat_user_id']}) 在线={d['is_online']}")
for shop, gid in d["shops"].items():
print(f" - {shop} -> {gid}")
else:
print("用法: python scripts/init_designer_roster.py example # 写入示例")
print(" python scripts/init_designer_roster.py list # 查看当前数据")