Commit 587cc7c0 by 张立顺

fix 分账测试bug

1 parent 347a500d
...@@ -12,8 +12,7 @@ ...@@ -12,8 +12,7 @@
'margin-bottom': isEdit ? '24px' : '', 'margin-bottom': isEdit ? '24px' : '',
'margin-right': isEdit ? '0px' : '30px', 'margin-right': isEdit ? '0px' : '30px',
...item.style, ...item.style,
}" :label="item.label" :prop="item.name" :rules="item.rules" }" :label="item.label" :prop="item.name" :rules="item.rules" :required="!!item.labelRequired">
:required="!!item.labelRequired">
<template #label> <template #label>
<span v-if="!getItemIsHide(item) && item.tips" class="tips-block"> <span v-if="!getItemIsHide(item) && item.tips" class="tips-block">
<span class="tips-label">{{ item.label }}</span> <span class="tips-label">{{ item.label }}</span>
...@@ -49,27 +48,24 @@ ...@@ -49,27 +48,24 @@
:disabled="getItemIsDisabled(item)" :maxlength="item.maxlength" :clearable="item.isClear || false" :disabled="getItemIsDisabled(item)" :maxlength="item.maxlength" :clearable="item.isClear || false"
:type="passwordInputType(item)" :autosize="item.inputType == 'textarea' && !item.rows" :type="passwordInputType(item)" :autosize="item.inputType == 'textarea' && !item.rows"
:rows="item.rows || 2" :style="{ width: item.width || defaultWidth }" :rows="item.rows || 2" :style="{ width: item.width || defaultWidth }"
:show-word-limit="item.showLimit || false" :show-word-limit="item.showLimit || false" v-on="item.listeners ? item.listeners : {}"
v-on="item.listeners ? item.listeners : {}" @keydown.native="(e) => handleInputDown(e, item)" @keydown.native="(e) => handleInputDown(e, item)" @input="(e) => maxLengthInput(e, item)">
@input="(e) => maxLengthInput(e, item)">
<template #prepend> <template #prepend>
<span v-if="item.prepend">{{ item.prepend }}</span> <span v-if="item.prepend">{{ item.prepend }}</span>
</template> </template>
<template #suffix> <template #suffix>
<span v-if="item.append">{{ item.append }}</span> <span v-if="item.append">{{ item.append }}</span>
<span v-if="item.showPass" class="gl-password-toggle" role="button" tabindex="-1" <span v-if="item.showPass" class="gl-password-toggle" role="button" tabindex="-1"
:title="passwordPlain[item.name] ? '隐藏密码' : '显示密码'" :title="passwordPlain[item.name] ? '隐藏密码' : '显示密码'" @click.stop="togglePasswordPlain(item.name)">
@click.stop="togglePasswordPlain(item.name)"> <svg v-if="passwordPlain[item.name]" class="gl-password-toggle-svg" xmlns="http://www.w3.org/2000/svg"
<svg v-if="passwordPlain[item.name]" class="gl-password-toggle-svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" aria-hidden="true">
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" /> <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" />
<circle cx="12" cy="12" r="3" /> <circle cx="12" cy="12" r="3" />
</svg> </svg>
<svg v-else class="gl-password-toggle-svg" xmlns="http://www.w3.org/2000/svg" width="14" <svg v-else class="gl-password-toggle-svg" xmlns="http://www.w3.org/2000/svg" width="14" height="14"
height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> stroke-linejoin="round" aria-hidden="true">
<path <path
d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" /> d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" />
<line x1="1" y1="1" x2="23" y2="23" /> <line x1="1" y1="1" x2="23" y2="23" />
...@@ -186,8 +182,7 @@ ...@@ -186,8 +182,7 @@
class="activity-img img-w-h" :style="item.uploadStyle && item.uploadStyle.hasOwnProperty('imgWH') class="activity-img img-w-h" :style="item.uploadStyle && item.uploadStyle.hasOwnProperty('imgWH')
? item.uploadStyle.imgWH ? item.uploadStyle.imgWH
: '' : ''
" accept="image/png, image/jpeg, image/gif, image/jpg" " accept="image/png, image/jpeg, image/gif, image/jpg" @change="(e) => handleUploadChange(e, item)" />
@change="(e) => handleUploadChange(e, item)" />
</div> </div>
</div> </div>
<template> <template>
...@@ -326,17 +321,6 @@ ...@@ -326,17 +321,6 @@
</div> </div>
</div> </div>
</el-select> </el-select>
<div v-else-if="item.type === 'map'" class="flex">
<Province ref="provinceForm" :subdistrict="subdistrict" :is-disabled="getItemIsDisabled(item)"
:province-view="item.provinceView" @selectProvince="(e) => handleSelectProvince(e, item)"
@selectCity="(e) => handleSelectCity(e, item)">
</Province>
<el-input v-model="formObj[item.name]" style="flex: 1" placeholder="请选择商户地址" :readonly="item.isReadonly">
</el-input>
<el-button v-show="!getItemIsDisabled(item)" class="m-l-10" type="primary" @click="handleSelectMap(item)">
选择地址
</el-button>
</div>
<div v-if="item.message" class="message-tip"> <div v-if="item.message" class="message-tip">
{{ item.message }} {{ item.message }}
</div> </div>
...@@ -373,14 +357,10 @@ import RemoteSelect from "@/components/remoteSearchSelect/index.vue"; ...@@ -373,14 +357,10 @@ import RemoteSelect from "@/components/remoteSearchSelect/index.vue";
import GLDialog from "../glsx-dialog/index.vue"; import GLDialog from "../glsx-dialog/index.vue";
import { afterRangePickerOptions, beforeRangePickerOptions } from "./common"; import { afterRangePickerOptions, beforeRangePickerOptions } from "./common";
import mapView from "./mapView.vue"; import mapView from "./mapView.vue";
// import textBox from '@/views/material/components/textBox'
import Province from "./provinceCity.vue";
export default { export default {
name: "GlsxCombiForm", name: "GlsxCombiForm",
components: { components: {
// textBox,
Province,
MapView: mapView, MapView: mapView,
GLDialog, GLDialog,
RemoteSelect, RemoteSelect,
......
<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>
...@@ -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.step1Paid" :step1-paid="step1ShowOrderLinked"
: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.step1Paid if (this.viewStep === 1) return !this.step1ShowOrderLinked
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.step1Paid && this.testOrderCode) { if (!this.step1ShowOrderLinked && 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)
}, },
syncViewStepIfSubProgress36() { syncViewStepFromServerProgress() {
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.syncViewStepIfSubProgress36() this.syncViewStepFromServerProgress()
if (!this.uiState.step1Paid && this.testOrderCode) { if (!this.step1ShowOrderLinked && 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.step1Paid) { if (!this.step1ShowOrderLinked) {
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
......
...@@ -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,6 +676,13 @@ export default { ...@@ -659,6 +676,13 @@ export default {
const shouldOpenDialog = const shouldOpenDialog =
isDivisionTestInProgress(sp) || isDivisionRuleAutoTestPending(item) isDivisionTestInProgress(sp) || isDivisionRuleAutoTestPending(item)
if (shouldOpenDialog) { if (shouldOpenDialog) {
this.openDivisionTestDialogForChannel(item, result)
}
}).catch((err) => {
console.error("[FinancialRules] getDivisionTestProgress", err)
})
},
openDivisionTestDialogForChannel(item, result) {
this.financialCalculationVisible = true this.financialCalculationVisible = true
this.financialCalculationObj = normalizeDivisionTestPayload({ this.financialCalculationObj = normalizeDivisionTestPayload({
divisionRuleId: this.financialRulesEnv.divisionRuleId, divisionRuleId: this.financialRulesEnv.divisionRuleId,
...@@ -666,10 +690,6 @@ export default { ...@@ -666,10 +690,6 @@ export default {
paymentChannelName: item.paymentChannelName, paymentChannelName: item.paymentChannelName,
...result ...result
}) })
}
}).catch((err) => {
console.error("[FinancialRules] getDivisionTestProgress", err)
})
}, },
divisionTestChannelConfirm(result) { divisionTestChannelConfirm(result) {
const paymentChannelId = result.paymentChannelId const paymentChannelId = result.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,
indicesForIncremental, indicesToSubmit,
onlyActiveTab onlyActiveTab
) )
......
...@@ -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
)
}
...@@ -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
}
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)
})
}
...@@ -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
......
...@@ -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" },
......
...@@ -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, false, false]) expect(buildStepCompletedFlags(true, 2)).toEqual([true, true, 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", () => {
......
/**
* @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)
})
})
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: [
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!