Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
pension
Project
Project
Details
Activity
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
mengmeng
pension
Commits
e60bcc72
Commit
e60bcc72
authored
Mar 12, 2021
by
mlchun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.添加微信消息模板推送
parent
87bba441
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
133 additions
and
2 deletions
+133
-2
WeChatMpConfig.java
hmit-api/src/main/java/io/hmit/config/WeChatMpConfig.java
+38
-0
WechatAccountConfig.java
...api/src/main/java/io/hmit/config/WechatAccountConfig.java
+22
-0
PensionOrderServiceImpl.java
...es/serviceOrder/service/impl/PensionOrderServiceImpl.java
+5
-1
PushMessage.java
hmit-api/src/main/java/io/hmit/service/PushMessage.java
+9
-0
PushMessageImpl.java
...i/src/main/java/io/hmit/service/impl/PushMessageImpl.java
+49
-0
application.yml
hmit-api/src/main/resources/application.yml
+5
-1
pom.xml
pom.xml
+5
-0
No files found.
hmit-api/src/main/java/io/hmit/config/WeChatMpConfig.java
0 → 100644
View file @
e60bcc72
package
io
.
hmit
.
config
;
import
me.chanjar.weixin.mp.api.WxMpConfigStorage
;
import
me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage
;
import
me.chanjar.weixin.mp.api.WxMpService
;
import
me.chanjar.weixin.mp.api.impl.WxMpServiceImpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.stereotype.Component
;
/**
* @Description :
* @Author : Shen Yuanfeng
* @Date: 2021/3/12 16:03
*/
@Component
public
class
WeChatMpConfig
{
@Autowired
private
WechatAccountConfig
wechatAccountConfig
;
@Bean
public
WxMpService
wxMpService
(){
WxMpService
wxMpService
=
new
WxMpServiceImpl
();
wxMpService
.
setWxMpConfigStorage
(
wxMpConfigStorage
());
return
wxMpService
;
}
@Bean
public
WxMpConfigStorage
wxMpConfigStorage
(){
WxMpInMemoryConfigStorage
wxMpConfigStorage
=
new
WxMpInMemoryConfigStorage
();
wxMpConfigStorage
.
setAppId
(
wechatAccountConfig
.
getMpAppId
());
wxMpConfigStorage
.
setSecret
(
wechatAccountConfig
.
getMpAppSecret
());
return
wxMpConfigStorage
;
}
}
hmit-api/src/main/java/io/hmit/config/WechatAccountConfig.java
0 → 100644
View file @
e60bcc72
package
io
.
hmit
.
config
;
import
lombok.Data
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.stereotype.Component
;
/**
* @Description :
* @Author : Shen Yuanfeng
* @Date: 2021/3/12 16:02
*/
@Data
@Component
@ConfigurationProperties
(
prefix
=
"wechat"
)
public
class
WechatAccountConfig
{
private
String
mpAppId
;
private
String
mpAppSecret
;
}
hmit-api/src/main/java/io/hmit/modules/serviceOrder/service/impl/PensionOrderServiceImpl.java
View file @
e60bcc72
...
...
@@ -12,6 +12,7 @@ import io.hmit.modules.serviceOrder.dto.*;
import
io.hmit.modules.serviceOrder.entity.PensionOrderDocumentEntity
;
import
io.hmit.modules.serviceOrder.entity.PensionOrderEntity
;
import
io.hmit.modules.serviceOrder.service.*
;
import
io.hmit.service.PushMessage
;
import
io.hmit.service.UserService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -55,6 +56,9 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe
@Autowired
private
UserService
userService
;
@Autowired
private
PushMessage
pushMessage
;
//查询全部订单
@Override
public
PageData
<
PensionOrderDTO
>
getAllOrderPage
(
Map
<
String
,
Object
>
params
,
Long
userId
)
{
...
...
@@ -85,7 +89,7 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe
save
(
pensionOrderDTO
);
PensionOrderServiceDTO
orderServiceDTO
=
new
PensionOrderServiceDTO
().
assemblePensionOrderService
(
pensionOrderDTO
);
pensionOrderServiceService
.
save
(
orderServiceDTO
);
pushMessage
.
sendMsg
(
pensionOrderDTO
,
userService
.
getUserByUserId
(
pensionOrderDTO
.
getCreator
()).
getOpenid
());
}
@Override
...
...
hmit-api/src/main/java/io/hmit/service/PushMessage.java
0 → 100644
View file @
e60bcc72
package
io
.
hmit
.
service
;
import
io.hmit.modules.serviceOrder.dto.PensionOrderDTO
;
public
interface
PushMessage
{
void
sendMsg
(
PensionOrderDTO
pensionOrderDTO
,
String
openId
);
}
hmit-api/src/main/java/io/hmit/service/impl/PushMessageImpl.java
0 → 100644
View file @
e60bcc72
package
io
.
hmit
.
service
.
impl
;
import
io.hmit.modules.serviceOrder.dto.PensionOrderDTO
;
import
io.hmit.service.PushMessage
;
import
lombok.extern.slf4j.Slf4j
;
import
me.chanjar.weixin.common.exception.WxErrorException
;
import
me.chanjar.weixin.mp.api.WxMpService
;
import
me.chanjar.weixin.mp.bean.template.WxMpTemplateData
;
import
me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.Arrays
;
import
java.util.List
;
/**
* @Description :
* @Author : Shen Yuanfeng
* @Date: 2021/3/12 14:40
*/
@Slf4j
@Service
public
class
PushMessageImpl
implements
PushMessage
{
@Autowired
private
WxMpService
wxMpService
;
@Override
public
void
sendMsg
(
PensionOrderDTO
pensionOrderDTO
,
String
openId
)
{
WxMpTemplateMessage
templateMessage
=
new
WxMpTemplateMessage
();
templateMessage
.
setTemplateId
(
"GsGydVGl-vzOv5aA0LaIdA-FcMM88TEpe37U-lZ6HJ8"
);
templateMessage
.
setToUser
(
openId
);
List
<
WxMpTemplateData
>
data
=
Arrays
.
asList
(
new
WxMpTemplateData
(
"first"
,
"订单预约成功!"
),
new
WxMpTemplateData
(
"keyword1"
,
pensionOrderDTO
.
getServiceName
()),
new
WxMpTemplateData
(
"keyword2"
,
pensionOrderDTO
.
getAppointmentTime
().
toString
()),
new
WxMpTemplateData
(
"keyword3"
,
pensionOrderDTO
.
getStatusName
())
);
templateMessage
.
setData
(
data
);
try
{
wxMpService
.
getTemplateMsgService
().
sendTemplateMsg
(
templateMessage
);
}
catch
(
WxErrorException
e
){
log
.
error
(
"【微信模板消息】发送失败,{}"
,
e
);
}
}
}
hmit-api/src/main/resources/application.yml
View file @
e60bcc72
...
...
@@ -73,3 +73,7 @@ mybatis-plus:
QR
:
# download-path: D:/123/ /home/websoft/java_jar/pension_service/myfile/
download-path
:
/home/websoft/java_jar/pension_service/myfile/
wechat
:
mpAppId
:
wxfa2386639794d998
mpAppSecret
:
8f624f83c9585baa9d1697e24fdffd81
\ No newline at end of file
pom.xml
View file @
e60bcc72
...
...
@@ -195,6 +195,11 @@
<artifactId>
lombok
</artifactId>
<version>
${lombok.version}
</version>
</dependency>
<dependency>
<groupId>
com.github.binarywang
</groupId>
<artifactId>
weixin-java-mp
</artifactId>
<version>
2.7.0
</version>
</dependency>
</dependencies>
<!-- 阿里云maven仓库 -->
...
...
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