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 0ce3594f
authored
Mar 31, 2026
by
Jaxon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: 嘀加上架 - 运营确认 - 分账配置 联调
1 parent
ca1e7dba
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
264 additions
and
319 deletions
src/api/shelfManage.js
src/components/remoteSearchSelect/index.vue
src/views/goods/shelfManage/components/profitSharingConfig/components/costAttributionSetting/index.vue
src/views/goods/shelfManage/components/profitSharingConfig/components/specialCategory/index.vue
src/views/goods/shelfManage/components/profitSharingConfig/components/specialCategory/specialCategoryModify/index.vue
src/views/goods/shelfManage/components/profitSharingConfig/index.vue
src/views/goods/shelfManage/components/profitSharingConfig/store/index.js
src/views/goods/shelfManage/components/profitSharingConfig/utils/feeCategoryHelper.js
src/api/shelfManage.js
View file @
0ce3594
...
...
@@ -198,3 +198,19 @@ export function getSaveRuleMerchantApi(data) {
data
.
method
=
"dj.api.create.business.approve.getSaveRuleMerchant"
;
return
request
(
data
);
};
// 保存分账信息 -单个特殊品类的信息
export
function
saveProfitSharingConfigSpecialDetailApi
(
data
)
{
data
.
method
=
"dj.api.create.business.approve.saveSettleGoodsTypeGroupRule"
;
return
request
(
data
,
"post"
);
};
export
function
getProfitSharingConfigOtherGoodsItemApi
(
data
)
{
data
.
method
=
"dj.api.create.business.approve.listOtherGoodsTypeItem"
;
return
request
(
data
,
"post"
);
};
export
function
delProfitSharingConfigSpecialItemApi
(
data
)
{
data
.
method
=
"dj.api.smartcarlife.merchantSettleDistributeRule.deleteGoodsTypeRule"
;
return
request
(
data
,
"post"
);
};
src/components/remoteSearchSelect/index.vue
View file @
0ce3594
...
...
@@ -107,7 +107,6 @@ export default {
},
computed
:
{
selectProps
()
{
console
.
log
(
"selectProps"
,
this
.
$attrs
);
return
{
"collapse-tags"
:
true
,
"filterable"
:
true
,
...
...
src/views/goods/shelfManage/components/profitSharingConfig/components/costAttributionSetting/index.vue
View file @
0ce3594
...
...
@@ -8,23 +8,25 @@
<tr
class=
"table-header"
>
<th>
分账对象/分账类目
</th>
<!--
<td>
平台方分账金额
</td>
-->
<th
v-for=
"(item, index) in
colList
"
<th
v-for=
"(item, index) in
tableCols
"
:key=
"index"
>
{{
item
.
feeCategoryName
||
item
.
expenseCategoryName
}}
</th>
</tr>
<tr
v-for=
"(item, rowIndex) in tableRows"
:key=
"
rowIndex
"
:key=
"
item.targetMerchantType
"
class=
"table-body"
>
<td
class=
"merchant-name-wrapper"
>
<span
:title=
"getMerchantTypeName(item)"
>
{{
getMerchantTypeName
(
item
)
}}
</span>
</td>
<template
v-for=
"(colItem, colIndex) in
colList
"
>
<template
v-for=
"(colItem, colIndex) in
tableCols
"
>
<td
:key=
"`$
{colIndex}colList`" class="radio-wrapper">
<el-form-item
label-width=
"0"
>
<el-radio
v-model=
"form.tableTemp[colItem.expenseCategoryId]"
:label=
"item.targetMerchantType"
>
<el-radio
:value=
"value[colItem.expenseCategoryId]"
:label=
"item.targetMerchantType"
@
input=
"val => handleRadioChange(colItem.expenseCategoryId, val)"
>
{{
""
}}
</el-radio>
</el-form-item>
...
...
@@ -38,12 +40,13 @@
</template>
<
script
>
import
{
mapState
}
from
"vuex
"
;
import
{
cloneDeep
,
uniqBy
}
from
"lodash-es
"
;
// targetMerchantType 决定行数
// expenseCategoryId 决定列数
import
{
mapGetters
,
mapState
}
from
"vuex"
;
// import { userType } from '@/common/constants'
import
{
isBatchPublishMode
,
isSingleShopMode
}
from
"../../utils/feeCategoryHelper.js"
;
import
{
getTableFilterIds
,
isBatchPublishMode
,
isSingleShopMode
}
from
"../../utils/feeCategoryHelper.js"
;
export
default
{
name
:
"TableAccount"
,
...
...
@@ -52,7 +55,6 @@ export default {
type
:
String
,
default
:
""
,
},
// 列选项
tableCols
:
{
type
:
Array
,
default
:
()
=>
([]),
...
...
@@ -62,20 +64,14 @@ export default {
type
:
Array
,
default
:
()
=>
([]),
},
merchantDistributionRules
:
{
type
:
Array
,
default
:
()
=>
{
return
[];
},
value
:
{
type
:
Object
,
default
:
()
=>
({}),
},
},
data
()
{
return
{
copyMerchantInfo
:
{},
// 多商户存导流方id
form
:
{
// settleTimeType: 1
tableTemp
:
{},
},
rules
:
{},
// 导流方下拉选项对应
attrToVal
:
[
...
...
@@ -103,125 +99,32 @@ export default {
},
computed
:
{
...
mapState
(
"ShelfManage/ProfitSharingConfigStore"
,
[
"shelfType"
]),
colList
()
{
// 只取 id 或者 expenseCategoryId 在下面这个数组里的
const
filterIds
=
[
1
,
2
,
302
,
701
,
4
];
return
this
.
tableCols
.
filter
((
item
)
=>
{
return
filterIds
.
includes
(
item
.
expenseCategoryId
);
});
},
// 给watch监听同时监听两个
merchantDistributionRulesWithCols
()
{
return
{
merchantDistributionRules
:
this
.
merchantDistributionRules
,
tableCols
:
this
.
tableCols
,
};
},
},
watch
:
{
merchantDistributionRulesWithCols
:
{
handler
(
val
)
{
this
.
initList
();
// this.initList2();
},
deep
:
true
,
// immediate: true
},
...
mapState
(
"ShelfManage/ProfitSharingConfigStore"
,
[
"shelfType"
,
"sceneType"
]),
...
mapGetters
(
"ShelfManage/ProfitSharingConfigStore"
,
{
_expenseCategoryRules
:
"expenseCategoryRules"
,
goodsTypeGroupRules
:
"goodsTypeGroupRules"
,
}),
},
mounted
()
{
// this.initList();
// this.changFormList();
},
methods
:
{
getMerchantTypeName
(
val
)
{
handleRadioChange
(
expenseCategoryId
,
val
)
{
const
newValue
=
{
...
this
.
value
,
[
expenseCategoryId
]:
val
};
this
.
$emit
(
"input"
,
newValue
);
},
getMerchantTypeName
(
item
)
{
const
name
=
{
1
:
"平台方"
,
2
:
"服务商"
,
3
:
"流量方"
,
4
:
"平台方"
,
};
const
type
=
val
.
targetMerchantType
;
// TODO: 如果是 项目制批量上架 不显示name
if
(
isBatchPublishMode
(
this
.
shelfType
))
{
return
`
${
name
[
type
]}
`
;
}
return
`
${
name
[
type
]}
:
${
val
.
merchantName
}
`
;
},
initList
()
{
// 初始化表单:根据 merchantDistributionRules 填充每一列的选择
// merchantDistributionRules 格式:
// {
// "targetMerchantType": 2,
// "targetMerchantLevel": 1,
// "ruleType": 1,
// "merchantId": 44206988,
// "merchantName": "深圳嘀加",
// "expenseCategoryId": 1301,
// "expenseCategoryName": "资源费",
// "diffTypes": null,
// "convertRate": null
// }
const
form
=
{};
// 先默认所有列都选中第一行
if
(
this
.
tableRows
.
length
>
0
)
{
for
(
const
col
of
this
.
colList
)
{
form
[
col
.
expenseCategoryId
]
=
this
.
tableRows
[
0
].
targetMerchantType
;
}
return
item
.
merchantName
;
}
// 再用实际数据覆盖
for
(
const
rule
of
this
.
merchantDistributionRules
)
{
// 按 expenseCategoryId 存储对应的 targetMerchantType
form
[
rule
.
expenseCategoryId
]
=
rule
.
targetMerchantType
;
}
this
.
$set
(
this
.
form
,
"tableTemp"
,
form
);
},
async
handleConfirm
()
{
const
valid
=
await
this
.
$refs
.
divisionRuleRef
.
validate
();
if
(
valid
)
{
return
this
.
getTableAccountParams
();
}
},
getTableAccountParams
()
{
const
merchantDistributionRules
=
[];
// 遍历表单选择,将 form.tableTemp 转换成分账规则数组
for
(
const
expenseCategoryId
in
this
.
form
.
tableTemp
)
{
const
selectedMerchantType
=
this
.
form
.
tableTemp
[
expenseCategoryId
];
// 找到对应的费用类目信息
const
colItem
=
this
.
colList
.
find
(
col
=>
col
.
expenseCategoryId
===
Number
(
expenseCategoryId
));
if
(
!
colItem
)
{
continue
;
}
// 找到对应的分账对象信息
const
merchantObj
=
this
.
tableRows
.
find
(
item
=>
item
.
targetMerchantType
===
Number
(
selectedMerchantType
),
);
if
(
!
merchantObj
)
{
continue
;
}
const
rule
=
{
targetMerchantType
:
merchantObj
.
targetMerchantType
,
targetMerchantLevel
:
merchantObj
.
targetMerchantLevel
,
expenseCategoryId
:
Number
(
expenseCategoryId
),
expenseCategoryName
:
colItem
.
expenseCategoryName
||
colItem
.
feeCategoryName
,
merchantId
:
merchantObj
.
merchantId
,
merchantName
:
merchantObj
.
merchantName
,
};
// 处理 merchantId 为 流量方 的特殊情况
if
(
merchantObj
.
targetMerchantType
===
3
)
{
rule
.
ruleType
=
1
;
}
merchantDistributionRules
.
push
(
rule
);
}
return
merchantDistributionRules
;
const
type
=
item
.
targetMerchantType
;
return
`
${
name
[
type
]}
:
${
item
.
merchantName
}
`
;
},
},
};
...
...
src/views/goods/shelfManage/components/profitSharingConfig/components/specialCategory/index.vue
View file @
0ce3594
...
...
@@ -14,11 +14,11 @@
<
script
>
import
{
mapActions
,
mapState
}
from
"vuex"
;
import
{
getProfitSharingConfigOtherGoodsItemApi
}
from
"@/api/shelfManage.js"
;
import
{
queryFeeCategoryByType
as
getFeeCategoryByTypeApi
,
getGoodsCategoryConfiguration
as
getGoodsCategoryConfigurationApi
,
}
from
"@/api/sys.base.js"
;
import
{
VIEW_MODE
}
from
"@/views/goods/shelfManage/constant/baseData.js"
;
import
Detail
from
"./specialCategoryDetail/index.vue"
;
import
Modify
from
"./specialCategoryModify/index.vue"
;
...
...
@@ -43,6 +43,7 @@ export default {
options
:
{
category
:
{},
productType
:
[],
selectedGoodsType
:
[],
},
isInitialized
:
false
,
};
...
...
@@ -51,25 +52,23 @@ export default {
...
mapState
(
"ShelfManage/ProfitSharingConfigStore"
,
{
sceneType
:
state
=>
state
.
sceneType
,
goodsTypeGroupRules
:
state
=>
state
.
profitSharingForm
.
goodsTypeGroupRules
,
businessCode
:
"businessCode"
,
specialCategory
:
"specialCategory"
,
}),
},
watch
:
{
goodsTypeGroupRules
:
{
async
handler
(
val
)
{
await
this
.
init
();
},
immediate
:
true
,
},
},
async
mounted
()
{
await
this
.
init
();
},
methods
:
{
...
mapActions
(
"ShelfManage/ProfitSharingConfigStore"
,
[
"getFeeCategoryByType"
]),
async
init
()
{
try
{
await
this
.
getFeeCategoryByType
();
await
this
.
getProductTypeOptions
();
// 商品分类
// 商品分类
await
this
.
getProductTypeOptions
();
}
finally
{
this
.
isInitialized
=
true
;
}
...
...
@@ -86,11 +85,22 @@ export default {
async
getProductTypeOptions
()
{
const
{
list
}
=
await
getGoodsCategoryConfigurationApi
({});
if
(
!
this
.
options
.
selectedGoodsType
.
length
)
{
const
goodsTypeGroupRuleId
=
String
(
this
.
specialCategory
.
active
).
startsWith
(
"nano-"
)
?
undefined
:
this
.
specialCategory
.
active
;
const
selectedGoods
=
await
getProfitSharingConfigOtherGoodsItemApi
({
goodsTypeGroupRuleId
,
categoryType
:
1
,
businessCode
:
this
.
businessCode
,
});
this
.
options
.
selectedGoodsType
=
selectedGoods
.
map
(
item
=>
item
.
goodsType
);
}
if
(
list
&&
list
.
length
)
{
this
.
options
.
productType
=
list
.
map
(({
categoryType
,
categoryName
})
=>
{
return
{
goodsType
:
categoryType
,
goodsTypeName
:
categoryName
,
disabled
:
this
.
options
.
selectedGoodsType
.
includes
(
categoryType
),
};
});
}
...
...
src/views/goods/shelfManage/components/profitSharingConfig/components/specialCategory/specialCategoryModify/index.vue
View file @
0ce3594
This diff is collapsed.
Click to expand it.
src/views/goods/shelfManage/components/profitSharingConfig/index.vue
View file @
0ce3594
This diff is collapsed.
Click to expand it.
src/views/goods/shelfManage/components/profitSharingConfig/store/index.js
View file @
0ce3594
...
...
@@ -6,66 +6,26 @@ import {
getGoodsCategoryConfiguration
as
getGoodsCategoryConfigurationApi
,
}
from
"@/api/sys.base.js"
;
import
{
attrToVal
as
attrToValOptions
,
userType
}
from
"@/common/constants"
;
import
{
syncExpenseCategoryRulesToFeeCategoryType
}
from
"../utils/feeCategoryHelper"
;
import
{
isMemberRightsUpgrade
,
isQualityUpgrade
}
from
"@/views/goods/shelfManage/utils/index.js"
;
import
{
getDefaultProfitSharingForm
,
getSelectFilterIds
,
syncExpenseCategoryRulesToFeeCategoryType
}
from
"../utils/feeCategoryHelper"
;
export
default
{
namespaced
:
true
,
state
:
{
// 整个分账配置的表单
profitSharingForm
:
{
divisionRuleAutos
:
[
// {
// paymentChannelName:"",
// autoFlag:"", Y | N
// settleTime:0,
// },
],
// 流量方分账方 批量模式
realityShopLevel
:
undefined
,
// 流量方分账方 单店模式
realityShopMerchantId
:
undefined
,
// 详情
goodsTypeGroupRules
:
{
// expenseCategoryRules: [],
// goodsTypeGroupRelations: [],
},
// 实际分账4S店商户名称
realityShopMerchantName
:
""
,
// 实际分账4S店商户用户类型(1工厂2省代3市代4门店)
realityShopUserType
:
""
,
// 自动分账标识(Y是,N否)
autoFlag
:
"N"
,
// 分账时间方式(1:T+1,2:每月)
settleTimeType
:
1
,
// 分账时间每月几号
settleTime
:
""
,
// 实际分账平台方商户id(嘀加智慧云为-1)
realityPlatformMerchantId
:
""
,
// 实际分账平台方商户名称
realityPlatformMerchantName
:
""
,
// 实际分账平台方商户用户类型(1工厂2省代3市代4门店)
realityPlatformUserType
:
"2"
,
merchantId
:
""
,
merchantName
:
""
,
sceneType
:
""
,
// 是否多平台
multiPlatformMerchantFlag
:
"N"
,
partnerMerchantId
:
""
,
partnerMerchantName
:
""
,
},
profitSharingForm
:
getDefaultProfitSharingForm
(),
// Props 值缓存
shelveId
:
undefined
,
shelfType
:
undefined
,
businessCode
:
undefined
,
sceneType
:
undefined
,
// 特殊品类值
specialCategory
:
{
list
:
[],
active
:
undefined
,
},
},
getters
:
{
goodsTypeGroupRules
(
state
)
{
...
...
@@ -79,12 +39,7 @@ export default {
},
trafficSideExpenseCategoryRules
(
state
)
{
return
state
.
profitSharingForm
.
goodsTypeGroupRules
.
expenseCategoryRules
.
filter
((
item
)
=>
{
if
(
item
.
applicationObjectType
===
1
)
{
return
item
.
id
===
1
;
}
else
if
(
item
.
applicationObjectType
===
2
)
{
return
item
.
id
===
2
;
}
return
false
;
return
getSelectFilterIds
().
includes
(
item
.
feeCategoryNameId
);
});
},
financialLedgerParty
(
state
)
{
...
...
@@ -111,6 +66,53 @@ export default {
},
mutations
:
{
UPDATE_PROFIT_SHARING_FORM
(
state
,
profitSharingForm
)
{
state
.
profitSharingForm
=
profitSharingForm
;
},
UPDATE_SPECIAL_CATEGORY_LIST
(
state
,
list
)
{
state
.
specialCategory
.
list
=
list
;
},
// 更新item的多个字段
UPDATE_SPECIAL_CATEGORY_ITEM
(
state
,
{
id
,
divisionRuleId
,
settleRuleId
})
{
const
index
=
state
.
specialCategory
.
list
.
findIndex
(
item
=>
item
.
id
===
id
);
if
(
index
===
-
1
)
{
return
;
}
Object
.
assign
(
state
.
specialCategory
.
list
[
index
],
{
id
,
divisionRuleId
,
settleRuleId
});
},
UPDATE_SPECIAL_CATEGORY_ACTIVE
(
state
,
active
)
{
state
.
specialCategory
.
active
=
active
;
},
APPEND_SPECIAL_CATEGORY
(
state
,
category
)
{
if
(
!
Array
.
isArray
(
state
.
specialCategory
.
list
))
{
state
.
specialCategory
.
list
=
[];
}
state
.
specialCategory
.
list
.
push
(
category
);
},
UPDATE_SPECIAL_CATEGORY_ID
(
state
,
{
oldId
,
newId
})
{
const
index
=
state
.
specialCategory
.
list
.
findIndex
(
item
=>
item
.
id
===
oldId
);
if
(
index
!==
-
1
)
{
state
.
specialCategory
.
list
[
index
].
id
=
newId
;
}
},
// 不做任何,直接设置
SET_SPECIAL_CATEGORY_ID
(
state
,
specialId
)
{
state
.
specialCategory
.
active
=
specialId
;
},
UPDATE_SPECIAL_CATEGORY_INTEGRITY
(
state
,
{
specialId
,
integrity
})
{
const
specialItem
=
state
.
specialCategory
.
list
.
find
(
item
=>
item
.
id
===
specialId
);
if
(
!
specialItem
)
{
return
;
}
specialItem
.
integrity
=
integrity
;
},
REMOVE_SPECIAL_CATEGORY_INTEGRITY
(
state
,
{
specialId
})
{
const
specialIndex
=
state
.
specialCategory
.
list
.
findIndex
(
item
=>
item
.
id
===
specialId
);
if
(
specialIndex
===
-
1
)
{
return
;
}
state
.
specialCategory
.
list
.
splice
(
specialIndex
,
1
);
},
/**
* 更新 divisionRuleAutos (分账规则自动配置列表)
* @param {object} state - Vuex state
...
...
@@ -185,8 +187,7 @@ export default {
*/
UPDATE_TRAFFIC_SIDE_EXPENSE_CATEGORY_RULES
(
state
,
trafficSideExpenseCategoryRules
)
{
const
otherRules
=
(
state
.
profitSharingForm
.
goodsTypeGroupRules
.
expenseCategoryRules
||
[]).
filter
((
item
)
=>
{
const
isTrafficSide
=
(
item
.
applicationObjectType
===
1
&&
[
1
].
includes
(
item
.
id
))
||
(
item
.
applicationObjectType
===
2
&&
item
.
id
===
2
);
const
isTrafficSide
=
[
1
,
2
].
includes
(
item
.
id
);
return
!
isTrafficSide
;
});
state
.
profitSharingForm
.
goodsTypeGroupRules
.
expenseCategoryRules
=
[...
otherRules
,
...
trafficSideExpenseCategoryRules
];
...
...
@@ -314,9 +315,6 @@ export default {
merchantName
:
res
.
flowChannelMerchantName
,
});
}
// 将数据去重 (商户上架时一级流量方和流量通道方设置同一家门店)
merchantLevel
=
uniqBy
(
this
.
options
.
merchantLevel
,
"merchantId"
);
// 赋值一些写死的数据
// 实际分账平台方商户id(嘀加智慧云为-1)
state
.
profitSharingForm
.
realityPlatformMerchantId
=
-
1
;
...
...
@@ -345,6 +343,17 @@ export default {
if
(
!
list
)
{
return
;
}
// const commonFilter = [3, 300, 301, 700, 4];
// const sceneTypeFilter = {
// // 精品升级
// 1: [701, ...commonFilter],
// // 会员升级权益
// 0: [...commonFilter],
// };
// const filterIdList = sceneTypeFilter[state.sceneType];
// list = list.filter(item => !filterIdList.includes(item.feeCategoryNameId));
// 同步detail的数据到 list里
list
=
syncExpenseCategoryRulesToFeeCategoryType
(
list
,
expenseCategoryRules
);
commit
(
"UPDATE_GROUP_RULES_EXPENSE_CATEGORY"
,
list
);
},
...
...
src/views/goods/shelfManage/components/profitSharingConfig/utils/feeCategoryHelper.js
View file @
0ce3594
...
...
@@ -2,7 +2,6 @@
* 费用类别处理工具
* 用于处理分账配置中的费用类别数据转换、验证和分类
*/
import
_
from
"lodash"
;
/**
* 是否为单店模式
...
...
@@ -16,6 +15,29 @@ export function isSingleShopMode(shelfType) {
export
function
isBatchPublishMode
(
shelfType
)
{
return
shelfType
===
2
;
}
/**
* 表格仅展示下面这些expenseCategoryId || feeCategoryNameId
* @param {*} sceneType
* @returns
*/
export
function
getSelectFilterIds
(
sceneType
)
{
return
[
1
,
2
,
1300
,
1301
];
}
/**
* 表格仅展示下面这些expenseCategoryId || feeCategoryNameId
* @param {*} sceneType
* @returns
*/
export
function
getTableFilterIds
(
sceneType
)
{
const
sceneTypeFilter
=
{
// 精品升级
1
:
[
1
,
2
,
3
,
4
,
301
,
1300
],
// 会员升级权益
0
:
[
1
,
2
,
4
,
701
,
1300
,
1301
],
};
return
sceneTypeFilter
[
sceneType
]
||
[];
}
/**
* 将 expenseCategoryRules 的值 设置到 feeCategoryList 上,返回feeCategoryList
...
...
@@ -37,140 +59,126 @@ export function syncExpenseCategoryRulesToFeeCategoryType(feeCategoryList, expen
});
}
/**
* 费用类别类型常量
* @type {object}
*/
export
const
CATEGORY_TYPE
=
{
TRAFFIC_SIDE
:
1
,
// 流量方
PARTNER
:
2
,
// 合作方
PLATFORM_PUBLIC
:
3
,
// 平台通用
};
export
function
getSubDataGoodsTypeGroupRelations
(
goodsTypeGroupRelations
,
categoryType
)
{
return
goodsTypeGroupRelations
.
map
(
item
=>
({
categoryType
,
upgradeGoodsId
:
item
.
upgradeGoodsId
,
goodsType
:
item
.
goodsType
,
goodsTypeName
:
item
.
goodsTypeName
,
packageCode
:
item
.
packageCode
,
packageName
:
item
.
packageName
,
upgradeGoodsName
:
item
.
upgradeGoodsName
,
commodityCode
:
item
.
commodityCode
,
tempPackageCode
:
item
.
tempPackageCode
,
}));
}
export
function
getSubDataOwningMerchantDistributionRules
(
owningMerchantDistributionRules
,
sceneType
)
{
const
filterData
=
owningMerchantDistributionRules
.
filter
(
item
=>
getTableFilterIds
(
sceneType
).
includes
(
item
.
expenseCategoryId
));
return
filterData
.
map
(
item
=>
({
targetMerchantType
:
item
.
targetMerchantType
,
targetMerchantLevel
:
item
.
targetMerchantLevel
,
ruleType
:
item
.
ruleType
,
merchantId
:
item
.
merchantId
,
merchantName
:
item
.
merchantName
,
expenseCategoryId
:
item
.
expenseCategoryId
,
expenseCategoryName
:
item
.
expenseCategoryName
,
diffTypes
:
item
.
diffTypes
,
convertRate
:
item
.
convertRate
,
}));
}
/**
* 费用类别配置
* 每种类型对应的目标数组名称和过滤规则
* @type {object}
*/
export
const
CATEGORY_CONFIG
=
{
[
CATEGORY_TYPE
.
TRAFFIC_SIDE
]:
{
target
:
"trafficSide"
,
},
[
CATEGORY_TYPE
.
PARTNER
]:
{
target
:
"serviceProvider"
,
},
[
CATEGORY_TYPE
.
PLATFORM_PUBLIC
]:
{
target
:
"platformPublic"
,
// 黑名单:排除以下 ID(产品成本、虚拟对账成本、回收成本、嘀加成本、第三方成本等)
excludeIds
:
new
Set
([
3
,
4
,
300
,
301
,
700
,
701
]),
},
};
export
function
getSubDataExpenseCategoryRules
(
expenseCategoryRules
)
{
const
filterData
=
expenseCategoryRules
.
filter
(
item
=>
getSelectFilterIds
().
includes
(
item
.
id
));
/**
* 转换单个费用类别项目
* 将原始 API 响应数据转换为前端所需的格式
*
* @param {object} item - 单个费用类别项目
* @param {number} item.id - 项目 ID
* @param {number} item.applicationObjectType - 应用对象类型
* @param {string} item.feeCategoryName - 费用类别名称
* @param {string} item.feeCategoryNameId - 费用类别名称 ID
* @param {Array} item.feeCategoryChildren - 子费用类别列表
* @param {string} item.formType - 表单类型
* @param {string} item.nodeType - 节点类型
* @returns {object} 转换后的费用类别对象
*/
export
function
transformFeeCategoryItem
(
item
)
{
return
filterData
.
map
((
item
)
=>
{
const
result
=
{
nodeType
:
item
.
nodeType
,
expenseCategoryId
:
item
.
expenseCategoryId
,
expenseCategoryName
:
item
.
expenseCategoryName
,
targetMerchantId
:
item
.
targetMerchantId
,
targetMerchantName
:
item
.
targetMerchantName
,
calculateMode
:
item
.
calculateMode
,
expenseCategoryCalculateType
:
item
.
expenseCategoryCalculateType
,
expenseCategoryValue
:
item
.
expenseCategoryValue
,
diffTypes
:
item
.
diffTypes
,
distributeTargetMerchantType
:
item
.
distributeTargetMerchantType
,
distributeTargetMerchantId
:
item
.
distributeTargetMerchantId
,
distributeTargetMerchantName
:
item
.
distributeTargetMerchantName
,
merchantId
:
item
.
merchantId
,
merchantName
:
item
.
merchantName
,
};
if
(
item
.
children
&&
item
.
children
.
length
)
{
result
.
children
=
item
?.
children
?.
map
(
cItem
=>
({
nodeType
:
cItem
.
nodeType
,
expenseCategoryId
:
cItem
.
expenseCategoryId
,
expenseCategoryName
:
cItem
.
expenseCategoryName
,
targetMerchantId
:
cItem
.
targetMerchantId
,
targetMerchantName
:
cItem
.
targetMerchantName
,
calculateMode
:
cItem
.
calculateMode
,
expenseCategoryCalculateType
:
cItem
.
expenseCategoryCalculateType
,
expenseCategoryValue
:
cItem
.
expenseCategoryValue
,
diffTypes
:
cItem
.
diffTypes
,
distributeTargetMerchantType
:
cItem
.
distributeTargetMerchantType
,
distributeTargetMerchantId
:
cItem
.
distributeTargetMerchantId
,
distributeTargetMerchantName
:
cItem
.
distributeTargetMerchantName
,
merchantId
:
cItem
.
merchantId
,
merchantName
:
cItem
.
merchantName
,
}));
}
return
result
;
});
}
export
function
getDefaultProfitSharingForm
()
{
return
{
id
:
item
.
id
,
nodeType
:
item
.
nodeType
,
applicationObjectType
:
item
.
applicationObjectType
,
formType
:
item
.
formType
,
divisionRuleAutos
:
[
// {
// paymentChannelName:"",
// autoFlag:"", Y | N
// settleTime:0,
// },
],
targetType
:
item
.
applicationObjectType
,
applicationObjectName
:
item
.
feeCategoryName
,
// 对应detail中的id
expenseCategoryId
:
item
.
feeCategoryNameId
,
expenseType
:
""
,
// 转换子费用类别列表
feeCategoryNameList
:
transformFeeCategoryChildren
(
item
.
feeCategoryChildren
,
item
.
applicationObjectType
),
};
}
// 流量方分账方 批量模式
realityShopLevel
:
undefined
,
// 流量方分账方 单店模式
realityShopMerchantId
:
undefined
,
/**
* 转换费用类别子项列表
* 为每个子项添加必要的映射字段
*
* @param {Array} children - 子费用类别数组
* @param {number} targetType - 目标类型(用于标记)
* @returns {Array} 转换后的子费用类别数组
*/
export
function
transformFeeCategoryChildren
(
children
,
targetType
)
{
return
children
.
map
(
child
=>
({
...
child
,
applicationObjectName
:
child
.
feeCategoryName
,
expenseCategoryId
:
child
.
feeCategoryNameId
,
targetType
,
}));
}
// 详情
goodsTypeGroupRules
:
{
goodsTypes
:
[],
expenseCategoryRules
:
[],
goodsTypeGroupRelations
:
[],
merchantDistributionRules
:
[],
owningMerchantDistributionRules
:
[],
/**
* 判断项目是否应该被包含
* 根据配置的白名单或黑名单规则检查项目 ID 是否有效
*
* @param {number} id - 项目 ID
* @param {object} typeConfig - 类型配置对象
* @param {Set} [typeConfig.validIds] - 白名单:包含的 ID 集合
* @param {Set} [typeConfig.excludeIds] - 黑名单:排除的 ID 集合
* @returns {boolean} 项目是否应该被包含
*
* @example
* // 白名单模式
* shouldIncludeItem(1, { validIds: new Set([1, 2]) }); // true
* shouldIncludeItem(3, { validIds: new Set([1, 2]) }); // false
*
* @example
* // 黑名单模式
* shouldIncludeItem(5, { excludeIds: new Set([3, 4]) }); // true
* shouldIncludeItem(3, { excludeIds: new Set([3, 4]) }); // false
*/
export
function
shouldIncludeItem
(
id
,
typeConfig
)
{
// 优先检查白名单
if
(
typeConfig
.
validIds
)
{
return
typeConfig
.
validIds
.
has
(
id
);
}
// 其次检查黑名单
if
(
typeConfig
.
excludeIds
)
{
return
!
typeConfig
.
excludeIds
.
has
(
id
);
}
// 都不存在时,默认包含
return
true
;
}
},
/**
* 处理费用类别数据(完整流程)
* 将 API 返回的原始数据转换并分类
*
* @param {Array} items - 费用类别项目数组
* @returns {object} 分类后的费用类别对象
*/
export
function
processFeeCategories
(
items
)
{
const
grouped
=
_
.
chain
(
items
)
.
map
((
item
)
=>
{
const
transformedItem
=
transformFeeCategoryItem
(
item
);
const
config
=
CATEGORY_CONFIG
[
item
.
applicationObjectType
];
return
config
&&
shouldIncludeItem
(
transformedItem
.
id
,
config
)
?
{
item
:
transformedItem
,
target
:
config
.
target
}
:
null
;
})
.
compact
()
// 移除 null 值
.
groupBy
(
"target"
)
// 按 target 字段分组
.
value
();
// 实际分账4S店商户名称
realityShopMerchantName
:
""
,
// 实际分账4S店商户用户类型(1工厂2省代3市代4门店)
realityShopUserType
:
""
,
// 自动分账标识(Y是,N否)
autoFlag
:
"N"
,
// 分账时间方式(1:T+1,2:每月)
settleTimeType
:
1
,
// 分账时间每月几号
settleTime
:
""
,
// 实际分账平台方商户id(嘀加智慧云为-1)
realityPlatformMerchantId
:
""
,
// 实际分账平台方商户名称
realityPlatformMerchantName
:
""
,
// 实际分账平台方商户用户类型(1工厂2省代3市代4门店)
realityPlatformUserType
:
"2"
,
return
{
trafficSide
:
_
.
map
(
grouped
.
trafficSide
,
"item"
)
||
[],
serviceProvider
:
_
.
map
(
grouped
.
serviceProvider
,
"item"
)
||
[],
platformPublic
:
_
.
map
(
grouped
.
platformPublic
,
"item"
)
||
[],
merchantId
:
""
,
merchantName
:
""
,
sceneType
:
""
,
// 是否多平台
multiPlatformMerchantFlag
:
"N"
,
partnerMerchantId
:
""
,
partnerMerchantName
:
""
,
};
}
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