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 587cc7c0
authored
May 25, 2026
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix 分账测试bug
1 parent
347a500d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
647 additions
and
210 deletions
src/components/glsx-combi-form/index.vue
src/components/glsx-combi-form/provinceCity.vue
src/views/systemConfig/merchant/financialRules/components/financialCalculationDialog.vue
src/views/systemConfig/merchant/financialRules/index.vue
src/views/systemConfig/merchant/financialRules/utils/divisionRuleAutoTest.js
src/views/systemConfig/merchant/financialRules/utils/divisionTestStepProgress.js
src/views/systemConfig/merchant/financialRules/utils/financialRulesIncrementalGate.js
src/views/systemConfig/merchant/financialRules/utils/resolveDivisionTestOrderCode.js
tests/unit/financialRules/divisionRuleAutoTest.spec.js
tests/unit/financialRules/divisionTestStepProgress.spec.js
tests/unit/financialRules/financialRulesIncrementalGate.spec.js
tests/unit/financialRules/resolveDivisionTestOrderCode.spec.js
src/components/glsx-combi-form/index.vue
View file @
587cc7c
This diff is collapsed.
Click to expand it.
src/components/glsx-combi-form/provinceCity.vue
deleted
100644 → 0
View file @
347a500
<
template
>
<div
v-if=
"provinceView"
>
<el-form
ref=
"provinceForm"
:model=
"provinceForm"
inline=
"true"
class=
"province"
style=
"padding-left: 0;"
>
<el-select
size=
"small"
v-model=
"provinceForm.provinceName"
clearable
:disabled=
"isDisabled"
placeholder=
"选择省份"
:style=
"
{ width: defaultWidth }" @change="selectProvince" class="select-padding">
<el-option
v-for=
"item in AllData"
:key=
"item.adcode"
:label=
"item.name"
:value=
"item.name"
@
click
.
native=
"selectProvince(item)"
></el-option>
</el-select>
<el-select
size=
"small"
v-model=
"provinceForm.cityName"
clearable
:disabled=
"isDisabled"
placeholder=
"选择市"
:style=
"
{ width: defaultWidth }" @change="selectCity" class="select-padding">
<el-option
v-for=
"item in cityList"
:key=
"item.adcode"
:label=
"item.name"
:value=
"item.name"
@
click
.
native=
"selectCity(item)"
></el-option>
</el-select>
<el-select
v-if=
"subdistrict == 3"
size=
"small"
v-model=
"provinceForm.townName"
clearable
:disabled=
"isDisabled"
placeholder=
"选择区"
:style=
"
{ width: defaultWidth }" @change="selectTown" class="select-padding">
<el-option
v-for=
"item in townList"
:key=
"item.adcode"
:label=
"item.name"
:value=
"item.name"
@
click
.
native=
"selectTown(item)"
></el-option>
</el-select>
</el-form>
</div>
</
template
>
<
script
>
export
default
{
name
:
'GLProvince'
,
props
:
{
// 省市级别,2--只显示省市,3--显示省市区,默认只显示省市
subdistrict
:
{
type
:
Number
,
default
:
2
},
// 省市下拉组件宽度
defaultWidth
:
{
type
:
String
,
default
:
'150px'
},
// 组件是否展示,默认展示
provinceView
:
{
type
:
Boolean
,
default
:
true
},
isDisabled
:
{
type
:
Boolean
,
default
:
false
}
},
data
()
{
return
{
// 所有数据
AllData
:
[],
// 城市列表
cityList
:
[],
// 地区列表
townList
:
[],
provinceForm
:
{
// 省份名称
provinceName
:
''
,
// 城市名称
cityName
:
''
,
// 地区名称
townName
:
''
,
// 省份代码
provinceCode
:
''
,
// 城市代码
cityCode
:
''
,
// 地区代码
townCode
:
''
}
}
},
mounted
()
{
this
.
provinceList
()
},
methods
:
{
/*
* @params:传入的为一个key-value的对象
1、keywords --查询关键字,只支持单个关键词语搜索关键词支持:行政区名称、citycode、adcode
列如:this.provinceList({keywords: '山东省'}),这样就可以筛选出山东省下的市、区信息
2、subdistrict --设置显示下级行政区级数,0:不返回下级行政区;1:返回下一级行政区;2:返回下两级行政区;3:返回下三级行政区;
不传的话默认为2,可以在组件中穿,也可以在调用方法的时候传,如果需要展示省市组件,传值最小为2
3、page --最外层的districts最多会返回20个数据,若超过限制,请用page请求下一页数据。
例如page=2;page=3。默认page=1
4、extensions --控制行政区信息中返回行政区边界坐标点; 可选值:base、all;
base:不返回行政区边界坐标点;(默认)
all:只返回当前查询district的边界值,不返回子节点的边界值;目前不能返回乡镇/街道级别的边界值
5、filter -- 按照指定行政区划进行过滤,填入后则只返回该省/直辖市信息,需填入adcode,为了保证数据的正确,强烈建议填入此参数
6、callback -- callback值是用户定义的函数名称,此参数只在output=JSON时有效
7、output --返回数据格式类型,可选值:JSON,XML(默认JSON)
* @return:返回的是一个promise对象,如果不需要展示组件,只需要获取值,可以直接调用方法,异步获取返回值
列如:
const p = this.$refs.provinceForm.provinceList({xxxx(可传值,传值可参考上文params描述) })
p.then(r => {
// r 为返回结果
console.log(r)
})
**/
// 获取省市信息
provinceList
(
params
=
{})
{
params
?
(
params
.
subdistrict
?
''
:
(
params
.
subdistrict
=
this
.
subdistrict
))
:
(
params
.
subdistrict
=
this
.
subdistrict
)
let
data
=
''
for
(
const
key
in
params
)
{
data
+=
'&'
+
key
+
'='
+
params
[
key
]
}
let
path
=
`https://restapi.amap.com/v3/config/district?key=d22348363c34c266f772ae9b635eef2a`
path
=
path
+
data
const
pro
=
fetch
(
path
).
then
(
res
=>
{
return
res
.
json
()
})
if
(
this
.
provinceView
)
{
pro
.
then
(
r
=>
{
this
.
AllData
=
r
.
districts
[
0
].
districts
})
}
return
pro
},
// 省市回显
init
(
province
,
city
,
town
)
{
this
.
provinceForm
=
{
provinceName
:
province
,
cityName
:
city
,
townName
:
town
}
if
(
province
)
{
this
.
AllData
.
map
(
item
=>
{
if
(
item
.
name
.
indexOf
(
province
)
!=
-
1
)
{
this
.
provinceForm
.
provinceName
=
item
.
name
this
.
cityList
=
item
.
districts
this
.
provinceForm
.
provinceCode
=
item
.
adcode
if
(
city
)
{
this
.
cityList
.
map
(
itm
=>
{
if
(
itm
.
name
.
indexOf
(
city
)
!=
-
1
)
{
this
.
provinceForm
.
cityCode
=
itm
.
adcode
this
.
provinceForm
.
cityName
=
itm
.
name
this
.
townList
=
itm
.
districts
if
(
town
)
{
this
.
townList
.
map
(
itmx
=>
{
if
(
itmx
.
name
.
indexOf
(
town
)
!=
-
1
)
{
this
.
provinceForm
.
townCode
=
itmx
.
adcode
this
.
provinceForm
.
townName
=
itmx
.
name
}
})
}
}
})
}
}
})
}
},
// 选择省
selectProvince
(
val
)
{
this
.
provinceForm
.
cityName
=
''
this
.
provinceForm
.
townName
=
''
this
.
cityList
=
val
.
districts
this
.
$emit
(
'selectProvince'
,
{
provinceName
:
val
.
name
,
provinceCode
:
val
.
adcode
})
},
// 选择市
selectCity
(
val
)
{
this
.
provinceForm
.
townName
=
''
this
.
townList
=
val
.
districts
this
.
$emit
(
'selectCity'
,
{
cityName
:
val
.
name
,
cityCode
:
val
.
adcode
})
},
// 选择区
selectTown
(
val
)
{
this
.
$emit
(
'selectTown'
,
{
townName
:
val
.
name
,
townCode
:
val
.
adcode
})
}
}
}
</
script
>
<
style
lang=
"scss"
>
.province
{
display
:
inline-flex
;
.el-select
.el-input
{
width
:
auto
!important
;
}
}
.select-padding
{
margin-right
:
10px
;
}
</
style
>
src/views/systemConfig/merchant/financialRules/components/financialCalculationDialog.vue
View file @
587cc7c
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
<div
class=
"step-content"
>
<div
class=
"step-content"
>
<DivisionTestStep1Pay
<DivisionTestStep1Pay
v-show=
"viewStep === 1"
v-show=
"viewStep === 1"
:step1-paid=
"
uiState.step1Pai
d"
:step1-paid=
"
step1ShowOrderLinke
d"
:order-code=
"testOrderCode"
:order-code=
"testOrderCode"
:qr-code-u-r-l=
"qrCodeURL"
:qr-code-u-r-l=
"qrCodeURL"
:pay-amount=
"payAmount"
:pay-amount=
"payAmount"
...
@@ -87,6 +87,8 @@ import {
...
@@ -87,6 +87,8 @@ import {
canNavigateToStep
,
canNavigateToStep
,
isStepReadOnly
as
checkStepReadOnly
,
isStepReadOnly
as
checkStepReadOnly
,
isDivisionTestPassed
,
isDivisionTestPassed
,
shouldShowStep1OrderLinked
,
shouldSyncWizardStepsFromProgress
,
DIVISION_TEST_SUB_PROGRESS_IN_PROGRESS
DIVISION_TEST_SUB_PROGRESS_IN_PROGRESS
}
from
'../utils/divisionTestStepProgress'
}
from
'../utils/divisionTestStepProgress'
import
{
import
{
...
@@ -103,6 +105,7 @@ import {
...
@@ -103,6 +105,7 @@ import {
}
from
'../utils/buildDivisionRuleTestParams'
}
from
'../utils/buildDivisionRuleTestParams'
import
{
import
{
resolveDivisionTestOrderCode
,
resolveDivisionTestOrderCode
,
resolveDivisionTestOutTradeNo
,
resolveDivisionTestSubProgress
,
resolveDivisionTestSubProgress
,
resolveDivisionTestProgress
,
resolveDivisionTestProgress
,
resolveDivisionTestMerchantDivisions
,
resolveDivisionTestMerchantDivisions
,
...
@@ -167,12 +170,24 @@ export default {
...
@@ -167,12 +170,24 @@ export default {
return
this
.
testObj
.
testGoodsPrice
||
3.5
return
this
.
testObj
.
testGoodsPrice
||
3.5
},
},
nextButtonDisabled
()
{
nextButtonDisabled
()
{
if
(
this
.
viewStep
===
1
)
return
!
this
.
uiState
.
step1Pai
d
if
(
this
.
viewStep
===
1
)
return
!
this
.
step1ShowOrderLinke
d
return
false
return
false
},
},
testOrderCode
()
{
testOrderCode
()
{
return
resolveDivisionTestOrderCode
(
this
.
testObj
)
return
resolveDivisionTestOrderCode
(
this
.
testObj
)
},
},
testOutTradeNo
()
{
return
resolveDivisionTestOutTradeNo
(
this
.
testObj
)
},
step1ShowOrderLinked
()
{
return
shouldShowStep1OrderLinked
({
step1Paid
:
this
.
uiState
.
step1Paid
,
subProgress
:
this
.
subProgress
,
outTradeNo
:
this
.
testOutTradeNo
,
maxReachedStep
:
this
.
maxReachedStep
,
viewStep
:
this
.
viewStep
})
},
stepCompletedFlags
()
{
stepCompletedFlags
()
{
return
buildStepCompletedFlags
(
return
buildStepCompletedFlags
(
this
.
uiState
.
step1Paid
,
this
.
uiState
.
step1Paid
,
...
@@ -195,7 +210,7 @@ export default {
...
@@ -195,7 +210,7 @@ export default {
visible
(
val
)
{
visible
(
val
)
{
if
(
val
)
{
if
(
val
)
{
this
.
bootstrapFromProps
()
this
.
bootstrapFromProps
()
if
(
!
this
.
uiState
.
step1Pai
d
&&
this
.
testOrderCode
)
{
if
(
!
this
.
step1ShowOrderLinke
d
&&
this
.
testOrderCode
)
{
this
.
initQrCode
()
this
.
initQrCode
()
}
}
this
.
refreshTestData
()
this
.
refreshTestData
()
...
@@ -211,6 +226,7 @@ export default {
...
@@ -211,6 +226,7 @@ export default {
if
(
!
this
.
visible
)
return
if
(
!
this
.
visible
)
return
this
.
testObj
=
this
.
normalizeTestObjPayload
(
this
.
financialCalculationObj
)
this
.
testObj
=
this
.
normalizeTestObjPayload
(
this
.
financialCalculationObj
)
this
.
applySubProgress
(
this
.
testObj
.
subProgress
,
this
.
testObj
)
this
.
applySubProgress
(
this
.
testObj
.
subProgress
,
this
.
testObj
)
this
.
syncViewStepFromServerProgress
()
}
}
}
}
},
},
...
@@ -283,10 +299,10 @@ export default {
...
@@ -283,10 +299,10 @@ export default {
this
.
resetWizardNavigation
(
sp
)
this
.
resetWizardNavigation
(
sp
)
this
.
applySubProgress
(
sp
,
this
.
testObj
)
this
.
applySubProgress
(
sp
,
this
.
testObj
)
},
},
syncViewStep
IfSubProgress36
()
{
syncViewStep
FromServerProgress
()
{
if
(
Number
(
this
.
subProgress
)
!==
36
)
return
if
(
!
shouldSyncWizardStepsFromProgress
(
this
.
subProgress
)
)
return
const
progress
=
resolveDivisionTestProgress
(
this
.
testObj
,
this
.
testObj
.
progress
)
const
progress
=
resolveDivisionTestProgress
(
this
.
testObj
,
this
.
testObj
.
progress
)
const
{
viewStep
,
maxReachedStep
}
=
resolveInitialWizardSteps
(
36
,
progress
)
const
{
viewStep
,
maxReachedStep
}
=
resolveInitialWizardSteps
(
this
.
subProgress
,
progress
)
this
.
maxReachedStep
=
maxReachedStep
this
.
maxReachedStep
=
maxReachedStep
this
.
setViewStep
(
viewStep
)
this
.
setViewStep
(
viewStep
)
},
},
...
@@ -296,7 +312,8 @@ export default {
...
@@ -296,7 +312,8 @@ export default {
const
ui
=
mapSubProgressToUi
(
this
.
subProgress
,
{
const
ui
=
mapSubProgressToUi
(
this
.
subProgress
,
{
orderPaid
:
payload
.
orderPaid
,
orderPaid
:
payload
.
orderPaid
,
payStatus
:
payload
.
payStatus
,
payStatus
:
payload
.
payStatus
,
paymentSuccess
:
payload
.
paymentSuccess
paymentSuccess
:
payload
.
paymentSuccess
,
outTradeNo
:
resolveDivisionTestOutTradeNo
(
payload
)
})
})
let
step1Paid
=
ui
.
step1Paid
let
step1Paid
=
ui
.
step1Paid
if
(
prevPaid
&&
resolveDivisionTestOrderCode
(
payload
)
&&
!
step1Paid
)
{
if
(
prevPaid
&&
resolveDivisionTestOrderCode
(
payload
)
&&
!
step1Paid
)
{
...
@@ -350,8 +367,8 @@ export default {
...
@@ -350,8 +367,8 @@ export default {
if
(
!
result
)
return
if
(
!
result
)
return
this
.
testObj
=
this
.
normalizeTestObjPayload
({
...
this
.
testObj
,
...
result
})
this
.
testObj
=
this
.
normalizeTestObjPayload
({
...
this
.
testObj
,
...
result
})
this
.
applySubProgress
(
result
.
subProgress
,
this
.
testObj
)
this
.
applySubProgress
(
result
.
subProgress
,
this
.
testObj
)
this
.
syncViewStep
IfSubProgress36
()
this
.
syncViewStep
FromServerProgress
()
if
(
!
this
.
uiState
.
step1Pai
d
&&
this
.
testOrderCode
)
{
if
(
!
this
.
step1ShowOrderLinke
d
&&
this
.
testOrderCode
)
{
this
.
initQrCode
()
this
.
initQrCode
()
}
}
if
(
isDivisionTestPassed
(
result
.
subProgress
))
{
if
(
isDivisionTestPassed
(
result
.
subProgress
))
{
...
@@ -488,7 +505,7 @@ export default {
...
@@ -488,7 +505,7 @@ export default {
},
},
handleNext
()
{
handleNext
()
{
if
(
this
.
viewStep
===
1
)
{
if
(
this
.
viewStep
===
1
)
{
if
(
!
this
.
uiState
.
step1Pai
d
)
{
if
(
!
this
.
step1ShowOrderLinke
d
)
{
this
.
$message
.
warning
(
'请先完成扫码支付'
)
this
.
$message
.
warning
(
'请先完成扫码支付'
)
return
return
}
}
...
@@ -542,13 +559,13 @@ export default {
...
@@ -542,13 +559,13 @@ export default {
this
.
handleClose
()
this
.
handleClose
()
this
.
$emit
(
'checkSuccess'
)
this
.
$emit
(
'checkSuccess'
)
}
else
{
}
else
{
this
.
$message
.
warning
(
'测试失败,请确认商户、金额、订单分账状态是否正常'
)
this
.
testObj
=
this
.
normalizeTestObjPayload
({
...
this
.
testObj
,
...
result
})
this
.
applySubProgress
(
sp
,
{
...
this
.
testObj
,
...
result
})
this
.
applySubProgress
(
sp
,
this
.
testObj
)
this
.
syncViewStepFromServerProgress
()
}
}
})
})
.
catch
((
err
)
=>
{
.
catch
((
err
)
=>
{
console
.
error
(
'[FinancialCalculationDialog] completeTest'
,
err
)
console
.
error
(
'[FinancialCalculationDialog] completeTest'
,
err
)
this
.
$message
.
warning
(
'测试失败,请确认商户、金额、订单分账状态是否正常'
)
})
})
.
finally
(()
=>
{
.
finally
(()
=>
{
this
.
actionLoading
=
false
this
.
actionLoading
=
false
...
...
src/views/systemConfig/merchant/financialRules/index.vue
View file @
587cc7c
...
@@ -216,13 +216,17 @@ import {
...
@@ -216,13 +216,17 @@ import {
collectPendingDeleteForRemovedTab
,
collectPendingDeleteForRemovedTab
,
mapTabMetaAfterTabRemoval
mapTabMetaAfterTabRemoval
}
from
"./utils/applyRemoveTabToGoodsTypeGroupRules"
}
from
"./utils/applyRemoveTabToGoodsTypeGroupRules"
import
{
resolveIndicesForIncrementalSubmit
}
from
"./utils/resolveIndicesForIncrementalSubmit"
import
{
filterFinancialIndicesToSubmitIncremental
,
resolveIndicesForFinancialIncrementalSubmit
}
from
"./utils/financialRulesIncrementalGate"
import
{
buildFullMergedGoodsTypeGroupRules
as
buildFullMergedGoodsTypeGroupRulesUtil
}
from
"./utils/buildFullMergedGoodsTypeGroupRules"
import
{
buildFullMergedGoodsTypeGroupRules
as
buildFullMergedGoodsTypeGroupRulesUtil
}
from
"./utils/buildFullMergedGoodsTypeGroupRules"
import
{
CLASSIFICATION_EMIT
}
from
"./utils/classificationEmitTypes"
import
{
CLASSIFICATION_EMIT
}
from
"./utils/classificationEmitTypes"
import
{
import
{
isDivisionRuleAutoTestPending
,
isDivisionRuleAutoTestPending
,
hasPendingDivisionRuleAutoTest
,
hasPendingDivisionRuleAutoTest
,
findPendingDivisionRuleAutoTestIndices
,
findPendingDivisionRuleAutoTestIndices
,
findDivisionRuleTestByChannelId
,
buildDivisionRuleAutosByChannelId
,
buildDivisionRuleAutosByChannelId
,
shouldShowDivisionTestButton
shouldShowDivisionTestButton
}
from
"./utils/divisionRuleAutoTest"
}
from
"./utils/divisionRuleAutoTest"
...
@@ -319,6 +323,8 @@ export default {
...
@@ -319,6 +323,8 @@ export default {
effectStartDate
:
false
,
// 规则时间 true 表示可以立即生效 是否立即生效
effectStartDate
:
false
,
// 规则时间 true 表示可以立即生效 是否立即生效
/** 本会话删除的已落库分账品类规则快照;提交前并入 goodsTypeGroupRules(type=DELETE),不向接口单独字段传(名历史遗留:兼容仅 push id) */
/** 本会话删除的已落库分账品类规则快照;提交前并入 goodsTypeGroupRules(type=DELETE),不向接口单独字段传(名历史遗留:兼容仅 push id) */
pendingDeletedGroupDivisionRuleIds
:
[],
pendingDeletedGroupDivisionRuleIds
:
[],
/** 进入页时分账品类规则基线,用于增量提交 diff(与 merchantCheck reconciliationRulesBaseline 同语义) */
goodsTypeGroupRulesBaseline
:
null
,
/** 费用类目冲突检测用:与 editableTabs 下标对齐的全量规则视图 */
/** 费用类目冲突检测用:与 editableTabs 下标对齐的全量规则视图 */
_fullMergedGoodsTypeGroupRulesForConflict
:
null
,
_fullMergedGoodsTypeGroupRulesForConflict
:
null
,
/**
/**
...
@@ -646,11 +652,22 @@ export default {
...
@@ -646,11 +652,22 @@ export default {
}
}
if
(
Array
.
isArray
(
divisionRuleTests
)
&&
divisionRuleTests
.
length
>
0
)
{
if
(
Array
.
isArray
(
divisionRuleTests
)
&&
divisionRuleTests
.
length
>
0
)
{
if
(
divisionRuleTests
.
length
===
1
)
{
const
matched
=
findDivisionRuleTestByChannelId
(
this
.
divisionTestChannelConfirm
(
divisionRuleTests
[
0
])
divisionRuleTests
,
item
.
paymentChannelId
)
if
(
matched
)
{
this
.
divisionTestChannelConfirm
({
...
matched
,
paymentChannelName
:
item
.
paymentChannelName
})
}
else
if
(
divisionRuleTests
.
length
===
1
)
{
this
.
divisionTestChannelConfirm
({
...
divisionRuleTests
[
0
],
paymentChannelName
:
item
.
paymentChannelName
})
}
else
{
}
else
{
this
.
channelSelectDialogVisible
=
true
this
.
openDivisionTestDialogForChannel
(
item
,
result
)
this
.
divisionRuleTests
=
divisionRuleTests
}
}
return
return
}
}
...
@@ -659,18 +676,21 @@ export default {
...
@@ -659,18 +676,21 @@ export default {
const
shouldOpenDialog
=
const
shouldOpenDialog
=
isDivisionTestInProgress
(
sp
)
||
isDivisionRuleAutoTestPending
(
item
)
isDivisionTestInProgress
(
sp
)
||
isDivisionRuleAutoTestPending
(
item
)
if
(
shouldOpenDialog
)
{
if
(
shouldOpenDialog
)
{
this
.
financialCalculationVisible
=
true
this
.
openDivisionTestDialogForChannel
(
item
,
result
)
this
.
financialCalculationObj
=
normalizeDivisionTestPayload
({
divisionRuleId
:
this
.
financialRulesEnv
.
divisionRuleId
,
paymentChannelId
:
item
.
paymentChannelId
,
paymentChannelName
:
item
.
paymentChannelName
,
...
result
})
}
}
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
"[FinancialRules] getDivisionTestProgress"
,
err
)
console
.
error
(
"[FinancialRules] getDivisionTestProgress"
,
err
)
})
})
},
},
openDivisionTestDialogForChannel
(
item
,
result
)
{
this
.
financialCalculationVisible
=
true
this
.
financialCalculationObj
=
normalizeDivisionTestPayload
({
divisionRuleId
:
this
.
financialRulesEnv
.
divisionRuleId
,
paymentChannelId
:
item
.
paymentChannelId
,
paymentChannelName
:
item
.
paymentChannelName
,
...
result
})
},
divisionTestChannelConfirm
(
result
)
{
divisionTestChannelConfirm
(
result
)
{
const
paymentChannelId
=
result
.
paymentChannelId
const
paymentChannelId
=
result
.
paymentChannelId
||
(
result
.
divisionRuleTestItem
&&
result
.
divisionRuleTestItem
.
paymentChannelId
)
||
(
result
.
divisionRuleTestItem
&&
result
.
divisionRuleTestItem
.
paymentChannelId
)
...
@@ -1212,6 +1232,14 @@ export default {
...
@@ -1212,6 +1232,14 @@ export default {
}
}
this
.
rebuildCrossTabGoodsSelectionsFromRules
()
this
.
rebuildCrossTabGoodsSelectionsFromRules
()
this
.
pendingDeletedGroupDivisionRuleIds
=
[]
this
.
pendingDeletedGroupDivisionRuleIds
=
[]
this
.
goodsTypeGroupRulesBaseline
=
deepClone
(
this
.
financialObj
.
goodsTypeGroupRules
||
[]
)
this
.
editableTabs
.
forEach
((
tab
)
=>
{
if
(
!
tab
||
String
(
tab
.
name
)
===
"add"
)
return
this
.
$set
(
tab
,
"classificationUserTouched"
,
false
)
this
.
$set
(
tab
,
"sessionAdded"
,
false
)
})
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
if
(
if
(
this
.
$refs
.
divisionRuleRef
this
.
$refs
.
divisionRuleRef
...
@@ -1590,7 +1618,11 @@ export default {
...
@@ -1590,7 +1618,11 @@ export default {
}
}
}
else
{
}
else
{
indicesForIncremental
.
push
(
indicesForIncremental
.
push
(
...
resolveIndicesForIncrementalSubmit
(
this
.
editableTabs
)
...
resolveIndicesForFinancialIncrementalSubmit
(
this
.
editableTabs
,
this
.
goodsTypeGroupRulesBaseline
,
this
.
financialObj
.
goodsTypeGroupRules
)
)
)
}
}
...
@@ -1709,9 +1741,17 @@ export default {
...
@@ -1709,9 +1741,17 @@ export default {
}
}
}
}
const
indicesToSubmit
=
onlyActiveTab
?
indicesForIncremental
:
filterFinancialIndicesToSubmitIncremental
(
indicesForIncremental
,
validatedByIndex
,
this
.
goodsTypeGroupRulesBaseline
,
this
.
editableTabs
)
const
incrementalRules
=
buildGoodsTypeGroupIncrementalRules
(
const
incrementalRules
=
buildGoodsTypeGroupIncrementalRules
(
validatedByIndex
,
validatedByIndex
,
indices
ForIncremental
,
indices
ToSubmit
,
onlyActiveTab
onlyActiveTab
)
)
...
...
src/views/systemConfig/merchant/financialRules/utils/divisionRuleAutoTest.js
View file @
587cc7c
...
@@ -42,3 +42,15 @@ export function findPendingDivisionRuleAutoTestIndices(divisionRuleAutos) {
...
@@ -42,3 +42,15 @@ export function findPendingDivisionRuleAutoTestIndices(divisionRuleAutos) {
.
map
((
item
,
index
)
=>
(
isDivisionRuleAutoTestPending
(
item
)
?
index
:
-
1
))
.
map
((
item
,
index
)
=>
(
isDivisionRuleAutoTestPending
(
item
)
?
index
:
-
1
))
.
filter
((
i
)
=>
i
>=
0
)
.
filter
((
i
)
=>
i
>=
0
)
}
}
/** 从 divisionRuleTest.get 的 divisionRuleTests 中匹配当前渠道 */
export
function
findDivisionRuleTestByChannelId
(
divisionRuleTests
,
paymentChannelId
)
{
if
(
!
Array
.
isArray
(
divisionRuleTests
)
||
paymentChannelId
==
null
)
return
null
return
(
divisionRuleTests
.
find
(
(
t
)
=>
t
?.
paymentChannelId
==
paymentChannelId
||
t
?.
divisionRuleTestItem
?.
paymentChannelId
==
paymentChannelId
)
||
null
)
}
src/views/systemConfig/merchant/financialRules/utils/divisionTestStepProgress.js
View file @
587cc7c
...
@@ -11,19 +11,25 @@ export function isDivisionTestPassed(subProgress) {
...
@@ -11,19 +11,25 @@ export function isDivisionTestPassed(subProgress) {
return
sp
>
0
&&
!
isDivisionTestInProgress
(
sp
)
return
sp
>
0
&&
!
isDivisionTestInProgress
(
sp
)
}
}
function
hasOutTradeNo
(
payload
=
{})
{
const
v
=
payload
.
outTradeNo
return
v
!=
null
&&
v
!==
''
}
function
isOrderPaidFromPayload
(
payload
,
sp
)
{
function
isOrderPaidFromPayload
(
payload
,
sp
)
{
if
(
payload
.
orderPaid
===
true
)
return
true
if
(
payload
.
orderPaid
===
true
)
return
true
if
(
payload
.
paymentSuccess
===
true
)
return
true
if
(
payload
.
paymentSuccess
===
true
)
return
true
if
(
payload
.
payStatus
===
1
||
payload
.
payStatus
===
'1'
||
payload
.
payStatus
===
'Y'
)
{
if
(
payload
.
payStatus
===
1
||
payload
.
payStatus
===
'1'
||
payload
.
payStatus
===
'Y'
)
{
return
true
return
true
}
}
if
(
sp
===
31
&&
hasOutTradeNo
(
payload
))
return
true
return
sp
>=
35
return
sp
>=
35
}
}
/**
/**
* 仅从 subProgress / 支付状态解析业务态,不映射展示步骤
* 仅从 subProgress / 支付状态解析业务态,不映射展示步骤
* @param {number|string} subProgress
* @param {number|string} subProgress
* @param {{ orderPaid?: boolean, payStatus?: *, paymentSuccess?: boolean }} [payload]
* @param {{ orderPaid?: boolean, payStatus?: *, paymentSuccess?: boolean
, outTradeNo?: string
}} [payload]
*/
*/
export
function
mapSubProgressToUi
(
subProgress
,
payload
=
{})
{
export
function
mapSubProgressToUi
(
subProgress
,
payload
=
{})
{
const
sp
=
Number
(
subProgress
)
const
sp
=
Number
(
subProgress
)
...
@@ -36,13 +42,13 @@ export function mapSubProgressToUi(subProgress, payload = {}) {
...
@@ -36,13 +42,13 @@ export function mapSubProgressToUi(subProgress, payload = {}) {
}
}
}
}
/** 步骤条完成态:[0]=步骤1已付款 [1]=步骤2已
提交 [2]=失败标记
*/
/** 步骤条完成态:[0]=步骤1已付款 [1]=步骤2已
到达 [2]=步骤3失败标记(仅 max>=3 时)
*/
export
function
buildStepCompletedFlags
(
step1Paid
,
maxReachedStep
,
isFailed
=
false
)
{
export
function
buildStepCompletedFlags
(
step1Paid
,
maxReachedStep
,
isFailed
=
false
)
{
const
max
=
Number
(
maxReachedStep
)
||
1
const
max
=
Number
(
maxReachedStep
)
||
1
return
[
return
[
!!
step1Paid
,
!!
step1Paid
,
max
>=
3
,
max
>=
2
,
!!
isFailed
!!
isFailed
&&
max
>=
3
]
]
}
}
...
@@ -71,17 +77,20 @@ export function isStepReadOnly(viewStep, uiState) {
...
@@ -71,17 +77,20 @@ export function isStepReadOnly(viewStep, uiState) {
/**
/**
* subProgress 决定可达的最大步骤
* subProgress 决定可达的最大步骤
* @param {number|string} subProgress
* @param {number|string} subProgress
* @param {number|string} [progress] 服务端主步骤 1/2/3
* @returns {number} 1 | 2 | 3
* @returns {number} 1 | 2 | 3
*/
*/
export
function
resolveMaxReachedStepFromSubProgress
(
subProgress
)
{
export
function
resolveMaxReachedStepFromSubProgress
(
subProgress
,
progress
)
{
const
sp
=
Number
(
subProgress
)
||
0
const
sp
=
Number
(
subProgress
)
||
0
const
mp
=
Number
(
progress
)
||
0
if
(
sp
===
36
)
return
3
if
(
sp
===
36
)
return
3
if
(
sp
>=
35
)
return
2
if
(
sp
>=
35
)
return
2
if
(
sp
===
31
&&
mp
>=
1
&&
mp
<=
3
)
return
mp
return
1
return
1
}
}
/**
/**
* 打开弹窗时决定初始展示步骤:优先 progress(
为 3 则展示步骤
3),无 progress 时回退 subProgress
* 打开弹窗时决定初始展示步骤:优先 progress(
1/2/
3),无 progress 时回退 subProgress
* @param {number|string} subProgress
* @param {number|string} subProgress
* @param {number|string} [progress] 服务端主步骤 1/2/3
* @param {number|string} [progress] 服务端主步骤 1/2/3
* @returns {{ viewStep: number, maxReachedStep: number }}
* @returns {{ viewStep: number, maxReachedStep: number }}
...
@@ -89,7 +98,7 @@ export function resolveMaxReachedStepFromSubProgress(subProgress) {
...
@@ -89,7 +98,7 @@ export function resolveMaxReachedStepFromSubProgress(subProgress) {
export
function
resolveInitialWizardSteps
(
subProgress
,
progress
)
{
export
function
resolveInitialWizardSteps
(
subProgress
,
progress
)
{
const
sp
=
Number
(
subProgress
)
||
0
const
sp
=
Number
(
subProgress
)
||
0
const
mp
=
Number
(
progress
)
||
0
const
mp
=
Number
(
progress
)
||
0
let
maxReachedStep
=
resolveMaxReachedStepFromSubProgress
(
sp
)
let
maxReachedStep
=
resolveMaxReachedStepFromSubProgress
(
sp
,
mp
)
if
(
mp
>=
1
&&
mp
<=
3
)
{
if
(
mp
>=
1
&&
mp
<=
3
)
{
maxReachedStep
=
Math
.
max
(
maxReachedStep
,
mp
)
maxReachedStep
=
Math
.
max
(
maxReachedStep
,
mp
)
...
@@ -100,5 +109,38 @@ export function resolveInitialWizardSteps(subProgress, progress) {
...
@@ -100,5 +109,38 @@ export function resolveInitialWizardSteps(subProgress, progress) {
return
{
viewStep
:
3
,
maxReachedStep
:
3
}
return
{
viewStep
:
3
,
maxReachedStep
:
3
}
}
}
if
(
sp
===
31
&&
maxReachedStep
>
1
)
{
return
{
viewStep
:
maxReachedStep
,
maxReachedStep
}
}
return
{
viewStep
:
1
,
maxReachedStep
}
return
{
viewStep
:
1
,
maxReachedStep
}
}
}
export
function
isDivisionTestFailed
(
subProgress
)
{
return
Number
(
subProgress
)
===
31
}
/**
* subProgress=31/36 等需按服务端 progress 恢复展示步骤
*/
export
function
shouldSyncWizardStepsFromProgress
(
subProgress
)
{
const
sp
=
Number
(
subProgress
)
return
sp
===
31
||
sp
===
36
}
/**
* 步骤1是否展示「关联测试订单」(而非二维码)
* @param {{ step1Paid?: boolean, subProgress?: number|string, outTradeNo?: string, maxReachedStep?: number, viewStep?: number }} params
*/
export
function
shouldShowStep1OrderLinked
({
step1Paid
=
false
,
subProgress
=
0
,
outTradeNo
=
''
,
maxReachedStep
=
1
,
viewStep
=
1
}
=
{})
{
if
(
step1Paid
)
return
true
if
(
Number
(
subProgress
)
===
31
&&
outTradeNo
)
return
true
if
(
Number
(
maxReachedStep
)
>
1
&&
Number
(
viewStep
)
===
1
)
return
true
return
false
}
src/views/systemConfig/merchant/financialRules/utils/financialRulesIncrementalGate.js
0 → 100644
View file @
587cc7c
import
{
getStableReconciliationRuleId
}
from
"../../merchantStep/utils/reconciliationIncrementalRules"
import
{
shouldIncludeReconciliationTabForProcess
}
from
"../../merchantStep/utils/reconciliationSubmitTabGate"
import
{
reconciliationRulePayloadIsSubstantive
}
from
"../../merchantStep/utils/validateReconciliationRulePayload"
import
{
financialRulePayloadDeepEqual
}
from
"./rulePayloadCanonicalCompare"
import
{
prepareRuleForValidation
}
from
"./validateGoodsTypeGroupRulePayload"
/**
* @param {Array<object>|null|undefined} baseline
* @param {number} ti
* @returns {boolean}
*/
export
function
financialBaselineHasSlotForTabIndex
(
baseline
,
ti
)
{
const
prevRaw
=
Array
.
isArray
(
baseline
)
?
baseline
[
ti
]
:
null
return
!!
(
prevRaw
&&
typeof
prevRaw
===
"object"
)
}
/**
* @param {object|null|undefined} baselineRule
* @param {object|null|undefined} currentRule
* @returns {boolean}
*/
export
function
financialRulePayloadEqualsNormalized
(
baselineRule
,
currentRule
)
{
if
(
!
baselineRule
||
typeof
baselineRule
!==
"object"
)
{
if
(
!
currentRule
||
typeof
currentRule
!==
"object"
)
return
true
return
!
reconciliationRulePayloadIsSubstantive
(
currentRule
)
}
if
(
!
currentRule
||
typeof
currentRule
!==
"object"
)
return
true
const
curNorm
=
prepareRuleForValidation
(
currentRule
)
const
prevNorm
=
prepareRuleForValidation
(
baselineRule
)
return
financialRulePayloadDeepEqual
(
curNorm
,
prevNorm
)
}
/**
* 当前 Tab 槽位规则是否与进入页时的基线不一致。
*
* @param {Array<object>|null|undefined} baseline
* @param {number} ti
* @param {object|null|undefined} currentRule
* @returns {boolean}
*/
export
function
financialTabDiffersFromBaseline
(
baseline
,
ti
,
currentRule
)
{
if
(
!
Array
.
isArray
(
baseline
))
return
false
const
prevRaw
=
baseline
[
ti
]
if
(
!
prevRaw
)
{
if
(
!
currentRule
)
return
false
return
reconciliationRulePayloadIsSubstantive
(
currentRule
)
}
return
!
financialRulePayloadEqualsNormalized
(
prevRaw
,
currentRule
)
}
/**
* 校验通过后的单条规则快照是否与进入页基线一致(用于收缩 goodsTypeGroupRules 增量)。
*
* @param {Array<object>|null|undefined} baseline
* @param {number} ti
* @param {object|null|undefined} snapshot
* @returns {boolean}
*/
export
function
financialSnapshotEqualsBaseline
(
baseline
,
ti
,
snapshot
)
{
if
(
!
Array
.
isArray
(
baseline
)
||
!
snapshot
||
typeof
snapshot
!==
"object"
)
{
return
false
}
const
prevRaw
=
baseline
[
ti
]
if
(
!
prevRaw
)
{
if
(
!
reconciliationRulePayloadIsSubstantive
(
snapshot
))
return
true
return
false
}
return
financialRulePayloadEqualsNormalized
(
prevRaw
,
snapshot
)
}
/**
* 全量保存:与 merchantCheck indicesToProcess 同款语义。
* 仅 touched/sessionAdded 且与基线 diff(或无基线槽位)的 Tab 进入增量候选。
*
* @param {Array<object>} editableTabs
* @param {Array<object>|null|undefined} baseline
* @param {Array<object>|null|undefined} slotCaches financialObj.goodsTypeGroupRules
* @returns {number[]}
*/
export
function
resolveIndicesForFinancialIncrementalSubmit
(
editableTabs
,
baseline
,
slotCaches
)
{
const
indices
=
[]
const
tabs
=
editableTabs
||
[]
const
caches
=
slotCaches
||
[]
for
(
let
i
=
0
;
i
<
tabs
.
length
;
i
++
)
{
const
tab
=
tabs
[
i
]
if
(
!
tab
||
String
(
tab
.
name
)
===
"add"
)
continue
const
differs
=
financialTabDiffersFromBaseline
(
baseline
,
i
,
caches
[
i
])
const
isSessionAdded
=
tab
.
sessionAdded
===
true
if
(
!
differs
&&
!
isSessionAdded
)
continue
if
(
differs
)
{
if
(
!
shouldIncludeReconciliationTabForProcess
({
hasBaselineSlot
:
financialBaselineHasSlotForTabIndex
(
baseline
,
i
),
classificationUserTouched
:
tab
.
classificationUserTouched
===
true
,
sessionAdded
:
isSessionAdded
})
)
{
continue
}
}
indices
.
push
(
i
)
}
return
indices
}
/**
* 校验通过的 Tab 中,仅「快照与基线仍不一致」的进入提交(无基线时仅 sessionAdded 且 substantive)。
*
* @param {number[]} dirtyIndices
* @param {Record<number, object>} validatedByIndex
* @param {Array<object>|null|undefined} baseline
* @param {Array<object>} editableTabs
* @returns {number[]}
*/
export
function
filterFinancialIndicesToSubmitIncremental
(
dirtyIndices
,
validatedByIndex
,
baseline
,
editableTabs
)
{
const
tabs
=
editableTabs
||
[]
return
(
dirtyIndices
||
[]).
filter
((
ti
)
=>
{
const
rule
=
validatedByIndex
[
ti
]
if
(
!
rule
||
typeof
rule
!==
"object"
)
return
false
if
(
!
Array
.
isArray
(
baseline
))
{
return
(
tabs
[
ti
]?.
sessionAdded
===
true
&&
reconciliationRulePayloadIsSubstantive
(
rule
)
)
}
return
!
financialSnapshotEqualsBaseline
(
baseline
,
ti
,
rule
)
})
}
src/views/systemConfig/merchant/financialRules/utils/resolveDivisionTestOrderCode.js
View file @
587cc7c
...
@@ -33,6 +33,30 @@ export function resolveDivisionTestOrderCode(payload = {}) {
...
@@ -33,6 +33,30 @@ export function resolveDivisionTestOrderCode(payload = {}) {
}
}
/**
/**
* 分账测试支付流水号:优先取 divisionRuleTests 项下 divisionRuleTestItem.outTradeNo
*/
export
function
resolveDivisionTestOutTradeNo
(
payload
=
{})
{
if
(
!
payload
||
typeof
payload
!==
'object'
)
return
''
const
entry
=
findDivisionRuleTestChannelEntry
(
payload
)
const
fromList
=
entry
?.
divisionRuleTestItem
?.
outTradeNo
if
(
fromList
!=
null
&&
fromList
!==
''
)
{
return
String
(
fromList
)
}
const
fromItem
=
payload
.
divisionRuleTestItem
?.
outTradeNo
if
(
fromItem
!=
null
&&
fromItem
!==
''
)
{
return
String
(
fromItem
)
}
if
(
payload
.
outTradeNo
!=
null
&&
payload
.
outTradeNo
!==
''
)
{
return
String
(
payload
.
outTradeNo
)
}
return
''
}
/**
* 分账测试进度:优先取 divisionRuleTests 项下 divisionRuleTestItem.subProgress
* 分账测试进度:优先取 divisionRuleTests 项下 divisionRuleTestItem.subProgress
*/
*/
export
function
resolveDivisionTestSubProgress
(
payload
=
{},
fallback
)
{
export
function
resolveDivisionTestSubProgress
(
payload
=
{},
fallback
)
{
...
@@ -140,15 +164,17 @@ export function resolveDivisionTestMerchantDivisions(payload = {}) {
...
@@ -140,15 +164,17 @@ export function resolveDivisionTestMerchantDivisions(payload = {}) {
return
[]
return
[]
}
}
/** 合并接口数据并写入规范化 orderCode、subProgress、testMerchantDivisions */
/** 合并接口数据并写入规范化 orderCode、
outTradeNo、
subProgress、testMerchantDivisions */
export
function
normalizeDivisionTestPayload
(
payload
=
{})
{
export
function
normalizeDivisionTestPayload
(
payload
=
{})
{
const
orderCode
=
resolveDivisionTestOrderCode
(
payload
)
const
orderCode
=
resolveDivisionTestOrderCode
(
payload
)
const
outTradeNo
=
resolveDivisionTestOutTradeNo
(
payload
)
const
subProgress
=
resolveDivisionTestSubProgress
(
payload
,
payload
.
subProgress
)
const
subProgress
=
resolveDivisionTestSubProgress
(
payload
,
payload
.
subProgress
)
const
progress
=
resolveDivisionTestProgress
(
payload
,
payload
.
progress
)
const
progress
=
resolveDivisionTestProgress
(
payload
,
payload
.
progress
)
const
testMerchantDivisions
=
resolveDivisionTestMerchantDivisions
(
payload
)
const
testMerchantDivisions
=
resolveDivisionTestMerchantDivisions
(
payload
)
return
{
return
{
...
payload
,
...
payload
,
orderCode
,
orderCode
,
outTradeNo
,
subProgress
,
subProgress
,
progress
,
progress
,
testMerchantDivisions
testMerchantDivisions
...
...
tests/unit/financialRules/divisionRuleAutoTest.spec.js
View file @
587cc7c
...
@@ -2,6 +2,7 @@ import {
...
@@ -2,6 +2,7 @@ import {
isDivisionRuleAutoTestPending
,
isDivisionRuleAutoTestPending
,
hasPendingDivisionRuleAutoTest
,
hasPendingDivisionRuleAutoTest
,
findPendingDivisionRuleAutoTestIndices
,
findPendingDivisionRuleAutoTestIndices
,
findDivisionRuleTestByChannelId
,
buildDivisionRuleAutosByChannelId
,
buildDivisionRuleAutosByChannelId
,
shouldShowDivisionTestButton
shouldShowDivisionTestButton
}
from
"@/views/systemConfig/merchant/financialRules/utils/divisionRuleAutoTest"
}
from
"@/views/systemConfig/merchant/financialRules/utils/divisionRuleAutoTest"
...
@@ -40,6 +41,18 @@ describe("divisionRuleAutoTest", () => {
...
@@ -40,6 +41,18 @@ describe("divisionRuleAutoTest", () => {
expect
(
findPendingDivisionRuleAutoTestIndices
(
list
)).
toEqual
([
1
])
expect
(
findPendingDivisionRuleAutoTestIndices
(
list
)).
toEqual
([
1
])
})
})
it
(
"findDivisionRuleTestByChannelId matches paymentChannelId"
,
()
=>
{
const
tests
=
[
{
paymentChannelId
:
"ch1"
,
divisionRuleTestItem
:
{
orderCode
:
"A"
}
},
{
paymentChannelId
:
"ch2"
,
divisionRuleTestItem
:
{
paymentChannelId
:
"ch2"
,
orderCode
:
"B"
}
}
]
expect
(
findDivisionRuleTestByChannelId
(
tests
,
"ch2"
).
divisionRuleTestItem
.
orderCode
).
toBe
(
"B"
)
expect
(
findDivisionRuleTestByChannelId
(
tests
,
"ch9"
)).
toBe
(
null
)
})
it
(
"buildDivisionRuleAutosByChannelId"
,
()
=>
{
it
(
"buildDivisionRuleAutosByChannelId"
,
()
=>
{
const
map
=
buildDivisionRuleAutosByChannelId
([
const
map
=
buildDivisionRuleAutosByChannelId
([
{
paymentChannelId
:
1
,
autoFlag
:
"Y"
,
testFlag
:
"N"
},
{
paymentChannelId
:
1
,
autoFlag
:
"Y"
,
testFlag
:
"N"
},
...
...
tests/unit/financialRules/divisionTestStepProgress.spec.js
View file @
587cc7c
...
@@ -6,7 +6,10 @@ import {
...
@@ -6,7 +6,10 @@ import {
isStepReadOnly
,
isStepReadOnly
,
buildStepCompletedFlags
,
buildStepCompletedFlags
,
resolveMaxReachedStepFromSubProgress
,
resolveMaxReachedStepFromSubProgress
,
resolveInitialWizardSteps
resolveInitialWizardSteps
,
shouldShowStep1OrderLinked
,
isDivisionTestFailed
,
shouldSyncWizardStepsFromProgress
}
from
"@/views/systemConfig/merchant/financialRules/utils/divisionTestStepProgress"
}
from
"@/views/systemConfig/merchant/financialRules/utils/divisionTestStepProgress"
describe
(
"divisionTestStepProgress"
,
()
=>
{
describe
(
"divisionTestStepProgress"
,
()
=>
{
...
@@ -35,6 +38,53 @@ describe("divisionTestStepProgress", () => {
...
@@ -35,6 +38,53 @@ describe("divisionTestStepProgress", () => {
expect
(
ui
.
currentStep
).
toBeUndefined
()
expect
(
ui
.
currentStep
).
toBeUndefined
()
})
})
it
(
"mapSubProgressToUi: 31 with outTradeNo treated as paid"
,
()
=>
{
const
ui
=
mapSubProgressToUi
(
31
,
{
outTradeNo
:
"OUT001"
})
expect
(
ui
.
step1Paid
).
toBe
(
true
)
expect
(
ui
.
isFailed
).
toBe
(
true
)
})
it
(
"mapSubProgressToUi: 31 without outTradeNo unpaid failed"
,
()
=>
{
const
ui
=
mapSubProgressToUi
(
31
,
{})
expect
(
ui
.
step1Paid
).
toBe
(
false
)
expect
(
ui
.
isFailed
).
toBe
(
true
)
})
it
(
"shouldShowStep1OrderLinked: 31 with outTradeNo"
,
()
=>
{
expect
(
shouldShowStep1OrderLinked
({
subProgress
:
31
,
outTradeNo
:
"OUT001"
})
).
toBe
(
true
)
})
it
(
"shouldShowStep1OrderLinked: maxReachedStep>1 back to step1"
,
()
=>
{
expect
(
shouldShowStep1OrderLinked
({
step1Paid
:
false
,
maxReachedStep
:
3
,
viewStep
:
1
})
).
toBe
(
true
)
})
it
(
"shouldShowStep1OrderLinked: 34 unpaid on step1"
,
()
=>
{
expect
(
shouldShowStep1OrderLinked
({
step1Paid
:
false
,
subProgress
:
34
,
maxReachedStep
:
1
,
viewStep
:
1
})
).
toBe
(
false
)
})
it
(
"isDivisionTestFailed"
,
()
=>
{
expect
(
isDivisionTestFailed
(
31
)).
toBe
(
true
)
expect
(
isDivisionTestFailed
(
34
)).
toBe
(
false
)
})
it
(
"canNavigateToStep uses maxReachedStep only"
,
()
=>
{
it
(
"canNavigateToStep uses maxReachedStep only"
,
()
=>
{
expect
(
canNavigateToStep
(
2
,
{
maxReachedStep
:
1
,
step1Paid
:
true
})).
toBe
(
false
)
expect
(
canNavigateToStep
(
2
,
{
maxReachedStep
:
1
,
step1Paid
:
true
})).
toBe
(
false
)
expect
(
canNavigateToStep
(
2
,
{
maxReachedStep
:
2
})).
toBe
(
true
)
expect
(
canNavigateToStep
(
2
,
{
maxReachedStep
:
2
})).
toBe
(
true
)
...
@@ -47,14 +97,31 @@ describe("divisionTestStepProgress", () => {
...
@@ -47,14 +97,31 @@ describe("divisionTestStepProgress", () => {
})
})
it
(
"buildStepCompletedFlags"
,
()
=>
{
it
(
"buildStepCompletedFlags"
,
()
=>
{
expect
(
buildStepCompletedFlags
(
true
,
2
)).
toEqual
([
true
,
fals
e
,
false
])
expect
(
buildStepCompletedFlags
(
true
,
2
)).
toEqual
([
true
,
tru
e
,
false
])
expect
(
buildStepCompletedFlags
(
true
,
3
)).
toEqual
([
true
,
true
,
false
])
expect
(
buildStepCompletedFlags
(
true
,
3
)).
toEqual
([
true
,
true
,
false
])
expect
(
buildStepCompletedFlags
(
true
,
3
,
true
)).
toEqual
([
true
,
true
,
true
])
expect
(
buildStepCompletedFlags
(
true
,
2
,
true
)).
toEqual
([
true
,
true
,
false
])
})
})
it
(
"resolveMaxReachedStepFromSubProgress"
,
()
=>
{
it
(
"resolveMaxReachedStepFromSubProgress"
,
()
=>
{
expect
(
resolveMaxReachedStepFromSubProgress
(
34
)).
toBe
(
1
)
expect
(
resolveMaxReachedStepFromSubProgress
(
34
)).
toBe
(
1
)
expect
(
resolveMaxReachedStepFromSubProgress
(
35
)).
toBe
(
2
)
expect
(
resolveMaxReachedStepFromSubProgress
(
35
)).
toBe
(
2
)
expect
(
resolveMaxReachedStepFromSubProgress
(
36
)).
toBe
(
3
)
expect
(
resolveMaxReachedStepFromSubProgress
(
36
)).
toBe
(
3
)
expect
(
resolveMaxReachedStepFromSubProgress
(
31
,
3
)).
toBe
(
3
)
expect
(
resolveMaxReachedStepFromSubProgress
(
31
,
2
)).
toBe
(
2
)
expect
(
resolveMaxReachedStepFromSubProgress
(
31
,
1
)).
toBe
(
1
)
})
it
(
"resolveInitialWizardSteps: 31 with progress opens matching step"
,
()
=>
{
expect
(
resolveInitialWizardSteps
(
31
,
3
)).
toEqual
({
viewStep
:
3
,
maxReachedStep
:
3
})
expect
(
resolveInitialWizardSteps
(
31
,
2
)).
toEqual
({
viewStep
:
2
,
maxReachedStep
:
2
})
expect
(
resolveInitialWizardSteps
(
31
,
1
)).
toEqual
({
viewStep
:
1
,
maxReachedStep
:
1
})
})
it
(
"shouldSyncWizardStepsFromProgress"
,
()
=>
{
expect
(
shouldSyncWizardStepsFromProgress
(
31
)).
toBe
(
true
)
expect
(
shouldSyncWizardStepsFromProgress
(
36
)).
toBe
(
true
)
expect
(
shouldSyncWizardStepsFromProgress
(
34
)).
toBe
(
false
)
})
})
it
(
"resolveInitialWizardSteps: progress takes priority over subProgress"
,
()
=>
{
it
(
"resolveInitialWizardSteps: progress takes priority over subProgress"
,
()
=>
{
...
...
tests/unit/financialRules/financialRulesIncrementalGate.spec.js
0 → 100644
View file @
587cc7c
/**
* @jest-environment jsdom
*/
import
{
filterFinancialIndicesToSubmitIncremental
,
financialSnapshotEqualsBaseline
,
financialTabDiffersFromBaseline
,
resolveIndicesForFinancialIncrementalSubmit
}
from
"@/views/systemConfig/merchant/financialRules/utils/financialRulesIncrementalGate"
import
{
buildGoodsTypeGroupIncrementalRules
}
from
"@/views/systemConfig/merchant/financialRules/utils/buildGoodsTypeGroupIncrementalRules"
import
{
GOODS_TYPE_GROUP_RULE_OP
}
from
"@/views/systemConfig/merchant/financialRules/utils/goodsTypeGroupRuleOpType"
const
baselineRule
=
{
groupType
:
1
,
groupDivisionRuleId
:
"17805"
,
expenseCategoryRules
:
[
{
expenseCategoryId
:
1
,
expenseCategoryCalculateType
:
1
,
expenseCategoryValue
:
"10"
,
children
:
[]
}
],
merchantDistributionRules
:
[{
merchantId
:
1
,
merchantName
:
"平台"
}],
owningMerchantDistributionRules
:
[{
merchantId
:
2
,
merchantName
:
"流量"
}]
}
function
makeTabs
(
overrides
=
{})
{
return
[
{
name
:
"1"
,
classificationUserTouched
:
false
,
sessionAdded
:
false
,
...
overrides
}
]
}
describe
(
"resolveIndicesForFinancialIncrementalSubmit"
,
()
=>
{
test
(
"无 touched、无 diff → 空数组"
,
()
=>
{
const
baseline
=
[
baselineRule
]
const
caches
=
[
baselineRule
]
expect
(
resolveIndicesForFinancialIncrementalSubmit
(
makeTabs
(),
baseline
,
caches
)
).
toEqual
([])
})
test
(
"有基线槽位、diff 但无 touched/sessionAdded:不进入(挡无操作假脏)"
,
()
=>
{
const
baseline
=
[
baselineRule
]
const
caches
=
[
{
...
baselineRule
,
expenseCategoryRules
:
[
{
expenseCategoryId
:
1
,
expenseCategoryCalculateType
:
1
,
expenseCategoryValue
:
"20"
,
children
:
[]
}
]
}
]
expect
(
resolveIndicesForFinancialIncrementalSubmit
(
makeTabs
(),
baseline
,
caches
)
).
toEqual
([])
})
test
(
"有 touched 且 diff → 进入"
,
()
=>
{
const
baseline
=
[
baselineRule
]
const
caches
=
[
{
...
baselineRule
,
expenseCategoryRules
:
[
{
expenseCategoryId
:
1
,
expenseCategoryCalculateType
:
1
,
expenseCategoryValue
:
"20"
,
children
:
[]
}
]
}
]
expect
(
resolveIndicesForFinancialIncrementalSubmit
(
makeTabs
({
classificationUserTouched
:
true
}),
baseline
,
caches
)
).
toEqual
([
0
])
})
test
(
"sessionAdded 新 Tab → 进入"
,
()
=>
{
const
baseline
=
[
baselineRule
]
const
caches
=
[
baselineRule
,
{
groupType
:
2
}]
const
tabs
=
[
{
name
:
"1"
,
classificationUserTouched
:
false
,
sessionAdded
:
false
},
{
name
:
"2"
,
classificationUserTouched
:
false
,
sessionAdded
:
true
}
]
expect
(
resolveIndicesForFinancialIncrementalSubmit
(
tabs
,
baseline
,
caches
)
).
toEqual
([
1
])
})
})
describe
(
"filterFinancialIndicesToSubmitIncremental"
,
()
=>
{
test
(
"有 touched 但无 diff → 第一层 gate 即不进入"
,
()
=>
{
const
baseline
=
[
baselineRule
]
expect
(
resolveIndicesForFinancialIncrementalSubmit
(
makeTabs
({
classificationUserTouched
:
true
}),
baseline
,
[
baselineRule
]
)
).
toEqual
([])
})
test
(
"有 touched 但快照 equals baseline → 过滤后为空"
,
()
=>
{
const
baseline
=
[
baselineRule
]
const
validatedByIndex
=
{
0
:
baselineRule
}
const
dirty
=
[
0
]
const
tabs
=
makeTabs
({
classificationUserTouched
:
true
})
expect
(
filterFinancialIndicesToSubmitIncremental
(
dirty
,
validatedByIndex
,
baseline
,
tabs
)
).
toEqual
([])
})
test
(
"有 touched 且快照与基线不同 → 保留"
,
()
=>
{
const
baseline
=
[
baselineRule
]
const
changed
=
{
...
baselineRule
,
expenseCategoryRules
:
[
{
expenseCategoryId
:
1
,
expenseCategoryCalculateType
:
1
,
expenseCategoryValue
:
"99"
,
children
:
[]
}
]
}
const
validatedByIndex
=
{
0
:
changed
}
expect
(
filterFinancialIndicesToSubmitIncremental
(
[
0
],
validatedByIndex
,
baseline
,
makeTabs
({
classificationUserTouched
:
true
})
)
).
toEqual
([
0
])
})
test
(
"端到端:误 touched + 未改规则 → 不产生 UPDATE"
,
()
=>
{
const
baseline
=
[
baselineRule
]
const
validatedByIndex
=
{
0
:
baselineRule
}
const
dirty
=
resolveIndicesForFinancialIncrementalSubmit
(
makeTabs
({
classificationUserTouched
:
true
}),
baseline
,
[
baselineRule
]
)
expect
(
dirty
).
toEqual
([])
const
indicesToSubmit
=
filterFinancialIndicesToSubmitIncremental
(
dirty
,
validatedByIndex
,
baseline
,
makeTabs
({
classificationUserTouched
:
true
})
)
expect
(
indicesToSubmit
).
toEqual
([])
const
incremental
=
buildGoodsTypeGroupIncrementalRules
(
validatedByIndex
,
indicesToSubmit
,
false
)
expect
(
incremental
).
toEqual
([])
})
test
(
"真实修改 → filter 后仍生成 UPDATE"
,
()
=>
{
const
baseline
=
[
baselineRule
]
const
changed
=
{
...
baselineRule
,
expenseCategoryRules
:
[
{
expenseCategoryId
:
1
,
expenseCategoryCalculateType
:
1
,
expenseCategoryValue
:
"50"
,
children
:
[]
}
]
}
const
validatedByIndex
=
{
0
:
changed
}
const
dirty
=
resolveIndicesForFinancialIncrementalSubmit
(
makeTabs
({
classificationUserTouched
:
true
}),
baseline
,
[
changed
]
)
const
indicesToSubmit
=
filterFinancialIndicesToSubmitIncremental
(
dirty
,
validatedByIndex
,
baseline
,
makeTabs
({
classificationUserTouched
:
true
})
)
const
incremental
=
buildGoodsTypeGroupIncrementalRules
(
validatedByIndex
,
indicesToSubmit
,
false
)
expect
(
incremental
).
toHaveLength
(
1
)
expect
(
incremental
[
0
].
type
).
toBe
(
GOODS_TYPE_GROUP_RULE_OP
.
UPDATE
)
})
})
describe
(
"financialTabDiffersFromBaseline / financialSnapshotEqualsBaseline"
,
()
=>
{
test
(
"相同规则:diff false,snapshot equals true"
,
()
=>
{
const
baseline
=
[
baselineRule
]
expect
(
financialTabDiffersFromBaseline
(
baseline
,
0
,
baselineRule
)).
toBe
(
false
)
expect
(
financialSnapshotEqualsBaseline
(
baseline
,
0
,
baselineRule
)).
toBe
(
true
)
})
})
tests/unit/financialRules/resolveDivisionTestOrderCode.spec.js
View file @
587cc7c
import
{
import
{
resolveDivisionTestOrderCode
,
resolveDivisionTestOrderCode
,
resolveDivisionTestOutTradeNo
,
resolveDivisionTestSubProgress
,
resolveDivisionTestSubProgress
,
resolveDivisionTestMerchantDivisions
,
resolveDivisionTestMerchantDivisions
,
resolveGoodsTypeGroupDivisionId
,
resolveGoodsTypeGroupDivisionId
,
...
@@ -33,6 +34,37 @@ describe("resolveDivisionTestOrderCode", () => {
...
@@ -33,6 +34,37 @@ describe("resolveDivisionTestOrderCode", () => {
).
toBe
(
"ORD003"
)
).
toBe
(
"ORD003"
)
})
})
it
(
"reads outTradeNo from divisionRuleTests[].divisionRuleTestItem"
,
()
=>
{
expect
(
resolveDivisionTestOutTradeNo
({
paymentChannelId
:
"ch2"
,
divisionRuleTests
:
[
{
paymentChannelId
:
"ch1"
,
divisionRuleTestItem
:
{
outTradeNo
:
"OUT001"
}
},
{
paymentChannelId
:
"ch2"
,
divisionRuleTestItem
:
{
outTradeNo
:
"OUT002"
}
}
]
})
).
toBe
(
"OUT002"
)
})
it
(
"normalizeDivisionTestPayload sets outTradeNo on root"
,
()
=>
{
const
payload
=
normalizeDivisionTestPayload
({
paymentChannelId
:
"ch1"
,
divisionRuleTests
:
[
{
paymentChannelId
:
"ch1"
,
divisionRuleTestItem
:
{
outTradeNo
:
"OUT003"
}
}
]
})
expect
(
payload
.
outTradeNo
).
toBe
(
"OUT003"
)
})
it
(
"normalizeDivisionTestPayload sets orderCode on root"
,
()
=>
{
it
(
"normalizeDivisionTestPayload sets orderCode on root"
,
()
=>
{
const
payload
=
normalizeDivisionTestPayload
({
const
payload
=
normalizeDivisionTestPayload
({
divisionRuleTests
:
[
divisionRuleTests
:
[
...
...
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