Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
dbe5c08e
Commit
dbe5c08e
authored
Feb 01, 2023
by
王亮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
format code.
parent
f6d61138
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
33 deletions
+36
-33
BlackHoleRegisteredEventListener.java
...antgroup/xyqb/event/BlackHoleRegisteredEventListener.java
+36
-33
No files found.
src/main/java/cn/quantgroup/xyqb/event/BlackHoleRegisteredEventListener.java
View file @
dbe5c08e
package
cn
.
quantgroup
.
xyqb
.
event
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.model.UserRegisterParam
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
java.time.LocalDate
;
...
...
@@ -14,43 +13,47 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.stereotype.Component
;
/**
* 用户注册发送给合同中心事件监听
*/
@Slf4j
@Component
public
class
BlackHoleRegisteredEventListener
implements
ApplicationListener
<
RegisterEvent
>
{
@Value
(
"${registered.notify.black.hole.rabbitmq.connection.exchange}"
)
private
String
exchange
;
@Value
(
"${registered.notify.black.hole.rabbitmq.connection.routingKey}"
)
private
String
routingKey
;
@Resource
private
RabbitTemplate
registeredNotifyBlackHoleRabbitTemplate
;
@Value
(
"${registered.notify.black.hole.rabbitmq.connection.exchange}"
)
private
String
exchange
;
@Value
(
"${registered.notify.black.hole.rabbitmq.connection.routingKey}"
)
private
String
routingKey
;
@Resource
private
RabbitTemplate
registeredNotifyBlackHoleRabbitTemplate
;
// 用户注册合同中心模版id
@Value
(
"#{'${register.templateids}'.split(',')}"
)
private
List
<
Long
>
templateIds
;
// 用户注册合同中心模版id
@Value
(
"#{'${register.templateids}'.split(',')}"
)
private
List
<
Long
>
templateIds
;
@Override
public
void
onApplicationEvent
(
RegisterEvent
event
)
{
User
user
=
event
.
getUserRegisterParam
().
getUser
();
log
.
info
(
"onApplicationEvent cn.quantgroup.xyqb.event.BlackHoleRegisteredEventListener start userId = 【{}】, registerFrom = 【{}】"
,
user
.
getId
(),
event
);
LocalDate
signDate
=
LocalDate
.
now
();
String
dateStr
=
signDate
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy年MM月dd日"
));
int
day
=
signDate
.
getDayOfMonth
();
// 信用钱包服务与隐私协议
templateIds
.
forEach
(
id
->{
JSONObject
fields
=
new
JSONObject
();
fields
.
put
(
"phoneNo"
,
user
.
getPhoneNo
());
fields
.
put
(
"genarateDateStr"
,
dateStr
);
fields
.
put
(
"day"
,
day
);
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"userId"
,
user
.
getId
());
json
.
put
(
"mustReal"
,
false
);
json
.
put
(
"templateId"
,
id
);
json
.
put
(
"fields"
,
fields
);
JSONArray
array
=
new
JSONArray
();
array
.
add
(
json
);
registeredNotifyBlackHoleRabbitTemplate
.
convertAndSend
(
exchange
,
routingKey
,
array
.
toString
());
});
}
@Override
public
void
onApplicationEvent
(
RegisterEvent
event
)
{
User
user
=
event
.
getUserRegisterParam
().
getUser
();
log
.
info
(
"onApplicationEvent start userId = 【{}】, registerFrom = 【{}】"
,
user
.
getId
(),
event
);
LocalDate
signDate
=
LocalDate
.
now
();
String
dateStr
=
signDate
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy年MM月dd日"
));
int
day
=
signDate
.
getDayOfMonth
();
// 信用钱包服务与隐私协议
templateIds
.
forEach
(
id
->
{
JSONObject
fields
=
new
JSONObject
();
fields
.
put
(
"phoneNo"
,
user
.
getPhoneNo
());
fields
.
put
(
"genarateDateStr"
,
dateStr
);
fields
.
put
(
"day"
,
day
);
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"userId"
,
user
.
getId
());
json
.
put
(
"mustReal"
,
false
);
json
.
put
(
"templateId"
,
id
);
json
.
put
(
"fields"
,
fields
);
JSONArray
array
=
new
JSONArray
();
array
.
add
(
json
);
registeredNotifyBlackHoleRabbitTemplate
.
convertAndSend
(
exchange
,
routingKey
,
array
.
toString
());
});
}
}
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