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 47e85dee
authored
May 07, 2026
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix bug
1 parent
dc0b8fa2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
30 deletions
src/common/sceneBaseSceneCode.js
src/common/sceneBaseSceneCode.js
View file @
47e85de
/**
* scene_type(前端的 scene 字段)→ baseSceneCode,与商户列表入参一致。
* 优先使用接口同步后的映射(见 syncStaffSceneLabelList);未加载前
使用 LEGACY 兜底
。
* 优先使用接口同步后的映射(见 syncStaffSceneLabelList);未加载前
由 LEGACY_BASE_SCENE_CODE_TO_SCENE_TYPE 推导
。
*/
/** baseSceneCode → sceneType,冷启动 / 接口未返回前兜底(一码一型,避免「sceneType 多条共码」反转丢失) */
const
LEGACY_BASE_SCENE_CODE_TO_SCENE_TYPE
=
{
/**
* base_scene_code → scene_type(与 dj_car_life_scene 全量一一对应,含同 scene_type 多码;兜底唯一数据源)
*/
export
const
LEGACY_BASE_SCENE_CODE_TO_SCENE_TYPE
=
Object
.
freeze
({
100101
:
1
,
100102
:
2
,
110101
:
2
,
110201
:
2
,
110202
:
2
,
100103
:
3
,
110101
:
0
,
110102
:
0
,
110201
:
0
,
110202
:
0
,
120101
:
7
,
};
});
/** 由 LEGACY_BASE_SCENE_CODE_TO_SCENE_TYPE 分组:同 scene_type 多码时默认取数值最小的 base_scene_code */
function
buildLegacySceneTypeDerived
()
{
const
buckets
=
{};
for
(
const
[
codeStr
,
st
]
of
Object
.
entries
(
LEGACY_BASE_SCENE_CODE_TO_SCENE_TYPE
))
{
const
code
=
Number
(
codeStr
);
if
(
Number
.
isNaN
(
code
))
continue
;
if
(
!
buckets
[
st
])
buckets
[
st
]
=
[];
buckets
[
st
].
push
(
code
);
}
const
defaultByType
=
{};
const
allByType
=
{};
for
(
const
st
of
Object
.
keys
(
buckets
))
{
const
sorted
=
Object
.
freeze
(
[...
buckets
[
st
]].
sort
((
a
,
b
)
=>
a
-
b
),
);
const
sn
=
Number
(
st
);
defaultByType
[
sn
]
=
sorted
[
0
];
allByType
[
sn
]
=
sorted
;
}
return
{
defaultByType
:
Object
.
freeze
(
defaultByType
),
allByType
:
Object
.
freeze
(
allByType
),
};
}
const
_legacySceneTypeDerived
=
buildLegacySceneTypeDerived
();
/** @type {Readonly<Record<number, number>>} */
const
LEGACY_SCENE_TYPE_TO_DEFAULT_BASE_SCENE_CODE
=
_legacySceneTypeDerived
.
defaultByType
;
/**
* sceneType → 默认 baseSceneCode(与历史 getBaseSceneCodeBySceneType 行为一致:同类型多码时取约定主码)
* 注意:0 与 2 历史上均曾落到 110101,仅作路由/入参默认,细粒度以 baseSceneCode 为准。
* scene_type → 该类型下全部 base_scene_code(由 LEGACY_BASE_SCENE_CODE_TO_SCENE_TYPE 推导,升序)
*/
const
LEGACY_SCENE_TYPE_TO_BASE_SCENE_CODE
=
{
0
:
110101
,
1
:
100101
,
2
:
110101
,
3
:
100103
,
7
:
120101
,
};
export
const
LEGACY_SCENE_TYPE_TO_ALL_BASE_SCENE_CODES
=
_legacySceneTypeDerived
.
allByType
;
/** @type {Map<number, number>} sceneType → baseSceneCode(数字),仅 status===1 的接口数据 */
let
dynamicSceneTypeToBaseSceneCode
=
new
Map
();
/** @type {Map<string, number>} 规范化 baseSceneCode 字符串 → sceneType */
/** @type {Map<string, number>} 规范化 baseSceneCode 字符串 → sceneType
,与 syncStaffSceneLabelList 同步
*/
let
dynamicBaseSceneCodeToSceneType
=
new
Map
();
/**
...
...
@@ -64,13 +91,10 @@ export function syncStaffSceneLabelList(payload) {
const
raw
=
item
.
baseSceneCode
;
if
(
raw
==
null
||
raw
===
""
)
continue
;
const
codeNum
=
Number
(
raw
);
const
codeKey
=
Number
.
isNaN
(
codeNum
)
?
String
(
raw
).
trim
()
:
String
(
codeNum
);
if
(
!
codeKey
)
continue
;
if
(
Number
.
isNaN
(
codeNum
))
continue
;
typeToCode
.
set
(
st
,
codeNum
);
codeToType
.
set
(
codeKey
,
st
);
codeToType
.
set
(
String
(
codeNum
)
,
st
);
}
dynamicSceneTypeToBaseSceneCode
=
typeToCode
;
...
...
@@ -84,16 +108,17 @@ export function syncStaffSceneLabelList(payload) {
export
function
getSceneTypeByBaseSceneCode
(
baseSceneCode
)
{
if
(
baseSceneCode
==
null
||
baseSceneCode
===
""
)
return
NaN
;
const
n
=
Number
(
baseSceneCode
);
const
key
=
Number
.
isNaN
(
n
)
?
String
(
baseSceneCode
).
trim
()
:
String
(
n
);
const
strKey
=
Number
.
isNaN
(
n
)
?
String
(
baseSceneCode
).
trim
()
:
String
(
n
);
if
(
!
strKey
)
return
NaN
;
if
(
dynamicBaseSceneCodeToSceneType
.
has
(
k
ey
))
{
return
dynamicBaseSceneCodeToSceneType
.
get
(
k
ey
);
if
(
dynamicBaseSceneCodeToSceneType
.
has
(
strK
ey
))
{
return
dynamicBaseSceneCodeToSceneType
.
get
(
strK
ey
);
}
const
legacyKey
=
Number
.
isNaN
(
n
)
?
k
ey
:
n
;
const
legacyKey
=
Number
.
isNaN
(
n
)
?
strK
ey
:
n
;
const
hit
=
LEGACY_BASE_SCENE_CODE_TO_SCENE_TYPE
[
legacyKey
]
??
LEGACY_BASE_SCENE_CODE_TO_SCENE_TYPE
[
k
ey
];
LEGACY_BASE_SCENE_CODE_TO_SCENE_TYPE
[
strK
ey
];
return
hit
!==
undefined
?
hit
:
NaN
;
}
...
...
@@ -111,11 +136,11 @@ export function getBaseSceneCodeBySceneType(scene) {
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
LEGACY_SCENE_TYPE_TO_BASE_SCENE_CODE
,
n
LEGACY_SCENE_TYPE_TO_
DEFAULT_
BASE_SCENE_CODE
,
n
,
)
)
{
return
LEGACY_SCENE_TYPE_TO_BASE_SCENE_CODE
[
n
];
return
LEGACY_SCENE_TYPE_TO_
DEFAULT_
BASE_SCENE_CODE
[
n
];
}
return
110101
;
...
...
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