feat(distribution): 优化货架批量操作、结算大事务、大盘与前台多端解析缓存及货架分页

This commit is contained in:
yml2213
2026-09-11 12:59:33 +08:00
parent 9ae6d5eaea
commit 3508608a8f
10 changed files with 518 additions and 48 deletions
+27 -27
View File
@@ -40,6 +40,7 @@ import {
syncSiteAccounts,
updateAccountMarkup,
batchUpdateAccountMarkup,
batchUpdateAccountDisplay,
formatMoney,
getMe,
type AccountDisplay,
@@ -254,23 +255,24 @@ export default function Accounts() {
message.warning('请先勾选需要批量操作的账号')
return
}
if (!siteID) {
message.warning('无法获取当前分销站点信息')
return
}
const actionLabel = targetStatus === 'enabled' ? '批量恢复展示' : '批量下架'
Modal.confirm({
title: `确认${actionLabel}?`,
content: `即将对选中的 ${selectedRowKeys.length} 个账号执行${actionLabel}操作。`,
onOk: async () => {
let successCount = 0
for (const id of selectedRowKeys) {
try {
await updateAccountDisplay(Number(id), targetStatus)
successCount++
} catch {
// continue next
}
try {
await batchUpdateAccountDisplay(siteID, selectedRowKeys.map(Number), targetStatus)
message.success(`已成功完成选中的 ${selectedRowKeys.length} 个账号的${actionLabel}`)
setSelectedRowKeys([])
void load(siteID)
} catch (error: unknown) {
const respMessage = (error as { response?: { data?: { message?: string } } })?.response?.data?.message
message.error(respMessage ?? `${actionLabel}失败`)
}
message.success(`已完成 ${successCount}/${selectedRowKeys.length} 个账号的${actionLabel}`)
setSelectedRowKeys([])
if (siteID) void load(siteID)
},
})
}
@@ -404,23 +406,21 @@ export default function Accounts() {
const listingIDs = selectedItems.map((it) => it.listing_id)
await batchUpdateAccountMarkup(siteID, listingIDs, batchValue)
} else if (batchMode === 'percent') {
await Promise.all(
selectedItems.map((it) => {
const basePriceYuan = (it.price_cent || 0) / 100
const targetYuan = basePriceYuan * (1 + batchValue / 100)
const delta = calcDeltaFromTargetPrice(it.haf_coin_amount || 0, it.price_cent || 0, targetYuan)
return updateAccountMarkup(it.id, delta)
})
)
const itemsToUpdate = selectedItems.map((it) => {
const basePriceYuan = (it.price_cent || 0) / 100
const targetYuan = basePriceYuan * (1 + batchValue / 100)
const delta = calcDeltaFromTargetPrice(it.haf_coin_amount || 0, it.price_cent || 0, targetYuan)
return { id: it.id, listing_id: it.listing_id, shelf_ratio_delta: delta }
})
await batchUpdateAccountMarkup(siteID, { items: itemsToUpdate })
} else if (batchMode === 'add_amount') {
await Promise.all(
selectedItems.map((it) => {
const basePriceYuan = (it.price_cent || 0) / 100
const targetYuan = basePriceYuan + batchValue
const delta = calcDeltaFromTargetPrice(it.haf_coin_amount || 0, it.price_cent || 0, targetYuan)
return updateAccountMarkup(it.id, delta)
})
)
const itemsToUpdate = selectedItems.map((it) => {
const basePriceYuan = (it.price_cent || 0) / 100
const targetYuan = basePriceYuan + batchValue
const delta = calcDeltaFromTargetPrice(it.haf_coin_amount || 0, it.price_cent || 0, targetYuan)
return { id: it.id, listing_id: it.listing_id, shelf_ratio_delta: delta }
})
await batchUpdateAccountMarkup(siteID, { items: itemsToUpdate })
}
message.success(`已成功为选中的 ${selectedItems.length} 个商品批量设置提价!`)
setSelectedRowKeys([])