feat(跟价多状态): 全量跟价支持勾选多个商品状态,取值以派发落库值为准
原来「按商品状态(全量)」写死在售。现在用户端可勾选 在售/缺少的报价/定价问题 (默认只勾在售),勾几个跑几个,状态清单随循环任务落库并在每次派发子任务时下发。 - 载荷的 mode 与状态清单都取派发上下文(childTaskRequest),不再读界面当前勾选: 循环跑到第 N 轮时用户可能已经改过勾选,用界面值会把没勾的状态跑出去。 - listingStatuses 白名单 Active/PricingIssue/MissingOffer 三值,校验放在 try 之外—— try 里的 catch 会把「不支持的商品状态」改写成「循环任务序列化失败」,那是句假话。 - V159 给 biz_price_track_loop_run 加 listing_statuses_json(可空=本特性之前的行=在售)。 - 状态标识用我们自己的键 MissingOffer,页面真实取值是 OfferMissing(2026-10-17 黄建新 英国站真机实锤),两者不同形是有意的:改键名会断载荷兼容。
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
<label class="mode-check-row">
|
||||
<input type="radio" name="price-track-mode" class="mode-check-input" :checked="statusModeEnabled" @change="selectMode('status')" />
|
||||
<span class="mode-check-text">按商品状态(全量)</span>
|
||||
<span class="mode-hint-inline">— 获取店铺所有在售ASIN跑跟价</span>
|
||||
<span class="mode-hint-inline">— 按下方勾选的商品状态跑跟价</span>
|
||||
</label>
|
||||
<label class="mode-check-row">
|
||||
<input type="radio" name="price-track-mode" class="mode-check-input" :checked="asinModeEnabled" @change="selectMode('asin')" />
|
||||
@@ -19,6 +19,22 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- 商品状态多选(仅全量模式):勾几个状态就跑几个状态 -->
|
||||
<template v-if="statusModeEnabled">
|
||||
<div class="section-title">商品状态 <span class="tag-badge">可多选</span></div>
|
||||
<div class="country-pref-checks">
|
||||
<label v-for="row in listingStatusRows" :key="row.value" class="country-check-row">
|
||||
<input type="checkbox" class="country-check-input" :checked="isListingStatusSelected(row.value)"
|
||||
:disabled="pushing" @change="onListingStatusToggle(row.value, $event)" />
|
||||
<span class="country-check-text">{{ row.label }}</span>
|
||||
</label>
|
||||
</div>
|
||||
<p class="hint">
|
||||
勾选的状态在同一国家内各筛一遍、各跑一遍整店列表;同一 ASIN 命中多个状态只跟一次价。
|
||||
某状态在该店铺没有商品时会被跳过并记进任务日志。
|
||||
</p>
|
||||
</template>
|
||||
|
||||
<!-- 按指定ASIN文档:上传 -->
|
||||
<div class="section-title">执行配置</div>
|
||||
<div class="mode-zone">
|
||||
@@ -122,7 +138,7 @@
|
||||
<!-- 状态指示 -->
|
||||
<div v-if="statusModeEnabled" class="mode-status-bar">
|
||||
<span class="mode-status-dot active"></span>
|
||||
<span class="mode-status-text">商品状态模式:将在售(Active)ASIN纳入跟价,跳过ASIN由后台配置的店铺维度数据提供</span>
|
||||
<span class="mode-status-text">商品状态模式:将{{ listingStatusSummaryText }}ASIN纳入跟价,跳过ASIN由后台配置的店铺维度数据提供</span>
|
||||
</div>
|
||||
|
||||
<div class="run-row">
|
||||
@@ -223,6 +239,10 @@ import { userNotice } from '@/shared/utils/user-notice'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { TableInstance } from 'element-plus'
|
||||
import AmazonToolPageShell from '@/pages/amazon/components/AmazonToolPageShell.vue';
|
||||
import {
|
||||
PRICE_TRACK_DEFAULT_LISTING_STATUSES,
|
||||
PRICE_TRACK_LISTING_STATUSES,
|
||||
} from './listingFilters'
|
||||
import ModuleTemplateDownload from '@/shared/components/ModuleTemplateDownload.vue'
|
||||
import FileUploadZone from '@/shared/components/FileUploadZone.vue'
|
||||
import TaskCenterPanel from '@/shared/components/tasks/TaskCenterPanel.vue'
|
||||
@@ -265,6 +285,7 @@ import {
|
||||
stopPriceTrackLoopRun,
|
||||
type PriceTrackAsinParsedRow,
|
||||
type PriceTrackCandidateVo,
|
||||
type PriceTrackCreateTaskRequest,
|
||||
type PriceTrackCreateTaskVo,
|
||||
type PriceTrackDashboardVo,
|
||||
type PriceTrackExecutionMode,
|
||||
@@ -342,6 +363,30 @@ const stopLoopPending = ref(false)
|
||||
const statusModeEnabled = ref(true) // 按商品状态(全量)
|
||||
const asinModeEnabled = ref(false) // 按指定ASIN文档(自定义)
|
||||
|
||||
// 商品状态多选(只在全量模式生效)。默认只勾在售=本功能上线前的行为,存量用户不勾不多跑状态。
|
||||
const listingStatusRows = PRICE_TRACK_LISTING_STATUSES
|
||||
const selectedListingStatuses = ref<string[]>([...PRICE_TRACK_DEFAULT_LISTING_STATUSES])
|
||||
|
||||
function isListingStatusSelected(value: string) {
|
||||
return selectedListingStatuses.value.includes(value)
|
||||
}
|
||||
|
||||
function onListingStatusToggle(value: string, event: Event) {
|
||||
const checked = (event.target as HTMLInputElement).checked
|
||||
const next = new Set(selectedListingStatuses.value)
|
||||
if (checked) next.add(value)
|
||||
else next.delete(value)
|
||||
// 按目录顺序回写:这个顺序就是客户端逐状态筛选、逐页跑的顺序,不能跟着点击次序漂
|
||||
selectedListingStatuses.value = listingStatusRows.filter((row) => next.has(row.value)).map((row) => row.value)
|
||||
}
|
||||
|
||||
const hasValidListingStatuses = computed(() => selectedListingStatuses.value.length > 0)
|
||||
|
||||
const listingStatusSummaryText = computed(() => {
|
||||
const labels = listingStatusRows.filter((row) => isListingStatusSelected(row.value)).map((row) => row.label)
|
||||
return labels.length ? `「${labels.join(' / ')}」的` : '(一个状态都没勾,无法启动)'
|
||||
})
|
||||
|
||||
// 上传文件
|
||||
const {
|
||||
files: asinUploadedFiles,
|
||||
@@ -912,10 +957,21 @@ function rowKeyForMatch(row: { shopName?: string; shopId?: number | string | nul
|
||||
return `${(row.shopName || '').trim()}\u0001${row.shopId ?? ''}`
|
||||
}
|
||||
|
||||
function priceTrackModeForAppClient() {
|
||||
function priceTrackModeForAppClient(child?: PriceTrackCreateTaskRequest | null) {
|
||||
// 载荷的 mode 以派发回来的子任务为准,本地勾选只作兜底:onMounted 会自动续跑未完成的循环,
|
||||
// 而页面刷新后本地勾选态回到默认(全量)——那时按本地态拼载荷,指定ASIN的循环会被拼成
|
||||
// "全量在售跟价",等于对整店真实改价。
|
||||
if (child) return child.statusMode ? 'status' : 'asin'
|
||||
return statusModeEnabled.value ? 'status' : 'asin'
|
||||
}
|
||||
|
||||
function listingStatusesForPayload(child?: PriceTrackCreateTaskRequest | null) {
|
||||
const fromDispatch = (child?.listingStatuses || []).filter((item) => !!item)
|
||||
// 派发值优先(循环建单时勾的那几个状态要一路跑到最后一轮,不随界面中途改勾选而变);
|
||||
// 老循环没存这个字段(后端加列前的记录)时退回本地勾选。
|
||||
return fromDispatch.length ? fromDispatch : [...selectedListingStatuses.value]
|
||||
}
|
||||
|
||||
function buildMinimumPriceByCountryAndAsin(rowsByCountry: Record<string, PriceTrackAsinParsedRow[]>) {
|
||||
const out: Record<string, Record<string, string>> = {}
|
||||
for (const [country, rows] of Object.entries(rowsByCountry || {})) {
|
||||
@@ -1023,10 +1079,12 @@ async function removeMatchedRow(row: PriceTrackShopQueueItem) {
|
||||
}
|
||||
|
||||
// ========== 任务状态轮询 ==========
|
||||
async function buildQueuePayload(taskVo: PriceTrackCreateTaskVo, row: PriceTrackShopQueueItem) {
|
||||
async function buildQueuePayload(taskVo: PriceTrackCreateTaskVo, row: PriceTrackShopQueueItem,
|
||||
child?: PriceTrackCreateTaskRequest | null) {
|
||||
const shopName = (row.shopName || '').trim()
|
||||
const asinRowsByCountry = await loadAsinRowsForAppClient(taskVo)
|
||||
const minimumPriceByCountryAndAsin = buildMinimumPriceMapForAppClient(taskVo, asinRowsByCountry)
|
||||
const mode = priceTrackModeForAppClient(child)
|
||||
|
||||
return {
|
||||
type: 'price-track-run',
|
||||
@@ -1035,7 +1093,10 @@ async function buildQueuePayload(taskVo: PriceTrackCreateTaskVo, row: PriceTrack
|
||||
task_id: taskVo.taskId,
|
||||
shop_name: shopName,
|
||||
country_codes: resolveCountryCodesForRequest(),
|
||||
mode: priceTrackModeForAppClient(),
|
||||
mode,
|
||||
// 只在状态模式下带这份清单:指定ASIN模式不发这个键,客户端就按今天的默认(在售)预筛,
|
||||
// 逐字保持原行为——那一模式的搜索目标是文档里的 ASIN,不是某个状态的整店列表。
|
||||
...(mode === 'status' ? { listing_statuses: listingStatusesForPayload(child) } : {}),
|
||||
shopName,
|
||||
companyName: row.companyName || '',
|
||||
shopMallName: row.shopMallName || '',
|
||||
@@ -1051,11 +1112,13 @@ async function enqueueCreatedTask(api: PywebviewApi, taskId: number, queuePayloa
|
||||
// 空 country_codes 会让 Python 端没有可遍历的站点,任务永远停在 RUNNING。
|
||||
// asin_rows_by_country 只在 asin 模式下要求非空——status 模式下
|
||||
// loadAsinRowsForAppClient 本就返回 {},那是正常的。
|
||||
// listing_statuses 只在 status 模式下要求非空:空清单到了客户端会退回"在售",
|
||||
// 用户勾的其它状态就静默不跑——宁可不投也不投一个语义不对的任务。
|
||||
const mode = (queuePayload as { data?: { mode?: unknown } } | null)?.data?.mode
|
||||
const guard = checkQueuePayload(queuePayload, {
|
||||
expectedType: 'price-track-run',
|
||||
requiredDataKeys: ['task_id', 'shop_name'],
|
||||
nonEmptyArrayKeys: ['country_codes'],
|
||||
nonEmptyArrayKeys: mode === 'status' ? ['country_codes', 'listing_statuses'] : ['country_codes'],
|
||||
nonEmptyObjectKeys: mode === 'asin' ? ['asin_rows_by_country'] : [],
|
||||
})
|
||||
if (!(await passGuard(guard))) {
|
||||
@@ -1320,7 +1383,7 @@ async function runLoopExecution(loopId?: number) {
|
||||
}
|
||||
})()
|
||||
recordCreatedTask(taskVo)
|
||||
const queuePayload = await buildQueuePayload(taskVo, row)
|
||||
const queuePayload = await buildQueuePayload(taskVo, row, childTaskRequest)
|
||||
queuePayloadText.value = JSON.stringify(queuePayload, null, 2)
|
||||
await enqueueCreatedTask(api, taskVo.taskId, queuePayload)
|
||||
addPollingTask(taskVo.taskId)
|
||||
@@ -1353,6 +1416,11 @@ async function pushToPythonLoopQueue() {
|
||||
ElMessage.warning('请至少选择一个跟价模式')
|
||||
return
|
||||
}
|
||||
if (statusModeEnabled.value && !hasValidListingStatuses.value) {
|
||||
// 空清单投出去会被客户端退回"在售",用户勾的其它状态就静默不跑,所以在这里就拦住
|
||||
ElMessage.warning('按商品状态跟价时请至少勾选一个商品状态')
|
||||
return
|
||||
}
|
||||
if (asinModeEnabled.value && !asinFiles.value.length) {
|
||||
ElMessage.warning('请先选择 ASIN 文件')
|
||||
return
|
||||
@@ -1368,6 +1436,8 @@ async function pushToPythonLoopQueue() {
|
||||
const loop = await createPriceTrackLoopRun({
|
||||
userId: 0,
|
||||
statusMode: statusModeEnabled.value,
|
||||
// 勾了哪些状态随循环落库:每一轮子任务都从这里回读,界面中途改勾选不影响已启动的循环
|
||||
listingStatuses: statusModeEnabled.value ? [...selectedListingStatuses.value] : [],
|
||||
asinMode: asinModeEnabled.value,
|
||||
items: matchedRows,
|
||||
asinFiles: resolveAsinRequestPaths(),
|
||||
|
||||
@@ -6,3 +6,24 @@ export const LISTING_FILTER_OPTIONS = [
|
||||
] as const
|
||||
|
||||
export type ListingFilterValue = (typeof LISTING_FILTER_OPTIONS)[number]['value']
|
||||
|
||||
/**
|
||||
* 跟价「按商品状态(全量)」可勾选的状态(2026-10-16 多状态立项)。
|
||||
*
|
||||
* value 是发给客户端的标识,必须与 app_client/amazon/amazon_base_v2.py 的
|
||||
* LISTING_STATUS_CATALOG 的键逐字一致——那边按 value 精确命中页面选项,命中不到
|
||||
* 再按中文文案兜底。顺序即客户端逐状态跑的顺序(在售 → 缺少的报价 → 定价问题)。
|
||||
*
|
||||
* MissingOffer 的页面真实取值未经真机证实(唯一可测的测试店该状态没有商品、选项不渲染),
|
||||
* 所以客户端先按文案命中并把回显的取值写进日志,届时再补进目录升为第一路。
|
||||
*/
|
||||
export const PRICE_TRACK_LISTING_STATUSES = [
|
||||
{ value: 'Active', label: '在售' },
|
||||
{ value: 'MissingOffer', label: '缺少的报价' },
|
||||
{ value: 'PricingIssue', label: '定价问题' },
|
||||
] as const
|
||||
|
||||
export type PriceTrackListingStatusValue = (typeof PRICE_TRACK_LISTING_STATUSES)[number]['value']
|
||||
|
||||
/** 默认只勾在售=本功能上线前的行为,存量用户不勾也不会多跑状态。 */
|
||||
export const PRICE_TRACK_DEFAULT_LISTING_STATUSES: PriceTrackListingStatusValue[] = ['Active']
|
||||
|
||||
@@ -134,6 +134,8 @@ export type PriceTrackCreateTaskPayload = Omit<
|
||||
export interface PriceTrackCreateTaskRequest {
|
||||
userId: number;
|
||||
statusMode: boolean;
|
||||
/** 状态模式下要跑的商品状态清单(Active/PricingIssue/MissingOffer);空=客户端按在售跑 */
|
||||
listingStatuses?: string[];
|
||||
asinMode: boolean;
|
||||
items: PriceTrackShopQueueItem[];
|
||||
asinFiles: string[];
|
||||
@@ -148,6 +150,7 @@ export type PriceTrackExecutionMode = "FINITE" | "INFINITE";
|
||||
export interface PriceTrackLoopRunCreateRequest {
|
||||
userId: number;
|
||||
statusMode: boolean;
|
||||
listingStatuses?: string[];
|
||||
asinMode: boolean;
|
||||
items: PriceTrackShopQueueItem[];
|
||||
asinFiles: string[];
|
||||
@@ -169,6 +172,7 @@ export interface PriceTrackLoopRunVo {
|
||||
stopRequested?: boolean;
|
||||
errorMessage?: string;
|
||||
statusMode?: boolean;
|
||||
listingStatuses?: string[];
|
||||
asinMode?: boolean;
|
||||
asinFiles?: string[];
|
||||
countryCodes?: string[];
|
||||
|
||||
Reference in New Issue
Block a user