记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董敬伟
liquidnet-bus-v1
Commits
b74ea203
Commit
b74ea203
authored
Aug 06, 2026
by
姜秀龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
补充主动查询逻辑
parent
44065b25
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
37 deletions
+43
-37
GoblinMailTrackServiceImpl.java
...rvice/goblin/service/impl/GoblinMailTrackServiceImpl.java
+43
-37
No files found.
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/service/impl/GoblinMailTrackServiceImpl.java
View file @
b74ea203
...
@@ -118,6 +118,8 @@ public class GoblinMailTrackServiceImpl implements IGoblinMailTrackService {
...
@@ -118,6 +118,8 @@ public class GoblinMailTrackServiceImpl implements IGoblinMailTrackService {
return
;
return
;
}
}
doSubscribe
(
orderId
,
mailId
,
mailNo
,
com
,
cache
);
doSubscribe
(
orderId
,
mailId
,
mailNo
,
com
,
cache
);
// 订阅成功也立刻主动查一次,避免等推送才有 track
queryAndOverwriteTrack
(
orderId
,
mailId
,
com
,
mailNo
,
"query"
);
}
}
@Override
@Override
...
@@ -129,54 +131,58 @@ public class GoblinMailTrackServiceImpl implements IGoblinMailTrackService {
...
@@ -129,54 +131,58 @@ public class GoblinMailTrackServiceImpl implements IGoblinMailTrackService {
// 统一用包裹真实 mailId(兼容误传 mailNo)
// 统一用包裹真实 mailId(兼容误传 mailNo)
mailId
=
mailVo
.
getMailId
();
mailId
=
mailVo
.
getMailId
();
GoblinMailTrackCache
cache
=
redisUtils
.
getMailTrackCache
(
mailId
);
GoblinMailTrackCache
cache
=
redisUtils
.
getMailTrackCache
(
mailId
);
boolean
emptyOrUnsubscribed
=
cache
==
null
if
(
cache
==
null
||
cache
.
getSubscribe
()
==
null
)
{
||
cache
.
getSubscribe
()
==
null
||
!
Boolean
.
TRUE
.
equals
(
cache
.
getSubscribe
().
getSubscribed
());
if
(
emptyOrUnsubscribed
)
{
String
com
=
resolveAndPersistCom
(
orderId
,
mailVo
);
if
(
cache
==
null
)
{
cache
=
newEmptyCache
(
orderId
,
mailId
);
cache
=
newEmptyCache
(
orderId
,
mailId
);
}
}
GoblinMailTrackSubscribeVo
sub
=
cache
.
getSubscribe
();
ensureMonthCounter
(
sub
);
boolean
finished
=
"shutdown"
.
equals
(
sub
.
getSubscribeStatus
())
||
(
cache
.
getTrack
()
!=
null
&&
"1"
.
equals
(
cache
.
getTrack
().
getIscheck
()));
// 已结束且已有轨迹:只读
if
(
finished
&&
hasTrackData
(
cache
))
{
return
cache
;
}
String
com
=
resolveAndPersistCom
(
orderId
,
mailVo
);
if
(
StringUtils
.
isBlank
(
com
))
{
if
(
StringUtils
.
isBlank
(
com
))
{
updateSubscribeFail
(
cache
,
"无法识别快递公司编码"
);
updateSubscribeFail
(
cache
,
"无法识别快递公司编码"
);
redisUtils
.
setMailTrackCache
(
mailId
,
cache
);
redisUtils
.
setMailTrackCache
(
mailId
,
cache
);
return
cache
;
return
cache
;
}
}
// 未订阅成功时可尝试首次订阅(未超限)
ensureMonthCounter
(
cache
.
getSubscribe
());
boolean
overQuota
=
Boolean
.
TRUE
.
equals
(
sub
.
getQuotaExceeded
())
if
(!
Boolean
.
TRUE
.
equals
(
cache
.
getSubscribe
().
getQuotaExceeded
())
||
(
sub
.
getSubscribeCount
()
!=
null
&&
sub
.
getSubscribeCount
()
>=
MAX_SUBSCRIBE_PER_MONTH
);
&&
(
cache
.
getSubscribe
().
getSubscribeCount
()
==
null
||
cache
.
getSubscribe
().
getSubscribeCount
()
<
MAX_SUBSCRIBE_PER_MONTH
)
if
(
overQuota
)
{
&&
!
Boolean
.
TRUE
.
equals
(
cache
.
getSubscribe
().
getSubscribed
()))
{
sub
.
setQuotaExceeded
(
true
);
}
// 订阅与查轨迹分开:已订阅则不再订;未订阅/需重订且未超限才订
boolean
needSubscribe
=
!
finished
&&
!
overQuota
&&
(!
Boolean
.
TRUE
.
equals
(
sub
.
getSubscribed
())
||
Boolean
.
TRUE
.
equals
(
sub
.
getNeedResubscribe
()));
if
(
needSubscribe
)
{
doSubscribe
(
orderId
,
mailId
,
mailVo
.
getMailNo
(),
com
,
cache
);
doSubscribe
(
orderId
,
mailId
,
mailVo
.
getMailNo
(),
com
,
cache
);
cache
=
redisUtils
.
getMailTrackCache
(
mailId
);
cache
=
redisUtils
.
getMailTrackCache
(
mailId
);
if
(
cache
==
null
)
{
if
(
cache
==
null
)
{
cache
=
newEmptyCache
(
orderId
,
mailId
);
cache
=
newEmptyCache
(
orderId
,
mailId
);
}
}
sub
=
cache
.
getSubscribe
();
}
}
// 无轨迹(或超限只能靠主动查)则 QueryTrackMap
if
(!
hasTrackData
(
cache
)
||
overQuota
)
{
queryAndOverwriteTrack
(
orderId
,
mailId
,
com
,
mailVo
.
getMailNo
(),
"query"
);
queryAndOverwriteTrack
(
orderId
,
mailId
,
com
,
mailVo
.
getMailNo
(),
"query"
);
GoblinMailTrackCache
latest
=
redisUtils
.
getMailTrackCache
(
mailId
);
GoblinMailTrackCache
latest
=
redisUtils
.
getMailTrackCache
(
mailId
);
return
latest
!=
null
?
latest
:
cache
;
return
latest
!=
null
?
latest
:
cache
;
}
}
GoblinMailTrackSubscribeVo
sub
=
cache
.
getSubscribe
();
if
(
"shutdown"
.
equals
(
sub
.
getSubscribeStatus
())
||
"1"
.
equals
(
cache
.
getTrack
()
!=
null
?
cache
.
getTrack
().
getIscheck
()
:
null
))
{
return
cache
;
return
cache
;
}
}
if
(
Boolean
.
TRUE
.
equals
(
sub
.
getQuotaExceeded
())
||
(
sub
.
getSubscribeCount
()
!=
null
&&
sub
.
getSubscribeCount
()
>=
MAX_SUBSCRIBE_PER_MONTH
))
{
/** 是否已有可用轨迹点(仅有 subscribe、track 为空不算) */
sub
.
setQuotaExceeded
(
true
);
private
boolean
hasTrackData
(
GoblinMailTrackCache
cache
)
{
String
com
=
resolveAndPersistCom
(
orderId
,
mailVo
);
return
cache
!=
null
queryAndOverwriteTrack
(
orderId
,
mailId
,
com
,
mailVo
.
getMailNo
(),
"query"
);
&&
cache
.
getTrack
()
!=
null
return
redisUtils
.
getMailTrackCache
(
mailId
);
&&
!
CollectionUtils
.
isEmpty
(
cache
.
getTrack
().
getData
());
}
if
(
Boolean
.
TRUE
.
equals
(
sub
.
getNeedResubscribe
()))
{
String
com
=
resolveAndPersistCom
(
orderId
,
mailVo
);
doSubscribe
(
orderId
,
mailId
,
mailVo
.
getMailNo
(),
com
,
cache
);
queryAndOverwriteTrack
(
orderId
,
mailId
,
com
,
mailVo
.
getMailNo
(),
"query"
);
return
redisUtils
.
getMailTrackCache
(
mailId
);
}
return
cache
;
}
}
@Override
@Override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment