最后更新:2026-05-26
| 项目 | 值 |
|---|---|
| 地址 | http://182.61.44.242:16888 |
| 企业编号 | st |
| 账号 | 888 |
| 密码 | 123456 |
| 系统名称 | 欧普V8移动报表 V3.1 |
| 后端 | Python uvicorn |
curl 抓取 → 解析 HTML → 生成静态页面 → 飞书通知
0.5s 即时 即时 即时
# 当天数据
python3 ~/erp_daily_report.py
# 指定日期
python3 ~/erp_daily_report.py --date 2026-05-25
# 不发飞书
python3 ~/erp_daily_report.py --no-feishu
# 发飞书群(而非私发)
python3 ~/erp_daily_report.py --to-group
脚本:~/erp_fetch.py
python3 ~/erp_fetch.py # 当天
python3 ~/erp_fetch.py --date 2026-05-25 # 指定日期
核心原理:
# 1. 登录(获取 session cookie)
curl -s -c /tmp/erp_cookies.txt -X POST http://182.61.44.242:16888/login \
-d "tenant_code=st&username=888&password=123456"
# 2. 查询零售汇总(店铺+商品+颜色 + 实时POS)
curl -s -b /tmp/erp_cookies.txt \
"http://182.61.44.242:16888/retail/summary?start_date=2026-05-26&end_date=2026-05-26&spid=&cdid=&price_type=CKJJ&ztstate=&ywyid=&mode=10&is_pos=1"
# 3. 解析 HTML <tr> 表格,提取 13 列数据:
# 店铺编码 | 店铺名称 | 商品编码 | 商品名称 | 颜色编码 | 颜色 |
# 数量 | 单价 | 折扣 | 金额 | 结算金额 | 选择价格 | 选择价格金额
关键参数:
| 参数 | 值 | 说明 |
|---|---|---|
mode |
10 |
店铺+商品+颜色汇总 |
is_pos |
1 |
包含实时POS销售数据 |
price_type |
CKJJ |
价格类型:参考进价 |
输出:/tmp/erp_store_data.json
{
"date": "2026-05-26",
"header": ["店铺编码", "店铺名称", ...],
"rows": [["STA108", "八店", "YG75069-3", ...], ...],
"summary": {
"total_qty": 23,
"total_amt": 6622,
"avg_price": 288,
"avg_discount": 0.651,
"unique_stores": 5,
"unique_products": 23
},
"stores": [
{"code": "STA102", "name": "二店", "qty": 3, "amt": 889},
...
]
}
在 ~/erp_daily_report.py 中完成:
total_qty = sum(int(r['数量']) for r in rows)
total_amt = sum(float(r['金额']) for r in rows)
total_sel = sum(float(r['选择价格金额']) for r in rows)
profit = round(total_amt - total_sel) # 毛利 = 金额 - 选择价格金额
# 店铺均价(4店不含商场)
shop_stores = ['STA102','STA104','STA105','STA106']
shop_qty = sum(store_qty[s] for s in shop_stores)
shop_amt = sum(store_amt[s] for s in shop_stores)
shop_avg = round(shop_amt / shop_qty)
# 商场均价
mall_qty = store_qty['STA108']
mall_amt = store_amt['STA108']
mall_avg = round(mall_amt / mall_qty)
输出路径:/var/www/sieta/sietadata/erp/report_{YYYYMMDD}.html
访问 URL:https://www.sieta.vip/sietadata/erp/report_{YYYYMMDD}.html
页面结构详见 即时销售表.md。
# 获取 token
curl -X POST https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal
-d '{"app_id":"cli_a97a74d749b85cd4","app_secret":"..."}'
# 私发
curl -X POST https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=open_id
-d '{"receive_id":"ou_f6159b423503f8f6927b2c8150c785a4","msg_type":"text",...}'
# 发群 oc_569a
curl ... -d '{"receive_id":"oc_569a01e75d67f5f0422a994aa7132365","receive_id_type":"chat_id",...}'
凭据从 ~/.hermes/.env 读取 FEISHU_APP_SECRET。
| 条件 | value |
|---|---|
| 商品汇总 | 0 |
| 商品+颜色汇总 | 1 |
| 营业员汇总 | 3 |
| 店铺汇总 | 7 |
| 店铺+商品汇总 | 8 |
| 店铺+商品+颜色汇总 | 10 |
| 店铺+商品+颜色汇总(显示尺码) | 11 |
| 日期汇总 | 12 |
| 折扣汇总 | 16 |
| curl | Playwright | |
|---|---|---|
| 耗时 | 0.5 秒 | 7 秒 |
| 依赖 | 零(bash+python) | Chrome + venv |
| 可靠性 | 100%(纯 HTTP) | 偶有超时 |
| 适用 | 服务端渲染 HTML | JS 动态页面 |
ERP 的表格数据是服务端直出的 HTML,不需要 JS 渲染,curl 完美适用。
| 文件 | 作用 |
|---|---|
~/erp_fetch.py |
curl 抓取 + 解析,输出 JSON |
~/erp_daily_report.py |
全流程:抓取→计算→生成页面→飞书 |
~/即时销售表.md |
页面设计规范 |
~/即时销售表Workflow.md |
本文档 |
/var/www/sieta/sietadata/erp/ |
HTML 页面输出目录 |
q_mode=10,不是 q_mode=店铺+商品+颜色汇总金额 - 选择价格金额,不是 金额 - 结算金额instant_sales.html(固定不变,始终只有一个文件)/var/www/sieta/sietadata/erp/instant_sales.htmlhttps://www.sieta.vip/sietadata/erp/instant_sales.htmlsales_*.html、pics_*.html、report_*.html、charts_*.html 已全部删除即时销售表 2026-05-26 20:35
https://www.sieta.vip/sietadata/erp/instant_sales.html
销售:¥6,622 毛利:¥3,451 23双