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 f6be5deb
authored
Jun 12, 2026
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix 商户测试bug
1 parent
1f0ba46a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
8 deletions
src/views/systemConfig/merchant/financialRules/components/financialCalculationDialog.vue
src/views/systemConfig/merchant/financialRules/utils/validateStep3Amounts.js
tests/unit/financialRules/validateStep3Amounts.spec.js
src/views/systemConfig/merchant/financialRules/components/financialCalculationDialog.vue
View file @
f6be5de
...
...
@@ -93,10 +93,12 @@ import {
}
from
'../utils/divisionTestStepProgress'
import
{
buildStep2DisplayMerchants
,
buildStep3VerifyMerchants
,
isTotalProfitAmountValid
buildStep3VerifyMerchants
}
from
'../utils/buildStep2DisplayMerchants'
import
{
buildStep3SubmitMerchants
}
from
'../utils/validateStep3Amounts'
import
{
buildStep3SubmitMerchants
,
isStep3AmountTotalConsistent
}
from
'../utils/validateStep3Amounts'
import
{
buildDivisionRuleTestParams
,
buildDivisionRuleTestRetestParams
,
...
...
@@ -514,10 +516,6 @@ export default {
return
}
if
(
this
.
viewStep
===
2
)
{
if
(
!
isTotalProfitAmountValid
(
this
.
step2Merchants
))
{
this
.
$message
.
warning
(
'金额不一致,请确认后重新操作'
)
return
}
this
.
maxReachedStep
=
3
this
.
setViewStep
(
3
)
}
...
...
@@ -531,6 +529,10 @@ export default {
const
rawList
=
resolveDivisionTestMerchantDivisions
(
this
.
testObj
)
const
formMerchants
=
step3
.
getSubmitMerchants
()
if
(
!
isStep3AmountTotalConsistent
(
formMerchants
,
rawList
))
{
this
.
$message
.
warning
(
'金额不一致,请确认后重新操作'
)
return
}
const
testMerchantDivisions
=
buildStep3SubmitMerchants
(
rawList
,
formMerchants
)
const
params
=
buildDivisionRuleTestMoneyValidParams
({
testObj
:
this
.
testObj
,
...
...
src/views/systemConfig/merchant/financialRules/utils/validateStep3Amounts.js
View file @
f6be5de
...
...
@@ -79,3 +79,45 @@ export function buildStep3SubmitMerchants(displayMerchants, formMerchants) {
}
})
}
function
roundMoney
(
n
)
{
return
Math
.
round
(
n
*
100
)
/
100
}
function
parseMoney
(
value
)
{
const
n
=
parseFloat
(
value
)
return
Number
.
isFinite
(
n
)
?
n
:
0
}
/** 待确认商户接口返回 divisionMoney 合计 */
export
function
sumExpectedDivisionMoney
(
rawList
)
{
return
roundMoney
(
getStep3PendingMerchants
(
rawList
).
reduce
(
(
sum
,
m
)
=>
sum
+
parseMoney
(
m
.
divisionMoney
),
0
)
)
}
/** 待确认商户用户填写 confirmDivisionMoney 合计 */
export
function
sumConfirmDivisionMoney
(
formMerchants
,
rawList
)
{
const
formMap
=
new
Map
()
;(
formMerchants
||
[]).
forEach
((
m
)
=>
{
const
key
=
step3MerchantKey
(
m
)
if
(
key
)
formMap
.
set
(
key
,
m
)
})
return
roundMoney
(
getStep3PendingMerchants
(
rawList
).
reduce
((
sum
,
m
)
=>
{
const
key
=
step3MerchantKey
(
m
)
const
form
=
formMap
.
get
(
key
)
||
m
return
sum
+
parseMoney
(
form
.
confirmDivisionMoney
)
},
0
)
)
}
/** 用户填写合计与接口 divisionMoney 合计是否一致 */
export
function
isStep3AmountTotalConsistent
(
formMerchants
,
rawList
)
{
const
expected
=
sumExpectedDivisionMoney
(
rawList
)
const
actual
=
sumConfirmDivisionMoney
(
formMerchants
,
rawList
)
return
Math
.
abs
(
actual
-
expected
)
<
0.001
}
tests/unit/financialRules/validateStep3Amounts.spec.js
View file @
f6be5de
...
...
@@ -4,7 +4,10 @@ import {
buildStep3SubmitMerchants
,
mergeStep3FormMerchants
,
isMerchantCompletedFromDetail
,
getStep3PendingMerchants
getStep3PendingMerchants
,
sumExpectedDivisionMoney
,
sumConfirmDivisionMoney
,
isStep3AmountTotalConsistent
}
from
"@/views/systemConfig/merchant/financialRules/utils/validateStep3Amounts"
describe
(
"validateStep3Amounts"
,
()
=>
{
...
...
@@ -71,6 +74,31 @@ describe("validateStep3Amounts", () => {
expect
(
out
[
0
].
testCompleted
).
toBeUndefined
()
})
it
(
"isStep3AmountTotalConsistent compares confirmDivisionMoney sum to divisionMoney sum"
,
()
=>
{
const
rawList
=
[
{
merchantId
:
"m1"
,
distributionMoney
:
"0"
,
divisionMoney
:
"0.5"
},
{
merchantId
:
"m2"
,
distributionMoney
:
"1.2"
,
divisionMoney
:
"3"
}
]
const
formMatch
=
[
{
merchantId
:
"m2"
,
confirmDivisionMoney
:
"3"
}
]
const
formMismatch
=
[
{
merchantId
:
"m2"
,
confirmDivisionMoney
:
"2.9"
}
]
expect
(
sumExpectedDivisionMoney
(
rawList
)).
toBe
(
3
)
expect
(
sumConfirmDivisionMoney
(
formMatch
,
rawList
)).
toBe
(
3
)
expect
(
isStep3AmountTotalConsistent
(
formMatch
,
rawList
)).
toBe
(
true
)
expect
(
isStep3AmountTotalConsistent
(
formMismatch
,
rawList
)).
toBe
(
false
)
})
it
(
"sumExpectedDivisionMoney treats missing divisionMoney as 0"
,
()
=>
{
const
rawList
=
[
{
merchantId
:
"m1"
,
distributionMoney
:
"1.2"
,
divisionMoney
:
null
},
{
merchantId
:
"m2"
,
distributionMoney
:
"1.3"
,
divisionMoney
:
"3.5"
}
]
expect
(
sumExpectedDivisionMoney
(
rawList
)).
toBe
(
3.5
)
})
it
(
"buildStep3SubmitMerchants excludes detail-0 only, keeps user input 0"
,
()
=>
{
const
rawList
=
[
{
merchantId
:
"m1"
,
distributionMoney
:
"0"
},
...
...
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