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