Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_backend
Commits
8ea975a9
Commit
8ea975a9
authored
Jul 03, 2024
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
订阅消息
parent
929298f7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
121 additions
and
5 deletions
+121
-5
ch-wx-api/src/main/java/com/wwdz/ch/wx/config/WebMvcConfiguration.java
.../main/java/com/wwdz/ch/wx/config/WebMvcConfiguration.java
+1
-1
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/SpecialPerformanceServiceImpl.java
...h/wx/impl/distribution/SpecialPerformanceServiceImpl.java
+71
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/job/SpecialPerformanceNoticeJob.java
.../java/com/wwdz/ch/wx/job/SpecialPerformanceNoticeJob.java
+33
-4
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/distribution/SpecialPerformanceService.java
...ch/wx/service/distribution/SpecialPerformanceService.java
+2
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/distribution/SpecialPerformanceController.java
.../ch/wx/web/distribution/SpecialPerformanceController.java
+14
-0
No files found.
ch-wx-api/src/main/java/com/wwdz/ch/wx/config/WebMvcConfiguration.java
View file @
8ea975a9
...
@@ -45,7 +45,7 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
...
@@ -45,7 +45,7 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
"/wx/returnOrder/**"
,
"/wx/distributionOrder/confirmSigned"
,
"/wx/distributionOrder/delivery"
,
"/wx/distributionOrder/cancel"
,
"/wx/returnOrder/**"
,
"/wx/distributionOrder/confirmSigned"
,
"/wx/distributionOrder/delivery"
,
"/wx/distributionOrder/cancel"
,
"/wx/distributionOrder/refund"
,
"/wx/distributionOrder/refund"
,
"/wx/supplierItem/findItemsOfCurrentDistributor"
,
"/wx/selfPage/updateSwitch"
,
"/wx/supplierItem/findHomePage"
,
"/wx/supplierItem/findItemsOfCurrentDistributor"
,
"/wx/selfPage/updateSwitch"
,
"/wx/supplierItem/findHomePage"
,
"/wx/specialPerformance/sendMsg"
"/wx/specialPerformance/sendMsg"
,
"/wx/specialPerformance/sendMsgTest"
//下列路径上线注释
//下列路径上线注释
/*,"/wx/specialPerformance/**"
/*,"/wx/specialPerformance/**"
, "/wx/supplierItem/**", "/wx/shareRecord/**", "/wx/distributionOrder/**", "/wx/selfPage/**", "/wx/auctionRecord/**",
, "/wx/supplierItem/**", "/wx/shareRecord/**", "/wx/distributionOrder/**", "/wx/selfPage/**", "/wx/auctionRecord/**",
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/SpecialPerformanceServiceImpl.java
View file @
8ea975a9
...
@@ -6,8 +6,10 @@ import com.wwdz.ch.core.consts.AuctionEnum;
...
@@ -6,8 +6,10 @@ import com.wwdz.ch.core.consts.AuctionEnum;
import
com.wwdz.ch.core.consts.DisposableSubscribeRecordEnum
;
import
com.wwdz.ch.core.consts.DisposableSubscribeRecordEnum
;
import
com.wwdz.ch.core.consts.DistributionEnum
;
import
com.wwdz.ch.core.consts.DistributionEnum
;
import
com.wwdz.ch.core.consts.SpecialPerformanceEnum
;
import
com.wwdz.ch.core.consts.SpecialPerformanceEnum
;
import
com.wwdz.ch.core.entity.AuctionOfferNoticeMsg
;
import
com.wwdz.ch.core.entity.SupplierItemVo
;
import
com.wwdz.ch.core.entity.SupplierItemVo
;
import
com.wwdz.ch.core.notify.AliSmsSender
;
import
com.wwdz.ch.core.notify.AliSmsSender
;
import
com.wwdz.ch.core.service.SendMsgService
;
import
com.wwdz.ch.core.type.PageSearchResult
;
import
com.wwdz.ch.core.type.PageSearchResult
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.core.util.MediaUtil
;
import
com.wwdz.ch.core.util.MediaUtil
;
...
@@ -78,6 +80,9 @@ public class SpecialPerformanceServiceImpl implements SpecialPerformanceService
...
@@ -78,6 +80,9 @@ public class SpecialPerformanceServiceImpl implements SpecialPerformanceService
@Autowired
@Autowired
SpecialPerformanceItemFollowDao
specialPerformanceItemFollowDao
;
SpecialPerformanceItemFollowDao
specialPerformanceItemFollowDao
;
@Autowired
SendMsgService
sendMsgService
;
private
final
static
String
SPECIAL_PERFORMANCE_URL
=
"/pages/saleSpecialList/index"
;
private
final
static
String
SPECIAL_PERFORMANCE_URL
=
"/pages/saleSpecialList/index"
;
private
final
static
String
SPECIAL_PERFORMANCE_PROGRESS_SEND_MSG_KEY
=
"SPECIAL_PERFORMANCE_PROGRESS_SEND_MSG_KEY:"
;
private
final
static
String
SPECIAL_PERFORMANCE_PROGRESS_SEND_MSG_KEY
=
"SPECIAL_PERFORMANCE_PROGRESS_SEND_MSG_KEY:"
;
...
@@ -510,6 +515,72 @@ public class SpecialPerformanceServiceImpl implements SpecialPerformanceService
...
@@ -510,6 +515,72 @@ public class SpecialPerformanceServiceImpl implements SpecialPerformanceService
}
}
return
Result
.
failed
();
return
Result
.
failed
();
}
}
@Override
public
void
sendMsgTest
()
{
SpecialPerformanceRequestDto
specialPerformanceRequestDto
=
new
SpecialPerformanceRequestDto
();
specialPerformanceRequestDto
.
setState
(
SpecialPerformanceEnum
.
StateEnum
.
PREVIEW
.
getCode
());
Date
now
=
new
Date
();
Instant
startInstant
=
now
.
toInstant
().
plus
(
Duration
.
ofMinutes
(
20
));
Date
startTime
=
Date
.
from
(
startInstant
);
specialPerformanceRequestDto
.
setStartQueryTime
(
startTime
);
specialPerformanceRequestDto
.
setEndQueryTime
(
now
);
List
<
SpecialPerformance
>
specialPerformanceList
=
specialPerformanceDao
.
find
(
specialPerformanceRequestDto
);
logger
.
info
(
"test------------------ 即将开始的专场个数为 {}"
,
specialPerformanceList
.
size
());
if
(
CollectionUtils
.
isEmpty
(
specialPerformanceList
))
{
return
;
}
SpecialPerformance
specialPerformance
=
specialPerformanceList
.
get
(
0
);
logger
.
info
(
"当前即将开始的专场id:{}, 名称为 {} "
,
specialPerformance
.
getId
(),
specialPerformance
.
getTitle
());
//发送专场开始订阅通知
DisposableSubscribeRecordRequestDto
disposableSubscribeRecordRequestDto
=
new
DisposableSubscribeRecordRequestDto
();
disposableSubscribeRecordRequestDto
.
setTargetId
(
Long
.
valueOf
(
specialPerformance
.
getId
()));
disposableSubscribeRecordRequestDto
.
setType
(
DisposableSubscribeRecordEnum
.
TypeEnum
.
PRE_START
.
getType
());
boolean
hasNextPage
=
true
;
int
page
=
1
;
String
url
=
wxAppletApi
.
getUrlLink
(
SPECIAL_PERFORMANCE_URL
,
"specialId="
+
specialPerformance
.
getId
());
String
msg
=
specialPerformance
.
getTitle
()
+
"将在"
+
DateUtils
.
toString
(
specialPerformance
.
getStartTime
())
+
"开始,请前往"
+
url
+
"查看"
;
while
(
hasNextPage
)
{
List
<
DisposableSubscribeRecord
>
disposableSubscribeRecordList
=
disposableSubscribeRecordDao
.
findList
(
disposableSubscribeRecordRequestDto
);
PageInfo
pageInfo
=
new
PageInfo
(
disposableSubscribeRecordList
);
for
(
DisposableSubscribeRecord
disposableSubscribeRecord
:
disposableSubscribeRecordList
)
{
sendStartSubscribeMsg
(
specialPerformance
,
disposableSubscribeRecord
,
msg
);
}
if
(
pageInfo
.
isHasNextPage
())
{
page
=
page
+
1
;
disposableSubscribeRecordRequestDto
.
setPage
(
page
);
logger
.
info
(
"要发送专场开始订阅消息的用户数据总页数为 : {}, 当前为 : {}"
,
pageInfo
.
getPages
(),
page
);
}
else
{
logger
.
info
(
"============= 发送专场开始订阅消息循环结束 ============="
);
break
;
}
}
logger
.
info
(
"================专场id: {}, 即将开始通知消息全部发送成功 =============="
,
specialPerformance
.
getId
());
}
private
void
sendStartSubscribeMsg
(
SpecialPerformance
specialPerformance
,
DisposableSubscribeRecord
disposableSubscribeRecord
,
String
msg
){
AuctionOfferNoticeMsg
auctionOfferNoticeMsg
=
new
AuctionOfferNoticeMsg
();
auctionOfferNoticeMsg
.
setSpecialPerformanceTitle
(
specialPerformance
.
getTitle
());
auctionOfferNoticeMsg
.
setSpecialPerformanceStartTime
(
DateUtils
.
toString
(
specialPerformance
.
getStartTime
()));
auctionOfferNoticeMsg
.
setOpenId
(
disposableSubscribeRecord
.
getOpenid
());
auctionOfferNoticeMsg
.
setSpecialId
(
specialPerformance
.
getId
());
Result
result
=
sendMsgService
.
sendSpecialPerformanceStartMsg
(
auctionOfferNoticeMsg
);
if
(!
result
.
getSuccess
())
{
String
errorCode
=
JsonUtils
.
getValueByPath
(
result
.
getData
().
toString
(),
"errcode"
);
//用户为订阅消息,43101用户未订阅消息;43108并发下发消息给同一个粉丝,这两种情况表示用户不需要被通知
if
(!
"43101"
.
equals
(
errorCode
)
&&
!
"43108"
.
equals
(
errorCode
))
{
//发订阅消息送失败发短信
long
userId
=
disposableSubscribeRecord
.
getUserId
();
aliSmsSender
.
sendSms
(
userId
,
msg
);
}
}
//订阅状态改为无效
disposableSubscribeRecordDao
.
updateInvalid
(
disposableSubscribeRecord
.
getOpenid
(),
disposableSubscribeRecord
.
getTargetId
(),
disposableSubscribeRecord
.
getTemplateId
());
}
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/job/SpecialPerformanceNoticeJob.java
View file @
8ea975a9
...
@@ -43,6 +43,7 @@ import java.time.Duration;
...
@@ -43,6 +43,7 @@ import java.time.Duration;
import
java.time.Instant
;
import
java.time.Instant
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -125,7 +126,7 @@ public class SpecialPerformanceNoticeJob {
...
@@ -125,7 +126,7 @@ public class SpecialPerformanceNoticeJob {
}
finally
{
}
finally
{
if
(
lock
!=
null
&&
lock
.
isHeldByCurrentThread
())
{
if
(
lock
!=
null
&&
lock
.
isHeldByCurrentThread
())
{
lock
.
unlock
();
lock
.
unlock
();
logger
.
info
(
"======================== 线程id: {} ,专场
即将开始
通知任务执行结束, 释放锁成功 ========================"
,
Thread
.
currentThread
().
getId
());
logger
.
info
(
"======================== 线程id: {} ,专场通知任务执行结束, 释放锁成功 ========================"
,
Thread
.
currentThread
().
getId
());
}
}
}
}
}
}
...
@@ -164,7 +165,7 @@ public class SpecialPerformanceNoticeJob {
...
@@ -164,7 +165,7 @@ public class SpecialPerformanceNoticeJob {
List
<
DisposableSubscribeRecord
>
disposableSubscribeRecordList
=
disposableSubscribeRecordDao
.
findList
(
disposableSubscribeRecordRequestDto
);
List
<
DisposableSubscribeRecord
>
disposableSubscribeRecordList
=
disposableSubscribeRecordDao
.
findList
(
disposableSubscribeRecordRequestDto
);
PageInfo
pageInfo
=
new
PageInfo
(
disposableSubscribeRecordList
);
PageInfo
pageInfo
=
new
PageInfo
(
disposableSubscribeRecordList
);
for
(
DisposableSubscribeRecord
disposableSubscribeRecord
:
disposableSubscribeRecordList
)
{
for
(
DisposableSubscribeRecord
disposableSubscribeRecord
:
disposableSubscribeRecordList
)
{
sendSubscribeMsg
(
specialPerformance
,
disposableSubscribeRecord
,
msg
);
sendS
tartS
ubscribeMsg
(
specialPerformance
,
disposableSubscribeRecord
,
msg
);
}
}
if
(
pageInfo
.
isHasNextPage
())
{
if
(
pageInfo
.
isHasNextPage
())
{
page
=
page
+
1
;
page
=
page
+
1
;
...
@@ -218,7 +219,7 @@ public class SpecialPerformanceNoticeJob {
...
@@ -218,7 +219,7 @@ public class SpecialPerformanceNoticeJob {
List
<
DisposableSubscribeRecord
>
disposableSubscribeRecordList
=
disposableSubscribeRecordDao
.
findList
(
disposableSubscribeRecordRequestDto
);
List
<
DisposableSubscribeRecord
>
disposableSubscribeRecordList
=
disposableSubscribeRecordDao
.
findList
(
disposableSubscribeRecordRequestDto
);
PageInfo
pageInfo
=
new
PageInfo
(
disposableSubscribeRecordList
);
PageInfo
pageInfo
=
new
PageInfo
(
disposableSubscribeRecordList
);
for
(
DisposableSubscribeRecord
disposableSubscribeRecord
:
disposableSubscribeRecordList
)
{
for
(
DisposableSubscribeRecord
disposableSubscribeRecord
:
disposableSubscribeRecordList
)
{
sendSubscribeMsg
(
specialPerformance
,
disposableSubscribeRecord
,
msg
);
send
End
SubscribeMsg
(
specialPerformance
,
disposableSubscribeRecord
,
msg
);
}
}
if
(
pageInfo
.
isHasNextPage
())
{
if
(
pageInfo
.
isHasNextPage
())
{
page
=
page
+
1
;
page
=
page
+
1
;
...
@@ -237,11 +238,12 @@ public class SpecialPerformanceNoticeJob {
...
@@ -237,11 +238,12 @@ public class SpecialPerformanceNoticeJob {
}
}
private
void
sendSubscribeMsg
(
SpecialPerformance
specialPerformance
,
DisposableSubscribeRecord
disposableSubscribeRecord
,
String
msg
){
private
void
sendS
tartS
ubscribeMsg
(
SpecialPerformance
specialPerformance
,
DisposableSubscribeRecord
disposableSubscribeRecord
,
String
msg
){
AuctionOfferNoticeMsg
auctionOfferNoticeMsg
=
new
AuctionOfferNoticeMsg
();
AuctionOfferNoticeMsg
auctionOfferNoticeMsg
=
new
AuctionOfferNoticeMsg
();
auctionOfferNoticeMsg
.
setSpecialPerformanceTitle
(
specialPerformance
.
getTitle
());
auctionOfferNoticeMsg
.
setSpecialPerformanceTitle
(
specialPerformance
.
getTitle
());
auctionOfferNoticeMsg
.
setSpecialPerformanceStartTime
(
DateUtils
.
toString
(
specialPerformance
.
getStartTime
()));
auctionOfferNoticeMsg
.
setSpecialPerformanceStartTime
(
DateUtils
.
toString
(
specialPerformance
.
getStartTime
()));
auctionOfferNoticeMsg
.
setOpenId
(
disposableSubscribeRecord
.
getOpenid
());
auctionOfferNoticeMsg
.
setOpenId
(
disposableSubscribeRecord
.
getOpenid
());
auctionOfferNoticeMsg
.
setSpecialId
(
specialPerformance
.
getId
());
Result
result
=
sendMsgService
.
sendSpecialPerformanceStartMsg
(
auctionOfferNoticeMsg
);
Result
result
=
sendMsgService
.
sendSpecialPerformanceStartMsg
(
auctionOfferNoticeMsg
);
if
(!
result
.
getSuccess
())
{
if
(!
result
.
getSuccess
())
{
String
errorCode
=
JsonUtils
.
getValueByPath
(
result
.
getData
().
toString
(),
"errcode"
);
String
errorCode
=
JsonUtils
.
getValueByPath
(
result
.
getData
().
toString
(),
"errcode"
);
...
@@ -257,6 +259,33 @@ public class SpecialPerformanceNoticeJob {
...
@@ -257,6 +259,33 @@ public class SpecialPerformanceNoticeJob {
}
}
private
void
sendEndSubscribeMsg
(
SpecialPerformance
specialPerformance
,
DisposableSubscribeRecord
disposableSubscribeRecord
,
String
msg
){
AuctionOfferNoticeMsg
auctionOfferNoticeMsg
=
new
AuctionOfferNoticeMsg
();
auctionOfferNoticeMsg
.
setSpecialPerformanceTitle
(
specialPerformance
.
getTitle
());
auctionOfferNoticeMsg
.
setSpecialPerformanceStartTime
(
DateUtils
.
toString
(
specialPerformance
.
getStartTime
()));
auctionOfferNoticeMsg
.
setSpecialPerformanceEndTime
(
DateUtils
.
toString
(
specialPerformance
.
getEndTime
()));
Date
now
=
new
Date
();
long
minutes
=
specialPerformance
.
getEndTime
().
getTime
()
-
now
.
getTime
();
long
surplusMinutes
=
TimeUnit
.
MINUTES
.
convert
(
minutes
,
TimeUnit
.
MILLISECONDS
);
auctionOfferNoticeMsg
.
setSpecialPerformanceSurplusTime
(
"距离专场结束还有"
+
surplusMinutes
+
"分钟"
);
auctionOfferNoticeMsg
.
setOpenId
(
disposableSubscribeRecord
.
getOpenid
());
auctionOfferNoticeMsg
.
setSpecialId
(
specialPerformance
.
getId
());
Result
result
=
sendMsgService
.
sendSpecialPerformanceEndMsg
(
auctionOfferNoticeMsg
);
if
(!
result
.
getSuccess
())
{
String
errorCode
=
JsonUtils
.
getValueByPath
(
result
.
getData
().
toString
(),
"errcode"
);
//用户为订阅消息,43101用户未订阅消息;43108并发下发消息给同一个粉丝,这两种情况表示用户不需要被通知
if
(!
"43101"
.
equals
(
errorCode
)
&&
!
"43108"
.
equals
(
errorCode
))
{
//发订阅消息送失败发短信
long
userId
=
disposableSubscribeRecord
.
getUserId
();
aliSmsSender
.
sendSms
(
userId
,
msg
);
}
}
//订阅状态改为无效
disposableSubscribeRecordDao
.
updateInvalid
(
disposableSubscribeRecord
.
getOpenid
(),
disposableSubscribeRecord
.
getTargetId
(),
disposableSubscribeRecord
.
getTemplateId
());
}
/**
/**
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/distribution/SpecialPerformanceService.java
View file @
8ea975a9
...
@@ -33,5 +33,7 @@ public interface SpecialPerformanceService {
...
@@ -33,5 +33,7 @@ public interface SpecialPerformanceService {
*/
*/
Result
sendMsg
();
Result
sendMsg
();
void
sendMsgTest
();
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/distribution/SpecialPerformanceController.java
View file @
8ea975a9
...
@@ -86,5 +86,19 @@ public class SpecialPerformanceController {
...
@@ -86,5 +86,19 @@ public class SpecialPerformanceController {
}
}
@ApiOperation
(
value
=
"发送专场订阅消息测试"
)
@GetMapping
(
"/sendMsgTest"
)
public
Result
sendMsgTest
()
{
logger
.
info
(
">>>>>>>>>>> 发送专场订阅消息测试 <<<<<<<<<<<<<"
);
try
{
specialPerformanceService
.
sendMsgTest
();
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
info
(
"发送专场订阅消息测试 error :{}"
,
e
);
}
return
Result
.
failed
();
}
}
}
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