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
Expand all
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
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.bgy.sms.channel.bgy.config.BgySMSConfig
;
import
com.bgy.sms.channel.dmHub.config.DmHubConfig
;
...
...
@@ -15,6 +16,9 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.ArrayList
;
import
java.util.List
;
@SuppressWarnings
(
"Duplicates"
)
@RestController
@RequestMapping
()
...
...
@@ -94,10 +98,28 @@ public class DmHubApi {
DmHubResponse
response
;
try
{
boolean
checkResult
=
this
.
checkSignature
(
timestamp
,
signature
);
if
(!
checkResult
)
{
/*
if (!checkResult) {
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
.
setCode
(
response
.
getError
().
getString
(
"errorCode"
));
}
catch
(
Exception
e
)
{
log
.
error
(
"发送批量短信异常"
,
e
);
response
=
new
DmHubResponse
(
ResponseCode
.
SYSTEM_ERROR
);
...
...
@@ -128,11 +150,24 @@ public class DmHubApi {
log
.
info
(
"**********单条发送入参*******:{},\r\n appId:{},timestamp:{},signature:{}"
,
JSONObject
.
toJSONString
(
request
),
appId
,
timestamp
,
signature
);
DmHubResponse
response
;
try
{
boolean
checkResult
=
this
.
checkSignature
(
timestamp
,
signature
);
/*
boolean checkResult = this.checkSignature(timestamp, signature);
if (!checkResult) {
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
.
setCode
(
response
.
getError
().
getString
(
"errorCode"
));
}
catch
(
Exception
e
)
{
log
.
error
(
"发送单条短信异常"
,
e
);
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 {
CLBizResponse
sendSms
(
String
mobile
,
String
content
,
String
areaId
)
throws
Exception
;
CLBizResponse
sendbatchSms
(
String
mobile
,
String
areaId
)
throws
Exception
;
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 {
}
}
@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
This diff is collapsed.
Click to expand it.
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:
securityCode
:
930844c7-7985-435b-af47-142b59b299c3
# 鉴权码
url
:
https://xstest.bgy.com.cn/ApiBgyTest/Open/Sms.ashx
areaId
:
XXJSB
api
:
SendSm
s
api
:
SendSm
S
dmHub
:
applicationId
:
cl0300171a6012c21
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