CRM 订单管理
参考文档索引
| 分类 | 文件 | 说明 | |------|------|------| | 认证 | authentication.md | 登录流程、密码加密、凭据提取 | | 基础 | base.md | 工具函数、编码规范 | | 枚举 | enums.md | 时间常量、dbType、searchCondition 通用结构 | | 销售合同 | agree_ment.md | 查询销售合同列表、新增销售合同 | | 合同跟进 | agree_ment_follow.md | 查询合同跟进列表、新增合同跟进 | | 销售订单 | contract_order.md | 查询销售订单列表、新增销售订单 | | 订单跟进 | contract_order_follow.md | 查询订单跟进列表、新增订单跟进 | | 收款计划 | pay_plan.md | 查询收款计划列表、新增收款计划 | | 开票记录 | invoice.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 登录:
python scripts/crm_login.py \
--base-url <base_url> \
--user-id <userId> \
--email <email> \
--password <password>
登录成功输出 JSON:{"success": true, "authToken": "...", "JSESSIONID": "...", "emp_id": "..."}
凭据在当前会话中复用,不要重复询问。
常见操作速查
| 操作 | 接口 | 参考文档 |
|------|------|---------|
| 查询销售合同列表 | POST /agreeMent/list | agree_ment.md |
| 新增销售合同 | viewId=AgreeMentAdd → POST /agreeMent/insert | agree_ment.md |
| 查询合同跟进列表 | POST /agreeMentFollow/list | agree_ment_follow.md |
| 新增合同跟进 | viewId=AgreeMentFollowAdd → POST /agreeMentFollow/insert | agree_ment_follow.md |
| 查询销售订单列表 | POST /ContractOrder/list | contract_order.md |
| 新增销售订单 | viewId=ContractOrderAdd → POST /ContractOrder/insert | contract_order.md |
| 查询订单跟进列表 | POST /ContractOrderFollow/list | contract_order_follow.md |
| 新增订单跟进 | viewId=ContractOrderFollowAdd → POST /ContractOrderFollow/insert | contract_order_follow.md |
| 查询收款计划列表 | POST /PayPlan/list | pay_plan.md |
| 新增收款计划 | viewId=PayPlanAdd → POST /PayPlan/insert | pay_plan.md |
| 查询开票记录列表 | POST /Invoice/list | invoice.md |
| 新增开票记录 | viewId=InvoiceAdd → POST /Invoice/insert | invoice.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 agree_ment \
--limit 25
crm_form_submit.py — 通用表单提交(使用凭据)
# 仅查看模板
python scripts/crm_form_submit.py \
--base-url https://xxx \
--jsessionid xxx \
--auth-token xxx \
--view-id AgreeMentAdd \
--template-only
# 提交新增
python scripts/crm_form_submit.py \
--base-url https://xxx \
--jsessionid xxx \
--auth-token xxx \
--view-id AgreeMentAdd \
--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
Scan to join WeChat group