|
|
@@ -327,4 +327,614 @@ Mock.mock(/\/api\/campaign\/delete/, 'post', (options) => {
|
|
|
return { code: 200, data: null, msg: '删除成功' }
|
|
|
})
|
|
|
|
|
|
+// =============================================
|
|
|
+// 借记卡权益 + 审核中心
|
|
|
+// =============================================
|
|
|
+
|
|
|
+// 商品状态:未上架 / 已上架
|
|
|
+// 审核状态:草稿 / 上架待审核 / 编辑待审核 / 下架待审核 / 审核通过
|
|
|
+// 合法组合(6 种):
|
|
|
+// 未上架+草稿 = 草稿
|
|
|
+// 未上架+上架待审核 = 新增待审核
|
|
|
+// 未上架+审核通过 = 已下架
|
|
|
+// 已上架+审核通过 = 已上架
|
|
|
+// 已上架+编辑待审核 = 已上架·变更待审核
|
|
|
+// 已上架+下架待审核 = 已上架·下架待审核
|
|
|
+const equityList = [
|
|
|
+ {
|
|
|
+ productId: '100001',
|
|
|
+ equityName: '权益A',
|
|
|
+ source: '银行自有',
|
|
|
+ jumpMethod: '-',
|
|
|
+ jumpLink: '-',
|
|
|
+ exchangeMethod: '权益平台',
|
|
|
+ productType: '券码',
|
|
|
+ skuNo: 'SKU001',
|
|
|
+ merchantName: '商户A',
|
|
|
+ creator: '李运营',
|
|
|
+ createTime: '2026-04-10 09:32:15',
|
|
|
+ reviewer: '王五',
|
|
|
+ reviewTime: '2026-04-15 10:30:00',
|
|
|
+ shelfStatus: '已上架',
|
|
|
+ auditStatus: '审核通过',
|
|
|
+ pendingData: null,
|
|
|
+ showOnHome: '显示',
|
|
|
+ showOnAssembly: '不显示',
|
|
|
+ assemblyPages: []
|
|
|
+ },
|
|
|
+ {
|
|
|
+ productId: '100002',
|
|
|
+ equityName: '权益B',
|
|
|
+ source: '第三方',
|
|
|
+ jumpMethod: '没有',
|
|
|
+ jumpLink: '太古地产',
|
|
|
+ exchangeMethod: '第三方(列表跳转)',
|
|
|
+ productType: '',
|
|
|
+ skuNo: 'SKU002',
|
|
|
+ merchantName: '商户B',
|
|
|
+ creator: '王运营',
|
|
|
+ createTime: '2026-04-12 14:08:42',
|
|
|
+ reviewer: '',
|
|
|
+ reviewTime: '',
|
|
|
+ shelfStatus: '未上架',
|
|
|
+ auditStatus: '上架待审核',
|
|
|
+ pendingData: null,
|
|
|
+ showOnHome: '显示',
|
|
|
+ showOnAssembly: '不显示',
|
|
|
+ assemblyPages: []
|
|
|
+ },
|
|
|
+ {
|
|
|
+ productId: '100003',
|
|
|
+ equityName: '权益C',
|
|
|
+ source: '第三方',
|
|
|
+ jumpMethod: '有',
|
|
|
+ jumpLink: '龙腾',
|
|
|
+ exchangeMethod: '第三方(详情页跳转)',
|
|
|
+ productType: '',
|
|
|
+ skuNo: 'SKU003',
|
|
|
+ merchantName: '商户C',
|
|
|
+ creator: '李运营',
|
|
|
+ createTime: '2026-04-08 11:20:05',
|
|
|
+ reviewer: '王五',
|
|
|
+ reviewTime: '2026-04-14 16:45:00',
|
|
|
+ shelfStatus: '已上架',
|
|
|
+ auditStatus: '编辑待审核',
|
|
|
+ pendingData: { equityName: '权益C(变更)', subTitle: '调整后的副标题' },
|
|
|
+ showOnHome: '显示',
|
|
|
+ showOnAssembly: '不显示',
|
|
|
+ assemblyPages: []
|
|
|
+ },
|
|
|
+ {
|
|
|
+ productId: '100004',
|
|
|
+ equityName: '权益D',
|
|
|
+ source: '第三方',
|
|
|
+ jumpMethod: '有',
|
|
|
+ jumpLink: 'h5链接',
|
|
|
+ exchangeMethod: '第三方(详情页跳转)',
|
|
|
+ productType: '',
|
|
|
+ skuNo: 'SKU004',
|
|
|
+ merchantName: '商户D',
|
|
|
+ creator: '陈运营',
|
|
|
+ createTime: '2026-04-05 15:50:18',
|
|
|
+ reviewer: '赵六',
|
|
|
+ reviewTime: '2026-04-13 09:15:00',
|
|
|
+ shelfStatus: '已上架',
|
|
|
+ auditStatus: '下架待审核',
|
|
|
+ pendingData: null,
|
|
|
+ showOnHome: '显示',
|
|
|
+ showOnAssembly: '不显示',
|
|
|
+ assemblyPages: []
|
|
|
+ },
|
|
|
+ {
|
|
|
+ productId: '100005',
|
|
|
+ equityName: '权益E',
|
|
|
+ source: '银行自有',
|
|
|
+ jumpMethod: '-',
|
|
|
+ jumpLink: '-',
|
|
|
+ exchangeMethod: '权益平台',
|
|
|
+ productType: '券码',
|
|
|
+ skuNo: 'SKU005',
|
|
|
+ merchantName: '商户E',
|
|
|
+ creator: '王运营',
|
|
|
+ createTime: '2026-03-28 09:00:11',
|
|
|
+ reviewer: '钱七',
|
|
|
+ reviewTime: '2026-04-12 11:20:00',
|
|
|
+ shelfStatus: '未上架',
|
|
|
+ auditStatus: '审核通过',
|
|
|
+ pendingData: null,
|
|
|
+ showOnHome: '显示',
|
|
|
+ showOnAssembly: '不显示',
|
|
|
+ assemblyPages: []
|
|
|
+ },
|
|
|
+ {
|
|
|
+ productId: '100006',
|
|
|
+ equityName: '权益F(草稿)',
|
|
|
+ source: '银行自有',
|
|
|
+ jumpMethod: '-',
|
|
|
+ jumpLink: '-',
|
|
|
+ exchangeMethod: '权益平台',
|
|
|
+ productType: '券码',
|
|
|
+ skuNo: 'SKU006',
|
|
|
+ merchantName: '商户F',
|
|
|
+ creator: '李运营',
|
|
|
+ createTime: '2026-05-16 10:00:00',
|
|
|
+ reviewer: '',
|
|
|
+ reviewTime: '',
|
|
|
+ shelfStatus: '未上架',
|
|
|
+ auditStatus: '草稿',
|
|
|
+ pendingData: null,
|
|
|
+ showOnHome: '不显示',
|
|
|
+ showOnAssembly: '不显示',
|
|
|
+ assemblyPages: []
|
|
|
+ }
|
|
|
+]
|
|
|
+
|
|
|
+let equityIdCounter = 100006
|
|
|
+
|
|
|
+const auditList = [
|
|
|
+ {
|
|
|
+ id: 'AR202605150001',
|
|
|
+ auditType: 'new',
|
|
|
+ bizModule: 'equity_product',
|
|
|
+ bizModuleName: '借记卡权益',
|
|
|
+ bizId: '100002',
|
|
|
+ bizName: '权益B',
|
|
|
+ snapshot: {
|
|
|
+ equityName: '权益B',
|
|
|
+ source: '第三方',
|
|
|
+ jumpMethod: '没有',
|
|
|
+ jumpLink: '太古地产',
|
|
|
+ productType: '',
|
|
|
+ skuNo: 'SKU002',
|
|
|
+ merchantName: '商户B',
|
|
|
+ subTitle: '外部列表页副标题'
|
|
|
+ },
|
|
|
+ submitReason: '新建第三方权益,链接已对齐',
|
|
|
+ submitterId: 'u001',
|
|
|
+ submitterName: '王运营',
|
|
|
+ submitTime: '2026-05-15 10:00:00',
|
|
|
+ auditorId: null,
|
|
|
+ auditorName: '',
|
|
|
+ auditTime: '',
|
|
|
+ auditStatus: 'pending',
|
|
|
+ auditComment: ''
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 'AR202605160001',
|
|
|
+ auditType: 'change',
|
|
|
+ bizModule: 'equity_product',
|
|
|
+ bizModuleName: '借记卡权益',
|
|
|
+ bizId: '100003',
|
|
|
+ bizName: '权益C',
|
|
|
+ snapshot: {
|
|
|
+ equityName: '权益C(变更)',
|
|
|
+ source: '第三方',
|
|
|
+ jumpMethod: '有',
|
|
|
+ jumpLink: '龙腾',
|
|
|
+ productType: '',
|
|
|
+ skuNo: 'SKU003',
|
|
|
+ merchantName: '商户C',
|
|
|
+ subTitle: '调整后的副标题'
|
|
|
+ },
|
|
|
+ submitReason: '调整副标题与名称',
|
|
|
+ submitterId: 'u002',
|
|
|
+ submitterName: '李运营',
|
|
|
+ submitTime: '2026-05-16 14:30:00',
|
|
|
+ auditorId: null,
|
|
|
+ auditorName: '',
|
|
|
+ auditTime: '',
|
|
|
+ auditStatus: 'pending',
|
|
|
+ auditComment: ''
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 'AR202605170001',
|
|
|
+ auditType: 'offshelf',
|
|
|
+ bizModule: 'equity_product',
|
|
|
+ bizModuleName: '借记卡权益',
|
|
|
+ bizId: '100004',
|
|
|
+ bizName: '权益D',
|
|
|
+ snapshot: {
|
|
|
+ equityName: '权益D',
|
|
|
+ source: '第三方',
|
|
|
+ jumpMethod: '有',
|
|
|
+ jumpLink: 'h5链接',
|
|
|
+ productType: '',
|
|
|
+ skuNo: 'SKU004',
|
|
|
+ merchantName: '商户D',
|
|
|
+ subTitle: '外部自定义链接副标题'
|
|
|
+ },
|
|
|
+ submitReason: '业务合作到期,申请下架',
|
|
|
+ submitterId: 'u003',
|
|
|
+ submitterName: '陈运营',
|
|
|
+ submitTime: '2026-05-17 09:00:00',
|
|
|
+ auditorId: null,
|
|
|
+ auditorName: '',
|
|
|
+ auditTime: '',
|
|
|
+ auditStatus: 'pending',
|
|
|
+ auditComment: ''
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 'AR202605120001',
|
|
|
+ auditType: 'new',
|
|
|
+ bizModule: 'equity_product',
|
|
|
+ bizModuleName: '借记卡权益',
|
|
|
+ bizId: '100001',
|
|
|
+ bizName: '权益A',
|
|
|
+ snapshot: {
|
|
|
+ equityName: '权益A',
|
|
|
+ source: '银行自有',
|
|
|
+ jumpMethod: '-',
|
|
|
+ jumpLink: '-',
|
|
|
+ productType: '券码',
|
|
|
+ skuNo: 'SKU001',
|
|
|
+ merchantName: '商户A',
|
|
|
+ subTitle: '副标题示例'
|
|
|
+ },
|
|
|
+ submitReason: '',
|
|
|
+ submitterId: 'u001',
|
|
|
+ submitterName: '李运营',
|
|
|
+ submitTime: '2026-04-10 09:32:15',
|
|
|
+ auditorId: 'u099',
|
|
|
+ auditorName: '王五',
|
|
|
+ auditTime: '2026-04-15 10:30:00',
|
|
|
+ auditStatus: 'approved',
|
|
|
+ auditComment: '内容合规,准予上架'
|
|
|
+ }
|
|
|
+]
|
|
|
+
|
|
|
+let auditIdCounter = 4
|
|
|
+
|
|
|
+function nowStr() {
|
|
|
+ return new Date().toLocaleString('zh-CN', { hour12: false }).replace(/\//g, '-')
|
|
|
+}
|
|
|
+
|
|
|
+function nextAuditId() {
|
|
|
+ auditIdCounter += 1
|
|
|
+ const d = new Date()
|
|
|
+ const ymd = d.getFullYear().toString() + String(d.getMonth() + 1).padStart(2, '0') + String(d.getDate()).padStart(2, '0')
|
|
|
+ return 'AR' + ymd + String(auditIdCounter).padStart(4, '0')
|
|
|
+}
|
|
|
+
|
|
|
+function snapshotOf(equity) {
|
|
|
+ return {
|
|
|
+ equityName: equity.equityName,
|
|
|
+ source: equity.source,
|
|
|
+ jumpMethod: equity.jumpMethod,
|
|
|
+ jumpLink: equity.jumpLink,
|
|
|
+ productType: equity.productType,
|
|
|
+ skuNo: equity.skuNo,
|
|
|
+ merchantName: equity.merchantName,
|
|
|
+ subTitle: equity.subTitle || ''
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 借记卡权益 - 列表
|
|
|
+Mock.mock(/\/api\/equity\/list/, 'get', (options) => {
|
|
|
+ const url = new URL(options.url, 'http://localhost')
|
|
|
+ const equityName = url.searchParams.get('equityName') || ''
|
|
|
+ const productId = url.searchParams.get('productId') || ''
|
|
|
+ const shelfStatus = url.searchParams.get('shelfStatus') || ''
|
|
|
+ const auditStatus = url.searchParams.get('auditStatus') || ''
|
|
|
+ let filtered = equityList
|
|
|
+ if (equityName) filtered = filtered.filter(e => e.equityName.includes(equityName))
|
|
|
+ if (productId) filtered = filtered.filter(e => e.productId.includes(productId))
|
|
|
+ if (shelfStatus) filtered = filtered.filter(e => e.shelfStatus === shelfStatus)
|
|
|
+ if (auditStatus) filtered = filtered.filter(e => e.auditStatus === auditStatus)
|
|
|
+ return { code: 200, data: filtered, msg: 'ok' }
|
|
|
+})
|
|
|
+
|
|
|
+// 借记卡权益 - 详情
|
|
|
+Mock.mock(/\/api\/equity\/detail/, 'get', (options) => {
|
|
|
+ const url = new URL(options.url, 'http://localhost')
|
|
|
+ const id = url.searchParams.get('id')
|
|
|
+ const item = equityList.find(e => e.productId === id)
|
|
|
+ return item
|
|
|
+ ? { code: 200, data: item, msg: 'ok' }
|
|
|
+ : { code: 404, data: null, msg: '权益不存在' }
|
|
|
+})
|
|
|
+
|
|
|
+// 保存草稿(新建或修改草稿)
|
|
|
+Mock.mock(/\/api\/equity\/save-draft/, 'post', (options) => {
|
|
|
+ const body = JSON.parse(options.body)
|
|
|
+ if (body.productId) {
|
|
|
+ // 修改草稿
|
|
|
+ const idx = equityList.findIndex(e => e.productId === body.productId)
|
|
|
+ if (idx < 0) return { code: 404, data: null, msg: '权益不存在' }
|
|
|
+ const cur = equityList[idx]
|
|
|
+ if (cur.auditStatus !== '草稿') {
|
|
|
+ return { code: 400, data: null, msg: '仅草稿状态可保存为草稿' }
|
|
|
+ }
|
|
|
+ equityList[idx] = { ...cur, ...body, shelfStatus: '未上架', auditStatus: '草稿' }
|
|
|
+ return { code: 200, data: { productId: cur.productId }, msg: '草稿已保存' }
|
|
|
+ }
|
|
|
+ // 新建草稿
|
|
|
+ equityIdCounter += 1
|
|
|
+ const newId = String(equityIdCounter)
|
|
|
+ const newRow = {
|
|
|
+ productId: newId,
|
|
|
+ equityName: body.equityName || '未命名权益',
|
|
|
+ source: body.source || '银行自有',
|
|
|
+ jumpMethod: body.jumpMethod || '-',
|
|
|
+ jumpLink: body.jumpLink || '-',
|
|
|
+ exchangeMethod: body.exchangeMethod || '权益平台',
|
|
|
+ productType: body.productType || '',
|
|
|
+ skuNo: body.skuNo || '',
|
|
|
+ merchantName: body.merchantName || '',
|
|
|
+ creator: body.creator || '李运营',
|
|
|
+ createTime: nowStr(),
|
|
|
+ reviewer: '',
|
|
|
+ reviewTime: '',
|
|
|
+ shelfStatus: '未上架',
|
|
|
+ auditStatus: '草稿',
|
|
|
+ pendingData: null,
|
|
|
+ showOnHome: body.showOnHome || '不显示',
|
|
|
+ showOnAssembly: body.showOnAssembly || '不显示',
|
|
|
+ assemblyPages: body.assemblyPages || [],
|
|
|
+ subTitle: body.subTitle || ''
|
|
|
+ }
|
|
|
+ equityList.unshift(newRow)
|
|
|
+ return { code: 200, data: { productId: newId }, msg: '草稿已保存' }
|
|
|
+})
|
|
|
+
|
|
|
+// 提交审核(新增上架审核 / 已上架编辑提审 / 已下架重新提审)
|
|
|
+Mock.mock(/\/api\/equity\/submit/, 'post', (options) => {
|
|
|
+ const body = JSON.parse(options.body)
|
|
|
+ let cur
|
|
|
+ let idx = -1
|
|
|
+ if (body.productId) {
|
|
|
+ idx = equityList.findIndex(e => e.productId === body.productId)
|
|
|
+ if (idx < 0) return { code: 404, data: null, msg: '权益不存在' }
|
|
|
+ cur = equityList[idx]
|
|
|
+ }
|
|
|
+
|
|
|
+ const submitReason = body.submitReason || ''
|
|
|
+ const submitter = body.submitterName || '李运营'
|
|
|
+
|
|
|
+ // 新建 + 直接提审
|
|
|
+ if (!cur) {
|
|
|
+ equityIdCounter += 1
|
|
|
+ const newId = String(equityIdCounter)
|
|
|
+ const newRow = {
|
|
|
+ productId: newId,
|
|
|
+ equityName: body.equityName || '未命名权益',
|
|
|
+ source: body.source || '银行自有',
|
|
|
+ jumpMethod: body.jumpMethod || '-',
|
|
|
+ jumpLink: body.jumpLink || '-',
|
|
|
+ exchangeMethod: body.exchangeMethod || '权益平台',
|
|
|
+ productType: body.productType || '',
|
|
|
+ skuNo: body.skuNo || '',
|
|
|
+ merchantName: body.merchantName || '',
|
|
|
+ creator: submitter,
|
|
|
+ createTime: nowStr(),
|
|
|
+ reviewer: '',
|
|
|
+ reviewTime: '',
|
|
|
+ shelfStatus: '未上架',
|
|
|
+ auditStatus: '上架待审核',
|
|
|
+ pendingData: null,
|
|
|
+ showOnHome: body.showOnHome || '不显示',
|
|
|
+ showOnAssembly: body.showOnAssembly || '不显示',
|
|
|
+ assemblyPages: body.assemblyPages || [],
|
|
|
+ subTitle: body.subTitle || ''
|
|
|
+ }
|
|
|
+ equityList.unshift(newRow)
|
|
|
+ auditList.unshift({
|
|
|
+ id: nextAuditId(),
|
|
|
+ auditType: 'new',
|
|
|
+ bizModule: 'equity_product',
|
|
|
+ bizModuleName: '借记卡权益',
|
|
|
+ bizId: newId,
|
|
|
+ bizName: newRow.equityName,
|
|
|
+ snapshot: snapshotOf(newRow),
|
|
|
+ submitReason,
|
|
|
+ submitterId: 'u001',
|
|
|
+ submitterName: submitter,
|
|
|
+ submitTime: nowStr(),
|
|
|
+ auditorId: null,
|
|
|
+ auditorName: '',
|
|
|
+ auditTime: '',
|
|
|
+ auditStatus: 'pending',
|
|
|
+ auditComment: ''
|
|
|
+ })
|
|
|
+ return { code: 200, data: { productId: newId }, msg: '已提交审核' }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 草稿 → 上架待审核(new)
|
|
|
+ if (cur.shelfStatus === '未上架' && cur.auditStatus === '草稿') {
|
|
|
+ const merged = { ...cur, ...body }
|
|
|
+ equityList[idx] = { ...merged, shelfStatus: '未上架', auditStatus: '上架待审核' }
|
|
|
+ auditList.unshift({
|
|
|
+ id: nextAuditId(),
|
|
|
+ auditType: 'new',
|
|
|
+ bizModule: 'equity_product',
|
|
|
+ bizModuleName: '借记卡权益',
|
|
|
+ bizId: cur.productId,
|
|
|
+ bizName: equityList[idx].equityName,
|
|
|
+ snapshot: snapshotOf(equityList[idx]),
|
|
|
+ submitReason,
|
|
|
+ submitterId: 'u001',
|
|
|
+ submitterName: submitter,
|
|
|
+ submitTime: nowStr(),
|
|
|
+ auditorId: null,
|
|
|
+ auditorName: '',
|
|
|
+ auditTime: '',
|
|
|
+ auditStatus: 'pending',
|
|
|
+ auditComment: ''
|
|
|
+ })
|
|
|
+ return { code: 200, data: { productId: cur.productId }, msg: '已提交审核' }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 已下架 → 重新上架(也是 new)
|
|
|
+ if (cur.shelfStatus === '未上架' && cur.auditStatus === '审核通过') {
|
|
|
+ equityList[idx] = { ...cur, ...body, shelfStatus: '未上架', auditStatus: '上架待审核' }
|
|
|
+ auditList.unshift({
|
|
|
+ id: nextAuditId(),
|
|
|
+ auditType: 'new',
|
|
|
+ bizModule: 'equity_product',
|
|
|
+ bizModuleName: '借记卡权益',
|
|
|
+ bizId: cur.productId,
|
|
|
+ bizName: equityList[idx].equityName,
|
|
|
+ snapshot: snapshotOf(equityList[idx]),
|
|
|
+ submitReason,
|
|
|
+ submitterId: 'u001',
|
|
|
+ submitterName: submitter,
|
|
|
+ submitTime: nowStr(),
|
|
|
+ auditorId: null,
|
|
|
+ auditorName: '',
|
|
|
+ auditTime: '',
|
|
|
+ auditStatus: 'pending',
|
|
|
+ auditComment: ''
|
|
|
+ })
|
|
|
+ return { code: 200, data: { productId: cur.productId }, msg: '已提交审核' }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 已上架 → 编辑待审核(change),写入 pendingData,不动主表运行字段
|
|
|
+ if (cur.shelfStatus === '已上架' && cur.auditStatus === '审核通过') {
|
|
|
+ const pending = { ...body }
|
|
|
+ delete pending.submitReason
|
|
|
+ delete pending.submitterName
|
|
|
+ delete pending.productId
|
|
|
+ equityList[idx] = { ...cur, auditStatus: '编辑待审核', pendingData: pending }
|
|
|
+ auditList.unshift({
|
|
|
+ id: nextAuditId(),
|
|
|
+ auditType: 'change',
|
|
|
+ bizModule: 'equity_product',
|
|
|
+ bizModuleName: '借记卡权益',
|
|
|
+ bizId: cur.productId,
|
|
|
+ bizName: cur.equityName,
|
|
|
+ snapshot: { ...snapshotOf(cur), ...pending },
|
|
|
+ submitReason,
|
|
|
+ submitterId: 'u001',
|
|
|
+ submitterName: submitter,
|
|
|
+ submitTime: nowStr(),
|
|
|
+ auditorId: null,
|
|
|
+ auditorName: '',
|
|
|
+ auditTime: '',
|
|
|
+ auditStatus: 'pending',
|
|
|
+ auditComment: ''
|
|
|
+ })
|
|
|
+ return { code: 200, data: { productId: cur.productId }, msg: '已提交审核' }
|
|
|
+ }
|
|
|
+
|
|
|
+ return { code: 400, data: null, msg: '当前状态不可提交审核' }
|
|
|
+})
|
|
|
+
|
|
|
+// 申请下架
|
|
|
+Mock.mock(/\/api\/equity\/request-offshelf/, 'post', (options) => {
|
|
|
+ const body = JSON.parse(options.body)
|
|
|
+ const idx = equityList.findIndex(e => e.productId === body.productId)
|
|
|
+ if (idx < 0) return { code: 404, data: null, msg: '权益不存在' }
|
|
|
+ const cur = equityList[idx]
|
|
|
+ if (cur.shelfStatus !== '已上架' || cur.auditStatus !== '审核通过') {
|
|
|
+ return { code: 400, data: null, msg: '仅已上架且无审核中的权益可申请下架' }
|
|
|
+ }
|
|
|
+ equityList[idx] = { ...cur, auditStatus: '下架待审核' }
|
|
|
+ auditList.unshift({
|
|
|
+ id: nextAuditId(),
|
|
|
+ auditType: 'offshelf',
|
|
|
+ bizModule: 'equity_product',
|
|
|
+ bizModuleName: '借记卡权益',
|
|
|
+ bizId: cur.productId,
|
|
|
+ bizName: cur.equityName,
|
|
|
+ snapshot: snapshotOf(cur),
|
|
|
+ submitReason: '',
|
|
|
+ submitterId: 'u001',
|
|
|
+ submitterName: body.submitterName || '李运营',
|
|
|
+ submitTime: nowStr(),
|
|
|
+ auditorId: null,
|
|
|
+ auditorName: '',
|
|
|
+ auditTime: '',
|
|
|
+ auditStatus: 'pending',
|
|
|
+ auditComment: ''
|
|
|
+ })
|
|
|
+ return { code: 200, data: null, msg: '已提交下架审核' }
|
|
|
+})
|
|
|
+
|
|
|
+// 删除权益(仅草稿/已下架)
|
|
|
+Mock.mock(/\/api\/equity\/delete/, 'post', (options) => {
|
|
|
+ const body = JSON.parse(options.body)
|
|
|
+ const idx = equityList.findIndex(e => e.productId === body.productId)
|
|
|
+ if (idx < 0) return { code: 404, data: null, msg: '权益不存在' }
|
|
|
+ const cur = equityList[idx]
|
|
|
+ const canDelete = (cur.shelfStatus === '未上架' && (cur.auditStatus === '草稿' || cur.auditStatus === '审核通过'))
|
|
|
+ if (!canDelete) return { code: 400, data: null, msg: '当前状态不可删除' }
|
|
|
+ equityList.splice(idx, 1)
|
|
|
+ return { code: 200, data: null, msg: '删除成功' }
|
|
|
+})
|
|
|
+
|
|
|
+// 审核中心 - 列表
|
|
|
+Mock.mock(/\/api\/audit\/list/, 'get', (options) => {
|
|
|
+ const url = new URL(options.url, 'http://localhost')
|
|
|
+ const auditStatus = url.searchParams.get('auditStatus') || ''
|
|
|
+ const bizId = url.searchParams.get('bizId') || ''
|
|
|
+ let filtered = auditList
|
|
|
+ if (auditStatus) filtered = filtered.filter(a => a.auditStatus === auditStatus)
|
|
|
+ if (bizId) filtered = filtered.filter(a => String(a.bizId).includes(bizId))
|
|
|
+ return { code: 200, data: filtered, msg: 'ok' }
|
|
|
+})
|
|
|
+
|
|
|
+// 审核中心 - 详情
|
|
|
+Mock.mock(/\/api\/audit\/detail/, 'get', (options) => {
|
|
|
+ const url = new URL(options.url, 'http://localhost')
|
|
|
+ const id = url.searchParams.get('id')
|
|
|
+ const item = auditList.find(a => a.id === id)
|
|
|
+ return item
|
|
|
+ ? { code: 200, data: item, msg: 'ok' }
|
|
|
+ : { code: 404, data: null, msg: '审核单不存在' }
|
|
|
+})
|
|
|
+
|
|
|
+// 审核中心 - 通过
|
|
|
+Mock.mock(/\/api\/audit\/approve/, 'post', (options) => {
|
|
|
+ const body = JSON.parse(options.body)
|
|
|
+ const idx = auditList.findIndex(a => a.id === body.id)
|
|
|
+ if (idx < 0) return { code: 404, data: null, msg: '审核单不存在' }
|
|
|
+ const audit = auditList[idx]
|
|
|
+ if (audit.auditStatus !== 'pending') return { code: 400, data: null, msg: '该审核单已完成' }
|
|
|
+
|
|
|
+ const eqIdx = equityList.findIndex(e => e.productId === audit.bizId)
|
|
|
+ if (eqIdx < 0) return { code: 404, data: null, msg: '关联权益不存在' }
|
|
|
+ const eq = equityList[eqIdx]
|
|
|
+ const now = nowStr()
|
|
|
+ const auditor = body.auditorName || '王五'
|
|
|
+
|
|
|
+ if (audit.auditType === 'new') {
|
|
|
+ equityList[eqIdx] = { ...eq, shelfStatus: '已上架', auditStatus: '审核通过', reviewer: auditor, reviewTime: now }
|
|
|
+ } else if (audit.auditType === 'change') {
|
|
|
+ // 合并 pendingData 到主表
|
|
|
+ const merged = { ...eq, ...(eq.pendingData || {}) }
|
|
|
+ equityList[eqIdx] = { ...merged, shelfStatus: '已上架', auditStatus: '审核通过', pendingData: null, reviewer: auditor, reviewTime: now }
|
|
|
+ } else if (audit.auditType === 'offshelf') {
|
|
|
+ equityList[eqIdx] = { ...eq, shelfStatus: '未上架', auditStatus: '审核通过', reviewer: auditor, reviewTime: now }
|
|
|
+ }
|
|
|
+
|
|
|
+ auditList[idx] = { ...audit, auditStatus: 'approved', auditorId: 'u099', auditorName: auditor, auditTime: now, auditComment: body.comment || '' }
|
|
|
+ return { code: 200, data: null, msg: '审核通过' }
|
|
|
+})
|
|
|
+
|
|
|
+// 审核中心 - 驳回
|
|
|
+Mock.mock(/\/api\/audit\/reject/, 'post', (options) => {
|
|
|
+ const body = JSON.parse(options.body)
|
|
|
+ const idx = auditList.findIndex(a => a.id === body.id)
|
|
|
+ if (idx < 0) return { code: 404, data: null, msg: '审核单不存在' }
|
|
|
+ const audit = auditList[idx]
|
|
|
+ if (audit.auditStatus !== 'pending') return { code: 400, data: null, msg: '该审核单已完成' }
|
|
|
+
|
|
|
+ const eqIdx = equityList.findIndex(e => e.productId === audit.bizId)
|
|
|
+ if (eqIdx < 0) return { code: 404, data: null, msg: '关联权益不存在' }
|
|
|
+ const eq = equityList[eqIdx]
|
|
|
+ const now = nowStr()
|
|
|
+ const auditor = body.auditorName || '王五'
|
|
|
+
|
|
|
+ // 驳回后权益主表回退到提审前的状态
|
|
|
+ if (audit.auditType === 'new') {
|
|
|
+ equityList[eqIdx] = { ...eq, shelfStatus: '未上架', auditStatus: '草稿' }
|
|
|
+ } else if (audit.auditType === 'change') {
|
|
|
+ equityList[eqIdx] = { ...eq, shelfStatus: '已上架', auditStatus: '审核通过', pendingData: null }
|
|
|
+ } else if (audit.auditType === 'offshelf') {
|
|
|
+ equityList[eqIdx] = { ...eq, shelfStatus: '已上架', auditStatus: '审核通过' }
|
|
|
+ }
|
|
|
+
|
|
|
+ auditList[idx] = { ...audit, auditStatus: 'rejected', auditorId: 'u099', auditorName: auditor, auditTime: now, auditComment: body.comment || '' }
|
|
|
+ return { code: 200, data: null, msg: '已驳回' }
|
|
|
+})
|
|
|
+
|
|
|
export default Mock
|