feat(distribution): 支持一键同步主站商品池并在货架区分货源归属

This commit is contained in:
yml2213
2026-09-09 13:44:50 +08:00
parent cf4bea9b6d
commit 9452cf608e
5 changed files with 59 additions and 28 deletions
+2
View File
@@ -191,6 +191,8 @@ export interface AccountDisplay {
deposit_amount_cent?: number
listing_status?: string
in_transaction?: boolean
listing_site_id?: number | null
source_channel?: string
}
export interface SyncSiteAccountsResult {
+35 -5
View File
@@ -1,5 +1,5 @@
import { useEffect, useState, useMemo } from 'react'
import { Card, Table, Typography, Space, Select, Tag, message, Button, Input, Modal, InputNumber } from 'antd'
import { Card, Table, Typography, Space, Select, Tag, message, Button, Input, Modal, InputNumber, Empty } from 'antd'
import { SyncOutlined, SearchOutlined, CheckCircleOutlined, StopOutlined, EditOutlined, DollarCircleOutlined } from '@ant-design/icons'
import {
listAccountDisplays,
@@ -69,13 +69,13 @@ export default function Accounts() {
try {
const res = await syncSiteAccounts(siteID)
message.success(
`同步完成!新增本站上传货 ${res.synced_count} 个,已存在 ${res.skipped_count} 个(本次候选 ${res.total_active} 个)`,
`同步完成!成功同步新增商品 ${res.synced_count} 个,已在货架 ${res.skipped_count} 个(平台在售共 ${res.total_active} 个)`,
5,
)
await load(siteID, status)
} catch (error: unknown) {
const respMessage = (error as { response?: { data?: { message?: string } } })?.response?.data?.message
message.error(respMessage ?? '同步本站上传商品失败')
message.error(respMessage ?? '同步主站商品失败')
} finally {
setSyncing(false)
}
@@ -189,7 +189,7 @@ export default function Accounts() {
商品与账号展示
</Typography.Title>
<Typography.Text type="secondary">
管理当前分销网站对外展示的商品。默认同步本站上传货,主站货需显式勾选,不会灌入全站目录。
管理当前分销网站对外展示的商品货架。所有账号源均来自主站及平台共享池,支持一键同步主站商品,并进行自主提价(调小比例)销售。
</Typography.Text>
</div>
<Button
@@ -199,7 +199,7 @@ export default function Accounts() {
onClick={handleSync}
style={{ background: '#1677ff' }}
>
同步本站上传商品
一键同步主站商品
</Button>
</div>
@@ -279,6 +279,23 @@ export default function Accounts() {
rowKey="id"
loading={loading}
dataSource={filteredItems}
locale={{
emptyText: (
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description="当前分站货架暂无商品。点击下方按钮一键同步主站账号池,即可在此设置提价并开始销售。"
>
<Button
type="primary"
icon={<SyncOutlined spin={syncing} />}
loading={syncing}
onClick={handleSync}
>
一键同步主站商品
</Button>
</Empty>
),
}}
rowSelection={{
selectedRowKeys,
onChange: setSelectedRowKeys,
@@ -302,6 +319,19 @@ export default function Accounts() {
</Space>
),
},
{
title: '货源归属',
width: 110,
render: (_: unknown, row: AccountDisplay) => {
if (row.listing_site_id === null || row.listing_site_id === undefined) {
return <Tag color="green">主站自营</Tag>
}
if (row.listing_site_id === siteID) {
return <Tag color="purple">本站收号</Tag>
}
return <Tag color="blue">合作分站</Tag>
},
},
{
title: '账号信息',
dataIndex: 'title',