Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
Overview
Overview
Details
Activity
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
pseer
gxpt_ht
Commits
e1f2d441
Commit
e1f2d441
authored
Jun 05, 2024
by
YG8999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
短信平台接口更换
parent
db25fb7f
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
369 additions
and
94 deletions
+369
-94
OtherCallbackController.java
.../share/web/controller/system/OtherCallbackController.java
+45
-0
SmsConts.java
...-common/src/main/java/share/common/constant/SmsConts.java
+1
-4
SmsStatusEnum.java
...ommon/src/main/java/share/common/enums/SmsStatusEnum.java
+50
-32
SmsUtil.java
share-common/src/main/java/share/common/utils/SmsUtil.java
+13
-18
SmsLog.java
share-system/src/main/java/share/system/domain/SmsLog.java
+15
-0
SmsDownResultVo.java
...src/main/java/share/system/domain/vo/SmsDownResultVo.java
+26
-0
SmsLogMapper.java
...ystem/src/main/java/share/system/mapper/SmsLogMapper.java
+2
-0
SmsLogService.java
...tem/src/main/java/share/system/service/SmsLogService.java
+2
-0
SmsService.java
...system/src/main/java/share/system/service/SmsService.java
+9
-0
SmsLogServiceImpl.java
...ain/java/share/system/service/impl/SmsLogServiceImpl.java
+6
-0
SmsServiceImpl.java
...c/main/java/share/system/service/impl/SmsServiceImpl.java
+167
-39
SmsLogMapper.xml
...-system/src/main/resources/mapper/system/SmsLogMapper.xml
+33
-1
No files found.
share-admin/src/main/java/share/web/controller/system/OtherCallbackController.java
0 → 100644
View file @
e1f2d441
package
share
.
web
.
controller
.
system
;
import
cn.hutool.json.JSONUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
share.system.domain.vo.SmsDownResultVo
;
import
share.system.service.SmsService
;
import
java.util.List
;
import
java.util.Map
;
/**
* @className: share.web.controller.system.OtherCallbackController
* @description: 其他平台回调、回执、推送
* @author: lwj
* @create: 2024-06-04 15:47
*/
@Slf4j
@RestController
@RequestMapping
(
"/admin/callback"
)
@Api
(
tags
=
"其他回调推送"
)
public
class
OtherCallbackController
{
@Autowired
private
SmsService
smsService
;
/**
* 短信发送下行回执推送
*/
@ApiOperation
(
value
=
"短信发送下行回执推送"
)
@RequestMapping
(
value
=
"/sms/downResult"
,
method
=
RequestMethod
.
POST
)
public
String
downResult
(
@RequestBody
List
<
SmsDownResultVo
>
data
,
@RequestHeader
Map
<
String
,
String
>
headers
)
{
String
tKey
=
headers
.
get
(
"zt-tkey"
);
String
password
=
headers
.
get
(
"zt-password"
);
System
.
out
.
println
(
"短信发送下行回执推送 request ===> "
+
JSONUtil
.
toJsonStr
(
data
));
System
.
out
.
println
(
"短信发送下行回执推送 request ===> "
+
tKey
);
System
.
out
.
println
(
"短信发送下行回执推送 request ===> "
+
password
);
String
response
=
smsService
.
updateDownResult
(
tKey
,
password
,
data
);
return
response
;
}
}
share-common/src/main/java/share/common/constant/SmsConts.java
View file @
e1f2d441
...
...
@@ -4,14 +4,11 @@ package share.common.constant;
*/
public
class
SmsConts
{
public
final
static
String
BASE_URL
=
"http://sms.xiaoyantong.com/sms"
;
public
final
static
String
USERNAME
=
"332450"
;
public
final
static
String
PASSWORD
=
"ML4pI31j"
;
/**
* 接口返回状态:成功
*/
public
final
static
Integer
SUCCESS_CODE
=
0
;
public
final
static
Integer
SUCCESS_CODE
=
20
0
;
/**
* 查询短信模板接口
...
...
share-common/src/main/java/share/common/enums/SmsStatusEnum.java
View file @
e1f2d441
...
...
@@ -10,38 +10,56 @@ import cn.hutool.core.util.StrUtil;
*/
public
enum
SmsStatusEnum
{
SMS_STATUS_0
(
0
,
"成功"
),
SMS_STATUS_1
(
1
,
"帐号名为空"
),
SMS_STATUS_2
(
2
,
"帐号名或密码鉴权错误"
),
SMS_STATUS_3
(
3
,
"帐号已被锁定"
),
SMS_STATUS_4
(
4
,
"此帐号业务未开通"
),
SMS_STATUS_5
(
5
,
"帐号余额不足"
),
SMS_STATUS_6
(
6
,
"缺少发送号码"
),
SMS_STATUS_7
(
7
,
"超过最大发送号码数"
),
SMS_STATUS_8
(
8
,
"发送消息内容为空"
),
SMS_STATUS_9
(
9
,
"无效的RCS模板ID"
),
SMS_STATUS_10
(
10
,
"非法的IP地址,提交来源IP地址与帐号绑定IP不一致"
),
SMS_STATUS_11
(
11
,
"24小时发送时间段限制"
),
SMS_STATUS_12
(
12
,
"定时发送时间错误或超过15天"
),
SMS_STATUS_13
(
13
,
"请求过于频繁,每次获取数据最小间隔为30秒"
),
SMS_STATUS_14
(
14
,
"错误的用户扩展码"
),
SMS_STATUS_16
(
16
,
"时间戳差异过大,与系统时间误差不得超过5分钟"
),
SMS_STATUS_18
(
18
,
"帐号未进行实名认证"
),
SMS_STATUS_19
(
19
,
"帐号未开放回执状态"
),
SMS_STATUS_22
(
22
,
"缺少必填参数"
),
SMS_STATUS_23
(
23
,
"用户帐号名重复"
),
SMS_STATUS_24
(
24
,
"用户无签名限制"
),
SMS_STATUS_25
(
25
,
"签名需要包含【】符"
),
SMS_STATUS_50
(
50
,
"缺少模板标题"
),
SMS_STATUS_51
(
51
,
"缺少模板内容"
),
SMS_STATUS_52
(
52
,
"模板内容不全"
),
SMS_STATUS_53
(
53
,
"不支持的模板帧类型"
),
SMS_STATUS_54
(
54
,
"不支持的文件类型"
),
SMS_STATUS_97
(
97
,
"此链接不支持GET请求"
),
SMS_STATUS_98
(
98
,
"HTTP Content-Type错误, 请设置Content-Type: application/json"
),
SMS_STATUS_99
(
99
,
"错误的请求JSON字符串"
),
SMS_STATUS_500
(
500
,
"系统异常,请联系管理员"
),
// SMS_STATUS_0(0, "成功"),
// SMS_STATUS_1(1, "帐号名为空"),
// SMS_STATUS_2(2, "帐号名或密码鉴权错误"),
// SMS_STATUS_3(3, "帐号已被锁定"),
// SMS_STATUS_4(4, "此帐号业务未开通"),
// SMS_STATUS_5(5, "帐号余额不足"),
// SMS_STATUS_6(6, "缺少发送号码"),
// SMS_STATUS_7(7, "超过最大发送号码数"),
// SMS_STATUS_8(8, "发送消息内容为空"),
// SMS_STATUS_9(9, "无效的RCS模板ID"),
// SMS_STATUS_10(10, "非法的IP地址,提交来源IP地址与帐号绑定IP不一致"),
// SMS_STATUS_11(11, "24小时发送时间段限制"),
// SMS_STATUS_12(12, "定时发送时间错误或超过15天"),
// SMS_STATUS_13(13, "请求过于频繁,每次获取数据最小间隔为30秒"),
// SMS_STATUS_14(14, "错误的用户扩展码"),
// SMS_STATUS_16(16, "时间戳差异过大,与系统时间误差不得超过5分钟"),
// SMS_STATUS_18(18, "帐号未进行实名认证"),
// SMS_STATUS_19(19, "帐号未开放回执状态"),
// SMS_STATUS_22(22, "缺少必填参数"),
// SMS_STATUS_23(23, "用户帐号名重复"),
// SMS_STATUS_24(24, "用户无签名限制"),
// SMS_STATUS_25(25, "签名需要包含【】符"),
// SMS_STATUS_50(50, "缺少模板标题"),
// SMS_STATUS_51(51, "缺少模板内容"),
// SMS_STATUS_52(52, "模板内容不全"),
// SMS_STATUS_53(53, "不支持的模板帧类型"),
// SMS_STATUS_54(54, "不支持的文件类型"),
// SMS_STATUS_97(97, "此链接不支持GET请求"),
// SMS_STATUS_98(98, "HTTP Content-Type错误, 请设置Content-Type: application/json"),
// SMS_STATUS_99(99, "错误的请求JSON字符串"),
// SMS_STATUS_500(500, "系统异常,请联系管理员"),
SMS_STATUS_200
(
200
,
"提交成功"
),
SMS_STATUS_4001
(
4001
,
"用户名错误"
),
SMS_STATUS_4002
(
4002
,
"密码不能为空"
),
SMS_STATUS_4003
(
4003
,
"短信内容不能为空"
),
SMS_STATUS_4004
(
4004
,
"手机号码错误"
),
SMS_STATUS_4006
(
4006
,
"IP鉴权错误"
),
SMS_STATUS_4007
(
4007
,
"用户禁用"
),
SMS_STATUS_4008
(
4008
,
"tKey错误"
),
SMS_STATUS_4009
(
4009
,
"密码错误"
),
SMS_STATUS_4010
(
4010
,
"短信内容超过1000个字符"
),
SMS_STATUS_4011
(
4011
,
"请求错误"
),
SMS_STATUS_4013
(
4013
,
"定时时间错误"
),
SMS_STATUS_4015
(
4015
,
"扩展号错误"
),
SMS_STATUS_4019
(
4019
,
"用户类型错误"
),
SMS_STATUS_4026
(
4026
,
"手机号码数最大2000个"
),
SMS_STATUS_4029
(
4029
,
"请使用post请求"
),
SMS_STATUS_4030
(
4030
,
"Content-Type请使用application/json"
),
SMS_STATUS_9998
(
9998
,
"JSON解析错误"
),
SMS_STATUS_9999
(
9999
,
"非法请求"
),
;
private
Integer
code
;
...
...
share-common/src/main/java/share/common/utils/SmsUtil.java
View file @
e1f2d441
...
...
@@ -53,10 +53,6 @@ public class SmsUtil {
return
result
;
}
public
String
sign
(
long
timestamp
)
{
return
SecureUtil
.
md5
(
SmsConts
.
USERNAME
+
timestamp
+
SecureUtil
.
md5
(
SmsConts
.
PASSWORD
));
}
/**
* 短信平台密码加密
* @param password
...
...
@@ -98,19 +94,18 @@ public class SmsUtil {
// param.put("extno", "10690");
//// param.put("atTime", "");
String
smsContent
=
StrUtil
.
concat
(
true
,
"【凑角】"
,
content
);
Long
timestamp
=
DateUtil
.
date
().
getTime
();
String
smsContent
=
StrUtil
.
concat
(
true
,
"【凑角】"
,
"提醒您:凑角【人信汇店】(999房),已被预订!请确认房间卫生情况,保证客户体验!"
);
Long
timestamp
=
DateUtil
.
date
().
getTime
()
/
1000
;
JSONObject
param
=
JSONUtil
.
createObj
();
param
.
put
(
"userName"
,
"799046"
);
param
.
put
(
"sign"
,
SecureUtil
.
md5
(
"799046"
+
timestamp
+
SecureUtil
.
md5
(
"mTPLoCadtv2V"
)));
param
.
put
(
"timestamp"
,
timestamp
);
// 短信发送集合messageList
JSONObject
sendParam
=
JSONUtil
.
createObj
();
sendParam
.
put
(
"phone"
,
"18062577819"
);
sendParam
.
put
(
"content"
,
smsContent
);
JSONArray
array
=
JSONUtil
.
createArray
();
array
.
add
(
sendParam
);
param
.
put
(
"messageList"
,
array
);
param
.
put
(
"username"
,
"yxkjhy"
);
param
.
put
(
"password"
,
SecureUtil
.
md5
(
SecureUtil
.
md5
(
")@nhctX7"
)
+
timestamp
));
param
.
put
(
"tKey"
,
timestamp
);
param
.
put
(
"mobile"
,
"18062577819,18062677049"
);
param
.
put
(
"content"
,
smsContent
);
param
.
put
(
"time"
,
DateUtil
.
now
());
param
.
put
(
"ext"
,
"9999"
);
System
.
out
.
println
(
JSONUtil
.
toJsonStr
(
param
));
HttpHeaders
headers
=
new
HttpHeaders
();
...
...
@@ -122,8 +117,8 @@ public class SmsUtil {
HttpEntity
<
JSONObject
>
requestEntity
=
new
HttpEntity
<>(
param
,
headers
);
RestTemplate
restTemplate
=
new
RestTemplate
();
cn
.
hutool
.
json
.
JSONObject
body
=
restTemplate
.
postForEntity
(
"http://43.137.43.203:8001/sms/api/sendMessageOne
"
,
requestEntity
,
cn
.
hutool
.
json
.
JSONObject
.
class
).
getBody
();
System
.
out
.
println
(
JSONUtil
.
toJsonStr
(
body
));
cn
.
hutool
.
json
.
JSONObject
body
=
restTemplate
.
postForEntity
(
"https://api-shss.zthysms.com/v2/sendSms
"
,
requestEntity
,
cn
.
hutool
.
json
.
JSONObject
.
class
).
getBody
();
System
.
out
.
println
(
"结果:"
+
JSONUtil
.
toJsonStr
(
body
));
}
...
...
share-system/src/main/java/share/system/domain/SmsLog.java
View file @
e1f2d441
...
...
@@ -57,6 +57,21 @@ public class SmsLog extends BaseEntity
@Excel
(
name
=
"返回内容"
)
private
String
resultParam
;
/** 短信下行结果(短信平台发送用户是否成功) */
@Excel
(
name
=
"短信下行结果"
)
private
String
downResult
;
/** 短信下行结果描述 */
@Excel
(
name
=
"短信下行结果描述"
)
private
String
downDesc
;
/** 短信下行回执参数 */
@Excel
(
name
=
"短信下行回执参数"
)
private
String
downParam
;
/** 短信平台消息ID */
@Excel
(
name
=
"短信平台消息ID"
)
private
String
msgId
;
@Override
public
String
toString
()
{
...
...
share-system/src/main/java/share/system/domain/vo/SmsDownResultVo.java
0 → 100644
View file @
e1f2d441
package
share
.
system
.
domain
.
vo
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @className: share.system.domain.vo.SmsDownResult
* @description: 短信发送下行回执推送参数
* @author: lwj
* @create: 2024-06-04 16:15
*/
@Data
public
class
SmsDownResultVo
implements
Serializable
{
private
String
msgId
;
// 消息ID
private
String
mobile
;
// 手机号
private
String
reportTime
;
// 回复时间
private
String
code
;
// 状态代码
private
String
msg
;
// 状态代码描述
private
String
extend
;
// 自定义信息
private
Integer
pkTotal
;
// 短信长度
private
Integer
pkNumber
;
// 短信回执序号,从1开始
private
String
username
;
// 用户名
}
share-system/src/main/java/share/system/mapper/SmsLogMapper.java
View file @
e1f2d441
...
...
@@ -59,4 +59,6 @@ public interface SmsLogMapper extends BaseMapper<SmsLog>
* @return 结果
*/
public
int
deleteSmsLogByIds
(
Long
[]
ids
);
int
updateSmsLogByMsgId
(
SmsLog
smsLog
);
}
share-system/src/main/java/share/system/service/SmsLogService.java
View file @
e1f2d441
...
...
@@ -59,4 +59,6 @@ public interface SmsLogService extends IService<SmsLog>
* @return 结果
*/
public
int
deleteSmsLogById
(
Long
id
);
int
updateSmsLogByMsgId
(
SmsLog
smsLog
);
}
share-system/src/main/java/share/system/service/SmsService.java
View file @
e1f2d441
...
...
@@ -3,6 +3,7 @@ package share.system.service;
import
cn.hutool.json.JSONArray
;
import
share.system.domain.*
;
import
share.system.domain.vo.SmsDownResultVo
;
import
java.util.List
;
...
...
@@ -76,5 +77,13 @@ public interface SmsService {
*/
boolean
sendSmsOrderPredetermine
(
List
<
String
>
phones
,
SOrder
order
,
SStore
store
,
SRoom
room
);
/**
* 短信发送下行回执推送
* @param tKey 东八区当前时间戳,精确到秒
* @param password 接口密码采用32位小写MD5二次加密
* @param data 参数
* @return SUCCESS
*/
String
updateDownResult
(
String
tKey
,
String
password
,
List
<
SmsDownResultVo
>
data
);
}
share-system/src/main/java/share/system/service/impl/SmsLogServiceImpl.java
View file @
e1f2d441
...
...
@@ -94,4 +94,10 @@ public class SmsLogServiceImpl extends ServiceImpl<SmsLogMapper, SmsLog> impleme
{
return
smsLogMapper
.
deleteSmsLogById
(
id
);
}
@Override
public
int
updateSmsLogByMsgId
(
SmsLog
smsLog
)
{
smsLog
.
setUpdateTime
(
DateUtils
.
getNowDate
());
return
smsLogMapper
.
updateSmsLogByMsgId
(
smsLog
);
}
}
share-system/src/main/java/share/system/service/impl/SmsServiceImpl.java
View file @
e1f2d441
...
...
@@ -2,6 +2,7 @@ package share.system.service.impl;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.crypto.SecureUtil
;
import
cn.hutool.json.JSONArray
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
...
...
@@ -18,6 +19,7 @@ import share.common.exception.base.BaseException;
import
share.common.utils.BaseUtil
;
import
share.common.utils.SmsUtil
;
import
share.system.domain.*
;
import
share.system.domain.vo.SmsDownResultVo
;
import
share.system.mapper.SysConfigMapper
;
import
share.system.service.ISysConfigService
;
import
share.system.service.SConsumerService
;
...
...
@@ -256,6 +258,7 @@ public class SmsServiceImpl implements SmsService {
}
}
private
String
getSmsContent
(
String
phone
,
Integer
tag
)
{
// 验证码 特殊处理 code
if
(
tag
.
equals
(
SmsTypeEnum
.
SMS_CODE_TEMP
.
getCode
()))
{
...
...
@@ -287,13 +290,16 @@ public class SmsServiceImpl implements SmsService {
private
JSONObject
sendGroupSms
(
List
<
String
>
phoneList
,
String
content
,
String
smsType
,
Long
storeId
,
Long
roomId
)
{
// 发送内容添加短信签名
String
smsContent
=
StrUtil
.
concat
(
true
,
signature
,
content
);
Long
timestamp
=
DateUtil
.
date
().
getTime
();
Long
timestamp
=
DateUtil
.
date
().
getTime
()
/
1000
;
JSONObject
param
=
JSONUtil
.
createObj
();
param
.
set
(
"userName"
,
userName
);
param
.
set
(
"sign"
,
smsUtil
.
sign
(
userName
,
timestamp
,
passWord
));
param
.
set
(
"phoneList"
,
JSONUtil
.
parseArray
(
phoneList
));
param
.
set
(
"username"
,
userName
);
param
.
set
(
"password"
,
SecureUtil
.
md5
(
SecureUtil
.
md5
(
passWord
)
+
timestamp
));
param
.
set
(
"tKey"
,
timestamp
);
param
.
set
(
"mobile"
,
String
.
join
(
","
,
phoneList
));
param
.
set
(
"content"
,
smsContent
);
param
.
set
(
"timestamp"
,
timestamp
);
param
.
set
(
"time"
,
DateUtil
.
now
());
param
.
set
(
"ext"
,
extno
);
// 短信日志
SmsLog
smsLog
=
new
SmsLog
();
smsLog
.
setPhone
(
String
.
join
(
","
,
phoneList
));
...
...
@@ -303,7 +309,7 @@ public class SmsServiceImpl implements SmsService {
smsLog
.
setStoreId
(
storeId
);
smsLog
.
setRoomId
(
roomId
);
try
{
JSONObject
jsonObject
=
smsUtil
.
postFrom
(
url
+
"/
api/sendMessageMas
s"
,
param
);
JSONObject
jsonObject
=
smsUtil
.
postFrom
(
url
+
"/
v2/sendSm
s"
,
param
);
smsLog
.
setResultParam
(
JSONUtil
.
toJsonStr
(
jsonObject
));
checkResult
(
jsonObject
,
smsLog
);
smsLogService
.
insertSmsLog
(
smsLog
);
...
...
@@ -329,18 +335,15 @@ public class SmsServiceImpl implements SmsService {
private
JSONObject
sendOneSms
(
String
phone
,
String
content
,
String
smsType
,
Long
storeId
,
Long
roomId
)
{
// 发送内容添加短信签名
String
smsContent
=
StrUtil
.
concat
(
true
,
signature
,
content
);
Long
timestamp
=
DateUtil
.
date
().
getTime
();
Long
timestamp
=
DateUtil
.
date
().
getTime
()
/
1000
;
JSONObject
param
=
JSONUtil
.
createObj
();
param
.
set
(
"userName"
,
userName
);
param
.
set
(
"sign"
,
smsUtil
.
sign
(
userName
,
timestamp
,
passWord
));
param
.
set
(
"timestamp"
,
timestamp
);
// 短信发送集合messageList
JSONObject
sendParam
=
JSONUtil
.
createObj
();
sendParam
.
set
(
"phone"
,
phone
);
sendParam
.
set
(
"content"
,
smsContent
);
JSONArray
array
=
JSONUtil
.
createArray
();
array
.
add
(
sendParam
);
param
.
set
(
"messageList"
,
array
);
param
.
set
(
"username"
,
userName
);
param
.
set
(
"password"
,
SecureUtil
.
md5
(
SecureUtil
.
md5
(
passWord
)
+
timestamp
));
param
.
set
(
"tKey"
,
timestamp
);
param
.
set
(
"mobile"
,
phone
);
param
.
set
(
"content"
,
smsContent
);
param
.
set
(
"time"
,
DateUtil
.
now
());
param
.
set
(
"ext"
,
extno
);
// 短信日志
SmsLog
smsLog
=
new
SmsLog
();
...
...
@@ -351,7 +354,7 @@ public class SmsServiceImpl implements SmsService {
smsLog
.
setStoreId
(
storeId
);
smsLog
.
setRoomId
(
roomId
);
try
{
JSONObject
jsonObject
=
smsUtil
.
postFrom
(
url
+
"/
api/sendMessageOne
"
,
param
);
JSONObject
jsonObject
=
smsUtil
.
postFrom
(
url
+
"/
v2/sendSms
"
,
param
);
smsLog
.
setResultParam
(
JSONUtil
.
toJsonStr
(
jsonObject
));
checkResult
(
jsonObject
,
smsLog
);
smsLogService
.
insertSmsLog
(
smsLog
);
...
...
@@ -367,33 +370,158 @@ public class SmsServiceImpl implements SmsService {
private
void
checkResult
(
JSONObject
result
,
SmsLog
smsLog
)
{
smsLog
.
setRemark
(
SmsStatusEnum
.
getNameStr
(
result
.
getInt
(
"code"
)));
smsLog
.
setMsgId
(
result
.
getStr
(
"msgId"
));
if
(!
SmsConts
.
SUCCESS_CODE
.
equals
(
result
.
getInt
(
"code"
)))
{
smsLog
.
setResult
(
0
);
smsLog
.
setRemark
(
SmsStatusEnum
.
getNameStr
(
result
.
getInt
(
"code"
)));
}
else
{
JSONArray
array
=
result
.
getJSONArray
(
"data"
);
if
(
array
!=
null
&&
array
.
size
()
>
0
)
{
StringBuilder
sb
=
new
StringBuilder
();
boolean
isSuccess
=
Boolean
.
TRUE
;
for
(
Object
o
:
array
)
{
JSONObject
json
=
JSONUtil
.
parseObj
(
o
);
sb
.
append
(
json
.
getStr
(
"phone"
)).
append
(
": "
);
sb
.
append
(
SmsStatusEnum
.
getNameStr
(
json
.
getInt
(
"code"
))).
append
(
","
);
if
(!
SmsConts
.
SUCCESS_CODE
.
equals
(
json
.
getInt
(
"code"
))){
isSuccess
=
Boolean
.
FALSE
;
}
}
// 判断字符串长度大于1并且最后一个字符为逗号时才进行处理
if
(
sb
.
length
()
>
1
&&
sb
.
charAt
(
sb
.
length
()
-
1
)
==
','
)
{
sb
.
deleteCharAt
(
sb
.
length
()
-
1
);
}
smsLog
.
setResult
(
isSuccess
?
1
:
0
);
smsLog
.
setRemark
(
sb
.
toString
());
}
else
{
smsLog
.
setResult
(
1
);
smsLog
.
setRemark
(
result
.
getStr
(
"message"
));
}
}
/**
* 短信发送下行回执推送
* @param tKey 东八区当前时间戳,精确到秒
* @param password 接口密码采用32位小写MD5二次加密
* @param data 参数
* @return SUCCESS
*/
@Override
public
String
updateDownResult
(
String
tKey
,
String
password
,
List
<
SmsDownResultVo
>
data
)
{
String
sign
=
SecureUtil
.
md5
(
SecureUtil
.
md5
(
passWord
)
+
tKey
);
if
(
sign
.
equals
(
password
))
{
if
(
data
!=
null
&&
data
.
size
()
>
0
)
{
SmsDownResultVo
vo
=
data
.
get
(
0
);
SmsLog
smsLog
=
new
SmsLog
();
smsLog
.
setDownResult
(
vo
.
getCode
());
smsLog
.
setDownDesc
(
vo
.
getMsg
());
String
param
=
JSONUtil
.
toJsonStr
(
data
);
if
(
param
!=
null
&&
param
.
length
()
<
1500
)
{
smsLog
.
setDownParam
(
param
);
}
smsLogService
.
updateSmsLogByMsgId
(
smsLog
);
}
return
"SUCCESS"
;
}
return
"密码错误"
;
}
// /**
// * 短信群发
// * @param phoneList 手机号码集合
// * @param content 发送内容
// * @return
// */
// private JSONObject sendGroupSms(List<String> phoneList, String content, String smsType, Long storeId, Long roomId) {
// // 发送内容添加短信签名
// String smsContent = StrUtil.concat(true, signature, content);
// Long timestamp = DateUtil.date().getTime();
// JSONObject param = JSONUtil.createObj();
// param.set("userName", userName);
// param.set("sign", smsUtil.sign(userName, timestamp, passWord));
// param.set("phoneList", JSONUtil.parseArray(phoneList));
// param.set("content", smsContent);
// param.set("timestamp", timestamp);
// // 短信日志
// SmsLog smsLog = new SmsLog();
// smsLog.setPhone(String.join(",", phoneList));
// smsLog.setContent(content);
// smsLog.setSignature(signature);
// smsLog.setSmsType(smsType);
// smsLog.setStoreId(storeId);
// smsLog.setRoomId(roomId);
// try {
// JSONObject jsonObject = smsUtil.postFrom(url + "/api/sendMessageMass", param);
// smsLog.setResultParam(JSONUtil.toJsonStr(jsonObject));
// checkResult(jsonObject, smsLog);
// smsLogService.insertSmsLog(smsLog);
// return jsonObject;
// } catch (BaseException exception) {
// // 异常日志
// smsLog.setResult(0);
// smsLog.setRemark(exception.getDefaultMessage());
// smsLogService.insertSmsLog(smsLog);
// }
// return null;
// }
//
// /**
// * 单独发送
// *
// * @param phone 手机号
// * @param content 发送内容
// * @param storeId 门店id
// * @param roomId 房间id
// * @return
// */
// private JSONObject sendOneSms(String phone, String content, String smsType, Long storeId, Long roomId) {
// // 发送内容添加短信签名
// String smsContent = StrUtil.concat(true, signature, content);
// Long timestamp = DateUtil.date().getTime();
// JSONObject param = JSONUtil.createObj();
// param.set("userName", userName);
// param.set("sign", smsUtil.sign(userName, timestamp, passWord));
// param.set("timestamp", timestamp);
// // 短信发送集合messageList
// JSONObject sendParam = JSONUtil.createObj();
// sendParam.set("phone", phone);
// sendParam.set("content", smsContent);
// JSONArray array = JSONUtil.createArray();
// array.add(sendParam);
// param.set("messageList", array);
//
// // 短信日志
// SmsLog smsLog = new SmsLog();
// smsLog.setPhone(phone);
// smsLog.setContent(content);
// smsLog.setSignature(signature);
// smsLog.setSmsType(smsType);
// smsLog.setStoreId(storeId);
// smsLog.setRoomId(roomId);
// try {
// JSONObject jsonObject = smsUtil.postFrom(url + "/api/sendMessageOne", param);
// smsLog.setResultParam(JSONUtil.toJsonStr(jsonObject));
// checkResult(jsonObject, smsLog);
// smsLogService.insertSmsLog(smsLog);
// return jsonObject;
// } catch (BaseException exception) {
// // 异常日志
// smsLog.setResult(0);
// smsLog.setRemark(exception.getDefaultMessage());
// smsLogService.insertSmsLog(smsLog);
// }
// return null;
// }
//
//
// private void checkResult(JSONObject result, SmsLog smsLog) {
// if (!SmsConts.SUCCESS_CODE.equals(result.getInt("code"))) {
// smsLog.setResult(0);
// smsLog.setRemark(SmsStatusEnum.getNameStr(result.getInt("code")));
// } else {
// JSONArray array = result.getJSONArray("data");
// if (array != null && array.size() > 0) {
// StringBuilder sb = new StringBuilder();
// boolean isSuccess = Boolean.TRUE;
// for (Object o : array) {
// JSONObject json = JSONUtil.parseObj(o);
// sb.append(json.getStr("phone")).append(": ");
// sb.append(SmsStatusEnum.getNameStr(json.getInt("code"))).append(",");
// if (!SmsConts.SUCCESS_CODE.equals(json.getInt("code"))){
// isSuccess = Boolean.FALSE;
// }
// }
// // 判断字符串长度大于1并且最后一个字符为逗号时才进行处理
// if (sb.length() > 1 && sb.charAt(sb.length() - 1) == ',') {
// sb.deleteCharAt(sb.length() - 1);
// }
// smsLog.setResult(isSuccess ? 1 : 0);
// smsLog.setRemark(sb.toString());
// } else {
// smsLog.setResult(1);
// smsLog.setRemark(result.getStr("message"));
// }
// }
// }
}
share-system/src/main/resources/mapper/system/SmsLogMapper.xml
View file @
e1f2d441
...
...
@@ -20,10 +20,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"remark"
column=
"remark"
/>
<result
property=
"result"
column=
"result"
/>
<result
property=
"resultParam"
column=
"result_param"
/>
<result
property=
"msgId"
column=
"msg_id"
/>
<result
property=
"downResult"
column=
"down_result"
/>
<result
property=
"downDesc"
column=
"down_desc"
/>
<result
property=
"downParam"
column=
"down_param"
/>
</resultMap>
<sql
id=
"selectSmsLogVo"
>
select id, store_id, room_id, phone, template_id, signature, content, sms_type, create_by, create_time, update_by, update_time, remark, result, result_param from s_sms_log
select id, store_id, room_id, phone, template_id, signature, content, sms_type, create_by, create_time,
update_by, update_time, remark, result, result_param, down_result, down_desc,down_param,msg_id
from s_sms_log
</sql>
<select
id=
"selectSmsLogList"
parameterType=
"SmsLog"
resultMap=
"SmsLogResult"
>
...
...
@@ -64,6 +71,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"remark != null"
>
remark,
</if>
<if
test=
"result != null"
>
result,
</if>
<if
test=
"resultParam != null"
>
result_param,
</if>
<if
test=
"msgId != null"
>
msg_id,
</if>
<if
test=
"downResult != null"
>
down_result,
</if>
<if
test=
"downDesc != null"
>
down_desc,
</if>
<if
test=
"downParam != null"
>
down_param,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"storeId != null"
>
#{storeId},
</if>
...
...
@@ -80,6 +91,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"remark != null"
>
#{remark},
</if>
<if
test=
"result != null"
>
#{result},
</if>
<if
test=
"resultParam != null"
>
#{resultParam},
</if>
<if
test=
"msgId != null"
>
#{msgId},
</if>
<if
test=
"downResult != null"
>
#{downResult},
</if>
<if
test=
"downDesc != null"
>
#{downDesc},
</if>
<if
test=
"downParam != null"
>
#{downParam},
</if>
</trim>
</insert>
...
...
@@ -100,6 +115,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"remark != null"
>
remark = #{remark},
</if>
<if
test=
"result != null"
>
result = #{result},
</if>
<if
test=
"resultParam != null"
>
result_param = #{resultParam},
</if>
<if
test=
"msgId != null"
>
msg_id = #{msgId},
</if>
<if
test=
"downResult != null"
>
down_result = #{downResult},
</if>
<if
test=
"downDesc != null"
>
down_desc = #{downDesc},
</if>
<if
test=
"downParam != null"
>
down_param = #{downParam},
</if>
</trim>
where id = #{id}
</update>
...
...
@@ -114,4 +133,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<update
id=
"updateSmsLogByMsgId"
parameterType=
"SmsLog"
>
update s_sms_log
<trim
prefix=
"SET"
suffixOverrides=
","
>
<if
test=
"updateTime != null"
>
update_time = #{updateTime},
</if>
<if
test=
"downResult != null"
>
down_result = #{downResult},
</if>
<if
test=
"downDesc != null"
>
down_desc = #{downDesc},
</if>
<if
test=
"downParam != null"
>
down_param = #{downParam},
</if>
</trim>
where msg_id = #{msgId}
</update>
</mapper>
\ No newline at end of file
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