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
494b7825
Commit
494b7825
authored
Jun 11, 2020
by
qinxunjia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
短信插件优化,区分不同类型用不同账号
parent
c9d1d951
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
15 deletions
+44
-15
BgySMSConfig.java
...ain/java/com/bgy/sms/channel/bgy/config/BgySMSConfig.java
+12
-5
BgySmsService.java
...n/java/com/bgy/sms/channel/bgy/service/BgySmsService.java
+1
-1
BgySmsServiceImpl.java
...m/bgy/sms/channel/bgy/service/impl/BgySmsServiceImpl.java
+1
-2
MessageServiceImpl.java
...ain/java/com/bgy/sms/service/impl/MessageServiceImpl.java
+24
-5
application-dev.yml
src/main/resources/application-dev.yml
+2
-1
application-prod.yml
src/main/resources/application-prod.yml
+2
-1
application-test.yml
src/main/resources/application-test.yml
+2
-0
No files found.
src/main/java/com/bgy/sms/channel/bgy/config/BgySMSConfig.java
View file @
494b7825
...
@@ -14,8 +14,10 @@ public class BgySMSConfig {
...
@@ -14,8 +14,10 @@ public class BgySMSConfig {
public
static
String
securityCode
;
public
static
String
securityCode
;
// 请求地址
// 请求地址
public
static
String
url
;
public
static
String
url
;
// 项目楼盘id
// 通知类项目楼盘ID
public
static
String
areaId
;
public
static
String
notifyAreaId
;
// 营销类项目楼盘ID
public
static
String
marketAreaId
;
// api
// api
public
static
String
api
;
public
static
String
api
;
...
@@ -35,9 +37,14 @@ public class BgySMSConfig {
...
@@ -35,9 +37,14 @@ public class BgySMSConfig {
BgySMSConfig
.
url
=
url
;
BgySMSConfig
.
url
=
url
;
}
}
@Value
(
"${system.config.bgy.areaId}"
)
@Value
(
"${system.config.bgy.notifyAreaId}"
)
public
void
setAreaId
(
String
areaId
)
{
public
void
setNotifyAreaId
(
String
notifyAreaId
)
{
BgySMSConfig
.
areaId
=
areaId
;
BgySMSConfig
.
notifyAreaId
=
notifyAreaId
;
}
@Value
(
"${system.config.bgy.marketAreaId}"
)
public
void
setMarketAreaId
(
String
marketAreaId
)
{
BgySMSConfig
.
marketAreaId
=
marketAreaId
;
}
}
@Value
(
"${system.config.bgy.api}"
)
@Value
(
"${system.config.bgy.api}"
)
...
...
src/main/java/com/bgy/sms/channel/bgy/service/BgySmsService.java
View file @
494b7825
...
@@ -6,7 +6,7 @@ public interface BgySmsService {
...
@@ -6,7 +6,7 @@ public interface BgySmsService {
CLBizResponse
sendSms
(
String
mobile
,
String
content
)
throws
Exception
;
CLBizResponse
sendSms
(
String
mobile
,
String
content
,
String
areaId
)
throws
Exception
;
}
}
src/main/java/com/bgy/sms/channel/bgy/service/impl/BgySmsServiceImpl.java
View file @
494b7825
...
@@ -39,11 +39,10 @@ public class BgySmsServiceImpl implements BgySmsService {
...
@@ -39,11 +39,10 @@ public class BgySmsServiceImpl implements BgySmsService {
private
DmHubService
dmHubService
;
private
DmHubService
dmHubService
;
@Override
@Override
public
CLBizResponse
sendSms
(
String
mobile
,
String
content
)
throws
Exception
{
public
CLBizResponse
sendSms
(
String
mobile
,
String
content
,
String
areaId
)
throws
Exception
{
String
appId
=
BgySMSConfig
.
appId
;
String
appId
=
BgySMSConfig
.
appId
;
String
securityCode
=
BgySMSConfig
.
securityCode
;
String
securityCode
=
BgySMSConfig
.
securityCode
;
String
url
=
BgySMSConfig
.
url
;
String
url
=
BgySMSConfig
.
url
;
String
areaId
=
BgySMSConfig
.
areaId
;
String
api
=
BgySMSConfig
.
api
;
String
api
=
BgySMSConfig
.
api
;
Map
<
String
,
String
>
requestParams
=
new
HashMap
<>();
Map
<
String
,
String
>
requestParams
=
new
HashMap
<>();
requestParams
.
put
(
"api"
,
api
);
requestParams
.
put
(
"api"
,
api
);
...
...
src/main/java/com/bgy/sms/service/impl/MessageServiceImpl.java
View file @
494b7825
...
@@ -3,6 +3,7 @@ package com.bgy.sms.service.impl;
...
@@ -3,6 +3,7 @@ package com.bgy.sms.service.impl;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
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.config.ResponseCode
;
import
com.bgy.sms.config.ResponseCode
;
...
@@ -191,7 +192,15 @@ public class MessageServiceImpl implements MessageService {
...
@@ -191,7 +192,15 @@ public class MessageServiceImpl implements MessageService {
// 模板参数占位符
// 模板参数占位符
String
params
=
templateInfo
.
getParams
();
String
params
=
templateInfo
.
getParams
();
JSONArray
paramsArr
=
JSONArray
.
parseArray
(
params
);
JSONArray
paramsArr
=
JSONArray
.
parseArray
(
params
);
String
smsType
=
templateInfo
.
getType
();
String
areaId
;
if
(
"notification"
.
equals
(
smsType
))
{
areaId
=
BgySMSConfig
.
notifyAreaId
;
}
else
if
(
"marketing"
.
equals
(
smsType
))
{
areaId
=
BgySMSConfig
.
marketAreaId
;
}
else
{
return
new
DmHubSendResponse
(
"999"
,
"未获取到短信类型"
);
}
// 封装参数
// 封装参数
List
<
String
>
paramList
=
new
ArrayList
<>();
List
<
String
>
paramList
=
new
ArrayList
<>();
Set
<
String
>
keys
=
data
.
keySet
();
Set
<
String
>
keys
=
data
.
keySet
();
...
@@ -242,7 +251,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -242,7 +251,7 @@ public class MessageServiceImpl implements MessageService {
String
upContent
=
templateInfo
.
getUpContent
();
String
upContent
=
templateInfo
.
getUpContent
();
content
=
getMsg
(
upContent
,
paramList
);
content
=
getMsg
(
upContent
,
paramList
);
}
}
response
=
bgySmsService
.
sendSms
(
mobile
,
content
);
response
=
bgySmsService
.
sendSms
(
mobile
,
content
,
areaId
);
String
code
=
response
.
getCode
();
String
code
=
response
.
getCode
();
String
msg
=
response
.
getMsg
();
String
msg
=
response
.
getMsg
();
// TODO 根据DM hub需要的返回数据封装
// TODO 根据DM hub需要的返回数据封装
...
@@ -392,6 +401,15 @@ public class MessageServiceImpl implements MessageService {
...
@@ -392,6 +401,15 @@ public class MessageServiceImpl implements MessageService {
if
(
null
==
templateInfo
)
{
if
(
null
==
templateInfo
)
{
return
new
DmHubSendResponse
(
"999"
,
"短信插件未获取到模板信息"
);
return
new
DmHubSendResponse
(
"999"
,
"短信插件未获取到模板信息"
);
}
}
String
smsType
=
templateInfo
.
getType
();
String
areaId
;
if
(
"notification"
.
equals
(
smsType
))
{
areaId
=
BgySMSConfig
.
notifyAreaId
;
}
else
if
(
"marketing"
.
equals
(
smsType
))
{
areaId
=
BgySMSConfig
.
marketAreaId
;
}
else
{
return
new
DmHubSendResponse
(
"999"
,
"未获取到短信类型"
);
}
// 模板参数占位符
// 模板参数占位符
String
params
=
templateInfo
.
getParams
();
String
params
=
templateInfo
.
getParams
();
JSONArray
paramsArr
=
JSONArray
.
parseArray
(
params
);
JSONArray
paramsArr
=
JSONArray
.
parseArray
(
params
);
...
@@ -434,6 +452,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -434,6 +452,7 @@ public class MessageServiceImpl implements MessageService {
}
}
}
}
DmBatchInfo
dmInfo
=
new
DmBatchInfo
();
DmBatchInfo
dmInfo
=
new
DmBatchInfo
();
dmInfo
.
setDmBatchId
(
batchId
);
dmInfo
.
setDmBatchId
(
batchId
);
dmInfo
.
setDmTemplateId
(
templateId
);
dmInfo
.
setDmTemplateId
(
templateId
);
...
@@ -460,7 +479,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -460,7 +479,7 @@ public class MessageServiceImpl implements MessageService {
try
{
try
{
for
(
String
mobile
:
mobileList
)
{
for
(
String
mobile
:
mobileList
)
{
try
{
try
{
response
=
bgySmsService
.
sendSms
(
mobile
,
templateInfo
.
getUpContent
());
response
=
bgySmsService
.
sendSms
(
mobile
,
templateInfo
.
getUpContent
()
,
areaId
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"除0"
);
log
.
error
(
"除0"
);
}
}
...
@@ -479,7 +498,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -479,7 +498,7 @@ public class MessageServiceImpl implements MessageService {
String
mobile
=
entry
.
getKey
().
toString
();
String
mobile
=
entry
.
getKey
().
toString
();
List
<
String
>
paramsList
=
entry
.
getValue
();
List
<
String
>
paramsList
=
entry
.
getValue
();
String
sendMsg
=
getMsg
(
templateInfo
.
getUpContent
(),
paramsList
);
String
sendMsg
=
getMsg
(
templateInfo
.
getUpContent
(),
paramsList
);
response
=
bgySmsService
.
sendSms
(
mobile
,
sendMsg
);
response
=
bgySmsService
.
sendSms
(
mobile
,
sendMsg
,
areaId
);
String
code
=
response
.
getCode
();
String
code
=
response
.
getCode
();
String
msg
=
response
.
getMsg
();
String
msg
=
response
.
getMsg
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -491,7 +510,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -491,7 +510,7 @@ public class MessageServiceImpl implements MessageService {
return
new
DmHubSendResponse
(
ResponseCode
.
SUCCESS
);
return
new
DmHubSendResponse
(
ResponseCode
.
SUCCESS
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"调用创蓝逻辑错误:"
,
e
);
log
.
error
(
"调用创蓝逻辑错误:"
,
e
);
return
new
DmHubSendResponse
(
ResponseCode
.
SYSTEM_ERROR
);
return
new
DmHubSendResponse
(
"999"
,
"插件服务系统异常"
);
}
}
}
}
return
new
DmHubSendResponse
(
ResponseCode
.
SUCCESS
);
return
new
DmHubSendResponse
(
ResponseCode
.
SUCCESS
);
...
...
src/main/resources/application-dev.yml
View file @
494b7825
...
@@ -33,7 +33,8 @@ system:
...
@@ -33,7 +33,8 @@ system:
appId
:
2021
# 系统id
appId
:
2021
# 系统id
securityCode
:
930844c7-7985-435b-af47-142b59b299c3
# 鉴权码
securityCode
:
930844c7-7985-435b-af47-142b59b299c3
# 鉴权码
url
:
https://xstest.bgy.com.cn/ApiBgyTest/Open/Sms.ashx
url
:
https://xstest.bgy.com.cn/ApiBgyTest/Open/Sms.ashx
areaId
:
XXJSB
notifyAreaId
:
XXJSB
marketAreaId
:
XXJSB
api
:
SendSms
api
:
SendSms
dmHub
:
dmHub
:
applicationId
:
cl0300171a6012c21
applicationId
:
cl0300171a6012c21
...
...
src/main/resources/application-prod.yml
View file @
494b7825
...
@@ -34,7 +34,8 @@ system:
...
@@ -34,7 +34,8 @@ system:
appId
:
2021
# 系统id
appId
:
2021
# 系统id
securityCode
:
930844c7-7985-435b-af47-142b59b299c3
# 鉴权码
securityCode
:
930844c7-7985-435b-af47-142b59b299c3
# 鉴权码
url
:
https://xstest.bgy.com.cn/ApiBgyTest/Open/Sms.ashx
url
:
https://xstest.bgy.com.cn/ApiBgyTest/Open/Sms.ashx
areaId
:
XXJSB
notifyAreaId
:
XXJSB
marketAreaId
:
XXJSB
api
:
SendSms
api
:
SendSms
dmHub
:
dmHub
:
applicationId
:
cl0300171a6012c21
applicationId
:
cl0300171a6012c21
...
...
src/main/resources/application-test.yml
View file @
494b7825
...
@@ -34,6 +34,8 @@ system:
...
@@ -34,6 +34,8 @@ system:
securityCode
:
930844c7-7985-435b-af47-142b59b299c3
# 鉴权码
securityCode
:
930844c7-7985-435b-af47-142b59b299c3
# 鉴权码
url
:
https://xstest.bgy.com.cn/ApiBgyTest/Open/Sms.ashx
url
:
https://xstest.bgy.com.cn/ApiBgyTest/Open/Sms.ashx
areaId
:
XXJSB
areaId
:
XXJSB
notifyAreaId
:
XXJSB
marketAreaId
:
XXJSB
api
:
SendSms
api
:
SendSms
dmHub
:
dmHub
:
applicationId
:
cl0300171a6012c21
applicationId
:
cl0300171a6012c21
...
...
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