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
52e36a29
Commit
52e36a29
authored
Jul 17, 2020
by
qinxunjia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
短信插件适配短链接的模板
parent
767e04f9
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
21 deletions
+35
-21
BgySmsServiceImpl.java
...m/bgy/sms/channel/bgy/service/impl/BgySmsServiceImpl.java
+4
-6
DmHubConfig.java
...in/java/com/bgy/sms/channel/dmHub/config/DmHubConfig.java
+7
-0
MessageServiceImpl.java
...ain/java/com/bgy/sms/service/impl/MessageServiceImpl.java
+21
-15
application-dev.yml
src/main/resources/application-dev.yml
+1
-0
application-prod.yml
src/main/resources/application-prod.yml
+1
-0
application-test.yml
src/main/resources/application-test.yml
+1
-0
No files found.
src/main/java/com/bgy/sms/channel/bgy/service/impl/BgySmsServiceImpl.java
View file @
52e36a29
...
@@ -35,6 +35,7 @@ public class BgySmsServiceImpl implements BgySmsService {
...
@@ -35,6 +35,7 @@ public class BgySmsServiceImpl implements BgySmsService {
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
BgySmsServiceImpl
.
class
);
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
BgySmsServiceImpl
.
class
);
private
static
final
String
SUCCESS
=
"success"
;
private
static
final
String
SUCCESS
=
"success"
;
private
static
final
String
Fail
=
"Fail"
;
private
static
final
String
Fail
=
"Fail"
;
private
static
final
String
OK
=
"Fail"
;
private
static
final
String
sendSuccessCode
=
"0"
;
// 发送响应成功字段
private
static
final
String
sendSuccessCode
=
"0"
;
// 发送响应成功字段
private
static
final
String
createTemplateStatus
=
"status"
;
// 响应状态字段
private
static
final
String
createTemplateStatus
=
"status"
;
// 响应状态字段
private
static
final
String
retMsg
=
"msg"
;
// 响应描述
private
static
final
String
retMsg
=
"msg"
;
// 响应描述
...
@@ -117,13 +118,10 @@ public class BgySmsServiceImpl implements BgySmsService {
...
@@ -117,13 +118,10 @@ public class BgySmsServiceImpl implements BgySmsService {
}
}
JSONObject
retJson
=
JSONObject
.
parseObject
(
retStr
);
JSONObject
retJson
=
JSONObject
.
parseObject
(
retStr
);
String
err
=
retJson
.
getString
(
"err"
);
String
err
=
retJson
.
getString
(
"err"
);
String
retPack
=
retJson
.
getString
(
"package"
);
String
status
=
retJson
.
getString
(
"Status"
);
String
retCode
=
retJson
.
getString
(
"ret"
);
String
retCode
=
retJson
.
getString
(
"ret"
);
if
(
StringUtils
.
isBlank
(
status
)
||
Fail
.
equals
(
status
))
{
String
retPack
=
retJson
.
getString
(
"package"
);
if
(!
sendSuccessCode
.
equals
(
retCode
))
{
return
new
CLBizResponse
(
ResponseCode
.
UPSTREAM_FAIL
.
getCode
(),
err
);
return
new
CLBizResponse
(
ResponseCode
.
UPSTREAM_FAIL
.
getCode
(),
err
);
}
else
if
(
sendSuccessCode
.
equals
(
retCode
))
{
return
new
CLBizResponse
(
ResponseCode
.
SUCCESS
);
}
else
{
}
else
{
return
new
CLBizResponse
(
ResponseCode
.
UPSTREAM_FAIL
.
getCode
(),
err
);
return
new
CLBizResponse
(
ResponseCode
.
UPSTREAM_FAIL
.
getCode
(),
err
);
}
}
...
@@ -160,7 +158,7 @@ public class BgySmsServiceImpl implements BgySmsService {
...
@@ -160,7 +158,7 @@ public class BgySmsServiceImpl implements BgySmsService {
updateInfo
.
setUpRejectMsg
(
auditReason
);
updateInfo
.
setUpRejectMsg
(
auditReason
);
updateInfo
.
setLastUpdated
(
new
Date
());
updateInfo
.
setLastUpdated
(
new
Date
());
smsTemplateService
.
updateById
(
updateInfo
);
smsTemplateService
.
updateById
(
updateInfo
);
xiaoShuService
.
updateDmhubSmsTempStatus
(
dmhubStatue
,
smsTemplateInfo
.
getDmTemplateId
(),
auditReason
);
xiaoShuService
.
updateDmhubSmsTempStatus
(
dmhubStatue
,
smsTemplateInfo
.
getDmTemplateId
(),
auditReason
);
return
new
BGYResponse
();
return
new
BGYResponse
();
}
}
...
...
src/main/java/com/bgy/sms/channel/dmHub/config/DmHubConfig.java
View file @
52e36a29
...
@@ -16,6 +16,8 @@ public class DmHubConfig {
...
@@ -16,6 +16,8 @@ public class DmHubConfig {
public
static
String
appId
;
public
static
String
appId
;
public
static
String
appSecret
;
public
static
String
appSecret
;
public
static
String
shortUrl
;
@Value
(
"${system.config.dmHub.applicationId}"
)
@Value
(
"${system.config.dmHub.applicationId}"
)
public
void
setApplicationId
(
String
applicationId
)
{
public
void
setApplicationId
(
String
applicationId
)
{
DmHubConfig
.
applicationId
=
applicationId
;
DmHubConfig
.
applicationId
=
applicationId
;
...
@@ -46,5 +48,10 @@ public class DmHubConfig {
...
@@ -46,5 +48,10 @@ public class DmHubConfig {
DmHubConfig
.
appSecret
=
appSecret
;
DmHubConfig
.
appSecret
=
appSecret
;
}
}
@Value
(
"${system.config.dmHub.shortUrl}"
)
public
void
setShortUrl
(
String
shortUrl
)
{
DmHubConfig
.
shortUrl
=
shortUrl
;
}
}
}
src/main/java/com/bgy/sms/service/impl/MessageServiceImpl.java
View file @
52e36a29
...
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper;
...
@@ -6,6 +6,7 @@ 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.service.BgySmsService
;
import
com.bgy.sms.channel.bgy.service.BgySmsService
;
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.*
;
import
com.bgy.sms.repository.domain.*
;
...
@@ -72,6 +73,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -72,6 +73,7 @@ public class MessageServiceImpl implements MessageService {
// 替换模板格式,保存适合碧桂园发送短信的模板,避免发送时修改模板格式
// 替换模板格式,保存适合碧桂园发送短信的模板,避免发送时修改模板格式
TemplateChangeBean
bean
=
dmHub2BgyTemplateSend
(
templateContent
);
TemplateChangeBean
bean
=
dmHub2BgyTemplateSend
(
templateContent
);
String
bgySendStr
=
bean
.
getUpSendStr
();
String
bgySendStr
=
bean
.
getUpSendStr
();
String
upCreateStr
=
bean
.
getUpCreateStr
();
String
params
=
bean
.
getParams
().
toString
();
String
params
=
bean
.
getParams
().
toString
();
SmsTemplateInfo
dbInfo
=
smsTemplateService
.
selectOne
(
new
EntityWrapper
<
SmsTemplateInfo
>().
eq
(
"dm_template_id"
,
templateId
));
SmsTemplateInfo
dbInfo
=
smsTemplateService
.
selectOne
(
new
EntityWrapper
<
SmsTemplateInfo
>().
eq
(
"dm_template_id"
,
templateId
));
if
(
dbInfo
!=
null
)
{
if
(
dbInfo
!=
null
)
{
...
@@ -111,7 +113,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -111,7 +113,7 @@ public class MessageServiceImpl implements MessageService {
xiaoShuService
.
updateDmhubSmsTempStatus
(
REJECTED
,
templateId
,
"未找到当前登录用户的售楼系统ID"
);
xiaoShuService
.
updateDmhubSmsTempStatus
(
REJECTED
,
templateId
,
"未找到当前登录用户的售楼系统ID"
);
return
new
DmHubResponse
(
ResponseCode
.
NO_USER_ID
);
return
new
DmHubResponse
(
ResponseCode
.
NO_USER_ID
);
}
}
response
=
bgySmsService
.
createTemplate
(
bgySend
Str
,
account
,
TEMPLATETYPE
,
pkID
);
response
=
bgySmsService
.
createTemplate
(
upCreate
Str
,
account
,
TEMPLATETYPE
,
pkID
);
String
code
=
response
.
getCode
();
String
code
=
response
.
getCode
();
String
msg
=
response
.
getMsg
();
String
msg
=
response
.
getMsg
();
if
(
code
.
equals
(
ResponseCode
.
SUCCESS
.
getCode
()))
{
if
(
code
.
equals
(
ResponseCode
.
SUCCESS
.
getCode
()))
{
...
@@ -166,21 +168,25 @@ public class MessageServiceImpl implements MessageService {
...
@@ -166,21 +168,25 @@ public class MessageServiceImpl implements MessageService {
upSendStr
=
upSendStr
.
replaceAll
(
g
,
"\\$\\$"
);
upSendStr
=
upSendStr
.
replaceAll
(
g
,
"\\$\\$"
);
if
(
t
.
contains
(
"${surl!"
))
{
if
(
t
.
contains
(
"${surl!"
))
{
// 短链没传长度,固定长度20
// 短链没传长度,固定长度20
upCreateStr
=
upCreateStr
.
replaceAll
(
g
,
"\\{s20\\}"
);
String
str
=
DmHubConfig
.
shortUrl
+
"\\$$"
;
}
else
{
str
=
java
.
util
.
regex
.
Matcher
.
quoteReplacement
(
str
);
int
i
=
t
.
indexOf
(
"@"
);
upCreateStr
=
upCreateStr
.
replaceAll
(
g
,
str
);
int
i1
=
t
.
indexOf
(
"!"
);
String
str
=
t
.
substring
(
i
+
1
,
i1
);
if
(
isNumeric
(
str
))
{
Integer
integer
=
Integer
.
valueOf
(
str
);
if
(
integer
==
0
)
{
upCreateStr
=
upCreateStr
.
replaceAll
(
g
,
"\\{s20\\}"
);
}
else
{
upCreateStr
=
upCreateStr
.
replaceAll
(
g
,
"\\{s"
+
integer
+
"\\}"
);
}
}
else
{
}
else
{
upCreateStr
=
upCreateStr
.
replaceAll
(
g
,
"\\{s20\\}"
);
upCreateStr
=
upCreateStr
.
replaceAll
(
g
,
"\\$\\$"
);
}
// int i = t.indexOf("@");
// int i1 = t.indexOf("!");
// String str = t.substring(i + 1, i1);
// if (isNumeric(str)) {
// Integer integer = Integer.valueOf(str);
// if (integer == 0) {
// upCreateStr = upCreateStr.replaceAll(g, "\\$\\$");
// } else {
// upCreateStr = upCreateStr.replaceAll(g, "\\$\\$");
// }
// } else {
// upCreateStr = upCreateStr.replaceAll(g, "\\$\\$");
// }
}
}
}
}
arr
.
addAll
(
groups
);
arr
.
addAll
(
groups
);
...
...
src/main/resources/application-dev.yml
View file @
52e36a29
...
@@ -53,6 +53,7 @@ system:
...
@@ -53,6 +53,7 @@ system:
report
:
${${system.config.dmHub.baseApiURL}}/v1/sms/report
report
:
${${system.config.dmHub.baseApiURL}}/v1/sms/report
appId
:
1smsdemo
appId
:
1smsdemo
appSecret
:
ac031765c3a8c9acc4747808e4fe5918
appSecret
:
ac031765c3a8c9acc4747808e4fe5918
shortUrl
:
urlshort-xsma-sit.bgy.com.cn
logging
:
logging
:
level
:
debug
level
:
debug
...
...
src/main/resources/application-prod.yml
View file @
52e36a29
...
@@ -53,6 +53,7 @@ system:
...
@@ -53,6 +53,7 @@ system:
report
:
${system.config.dmHub.baseApiURL}/v1/sms/report
report
:
${system.config.dmHub.baseApiURL}/v1/sms/report
appId
:
${smsAppId}
appId
:
${smsAppId}
appSecret
:
${smsSecret}
appSecret
:
${smsSecret}
shortUrl
:
${shortUrl}
logging
:
logging
:
level
:
${logLevel}
level
:
${logLevel}
...
...
src/main/resources/application-test.yml
View file @
52e36a29
...
@@ -46,6 +46,7 @@ system:
...
@@ -46,6 +46,7 @@ system:
report
:
https://api.convertlab.com/v1/sms/report
report
:
https://api.convertlab.com/v1/sms/report
appId
:
1smsdemo
appId
:
1smsdemo
appSecret
:
ac031765c3a8c9acc4747808e4fe5918
appSecret
:
ac031765c3a8c9acc4747808e4fe5918
shortUrl
:
urlshort-xsma-sit.bgy.com.cn
logging
:
logging
:
level
:
debug
level
:
debug
...
...
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