Back to skills
extension
Category: OtherNo API key required

35CRM商机管理

35CRM 商机管理模块,涵盖销售商机、商机跟进、商机任务、报价管理四大功能。

personAuthor: u_d22e0ecehubenterprise

CRM 商机管理

参考文档索引

| 分类 | 文件 | 说明 | |------|------|------| | 认证 | authentication.md | 登录流程、密码加密、凭据提取 | | 基础 | base.md | 工具函数、编码规范 | | 枚举 | enums.md | 时间常量、dbType、searchCondition 通用结构 | | 销售商机 | sale_chance.md | 查询销售商机列表、新增销售商机 | | 商机跟进 | sale_chance_follow.md | 查询商机跟进列表、新增商机跟进 | | 商机任务 | chance_task.md | 查询商机任务列表、新增商机任务 | | 报价管理 | quotation.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 /saleChance/list | sale_chance.md | | 新增销售商机 | viewId=SaleChanceAddPOST /saleChance/insert | sale_chance.md | | 查询商机跟进列表 | POST /saleChanceFollow/list | sale_chance_follow.md | | 新增商机跟进 | viewId=SaleChanceFollowAddPOST /saleChanceFollow/insert | sale_chance_follow.md | | 查询商机任务列表 | POST /chanceTask/list | chance_task.md | | 新增商机任务 | viewId=ChanceTaskAddPOST /chanceTask/insert | chance_task.md | | 查询报价管理列表 | POST /quotation/list | quotation.md | | 新增报价管理 | viewId=QuotationAddPOST /quotation/insert | quotation.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 sale_chance \
  --limit 25

crm_form_submit.py — 通用表单提交(使用凭据)

# 仅查看模板
python scripts/crm_form_submit.py \
  --base-url https://xxx \
  --jsessionid xxx \
  --auth-token xxx \
  --view-id SaleChanceAdd \
  --template-only

# 提交新增
python scripts/crm_form_submit.py \
  --base-url https://xxx \
  --jsessionid xxx \
  --auth-token xxx \
  --view-id SaleChanceAdd \
  --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