Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-life-system
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 175d5c53
authored
May 22, 2026
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix 自测bug
1 parent
b8b848ed
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
275 additions
and
46 deletions
src/views/systemConfig/merchant/financialRules/components/divisionTestDialog/DivisionTestStepper.vue
src/views/systemConfig/merchant/financialRules/index.vue
src/views/systemConfig/merchant/financialRules/utils/divisionRuleAutoTest.js
src/views/systemConfig/merchant/financialRules/utils/resolveDivisionRuleIdFromApi.js
tests/unit/financialRules/divisionRuleAutoTest.spec.js
tests/unit/financialRules/resolveDivisionRuleIdFromApi.spec.js
src/views/systemConfig/merchant/financialRules/components/divisionTestDialog/DivisionTestStepper.vue
View file @
175d5c5
<
template
>
<div
class=
"division-test-stepper"
>
<p
class=
"stepper-label"
>
分账测试步骤
</p>
<el-steps
:active=
"activeIndex"
finish-status=
"success"
align-center
class=
"division-test-steps"
>
<el-step
v-for=
"n in 3"
:key=
"n"
:title=
"String(n)"
:status=
"stepStatus(n)"
@
click
.
native=
"onStepClick(n)"
class=
"division-test-step-item"
/>
</el-steps>
<div
class=
"stepper-track"
>
<template
v-for=
"n in 3"
>
<button
:key=
"'node-' + n"
type=
"button"
class=
"stepper-node"
:class=
"'is-' + stepVisualState(n)"
@
click=
"onStepClick(n)"
>
<i
v-if=
"stepVisualState(n) === 'done'"
class=
"el-icon-check stepper-check"
/>
<span
v-else
class=
"stepper-num"
>
{{
n
}}
</span>
</button>
<div
v-if=
"n
< 3
"
:key=
"'line-' + n"
class=
"stepper-line"
:class=
"
{ 'is-done': isConnectorDone(n) }"
/>
</
template
>
</div>
</div>
</template>
...
...
@@ -36,19 +40,20 @@ export default {
default
:
()
=>
[
false
,
false
,
false
]
}
},
computed
:
{
activeIndex
()
{
return
Math
.
max
(
0
,
Number
(
this
.
viewStep
)
-
1
)
}
},
methods
:
{
stepStatus
(
stepNum
)
{
/** done=蓝色勾 | current=蓝色序号 | wait=灰色序号 */
stepVisualState
(
stepNum
)
{
const
idx
=
stepNum
-
1
if
(
this
.
stepCompletedFlags
[
idx
]
&&
stepNum
<
this
.
viewStep
)
return
'success'
if
(
stepNum
===
this
.
viewStep
)
return
'process'
if
(
stepNum
<
this
.
maxReachedStep
)
return
'success'
const
completed
=
!!
this
.
stepCompletedFlags
[
idx
]
||
stepNum
<
Number
(
this
.
viewStep
)
if
(
completed
)
return
'done'
if
(
stepNum
===
Number
(
this
.
viewStep
))
return
'current'
return
'wait'
},
/** 步骤 n 与 n+1 之间的连线:前序步骤已完成时为蓝色 */
isConnectorDone
(
stepNum
)
{
return
this
.
stepVisualState
(
stepNum
)
===
'done'
},
onStepClick
(
stepNum
)
{
this
.
$emit
(
'step-click'
,
stepNum
)
}
...
...
@@ -57,22 +62,82 @@ export default {
</
script
>
<
style
scoped
lang=
"scss"
>
$
step-primary
:
#2a58ad
;
$
step-wait-border
:
#dcdfe6
;
$
step-wait-text
:
#c0c4cc
;
$
step-line-wait
:
#dcdfe6
;
.division-test-stepper
{
margin-bottom
:
16px
;
margin-bottom
:
24px
;
padding
:
0
40px
;
}
.stepper-track
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
max-width
:
360px
;
margin
:
0
auto
;
}
.stepper-node
{
flex-shrink
:
0
;
display
:
inline-flex
;
align-items
:
center
;
justify-content
:
center
;
width
:
28px
;
height
:
28px
;
padding
:
0
;
border-radius
:
50%
;
border
:
1px
solid
$
step-wait-border
;
background
:
#fff
;
cursor
:
pointer
;
outline
:
none
;
cursor
:
pointer
;
transition
:
border-color
0.2s
,
color
0.2s
;
&:focus-visible
{
box-shadow
:
0
0
0
2px
rgba
(
$
step-primary
,
0.25
);
}
&
.is-done
{
border-color
:
$
step-primary
;
color
:
$
step-primary
;
}
.stepper-label
{
font-size
:
12px
;
color
:
#6c6f71
;
margin
:
0
0
12px
;
&
.is-current
{
border-color
:
$
step-primary
;
color
:
$
step-primary
;
}
.division-test-steps
{
max-width
:
480px
;
margin
:
0
auto
;
&
.is-wait
{
border-color
:
$
step-wait-border
;
color
:
$
step-wait-text
;
}
}
.stepper-check
{
font-size
:
14px
;
font-weight
:
700
;
line-height
:
1
;
}
.stepper-num
{
font-size
:
14px
;
font-weight
:
500
;
line-height
:
1
;
}
.stepper-line
{
flex
:
1
;
height
:
1px
;
min-width
:
48px
;
margin
:
0
8px
;
background
:
$
step-line-wait
;
transition
:
background-color
0.2s
;
.division-test-step-item
{
cursor
:
pointer
;
&.is-done
{
background
:
$
step-primary
;
}
}
</
style
>
src/views/systemConfig/merchant/financialRules/index.vue
View file @
175d5c5
...
...
@@ -222,11 +222,14 @@ import { CLASSIFICATION_EMIT } from "./utils/classificationEmitTypes"
import
{
isDivisionRuleAutoTestPending
,
hasPendingDivisionRuleAutoTest
,
findPendingDivisionRuleAutoTestIndices
findPendingDivisionRuleAutoTestIndices
,
buildDivisionRuleAutosByChannelId
,
shouldShowDivisionTestButton
}
from
"./utils/divisionRuleAutoTest"
import
{
isDivisionTestInProgress
}
from
"./utils/divisionTestStepProgress"
import
{
buildDivisionRuleTestParams
}
from
"./utils/buildDivisionRuleTestParams"
import
{
normalizeDivisionTestPayload
}
from
"./utils/resolveDivisionTestOrderCode"
import
{
resolveDivisionRuleIdFromApi
}
from
"./utils/resolveDivisionRuleIdFromApi"
export
default
{
name
:
"FinancialRules"
,
// isNeedVuex: true,
...
...
@@ -335,6 +338,8 @@ export default {
divisionTabSelectError
:
false
,
/** 当前分账测试渠道在 divisionRuleAutos 中的下标 */
divisionTestChannelIndex
:
null
,
/** 详情/保存回包后的 divisionRuleAutos 快照,用于立即测试按钮展示 */
serverDivisionRuleAutosByChannelId
:
{},
financialCalculationVisible
:
false
,
financialCalculationObj
:
{},
channelSelectDialogVisible
:
false
,
...
...
@@ -572,9 +577,24 @@ export default {
const
ref
=
this
.
$refs
.
classificationActive
return
Array
.
isArray
(
ref
)
?
ref
[
0
]
:
ref
},
/**
已开自动分账且 testFlag 严格为 N(未完成分账测试
) */
/**
服务端已确认待测且当前开启自动分账时展示立即测试(本地切换 autoFlag 不生效
) */
needsDivisionTestForChannel
(
item
)
{
return
isDivisionRuleAutoTestPending
(
item
)
return
shouldShowDivisionTestButton
(
item
,
this
.
serverDivisionRuleAutosByChannelId
,
this
.
financialRulesEnv
.
divisionRuleId
)
},
applyDivisionRuleIdFromApi
(
payload
)
{
const
id
=
resolveDivisionRuleIdFromApi
(
payload
)
if
(
id
==
null
||
id
===
""
)
return
this
.
$set
(
this
.
financialObj
,
"divisionRuleId"
,
id
)
this
.
financialRulesEnv
.
divisionRuleId
=
id
},
syncServerDivisionRuleAutosSnapshot
(
divisionRuleAutos
)
{
this
.
serverDivisionRuleAutosByChannelId
=
buildDivisionRuleAutosByChannelId
(
divisionRuleAutos
)
},
/** 保存/详情回包中的 divisionRuleAutos 按 paymentChannelId 合并到本地 */
mergeDivisionRuleAutosFromApi
(
apiDivisionRuleAutos
)
{
...
...
@@ -592,6 +612,7 @@ export default {
}
else
{
this
.
financialObj
.
divisionRuleAutos
=
deepClone
(
apiDivisionRuleAutos
)
}
this
.
syncServerDivisionRuleAutosSnapshot
(
this
.
financialObj
.
divisionRuleAutos
)
},
getDivisionTestProgress
(
item
,
index
)
{
this
.
divisionTestChannelIndex
=
index
...
...
@@ -601,7 +622,7 @@ export default {
merchantId
,
sceneType
,
paymentChannelId
:
item
.
paymentChannelId
,
divisionRuleId
:
this
.
financial
Obj
.
divisionRuleId
,
divisionRuleId
:
this
.
financial
RulesEnv
.
divisionRuleId
,
baseSceneCode
})
divisionRuleTestGet
(
params
).
then
((
result
)
=>
{
...
...
@@ -640,7 +661,7 @@ export default {
if
(
shouldOpenDialog
)
{
this
.
financialCalculationVisible
=
true
this
.
financialCalculationObj
=
normalizeDivisionTestPayload
({
divisionRuleId
:
this
.
financial
Obj
.
divisionRuleId
,
divisionRuleId
:
this
.
financial
RulesEnv
.
divisionRuleId
,
paymentChannelId
:
item
.
paymentChannelId
,
paymentChannelName
:
item
.
paymentChannelName
,
...
result
...
...
@@ -661,7 +682,7 @@ export default {
}
this
.
financialCalculationVisible
=
true
this
.
financialCalculationObj
=
normalizeDivisionTestPayload
({
divisionRuleId
:
this
.
financial
Obj
.
divisionRuleId
,
divisionRuleId
:
this
.
financial
RulesEnv
.
divisionRuleId
,
...
result
,
...
result
.
divisionRuleTestItem
})
...
...
@@ -1145,7 +1166,6 @@ export default {
}
if
(
result
&&
result
.
divisionRuleId
)
{
this
.
financialObj
=
result
this
.
financialRulesEnv
.
divisionRuleId
=
result
.
divisionRuleId
}
result
.
multiPlatformMerchantFlag
=
result
.
multiPlatformMerchantFlag
||
"N"
...
...
@@ -1155,10 +1175,9 @@ export default {
// 如果有分账配置
if
(
result
)
{
this
.
financialObj
=
result
if
(
result
.
divisionRuleId
!=
null
&&
result
.
divisionRuleId
!==
''
)
{
this
.
financialRulesEnv
.
divisionRuleId
=
result
.
divisionRuleId
}
}
this
.
applyDivisionRuleIdFromApi
(
result
)
this
.
syncServerDivisionRuleAutosSnapshot
(
this
.
financialObj
.
divisionRuleAutos
)
// 详情未返回分账品类(null / 非数组 / 空数组)时:默认一条「全部品类」,首个 Tab 激活
let
goodsTypeGroupRules
=
ensureAllCategoryRuleFirst
(
...
...
@@ -1336,6 +1355,7 @@ export default {
)
merchantSettleDistributeRule
({
json
:
JSON
.
stringify
(
this
.
submitParams
)
})
.
then
((
result
)
=>
{
this
.
applyDivisionRuleIdFromApi
(
result
)
const
{
divisionRuleAutos
}
=
result
||
{}
if
(
hasPendingDivisionRuleAutoTest
(
divisionRuleAutos
))
{
this
.
mergeDivisionRuleAutosFromApi
(
divisionRuleAutos
)
...
...
src/views/systemConfig/merchant/financialRules/utils/divisionRuleAutoTest.js
View file @
175d5c5
...
...
@@ -3,6 +3,36 @@ export function isDivisionRuleAutoTestPending(item) {
return
item
&&
item
.
autoFlag
==
"Y"
&&
item
.
testFlag
==
"N"
}
export
function
buildDivisionRuleAutosByChannelId
(
divisionRuleAutos
)
{
const
map
=
{}
;(
divisionRuleAutos
||
[]).
forEach
((
item
)
=>
{
if
(
item
&&
item
.
paymentChannelId
!=
null
)
{
map
[
item
.
paymentChannelId
]
=
{
paymentChannelId
:
item
.
paymentChannelId
,
autoFlag
:
item
.
autoFlag
,
testFlag
:
item
.
testFlag
}
}
})
return
map
}
/**
* 立即测试按钮:须已有 divisionRuleId,当前开启自动分账,且服务端(详情/保存回包)判定待测。
* 本地切换 autoFlag 不触发显示,避免后端尚未生成测算 id。
*/
export
function
shouldShowDivisionTestButton
(
currentChannel
,
serverChannelById
,
divisionRuleId
)
{
if
(
divisionRuleId
==
null
||
divisionRuleId
===
""
)
return
false
if
(
!
currentChannel
||
currentChannel
.
autoFlag
!=
"Y"
)
return
false
const
serverChannel
=
serverChannelById
&&
serverChannelById
[
currentChannel
.
paymentChannelId
]
return
isDivisionRuleAutoTestPending
(
serverChannel
)
}
export
function
hasPendingDivisionRuleAutoTest
(
divisionRuleAutos
)
{
return
(
divisionRuleAutos
||
[]).
some
(
isDivisionRuleAutoTestPending
)
}
...
...
src/views/systemConfig/merchant/financialRules/utils/resolveDivisionRuleIdFromApi.js
0 → 100644
View file @
175d5c5
export
function
resolveDivisionRuleIdFromApi
(
payload
)
{
if
(
!
payload
||
typeof
payload
!==
"object"
)
return
undefined
const
top
=
payload
.
divisionRuleId
if
(
top
!=
null
&&
top
!==
""
)
return
top
const
nested
=
payload
.
merchantSettleDistributeRule
if
(
nested
&&
nested
.
divisionRuleId
!=
null
&&
nested
.
divisionRuleId
!==
""
)
{
return
nested
.
divisionRuleId
}
return
undefined
}
tests/unit/financialRules/divisionRuleAutoTest.spec.js
View file @
175d5c5
import
{
isDivisionRuleAutoTestPending
,
hasPendingDivisionRuleAutoTest
,
findPendingDivisionRuleAutoTestIndices
findPendingDivisionRuleAutoTestIndices
,
buildDivisionRuleAutosByChannelId
,
shouldShowDivisionTestButton
}
from
"@/views/systemConfig/merchant/financialRules/utils/divisionRuleAutoTest"
describe
(
"divisionRuleAutoTest"
,
()
=>
{
...
...
@@ -37,4 +39,75 @@ describe("divisionRuleAutoTest", () => {
]
expect
(
findPendingDivisionRuleAutoTestIndices
(
list
)).
toEqual
([
1
])
})
it
(
"buildDivisionRuleAutosByChannelId"
,
()
=>
{
const
map
=
buildDivisionRuleAutosByChannelId
([
{
paymentChannelId
:
1
,
autoFlag
:
"Y"
,
testFlag
:
"N"
},
{
paymentChannelId
:
2
,
autoFlag
:
"N"
,
testFlag
:
"N"
}
])
expect
(
map
[
1
]).
toEqual
({
paymentChannelId
:
1
,
autoFlag
:
"Y"
,
testFlag
:
"N"
})
expect
(
map
[
2
].
autoFlag
).
toBe
(
"N"
)
})
it
(
"buildDivisionRuleAutosByChannelId: snapshot isolated from local autoFlag toggle"
,
()
=>
{
const
channel
=
{
paymentChannelId
:
10
,
autoFlag
:
"N"
,
testFlag
:
"N"
}
const
map
=
buildDivisionRuleAutosByChannelId
([
channel
])
channel
.
autoFlag
=
"Y"
expect
(
map
[
10
].
autoFlag
).
toBe
(
"N"
)
expect
(
shouldShowDivisionTestButton
(
channel
,
map
,
"rule-1"
)
).
toBe
(
false
)
})
it
(
"shouldShowDivisionTestButton: server pending and local auto on"
,
()
=>
{
const
serverMap
=
buildDivisionRuleAutosByChannelId
([
{
paymentChannelId
:
10
,
autoFlag
:
"Y"
,
testFlag
:
"N"
}
])
expect
(
shouldShowDivisionTestButton
(
{
paymentChannelId
:
10
,
autoFlag
:
"Y"
,
testFlag
:
"N"
},
serverMap
,
"rule-1"
)
).
toBe
(
true
)
})
it
(
"shouldShowDivisionTestButton: local auto on without server pending stays hidden"
,
()
=>
{
const
serverMap
=
buildDivisionRuleAutosByChannelId
([
{
paymentChannelId
:
10
,
autoFlag
:
"N"
,
testFlag
:
"N"
}
])
expect
(
shouldShowDivisionTestButton
(
{
paymentChannelId
:
10
,
autoFlag
:
"Y"
,
testFlag
:
"N"
},
serverMap
,
"rule-1"
)
).
toBe
(
false
)
})
it
(
"shouldShowDivisionTestButton: no divisionRuleId"
,
()
=>
{
const
serverMap
=
buildDivisionRuleAutosByChannelId
([
{
paymentChannelId
:
10
,
autoFlag
:
"Y"
,
testFlag
:
"N"
}
])
expect
(
shouldShowDivisionTestButton
(
{
paymentChannelId
:
10
,
autoFlag
:
"Y"
,
testFlag
:
"N"
},
serverMap
,
undefined
)
).
toBe
(
false
)
})
it
(
"shouldShowDivisionTestButton: local auto off hides even if server pending"
,
()
=>
{
const
serverMap
=
buildDivisionRuleAutosByChannelId
([
{
paymentChannelId
:
10
,
autoFlag
:
"Y"
,
testFlag
:
"N"
}
])
expect
(
shouldShowDivisionTestButton
(
{
paymentChannelId
:
10
,
autoFlag
:
"N"
,
testFlag
:
"N"
},
serverMap
,
"rule-1"
)
).
toBe
(
false
)
})
})
tests/unit/financialRules/resolveDivisionRuleIdFromApi.spec.js
0 → 100644
View file @
175d5c5
import
{
resolveDivisionRuleIdFromApi
}
from
"@/views/systemConfig/merchant/financialRules/utils/resolveDivisionRuleIdFromApi"
describe
(
"resolveDivisionRuleIdFromApi"
,
()
=>
{
it
(
"returns top-level divisionRuleId"
,
()
=>
{
expect
(
resolveDivisionRuleIdFromApi
({
divisionRuleId
:
4928
})).
toBe
(
4928
)
expect
(
resolveDivisionRuleIdFromApi
({
divisionRuleId
:
"rule-1"
})).
toBe
(
"rule-1"
)
})
it
(
"returns undefined for missing or empty id"
,
()
=>
{
expect
(
resolveDivisionRuleIdFromApi
(
null
)).
toBeUndefined
()
expect
(
resolveDivisionRuleIdFromApi
({})).
toBeUndefined
()
expect
(
resolveDivisionRuleIdFromApi
({
divisionRuleId
:
""
})).
toBeUndefined
()
})
it
(
"falls back to merchantSettleDistributeRule.divisionRuleId"
,
()
=>
{
expect
(
resolveDivisionRuleIdFromApi
({
merchantSettleDistributeRule
:
{
divisionRuleId
:
9001
}
})
).
toBe
(
9001
)
})
it
(
"prefers top-level divisionRuleId over nested"
,
()
=>
{
expect
(
resolveDivisionRuleIdFromApi
({
divisionRuleId
:
100
,
merchantSettleDistributeRule
:
{
divisionRuleId
:
200
}
})
).
toBe
(
100
)
})
})
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment