Commit 0ce3594f by Jaxon

feat: 嘀加上架 - 运营确认 - 分账配置 联调

1 parent ca1e7dba
...@@ -198,3 +198,19 @@ export function getSaveRuleMerchantApi(data) { ...@@ -198,3 +198,19 @@ export function getSaveRuleMerchantApi(data) {
data.method = "dj.api.create.business.approve.getSaveRuleMerchant"; data.method = "dj.api.create.business.approve.getSaveRuleMerchant";
return request(data); 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");
};
...@@ -107,7 +107,6 @@ export default { ...@@ -107,7 +107,6 @@ export default {
}, },
computed: { computed: {
selectProps() { selectProps() {
console.log("selectProps", this.$attrs);
return { return {
"collapse-tags": true, "collapse-tags": true,
"filterable": true, "filterable": true,
......
...@@ -8,23 +8,25 @@ ...@@ -8,23 +8,25 @@
<tr class="table-header"> <tr class="table-header">
<th>分账对象/分账类目</th> <th>分账对象/分账类目</th>
<!-- <td>平台方分账金额</td> --> <!-- <td>平台方分账金额</td> -->
<th v-for="(item, index) in colList" <th v-for="(item, index) in tableCols"
:key="index"> :key="index">
{{ item.feeCategoryName || item.expenseCategoryName }} {{ item.feeCategoryName || item.expenseCategoryName }}
</th> </th>
</tr> </tr>
<tr v-for="(item, rowIndex) in tableRows" <tr v-for="(item, rowIndex) in tableRows"
:key="rowIndex" :key="item.targetMerchantType"
class="table-body"> class="table-body">
<td class="merchant-name-wrapper"> <td class="merchant-name-wrapper">
<span :title="getMerchantTypeName(item)"> <span :title="getMerchantTypeName(item)">
{{ getMerchantTypeName(item) }} {{ getMerchantTypeName(item) }}
</span> </span>
</td> </td>
<template v-for="(colItem, colIndex) in colList"> <template v-for="(colItem, colIndex) in tableCols">
<td :key="`${colIndex}colList`" class="radio-wrapper"> <td :key="`${colIndex}colList`" class="radio-wrapper">
<el-form-item label-width="0"> <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-radio>
</el-form-item> </el-form-item>
...@@ -38,12 +40,13 @@ ...@@ -38,12 +40,13 @@
</template> </template>
<script> <script>
import { mapState } from "vuex"; import { cloneDeep, uniqBy } from "lodash-es";
// targetMerchantType 决定行数 // targetMerchantType 决定行数
// expenseCategoryId 决定列数 // expenseCategoryId 决定列数
import { mapGetters, mapState } from "vuex";
// import { userType } from '@/common/constants' // import { userType } from '@/common/constants'
import { isBatchPublishMode, isSingleShopMode } from "../../utils/feeCategoryHelper.js"; import { getTableFilterIds, isBatchPublishMode, isSingleShopMode } from "../../utils/feeCategoryHelper.js";
export default { export default {
name: "TableAccount", name: "TableAccount",
...@@ -52,7 +55,6 @@ export default { ...@@ -52,7 +55,6 @@ export default {
type: String, type: String,
default: "", default: "",
}, },
// 列选项
tableCols: { tableCols: {
type: Array, type: Array,
default: () => ([]), default: () => ([]),
...@@ -62,20 +64,14 @@ export default { ...@@ -62,20 +64,14 @@ export default {
type: Array, type: Array,
default: () => ([]), default: () => ([]),
}, },
merchantDistributionRules: { value: {
type: Array, type: Object,
default: () => { default: () => ({}),
return [];
},
}, },
}, },
data() { data() {
return { return {
copyMerchantInfo: {}, // 多商户存导流方id copyMerchantInfo: {}, // 多商户存导流方id
form: {
// settleTimeType: 1
tableTemp: {},
},
rules: {}, rules: {},
// 导流方下拉选项对应 // 导流方下拉选项对应
attrToVal: [ attrToVal: [
...@@ -103,125 +99,32 @@ export default { ...@@ -103,125 +99,32 @@ export default {
}, },
computed: { computed: {
...mapState("ShelfManage/ProfitSharingConfigStore", ["shelfType"]), ...mapState("ShelfManage/ProfitSharingConfigStore", ["shelfType", "sceneType"]),
colList() { ...mapGetters("ShelfManage/ProfitSharingConfigStore", {
// 只取 id 或者 expenseCategoryId 在下面这个数组里的 _expenseCategoryRules: "expenseCategoryRules",
const filterIds = [1, 2, 302, 701, 4]; goodsTypeGroupRules: "goodsTypeGroupRules",
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
},
}, },
mounted() { mounted() {
// this.initList();
// this.changFormList();
}, },
methods: { methods: {
getMerchantTypeName(val) { handleRadioChange(expenseCategoryId, val) {
const newValue = { ...this.value, [expenseCategoryId]: val };
this.$emit("input", newValue);
},
getMerchantTypeName(item) {
const name = { const name = {
1: "平台方", 1: "平台方",
2: "服务商", 2: "服务商",
3: "流量方", 3: "流量方",
4: "平台方", 4: "平台方",
}; };
const type = val.targetMerchantType;
// TODO: 如果是 项目制批量上架 不显示name // TODO: 如果是 项目制批量上架 不显示name
if (isBatchPublishMode(this.shelfType)) { if (isBatchPublishMode(this.shelfType)) {
return `${name[type]}`; return item.merchantName;
}
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;
}
} }
const type = item.targetMerchantType;
// 再用实际数据覆盖 return `${name[type]}: ${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;
}, },
}, },
}; };
......
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
<script> <script>
import { mapActions, mapState } from "vuex"; import { mapActions, mapState } from "vuex";
import { getProfitSharingConfigOtherGoodsItemApi } from "@/api/shelfManage.js";
import { import {
queryFeeCategoryByType as getFeeCategoryByTypeApi, queryFeeCategoryByType as getFeeCategoryByTypeApi,
getGoodsCategoryConfiguration as getGoodsCategoryConfigurationApi, getGoodsCategoryConfiguration as getGoodsCategoryConfigurationApi,
} from "@/api/sys.base.js"; } from "@/api/sys.base.js";
import { VIEW_MODE } from "@/views/goods/shelfManage/constant/baseData.js"; import { VIEW_MODE } from "@/views/goods/shelfManage/constant/baseData.js";
import Detail from "./specialCategoryDetail/index.vue"; import Detail from "./specialCategoryDetail/index.vue";
import Modify from "./specialCategoryModify/index.vue"; import Modify from "./specialCategoryModify/index.vue";
...@@ -43,6 +43,7 @@ export default { ...@@ -43,6 +43,7 @@ export default {
options: { options: {
category: {}, category: {},
productType: [], productType: [],
selectedGoodsType: [],
}, },
isInitialized: false, isInitialized: false,
}; };
...@@ -51,25 +52,23 @@ export default { ...@@ -51,25 +52,23 @@ export default {
...mapState("ShelfManage/ProfitSharingConfigStore", { ...mapState("ShelfManage/ProfitSharingConfigStore", {
sceneType: state => state.sceneType, sceneType: state => state.sceneType,
goodsTypeGroupRules: state => state.profitSharingForm.goodsTypeGroupRules, goodsTypeGroupRules: state => state.profitSharingForm.goodsTypeGroupRules,
businessCode: "businessCode",
specialCategory: "specialCategory",
}), }),
}, },
watch: { watch: {
goodsTypeGroupRules: {
async handler(val) {
await this.init();
},
immediate: true,
},
}, },
async mounted() { async mounted() {
await this.init();
}, },
methods: { methods: {
...mapActions("ShelfManage/ProfitSharingConfigStore", ["getFeeCategoryByType"]), ...mapActions("ShelfManage/ProfitSharingConfigStore", ["getFeeCategoryByType"]),
async init() { async init() {
try { try {
await this.getFeeCategoryByType(); // 商品分类
await this.getProductTypeOptions(); // 商品分类 await this.getProductTypeOptions();
} finally { } finally {
this.isInitialized = true; this.isInitialized = true;
} }
...@@ -86,11 +85,22 @@ export default { ...@@ -86,11 +85,22 @@ export default {
async getProductTypeOptions() { async getProductTypeOptions() {
const { list } = await getGoodsCategoryConfigurationApi({}); 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) { if (list && list.length) {
this.options.productType = list.map(({ categoryType, categoryName }) => { this.options.productType = list.map(({ categoryType, categoryName }) => {
return { return {
goodsType: categoryType, goodsType: categoryType,
goodsTypeName: categoryName, goodsTypeName: categoryName,
disabled: this.options.selectedGoodsType.includes(categoryType),
}; };
}); });
} }
......
...@@ -6,66 +6,26 @@ import { ...@@ -6,66 +6,26 @@ import {
getGoodsCategoryConfiguration as getGoodsCategoryConfigurationApi, getGoodsCategoryConfiguration as getGoodsCategoryConfigurationApi,
} from "@/api/sys.base.js"; } from "@/api/sys.base.js";
import { attrToVal as attrToValOptions, userType } from "@/common/constants"; 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 { export default {
namespaced: true, namespaced: true,
state: { state: {
// 整个分账配置的表单 // 整个分账配置的表单
profitSharingForm: { profitSharingForm: getDefaultProfitSharingForm(),
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: "",
},
// Props 值缓存 // Props 值缓存
shelveId: undefined, shelveId: undefined,
shelfType: undefined, shelfType: undefined,
businessCode: undefined, businessCode: undefined,
sceneType: undefined, sceneType: undefined,
// 特殊品类值
specialCategory: {
list: [],
active: undefined,
},
}, },
getters: { getters: {
goodsTypeGroupRules(state) { goodsTypeGroupRules(state) {
...@@ -79,12 +39,7 @@ export default { ...@@ -79,12 +39,7 @@ export default {
}, },
trafficSideExpenseCategoryRules(state) { trafficSideExpenseCategoryRules(state) {
return state.profitSharingForm.goodsTypeGroupRules.expenseCategoryRules.filter((item) => { return state.profitSharingForm.goodsTypeGroupRules.expenseCategoryRules.filter((item) => {
if (item.applicationObjectType === 1) { return getSelectFilterIds().includes(item.feeCategoryNameId);
return item.id === 1;
} else if (item.applicationObjectType === 2) {
return item.id === 2;
}
return false;
}); });
}, },
financialLedgerParty(state) { financialLedgerParty(state) {
...@@ -111,6 +66,53 @@ export default { ...@@ -111,6 +66,53 @@ export default {
}, },
mutations: { 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 (分账规则自动配置列表) * 更新 divisionRuleAutos (分账规则自动配置列表)
* @param {object} state - Vuex state * @param {object} state - Vuex state
...@@ -185,8 +187,7 @@ export default { ...@@ -185,8 +187,7 @@ export default {
*/ */
UPDATE_TRAFFIC_SIDE_EXPENSE_CATEGORY_RULES(state, trafficSideExpenseCategoryRules) { UPDATE_TRAFFIC_SIDE_EXPENSE_CATEGORY_RULES(state, trafficSideExpenseCategoryRules) {
const otherRules = (state.profitSharingForm.goodsTypeGroupRules.expenseCategoryRules || []).filter((item) => { const otherRules = (state.profitSharingForm.goodsTypeGroupRules.expenseCategoryRules || []).filter((item) => {
const isTrafficSide = (item.applicationObjectType === 1 && [1].includes(item.id)) const isTrafficSide = [1, 2].includes(item.id);
|| (item.applicationObjectType === 2 && item.id === 2);
return !isTrafficSide; return !isTrafficSide;
}); });
state.profitSharingForm.goodsTypeGroupRules.expenseCategoryRules = [...otherRules, ...trafficSideExpenseCategoryRules]; state.profitSharingForm.goodsTypeGroupRules.expenseCategoryRules = [...otherRules, ...trafficSideExpenseCategoryRules];
...@@ -314,9 +315,6 @@ export default { ...@@ -314,9 +315,6 @@ export default {
merchantName: res.flowChannelMerchantName, merchantName: res.flowChannelMerchantName,
}); });
} }
// 将数据去重 (商户上架时一级流量方和流量通道方设置同一家门店)
merchantLevel = uniqBy(this.options.merchantLevel, "merchantId");
// 赋值一些写死的数据 // 赋值一些写死的数据
// 实际分账平台方商户id(嘀加智慧云为-1) // 实际分账平台方商户id(嘀加智慧云为-1)
state.profitSharingForm.realityPlatformMerchantId = -1; state.profitSharingForm.realityPlatformMerchantId = -1;
...@@ -345,6 +343,17 @@ export default { ...@@ -345,6 +343,17 @@ export default {
if (!list) { if (!list) {
return; 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); list = syncExpenseCategoryRulesToFeeCategoryType(list, expenseCategoryRules);
commit("UPDATE_GROUP_RULES_EXPENSE_CATEGORY", list); commit("UPDATE_GROUP_RULES_EXPENSE_CATEGORY", list);
}, },
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
* 费用类别处理工具 * 费用类别处理工具
* 用于处理分账配置中的费用类别数据转换、验证和分类 * 用于处理分账配置中的费用类别数据转换、验证和分类
*/ */
import _ from "lodash";
/** /**
* 是否为单店模式 * 是否为单店模式
...@@ -16,6 +15,29 @@ export function isSingleShopMode(shelfType) { ...@@ -16,6 +15,29 @@ export function isSingleShopMode(shelfType) {
export function isBatchPublishMode(shelfType) { export function isBatchPublishMode(shelfType) {
return shelfType === 2; 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 * 将 expenseCategoryRules 的值 设置到 feeCategoryList 上,返回feeCategoryList
...@@ -37,140 +59,126 @@ export function syncExpenseCategoryRulesToFeeCategoryType(feeCategoryList, expen ...@@ -37,140 +59,126 @@ export function syncExpenseCategoryRulesToFeeCategoryType(feeCategoryList, expen
}); });
} }
/** export function getSubDataGoodsTypeGroupRelations(goodsTypeGroupRelations, categoryType) {
* 费用类别类型常量 return goodsTypeGroupRelations.map(item => ({
* @type {object} categoryType,
*/ upgradeGoodsId: item.upgradeGoodsId,
export const CATEGORY_TYPE = { goodsType: item.goodsType,
TRAFFIC_SIDE: 1, // 流量方 goodsTypeName: item.goodsTypeName,
PARTNER: 2, // 合作方 packageCode: item.packageCode,
PLATFORM_PUBLIC: 3, // 平台通用 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,
}));
}
/** export function getSubDataExpenseCategoryRules(expenseCategoryRules) {
* 费用类别配置 const filterData = expenseCategoryRules.filter(item => getSelectFilterIds().includes(item.id));
* 每种类型对应的目标数组名称和过滤规则
* @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]),
},
};
/** return filterData.map((item) => {
* 转换单个费用类别项目 const result = {
* 将原始 API 响应数据转换为前端所需的格式 nodeType: item.nodeType,
* expenseCategoryId: item.expenseCategoryId,
* @param {object} item - 单个费用类别项目 expenseCategoryName: item.expenseCategoryName,
* @param {number} item.id - 项目 ID targetMerchantId: item.targetMerchantId,
* @param {number} item.applicationObjectType - 应用对象类型 targetMerchantName: item.targetMerchantName,
* @param {string} item.feeCategoryName - 费用类别名称 calculateMode: item.calculateMode,
* @param {string} item.feeCategoryNameId - 费用类别名称 ID expenseCategoryCalculateType: item.expenseCategoryCalculateType,
* @param {Array} item.feeCategoryChildren - 子费用类别列表 expenseCategoryValue: item.expenseCategoryValue,
* @param {string} item.formType - 表单类型 diffTypes: item.diffTypes,
* @param {string} item.nodeType - 节点类型 distributeTargetMerchantType: item.distributeTargetMerchantType,
* @returns {object} 转换后的费用类别对象 distributeTargetMerchantId: item.distributeTargetMerchantId,
*/ distributeTargetMerchantName: item.distributeTargetMerchantName,
export function transformFeeCategoryItem(item) { 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 { return {
id: item.id, divisionRuleAutos: [
nodeType: item.nodeType, // {
applicationObjectType: item.applicationObjectType, // paymentChannelName:"",
formType: item.formType, // autoFlag:"", Y | N
// settleTime:0,
// },
],
targetType: item.applicationObjectType, // 流量方分账方 批量模式
applicationObjectName: item.feeCategoryName, realityShopLevel: undefined,
// 对应detail中的id // 流量方分账方 单店模式
expenseCategoryId: item.feeCategoryNameId, realityShopMerchantId: undefined,
expenseType: "",
// 转换子费用类别列表
feeCategoryNameList: transformFeeCategoryChildren(item.feeCategoryChildren, item.applicationObjectType),
};
}
/** // 详情
* 转换费用类别子项列表 goodsTypeGroupRules: {
* 为每个子项添加必要的映射字段 goodsTypes: [],
* expenseCategoryRules: [],
* @param {Array} children - 子费用类别数组 goodsTypeGroupRelations: [],
* @param {number} targetType - 目标类型(用于标记) merchantDistributionRules: [],
* @returns {Array} 转换后的子费用类别数组 owningMerchantDistributionRules: [],
*/
export function transformFeeCategoryChildren(children, targetType) {
return children.map(child => ({
...child,
applicationObjectName: child.feeCategoryName,
expenseCategoryId: child.feeCategoryNameId,
targetType,
}));
}
/** },
* 判断项目是否应该被包含
* 根据配置的白名单或黑名单规则检查项目 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;
}
/** // 实际分账4S店商户名称
* 处理费用类别数据(完整流程) realityShopMerchantName: "",
* 将 API 返回的原始数据转换并分类 // 实际分账4S店商户用户类型(1工厂2省代3市代4门店)
* realityShopUserType: "",
* @param {Array} items - 费用类别项目数组 // 自动分账标识(Y是,N否)
* @returns {object} 分类后的费用类别对象 autoFlag: "N",
*/ // 分账时间方式(1:T+1,2:每月)
export function processFeeCategories(items) { settleTimeType: 1,
const grouped = _ // 分账时间每月几号
.chain(items) settleTime: "",
.map((item) => { // 实际分账平台方商户id(嘀加智慧云为-1)
const transformedItem = transformFeeCategoryItem(item); realityPlatformMerchantId: "",
const config = CATEGORY_CONFIG[item.applicationObjectType]; // 实际分账平台方商户名称
return config && shouldIncludeItem(transformedItem.id, config) realityPlatformMerchantName: "",
? { item: transformedItem, target: config.target } // 实际分账平台方商户用户类型(1工厂2省代3市代4门店)
: null; realityPlatformUserType: "2",
})
.compact() // 移除 null 值
.groupBy("target") // 按 target 字段分组
.value();
return { merchantId: "",
trafficSide: _.map(grouped.trafficSide, "item") || [], merchantName: "",
serviceProvider: _.map(grouped.serviceProvider, "item") || [], sceneType: "",
platformPublic: _.map(grouped.platformPublic, "item") || [],
// 是否多平台
multiPlatformMerchantFlag: "N",
partnerMerchantId: "",
partnerMerchantName: "",
}; };
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!