CRM 竞争对手管理
参考文档索引
| 分类 | 文件 | 说明 | |------|------|------| | 认证 | authentication.md | 登录流程、密码加密、凭据提取 | | 基础 | base.md | 工具函数、编码规范 | | 枚举 | enums.md | 时间常量、dbType、searchCondition 通用结构 | | 配置 | module_config.json | viewId/insertPath 映射表 | | 竞争对手 | competitor.md | 查询竞争对手列表、新增竞争对手 | | 对手动态 | competitor_dynamic.md | 查询对手动态列表、新增对手动态 |
第一步:收集凭据(每次对话开始时)
尚未获取凭据时,使用 AskUserQuestion 工具一次性收集 4 个参数:
AskUserQuestion({
questions: [
{ header: "平台地址", question: "CRM 平台的 base_url 是什么?",
options: [{ label: "在下方输入平台地址", description: "例如 https://crm.example.com" }] },
{ header: "userId", question: "登录企业账号是什么?",
options: [{ label: "在下方输入企业账号", description: "企业 userId" }] },
{ header: "email", question: "登录账号是什么?",
options: [{ label: "在下方输入账号", description: "登录邮箱或账号" }] },
{ header: "密码", question: "登录密码是什么?",
options: [{ label: "在下方输入密码", description: "明文密码,自动加密" }] },
]
})
收集到凭据后,调用 scripts/crm_login.py 登录,获取 authToken、JSESSIONID、emp_id:
python scripts/crm_login.py \
--base-url <base_url> \
--user-id <userId> \
--email <email> \
--password <password>
登录成功输出 JSON:{"success": true, "authToken": "...", "JSESSIONID": "...", "emp_id": "..."}
凭据在当前会话中复用,不要重复询问。
常见操作速查
| 操作 | 接口 | 参考文档 |
|------|------|---------|
| 查询竞争对手列表 | POST /competitor/list | competitor.md |
| 新增竞争对手 | POST /competitor/insert(通用表单流程) | competitor.md |
| 查询对手动态列表 | POST /competitorDynamic/list | competitor_dynamic.md |
| 新增对手动态 | POST /competitorDynamic/insert(通用表单流程) | competitor_dynamic.md |
脚本工具
crm_login.py — 登录获取凭据
python scripts/crm_login.py \
--base-url https://xxx \
--user-id xxx \
--email xxx \
--password xxx
输出:{"success": true, "authToken": "...", "JSESSIONID": "...", "emp_id": "..."}
crm_query.py — 通用查询(使用凭据)
python scripts/crm_query.py \
--base-url https://xxx \
--jsessionid xxx \
--auth-token xxx \
--module-id competitor \
--limit 25
crm_form_submit.py — 通用表单提交(使用凭据)
# 仅查看模板
python scripts/crm_form_submit.py \
--base-url https://xxx \
--jsessionid xxx \
--auth-token xxx \
--view-id CompetitorAdd \
--template-only
# 提交新增
python scripts/crm_form_submit.py \
--base-url https://xxx \
--jsessionid xxx \
--auth-token xxx \
--view-id CompetitorAdd \
--data '{"name":"测试竞争对手"}'
关键注意事项
- 中文编码:所有含中文的请求必须通过 Python 脚本执行,不能用 Bash 直接 curl(详见 base.md)
- multipart 请求:使用
curl --data-binary @-通过 subprocess 发送 - 日期格式:提交格式必须为
Y-m-d H:i:s(含时间部分),如2026-06-05 00:00:00 - 响应数据位置:解析时用
resp.get('rows') or resp.get('data') or [] - 新增操作:使用通用表单流程(
scripts/crm_form_submit.py):view/form → 解析字段 → insert
微信扫一扫