forked from erp-dev/erp
feat: mission replied calling task
This commit is contained in:
@@ -23,6 +23,10 @@
|
||||
| `rejected_by` | 撤销人,由后端写入 |
|
||||
| `rejected_at` | 撤销时间,由后端写入 |
|
||||
|
||||
说明:
|
||||
|
||||
- 本次新增的“未回复提醒配置字段”不属于状态字段,允许通过普通创建/更新接口维护
|
||||
|
||||
## content_type 说明
|
||||
|
||||
`content_type` 和 `content_id` 是可选的"关联业务对象"字段,用于把任务挂靠到系统中的某个具体业务单据或对象上。
|
||||
@@ -109,6 +113,11 @@
|
||||
"is_urgent": false,
|
||||
"is_completed": false,
|
||||
"is_cancelled": false,
|
||||
"notify_if_unreplied": false,
|
||||
"unreplied_notify_interval_minutes": null,
|
||||
"unreplied_notify_max_count": 5,
|
||||
"unreplied_notify_sent_count": 0,
|
||||
"unreplied_last_notified_at": null,
|
||||
"cancelled_at": null,
|
||||
"creator": {
|
||||
"id": 20,
|
||||
@@ -246,6 +255,9 @@
|
||||
| `category` | int | 否 | 任务分类 ID;不传时默认使用当前商户下名称为“通用”的分类,不存在则自动创建 |
|
||||
| `content_type` | int/null | 否 | Django ContentType ID;必须与 `content_id` 同时提供或同时省略 |
|
||||
| `content_id` | int/null | 否 | 关联业务对象 ID;必须与 `content_type` 同时提供或同时省略 |
|
||||
| `notify_if_unreplied` | boolean | 否 | 是否开启“未回复持续提醒”,默认 `false` |
|
||||
| `unreplied_notify_interval_minutes` | int/null | 否 | 未回复提醒间隔(分钟);开启未回复提醒时必填 |
|
||||
| `unreplied_notify_max_count` | int | 否 | 最大提醒次数,默认 `5` |
|
||||
| `participant_ids` | int[] | 否 | 参与者员工 ID 列表,必须属于当前商户 |
|
||||
|
||||
说明:
|
||||
@@ -254,6 +266,8 @@
|
||||
- `category_name` 为只读字段,由后端根据分类表返回
|
||||
- `is_urgent`、`is_completed`、`is_cancelled` 均按默认值创建,不接受请求参数
|
||||
- 若关联对象存在 `merchant_id` 字段,后端会校验它必须属于当前商户
|
||||
- 若 `notify_if_unreplied=true`,则必须同时传入 `unreplied_notify_interval_minutes`
|
||||
- `unreplied_notify_sent_count` 与 `unreplied_last_notified_at` 为只读运行时字段,由后端维护
|
||||
|
||||
请求示例:
|
||||
|
||||
@@ -261,6 +275,9 @@
|
||||
{
|
||||
"description": "跟进客户问题",
|
||||
"category": 1,
|
||||
"notify_if_unreplied": true,
|
||||
"unreplied_notify_interval_minutes": 30,
|
||||
"unreplied_notify_max_count": 5,
|
||||
"participant_ids": [21, 22]
|
||||
}
|
||||
```
|
||||
@@ -289,10 +306,18 @@
|
||||
| `category` | int | 任务分类 ID |
|
||||
| `content_type` | int/null | 关联对象类型;必须与 `content_id` 同时提供 |
|
||||
| `content_id` | int/null | 关联对象 ID;必须与 `content_type` 同时提供 |
|
||||
| `notify_if_unreplied` | boolean | 是否开启“未回复持续提醒” |
|
||||
| `unreplied_notify_interval_minutes` | int/null | 未回复提醒间隔(分钟) |
|
||||
| `unreplied_notify_max_count` | int | 最大提醒次数 |
|
||||
| `participant_ids` | int[] | 重置参与者列表 |
|
||||
|
||||
禁止更新状态字段,见“基本约定”
|
||||
|
||||
补充说明:
|
||||
|
||||
- 更新 `notify_if_unreplied`、`unreplied_notify_interval_minutes` 时,后端会重置当前任务的未回复提醒计数与上次提醒时间
|
||||
- 更新 `unreplied_notify_max_count` 不会重置已提醒次数
|
||||
|
||||
成功响应:`Mission`
|
||||
|
||||
## 删除任务
|
||||
@@ -390,6 +415,7 @@ HTTP 状态码:`405 Method Not Allowed`
|
||||
- `Mission.cancelled_by=当前员工`
|
||||
- `Mission.cancelled_at=当前时间`
|
||||
- 不强行修改 `Mission.is_completed`
|
||||
- 后端会停止当前任务后续的未回复提醒,并保留任务上的提醒历史字段供查看
|
||||
|
||||
成功响应:`Mission`
|
||||
|
||||
@@ -431,7 +457,37 @@ HTTP 状态码:`405 Method Not Allowed`
|
||||
- 当前回应标记为 `is_rejected=true`
|
||||
- 当前回应的 `rejected_by`、`rejected_at` 由后端写入
|
||||
- 如果当前回应原本是唯一有效的结束回应,则对应任务会被重新置为未完成
|
||||
- 如果任务重新回到“没有任何有效回复”的状态,后端会重置未回复提醒计数,并从新的空窗期重新开始计算后续提醒
|
||||
|
||||
成功响应:`MissionReply`
|
||||
|
||||
无权限响应:`403 Forbidden`
|
||||
|
||||
## 未回复提醒规则
|
||||
|
||||
当任务开启 `notify_if_unreplied=true` 时,系统会通过每分钟一次的后台定时任务检查是否需要发送“未回复提醒”。
|
||||
|
||||
判定规则:
|
||||
|
||||
1. 任务开启了未回复提醒
|
||||
2. 任务未完成
|
||||
3. 任务未取消
|
||||
4. 任务当前没有任何有效回复(`is_rejected=false` 的回复)
|
||||
5. `unreplied_notify_sent_count < unreplied_notify_max_count`
|
||||
6. 到达提醒时间:
|
||||
- 从未提醒过:`created_at + unreplied_notify_interval_minutes`
|
||||
- 已提醒过:`unreplied_last_notified_at + unreplied_notify_interval_minutes`
|
||||
|
||||
发送成功后:
|
||||
|
||||
- `unreplied_notify_sent_count` 自增 1
|
||||
- `unreplied_last_notified_at` 更新为本次成功发送时间
|
||||
|
||||
收到有效回复后:
|
||||
|
||||
- 当前未回复提醒周期会被停止
|
||||
- `unreplied_notify_sent_count` 与 `unreplied_last_notified_at` 会被重置
|
||||
|
||||
如果后续因为撤销回复或 reopen 重新回到“无有效回复”状态:
|
||||
|
||||
- 系统会把该任务视为一个新的未回复周期重新开始计时
|
||||
|
||||
Reference in New Issue
Block a user