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
c5086574
Commit
c5086574
authored
Jul 15, 2020
by
qinxunjia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化逻辑
parent
73720f71
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
50 deletions
+10
-50
DmHubApi.java
src/main/java/com/bgy/sms/channel/api/DmHubApi.java
+0
-3
BgySmsServiceImpl.java
...m/bgy/sms/channel/bgy/service/impl/BgySmsServiceImpl.java
+9
-35
MessageServiceImpl.java
...ain/java/com/bgy/sms/service/impl/MessageServiceImpl.java
+1
-12
No files found.
src/main/java/com/bgy/sms/channel/api/DmHubApi.java
View file @
c5086574
...
@@ -90,7 +90,6 @@ public class DmHubApi {
...
@@ -90,7 +90,6 @@ public class DmHubApi {
return
new
DmHubResponse
(
"555"
,
"接口请求签名校验不通过"
);
return
new
DmHubResponse
(
"555"
,
"接口请求签名校验不通过"
);
}
}
response
=
messageService
.
batchSendBatch
(
request
);
response
=
messageService
.
batchSendBatch
(
request
);
response
.
setCode
(
response
.
getError
().
getString
(
"errorCode"
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"发送批量短信异常"
,
e
);
log
.
error
(
"发送批量短信异常"
,
e
);
response
=
new
DmHubResponse
(
ResponseCode
.
SYSTEM_ERROR
);
response
=
new
DmHubResponse
(
ResponseCode
.
SYSTEM_ERROR
);
...
@@ -125,9 +124,7 @@ public class DmHubApi {
...
@@ -125,9 +124,7 @@ public class DmHubApi {
if
(!
checkResult
)
{
if
(!
checkResult
)
{
return
new
DmHubResponse
(
"555"
,
"签名校验不通过"
);
return
new
DmHubResponse
(
"555"
,
"签名校验不通过"
);
}
}
response
=
messageService
.
send
(
request
);
response
=
messageService
.
send
(
request
);
response
.
setCode
(
response
.
getError
().
getString
(
"errorCode"
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"发送单条短信异常"
,
e
);
log
.
error
(
"发送单条短信异常"
,
e
);
response
=
new
DmHubResponse
(
ResponseCode
.
SYSTEM_ERROR
);
response
=
new
DmHubResponse
(
ResponseCode
.
SYSTEM_ERROR
);
...
...
src/main/java/com/bgy/sms/channel/bgy/service/impl/BgySmsServiceImpl.java
View file @
c5086574
...
@@ -14,6 +14,7 @@ import com.bgy.sms.repository.domain.SmsTemplateInfo;
...
@@ -14,6 +14,7 @@ import com.bgy.sms.repository.domain.SmsTemplateInfo;
import
com.bgy.sms.service.SmsTemplateService
;
import
com.bgy.sms.service.SmsTemplateService
;
import
com.bgy.util.HttpUtil
;
import
com.bgy.util.HttpUtil
;
import
com.bgy.util.Md5Util
;
import
com.bgy.util.Md5Util
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -31,6 +32,7 @@ public class BgySmsServiceImpl implements BgySmsService {
...
@@ -31,6 +32,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
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"
;
// 响应描述
...
@@ -106,14 +108,14 @@ public class BgySmsServiceImpl implements BgySmsService {
...
@@ -106,14 +108,14 @@ 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
retPack
=
retJson
.
getString
(
"package"
);
String
status
=
retJson
.
getString
(
"Status"
);
String
retCode
=
retJson
.
getString
(
"ret"
);
String
retCode
=
retJson
.
getString
(
"ret"
);
if
(!
sendSuccessCode
.
equals
(
retCode
))
{
if
(
StringUtils
.
isBlank
(
status
)
||
Fail
.
equals
(
status
))
{
if
(
err
.
contains
(
"成功"
))
{
return
new
CLBizResponse
(
ResponseCode
.
SUCCESS
);
}
return
new
CLBizResponse
(
ResponseCode
.
UPSTREAM_FAIL
.
getCode
(),
err
);
return
new
CLBizResponse
(
ResponseCode
.
UPSTREAM_FAIL
.
getCode
(),
err
);
}
else
{
}
else
if
(
sendSuccessCode
.
equals
(
retCode
))
{
return
new
CLBizResponse
(
ResponseCode
.
SUCCESS
);
return
new
CLBizResponse
(
ResponseCode
.
SUCCESS
);
}
else
{
return
new
CLBizResponse
(
ResponseCode
.
UPSTREAM_FAIL
.
getCode
(),
err
);
}
}
}
}
...
@@ -152,11 +154,11 @@ public class BgySmsServiceImpl implements BgySmsService {
...
@@ -152,11 +154,11 @@ public class BgySmsServiceImpl implements BgySmsService {
String
appId
=
BgySMSConfig
.
appId
;
String
appId
=
BgySMSConfig
.
appId
;
String
securityCode
=
BgySMSConfig
.
securityCode
;
String
securityCode
=
BgySMSConfig
.
securityCode
;
Map
<
String
,
String
>
param
=
new
HashMap
<>();
Map
<
String
,
String
>
param
=
new
HashMap
<>();
param
.
put
(
"api"
,
"AddTemplate"
);
//TODO
param
.
put
(
"api"
,
"AddTemplate"
);
param
.
put
(
"appid"
,
appId
);
param
.
put
(
"appid"
,
appId
);
param
.
put
(
"security"
,
Md5Util
.
encrypt
(
appId
+
securityCode
.
toUpperCase
()));
param
.
put
(
"security"
,
Md5Util
.
encrypt
(
appId
+
securityCode
.
toUpperCase
()));
param
.
put
(
"content"
,
content
);
param
.
put
(
"content"
,
content
);
param
.
put
(
"areaid"
,
"XXJSB"
);
param
.
put
(
"areaid"
,
BgySMSConfig
.
areaId
);
param
.
put
(
"pkID"
,
pkID
);
param
.
put
(
"pkID"
,
pkID
);
param
.
put
(
"slxtID"
,
account
);
param
.
put
(
"slxtID"
,
account
);
param
.
put
(
"templateType"
,
templateType
);
param
.
put
(
"templateType"
,
templateType
);
...
@@ -184,32 +186,4 @@ public class BgySmsServiceImpl implements BgySmsService {
...
@@ -184,32 +186,4 @@ public class BgySmsServiceImpl implements BgySmsService {
return
new
CLBizResponse
(
ResponseCode
.
SUCCESS
.
getCode
(),
data
);
return
new
CLBizResponse
(
ResponseCode
.
SUCCESS
.
getCode
(),
data
);
}
}
}
}
public
static
void
main
(
String
[]
args
)
{
String
appId
=
BgySMSConfig
.
appId
;
String
a
=
Md5Util
.
encrypt
(
2021
+
"930844c7-7985-435b-af47-142b59b299c3"
.
toUpperCase
());
System
.
out
.
println
(
a
);
System
.
out
.
println
(
appId
);
if
(
1
==
1
)
{
return
;
}
// String areaId = BgySMSConfig.areaId;
String
securityCode
=
BgySMSConfig
.
securityCode
;
String
url
=
BgySMSConfig
.
url
;
String
api
=
BgySMSConfig
.
api
;
Map
<
String
,
String
>
requestParams
=
new
HashMap
<>();
requestParams
.
put
(
"api"
,
"SendYXSMS"
);
requestParams
.
put
(
"appId"
,
""
);
requestParams
.
put
(
"security"
,
""
);
requestParams
.
put
(
"areaId"
,
"XXJSB"
);
requestParams
.
put
(
"content"
,
"测试模板内容,占位符测试:11,再来一个:22!退订回复TD【碧桂园】"
);
requestParams
.
put
(
"mobile"
,
"18088834894"
);
log
.
info
(
"碧桂园短信接口参数:{}"
,
requestParams
);
String
retStr
=
SendSmsUtil
.
sendSmsByPost
(
"https://xstest.bgy.com.cn/ApiBgyTest/Open/Sms.ashx"
,
JSONObject
.
toJSONString
(
requestParams
));
log
.
info
(
"碧桂园短信接口返回信息:{}"
,
retStr
);
}
}
}
src/main/java/com/bgy/sms/service/impl/MessageServiceImpl.java
View file @
c5086574
...
@@ -303,8 +303,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -303,8 +303,7 @@ public class MessageServiceImpl implements MessageService {
sysRecordInfo
.
setStatus
(
ResponseCode
.
SUCCESS
.
getCode
());
sysRecordInfo
.
setStatus
(
ResponseCode
.
SUCCESS
.
getCode
());
sysRecordInfo
.
setStatusDesc
(
response
.
getMsg
());
sysRecordInfo
.
setStatusDesc
(
response
.
getMsg
());
sysRecordService
.
insert
(
sysRecordInfo
);
sysRecordService
.
insert
(
sysRecordInfo
);
return
new
DmHubResponse
(
ResponseCode
.
SUCCESS
.
getCode
(),
ResponseCode
.
SUCCESS
.
getMsg
());
return
new
DmHubResponse
(
ResponseCode
.
SUCCESS
);
}
else
{
}
else
{
sysRecordInfo
.
setStatus
(
ResponseCode
.
UPSTREAM_FAIL
.
getCode
());
sysRecordInfo
.
setStatus
(
ResponseCode
.
UPSTREAM_FAIL
.
getCode
());
sysRecordInfo
.
setStatusDesc
(
response
.
getMsg
());
sysRecordInfo
.
setStatusDesc
(
response
.
getMsg
());
...
@@ -447,7 +446,6 @@ public class MessageServiceImpl implements MessageService {
...
@@ -447,7 +446,6 @@ public class MessageServiceImpl implements MessageService {
sysBatchService
.
insert
(
info
);
sysBatchService
.
insert
(
info
);
CLBizResponse
response
=
new
CLBizResponse
();
CLBizResponse
response
=
new
CLBizResponse
();
//4.短信发送记录
//4.短信发送记录
SysRecordInfo
sysRecordInfo
=
new
SysRecordInfo
();
SysRecordInfo
sysRecordInfo
=
new
SysRecordInfo
();
sysRecordInfo
.
setId
(
IdHandler
.
nextId
());
sysRecordInfo
.
setId
(
IdHandler
.
nextId
());
...
@@ -477,11 +475,9 @@ public class MessageServiceImpl implements MessageService {
...
@@ -477,11 +475,9 @@ public class MessageServiceImpl implements MessageService {
sysRecordInfo
.
setChargeNum
(
list
.
size
());
sysRecordInfo
.
setChargeNum
(
list
.
size
());
sysRecordInfo
.
setMobile
(
mobiles
.
deleteCharAt
(
mobiles
.
length
()
-
1
).
toString
());
sysRecordInfo
.
setMobile
(
mobiles
.
deleteCharAt
(
mobiles
.
length
()
-
1
).
toString
());
sysRecordInfo
.
setContent
(
content
);
sysRecordInfo
.
setContent
(
content
);
sysRecordInfo
.
setStatus
(
ResponseCode
.
SUCCESS
.
getCode
());
sysRecordInfo
.
setStatus
(
ResponseCode
.
SUCCESS
.
getCode
());
sysRecordInfo
.
setStatusDesc
(
response
.
getMsg
());
sysRecordInfo
.
setStatusDesc
(
response
.
getMsg
());
sysRecordService
.
insert
(
sysRecordInfo
);
sysRecordService
.
insert
(
sysRecordInfo
);
return
new
DmHubResponse
(
ResponseCode
.
SUCCESS
.
getCode
(),
ResponseCode
.
SUCCESS
.
getMsg
());
return
new
DmHubResponse
(
ResponseCode
.
SUCCESS
.
getCode
(),
ResponseCode
.
SUCCESS
.
getMsg
());
}
else
{
}
else
{
sysRecordInfo
.
setChargeNum
(
list
.
size
());
sysRecordInfo
.
setChargeNum
(
list
.
size
());
...
@@ -494,13 +490,11 @@ public class MessageServiceImpl implements MessageService {
...
@@ -494,13 +490,11 @@ public class MessageServiceImpl implements MessageService {
return
new
DmHubResponse
(
code
,
response
.
getMsg
());
return
new
DmHubResponse
(
code
,
response
.
getMsg
());
}
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"调用碧桂园逻辑错误"
,
e
);
log
.
error
(
"调用碧桂园逻辑错误"
,
e
);
return
new
DmHubResponse
(
"999"
,
"插件服务系统异常"
);
return
new
DmHubResponse
(
"999"
,
"插件服务系统异常"
);
}
}
}
else
{
}
else
{
// 变量短信
// 变量短信
Set
<
Map
.
Entry
<
String
,
List
<
String
>>>
entries
=
paramsMap
.
entrySet
();
Set
<
Map
.
Entry
<
String
,
List
<
String
>>>
entries
=
paramsMap
.
entrySet
();
...
@@ -518,28 +512,23 @@ public class MessageServiceImpl implements MessageService {
...
@@ -518,28 +512,23 @@ public class MessageServiceImpl implements MessageService {
list
.
add
(
jsonObject
);
list
.
add
(
jsonObject
);
}
}
try
{
try
{
response
=
bgySmsService
.
sendBatchSms
(
list
,
channelAccount
,
api
,
templateRecordId
);
response
=
bgySmsService
.
sendBatchSms
(
list
,
channelAccount
,
api
,
templateRecordId
);
String
code
=
response
.
getCode
();
String
code
=
response
.
getCode
();
if
(
code
.
equals
(
ResponseCode
.
SUCCESS
.
getCode
()))
{
if
(
code
.
equals
(
ResponseCode
.
SUCCESS
.
getCode
()))
{
sysRecordInfo
.
setChargeNum
(
list
.
size
());
sysRecordInfo
.
setChargeNum
(
list
.
size
());
sysRecordInfo
.
setMobile
(
mobiles
.
deleteCharAt
(
mobiles
.
length
()
-
1
).
toString
());
sysRecordInfo
.
setMobile
(
mobiles
.
deleteCharAt
(
mobiles
.
length
()
-
1
).
toString
());
sysRecordInfo
.
setContent
(
content
);
sysRecordInfo
.
setContent
(
content
);
sysRecordInfo
.
setStatus
(
ResponseCode
.
SUCCESS
.
getCode
());
sysRecordInfo
.
setStatus
(
ResponseCode
.
SUCCESS
.
getCode
());
sysRecordInfo
.
setStatusDesc
(
response
.
getMsg
());
sysRecordInfo
.
setStatusDesc
(
response
.
getMsg
());
sysRecordService
.
insert
(
sysRecordInfo
);
sysRecordService
.
insert
(
sysRecordInfo
);
return
new
DmHubResponse
(
ResponseCode
.
SUCCESS
.
getCode
(),
ResponseCode
.
SUCCESS
.
getMsg
());
return
new
DmHubResponse
(
ResponseCode
.
SUCCESS
.
getCode
(),
ResponseCode
.
SUCCESS
.
getMsg
());
}
else
{
}
else
{
sysRecordInfo
.
setChargeNum
(
list
.
size
());
sysRecordInfo
.
setChargeNum
(
list
.
size
());
sysRecordInfo
.
setMobile
(
mobiles
.
deleteCharAt
(
mobiles
.
length
()
-
1
).
toString
());
sysRecordInfo
.
setMobile
(
mobiles
.
deleteCharAt
(
mobiles
.
length
()
-
1
).
toString
());
sysRecordInfo
.
setContent
(
content
);
sysRecordInfo
.
setContent
(
content
);
sysRecordInfo
.
setStatus
(
ResponseCode
.
UPSTREAM_FAIL
.
getCode
());
sysRecordInfo
.
setStatus
(
ResponseCode
.
UPSTREAM_FAIL
.
getCode
());
sysRecordInfo
.
setStatusDesc
(
response
.
getMsg
());
sysRecordInfo
.
setStatusDesc
(
response
.
getMsg
());
boolean
a
=
sysRecordService
.
insert
(
sysRecordInfo
);
boolean
a
=
sysRecordService
.
insert
(
sysRecordInfo
);
return
new
DmHubResponse
(
code
,
response
.
getMsg
());
return
new
DmHubResponse
(
code
,
response
.
getMsg
());
}
}
...
...
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