S4-D1/D2: C1 回调推送引擎+C2 上行自动拉黑——验收项「死信可查/拒收即拉黑」✅: ①C1=callback_task 队列表(迁移 v21,状态机 pending→sent/dead+attempt/next_retry_at/last_code)+PushWorker(2s 扫/批 100/并发 8/2^n 秒指数退避封顶 10min/10 次耗尽死信/UPDATE CAS 防竞态)+双挂点(report 终态首锁[Consumer+PairService,与 CMPP Deliver 同点同语义]+uplink 消费尾)+URL 门控 account_config.report_url/uplink_url(60s TTL 缓存,未配置零任务)+GET /ops/callback(列表+状态计数面板)/POST /ops/callback/:id/resend(casbin ops callback:read/write v21 所种)+前端回调管理页(ops-callback 路由系统管理组+api/callback.ts+状态面板/筛选/载荷展开/死信重派;matrix+guard 33 菜单显式更)+metrics callback_push_total{type,result}/blacklist_total+openapi v1.4.0;②C2=AutoBlacklister 等值词表(trim+lower 防误伤,默认 R/TD/退订/拒收;SystemConfig uplink.blacklist.keywords 可配 60s 刷新)→policy_blacklist(source=2/账号级/uk 幂等)+Redis Set 即时生效,拉黑不影响上行推送(需求原文);③真机全链六步实证(dev 中间件):回执 DELIVRD→detail 终态→HTTP 回调 JSON 送达(200/sent)+上行 R→拉黑(source=2+Redis=1)+推送送达+坏 URL→attempt10→dead→resend ISC:000→修复重投 sent+status_counts 面板;一次性探针 cmd/cbprobe 用后即删+冒烟数据全清;④单测 +13(callback 6[入队门控/载荷/状态机全链/并发批]+uplink 5[词表/配置覆盖/幂等缓存/消费链]+report 2[首锁一次/nil]);⑤门禁=build/vet/-race 40 包/lint 0/eslint0/vue-tsc0/vitest 148/build 全绿;迁移测试 v15..v21 两遍幂等+dev 实跑 v21;gofmt 存量 8 文件顺手清零(S2 遗留);⑥口径诚实标注:载荷无签名挂账/拦截终态 HTTP 未挂(CMPP 侧已有)/PushWorker 单实例 at-least-once;验收单 s4-d1d2-callback.md+CHANGELOG+memory-bank 回填
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/** 回调任务管理 API(S4·C1;openapi v1.4.0 契约)。 */
|
||||
import { get, post } from './request'
|
||||
|
||||
/** 回调任务(status: 0待推送 1已送达 2死信;type: 1回执终态 2上行)。 */
|
||||
export interface CallbackTask {
|
||||
id: number
|
||||
account_id: number
|
||||
type: number
|
||||
url: string
|
||||
payload: string
|
||||
status: number
|
||||
attempt: number
|
||||
next_retry_at: string
|
||||
last_code: number
|
||||
last_err: string
|
||||
sent_at: string | null
|
||||
created_at: string
|
||||
}
|
||||
|
||||
/** 列表结果(含状态计数面板)。 */
|
||||
export interface CallbackListResult {
|
||||
total: number
|
||||
list: CallbackTask[]
|
||||
status_counts: { pending?: number; sent?: number; dead?: number }
|
||||
}
|
||||
|
||||
export const callbackApi = {
|
||||
list: (params: Record<string, unknown>) => get<CallbackListResult>('/ops/callback', params),
|
||||
resend: (id: number) => post<{ id: number; resent: boolean }>(`/ops/callback/${id}/resend`),
|
||||
}
|
||||
|
||||
/** 状态码值 → 中文标签。 */
|
||||
export const CALLBACK_STATUS: Record<number, string> = { 0: '待推送', 1: '已送达', 2: '死信' }
|
||||
export const CALLBACK_TYPE: Record<number, string> = { 1: '回执终态', 2: '上行消息' }
|
||||
@@ -71,6 +71,8 @@ export const asyncRoutes: RouteRecordRaw[] = [
|
||||
{ path: 'stats/channel', name: 'stats-channel', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '通道统计', icon: 'TrendCharts', menu: true, group: '统计结算', roles: ['admin', 'ops'] } },
|
||||
{ path: 'stats/profit', name: 'stats-profit', component: () => import('@/views/stats/profit/index.vue'), meta: { title: '利润分析', icon: 'Coin', menu: true, group: '统计结算', roles: ['admin', 'ops', 'service'], subtitle: '用户利润(含下级返点)· 通道利润 · 平台净利' } },
|
||||
{ path: 'settle', name: 'settle', component: () => import('@/views/settle/index.vue'), meta: { title: '结算管理', icon: 'Wallet', menu: true, group: '统计结算', roles: ['admin', 'ops'] } },
|
||||
{ path: 'ops/callback', name: 'ops-callback', component: () => import('@/views/ops/callback/index.vue'), meta: { title: '回调管理', icon: 'Promotion', menu: true, group: '系统管理', roles: ['admin', 'ops'], subtitle: '客户回调推送任务 · 指数退避 · 死信可查可重派' } },
|
||||
|
||||
|
||||
{ path: 'logs', name: 'logs', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '日志报表', icon: 'Document', menu: true, group: '系统管理', roles: ['admin', 'ops', 'service'] } },
|
||||
{ path: 'system', name: 'system', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '系统配置', icon: 'Setting', menu: true, group: '系统管理', roles: ['admin'] } },
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
<template>
|
||||
<div class="page-stack">
|
||||
<section class="card cb-card">
|
||||
<div class="cb-head">
|
||||
<div>
|
||||
<span class="card-head-title">回调管理</span>
|
||||
<el-tag size="small" type="warning" class="cb-badge">S4·C1 验收版</el-tag>
|
||||
</div>
|
||||
<span class="cb-sub">客户回调推送任务(回执终态/上行)· 指数退避重试 · 死信可查可重派</span>
|
||||
</div>
|
||||
|
||||
<!-- 数据脉象:状态计数面板(死信存量一眼可见) -->
|
||||
<div class="cb-counts">
|
||||
<div class="cb-count"><span class="cb-num">{{ counts.pending ?? 0 }}</span><span class="cb-label">待推送/重试中</span></div>
|
||||
<div class="cb-count"><span class="cb-num cb-ok">{{ counts.sent ?? 0 }}</span><span class="cb-label">已送达</span></div>
|
||||
<div class="cb-count"><span class="cb-num" :class="{ 'cb-dead': (counts.dead ?? 0) > 0 }">{{ counts.dead ?? 0 }}</span><span class="cb-label">死信(重试耗尽)</span></div>
|
||||
</div>
|
||||
|
||||
<div class="cb-filters">
|
||||
<el-select v-model="q.status" placeholder="状态(全部)" clearable style="width: 140px" @change="load">
|
||||
<el-option label="待推送" :value="0" /><el-option label="已送达" :value="1" /><el-option label="死信" :value="2" />
|
||||
</el-select>
|
||||
<el-select v-model="q.type" placeholder="类型(全部)" clearable style="width: 130px" @change="load">
|
||||
<el-option label="回执终态" :value="1" /><el-option label="上行消息" :value="2" />
|
||||
</el-select>
|
||||
<el-input-number v-model="q.account_id" :min="0" placeholder="账号ID" :controls="false" style="width: 110px" @change="load" />
|
||||
<el-button type="primary" :loading="loading" @click="load">查询</el-button>
|
||||
<el-button @click="showPayload = !showPayload">{{ showPayload ? '隐藏载荷' : '展开载荷' }}</el-button>
|
||||
</div>
|
||||
|
||||
<el-table v-loading="loading" :data="rows" size="small">
|
||||
<el-table-column prop="id" label="ID" width="80" sortable />
|
||||
<el-table-column prop="account_id" label="账号" width="80" />
|
||||
<el-table-column label="类型" width="90">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" :type="row.type === 2 ? 'warning' : 'primary'">{{ CALLBACK_TYPE[row.type] ?? row.type }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="url" label="回调地址" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column label="状态" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" :type="row.status === 1 ? 'success' : row.status === 2 ? 'danger' : 'info'">
|
||||
{{ CALLBACK_STATUS[row.status] ?? row.status }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="attempt" label="重试" width="70" />
|
||||
<el-table-column label="最近结果" min-width="150" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.last_code ? `HTTP ${row.last_code}` : '—' }}{{ row.last_err ? ` · ${row.last_err}` : '' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="next_retry_at" label="下次重试" width="170" />
|
||||
<el-table-column prop="created_at" label="入队时间" width="170" />
|
||||
<el-table-column v-if="showPayload" label="载荷(JSON)" min-width="260">
|
||||
<template #default="{ row }"><code class="cb-payload">{{ row.payload }}</code></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="110" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button v-if="row.status === 2" size="small" type="primary" @click="resend(row)">重派</el-button>
|
||||
<span v-else class="cb-done">—</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<template #empty>
|
||||
<el-empty description="暂无回调任务——账号配置 report_url/uplink_url 后,回执终态与上行消息自动入队推送" />
|
||||
</template>
|
||||
</el-table>
|
||||
|
||||
<el-pagination v-if="total > q.page_size" v-model:current-page="q.page" :page-size="q.page_size" :total="total"
|
||||
layout="total, prev, pager, next" class="cb-pager" @current-change="load" />
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/** 回调管理页(S4·C1):callback_task 列表 + 状态面板 + 死信重派。
|
||||
* 口径:PushWorker 在 consumer 进程投递(2s 扫描/2^n 秒退避/10 次耗尽死信);
|
||||
* 本页仅管理面——列表查询 + 死信重派(POST /ops/callback/:id/resend)。 */
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { callbackApi, CALLBACK_STATUS, CALLBACK_TYPE, type CallbackTask } from '@/api/callback'
|
||||
|
||||
const rows = ref<CallbackTask[]>([])
|
||||
const counts = ref<Record<string, number>>({})
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const showPayload = ref(false)
|
||||
|
||||
const q = reactive<Record<string, number>>({ page: 1, page_size: 20, status: -1, type: 0, account_id: 0 })
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
const params: Record<string, unknown> = { page: q.page, page_size: q.page_size }
|
||||
if (q.status >= 0) params.status = q.status
|
||||
if (q.type > 0) params.type = q.type
|
||||
if (q.account_id > 0) params.account_id = q.account_id
|
||||
const res = await callbackApi.list(params)
|
||||
rows.value = res.list ?? []
|
||||
total.value = res.total ?? 0
|
||||
counts.value = res.status_counts ?? {}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function resend(row: CallbackTask) {
|
||||
await ElMessageBox.confirm(`重派任务 #${row.id} 到 ${row.url}?重试计数将清零并立即投递。`, '死信重派', { type: 'warning' })
|
||||
await callbackApi.resend(row.id)
|
||||
ElMessage.success(`任务 #${row.id} 已重派`)
|
||||
await load()
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.cb-card { display: grid; gap: 14px; }
|
||||
.cb-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
|
||||
.cb-badge { margin-left: 8px; }
|
||||
.cb-sub { font-size: 12px; opacity: 0.65; }
|
||||
.cb-counts { display: flex; gap: 12px; }
|
||||
.cb-count { flex: 1; display: grid; gap: 2px; padding: 10px 14px; border-radius: 10px; background: var(--el-fill-color-light); }
|
||||
.cb-num { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
|
||||
.cb-ok { color: var(--el-color-success); }
|
||||
.cb-dead { color: var(--el-color-danger); }
|
||||
.cb-label { font-size: 12px; opacity: 0.65; }
|
||||
.cb-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
|
||||
.cb-payload { font-size: 11px; word-break: break-all; opacity: 0.85; }
|
||||
.cb-done { opacity: 0.4; }
|
||||
.cb-pager { justify-self: end; }
|
||||
</style>
|
||||
@@ -2,13 +2,13 @@ import { describe, expect, it } from 'vitest'
|
||||
import { accessibleRoutes } from '@/router/guard'
|
||||
|
||||
describe('路由权限过滤 accessibleRoutes', () => {
|
||||
it('admin 直通全部业务路由(31 模块菜单,含 FE-2 通道与策略五入口+D19 定时任务+D20 模板管理+D22 结果反馈+D23 短信聚合页+D24 下行记录+D27 上行记录+D28 回执工具+S3·FE-D34 利润分析)', () => {
|
||||
it('admin 直通全部业务路由(32 模块菜单,含 FE-2 通道与策略五入口+D19 定时任务+D20 模板管理+D22 结果反馈+D23 短信聚合页+D24 下行记录+D27 上行记录+D28 回执工具+S3·FE-D34 利润分析+S4·C1 回调管理)', () => {
|
||||
const all = accessibleRoutes(['admin'])
|
||||
const menus = all.flatMap((r) => (r.children ?? []).filter((c) => c.meta?.menu))
|
||||
expect(menus.length).toBe(32)
|
||||
expect(menus.length).toBe(33)
|
||||
// FE-2/D23/S3 关键入口在菜单(D11 上家/D14 通道组/D16 导流+报备/D19 定时任务/D20 模板管理/D22 结果反馈/D23 聚合页/FE-D34 利润分析)
|
||||
const names = menus.map((m) => m.name)
|
||||
for (const want of ['channel-upstream', 'channel-group', 'policy-route', 'policy-report', 'sms-timer', 'sms-template', 'sms-result', 'sms-home', 'record-down', 'stats-profit']) {
|
||||
for (const want of ['channel-upstream', 'channel-group', 'policy-route', 'policy-report', 'sms-timer', 'sms-template', 'sms-result', 'sms-home', 'record-down', 'stats-profit', 'ops-callback']) {
|
||||
expect(names).toContain(want)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -25,6 +25,7 @@ const MATRIX: Record<string, Roles[]> = {
|
||||
contacts: ALL,
|
||||
'stats-user': ['admin', 'ops', 'service'], 'stats-channel': ['admin', 'ops'],
|
||||
'stats-profit': ['admin', 'ops', 'service'], settle: ['admin', 'ops'],
|
||||
'ops-callback': ['admin', 'ops'],
|
||||
logs: ['admin', 'ops', 'service'], system: ['admin'], faq: ALL,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user