fix(admin): 恢复接单模板计价配置并统一成本价格链路
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
AccountBookOutlined,
|
||||
ApartmentOutlined,
|
||||
BellOutlined,
|
||||
BranchesOutlined,
|
||||
BugOutlined,
|
||||
DashboardOutlined,
|
||||
FileSearchOutlined,
|
||||
@@ -182,6 +183,7 @@ export default function AdminLayout() {
|
||||
const isFinanceKey = [
|
||||
'/admin/sales-profit',
|
||||
'/admin/cost-center',
|
||||
'/admin/fulfillment-channel',
|
||||
'/admin/fund',
|
||||
'/admin/finance',
|
||||
'/admin/finance/ledger',
|
||||
@@ -198,6 +200,7 @@ export default function AdminLayout() {
|
||||
const financeSubItems: MenuProps['items'] = [
|
||||
{ key: '/admin/sales-profit', icon: <LineChartOutlined />, label: '销售毛利' },
|
||||
{ key: '/admin/cost-center', icon: <ApartmentOutlined />, label: '商品与成本' },
|
||||
{ key: '/admin/fulfillment-channel', icon: <BranchesOutlined />, label: '履约渠道' },
|
||||
{ key: '/admin/fund', icon: <WalletOutlined />, label: '钱包管理' },
|
||||
{ key: '/admin/finance', icon: <AccountBookOutlined />, label: '收支明细' },
|
||||
{ key: '/admin/finance/ledger', icon: <AuditOutlined />, label: '总账与对账' },
|
||||
@@ -846,6 +849,7 @@ function resolveSelectedKey(pathname: string) {
|
||||
if (pathname.startsWith('/admin/orders')) return '/admin/orders'
|
||||
if (pathname.startsWith('/admin/sales-profit')) return '/admin/sales-profit'
|
||||
if (pathname.startsWith('/admin/cost-center')) return '/admin/cost-center'
|
||||
if (pathname.startsWith('/admin/fulfillment-channel')) return '/admin/fulfillment-channel'
|
||||
if (pathname.startsWith('/admin/fund')) return '/admin/fund'
|
||||
if (pathname.startsWith('/admin/finance/ledger')) return '/admin/finance/ledger'
|
||||
if (pathname.startsWith('/admin/finance')) return '/admin/finance'
|
||||
|
||||
@@ -342,7 +342,6 @@ export function ProductCatalogPanel() {
|
||||
}
|
||||
|
||||
function openSetProductPrice(item: ProductCatalogItem) {
|
||||
const isTemplateProduct = item.canonicalSku.startsWith('tpl:')
|
||||
setPricingProduct(item)
|
||||
priceForm.resetFields()
|
||||
priceForm.setFieldsValue({
|
||||
@@ -350,7 +349,6 @@ export function ProductCatalogPanel() {
|
||||
item.activeCostAmountFen !== null && item.activeCostAmountFen !== undefined
|
||||
? (item.activeCostAmountFen / 100).toFixed(2)
|
||||
: undefined,
|
||||
pricingMode: isTemplateProduct ? item.templatePricingMode || 'fixed' : undefined,
|
||||
effectiveScope: 'immediate',
|
||||
changeReason: '在商品与成本中心统一调整价格',
|
||||
syncSnapshots: true,
|
||||
@@ -360,7 +358,6 @@ export function ProductCatalogPanel() {
|
||||
|
||||
async function submitProductPrice(values: {
|
||||
amountYuan: number | string
|
||||
pricingMode?: 'fixed' | 'unit'
|
||||
effectiveScope: 'immediate' | 'custom'
|
||||
effectiveFromCustom?: string
|
||||
changeReason?: string
|
||||
@@ -381,7 +378,6 @@ export function ProductCatalogPanel() {
|
||||
try {
|
||||
const response = await setAdminProductPrice(pricingProduct.id, {
|
||||
amountFen,
|
||||
pricingMode: values.pricingMode,
|
||||
effectiveFrom,
|
||||
changeReason: values.changeReason || '在商品与成本中心统一调整价格',
|
||||
syncOpenOrders: true,
|
||||
@@ -1022,17 +1018,15 @@ export function ProductCatalogPanel() {
|
||||
</div>
|
||||
|
||||
{pricingProduct.canonicalSku.startsWith('tpl:') ? (
|
||||
<Form.Item
|
||||
name="pricingMode"
|
||||
label="接单计价方式"
|
||||
rules={[{ required: true, message: '请选择计价方式' }]}
|
||||
extra="保存后会同步到接单模板;固定金额按整单,按件单价按 SKU 数量计算"
|
||||
>
|
||||
<Radio.Group optionType="button" buttonStyle="solid">
|
||||
<Radio.Button value="fixed">固定金额</Radio.Button>
|
||||
<Radio.Button value="unit">按件计价</Radio.Button>
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
style={{ marginBottom: 16 }}
|
||||
message={`当前计价方式:${
|
||||
pricingProduct.templatePricingMode === 'unit' ? '按 SKU 按件' : '固定金额'
|
||||
}`}
|
||||
description="计价方式由接单模板统一设置;这里只维护对应金额。"
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<Form.Item
|
||||
@@ -1041,9 +1035,9 @@ export function ProductCatalogPanel() {
|
||||
pricingProduct.source === 'affiliate_dash'
|
||||
? '采购单价(元)'
|
||||
: pricingProduct.canonicalSku.startsWith('tpl:')
|
||||
? pricingProduct.templateSharingEnabled
|
||||
? '拼单总成本(元)'
|
||||
: '接单成本(元)'
|
||||
? pricingProduct.templatePricingMode === 'unit'
|
||||
? '每件接单成本(元)'
|
||||
: '整单接单成本(元)'
|
||||
: '标准结算单价(元)'
|
||||
}
|
||||
rules={[{ required: true, message: '请填写价格' }]}
|
||||
@@ -1051,7 +1045,9 @@ export function ProductCatalogPanel() {
|
||||
pricingProduct.source === 'affiliate_dash'
|
||||
? '上游每发货 1 件扣除的采购成本金额'
|
||||
: pricingProduct.canonicalSku.startsWith('tpl:')
|
||||
? '固定金额按整单计;按件计价时填写每个 SKU 的接单成本'
|
||||
? pricingProduct.templatePricingMode === 'unit'
|
||||
? `订单有 N 件时,本单接单成本 = 当前金额 × N`
|
||||
: '无论订单件数,当前金额就是整单接单成本'
|
||||
: '接单打手发单/验收的基础结算单价'
|
||||
}
|
||||
>
|
||||
|
||||
@@ -293,6 +293,7 @@ export default function ProductRulesPanel() {
|
||||
itemTitleMatchType: rule.match.itemTitleMatchType,
|
||||
skuNickMatchType: rule.match.skuNickMatchType,
|
||||
categoryId: rule.categoryId || undefined,
|
||||
pricingMode: rule.pricingMode || 'fixed',
|
||||
sharingEnabled: rule.sharing?.enabled || false,
|
||||
sharingAutoFromOrder: rule.sharing?.autoFromOrder || false,
|
||||
sharingTotalQuantity: hasManualSharingOverride ? rule.sharing?.totalQuantity : undefined,
|
||||
@@ -349,6 +350,7 @@ export default function ProductRulesPanel() {
|
||||
fieldsText?: string
|
||||
enabled?: boolean
|
||||
autoCreate?: boolean
|
||||
pricingMode?: 'fixed' | 'unit'
|
||||
sortOrder?: number
|
||||
}) {
|
||||
try {
|
||||
@@ -374,9 +376,7 @@ export default function ProductRulesPanel() {
|
||||
isFriendGift && giftCooldownUnit === 'minutes' ? Number(giftCooldownValue || 0) : 0,
|
||||
sharingEnabled: isFriendGift ? false : values.sharingEnabled === true,
|
||||
sharingAutoFromOrder:
|
||||
editingRule?.unitPriceFen !== undefined &&
|
||||
editingRule.unitPriceFen > 0 &&
|
||||
editingRule.rewardAmount === 0 &&
|
||||
values.pricingMode === 'unit' &&
|
||||
values.sharingEnabled === true &&
|
||||
!hasManualSharingOverride,
|
||||
})
|
||||
@@ -420,9 +420,12 @@ export default function ProductRulesPanel() {
|
||||
platform: rule.platform,
|
||||
productName: rule.productName,
|
||||
categoryId: rule.categoryId || undefined,
|
||||
pricingMode: rule.pricingMode,
|
||||
sharingEnabled: rule.sharing?.enabled || false,
|
||||
sharingAutoFromOrder:
|
||||
rule.unitPriceFen > 0 && rule.sharing?.enabled === true && !hasManualSharingOverride,
|
||||
rule.pricingMode === 'unit' &&
|
||||
rule.sharing?.enabled === true &&
|
||||
!hasManualSharingOverride,
|
||||
sharingTotalQuantity: hasManualSharingOverride ? rule.sharing?.totalQuantity : undefined,
|
||||
sharingUnitReward: hasManualSharingOverride
|
||||
? (rule.sharing?.unitReward || 0) / 100
|
||||
@@ -753,22 +756,17 @@ export default function ProductRulesPanel() {
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '接单金额',
|
||||
title: '接单价格',
|
||||
key: 'reward',
|
||||
width: '20%',
|
||||
render: (_, row) => (
|
||||
<div className="cell-stack">
|
||||
{row.rewardAmount > 0 || row.unitPriceFen > 0 ? (
|
||||
<>
|
||||
<Typography.Text strong style={{ color: '#3f8600', fontSize: 12 }}>
|
||||
{row.sharing?.autoFromOrder ? '随订单计算' : formatMoney(row.rewardAmount)}
|
||||
</Typography.Text>
|
||||
{row.unitPriceFen > 0 ? (
|
||||
<Typography.Text type="secondary" style={{ fontSize: 11 }}>
|
||||
按件: {formatMoney(row.unitPriceFen)}
|
||||
</Typography.Text>
|
||||
) : null}
|
||||
</>
|
||||
{(row.pricingMode === 'unit' ? row.unitPriceFen : row.rewardAmount) > 0 ? (
|
||||
<Typography.Text strong style={{ color: '#3f8600', fontSize: 12 }}>
|
||||
{row.pricingMode === 'unit'
|
||||
? `${formatMoney(row.unitPriceFen)} / 件`
|
||||
: formatMoney(row.rewardAmount)}
|
||||
</Typography.Text>
|
||||
) : (
|
||||
<Tag color="orange" style={{ width: 'fit-content', margin: 0 }}>
|
||||
待成本配置
|
||||
@@ -889,6 +887,7 @@ export default function ProductRulesPanel() {
|
||||
skuNickMatchType: 'exact',
|
||||
enabled: false,
|
||||
autoCreate: true,
|
||||
pricingMode: 'fixed',
|
||||
sharingEnabled: false,
|
||||
acceptanceMode: 'standard',
|
||||
giftCooldownUnit: 'hours',
|
||||
@@ -902,10 +901,10 @@ export default function ProductRulesPanel() {
|
||||
type="info"
|
||||
showIcon
|
||||
style={{ marginBottom: 16 }}
|
||||
message="接单模板只维护匹配和履约规则"
|
||||
message="接单模板维护计价方式和履约规则"
|
||||
description={
|
||||
<span>
|
||||
固定金额、按件单价和价格同步统一由
|
||||
在这里选择“固定金额”或“按 SKU 按件”;具体金额与价格同步统一由
|
||||
<a href="#/admin/cost-center" style={{ margin: '0 4px', fontWeight: 500 }}>
|
||||
商品与成本中心
|
||||
</a>
|
||||
@@ -940,6 +939,22 @@ export default function ProductRulesPanel() {
|
||||
<Form.Item label="任务时限" name="timeoutMinutes">
|
||||
<InputNumber min={0} step={5} addonAfter="分钟" className="full-width" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="计价方式"
|
||||
name="pricingMode"
|
||||
rules={[{ required: true, message: '请选择计价方式' }]}
|
||||
extra="固定金额按整单;按 SKU 按件会把成本中心金额乘以订单件数"
|
||||
>
|
||||
<Radio.Group
|
||||
optionType="button"
|
||||
buttonStyle="solid"
|
||||
className="full-width"
|
||||
options={[
|
||||
{ value: 'fixed', label: '固定金额' },
|
||||
{ value: 'unit', label: '按 SKU 按件' },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
{/* 验收模式:好友赠送模式与拼单互斥 */}
|
||||
@@ -1047,9 +1062,7 @@ export default function ProductRulesPanel() {
|
||||
<Form.Item noStyle shouldUpdate>
|
||||
{({ getFieldValue }) => {
|
||||
const sharingEnabled = getFieldValue('sharingEnabled')
|
||||
const unitMode =
|
||||
Number(editingRule?.unitPriceFen || 0) > 0 &&
|
||||
Number(editingRule?.rewardAmount || 0) === 0
|
||||
const unitMode = getFieldValue('pricingMode') === 'unit'
|
||||
const friendGiftMode = getFieldValue('acceptanceMode') === 'friend_gift'
|
||||
const hasConfiguredPrice =
|
||||
Number(editingRule?.unitPriceFen || 0) > 0 ||
|
||||
|
||||
@@ -499,7 +499,6 @@ export function setAdminProductPrice(
|
||||
productId: number,
|
||||
payload: {
|
||||
amountFen: number
|
||||
pricingMode?: 'fixed' | 'unit'
|
||||
effectiveFrom?: string
|
||||
changeReason?: string
|
||||
syncOpenOrders?: boolean
|
||||
|
||||
@@ -290,6 +290,7 @@ export function saveAdminWorkProductRule(payload: {
|
||||
categoryId?: number
|
||||
enabled?: boolean
|
||||
autoCreate?: boolean
|
||||
pricingMode?: 'fixed' | 'unit'
|
||||
sharingEnabled?: boolean
|
||||
sharingAutoFromOrder?: boolean
|
||||
sharingTotalQuantity?: number
|
||||
|
||||
@@ -438,6 +438,7 @@ export type WorkProductRule = {
|
||||
autoCreate: boolean
|
||||
rewardAmount: number
|
||||
unitPriceFen: number
|
||||
pricingMode: 'fixed' | 'unit'
|
||||
sharing?: WorkOrderSharingConfig
|
||||
requirement: {
|
||||
fields: CollectField[]
|
||||
|
||||
Reference in New Issue
Block a user