修复拼单默认自动匹配
This commit is contained in:
@@ -628,7 +628,7 @@ export async function saveAdminWorkProductRule(payload: JsonObject = {}) {
|
|||||||
sharingEnabled &&
|
sharingEnabled &&
|
||||||
unitPriceFen > 0 &&
|
unitPriceFen > 0 &&
|
||||||
(normalizeBoolean(payload.sharingAutoFromOrder ?? payload.sharing_auto_from_order, false) ||
|
(normalizeBoolean(payload.sharingAutoFromOrder ?? payload.sharing_auto_from_order, false) ||
|
||||||
(!hasManualSharingConfig && existingRule?.sharing_auto_from_order !== false))
|
!hasManualSharingConfig)
|
||||||
const hasManualSharingQuantity = hasConfiguredSharingValue(
|
const hasManualSharingQuantity = hasConfiguredSharingValue(
|
||||||
payload.sharingTotalQuantity ?? payload.sharing_total_quantity,
|
payload.sharingTotalQuantity ?? payload.sharing_total_quantity,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -97,6 +97,10 @@ export default function ProductRulesPanel() {
|
|||||||
|
|
||||||
function editRule(rule: WorkProductRule) {
|
function editRule(rule: WorkProductRule) {
|
||||||
setEditingRule(rule)
|
setEditingRule(rule)
|
||||||
|
const hasManualSharingOverride = hasManualSharingInput(
|
||||||
|
rule.sharing?.totalQuantity,
|
||||||
|
rule.sharing?.unitReward,
|
||||||
|
)
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
provider: rule.provider,
|
provider: rule.provider,
|
||||||
platform: rule.platform,
|
platform: rule.platform,
|
||||||
@@ -119,15 +123,13 @@ export default function ProductRulesPanel() {
|
|||||||
unitPrice: rule.unitPriceFen / 100,
|
unitPrice: rule.unitPriceFen / 100,
|
||||||
sharingEnabled: rule.sharing?.enabled || false,
|
sharingEnabled: rule.sharing?.enabled || false,
|
||||||
sharingAutoFromOrder: rule.sharing?.autoFromOrder || false,
|
sharingAutoFromOrder: rule.sharing?.autoFromOrder || false,
|
||||||
sharingTotalQuantity: rule.sharing?.autoFromOrder
|
sharingTotalQuantity: hasManualSharingOverride ? rule.sharing?.totalQuantity : undefined,
|
||||||
? undefined
|
sharingUnitReward: hasManualSharingOverride
|
||||||
: rule.sharing?.totalQuantity || 1,
|
? (rule.sharing?.unitReward || 0) / 100
|
||||||
sharingUnitReward: rule.sharing?.autoFromOrder
|
: undefined,
|
||||||
? undefined
|
sharingTotalAmount: hasManualSharingOverride
|
||||||
: (rule.sharing?.unitReward || 0) / 100,
|
? ((rule.sharing?.totalQuantity || 1) * (rule.sharing?.unitReward || 0)) / 100
|
||||||
sharingTotalAmount: rule.sharing?.autoFromOrder
|
: undefined,
|
||||||
? undefined
|
|
||||||
: ((rule.sharing?.totalQuantity || 1) * (rule.sharing?.unitReward || 0)) / 100,
|
|
||||||
timeoutMinutes: rule.timeoutMinutes || 0,
|
timeoutMinutes: rule.timeoutMinutes || 0,
|
||||||
timeoutPolicy: rule.timeoutPolicy || 'reopen',
|
timeoutPolicy: rule.timeoutPolicy || 'reopen',
|
||||||
fieldsText: formatRuleFields(rule.requirement?.fields || []),
|
fieldsText: formatRuleFields(rule.requirement?.fields || []),
|
||||||
@@ -174,7 +176,10 @@ export default function ProductRulesPanel() {
|
|||||||
try {
|
try {
|
||||||
const unitMode = values.pricingMode === 'unit'
|
const unitMode = values.pricingMode === 'unit'
|
||||||
const hasManualSharingOverride =
|
const hasManualSharingOverride =
|
||||||
Number(values.sharingTotalQuantity || 0) > 0 || Number(values.sharingUnitReward || 0) > 0
|
form.isFieldTouched('sharingTotalQuantity') || form.isFieldTouched('sharingUnitReward')
|
||||||
|
? Number(values.sharingTotalQuantity || 0) > 0 ||
|
||||||
|
Number(values.sharingUnitReward || 0) > 0
|
||||||
|
: hasManualSharingInput(values.sharingTotalQuantity, values.sharingUnitReward)
|
||||||
const { pricingMode: _pricingMode, ...payload } = values
|
const { pricingMode: _pricingMode, ...payload } = values
|
||||||
await saveAdminWorkProductRule({
|
await saveAdminWorkProductRule({
|
||||||
...payload,
|
...payload,
|
||||||
@@ -202,6 +207,10 @@ export default function ProductRulesPanel() {
|
|||||||
|
|
||||||
async function toggleRuleEnabled(rule: WorkProductRule, enabled: boolean) {
|
async function toggleRuleEnabled(rule: WorkProductRule, enabled: boolean) {
|
||||||
try {
|
try {
|
||||||
|
const hasManualSharingOverride = hasManualSharingInput(
|
||||||
|
rule.sharing?.totalQuantity,
|
||||||
|
rule.sharing?.unitReward,
|
||||||
|
)
|
||||||
await saveAdminWorkProductRule({
|
await saveAdminWorkProductRule({
|
||||||
ruleId: rule.ruleId,
|
ruleId: rule.ruleId,
|
||||||
ruleKey: rule.ruleKey,
|
ruleKey: rule.ruleKey,
|
||||||
@@ -216,16 +225,15 @@ export default function ProductRulesPanel() {
|
|||||||
rewardAmount: rule.rewardAmount / 100,
|
rewardAmount: rule.rewardAmount / 100,
|
||||||
unitPrice: rule.unitPriceFen / 100,
|
unitPrice: rule.unitPriceFen / 100,
|
||||||
sharingEnabled: rule.sharing?.enabled || false,
|
sharingEnabled: rule.sharing?.enabled || false,
|
||||||
sharingAutoFromOrder: rule.sharing?.autoFromOrder || false,
|
sharingAutoFromOrder:
|
||||||
sharingTotalQuantity: rule.sharing?.autoFromOrder
|
rule.unitPriceFen > 0 && rule.sharing?.enabled === true && !hasManualSharingOverride,
|
||||||
? undefined
|
sharingTotalQuantity: hasManualSharingOverride ? rule.sharing?.totalQuantity : undefined,
|
||||||
: rule.sharing?.totalQuantity || 1,
|
sharingUnitReward: hasManualSharingOverride
|
||||||
sharingUnitReward: rule.sharing?.autoFromOrder
|
? (rule.sharing?.unitReward || 0) / 100
|
||||||
? undefined
|
: undefined,
|
||||||
: (rule.sharing?.unitReward || 0) / 100,
|
sharingTotalAmount: hasManualSharingOverride
|
||||||
sharingTotalAmount: rule.sharing?.autoFromOrder
|
? ((rule.sharing?.totalQuantity || 1) * (rule.sharing?.unitReward || 0)) / 100
|
||||||
? undefined
|
: undefined,
|
||||||
: ((rule.sharing?.totalQuantity || 1) * (rule.sharing?.unitReward || 0)) / 100,
|
|
||||||
timeoutMinutes: rule.timeoutMinutes || 0,
|
timeoutMinutes: rule.timeoutMinutes || 0,
|
||||||
timeoutPolicy: rule.timeoutPolicy || 'reopen',
|
timeoutPolicy: rule.timeoutPolicy || 'reopen',
|
||||||
fieldsText: formatRuleFields(rule.requirement?.fields || []),
|
fieldsText: formatRuleFields(rule.requirement?.fields || []),
|
||||||
@@ -785,3 +793,7 @@ function formatRuleFields(fields: CollectField[]) {
|
|||||||
})
|
})
|
||||||
.join('\n')
|
.join('\n')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasManualSharingInput(quantity: unknown, unitRewardFen: unknown) {
|
||||||
|
return Number(quantity || 0) > 1 || Number(unitRewardFen || 0) > 0
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user