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
008568de
Commit
008568de
authored
Jul 08, 2020
by
fuwanli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"上"
parent
67f2b6a5
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
369 additions
and
45 deletions
+369
-45
DmHubApi.java
src/main/java/com/bgy/sms/channel/api/DmHubApi.java
+38
-3
BgySmsService.java
...n/java/com/bgy/sms/channel/bgy/service/BgySmsService.java
+2
-0
BgySmsServiceImpl.java
...m/bgy/sms/channel/bgy/service/impl/BgySmsServiceImpl.java
+34
-0
SysRecordInfo.java
...ain/java/com/bgy/sms/repository/domain/SysRecordInfo.java
+131
-0
SysRecordMapper.java
...n/java/com/bgy/sms/repository/mapper/SysRecordMapper.java
+9
-0
SysRecordService.java
src/main/java/com/bgy/sms/service/SysRecordService.java
+7
-0
MessageServiceImpl.java
...ain/java/com/bgy/sms/service/impl/MessageServiceImpl.java
+135
-41
SysRecordServiceImpl.java
...n/java/com/bgy/sms/service/impl/SysRecordServiceImpl.java
+12
-0
application-dev.yml
src/main/resources/application-dev.yml
+1
-1
No files found.
src/main/java/com/bgy/sms/channel/api/DmHubApi.java
View file @
008568de
package
com
.
bgy
.
sms
.
channel
.
api
;
package
com
.
bgy
.
sms
.
channel
.
api
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.bgy.sms.channel.bgy.config.BgySMSConfig
;
import
com.bgy.sms.channel.bgy.config.BgySMSConfig
;
import
com.bgy.sms.channel.dmHub.config.DmHubConfig
;
import
com.bgy.sms.channel.dmHub.config.DmHubConfig
;
...
@@ -15,6 +16,9 @@ import org.slf4j.LoggerFactory;
...
@@ -15,6 +16,9 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.ArrayList
;
import
java.util.List
;
@SuppressWarnings
(
"Duplicates"
)
@SuppressWarnings
(
"Duplicates"
)
@RestController
@RestController
@RequestMapping
()
@RequestMapping
()
...
@@ -94,10 +98,28 @@ public class DmHubApi {
...
@@ -94,10 +98,28 @@ public class DmHubApi {
DmHubResponse
response
;
DmHubResponse
response
;
try
{
try
{
boolean
checkResult
=
this
.
checkSignature
(
timestamp
,
signature
);
boolean
checkResult
=
this
.
checkSignature
(
timestamp
,
signature
);
if
(!
checkResult
)
{
/*
if (!checkResult) {
return new DmHubResponse("555", "接口请求签名校验不通过");
return new DmHubResponse("555", "接口请求签名校验不通过");
}*/
List
<
JSONObject
>
data
=
new
ArrayList
<>();
for
(
int
x
=
0
;
x
<
5
;
x
++)
{
String
a
=
"{\n"
+
"\t\"_audienceId\": \"15323888603\",\n"
+
"\t\"name\": \"大夹子\",\n"
+
"\t\"id\": \"699169968926801920\",\n"
+
"\t\"isRealtime\": false\n"
+
"}"
;
a
=
a
.
replaceAll
(
"15323888603"
,
"1532388860"
+
(
3
+
x
));
JSONObject
c
=
JSON
.
parseObject
(
a
);
data
.
add
(
c
);
}
}
request
.
setData
(
data
);
response
=
messageService
.
batchSendOneByOne
(
request
);
response
=
messageService
.
batchSendOneByOne
(
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
);
...
@@ -128,11 +150,24 @@ public class DmHubApi {
...
@@ -128,11 +150,24 @@ public class DmHubApi {
log
.
info
(
"**********单条发送入参*******:{},\r\n appId:{},timestamp:{},signature:{}"
,
JSONObject
.
toJSONString
(
request
),
appId
,
timestamp
,
signature
);
log
.
info
(
"**********单条发送入参*******:{},\r\n appId:{},timestamp:{},signature:{}"
,
JSONObject
.
toJSONString
(
request
),
appId
,
timestamp
,
signature
);
DmHubResponse
response
;
DmHubResponse
response
;
try
{
try
{
boolean
checkResult
=
this
.
checkSignature
(
timestamp
,
signature
);
/*
boolean checkResult = this.checkSignature(timestamp, signature);
if (!checkResult) {
if (!checkResult) {
return new DmHubResponse("555", "签名校验不通过");
return new DmHubResponse("555", "签名校验不通过");
}
}*/
String
a
=
"{\n"
+
"\t\"_audienceId\": \"15323888603\",\n"
+
"\t\"name\": \"大夹子\",\n"
+
"\t\"id\": \"699169968926801920\",\n"
+
"\t\"isRealtime\": false\n"
+
"}"
;
JSONObject
c
=
JSON
.
parseObject
(
a
);
request
.
setData
(
c
);
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/BgySmsService.java
View file @
008568de
...
@@ -8,6 +8,8 @@ public interface BgySmsService {
...
@@ -8,6 +8,8 @@ public interface BgySmsService {
CLBizResponse
sendSms
(
String
mobile
,
String
content
,
String
areaId
)
throws
Exception
;
CLBizResponse
sendSms
(
String
mobile
,
String
content
,
String
areaId
)
throws
Exception
;
CLBizResponse
sendbatchSms
(
String
mobile
,
String
areaId
)
throws
Exception
;
void
asyncNotify
(
TemplateNotify
templateNotify
);
void
asyncNotify
(
TemplateNotify
templateNotify
);
}
}
src/main/java/com/bgy/sms/channel/bgy/service/impl/BgySmsServiceImpl.java
View file @
008568de
...
@@ -78,6 +78,40 @@ public class BgySmsServiceImpl implements BgySmsService {
...
@@ -78,6 +78,40 @@ public class BgySmsServiceImpl implements BgySmsService {
}
}
}
}
@Override
public
CLBizResponse
sendbatchSms
(
String
data
,
String
areaId
)
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
<>();
requestParams
.
put
(
"api"
,
api
);
requestParams
.
put
(
"appId"
,
appId
);
requestParams
.
put
(
"security"
,
Md5Util
.
encrypt
(
appId
+
securityCode
.
toUpperCase
()));
requestParams
.
put
(
"areaId"
,
areaId
);
requestParams
.
put
(
"data"
,
data
);
log
.
info
(
"碧桂园短信接口参数:{}"
,
requestParams
);
String
retStr
=
SendSmsUtil
.
sendSmsByPost
(
url
,
JSONObject
.
toJSONString
(
requestParams
));
log
.
info
(
"碧桂园短信接口返回信息:{}"
,
retStr
);
if
(
retStr
==
null
)
{
return
new
CLBizResponse
(
ResponseCode
.
UPSTREAM_BLANK
);
}
JSONObject
retJson
=
JSONObject
.
parseObject
(
retStr
);
String
err
=
retJson
.
getString
(
"err"
);
String
retPack
=
retJson
.
getString
(
"package"
);
String
retCode
=
retJson
.
getString
(
"ret"
);
if
(!
sendSuccessCode
.
equals
(
retCode
))
{
if
(
err
.
contains
(
"成功"
))
{
return
new
CLBizResponse
(
ResponseCode
.
SUCCESS
);
}
return
new
CLBizResponse
(
ResponseCode
.
UPSTREAM_FAIL
.
getCode
(),
err
);
}
else
{
return
new
CLBizResponse
(
ResponseCode
.
SUCCESS
);
}
}
/**
/**
* 处理短信模板的通知
* 处理短信模板的通知
*
*
...
...
src/main/java/com/bgy/sms/repository/domain/SysRecordInfo.java
0 → 100644
View file @
008568de
package
com
.
bgy
.
sms
.
repository
.
domain
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
java.util.Date
;
@TableName
(
"sms_record"
)
public
class
SysRecordInfo
{
private
Long
id
;
private
Long
sysBatchId
;
private
String
mobile
;
private
String
msgId
;
private
Integer
chargeNum
;
private
String
content
;
private
String
params
;
private
String
status
;
private
String
statusDesc
;
private
Date
dateCreated
;
private
Date
lastUpdated
;
private
String
areaId
;
public
String
getAreaId
()
{
return
areaId
;
}
public
void
setAreaId
(
String
areaId
)
{
this
.
areaId
=
areaId
;
}
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
Long
getSysBatchId
()
{
return
sysBatchId
;
}
public
void
setSysBatchId
(
Long
sysBatchId
)
{
this
.
sysBatchId
=
sysBatchId
;
}
public
String
getMobile
()
{
return
mobile
;
}
public
void
setMobile
(
String
mobile
)
{
this
.
mobile
=
mobile
;
}
public
String
getMsgId
()
{
return
msgId
;
}
public
void
setMsgId
(
String
msgId
)
{
this
.
msgId
=
msgId
;
}
public
Integer
getChargeNum
()
{
return
chargeNum
;
}
public
void
setChargeNum
(
Integer
chargeNum
)
{
this
.
chargeNum
=
chargeNum
;
}
public
String
getContent
()
{
return
content
;
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
}
public
String
getParams
()
{
return
params
;
}
public
void
setParams
(
String
params
)
{
this
.
params
=
params
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
String
getStatusDesc
()
{
return
statusDesc
;
}
public
void
setStatusDesc
(
String
statusDesc
)
{
this
.
statusDesc
=
statusDesc
;
}
public
Date
getDateCreated
()
{
return
dateCreated
;
}
public
void
setDateCreated
(
Date
dateCreated
)
{
this
.
dateCreated
=
dateCreated
;
}
public
Date
getLastUpdated
()
{
return
lastUpdated
;
}
public
void
setLastUpdated
(
Date
lastUpdated
)
{
this
.
lastUpdated
=
lastUpdated
;
}
}
src/main/java/com/bgy/sms/repository/mapper/SysRecordMapper.java
0 → 100644
View file @
008568de
package
com
.
bgy
.
sms
.
repository
.
mapper
;
import
com.baomidou.mybatisplus.mapper.BaseMapper
;
import
com.bgy.sms.repository.domain.SysRecordInfo
;
public
interface
SysRecordMapper
extends
BaseMapper
<
SysRecordInfo
>
{
}
src/main/java/com/bgy/sms/service/SysRecordService.java
0 → 100644
View file @
008568de
package
com
.
bgy
.
sms
.
service
;
import
com.baomidou.mybatisplus.service.IService
;
import
com.bgy.sms.repository.domain.SysRecordInfo
;
public
interface
SysRecordService
extends
IService
<
SysRecordInfo
>
{
}
src/main/java/com/bgy/sms/service/impl/MessageServiceImpl.java
View file @
008568de
...
@@ -8,14 +8,8 @@ import com.bgy.sms.channel.bgy.dto.CLBizResponse;
...
@@ -8,14 +8,8 @@ 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.channel.dto.*
;
import
com.bgy.sms.channel.dto.*
;
import
com.bgy.sms.config.ResponseCode
;
import
com.bgy.sms.config.ResponseCode
;
import
com.bgy.sms.repository.domain.DmBatchInfo
;
import
com.bgy.sms.repository.domain.*
;
import
com.bgy.sms.repository.domain.DmCodeInfo
;
import
com.bgy.sms.service.*
;
import
com.bgy.sms.repository.domain.SmsTemplateInfo
;
import
com.bgy.sms.repository.domain.SysBatchInfo
;
import
com.bgy.sms.service.DmBatchService
;
import
com.bgy.sms.service.DmCodeService
;
import
com.bgy.sms.service.MessageService
;
import
com.bgy.sms.service.SmsTemplateService
;
import
com.bgy.sms.service.bean.TemplateChangeBean
;
import
com.bgy.sms.service.bean.TemplateChangeBean
;
import
com.bgy.util.HttpUtil
;
import
com.bgy.util.HttpUtil
;
import
com.bgy.util.Md5Util
;
import
com.bgy.util.Md5Util
;
...
@@ -49,6 +43,9 @@ public class MessageServiceImpl implements MessageService {
...
@@ -49,6 +43,9 @@ public class MessageServiceImpl implements MessageService {
@Autowired
@Autowired
private
DmCodeService
dmCodeService
;
private
DmCodeService
dmCodeService
;
@Autowired
private
SysRecordService
sysRecordService
;
/**
/**
* 短信模板创建
* 短信模板创建
*
*
...
@@ -96,11 +93,12 @@ public class MessageServiceImpl implements MessageService {
...
@@ -96,11 +93,12 @@ public class MessageServiceImpl implements MessageService {
if
(!
insert
)
{
if
(!
insert
)
{
log
.
error
(
"模板插入DB异常:【{}】"
,
JSONObject
.
toJSONString
(
info
));
log
.
error
(
"模板插入DB异常:【{}】"
,
JSONObject
.
toJSONString
(
info
));
return
new
DmHubResponse
(
ResponseCode
.
SYSTEM_ERROR
);
return
new
DmHubResponse
(
ResponseCode
.
SYSTEM_ERROR
);
}
else
{
}
else
{
String
appId
=
BgySMSConfig
.
appId
;
String
appId
=
BgySMSConfig
.
appId
;
String
securityCode
=
BgySMSConfig
.
securityCode
;
String
securityCode
=
BgySMSConfig
.
securityCode
;
String
pkID
=
info
.
getId
()
+
""
;
String
pkID
=
info
.
getId
()
+
""
;
String
content
=
info
.
getContent
();
String
content
=
info
.
getContent
();
String
TEMPLATETYPE
=
"52"
;
JSONObject
param
=
new
JSONObject
();
JSONObject
param
=
new
JSONObject
();
param
.
put
(
"api"
,
"AddTemplate"
);
param
.
put
(
"api"
,
"AddTemplate"
);
param
.
put
(
"appid"
,
appId
);
param
.
put
(
"appid"
,
appId
);
...
@@ -109,7 +107,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -109,7 +107,7 @@ public class MessageServiceImpl implements MessageService {
param
.
put
(
"areaid"
,
"FHY"
);
param
.
put
(
"areaid"
,
"FHY"
);
param
.
put
(
"pkID"
,
pkID
);
param
.
put
(
"pkID"
,
pkID
);
param
.
put
(
"account"
,
"SZH003"
);
param
.
put
(
"account"
,
"SZH003"
);
param
.
put
(
"templateType"
,
""
);
param
.
put
(
"templateType"
,
TEMPLATETYPE
);
String
retStr
=
HttpUtil
.
sendPost
(
BgySMSConfig
.
url
,
JSONObject
.
toJSONString
(
param
));
String
retStr
=
HttpUtil
.
sendPost
(
BgySMSConfig
.
url
,
JSONObject
.
toJSONString
(
param
));
JSONObject
retJson
=
JSONObject
.
parseObject
(
retStr
);
JSONObject
retJson
=
JSONObject
.
parseObject
(
retStr
);
...
@@ -122,16 +120,21 @@ public class MessageServiceImpl implements MessageService {
...
@@ -122,16 +120,21 @@ public class MessageServiceImpl implements MessageService {
JSONObject
Json
=
JSONObject
.
parseObject
(
reePackage
);
JSONObject
Json
=
JSONObject
.
parseObject
(
reePackage
);
String
data
=
Json
.
getString
(
"data"
);
String
data
=
Json
.
getString
(
"data"
);
info
.
setTemplateRecordId
(
data
);
info
.
setTemplateRecordId
(
data
);
info
.
setStatus
(
"normal"
);
info
.
setId
(
Long
.
parseLong
(
pkID
));
info
.
setId
(
Long
.
parseLong
(
pkID
));
smsTemplateService
.
updateById
(
info
);
smsTemplateService
.
updateById
(
info
);
responseDTO
.
setCode
(
ResponseCode
.
SUCCESS
.
getCode
());
responseDTO
.
setError
(
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
err
)));
return
responseDTO
;
}
}
responseDTO
.
setCode
(
ResponseCode
.
SYSTEM_ERROR
.
getCode
());
responseDTO
.
setError
(
retJson
);
return
responseDTO
;
}
else
{
responseDTO
.
setCode
(
ResponseCode
.
SYSTEM_ERROR
.
getCode
());
responseDTO
.
setError
(
retJson
);
return
responseDTO
;
}
}
responseDTO
.
setCode
(
ResponseCode
.
SUCCESS
.
getCode
());
responseDTO
.
setError
(
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
info
)));
return
responseDTO
;
}
}
}
catch
(
Exception
exception
)
{
}
catch
(
Exception
exception
)
{
log
.
error
(
"创建模板业务逻辑异常,错误信息"
,
exception
);
log
.
error
(
"创建模板业务逻辑异常,错误信息"
,
exception
);
...
@@ -169,7 +172,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -169,7 +172,7 @@ public class MessageServiceImpl implements MessageService {
g
=
Matcher
.
quoteReplacement
(
g
);
g
=
Matcher
.
quoteReplacement
(
g
);
g
=
escapeRegex
(
g
);
g
=
escapeRegex
(
g
);
// upSendStr = upSendStr.replaceAll(g, "\\{\\$var\\}");
// upSendStr = upSendStr.replaceAll(g, "\\{\\$var\\}");
upSendStr
=
upSendStr
.
replaceAll
(
g
,
"\\
{\\$\\$\\}
"
);
upSendStr
=
upSendStr
.
replaceAll
(
g
,
"\\
$\\$
"
);
if
(
t
.
contains
(
"${surl!"
))
{
if
(
t
.
contains
(
"${surl!"
))
{
// 短链没传长度,固定长度20
// 短链没传长度,固定长度20
upCreateStr
=
upCreateStr
.
replaceAll
(
g
,
"\\{s20\\}"
);
upCreateStr
=
upCreateStr
.
replaceAll
(
g
,
"\\{s20\\}"
);
...
@@ -221,6 +224,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -221,6 +224,7 @@ public class MessageServiceImpl implements MessageService {
public
DmHubResponse
send
(
DmHubSendRequest
request
)
{
public
DmHubResponse
send
(
DmHubSendRequest
request
)
{
try
{
try
{
String
dmHubBatchId
=
request
.
getBatchId
();
String
dmHubBatchId
=
request
.
getBatchId
();
String
channelAccount
=
request
.
getChannelAccount
();
String
templateId
=
request
.
getTemplateId
();
String
templateId
=
request
.
getTemplateId
();
String
audienceIdType
=
request
.
getAudienceIdType
();
String
audienceIdType
=
request
.
getAudienceIdType
();
JSONObject
data
=
request
.
getData
();
JSONObject
data
=
request
.
getData
();
...
@@ -293,10 +297,34 @@ public class MessageServiceImpl implements MessageService {
...
@@ -293,10 +297,34 @@ public class MessageServiceImpl implements MessageService {
content
=
getMsg
(
upContent
,
paramList
);
content
=
getMsg
(
upContent
,
paramList
);
}
}
response
=
bgySmsService
.
sendSms
(
mobile
,
content
,
areaId
);
response
=
bgySmsService
.
sendSms
(
mobile
,
content
,
areaId
);
//4.短信发送记录
SysRecordInfo
sysRecordInfo
=
new
SysRecordInfo
();
sysRecordInfo
.
setId
(
IdHandler
.
nextId
());
long
sysRecordInfoBatchId
=
IdHandler
.
nextId
();
sysRecordInfo
.
setSysBatchId
(
sysRecordInfoBatchId
);
sysRecordInfo
.
setMobile
(
mobile
);
//sysRecordInfo.setMsgId();
sysRecordInfo
.
setChargeNum
(
1
);
sysRecordInfo
.
setContent
(
content
);
//sysRecordInfo.setParams();
Date
date
=
new
Date
();
sysRecordInfo
.
setDateCreated
(
date
);
sysRecordInfo
.
setLastUpdated
(
date
);
sysRecordInfo
.
setAreaId
(
channelAccount
);
String
code
=
response
.
getCode
();
String
code
=
response
.
getCode
();
if
(
code
.
equals
(
ResponseCode
.
SUCCESS
.
getCode
()))
{
if
(
code
.
equals
(
ResponseCode
.
SUCCESS
.
getCode
()))
{
sysRecordInfo
.
setStatus
(
ResponseCode
.
SUCCESS
.
getCode
());
sysRecordInfo
.
setStatusDesc
(
response
.
getMsg
());
sysRecordService
.
insert
(
sysRecordInfo
);
return
new
DmHubResponse
(
ResponseCode
.
SUCCESS
);
return
new
DmHubResponse
(
ResponseCode
.
SUCCESS
);
}
else
{
}
else
{
sysRecordInfo
.
setStatus
(
ResponseCode
.
UPSTREAM_FAIL
.
getCode
());
sysRecordInfo
.
setStatusDesc
(
response
.
getMsg
());
boolean
a
=
sysRecordService
.
insert
(
sysRecordInfo
);
return
new
DmHubResponse
(
code
,
response
.
getMsg
());
return
new
DmHubResponse
(
code
,
response
.
getMsg
());
}
}
...
@@ -354,7 +382,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -354,7 +382,7 @@ public class MessageServiceImpl implements MessageService {
String
batchId
=
request
.
getBatchId
();
// DM hub 批次号
String
batchId
=
request
.
getBatchId
();
// DM hub 批次号
String
templateId
=
request
.
getTemplateId
();
// 此次短信对应的模板id
String
templateId
=
request
.
getTemplateId
();
// 此次短信对应的模板id
List
<
JSONObject
>
data
=
request
.
getData
();
List
<
JSONObject
>
data
=
request
.
getData
();
String
channelAccount
=
request
.
getChannelAccount
();
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
DmHubResponse
(
"999"
,
"短信插件未获取到模板信息"
);
return
new
DmHubResponse
(
"999"
,
"短信插件未获取到模板信息"
);
...
@@ -401,7 +429,6 @@ public class MessageServiceImpl implements MessageService {
...
@@ -401,7 +429,6 @@ public class MessageServiceImpl implements MessageService {
}
}
paramsMap
.
put
(
mobile
,
list
);
paramsMap
.
put
(
mobile
,
list
);
}
}
}
else
{
}
else
{
if
(
i
!=
data
.
size
())
{
if
(
i
!=
data
.
size
())
{
paramsMap
.
put
(
mobile
,
new
ArrayList
<>());
paramsMap
.
put
(
mobile
,
new
ArrayList
<>());
...
@@ -409,7 +436,6 @@ public class MessageServiceImpl implements MessageService {
...
@@ -409,7 +436,6 @@ 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
);
...
@@ -431,43 +457,111 @@ public class MessageServiceImpl implements MessageService {
...
@@ -431,43 +457,111 @@ public class MessageServiceImpl implements MessageService {
sysBatchService
.
insert
(
info
);
sysBatchService
.
insert
(
info
);
CLBizResponse
response
=
new
CLBizResponse
();
CLBizResponse
response
=
new
CLBizResponse
();
//4.短信发送记录
SysRecordInfo
sysRecordInfo
=
new
SysRecordInfo
();
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
);
sysRecordInfo
.
setAreaId
(
channelAccount
);
if
(
paramsArr
==
null
||
paramsArr
.
isEmpty
())
{
if
(
paramsArr
==
null
||
paramsArr
.
isEmpty
())
{
try
{
List
<
JSONObject
>
list
=
new
ArrayList
<>();
StringBuilder
mobiles
=
new
StringBuilder
();
String
content
=
templateInfo
.
getUpContent
();
for
(
String
mobile
:
mobileList
)
{
for
(
String
mobile
:
mobileList
)
{
JSONObject
jsonObject
=
new
JSONObject
();
mobiles
.
append
(
","
+
mobile
);
jsonObject
.
put
(
"mobile"
,
mobile
);
jsonObject
.
put
(
"content"
,
content
);
list
.
add
(
jsonObject
);
}
try
{
try
{
response
=
bgySmsService
.
sendSms
(
mobile
,
templateInfo
.
getUpContent
(),
areaId
);
if
(!
list
.
isEmpty
())
{
}
catch
(
Exception
e
)
{
response
=
bgySmsService
.
sendbatchSms
(
list
.
toString
(),
areaId
);
log
.
error
(
"短信发送异常"
,
e
);
String
code
=
response
.
getCode
();
if
(
code
.
equals
(
ResponseCode
.
SUCCESS
.
getCode
()))
{
sysRecordInfo
.
setChargeNum
(
list
.
size
());
sysRecordInfo
.
setMobile
(
mobiles
.
toString
());
sysRecordInfo
.
setContent
(
content
);
sysRecordInfo
.
setStatus
(
ResponseCode
.
SUCCESS
.
getCode
());
sysRecordInfo
.
setStatusDesc
(
response
.
getMsg
());
sysRecordService
.
insert
(
sysRecordInfo
);
return
new
DmHubResponse
(
ResponseCode
.
SUCCESS
.
getCode
(),
ResponseCode
.
SUCCESS
.
getMsg
());
}
else
{
sysRecordInfo
.
setChargeNum
(
list
.
size
());
sysRecordInfo
.
setMobile
(
mobiles
.
toString
());
sysRecordInfo
.
setContent
(
content
);
sysRecordInfo
.
setStatus
(
ResponseCode
.
UPSTREAM_FAIL
.
getCode
());
sysRecordInfo
.
setStatusDesc
(
response
.
getMsg
());
boolean
a
=
sysRecordService
.
insert
(
sysRecordInfo
);
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
();
try
{
List
<
JSONObject
>
list
=
new
ArrayList
<>();
StringBuilder
mobiles
=
new
StringBuilder
();
String
content
=
templateInfo
.
getUpContent
();
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
entries
)
{
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
entries
)
{
try
{
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
,
areaId
);
String
code
=
response
.
getCode
();
JSONObject
jsonObject
=
new
JSONObject
();
String
msg
=
response
.
getMsg
();
mobiles
.
append
(
","
+
mobile
);
}
catch
(
Exception
e
)
{
jsonObject
.
put
(
"mobile"
,
mobile
);
log
.
error
(
"chu0"
);
jsonObject
.
put
(
"content"
,
sendMsg
);
list
.
add
(
jsonObject
);
}
}
try
{
response
=
bgySmsService
.
sendbatchSms
(
list
.
toString
(),
areaId
);
String
code
=
response
.
getCode
();
if
(
code
.
equals
(
ResponseCode
.
SUCCESS
.
getCode
()))
{
sysRecordInfo
.
setChargeNum
(
list
.
size
());
sysRecordInfo
.
setMobile
(
mobiles
.
toString
());
sysRecordInfo
.
setContent
(
content
);
sysRecordInfo
.
setStatus
(
ResponseCode
.
SUCCESS
.
getCode
());
sysRecordInfo
.
setStatusDesc
(
response
.
getMsg
());
sysRecordService
.
insert
(
sysRecordInfo
);
return
new
DmHubResponse
(
ResponseCode
.
SUCCESS
.
getCode
(),
ResponseCode
.
SUCCESS
.
getMsg
());
}
else
{
sysRecordInfo
.
setChargeNum
(
list
.
size
());
sysRecordInfo
.
setMobile
(
mobiles
.
toString
());
sysRecordInfo
.
setContent
(
content
);
sysRecordInfo
.
setStatus
(
ResponseCode
.
UPSTREAM_FAIL
.
getCode
());
sysRecordInfo
.
setStatusDesc
(
response
.
getMsg
());
boolean
a
=
sysRecordService
.
insert
(
sysRecordInfo
);
return
new
DmHubResponse
(
code
,
response
.
getMsg
());
}
}
return
new
DmHubResponse
(
ResponseCode
.
SUCCESS
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"调用碧桂园逻辑错误:"
,
e
);
log
.
error
(
"调用碧桂园逻辑错误:"
,
e
);
return
new
DmHubResponse
(
"999"
,
"插件服务系统异常"
);
return
new
DmHubResponse
(
"999"
,
"插件服务系统异常"
);
}
}
}
}
return
new
DmHubResponse
(
ResponseCode
.
SUCCESS
);
return
new
DmHubResponse
(
"999"
,
"插件服务系统异常"
);
}
}
private
static
void
getKeyAndValue
(
JSONObject
json
,
List
<
String
>
keyList
,
StringBuffer
keyBuffer
,
Map
<
String
,
String
>
paramsMap
)
{
private
static
void
getKeyAndValue
(
JSONObject
json
,
List
<
String
>
keyList
,
StringBuffer
keyBuffer
,
Map
<
String
,
String
>
paramsMap
)
{
...
...
src/main/java/com/bgy/sms/service/impl/SysRecordServiceImpl.java
0 → 100644
View file @
008568de
package
com
.
bgy
.
sms
.
service
.
impl
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
import
com.bgy.sms.repository.domain.SysRecordInfo
;
import
com.bgy.sms.repository.mapper.SysRecordMapper
;
import
com.bgy.sms.service.SysRecordService
;
import
org.springframework.stereotype.Service
;
@Service
public
class
SysRecordServiceImpl
extends
ServiceImpl
<
SysRecordMapper
,
SysRecordInfo
>
implements
SysRecordService
{
}
src/main/resources/application-dev.yml
View file @
008568de
...
@@ -34,7 +34,7 @@ system:
...
@@ -34,7 +34,7 @@ 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
api
:
SendSm
s
api
:
SendSm
S
dmHub
:
dmHub
:
applicationId
:
cl0300171a6012c21
applicationId
:
cl0300171a6012c21
applicationKey
:
4017078e9dfd593b2d9a0ede58eff589644fbe50
applicationKey
:
4017078e9dfd593b2d9a0ede58eff589644fbe50
...
...
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