fix: 修复秒杀活动发布后状态未更新的问题

根因:publishFlashSale() 只做了缓存预热,从未调用 updateStatus()
将状态从1(未开始)更新为2(进行中),导致发布后UI无变化,
且活动无法被"进行中"查询找到。

修复内容:
- publishFlashSale() 添加 updateStatus(id, 2) 和缓存更新
- 简化 getFlashSaleList 状态查询,直接按 status 字段过滤
- 新增 findByStatus 仓库方法
- 前后端全面支持 PAUSED(status=4) 状态
- 修复管理后台"恢复"按钮错误显示在"已结束"状态上

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-14 17:46:43 +08:00
parent a813d3ffea
commit 0f67f6cc49
7 changed files with 22 additions and 16 deletions

View File

@@ -43,6 +43,7 @@
<el-select v-model="query.status" clearable placeholder="全部状态" @change="handleSearch">
<el-option label="即将开始" value="UPCOMING" />
<el-option label="进行中" value="ACTIVE" />
<el-option label="已暂停" value="PAUSED" />
<el-option label="已结束" value="ENDED" />
</el-select>
<el-button type="primary" @click="handleSearch">搜索</el-button>
@@ -88,8 +89,8 @@
<el-button text type="primary" @click="openEditDialog(row)">编辑</el-button>
<el-button v-if="row.status === 'UPCOMING'" text type="success" @click="changeStatus('publish', row)">发布</el-button>
<el-button v-if="row.status === 'ACTIVE'" text type="warning" @click="changeStatus('pause', row)">暂停</el-button>
<el-button v-if="row.status === 'ENDED'" text type="success" @click="changeStatus('resume', row)">恢复</el-button>
<el-button v-if="row.status !== 'ENDED'" text type="danger" @click="changeStatus('end', row)">结束</el-button>
<el-button v-if="row.status === 'PAUSED'" text type="success" @click="changeStatus('resume', row)">恢复</el-button>
<el-button v-if="row.status === 'ACTIVE' || row.status === 'PAUSED'" text type="danger" @click="changeStatus('end', row)">结束</el-button>
<el-button text type="danger" @click="removeFlashSale(row)">删除</el-button>
</template>
</el-table-column>
@@ -253,6 +254,7 @@ const getStatusText = (status: string) => {
const map: Record<string, string> = {
UPCOMING: '即将开始',
ACTIVE: '进行中',
PAUSED: '已暂停',
ENDED: '已结束',
}
return map[status] || status
@@ -262,6 +264,7 @@ const getStatusType = (status: string) => {
const map: Record<string, string> = {
UPCOMING: 'warning',
ACTIVE: 'danger',
PAUSED: 'warning',
ENDED: 'info',
}
return map[status] || 'info'