Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
YouJia
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 662a9ce5
authored
Oct 13, 2026
by
chenxi
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优加门店上架导入改动提交,判断门店是否上架过,调用D+系统商户关联关系判断而不再使用门店上架数据
1 parent
c6899e13
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
77 deletions
youjia-module-store/src/main/java/com/youjia/store/remote/StoreImportRemoteValidator.java
youjia-module-store/src/main/java/com/youjia/store/remote/StoreImportRemoteValidator.java
View file @
662a9ce
...
...
@@ -23,8 +23,9 @@ import java.util.Set;
*
* <ul>
* <li><b>V1 商户号 + 名称</b>:{@code dj.api.serviceMerchant.listWithPage}(车生活)</li>
* <li><b>V2 场景覆盖</b>:{@code dj.api.oaapproval.store.approve.pageQuery}(门店上架审批),
* 取该商户已完成上架({@code systemStatus=3})的全部 {@code baseSceneCode}</li>
* <li><b>V2 场景覆盖</b>:{@code dj.api.scenemerchantref.findAllSceneByMerchantId}(车生活,
* 10-13 起,旧 {@code dj.api.oaapproval.store.approve.pageQuery} 已废弃),
* 取该商户已开通(关联关系 {@code status=1} 启用中)的全部 {@code baseSceneCode}</li>
* <li><b>V3 产品分类</b>:{@code dj.api.goodsCategoryConfiguration.queryAll}(车生活),全量拉取后本地匹配</li>
* </ul>
*
...
...
@@ -40,21 +41,12 @@ public class StoreImportRemoteValidator {
/** ROP 方法:车生活-服务门店分页 */
private
static
final
String
METHOD_SERVICE_MERCHANT_PAGE
=
"dj.api.serviceMerchant.listWithPage"
;
/** ROP 方法:
门店上架审批分页
*/
private
static
final
String
METHOD_S
TORE_APPROVE_PAGE
=
"dj.api.oaapproval.store.approve.pageQuery
"
;
/** ROP 方法:
按商户查已开通场景(场景-商户关联关系,服务端已过滤启用状态)
*/
private
static
final
String
METHOD_S
CENE_BY_MERCHANT
=
"dj.api.scenemerchantref.findAllSceneByMerchantId
"
;
/** ROP 方法:全部商品类目 */
private
static
final
String
METHOD_GOODS_CATEGORY_ALL
=
"dj.api.goodsCategoryConfiguration.queryAll"
;
/** D+ 系统状态:完成上架更新 */
private
static
final
int
SYSTEM_STATUS_COMPLETED
=
3
;
/** 分页大小(取全量用) */
private
static
final
int
PAGE_SIZE
=
200
;
/** 最大翻页数,防止异常数据导致死循环 */
private
static
final
int
MAX_PAGES
=
50
;
/** 载荷数组候选字段名 */
private
static
final
String
[]
ARRAY_KEYS
=
{
"list"
,
"records"
,
"rows"
,
"data"
,
"result"
,
"items"
};
...
...
@@ -160,9 +152,14 @@ public class StoreImportRemoteValidator {
// ------------------------------------------------------------ V2 场景覆盖
/**
* 校验本次导入的全部业务场景,均已
被该商户在 D+ 上架过
。
* 校验本次导入的全部业务场景,均已
在 D+ 为该商户开通(场景-商户关联关系启用中)
。
*
* @param merchantNo 门店商户号
* <p><b>10-13 变更</b>:不再走 {@code dj.api.oaapproval.store.approve.pageQuery}
* (上架审批 {@code systemStatus=3} 口径),改用 smartcarlife 网关的
* {@code dj.api.scenemerchantref.findAllSceneByMerchantId} —— 单次调用、无分页,
* 服务端已过滤 {@code status==1}(启用),逐行取 {@code baseSceneCode} 比对。</p>
*
* @param merchantNo 门店商户号
* @param requiredCodes 本次导入涉及的去重 baseSceneCode 集合
* @return {@code null} 表示通过;否则返回失败原因
*/
...
...
@@ -174,11 +171,11 @@ public class StoreImportRemoteValidator {
if
(
merchantId
==
null
)
{
return
"门店商户号必须为纯数字:"
+
merchantNo
;
}
Set
<
String
>
shelved
=
loadShelv
edSceneCodes
(
merchantId
);
if
(
shelv
ed
.
isEmpty
())
{
return
"该门店在 D+ 系统没有已
完成上架
的业务场景记录"
;
Set
<
String
>
opened
=
loadOpen
edSceneCodes
(
merchantId
);
if
(
open
ed
.
isEmpty
())
{
return
"该门店在 D+ 系统没有已
开通
的业务场景记录"
;
}
List
<
String
>
missing
=
requiredCodes
.
stream
().
filter
(
code
->
!
shelv
ed
.
contains
(
code
)).
toList
();
List
<
String
>
missing
=
requiredCodes
.
stream
().
filter
(
code
->
!
open
ed
.
contains
(
code
)).
toList
();
if
(!
missing
.
isEmpty
())
{
// 展示用业务场景名称(编码兜底),不要把编码直接抛给用户
List
<
String
>
missingLabels
=
missing
.
stream
()
...
...
@@ -190,71 +187,32 @@ public class StoreImportRemoteValidator {
}
/**
* 取商户在 D+ 已上架({@code systemStatus=3})的全部 baseSceneCode。
* 取商户在 D+ 已开通(场景-商户关联关系 {@code status=1} 启用中)的全部 baseSceneCode。
*
* <p>接口返回 {@code data} 直接是数组,逐行含 {@code baseSceneCode}(String);
* 同一场景若有多行(如关联多个园区店),Set 天然去重。</p>
*/
private
Set
<
String
>
loadShelvedSceneCodes
(
Integer
merchantId
)
{
Set
<
String
>
codes
=
new
LinkedHashSet
<>();
for
(
int
page
=
1
;
page
<=
MAX_PAGES
;
page
++)
{
MultiValueMap
<
String
,
String
>
params
=
new
LinkedMultiValueMap
<>();
params
.
add
(
"currentPage"
,
String
.
valueOf
(
page
));
params
.
add
(
"pageSize"
,
String
.
valueOf
(
PAGE_SIZE
));
params
.
add
(
"merchantId"
,
String
.
valueOf
(
merchantId
));
params
.
add
(
"systemStatus"
,
String
.
valueOf
(
SYSTEM_STATUS_COMPLETED
));
private
Set
<
String
>
loadOpenedSceneCodes
(
Integer
merchantId
)
{
MultiValueMap
<
String
,
String
>
params
=
new
LinkedMultiValueMap
<>();
params
.
add
(
"merchantId"
,
String
.
valueOf
(
merchantId
));
JsonNode
result
=
ropClient
.
invokeForResultNode
(
RopProperties
.
APP_OAAPPROVAL
,
METHOD_STORE_APPROVE_PAGE
,
params
);
JsonNode
array
=
result
==
null
?
null
:
(
result
.
isArray
()
?
result
:
findArrayNode
(
result
));
if
(
array
==
null
||
array
.
isEmpty
())
{
break
;
}
array
.
forEach
(
item
->
collectSceneCodes
(
item
,
codes
));
JsonNode
result
=
ropClient
.
invokeForResultNode
(
RopProperties
.
APP_SMARTCARLIFE
,
METHOD_SCENE_BY_MERCHANT
,
params
);
JsonNode
array
=
result
==
null
?
null
:
(
result
.
isArray
()
?
result
:
findArrayNode
(
result
));
long
total
=
totalOf
(
result
);
if
(
total
>
0
&&
page
*
(
long
)
PAGE_SIZE
>=
total
)
{
break
;
}
if
(
array
.
size
()
<
PAGE_SIZE
)
{
break
;
}
Set
<
String
>
codes
=
new
LinkedHashSet
<>();
if
(
array
!=
null
)
{
array
.
forEach
(
item
->
{
String
code
=
textOrNull
(
item
,
"baseSceneCode"
);
if
(
StringUtils
.
hasText
(
code
))
{
codes
.
add
(
code
);
}
});
}
log
.
info
(
"[导入] 商户 {} 在 D+ 已
上架
场景:{}"
,
merchantId
,
codes
);
log
.
info
(
"[导入] 商户 {} 在 D+ 已
开通
场景:{}"
,
merchantId
,
codes
);
return
codes
;
}
/**
* 汇总单条记录的 baseSceneCode(单值与多值<b>取并集</b>,不是二选一)。
*
* <p>实测 D+ 返回的两种形态(2026-10-09):</p>
* <ul>
* <li><b>新数据(多值)</b>:{@code baseSceneCode = null}、
* {@code baseSceneCodes = ['110101','110201']}(来自流量方明细表去重回填);</li>
* <li><b>旧数据(单值)</b>:{@code baseSceneCode = '100103'}、
* {@code baseSceneCodes = []}(多值列表为<b>空数组</b>,只有主表旧字段有值)。</li>
* </ul>
*
* <p>⚠️ 因此<b>不能</b>「取到多值列表就 return」—— 旧数据的多值列表是空数组,
* 提前 return 会把单值 {@code baseSceneCode} 一起丢掉(曾因此漏掉全部售后众筹场景)。
* 两个来源都收集,取并集。</p>
*/
private
void
collectSceneCodes
(
JsonNode
item
,
Set
<
String
>
codes
)
{
// 多场景:baseSceneCodes / baseSceneCodeList 列表(旧数据可能是空数组)
for
(
String
key
:
new
String
[]{
"baseSceneCodes"
,
"baseSceneCodeList"
})
{
JsonNode
listNode
=
item
.
get
(
key
);
if
(
listNode
!=
null
&&
listNode
.
isArray
())
{
listNode
.
forEach
(
code
->
{
if
(
StringUtils
.
hasText
(
code
.
asText
()))
{
codes
.
add
(
code
.
asText
());
}
});
}
}
// 单场景:主表旧字段 baseSceneCode(与多值列表并存,取并集)
JsonNode
single
=
item
.
get
(
"baseSceneCode"
);
if
(
single
!=
null
&&
StringUtils
.
hasText
(
single
.
asText
()))
{
codes
.
add
(
single
.
asText
());
}
}
// ------------------------------------------------------------ JsonNode 工具
/** 宽松取数组节点 */
...
...
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