锁定缴费校验失败时整单回滚,避免样本半成功落库;前端禁止删除锁定缴费样本,改码走更正编码。同步落地样本更正、采集微信通知、OA提及未读、细胞产品套餐与相关迁移文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
import {
|
||
fetchOaCcUnreadCount,
|
||
fetchOaInstanceDraftCount,
|
||
fetchOaMentionUnreadCount,
|
||
fetchOaPendingTaskCount
|
||
} from './oa-api.js'
|
||
|
||
const PATH_DRAFTS = '/pages/oa/drafts/index'
|
||
const PATH_PENDING = '/pages/oa/pending/index'
|
||
const PATH_CC = '/pages/oa/cc/index'
|
||
const PATH_MENTIONS = '/pages/oa/mentions/index'
|
||
|
||
function readCount(data) {
|
||
if (data == null) return 0
|
||
if (typeof data === 'number') return Math.max(0, data)
|
||
const n = Number(data.count)
|
||
return Number.isFinite(n) && n > 0 ? n : 0
|
||
}
|
||
|
||
/**
|
||
* 并行拉取草稿 / 待办 / 抄送未读 / 提到我的未读数量。
|
||
* @returns {Promise<Record<string, number>>} path → 原始 count(>99 仍保留真实数字)
|
||
*/
|
||
export async function refreshOaMenuBadges() {
|
||
const [draftRes, pendingRes, ccRes, mentionRes] = await Promise.all([
|
||
fetchOaInstanceDraftCount().catch(() => null),
|
||
fetchOaPendingTaskCount().catch(() => null),
|
||
fetchOaCcUnreadCount().catch(() => null),
|
||
fetchOaMentionUnreadCount().catch(() => null)
|
||
])
|
||
return {
|
||
[PATH_DRAFTS]: readCount(draftRes),
|
||
[PATH_PENDING]: readCount(pendingRes),
|
||
[PATH_CC]: readCount(ccRes),
|
||
[PATH_MENTIONS]: readCount(mentionRes)
|
||
}
|
||
}
|
||
|
||
/** 展示层:0 → 空串;>99 → `99+` */
|
||
export function formatOaBadgeCount(n) {
|
||
const c = Number(n) || 0
|
||
if (c <= 0) return ''
|
||
return c > 99 ? '99+' : String(c)
|
||
}
|