fix(admin): 恢复接单模板计价配置并统一成本价格链路

This commit is contained in:
yml2213
2026-11-02 17:57:49 +08:00
parent d871b93fde
commit a7bac9c1d8
27 changed files with 304 additions and 83 deletions
@@ -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 ||