Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dmhub-plugin
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
qinxunjia
dmhub-plugin
Commits
9a996165
Commit
9a996165
authored
Jul 07, 2020
by
fuwanli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"审核通知,创建模板"
parent
5e15acc3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
5 deletions
+84
-5
DmHubApi.java
src/main/java/com/bgy/sms/channel/api/DmHubApi.java
+20
-1
BgySmsServiceImpl.java
...m/bgy/sms/channel/bgy/service/impl/BgySmsServiceImpl.java
+20
-1
SmsTemplateInfo.java
...n/java/com/bgy/sms/repository/domain/SmsTemplateInfo.java
+9
-0
MessageServiceImpl.java
...ain/java/com/bgy/sms/service/impl/MessageServiceImpl.java
+34
-2
application.yml
src/main/resources/application.yml
+1
-1
No files found.
src/main/java/com/bgy/sms/channel/api/DmHubApi.java
View file @
9a996165
package
com
.
bgy
.
sms
.
channel
.
api
;
package
com
.
bgy
.
sms
.
channel
.
api
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.bgy.sms.channel.bgy.config.BgySMSConfig
;
import
com.bgy.sms.channel.dmHub.config.DmHubConfig
;
import
com.bgy.sms.channel.dmHub.config.DmHubConfig
;
import
com.bgy.sms.channel.dto.*
;
import
com.bgy.sms.channel.dto.*
;
import
com.bgy.sms.config.ResponseCode
;
import
com.bgy.sms.config.ResponseCode
;
import
com.bgy.sms.repository.domain.SmsTemplateInfo
;
import
com.bgy.sms.service.MessageService
;
import
com.bgy.sms.service.MessageService
;
import
com.bgy.sms.service.SmsTemplateService
;
import
com.bgy.util.HttpUtil
;
import
com.bgy.util.Md5Util
;
import
com.bgy.util.Md5Util
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -20,7 +24,8 @@ public class DmHubApi {
...
@@ -20,7 +24,8 @@ public class DmHubApi {
@Autowired
@Autowired
private
MessageService
messageService
;
private
MessageService
messageService
;
@Autowired
private
SmsTemplateService
smsTemplateService
;
@GetMapping
(
"/ping"
)
@GetMapping
(
"/ping"
)
public
String
ping
()
{
public
String
ping
()
{
...
@@ -44,6 +49,8 @@ public class DmHubApi {
...
@@ -44,6 +49,8 @@ public class DmHubApi {
return
new
DmHubResponse
(
"555"
,
"接口请求签名校验不通过"
);
return
new
DmHubResponse
(
"555"
,
"接口请求签名校验不通过"
);
}
}
response
=
messageService
.
createTemplate
(
params
);
response
=
messageService
.
createTemplate
(
params
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"创建模板短信异常"
,
e
);
log
.
error
(
"创建模板短信异常"
,
e
);
response
=
new
DmHubResponse
(
"999"
,
"创建模板短信异常"
);
response
=
new
DmHubResponse
(
"999"
,
"创建模板短信异常"
);
...
@@ -133,4 +140,16 @@ public class DmHubApi {
...
@@ -133,4 +140,16 @@ public class DmHubApi {
log
.
info
(
"**********单条发送出参*******:{}"
,
JSONObject
.
toJSONString
(
response
));
log
.
info
(
"**********单条发送出参*******:{}"
,
JSONObject
.
toJSONString
(
response
));
return
response
;
return
response
;
}
}
public
static
void
main
(
String
[]
args
)
{
String
z
=
"{\"err\":\"成功\",\"package\":\"{\\\"data\\\":\\\"8fff70a0-d751-4d2b-b4c6-17edec541ec7\\\"}\",\"ret\":\"0\"} "
;
JSONObject
retJson
=
JSONObject
.
parseObject
(
z
);
String
data
=
retJson
.
getString
(
"package"
);
JSONObject
retJson2
=
JSONObject
.
parseObject
(
data
);
String
data2
=
retJson2
.
getString
(
"data"
);
//String retStr = HttpUtil.sendPost(BgySMSConfig.url, JSONObject.toJSONString(z));
System
.
out
.
println
(
data2
);
}
}
}
src/main/java/com/bgy/sms/channel/bgy/service/impl/BgySmsServiceImpl.java
View file @
9a996165
...
@@ -2,6 +2,7 @@ package com.bgy.sms.channel.bgy.service.impl;
...
@@ -2,6 +2,7 @@ package com.bgy.sms.channel.bgy.service.impl;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.bgy.sms.channel.bgy.config.BgySMSConfig
;
import
com.bgy.sms.channel.bgy.config.BgySMSConfig
;
import
com.bgy.sms.channel.bgy.dto.CLBizResponse
;
import
com.bgy.sms.channel.bgy.dto.CLBizResponse
;
import
com.bgy.sms.channel.bgy.dto.TemplateNotify
;
import
com.bgy.sms.channel.bgy.dto.TemplateNotify
;
...
@@ -9,6 +10,7 @@ import com.bgy.sms.channel.bgy.service.BgySmsService;
...
@@ -9,6 +10,7 @@ import com.bgy.sms.channel.bgy.service.BgySmsService;
import
com.bgy.sms.channel.bgy.utils.SendSmsUtil
;
import
com.bgy.sms.channel.bgy.utils.SendSmsUtil
;
import
com.bgy.sms.channel.dmHub.service.DmHubService
;
import
com.bgy.sms.channel.dmHub.service.DmHubService
;
import
com.bgy.sms.config.ResponseCode
;
import
com.bgy.sms.config.ResponseCode
;
import
com.bgy.sms.repository.domain.SmsTemplateInfo
;
import
com.bgy.sms.service.SmsTemplateService
;
import
com.bgy.sms.service.SmsTemplateService
;
import
com.bgy.util.Md5Util
;
import
com.bgy.util.Md5Util
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -39,6 +41,8 @@ public class BgySmsServiceImpl implements BgySmsService {
...
@@ -39,6 +41,8 @@ public class BgySmsServiceImpl implements BgySmsService {
@Autowired
@Autowired
private
DmHubService
dmHubService
;
private
DmHubService
dmHubService
;
@Autowired
private
SmsTemplateService
smsTemplateService
;
@Override
@Override
public
CLBizResponse
sendSms
(
String
mobile
,
String
content
,
String
areaId
)
throws
Exception
{
public
CLBizResponse
sendSms
(
String
mobile
,
String
content
,
String
areaId
)
throws
Exception
{
log
.
info
(
"进入碧桂园短信发送接口"
);
log
.
info
(
"进入碧桂园短信发送接口"
);
...
@@ -81,7 +85,22 @@ public class BgySmsServiceImpl implements BgySmsService {
...
@@ -81,7 +85,22 @@ public class BgySmsServiceImpl implements BgySmsService {
*/
*/
@Override
@Override
public
void
asyncNotify
(
TemplateNotify
templateNotify
)
{
public
void
asyncNotify
(
TemplateNotify
templateNotify
)
{
log
.
info
(
"碧桂园短信模板审核通知接口入参:{}"
,
templateNotify
);
//模板流水号
String
templateRecordId
=
templateNotify
.
getData
();
String
status
=
templateNotify
.
getAuditStatus
();
String
auditReason
=
templateNotify
.
getAuditReason
();
SmsTemplateInfo
smsTemplateInfo
=
smsTemplateService
.
selectOne
(
new
EntityWrapper
<
SmsTemplateInfo
>().
eq
(
"template_record_id"
,
templateRecordId
));
if
(
smsTemplateInfo
==
null
){
throw
new
RuntimeException
(
ResponseCode
.
NO_TEMPLATE
.
getMsg
());
}
if
(
"1"
.
equals
(
status
)){
smsTemplateInfo
.
setStatus
(
"normal"
);
}
else
{
smsTemplateInfo
.
setStatus
(
"abnormal"
);
}
smsTemplateInfo
.
setUpRejectMsg
(
auditReason
);
smsTemplateService
.
updateById
(
smsTemplateInfo
);
}
}
}
}
src/main/java/com/bgy/sms/repository/domain/SmsTemplateInfo.java
View file @
9a996165
...
@@ -39,6 +39,15 @@ public class SmsTemplateInfo {
...
@@ -39,6 +39,15 @@ public class SmsTemplateInfo {
private
String
upTemplateId
;
private
String
upTemplateId
;
private
String
upRejectMsg
;
private
String
upRejectMsg
;
private
String
params
;
private
String
params
;
private
String
templateRecordId
;
public
String
getTemplateRecordId
()
{
return
templateRecordId
;
}
public
void
setTemplateRecordId
(
String
templateRecordId
)
{
this
.
templateRecordId
=
templateRecordId
;
}
public
SmsTemplateInfo
()
{
public
SmsTemplateInfo
()
{
...
...
src/main/java/com/bgy/sms/service/impl/MessageServiceImpl.java
View file @
9a996165
...
@@ -17,6 +17,7 @@ import com.bgy.sms.service.DmCodeService;
...
@@ -17,6 +17,7 @@ import com.bgy.sms.service.DmCodeService;
import
com.bgy.sms.service.MessageService
;
import
com.bgy.sms.service.MessageService
;
import
com.bgy.sms.service.SmsTemplateService
;
import
com.bgy.sms.service.SmsTemplateService
;
import
com.bgy.sms.service.bean.TemplateChangeBean
;
import
com.bgy.sms.service.bean.TemplateChangeBean
;
import
com.bgy.util.HttpUtil
;
import
com.bgy.util.id.IdHandler
;
import
com.bgy.util.id.IdHandler
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -94,6 +95,36 @@ public class MessageServiceImpl implements MessageService {
...
@@ -94,6 +95,36 @@ public class MessageServiceImpl implements MessageService {
if
(!
insert
)
{
if
(!
insert
)
{
log
.
error
(
"模板插入DB异常:【{}】"
,
JSONObject
.
toJSONString
(
info
));
log
.
error
(
"模板插入DB异常:【{}】"
,
JSONObject
.
toJSONString
(
info
));
return
new
DmHubResponse
(
ResponseCode
.
SYSTEM_ERROR
);
return
new
DmHubResponse
(
ResponseCode
.
SYSTEM_ERROR
);
}
else
{
String
pkID
=
info
.
getId
()+
""
;
String
content
=
info
.
getContent
();
JSONObject
param
=
new
JSONObject
();
param
.
put
(
"api"
,
"AddTemplate"
);
param
.
put
(
"appid"
,
""
);
param
.
put
(
"security"
,
""
);
param
.
put
(
"content"
,
content
);
param
.
put
(
"areaid"
,
"FHY"
);
param
.
put
(
"pkID"
,
pkID
);
param
.
put
(
"account"
,
""
);
param
.
put
(
"templateType"
,
""
);
String
retStr
=
HttpUtil
.
sendPost
(
BgySMSConfig
.
url
,
JSONObject
.
toJSONString
(
param
));
JSONObject
retJson
=
JSONObject
.
parseObject
(
retStr
);
String
ret
=
retJson
.
getString
(
"ret"
);
String
reePackage
=
retJson
.
getString
(
"package"
);
if
(
ret
.
equals
(
0
)){
JSONObject
Json
=
JSONObject
.
parseObject
(
reePackage
);
String
data
=
Json
.
getString
(
"data"
);
info
.
setTemplateRecordId
(
data
);
info
.
setId
(
Long
.
parseLong
(
pkID
));
smsTemplateService
.
updateById
(
info
);
}
responseDTO
.
setCode
(
ResponseCode
.
SUCCESS
.
getCode
());
responseDTO
.
setError
(
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
info
)));
return
responseDTO
;
}
}
}
catch
(
Exception
exception
)
{
}
catch
(
Exception
exception
)
{
log
.
error
(
"创建模板业务逻辑异常,错误信息"
,
exception
);
log
.
error
(
"创建模板业务逻辑异常,错误信息"
,
exception
);
...
@@ -130,7 +161,8 @@ public class MessageServiceImpl implements MessageService {
...
@@ -130,7 +161,8 @@ public class MessageServiceImpl implements MessageService {
String
t
=
g
;
String
t
=
g
;
g
=
Matcher
.
quoteReplacement
(
g
);
g
=
Matcher
.
quoteReplacement
(
g
);
g
=
escapeRegex
(
g
);
g
=
escapeRegex
(
g
);
upSendStr
=
upSendStr
.
replaceAll
(
g
,
"\\{\\$var\\}"
);
// upSendStr = upSendStr.replaceAll(g, "\\{\\$var\\}");
upSendStr
=
upSendStr
.
replaceAll
(
g
,
"\\{\\$\\$\\}"
);
if
(
t
.
contains
(
"${surl!"
))
{
if
(
t
.
contains
(
"${surl!"
))
{
// 短链没传长度,固定长度20
// 短链没传长度,固定长度20
upCreateStr
=
upCreateStr
.
replaceAll
(
g
,
"\\{s20\\}"
);
upCreateStr
=
upCreateStr
.
replaceAll
(
g
,
"\\{s20\\}"
);
...
@@ -301,7 +333,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -301,7 +333,7 @@ public class MessageServiceImpl implements MessageService {
*/
*/
private
String
getMsg
(
String
upContent
,
List
<
String
>
params
)
{
private
String
getMsg
(
String
upContent
,
List
<
String
>
params
)
{
for
(
String
info
:
params
)
{
for
(
String
info
:
params
)
{
upContent
=
upContent
.
replaceFirst
(
"\\$
v
\\$"
,
info
);
upContent
=
upContent
.
replaceFirst
(
"\\$\\$"
,
info
);
}
}
return
upContent
;
return
upContent
;
}
}
...
...
src/main/resources/application.yml
View file @
9a996165
...
@@ -8,7 +8,7 @@ info:
...
@@ -8,7 +8,7 @@ info:
spring
:
spring
:
profiles
:
profiles
:
active
:
prod
active
:
dev
mybatis-plus
:
mybatis-plus
:
mapper-locations
:
classpath:mapper/*.xml
mapper-locations
:
classpath:mapper/*.xml
...
...
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