Commit 51f83bf8 by 张立顺

feat 功能联调

1 parent e442af62
...@@ -380,16 +380,16 @@ export function getContractAffiliationDataList(data) { ...@@ -380,16 +380,16 @@ export function getContractAffiliationDataList(data) {
return request(data, "post"); return request(data, "post");
} }
// 获取商户关系历史记录 // 获取商户关系历史记录(场景商户关系)
export function getMerchantRelationRecordApi(data) { export function getMerchantRelationRecordApi(data) {
data.method = `${path2}shopMerchant.queryMerchantRefDetailHistory`; data.method = `${path}scenemerchantref.queryMerchantHistory`;
return request(data, "post"); return request(data, RequestMethods.POST);
} }
// 新增/编辑商户上架 // 新增/编辑商户上架(Open 网关参数形态)
export function merchantOnShelf(data) { export function merchantOnShelf(data) {
data.method = `${path2}shopMerchant.addOrUpdateSceneMerchantRefNew`; data.method = `${path2}shopMerchant.addOrUpdateSceneMerchantRefNewOpen`;
return request(data, "post"); return request(data, RequestMethods.POST);
} }
// 获取商户关联关系详情 // 获取商户关联关系详情
......
...@@ -96,7 +96,8 @@ export default { ...@@ -96,7 +96,8 @@ export default {
productCost = 0, productCost = 0,
recyclingFilm = 0 recyclingFilm = 0
productDetails.forEach(item => { productDetails.forEach(item => {
revenue = NP.plus(revenue, item.revenue || 0) const lineRev = item.estimatedRevenue != null ? item.estimatedRevenue : item.revenue
revenue = NP.plus(revenue, lineRev || 0)
trafficFee = NP.plus(trafficFee, item.trafficFee || 0) trafficFee = NP.plus(trafficFee, item.trafficFee || 0)
marketFee1 = NP.plus(marketFee1, item.marketFee1 || 0) marketFee1 = NP.plus(marketFee1, item.marketFee1 || 0)
marketFee2 = NP.plus(marketFee2, item.marketFee2 || 0) marketFee2 = NP.plus(marketFee2, item.marketFee2 || 0)
...@@ -129,7 +130,8 @@ export default { ...@@ -129,7 +130,8 @@ export default {
let { productDetails, djGrossProfit } = this, let { productDetails, djGrossProfit } = this,
revenue = 0 revenue = 0
productDetails.forEach(item => { productDetails.forEach(item => {
revenue = NP.plus(revenue, item.revenue || 0) const lineRev = item.estimatedRevenue != null ? item.estimatedRevenue : item.revenue
revenue = NP.plus(revenue, lineRev || 0)
}) })
// 检查边界情况 // 检查边界情况
......
...@@ -23,9 +23,9 @@ const SALES_CATEGORY_LIST = [ ...@@ -23,9 +23,9 @@ const SALES_CATEGORY_LIST = [
}, },
{ {
title: '预估经营数据', list: [ title: '预估经营数据', list: [
{ label: '转化率', key: 'estimatedConversionRate', unit: '%', type: 'input', filterRule: 'decimalRange', min: 0, max: 100, precision: 2 }, { label: '转化率', key: 'estimatedConversion', unit: '%', type: 'input', filterRule: 'decimalRange', min: 0, max: 100, precision: 2 },
{ label: '升级客单价', key: 'upgradePrice', type: 'input', filterRule: 'decimalRange', min: 0, max: 999999, precision: 2 }, { label: '升级客单价', key: 'estimatedUpgradePrice', type: 'input', filterRule: 'decimalRange', min: 0, max: 999999, precision: 2 },
{ label: '产值', key: 'revenue', type: 'input', filterRule: 'decimalRange', min: 0, max: 999999, precision: 2 }, { label: '产值', key: 'estimatedRevenue', type: 'input', filterRule: 'decimalRange', min: 0, max: 999999, precision: 2 },
] ]
}, },
{ {
...@@ -63,9 +63,9 @@ const SALES_CATEGORY_RULES = { ...@@ -63,9 +63,9 @@ const SALES_CATEGORY_RULES = {
penetrationRate: [{ required: true, validator: VAILIDATOR_FROM, trigger: 'blur' }], penetrationRate: [{ required: true, validator: VAILIDATOR_FROM, trigger: 'blur' }],
conversionRate: [{ required: true, validator: VAILIDATOR_FROM, trigger: 'blur' }], conversionRate: [{ required: true, validator: VAILIDATOR_FROM, trigger: 'blur' }],
revenuePerCar: [{ required: true, validator: VAILIDATOR_FROM, trigger: 'blur' }], revenuePerCar: [{ required: true, validator: VAILIDATOR_FROM, trigger: 'blur' }],
estimatedConversionRate: [{ required: true, validator: VAILIDATOR_FROM, trigger: 'blur' }], estimatedConversion: [{ required: true, validator: VAILIDATOR_FROM, trigger: 'blur' }],
upgradePrice: [{ required: true, validator: VAILIDATOR_FROM, trigger: 'blur' }], estimatedUpgradePrice: [{ required: true, validator: VAILIDATOR_FROM, trigger: 'blur' }],
revenue: [{ required: true, validator: VAILIDATOR_FROM, trigger: 'blur' }], estimatedRevenue: [{ required: true, validator: VAILIDATOR_FROM, trigger: 'blur' }],
trafficFee: [{ required: true, validator: VAILIDATOR_FROM, trigger: 'blur' }], trafficFee: [{ required: true, validator: VAILIDATOR_FROM, trigger: 'blur' }],
marketFee1: [{ required: true, validator: VAILIDATOR_FROM, trigger: 'blur' }], marketFee1: [{ required: true, validator: VAILIDATOR_FROM, trigger: 'blur' }],
marketFee2: [{ required: true, validator: VAILIDATOR_FROM, trigger: 'blur' }], marketFee2: [{ required: true, validator: VAILIDATOR_FROM, trigger: 'blur' }],
......
...@@ -271,9 +271,9 @@ export default { ...@@ -271,9 +271,9 @@ export default {
penetrationRate: '兜底要求-渗透率', penetrationRate: '兜底要求-渗透率',
conversionRate: '兜底要求-转化率', conversionRate: '兜底要求-转化率',
revenuePerCar: '兜底要求-单车采购产值', revenuePerCar: '兜底要求-单车采购产值',
estimatedConversionRate: '预估经营数据-转化率', estimatedConversion: '预估经营数据-转化率',
upgradePrice: '预估经营数据-升级客单价', estimatedUpgradePrice: '预估经营数据-升级客单价',
revenue: '预估经营数据-产值', estimatedRevenue: '预估经营数据-产值',
trafficFtrafficFeeee: '商务政策-流量费', trafficFtrafficFeeee: '商务政策-流量费',
marketFee1: '商务政策-管理层市场费1', marketFee1: '商务政策-管理层市场费1',
marketFee2: '商务政策-管理层市场费2', marketFee2: '商务政策-管理层市场费2',
......
<template>
<div class="merchant-relation-grounding-readonly" v-loading="loading">
<div class="section grounding-section-traffic">
<div class="section-title">
流量方信息
</div>
<traffic-provider-information
:data="trafficProviderData"
:is-view-mode="true"
:show-edit-toolbar="false"
/>
</div>
<div class="section">
<div class="section-title">经营信息</div>
<mg-business-section
:data="businessForm"
:product-details="productDetails"
:is-view-mode="true"
/>
</div>
<div class="section section-sales-category">
<mg-sales-category-section :product-details="productDetails" />
</div>
</div>
</template>
<script>
import TrafficProviderInformation
from "@/views/salesManagement/availableInStores/tigaListingAndSalesContract/components/StepTwo/components/TrafficProviderInformation.vue";
import MgBusinessSection from "./MgBusinessSection.vue";
import MgSalesCategorySection from "./MgSalesCategorySection.vue";
export default {
name: "MerchantRelationGroundingReadonly",
components: {
TrafficProviderInformation,
MgBusinessSection,
MgSalesCategorySection,
},
provide () {
return {
size: "mini",
};
},
props: {
trafficProviderData: {
type: Object,
default: () => ({}),
},
businessForm: {
type: Object,
default: () => ({}),
},
productDetails: {
type: Array,
default: () => [],
},
loading: {
type: Boolean,
default: false,
},
},
};
</script>
<style scoped lang="scss">
.merchant-relation-grounding-readonly {
background: #f5f7fa;
padding: 12px 0 16px;
box-sizing: border-box;
.section {
margin-bottom: 12px;
background: #fff;
}
.section-title {
height: 48px;
line-height: 48px;
margin: 0;
padding: 0 20px;
box-sizing: border-box;
font-size: 14px;
font-weight: 600;
color: #333333;
background: #fff;
border-bottom: 1px solid #ebeef5;
}
.section-sales-category {
margin-bottom: 0;
}
::v-deep .grounding-section-traffic .traffic-provider-information-btns {
display: none !important;
}
}
</style>
...@@ -108,7 +108,8 @@ export default { ...@@ -108,7 +108,8 @@ export default {
let productCost = 0; let productCost = 0;
let recyclingFilm = 0; let recyclingFilm = 0;
(productDetails || []).forEach((item) => { (productDetails || []).forEach((item) => {
revenue = NP.plus(revenue, item.revenue || 0); const lineRev = item.estimatedRevenue != null ? item.estimatedRevenue : item.revenue;
revenue = NP.plus(revenue, lineRev || 0);
trafficFee = NP.plus(trafficFee, item.trafficFee || 0); trafficFee = NP.plus(trafficFee, item.trafficFee || 0);
marketFee1 = NP.plus(marketFee1, item.marketFee1 || 0); marketFee1 = NP.plus(marketFee1, item.marketFee1 || 0);
marketFee2 = NP.plus(marketFee2, item.marketFee2 || 0); marketFee2 = NP.plus(marketFee2, item.marketFee2 || 0);
...@@ -140,7 +141,8 @@ export default { ...@@ -140,7 +141,8 @@ export default {
djGpr() { djGpr() {
let revenue = 0; let revenue = 0;
(this.productDetails || []).forEach((item) => { (this.productDetails || []).forEach((item) => {
revenue = NP.plus(revenue, item.revenue || 0); const lineRev = item.estimatedRevenue != null ? item.estimatedRevenue : item.revenue;
revenue = NP.plus(revenue, lineRev || 0);
}); });
if (revenue === 0) return "0.00%"; if (revenue === 0) return "0.00%";
const gpr = NP.times(NP.divide(this.djGrossProfit, revenue), 100); const gpr = NP.times(NP.divide(this.djGrossProfit, revenue), 100);
......
...@@ -28,6 +28,13 @@ ...@@ -28,6 +28,13 @@
<script> <script>
import { MG_SALES_CATEGORY_LIST } from "./mgSalesConstants"; import { MG_SALES_CATEGORY_LIST } from "./mgSalesConstants";
/** 接口历史字段 → 与新 key 等价,便于只读展示回退 */
const MG_FIELD_LEGACY_READ = {
estimatedConversion: "estimatedConversionRate",
estimatedUpgradePrice: "upgradePrice",
estimatedRevenue: "revenue",
};
export default { export default {
name: "MgSalesCategorySection", name: "MgSalesCategorySection",
props: { props: {
...@@ -74,7 +81,9 @@ export default { ...@@ -74,7 +81,9 @@ export default {
}, },
/** 与 SalesCategory.vue 展示一致:仅 null / undefined 显示为 - */ /** 与 SalesCategory.vue 展示一致:仅 null / undefined 显示为 - */
formatField(row, field) { formatField(row, field) {
const v = row[field.key]; const legacy = MG_FIELD_LEGACY_READ[field.key];
const v =
row[field.key] != null ? row[field.key] : legacy != null ? row[legacy] : null;
if (v == null) return "-"; if (v == null) return "-";
return field.unit ? `${v}${field.unit}` : `${v}`; return field.unit ? `${v}${field.unit}` : `${v}`;
}, },
......
import NP from "number-precision";
export function joinIds(mi, listKey, strKey) {
const list = mi[listKey];
const str = mi[strKey];
if (str != null && str !== "") return String(str);
if (Array.isArray(list) && list.length) return list.join(",");
return "";
}
export function resolveSceneName(code, baseSceneList = []) {
if (code == null || code === "") return "";
const hit = baseSceneList.find(
x => String(x.baseSceneCode) === String(code),
);
return hit?.name || String(code);
}
export function storeProfitPerCar(mi) {
const d = mi?.deliveryCount;
const r = mi?.estimatedRevenue ?? mi?.revenue;
if (!d || Number(d) <= 0 || r == null) return "";
return String(NP.round(NP.divide(Number(r), Number(d)), 2));
}
export function buildTrafficProviderData(mi, baseSceneList = []) {
return {
trafficPartyName: mi.trafficPartyName || "",
parentName: mi.parentName || mi.parentMerchantName || "",
sceneTypeName: mi.sceneTypeName || mi.baseSceneName || resolveSceneName(mi.baseSceneCode, baseSceneList) || "",
signingEntityId: mi.signingEntityId != null ? Number(mi.signingEntityId) : null,
signingEntity: mi.signingEntity || mi.signingEntityName || "",
businessMode: mi.businessMode != null ? Number(mi.businessMode) : null,
operationMode: mi.operationMode != null ? Number(mi.operationMode) : null,
serviceMerchant2fId: mi.serviceMerchant2fId != null ? Number(mi.serviceMerchant2fId) : null,
serviceMerchant2fName: mi.serviceMerchant2fName || "",
partnerId: mi.partnerId != null ? Number(mi.partnerId) : (mi.serviceProviderId != null ? Number(mi.serviceProviderId) : null),
partnerName: mi.partnerName || mi.serviceProviderName || "",
parentServiceMerchantName: mi.parentServiceMerchantName || "",
yqMerchantId: mi.yqMerchantId != null ? Number(mi.yqMerchantId) : (mi.parkingStoreId != null ? Number(mi.parkingStoreId) : null),
yqMerchantName: mi.yqMerchantName || mi.parkingStoreName || "",
areaOpId: joinIds(mi, "areaOpIdList", "areaOpId"),
onlineOpId: joinIds(mi, "onlineOpIdList", "onlineOpId"),
regionSupervisorId: joinIds(mi, "regionSupervisorIdList", "regionSupervisorId"),
};
}
export function buildBusinessForm(mi) {
return {
deliveryCount: mi.deliveryCount,
customerTouchRate: mi.customerTouchRate,
personnelCost: mi.personnelCost,
rentCost: mi.rentCost,
depreciationCost: mi.depreciationCost,
otherCost: mi.otherCost,
storeProfitPerCar: storeProfitPerCar(mi),
};
}
import NP from "number-precision";
import { getSceneTypeByBaseSceneCode } from "@/common/sceneBaseSceneCode";
/** 与 MgBusinessSection 中嘀加毛利/毛利率/产值合计一致 */
export function computeDjMetrics(componentData, productDetails) {
const pd = productDetails || [];
const { personnelCost, rentCost, depreciationCost, otherCost } = componentData || {};
let revenue = 0;
let trafficFee = 0;
let marketFee1 = 0;
let marketFee2 = 0;
let incentive1 = 0;
let incentive2 = 0;
let resourceFee = 0;
let productCost = 0;
let recyclingFilm = 0;
pd.forEach((item) => {
revenue = NP.plus(revenue, item.estimatedRevenue != null ? item.estimatedRevenue : item.revenue || 0);
trafficFee = NP.plus(trafficFee, item.trafficFee || 0);
marketFee1 = NP.plus(marketFee1, item.marketFee1 || 0);
marketFee2 = NP.plus(marketFee2, item.marketFee2 || 0);
incentive1 = NP.plus(incentive1, item.incentive1 || 0);
incentive2 = NP.plus(incentive2, item.incentive2 || 0);
resourceFee = NP.plus(resourceFee, item.resourceFee || 0);
productCost = NP.plus(productCost, item.productCost || 0);
recyclingFilm = NP.plus(recyclingFilm, item.recyclingFilm || 0);
});
const sum = NP.minus(
revenue,
NP.plus(
trafficFee,
marketFee1,
marketFee2,
incentive1,
incentive2,
resourceFee,
productCost,
recyclingFilm,
personnelCost || 0,
rentCost || 0,
depreciationCost || 0,
otherCost || 0,
),
);
const djGrossProfit = Math.floor(sum * 100) / 100;
const djGpr = revenue === 0 ? 0 : NP.round(NP.times(NP.divide(djGrossProfit, revenue), 100), 2);
return { djGrossProfit, djGpr, estimatedRevenue: revenue };
}
function joinMultiId(traffic, listKey, scalarKey) {
const list = traffic[listKey];
if (Array.isArray(list) && list.length) return list.join(",");
const s = traffic[scalarKey];
if (s != null && s !== "") return String(s);
return "";
}
function numOrNull(v) {
if (v === "" || v === undefined || v === null) return null;
const n = Number(v);
return Number.isNaN(n) ? null : n;
}
function mapProductDetailBusinessRow(pd) {
const row = {
productType: pd.productType,
productCategory: pd.productCategory,
feeSettlementMode: pd.feeSettlementMode,
penetrationRate: numOrNull(pd.penetrationRate),
conversionRate: numOrNull(pd.conversionRate),
revenuePerCar: numOrNull(pd.revenuePerCar),
estimatedConversion: numOrNull(
pd.estimatedConversion != null ? pd.estimatedConversion : pd.estimatedConversionRate,
),
estimatedUpgradePrice: numOrNull(
pd.estimatedUpgradePrice != null ? pd.estimatedUpgradePrice : pd.upgradePrice,
),
estimatedRevenue: numOrNull(
pd.estimatedRevenue != null ? pd.estimatedRevenue : pd.revenue,
),
recyclingFilm: numOrNull(pd.recyclingFilm),
trafficFee: numOrNull(pd.trafficFee),
marketFee1: numOrNull(pd.marketFee1),
marketFee2: numOrNull(pd.marketFee2),
incentive1: numOrNull(pd.incentive1),
incentive2: numOrNull(pd.incentive2),
resourceFee: numOrNull(pd.resourceFee),
productCost: numOrNull(pd.productCost),
};
if (pd.id != null && pd.id !== "") {
const nid = Number(pd.id);
if (!Number.isNaN(nid)) row.id = nid;
}
if (pd.partyId != null && pd.partyId !== "") {
const pid = Number(pd.partyId);
if (!Number.isNaN(pid)) row.partyId = pid;
}
if (pd.createdBy != null) row.createdBy = pd.createdBy;
if (pd.updatedBy != null) row.updatedBy = pd.updatedBy;
if (pd.deletedFlag != null) row.deletedFlag = pd.deletedFlag;
return row;
}
/**
* addOrUpdateSceneMerchantRefNewOpen 请求体(由 sign/qs 序列化后 POST)
*/
export function buildMerchantOnShelfOpenPayload(options) {
const {
detailQueryBaseSceneCode,
detailQueryMerchantId,
merchantInfo: mi0,
traffic,
businessForm,
productDetailsForSubmit,
} = options;
const mi = mi0 || {};
const sceneFromCode = getSceneTypeByBaseSceneCode(detailQueryBaseSceneCode);
let sceneType = !Number.isNaN(sceneFromCode) ? sceneFromCode : NaN;
if (Number.isNaN(sceneType)) {
const s = mi.scene != null && mi.scene !== "" ? Number(mi.scene) : 0;
sceneType = Number.isNaN(s) ? 0 : s;
}
const trafficPartyId =
mi.trafficPartyId != null && mi.trafficPartyId !== ""
? Number(mi.trafficPartyId)
: detailQueryMerchantId;
const trafficPartyName = (traffic && traffic.trafficPartyName) || mi.trafficPartyName || "";
const yqId =
traffic.yqMerchantId != null && traffic.yqMerchantId !== ""
? Number(traffic.yqMerchantId)
: null;
const yqName = traffic.yqMerchantName || mi.parkingStoreName || "";
const biz = businessForm || {};
const { djGrossProfit, djGpr, estimatedRevenue } = computeDjMetrics(biz, productDetailsForSubmit);
const parentSvcId = mi.parentServiceMerchantId;
const trafficPartyBusinessData = {
trafficPartyId,
trafficPartyName,
parkingStoreId: yqId != null && !Number.isNaN(yqId) ? yqId : null,
parkingStoreName: yqName || "",
serviceProviderId: traffic.partnerId != null ? Number(traffic.partnerId) : null,
parentServiceMerchantId:
parentSvcId != null && parentSvcId !== "" ? Number(parentSvcId) : null,
serviceProviderName: traffic.partnerName || "",
parentServiceMerchantName:
traffic.parentServiceMerchantName || mi.parentServiceMerchantName || "",
serviceMerchant2fId:
traffic.serviceMerchant2fId != null ? Number(traffic.serviceMerchant2fId) : null,
serviceMerchant2fName: traffic.serviceMerchant2fName || "",
signingEntityId:
traffic.signingEntityId != null ? Number(traffic.signingEntityId) : null,
signingEntityName: traffic.signingEntity || "",
businessMode: traffic.businessMode != null ? Number(traffic.businessMode) : null,
operationMode: traffic.operationMode != null ? Number(traffic.operationMode) : null,
storeProfitPerCar: numOrNull(biz.storeProfitPerCar),
djGrossProfit,
djGpr,
deliveryCount: numOrNull(biz.deliveryCount),
customerTouchRate: numOrNull(biz.customerTouchRate),
personnelCost: numOrNull(biz.personnelCost),
rentCost: numOrNull(biz.rentCost),
estimatedRevenue: numOrNull(estimatedRevenue),
depreciation: numOrNull(biz.depreciationCost),
otherCost: numOrNull(biz.otherCost),
areaOpId: joinMultiId(traffic, "areaOpIdList", "areaOpId"),
onlineOpId: joinMultiId(traffic, "onlineOpIdList", "onlineOpId"),
regionSupervisorId: joinMultiId(traffic, "regionSupervisorIdList", "regionSupervisorId"),
};
const productDetailBusinessDataList = (productDetailsForSubmit || []).map(
mapProductDetailBusinessRow,
);
const payload = {
baseSceneCode: String(detailQueryBaseSceneCode),
sceneType,
merchantId: trafficPartyId,
partnerMerchantId:
traffic.partnerId != null ? Number(traffic.partnerId) : null,
trafficPartyBusinessData,
productDetailBusinessDataList,
};
if (yqId != null && !Number.isNaN(yqId)) {
payload.yqMerchantId = yqId;
}
return payload;
}
...@@ -19,9 +19,9 @@ export const MG_SALES_CATEGORY_LIST = [ ...@@ -19,9 +19,9 @@ export const MG_SALES_CATEGORY_LIST = [
{ {
title: "预估经营数据", title: "预估经营数据",
list: [ list: [
{ label: "转化率", key: "estimatedConversionRate", unit: "%" }, { label: "转化率", key: "estimatedConversion", unit: "%" },
{ label: "升级客单价", key: "upgradePrice" }, { label: "升级客单价", key: "estimatedUpgradePrice" },
{ label: "产值", key: "revenue" }, { label: "产值", key: "estimatedRevenue" },
], ],
}, },
{ {
......
...@@ -9,9 +9,14 @@ ...@@ -9,9 +9,14 @@
</el-tabs> </el-tabs>
</div> </div>
<!-- 商户关系 --> <!-- 商户关系(与商户上架编辑页一致的字段与布局) -->
<template v-if="activeName == 'third'"> <template v-if="activeName == 'third'">
<merchantRelationships :form-item="checkDetailItem" /> <merchant-relation-grounding-readonly
:traffic-provider-data="relationTrafficData"
:business-form="relationBusinessForm"
:product-details="relationProductDetails"
:loading="relationLoading"
/>
</template> </template>
<!-- 分账 --> <!-- 分账 -->
...@@ -31,8 +36,6 @@ ...@@ -31,8 +36,6 @@
<el-button @click="handleConfirm" size="small" type="primary"> <el-button @click="handleConfirm" size="small" type="primary">
返回 返回
</el-button> </el-button>
<!-- <el-button size="small"
@click="handleReset"> 返回 </el-button> -->
</div> </div>
</div> </div>
</d2-Container> </d2-Container>
...@@ -41,108 +44,140 @@ ...@@ -41,108 +44,140 @@
<script> <script>
import ledgerAccount from './components/ledgerAccount.vue' import ledgerAccount from './components/ledgerAccount.vue'
import reconciliation from './components/reconciliation.vue' import reconciliation from './components/reconciliation.vue'
import merchantRelationships from './components/merchantRelationships.vue' import MerchantRelationGroundingReadonly from '../merchantGroundingEdit/MerchantRelationGroundingReadonly.vue'
import { buildTrafficProviderData, buildBusinessForm } from '../merchantGroundingEdit/merchantDetailMap'
import { import {
getDistributeRuleApi, getDistributeRuleApi,
getEffectRuleApi, getEffectRuleApi,
getMerchantRelationDetailApi queryMerchantDetail
} from "@api/merchant" } from "@api/merchant"
import { getBaseSceneCodeList } from "@api/productManage"
export default { export default {
name: "MerchantCheckDetail", name: "MerchantCheckDetail",
props: {}, props: {},
data() { data () {
return { return {
activeName: "third", activeName: "third",
merchantRow: {}, merchantRow: {},
// 分账数据
checkDetailItem: {}, checkDetailItem: {},
// 对账数据 checkRecordList: {},
checkRecordList: {} relationLoading: false,
relationTrafficData: {},
relationBusinessForm: {},
relationProductDetails: [],
relationBaseSceneList: []
} }
}, },
created() { created () {
this.getRowItem() this.getRowItem()
}, },
mounted() { mounted () {
// 分账 this.loadMerchantGroundingRelation()
// this.getDistributeRule()
// 商户关系
this.getMerchantRelationDetail()
}, },
methods: { methods: {
async init() { resolveRelationMerchantId (row) {
if (!row) return ''
const raw = row.merchantId ?? row.merchantNo ?? row.trafficPartyId
?? row.trafficPartyMerchantId ?? row.diversionMerchantId ?? row.shopMerchantId
if (raw == null || raw === '') return ''
const n = Number(raw)
return Number.isNaN(n) ? String(raw) : n
},
resolveRowBaseSceneCode (row) {
if (row == null) return ''
const c = row.baseSceneCode
return c != null && c !== '' ? c : ''
},
async init () {
if (this.activeName == "first") { if (this.activeName == "first") {
// 分账
this.getDistributeRule() this.getDistributeRule()
} else if (this.activeName == "second") { } else if (this.activeName == "second") {
// 对账
this.getEffectRule() this.getEffectRule()
} else { } else {
// 商户关系 this.loadMerchantGroundingRelation()
this.getMerchantRelationDetail()
} }
}, },
// 分账 async getDistributeRule () {
async getDistributeRule() {
const params = { const params = {
merchantId: this.merchantRow.merchantId, merchantId: this.merchantRow.merchantId,
sceneType: this.merchantRow.scene, sceneType: this.merchantRow.scene,
expenseCategroyRulsBuildType: 2 expenseCategroyRulsBuildType: 2
} }
const bsc = this.resolveRowBaseSceneCode(this.merchantRow)
if (bsc !== '') params.baseSceneCode = bsc
const res = await getDistributeRuleApi(params) const res = await getDistributeRuleApi(params)
console.log('res: ', res) console.log('res: ', res)
this.checkDetailItem = res this.checkDetailItem = res
}, },
// 对账 async getEffectRule () {
async getEffectRule() {
const params = { const params = {
merchantId: this.merchantRow.merchantId, merchantId: this.merchantRow.merchantId,
sceneType: this.merchantRow.scene sceneType: this.merchantRow.scene
} }
const bsc = this.resolveRowBaseSceneCode(this.merchantRow)
if (bsc !== '') params.baseSceneCode = bsc
const res = await getEffectRuleApi(params) const res = await getEffectRuleApi(params)
console.log(res) console.log(res)
this.checkRecordList = res this.checkRecordList = res
// this.checkRecordList = res?.goodsTypeGroupReconciliationRules
// console.log('res: ', res)
}, },
// 商户关系 async loadMerchantGroundingRelation () {
async getMerchantRelationDetail() { const baseSceneCode = this.resolveRowBaseSceneCode(this.merchantRow)
const params = { if (!baseSceneCode || String(baseSceneCode) === '') {
merchantId: this.merchantRow.merchantId, this.$message.warning('缺少场景编码 baseSceneCode,无法加载商户详情')
scene: this.merchantRow.scene return
}
const midRaw = this.resolveRelationMerchantId(this.merchantRow)
const merchantIdNum = typeof midRaw === 'number' ? midRaw : Number(midRaw)
if (midRaw === '' || midRaw == null || Number.isNaN(merchantIdNum)) {
this.$message.warning('商户ID无效')
return
}
this.relationLoading = true
try {
const scenes = await getBaseSceneCodeList({})
this.relationBaseSceneList = Array.isArray(scenes) ? scenes : []
const res = await queryMerchantDetail({
merchantId: merchantIdNum,
baseSceneCode: String(baseSceneCode)
})
const mi = res?.merchantInfo || res
const pd = res?.productDetails
if (!mi) {
this.$message.error('未获取到商户详情')
return
}
this.relationProductDetails = Array.isArray(pd) ? pd : []
this.relationTrafficData = buildTrafficProviderData(mi, this.relationBaseSceneList)
this.relationBusinessForm = buildBusinessForm(mi)
} catch (e) {
console.error(e)
this.$message.error('加载商户详情失败')
} finally {
this.relationLoading = false
} }
const res = await getMerchantRelationDetailApi(params)
this.checkDetailItem = res
}, },
getRowItem() { getRowItem () {
const params = this.$route.query?.params const params = this.$route.query?.params
if (params) { if (params) {
this.merchantRow = JSON.parse(params) this.merchantRow = JSON.parse(params)
// console.log("is.merchantRow", this.merchantRow)
} }
}, },
handleClick(tab) { handleClick (tab) {
// console.log(tab.name)
this.activeName = tab.name this.activeName = tab.name
this.init() this.init()
}, },
handleConfirm () {
// handleType(num) {
// this.activeType = num
// },
// 保存
handleConfirm() {
this.$router.go(-1) this.$router.go(-1)
}, },
// 取消 handleReset () {
handleReset() {
this.$router.go(-1) this.$router.go(-1)
} }
}, },
components: { components: {
ledgerAccount, ledgerAccount,
reconciliation, reconciliation,
merchantRelationships MerchantRelationGroundingReadonly
}, },
computed: {} computed: {}
} }
...@@ -151,14 +186,10 @@ export default { ...@@ -151,14 +186,10 @@ export default {
$color: #2a58ad; $color: #2a58ad;
.merchant-checkdetail { .merchant-checkdetail {
// height: 100%;
padding-left: 20px; padding-left: 20px;
padding-right: 16px; padding-right: 16px;
padding-bottom: 20px; padding-bottom: 20px;
// overflow-y: auto;
.title {}
.type { .type {
margin-top: 6px; margin-top: 6px;
display: flex; display: flex;
...@@ -229,21 +260,18 @@ $color: #2a58ad; ...@@ -229,21 +260,18 @@ $color: #2a58ad;
.msg { .msg {
padding-bottom: 12px; padding-bottom: 12px;
flex: 1 0 auto; flex: 1 0 auto;
// width: 50%;
display: flex; display: flex;
align-items: flex-start; align-items: flex-start;
line-height: 24px; line-height: 24px;
.msg-title { .msg-title {
width: 138px; width: 138px;
// height: 20px;
font-size: 14px; font-size: 14px;
color: #666666; color: #666666;
text-align: right; text-align: right;
} }
.msg-val { .msg-val {
// height: 20px;
font-size: 14px; font-size: 14px;
color: #1d1d1d; color: #1d1d1d;
text-align: left; text-align: left;
...@@ -261,8 +289,6 @@ $color: #2a58ad; ...@@ -261,8 +289,6 @@ $color: #2a58ad;
font-size: 14px; font-size: 14px;
color: #666666; color: #666666;
.manner {}
.online { .online {
&+.online { &+.online {
margin-left: 44px; margin-left: 44px;
...@@ -282,10 +308,6 @@ $color: #2a58ad; ...@@ -282,10 +308,6 @@ $color: #2a58ad;
border-left: 1px solid #e5e5e5; border-left: 1px solid #e5e5e5;
.type1 { .type1 {
// &:first-child {
// border-top: 1px solid #E5E5E5;
// border-left: 1px solid #E5E5E5;
// }
display: flex; display: flex;
width: 33.33%; width: 33.33%;
height: 38px; height: 38px;
...@@ -301,9 +323,6 @@ $color: #2a58ad; ...@@ -301,9 +323,6 @@ $color: #2a58ad;
} }
.type-val { .type-val {
// flex: 1;
// display: flex;
// color: #1d1d1d;
flex-shrink: 0; flex-shrink: 0;
color: #1d1d1d; color: #1d1d1d;
display: inline-block !important; display: inline-block !important;
...@@ -379,15 +398,6 @@ $color: #2a58ad; ...@@ -379,15 +398,6 @@ $color: #2a58ad;
} }
} }
} }
// .part2 {
// }
// .part3 {
// }
// .part4 {
// }
// .part5 {
// }
} }
.btns { .btns {
......
...@@ -29,11 +29,10 @@ ...@@ -29,11 +29,10 @@
<span :class="{ 'labelColorEff': !formItem.formatEffectEndDate }">{{ "待生效"}}</span> <span :class="{ 'labelColorEff': !formItem.formatEffectEndDate }">{{ "待生效"}}</span>
</span> </span>
</template> </template>
<!-- 商户关系 --> <!-- 商户关系:operationType / createdBy / updatedDate -->
<template v-else> <template v-else>
<span>{{ formItem.formatEffectStartDate }}</span> <span>操作类型:</span>
<span> - </span> <span class="labelColor">{{ formatRelationOperationType(formItem.operationType) }}</span>
<span :class="{ 'labelColor': !formItem.applyEndTime }">{{ formItem.applyEndTime ? formItem.formatEffectEndDate : "生效中"}}</span>
</template> </template>
</span> </span>
<span class="updatedInfo"> <span class="updatedInfo">
...@@ -67,9 +66,11 @@ ...@@ -67,9 +66,11 @@
<reconciliation :form-item="formItem" :items="formItem.typeList" /> <reconciliation :form-item="formItem" :items="formItem.typeList" />
</template> </template>
<!-- 商户关系 --> <!-- 商户关系(与上架/详情对齐的新结构) -->
<template v-if="activeName == 'third'"> <template v-if="activeName == 'third'">
<merchantRelationships :form-item="formItem" /> <merchant-relation-grounding-readonly
v-bind="groundingRelationProps(formItem)"
/>
</template> </template>
</div> </div>
</el-collapse-transition> </el-collapse-transition>
...@@ -94,7 +95,8 @@ import dayjs from "dayjs" ...@@ -94,7 +95,8 @@ import dayjs from "dayjs"
import { getHistoryRecord } from "@api/publicAccount" import { getHistoryRecord } from "@api/publicAccount"
import ledgerAccount from "./components/ledgerAccount.vue" import ledgerAccount from "./components/ledgerAccount.vue"
import reconciliation from "./components/reconciliation.vue" import reconciliation from "./components/reconciliation.vue"
import merchantRelationships from "./components/merchantRelationships.vue" import MerchantRelationGroundingReadonly from '../merchantGroundingEdit/MerchantRelationGroundingReadonly.vue'
import { buildTrafficProviderData, buildBusinessForm } from '../merchantGroundingEdit/merchantDetailMap'
import { import {
getLedgerHistoryRecordApi, getLedgerHistoryRecordApi,
getReconciliationHistoryRecordApi, getReconciliationHistoryRecordApi,
...@@ -102,6 +104,7 @@ import { ...@@ -102,6 +104,7 @@ import {
getLedgerHistoryRecordDetailApi, getLedgerHistoryRecordDetailApi,
getReconciliationHistoryRecordDetailApi getReconciliationHistoryRecordDetailApi
} from "@api/merchant" } from "@api/merchant"
import { getBaseSceneCodeList } from "@api/productManage"
export default { export default {
name: "MerchantCheckRecord", name: "MerchantCheckRecord",
props: { props: {
...@@ -119,7 +122,8 @@ export default { ...@@ -119,7 +122,8 @@ export default {
activeName: "third", activeName: "third",
activeType: 1, activeType: 1,
merchantRow: {}, merchantRow: {},
formArray: [] formArray: [],
relationSceneList: []
} }
}, },
created() { created() {
...@@ -137,6 +141,28 @@ export default { ...@@ -137,6 +141,28 @@ export default {
console.log("is.merchantRow", this.merchantRow) console.log("is.merchantRow", this.merchantRow)
} }
}, },
resolveRowBaseSceneCode(row) {
if (row == null) return ""
const c = row.baseSceneCode
return c != null && c !== "" ? String(c) : ""
},
/** 列表/详情请求统一附加 baseSceneCode(与列表行一致) */
withBaseSceneCode(baseParams) {
const bsc = this.resolveRowBaseSceneCode(this.merchantRow)
if (bsc === "") return baseParams
return { ...baseParams, baseSceneCode: bsc }
},
/** 商户关系历史 operationType:1-新增 2-更新 3-禁用 4-启用 */
formatRelationOperationType(operationType) {
const map = {
1: "新增",
2: "更新",
3: "禁用",
4: "启用",
}
const key = operationType != null ? Number(operationType) : NaN
return !Number.isNaN(key) && map[key] != null ? map[key] : "-"
},
handleClick(tab) { handleClick(tab) {
this.activeName = tab.name this.activeName = tab.name
this.formArray = [] this.formArray = []
...@@ -162,6 +188,7 @@ export default { ...@@ -162,6 +188,7 @@ export default {
getItemDetail(SelectIndex, selectItem) { getItemDetail(SelectIndex, selectItem) {
let eventApi = this.activeName == "first" ? getLedgerHistoryRecordDetailApi : getReconciliationHistoryRecordDetailApi let eventApi = this.activeName == "first" ? getLedgerHistoryRecordDetailApi : getReconciliationHistoryRecordDetailApi
let params = selectItem.enableFlag == 2 ? { ruleAuditId: selectItem?.ruleAuditId } : { effectRecordId: selectItem?.id } let params = selectItem.enableFlag == 2 ? { ruleAuditId: selectItem?.ruleAuditId } : { effectRecordId: selectItem?.id }
params = this.withBaseSceneCode(params)
eventApi(params).then(res => { eventApi(params).then(res => {
// 分账 // 分账
if (this.activeName == "first") { if (this.activeName == "first") {
...@@ -191,10 +218,10 @@ export default { ...@@ -191,10 +218,10 @@ export default {
async getLedgerHistoryRecord() { async getLedgerHistoryRecord() {
const merchantId = this.merchantRow.merchantId const merchantId = this.merchantRow.merchantId
const sceneType = this.merchantRow.scene const sceneType = this.merchantRow.scene
const params = { const params = this.withBaseSceneCode({
merchantId, merchantId,
sceneType sceneType
} })
const res = await getLedgerHistoryRecordApi(params) const res = await getLedgerHistoryRecordApi(params)
if (res.length != 0) { if (res.length != 0) {
const format = "YYYY/MM/DD HH:mm" const format = "YYYY/MM/DD HH:mm"
...@@ -228,10 +255,10 @@ export default { ...@@ -228,10 +255,10 @@ export default {
async getReconciliationHistoryRecord() { async getReconciliationHistoryRecord() {
const merchantId = this.merchantRow.merchantId const merchantId = this.merchantRow.merchantId
const sceneType = this.merchantRow.scene const sceneType = this.merchantRow.scene
const params = { const params = this.withBaseSceneCode({
merchantId, merchantId,
sceneType sceneType
} })
const res = await getReconciliationHistoryRecordApi(params) const res = await getReconciliationHistoryRecordApi(params)
console.log("res: ", res) console.log("res: ", res)
if (res.length != 0) { if (res.length != 0) {
...@@ -265,22 +292,68 @@ export default { ...@@ -265,22 +292,68 @@ export default {
this.formArray = [] this.formArray = []
} }
}, },
groundingRelationProps(formItem) {
const { traffic, business, productDetails } = this.normalizeHistoryToGrounding(formItem)
return {
trafficProviderData: traffic,
businessForm: business,
productDetails,
loading: false,
}
},
/**
* 历史接口:merchantStoreInfoHistory → 商户/流量方与经营映射;
* merchantStoreProductDetailHistoryList → 销售品类(productDetails)。
*/
normalizeHistoryToGrounding(formItem) {
if (formItem == null || typeof formItem !== "object") {
return {
traffic: buildTrafficProviderData({}, this.relationSceneList),
business: buildBusinessForm({}),
productDetails: [],
}
}
const storeInfo =
formItem.merchantStoreInfoHistory != null
? formItem.merchantStoreInfoHistory
: formItem.merchantInfo != null
? formItem.merchantInfo
: formItem
const mi = storeInfo && typeof storeInfo === "object" ? storeInfo : {}
let pd = []
if (Array.isArray(formItem.merchantStoreProductDetailHistoryList)) {
pd = formItem.merchantStoreProductDetailHistoryList
} else if (Array.isArray(formItem.productDetails)) {
pd = formItem.productDetails
}
return {
traffic: buildTrafficProviderData(mi, this.relationSceneList),
business: buildBusinessForm(mi),
productDetails: pd,
}
},
// 商户关系 // 商户关系
async getMerchantRelationRecord() { async getMerchantRelationRecord() {
const merchantId = this.merchantRow.merchantId const merchantId = this.merchantRow.merchantId
const scene = this.merchantRow.scene const scene = this.merchantRow.scene
const params = { const params = this.withBaseSceneCode({
merchantId, merchantId,
scene scene,
})
try {
const scenes = await getBaseSceneCodeList({})
this.relationSceneList = Array.isArray(scenes) ? scenes : []
} catch (e) {
console.warn(e)
this.relationSceneList = []
} }
const res = await getMerchantRelationRecordApi(params) const res = await getMerchantRelationRecordApi(params)
if (res.length != 0) { if (res.length != 0) {
const format = "YYYY/MM/DD HH:mm" const format = "YYYY/MM/DD HH:mm"
this.formArray = res.map((item) => { this.formArray = res.map((item) => {
item.formatEffectEndDate = item.applyEndTime ? dayjs(item.applyEndTime).format(format) : "" const updatedRaw = item.updatedDate != null ? item.updatedDate : item.operateDate
item.formatEffectStartDate = item.applyStartTime ? dayjs(item.applyStartTime).format(format) : "" item.formatUpdatedDate = updatedRaw ? dayjs(updatedRaw).format(format) : "-"
item.formatUpdatedDate = dayjs(item.operateDate).format(format) item.updatedBy = item.createdBy ?? item.operator ?? "-"
item.updatedBy = item.operator
item.show = false item.show = false
return item return item
}) })
...@@ -292,7 +365,7 @@ export default { ...@@ -292,7 +365,7 @@ export default {
components: { components: {
ledgerAccount, ledgerAccount,
reconciliation, reconciliation,
merchantRelationships MerchantRelationGroundingReadonly,
}, },
computed: {} computed: {}
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!