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
a8064744
Commit
a8064744
authored
Jul 13, 2020
by
fuwanli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"修改状态取值"
parent
03962140
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
32 deletions
+21
-32
DmHubApi.java
src/main/java/com/bgy/sms/channel/api/DmHubApi.java
+1
-2
BgySmsService.java
...n/java/com/bgy/sms/channel/bgy/service/BgySmsService.java
+3
-1
BgySmsServiceImpl.java
...m/bgy/sms/channel/bgy/service/impl/BgySmsServiceImpl.java
+9
-8
MessageServiceImpl.java
...ain/java/com/bgy/sms/service/impl/MessageServiceImpl.java
+8
-21
No files found.
src/main/java/com/bgy/sms/channel/api/DmHubApi.java
View file @
a8064744
...
...
@@ -102,8 +102,6 @@ public class DmHubApi {
return
new
DmHubResponse
(
"555"
,
"接口请求签名校验不通过"
);
}
response
=
messageService
.
batchSendOneByOne
(
request
);
response
.
setCode
(
response
.
getError
().
getString
(
"errorCode"
));
}
catch
(
Exception
e
)
{
...
...
@@ -140,6 +138,7 @@ public class DmHubApi {
if
(!
checkResult
)
{
return
new
DmHubResponse
(
"555"
,
"签名校验不通过"
);
}
response
=
messageService
.
send
(
request
);
response
.
setCode
(
response
.
getError
().
getString
(
"errorCode"
));
}
catch
(
Exception
e
)
{
...
...
src/main/java/com/bgy/sms/channel/bgy/service/BgySmsService.java
View file @
a8064744
...
...
@@ -4,12 +4,14 @@ import com.alibaba.fastjson.JSONObject;
import
com.bgy.sms.channel.bgy.dto.CLBizResponse
;
import
com.bgy.sms.channel.bgy.dto.TemplateNotify
;
import
java.util.List
;
public
interface
BgySmsService
{
CLBizResponse
sendSms
(
String
mobile
,
String
content
,
String
areaId
,
String
api
)
throws
Exception
;
CLBizResponse
send
batchSms
(
String
data
,
String
areaId
,
String
api
,
String
templateId
)
throws
Exception
;
CLBizResponse
send
BatchSms
(
List
<
JSONObject
>
data
,
String
areaId
,
String
api
,
String
templateId
)
throws
Exception
;
CLBizResponse
createTemplate
(
String
content
,
String
account
,
String
templateType
,
String
pkID
)
throws
Exception
;
...
...
src/main/java/com/bgy/sms/channel/bgy/service/impl/BgySmsServiceImpl.java
View file @
a8064744
...
...
@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -47,14 +48,14 @@ public class BgySmsServiceImpl implements BgySmsService {
private
SmsTemplateService
smsTemplateService
;
@Override
public
CLBizResponse
sendSms
(
String
mobile
,
String
content
,
String
areaId
,
String
api
)
throws
Exception
{
public
CLBizResponse
sendSms
(
String
mobile
,
String
content
,
String
areaId
,
String
api
)
throws
Exception
{
log
.
info
(
"进入碧桂园短信发送接口"
);
String
appId
=
BgySMSConfig
.
appId
;
// String areaId = BgySMSConfig.areaId;
String
securityCode
=
BgySMSConfig
.
securityCode
;
String
url
=
BgySMSConfig
.
url
;
if
(
api
==
null
)
{
api
=
BgySMSConfig
.
api
;
if
(
api
==
null
)
{
api
=
BgySMSConfig
.
api
;
}
Map
<
String
,
String
>
requestParams
=
new
HashMap
<>();
requestParams
.
put
(
"api"
,
api
);
...
...
@@ -84,14 +85,14 @@ public class BgySmsServiceImpl implements BgySmsService {
}
@Override
public
CLBizResponse
send
batchSms
(
String
data
,
String
areaId
,
String
api
,
String
templateId
)
throws
Exception
{
public
CLBizResponse
send
BatchSms
(
List
<
JSONObject
>
data
,
String
areaId
,
String
api
,
String
templateId
)
throws
Exception
{
log
.
info
(
"进入碧桂园短信发送接口"
);
String
appId
=
BgySMSConfig
.
appId
;
// String areaId = BgySMSConfig.areaId;
String
securityCode
=
BgySMSConfig
.
securityCode
;
String
url
=
BgySMSConfig
.
url
;
// String api = BgySMSConfig.api;
Map
<
String
,
String
>
requestParams
=
new
HashMap
<>();
// String api = BgySMSConfig.api;
Map
<
String
,
Object
>
requestParams
=
new
HashMap
<>();
requestParams
.
put
(
"api"
,
api
);
requestParams
.
put
(
"appId"
,
appId
);
requestParams
.
put
(
"security"
,
Md5Util
.
encrypt
(
appId
+
securityCode
.
toUpperCase
()));
...
...
@@ -99,7 +100,8 @@ public class BgySmsServiceImpl implements BgySmsService {
requestParams
.
put
(
"templateId"
,
templateId
);
requestParams
.
put
(
"data"
,
data
);
log
.
info
(
"碧桂园短信接口参数:{}"
,
requestParams
);
//TODO
String
retStr
=
SendSmsUtil
.
sendSmsByPost
(
url
,
JSONObject
.
toJSONString
(
requestParams
));
String
reqStr
=
JSONObject
.
toJSONString
(
requestParams
);
String
retStr
=
SendSmsUtil
.
sendSmsByPost
(
url
,
reqStr
);
log
.
info
(
"碧桂园短信接口返回信息:{}"
,
retStr
);
if
(
retStr
==
null
)
{
return
new
CLBizResponse
(
ResponseCode
.
UPSTREAM_BLANK
);
...
...
@@ -190,7 +192,6 @@ public class BgySmsServiceImpl implements BgySmsService {
}
public
static
void
main
(
String
[]
args
)
{
...
...
src/main/java/com/bgy/sms/service/impl/MessageServiceImpl.java
View file @
a8064744
...
...
@@ -11,8 +11,6 @@ import com.bgy.sms.config.ResponseCode;
import
com.bgy.sms.repository.domain.*
;
import
com.bgy.sms.service.*
;
import
com.bgy.sms.service.bean.TemplateChangeBean
;
import
com.bgy.util.HttpUtil
;
import
com.bgy.util.Md5Util
;
import
com.bgy.util.id.IdHandler
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
...
...
@@ -223,13 +221,11 @@ public class MessageServiceImpl implements MessageService {
}
// 2、根据请求信息获取用户的手机号码(此处不考虑配置DMHUB系统不是SMS的情况),直接拿请求体中的_audienceId字段值,该值为手机号码
// 模板参数占位符
if
(
templateInfo
.
getStatus
()
.
equals
(
"abnormal"
))
{
return
new
DmHubResponse
(
"1001"
,
"当前模板暂未审核通过,请重新选择"
);
String
templateName
=
templateInfo
.
getTemplateName
();
String
[]
split
=
templateName
.
split
(
"_"
);
if
(
split
==
null
||
split
.
length
<=
1
)
{
return
new
DmHubResponse
(
"999"
,
"短信模板名称命名不规范,请使用:项目ID_模板名称格式"
);
}
String
areaId
=
split
[
0
];
String
params
=
templateInfo
.
getParams
();
JSONArray
paramsArr
=
JSONArray
.
parseArray
(
params
);
String
smsType
=
templateInfo
.
getType
();
...
...
@@ -291,7 +287,7 @@ public class MessageServiceImpl implements MessageService {
api
=
"SendNotifySMS"
;
}
response
=
bgySmsService
.
sendSms
(
mobile
,
content
,
areaId
,
api
);
response
=
bgySmsService
.
sendSms
(
mobile
,
content
,
channelAccount
,
api
);
//4.短信发送记录
SysRecordInfo
sysRecordInfo
=
new
SysRecordInfo
();
...
...
@@ -383,8 +379,8 @@ public class MessageServiceImpl implements MessageService {
return
new
DmHubResponse
(
"999"
,
"短信插件未获取到模板信息"
);
}
if
(
templateInfo
.
get
TemplateRecordId
()
==
null
)
{
return
new
DmHubResponse
(
"1001"
,
"当前模板暂未审核,请重新选择"
);
if
(
templateInfo
.
get
Status
()
.
equals
(
"abnormal"
)
)
{
return
new
DmHubResponse
(
"1001"
,
"当前模板暂未审核
通过
,请重新选择"
);
}
String
api
=
""
;
...
...
@@ -396,12 +392,6 @@ public class MessageServiceImpl implements MessageService {
//模板流水号
String
templateRecordId
=
templateInfo
.
getTemplateRecordId
();
String
smsType
=
templateInfo
.
getType
();
String
templateName
=
templateInfo
.
getTemplateName
();
String
[]
split
=
templateName
.
split
(
"_"
);
if
(
split
==
null
||
split
.
length
<=
1
)
{
return
new
DmHubResponse
(
"999"
,
"短信模板名称命名不规范,请使用:项目ID_模板名称格式"
);
}
String
areaId
=
split
[
0
];
// 模板参数占位符
String
params
=
templateInfo
.
getParams
();
JSONArray
paramsArr
=
JSONArray
.
parseArray
(
params
);
...
...
@@ -471,8 +461,6 @@ public class MessageServiceImpl implements MessageService {
sysRecordInfo
.
setId
(
IdHandler
.
nextId
());
long
sysRecordInfoBatchId
=
IdHandler
.
nextId
();
sysRecordInfo
.
setSysBatchId
(
sysRecordInfoBatchId
);
//sysRecordInfo.setMsgId();
//sysRecordInfo.setParams();
Date
date
=
new
Date
();
sysRecordInfo
.
setDateCreated
(
date
);
sysRecordInfo
.
setLastUpdated
(
date
);
...
...
@@ -491,7 +479,7 @@ public class MessageServiceImpl implements MessageService {
}
try
{
if
(!
list
.
isEmpty
())
{
response
=
bgySmsService
.
send
batchSms
(
JSONObject
.
toJSONString
(
list
),
areaId
,
api
,
templateRecordId
);
response
=
bgySmsService
.
send
BatchSms
(
list
,
channelAccount
,
api
,
templateRecordId
);
String
code
=
response
.
getCode
();
if
(
code
.
equals
(
ResponseCode
.
SUCCESS
.
getCode
()))
{
sysRecordInfo
.
setChargeNum
(
list
.
size
());
...
...
@@ -532,7 +520,6 @@ public class MessageServiceImpl implements MessageService {
String
mobile
=
entry
.
getKey
().
toString
();
List
<
String
>
paramsList
=
entry
.
getValue
();
String
sendMsg
=
getMsg
(
templateInfo
.
getUpContent
(),
paramsList
);
JSONObject
jsonObject
=
new
JSONObject
();
mobiles
.
append
(
mobile
+
","
);
jsonObject
.
put
(
"Mobile"
,
mobile
);
...
...
@@ -541,7 +528,7 @@ public class MessageServiceImpl implements MessageService {
}
try
{
response
=
bgySmsService
.
send
batchSms
(
JSONObject
.
toJSONString
(
list
),
areaId
,
api
,
templateRecordId
);
response
=
bgySmsService
.
send
BatchSms
(
list
,
channelAccount
,
api
,
templateRecordId
);
String
code
=
response
.
getCode
();
if
(
code
.
equals
(
ResponseCode
.
SUCCESS
.
getCode
()))
{
sysRecordInfo
.
setChargeNum
(
list
.
size
());
...
...
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