Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张云鹏
/
uc-consumer
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
be34f2c3
...
be34f2c3fc7c9b060542702f7e1d1baf4af55604
authored
2022-06-13 09:31:57 +0800
by
xianghan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.为关注业务添加必要的日志
1 parent
28189ec9
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
10 deletions
src/main/java/com/topdraw/business/process/service/impl/UserOperationServiceImpl.java
src/main/java/com/topdraw/mq/consumer/WeiXinEventConsumer.java
src/main/java/com/topdraw/resttemplate/RestTemplateClient.java
src/main/java/com/topdraw/business/process/service/impl/UserOperationServiceImpl.java
View file @
be34f2c
...
...
@@ -334,56 +334,70 @@ public class UserOperationServiceImpl implements UserOperationService {
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
rollbackFor
=
Exception
.
class
)
public
void
asyncSubscribe
(
MemberAndWeixinUserDTO
memberAndWeixinUserDTO
)
{
log
.
info
(
"微信关注业务开始"
);
UserWeixinDTO
userWeixinDTO
=
memberAndWeixinUserDTO
.
getUserWeixinDTO
();
log
.
info
(
"小屏侧传过来的微信账号信息 ==>> userWeixinDTO ==>> {}"
,
userWeixinDTO
);
String
openid
=
userWeixinDTO
.
getOpenid
();
String
unionid
=
userWeixinDTO
.
getUnionid
();
String
appid
=
userWeixinDTO
.
getAppid
();
MemberDTO
memberDTO
=
memberAndWeixinUserDTO
.
getMemberDTO
();
log
.
info
(
"小屏侧传过来的会员信息 ==>> memberDTO ==>> {}"
,
memberDTO
);
UserWeixinDTO
_userWeixinDTO
=
this
.
userWeixinService
.
findFirstByUnionIdAndAppIdAndOpenId
(
unionid
,
appid
,
openid
);
// 有账号
if
(
Objects
.
nonNull
(
_userWeixinDTO
.
getId
()))
{
log
.
info
(
"账号存在,检查会员是否存在"
);
UserWeixinDTO
_userWeixinDTO0
=
this
.
userWeixinService
.
findFirstByAppIdAndOpenId
(
appid
,
openid
);
// 会员存在
if
(
Objects
.
nonNull
(
_userWeixinDTO0
.
getMemberId
()))
{
log
.
info
(
"会员存在,修改账号的关注状态, 关注状态 status ==>> {}"
,
userWeixinDTO
.
getStatus
());
// 账号存在,修改账号和会员
this
.
updateWeixin
(
_userWeixinDTO
,
userWeixinDTO
);
MemberDTO
_memberDTO
=
this
.
memberService
.
findById
(
_userWeixinDTO
.
getMemberId
());
MemberDTO
memberDTO0
=
memberAndWeixinUserDTO
.
getMemberDTO
();
memberDTO0
.
setUserIptvId
(
_memberDTO
.
getUserIptvId
());
log
.
info
(
"会员存在,修改会员的绑定和vip标识"
,
userWeixinDTO
.
getStatus
());
this
.
updateMember
(
_memberDTO
,
memberDTO0
);
// 有账号无会员
}
else
{
log
.
info
(
"当前账号会员不存在"
);
// 是否存在会员
UserWeixinDTO
userWeixinDTO1
=
this
.
userWeixinService
.
findFirstByUnionId
(
unionid
);
log
.
info
(
"检查是否有其他账号存在, 其他账号信息 ==>> {}"
,
userWeixinDTO1
);
// 有其他账号
if
(
Objects
.
nonNull
(
userWeixinDTO1
.
getId
()))
{
log
.
info
(
"存在其他账号,检查其他账号是否有会员"
);
Long
memberId
=
userWeixinDTO1
.
getMemberId
();
if
(
Objects
.
nonNull
(
memberId
))
{
userWeixinDTO
.
setMemberId
(
memberId
);
MemberDTO
memberDTO0
=
this
.
memberService
.
findById
(
memberId
);
log
.
info
(
"其他账号有会员,会员信息 ==>> {}"
,
memberDTO0
);
MemberDTO
memberDTO1
=
memberAndWeixinUserDTO
.
getMemberDTO
();
log
.
info
(
"开始同步会员信息"
);
this
.
updateMember
(
memberDTO0
,
memberDTO1
);
}
else
{
log
.
info
(
"其他账号无会员"
);
MemberDTO
memberDTO1
=
memberAndWeixinUserDTO
.
getMemberDTO
();
Member
member
=
new
Member
();
BeanUtils
.
copyProperties
(
memberDTO1
,
member
);
member
.
setId
(
null
);
log
.
info
(
"为当前账号创建会员,会员信息 ==>> {}"
,
member
);
MemberDTO
_memberDTO1
=
this
.
memberService
.
create
(
member
);
userWeixinDTO
.
setMemberId
(
_memberDTO1
.
getId
());
}
}
log
.
info
(
"开始修改账号信息"
);
this
.
updateWeixin
(
_userWeixinDTO
,
userWeixinDTO
);
}
...
...
@@ -391,41 +405,56 @@ public class UserOperationServiceImpl implements UserOperationService {
// 无账号
}
else
{
log
.
info
(
"当前账号不存在,检查其他账号是否存在"
);
// 是否存在会员
UserWeixinDTO
userWeixinDTO1
=
this
.
userWeixinService
.
findFirstByUnionId
(
unionid
);
// 有其他账号
if
(
Objects
.
nonNull
(
userWeixinDTO1
.
getId
()))
{
log
.
info
(
"其他账号存在, 其他账号信息 ==>> {}"
,
userWeixinDTO1
);
log
.
info
(
"检查其他账号是否有会员"
);
Long
memberId
=
userWeixinDTO1
.
getMemberId
();
if
(
Objects
.
nonNull
(
memberId
))
{
userWeixinDTO
.
setMemberId
(
memberId
);
MemberDTO
memberDTO0
=
this
.
memberService
.
findById
(
memberId
);
log
.
info
(
"其他账号有会员,会员信息 ==>> {}"
,
memberDTO0
);
MemberDTO
memberDTO1
=
memberAndWeixinUserDTO
.
getMemberDTO
();
log
.
info
(
"开始同步会员信息"
);
this
.
updateMember
(
memberDTO0
,
memberDTO1
);
}
else
{
log
.
info
(
"其他账号无会员"
);
MemberDTO
memberDTO1
=
memberAndWeixinUserDTO
.
getMemberDTO
();
Member
member
=
new
Member
();
BeanUtils
.
copyProperties
(
memberDTO1
,
member
);
member
.
setId
(
null
);
log
.
info
(
"为当前账号创建会员,会员信息 ==>> {}"
,
member
);
MemberDTO
_memberDTO1
=
this
.
memberService
.
create
(
member
);
userWeixinDTO
.
setMemberId
(
_memberDTO1
.
getId
());
}
}
else
{
log
.
info
(
"无其他账号存在"
);
MemberDTO
memberDTO1
=
memberAndWeixinUserDTO
.
getMemberDTO
();
Member
member
=
new
Member
();
BeanUtils
.
copyProperties
(
memberDTO1
,
member
);
member
.
setId
(
null
);
log
.
info
(
"为当前账号创建会员,会员信息 ==>> {}"
,
member
);
MemberDTO
_memberDTO1
=
this
.
memberService
.
create
(
member
);
userWeixinDTO
.
setMemberId
(
_memberDTO1
.
getId
());
}
log
.
info
(
"开始创建微信账号"
);
this
.
createWeixin
(
userWeixinDTO
);
}
...
...
@@ -478,6 +507,7 @@ public class UserOperationServiceImpl implements UserOperationService {
Member
member
=
new
Member
();
BeanUtils
.
copyProperties
(
memberDTO
,
member
);
log
.
info
(
"会员入库结果 ==>> member ==>> {}"
,
member
);
return
this
.
memberService
.
update
(
member
);
}
...
...
@@ -504,6 +534,8 @@ public class UserOperationServiceImpl implements UserOperationService {
UserWeixin
userWeixin
=
new
UserWeixin
();
BeanUtils
.
copyProperties
(
weixinDTO
,
userWeixin
);
log
.
info
(
"账号入库结果 ==>> userWeixin ==>> {}"
,
userWeixin
);
this
.
userWeixinService
.
update
(
userWeixin
);
}
...
...
src/main/java/com/topdraw/mq/consumer/WeiXinEventConsumer.java
View file @
be34f2c
...
...
@@ -47,7 +47,7 @@ public class WeiXinEventConsumer {
@RabbitHandler
@RabbitListener
(
queues
=
"#{rabbitMqSourceConfig.getWechatQueue()}"
,
containerFactory
=
"#{rabbitMqSourceConfig.getWechatSource()}"
,
autoStartup
=
"#{rabbitMqSourceConfig.getWechatStartUp()}"
,
ackMode
=
"
MANUAL
"
)
autoStartup
=
"#{rabbitMqSourceConfig.getWechatStartUp()}"
,
ackMode
=
"
AUTO
"
)
@Transactional
public
void
subOrUnSubEvent
(
Channel
channel
,
Message
message
,
String
content
)
throws
IOException
{
try
{
...
...
@@ -61,23 +61,32 @@ public class WeiXinEventConsumer {
String
openid
=
wechatMsg
.
getString
(
"FromUserName"
);
String
msgType
=
wechatMsg
.
getString
(
"MsgType"
);
if
(
"event"
.
equals
(
msgType
))
{
String
event
=
wechatMsg
.
getString
(
"Event"
);
String
eventKey
=
wechatMsg
.
getString
(
"EventKey"
);
log
.
info
(
"event ==>> {}"
,
event
);
SubscribeBean
subscribeBean
=
new
SubscribeBean
();
subscribeBean
.
setAppid
(
appid
);
subscribeBean
.
setOpenid
(
openid
);
subscribeBean
.
setUnionid
(
unionid
);
subscribeBean
.
setEventKey
(
eventKey
);
if
(
event
.
equals
(
"subscribe"
))
if
(
event
.
equals
(
"subscribe"
))
{
log
.
info
(
"send subscribe request start"
);
this
.
restTemplateClient
.
subscribe
(
subscribeBean
);
log
.
info
(
"send subscribe request end "
);
}
if
(
event
.
equals
(
"unsubscribe"
))
if
(
event
.
equals
(
"unsubscribe"
))
{
log
.
info
(
"send unsubscribe request start"
);
this
.
restTemplateClient
.
unsubscribe
(
subscribeBean
);
log
.
info
(
"send unsubscribe request end"
);
}
channel
.
basicAck
(
message
.
getMessageProperties
().
getDeliveryTag
(),
false
);
//
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
}
}
catch
(
Exception
e
)
{
...
...
src/main/java/com/topdraw/resttemplate/RestTemplateClient.java
View file @
be34f2c
...
...
@@ -97,7 +97,9 @@ public class RestTemplateClient {
HashMap
<
Object
,
Object
>
objectObjectHashMap
=
new
HashMap
<>();
objectObjectHashMap
.
put
(
"content"
,
content
);
log
.
info
(
"reobjectObjectHashMap ===>> [{}]"
,
objectObjectHashMap
);
restTemplate
.
postForEntity
(
url
,
objectObjectHashMap
,
String
.
class
);
log
.
info
(
"unsubscribe ===>> success"
);
/*ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, subscribeBean, String.class);
String entityBody = "";
if (responseEntity.getStatusCode().is2xxSuccessful()) {
...
...
@@ -113,8 +115,9 @@ public class RestTemplateClient {
HashMap
<
String
,
String
>
objectObjectHashMap
=
new
HashMap
<>();
objectObjectHashMap
.
put
(
"content"
,
content
);
log
.
info
(
"objectObjectHashMap ===>> [{}]"
,
objectObjectHashMap
);
log
.
info
(
"
re
objectObjectHashMap ===>> [{}]"
,
objectObjectHashMap
);
restTemplate
.
postForEntity
(
url
,
objectObjectHashMap
,
String
.
class
);
log
.
info
(
"send subscribe request ===>> success"
);
/*ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, subscribeBean, String.class);
String entityBody = "";
if (responseEntity.getStatusCode().is2xxSuccessful()) {
...
...
Please
register
or
sign in
to post a comment