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
c9d1d951
Commit
c9d1d951
authored
Jun 10, 2020
by
qinxunjia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
短信
parent
e3aa6c8a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
28 deletions
+50
-28
DmHubSendResponse.java
src/main/java/com/bgy/sms/channel/dto/DmHubSendResponse.java
+17
-4
ResponseCode.java
src/main/java/com/bgy/sms/config/ResponseCode.java
+2
-0
MessageServiceImpl.java
...ain/java/com/bgy/sms/service/impl/MessageServiceImpl.java
+28
-19
application-dev.yml
src/main/resources/application-dev.yml
+2
-2
application-test.yml
src/main/resources/application-test.yml
+0
-2
application.yml
src/main/resources/application.yml
+1
-1
No files found.
src/main/java/com/bgy/sms/channel/dto/DmHubSendResponse.java
View file @
c9d1d951
package
com
.
bgy
.
sms
.
channel
.
dto
;
package
com
.
bgy
.
sms
.
channel
.
dto
;
import
com.alibaba.fastjson.JSONObject
;
import
com.bgy.sms.config.ResponseCode
;
import
com.bgy.sms.config.ResponseCode
;
import
java.io.Serializable
;
import
java.io.Serializable
;
...
@@ -10,18 +11,22 @@ public class DmHubSendResponse implements Serializable {
...
@@ -10,18 +11,22 @@ public class DmHubSendResponse implements Serializable {
private
String
code
;
private
String
code
;
private
JSONObject
error
;
public
DmHubSendResponse
()
{
public
DmHubSendResponse
()
{
}
}
public
DmHubSendResponse
(
String
code
,
String
msg
)
{
this
.
code
=
code
;
}
public
DmHubSendResponse
(
ResponseCode
responseCode
)
{
public
DmHubSendResponse
(
ResponseCode
responseCode
)
{
this
.
code
=
responseCode
.
getCode
();
this
.
code
=
responseCode
.
getCode
();
}
}
public
DmHubSendResponse
(
String
errorCode
,
String
errorMsg
)
{
error
=
new
JSONObject
();
error
.
put
(
"errorCode"
,
errorCode
);
error
.
put
(
"message"
,
errorMsg
);
}
public
String
getCode
()
{
public
String
getCode
()
{
return
code
;
return
code
;
}
}
...
@@ -30,11 +35,19 @@ public class DmHubSendResponse implements Serializable {
...
@@ -30,11 +35,19 @@ public class DmHubSendResponse implements Serializable {
this
.
code
=
code
;
this
.
code
=
code
;
}
}
public
JSONObject
getError
()
{
return
error
;
}
public
void
setError
(
JSONObject
error
)
{
this
.
error
=
error
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"DmHubSendResponse{"
+
return
"DmHubSendResponse{"
+
"code='"
+
code
+
'\''
+
"code='"
+
code
+
'\''
+
"error='"
+
error
.
toString
()
+
'\''
+
'}'
;
'}'
;
}
}
}
}
src/main/java/com/bgy/sms/config/ResponseCode.java
View file @
c9d1d951
...
@@ -6,6 +6,8 @@ public enum ResponseCode {
...
@@ -6,6 +6,8 @@ public enum ResponseCode {
UNKNOWN_TEMPLATE_TYPE
(
"500"
,
"未知模板类型"
),
UNKNOWN_TEMPLATE_TYPE
(
"500"
,
"未知模板类型"
),
TEMPLATE_ALREADY_EXISTED
(
"500"
,
"DM Hub模板ID冲突"
),
TEMPLATE_ALREADY_EXISTED
(
"500"
,
"DM Hub模板ID冲突"
),
SYSTEM_ERROR
(
"99"
,
"系统异常:"
),
SYSTEM_ERROR
(
"99"
,
"系统异常:"
),
NO_TEMPLATE
(
"error"
,
"未找到短信模板"
),
DMHUB_NO_DATA
(
"error"
,
"没有请求数据"
),
// 渠道异常错误
// 渠道异常错误
UPSTREAM_FAIL
(
"US01"
,
"渠道交易失败"
),
UPSTREAM_FAIL
(
"US01"
,
"渠道交易失败"
),
...
...
src/main/java/com/bgy/sms/service/impl/MessageServiceImpl.java
View file @
c9d1d951
...
@@ -175,16 +175,17 @@ public class MessageServiceImpl implements MessageService {
...
@@ -175,16 +175,17 @@ public class MessageServiceImpl implements MessageService {
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRED
)
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRED
)
public
DmHubSendResponse
send
(
DmHubSendRequest
request
DTO
)
{
public
DmHubSendResponse
send
(
DmHubSendRequest
request
)
{
try
{
try
{
String
dmHubBatchId
=
request
DTO
.
getBatchId
();
String
dmHubBatchId
=
request
.
getBatchId
();
String
templateId
=
request
DTO
.
getTemplateId
();
String
templateId
=
request
.
getTemplateId
();
String
audienceIdType
=
request
DTO
.
getAudienceIdType
();
String
audienceIdType
=
request
.
getAudienceIdType
();
JSONObject
data
=
request
DTO
.
getData
();
JSONObject
data
=
request
.
getData
();
// 1、获取模板信息
// 1、获取模板信息
SmsTemplateInfo
templateInfo
=
smsTemplateService
.
selectOne
(
new
EntityWrapper
<
SmsTemplateInfo
>().
eq
(
"dm_template_id"
,
templateId
));
SmsTemplateInfo
templateInfo
=
smsTemplateService
.
selectOne
(
new
EntityWrapper
<
SmsTemplateInfo
>().
eq
(
"dm_template_id"
,
templateId
));
if
(
null
==
templateInfo
)
{
if
(
null
==
templateInfo
)
{
return
null
;
log
.
error
(
"未获取到短信模板"
);
return
new
DmHubSendResponse
(
"999"
,
"未获取到短信模板"
);
}
}
// 2、根据请求信息获取用户的手机号码(此处不考虑配置DMHUB系统不是SMS的情况),直接拿请求体中的_audienceId字段值,该值为手机号码
// 2、根据请求信息获取用户的手机号码(此处不考虑配置DMHUB系统不是SMS的情况),直接拿请求体中的_audienceId字段值,该值为手机号码
// 模板参数占位符
// 模板参数占位符
...
@@ -199,6 +200,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -199,6 +200,7 @@ public class MessageServiceImpl implements MessageService {
data
.
remove
(
"id"
);
data
.
remove
(
"id"
);
data
.
remove
(
"_audienceId"
);
data
.
remove
(
"_audienceId"
);
log
.
info
(
"data信息:{}"
,
data
);
if
(!
data
.
isEmpty
())
{
if
(!
data
.
isEmpty
())
{
for
(
Object
parm
:
paramsArr
)
{
for
(
Object
parm
:
paramsArr
)
{
String
s
=
parm
.
toString
();
String
s
=
parm
.
toString
();
...
@@ -215,8 +217,6 @@ public class MessageServiceImpl implements MessageService {
...
@@ -215,8 +217,6 @@ public class MessageServiceImpl implements MessageService {
}
}
}
}
}
}
}
else
{
return
null
;
}
}
String
type
=
templateInfo
.
getType
();
String
type
=
templateInfo
.
getType
();
// 3、记录批次信息
// 3、记录批次信息
...
@@ -249,7 +249,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -249,7 +249,7 @@ public class MessageServiceImpl implements MessageService {
return
new
DmHubSendResponse
(
code
,
msg
);
return
new
DmHubSendResponse
(
code
,
msg
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"调用短信发送逻辑错误"
,
e
);
log
.
error
(
"调用短信发送逻辑错误"
,
e
);
return
new
DmHubSendResponse
(
ResponseCode
.
SYSTEM_ERROR
);
return
new
DmHubSendResponse
(
"999"
,
"插件系统异常"
);
}
}
}
}
...
@@ -390,7 +390,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -390,7 +390,7 @@ public class MessageServiceImpl implements MessageService {
SmsTemplateInfo
templateInfo
=
smsTemplateService
.
selectOne
(
new
EntityWrapper
<
SmsTemplateInfo
>().
eq
(
"dm_template_id"
,
templateId
));
SmsTemplateInfo
templateInfo
=
smsTemplateService
.
selectOne
(
new
EntityWrapper
<
SmsTemplateInfo
>().
eq
(
"dm_template_id"
,
templateId
));
if
(
null
==
templateInfo
)
{
if
(
null
==
templateInfo
)
{
return
new
DmHubSendResponse
(
ResponseCode
.
SYSTEM_ERROR
);
return
new
DmHubSendResponse
(
"999"
,
"短信插件未获取到模板信息"
);
}
}
// 模板参数占位符
// 模板参数占位符
String
params
=
templateInfo
.
getParams
();
String
params
=
templateInfo
.
getParams
();
...
@@ -407,7 +407,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -407,7 +407,7 @@ public class MessageServiceImpl implements MessageService {
json
.
remove
(
"name"
);
json
.
remove
(
"name"
);
json
.
remove
(
"id"
);
json
.
remove
(
"id"
);
json
.
remove
(
"_audienceId"
);
json
.
remove
(
"_audienceId"
);
mobileList
.
add
(
mobile
);
if
(!
json
.
isEmpty
())
{
if
(!
json
.
isEmpty
())
{
for
(
Object
parm
:
paramsArr
)
{
for
(
Object
parm
:
paramsArr
)
{
List
<
String
>
list
=
new
ArrayList
<>();
List
<
String
>
list
=
new
ArrayList
<>();
...
@@ -459,24 +459,33 @@ public class MessageServiceImpl implements MessageService {
...
@@ -459,24 +459,33 @@ public class MessageServiceImpl implements MessageService {
if
(
paramsArr
==
null
||
paramsArr
.
isEmpty
())
{
if
(
paramsArr
==
null
||
paramsArr
.
isEmpty
())
{
try
{
try
{
for
(
String
mobile
:
mobileList
)
{
for
(
String
mobile
:
mobileList
)
{
response
=
bgySmsService
.
sendSms
(
""
,
templateInfo
.
getUpContent
());
try
{
response
=
bgySmsService
.
sendSms
(
mobile
,
templateInfo
.
getUpContent
());
}
catch
(
Exception
e
)
{
log
.
error
(
"除0"
);
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"调用创蓝逻辑错误"
,
e
);
log
.
error
(
"调用创蓝逻辑错误"
,
e
);
// TODO 根据DM hub需要的返回数据封装
// TODO 根据DM hub需要的返回数据封装
return
new
DmHubSendResponse
(
ResponseCode
.
SYSTEM_ERROR
);
return
new
DmHubSendResponse
(
"999"
,
"插件服务系统异常"
);
}
}
}
else
{
}
else
{
// 变量短信
// 变量短信
Set
<
Map
.
Entry
<
String
,
List
<
String
>>>
entries
=
paramsMap
.
entrySet
();
Set
<
Map
.
Entry
<
String
,
List
<
String
>>>
entries
=
paramsMap
.
entrySet
();
try
{
try
{
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
entries
)
{
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
entries
)
{
String
mobile
=
entry
.
getKey
().
toString
();
try
{
List
<
String
>
paramsList
=
entry
.
getValue
();
String
mobile
=
entry
.
getKey
().
toString
();
String
sendMsg
=
getMsg
(
templateInfo
.
getUpContent
(),
paramsList
);
List
<
String
>
paramsList
=
entry
.
getValue
();
response
=
bgySmsService
.
sendSms
(
mobile
,
sendMsg
);
String
sendMsg
=
getMsg
(
templateInfo
.
getUpContent
(),
paramsList
);
String
code
=
response
.
getCode
();
response
=
bgySmsService
.
sendSms
(
mobile
,
sendMsg
);
String
msg
=
response
.
getMsg
();
String
code
=
response
.
getCode
();
String
msg
=
response
.
getMsg
();
}
catch
(
Exception
e
)
{
log
.
error
(
"chu0"
);
}
}
}
// TODO 待优化
// TODO 待优化
return
new
DmHubSendResponse
(
ResponseCode
.
SUCCESS
);
return
new
DmHubSendResponse
(
ResponseCode
.
SUCCESS
);
...
...
src/main/resources/application-dev.yml
View file @
c9d1d951
...
@@ -12,8 +12,8 @@ spring:
...
@@ -12,8 +12,8 @@ spring:
type
:
com.zaxxer.hikari.HikariDataSource
type
:
com.zaxxer.hikari.HikariDataSource
url
:
jdbc:mysql://119.23.32.151:3306/dmhub_plugin?characterEncoding=utf8&useSSL=false
url
:
jdbc:mysql://119.23.32.151:3306/dmhub_plugin?characterEncoding=utf8&useSSL=false
driver-class-name
:
com.mysql.cj.jdbc.Driver
driver-class-name
:
com.mysql.cj.jdbc.Driver
username
:
bu00310
username
:
dmp
password
:
pwd$BU00310
password
:
Ioubuy@2019@!
hikari
:
hikari
:
maxLifetime
:
1765000
maxLifetime
:
1765000
maximumPoolSize
:
20
maximumPoolSize
:
20
...
...
src/main/resources/application-test.yml
View file @
c9d1d951
...
@@ -10,7 +10,6 @@ server:
...
@@ -10,7 +10,6 @@ server:
spring
:
spring
:
datasource
:
datasource
:
type
:
com.zaxxer.hikari.HikariDataSource
type
:
com.zaxxer.hikari.HikariDataSource
# url: jdbc:mysql://119.23.32.151:3306/dmhub_plugin?characterEncoding=utf8&useSSL=false
url
:
jdbc:mysql://my09457h.mysql.db.pcloud.localdomain:3070/dmhub_plugin?characterEncoding=utf8&useSSL=false
url
:
jdbc:mysql://my09457h.mysql.db.pcloud.localdomain:3070/dmhub_plugin?characterEncoding=utf8&useSSL=false
driver-class-name
:
com.mysql.cj.jdbc.Driver
driver-class-name
:
com.mysql.cj.jdbc.Driver
username
:
bu00310
username
:
bu00310
...
@@ -41,4 +40,3 @@ system:
...
@@ -41,4 +40,3 @@ system:
applicationKey
:
4017078e9dfd593b2d9a0ede58eff589644fbe50
applicationKey
:
4017078e9dfd593b2d9a0ede58eff589644fbe50
tokenUrl
:
https://api.convertlab.com/security/accesstoken
tokenUrl
:
https://api.convertlab.com/security/accesstoken
report
:
https://api.convertlab.com/v1/sms/report
report
:
https://api.convertlab.com/v1/sms/report
src/main/resources/application.yml
View file @
c9d1d951
...
@@ -19,7 +19,7 @@ mybatis-plus:
...
@@ -19,7 +19,7 @@ mybatis-plus:
logging
:
logging
:
level
:
debug
level
:
debug
level.com.
jz
:
debug
# 单独指定包下的日志级别
level.com.
bgy
:
debug
# 单独指定包下的日志级别
config
:
classpath:logback-spring.xml
config
:
classpath:logback-spring.xml
file
:
file
:
path
:
logs.log
path
:
logs.log
\ No newline at end of file
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