From 2a4d9f43eb57d78f6dbabb9956aa393644730f29 Mon Sep 17 00:00:00 2001 From: zengzefeng <986510453@qq.com> Date: Wed, 24 Feb 2021 14:59:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9F=AD=E4=BF=A1=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/sms/client/AliyunSmsClient.java | 13 ++++++++++++- .../dashboard/framework/sms/core/SmsResult.java | 2 +- .../framework/sms/core/SmsResultDetail.java | 2 +- .../sms/core/property/SmsTemplateProperty.java | 2 +- .../modules/system/enums/sms/SmsSendStatusEnum.java | 5 ++++- .../service/sms/impl/SysSmsLogServiceImpl.java | 8 ++++++++ 6 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/main/java/cn/iocoder/dashboard/framework/sms/client/AliyunSmsClient.java b/src/main/java/cn/iocoder/dashboard/framework/sms/client/AliyunSmsClient.java index f1976589c..ef6ed73f3 100644 --- a/src/main/java/cn/iocoder/dashboard/framework/sms/client/AliyunSmsClient.java +++ b/src/main/java/cn/iocoder/dashboard/framework/sms/client/AliyunSmsClient.java @@ -5,6 +5,7 @@ import cn.iocoder.dashboard.framework.sms.core.SmsBody; import cn.iocoder.dashboard.framework.sms.core.SmsResult; import cn.iocoder.dashboard.framework.sms.core.SmsResultDetail; import cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperty; +import cn.iocoder.dashboard.modules.system.enums.sms.SmsSendStatusEnum; import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.IAcsClient; import com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsRequest; @@ -85,11 +86,21 @@ public class AliyunSmsClient extends AbstractSmsClient { resultDetail.setCreateTime(DateUtil.parseDateTime(s.getSendDate())); resultDetail.setMessage(s.getContent()); resultDetail.setPhone(s.getPhoneNum()); - resultDetail.setStatus(Math.toIntExact(s.getSendStatus())); + resultDetail.setStatus(statusConvert(s.getSendStatus())); resultDetailList.add(resultDetail); }); resultBody.setResult(resultDetailList); return resultBody; } + private int statusConvert(Long aliSendStatus) { + if (aliSendStatus == 1L) { + return SmsSendStatusEnum.SUCCESS.getStatus(); + } + if (aliSendStatus == 2L) { + return SmsSendStatusEnum.FAIL.getStatus(); + } + return SmsSendStatusEnum.WAITING.getStatus(); + } + } diff --git a/src/main/java/cn/iocoder/dashboard/framework/sms/core/SmsResult.java b/src/main/java/cn/iocoder/dashboard/framework/sms/core/SmsResult.java index 64bbd1e4b..9abffa4e8 100644 --- a/src/main/java/cn/iocoder/dashboard/framework/sms/core/SmsResult.java +++ b/src/main/java/cn/iocoder/dashboard/framework/sms/core/SmsResult.java @@ -12,7 +12,7 @@ import java.util.List; public class SmsResult implements Serializable { /** - * 是否成功 + * 是否成功(发送短信的请求是否成功) */ // TODO FROM 芋艿 to zzf:未来要加一个 code,将不同平台的短信失败的情况,做一次统一的收敛。 DONE private Boolean success; diff --git a/src/main/java/cn/iocoder/dashboard/framework/sms/core/SmsResultDetail.java b/src/main/java/cn/iocoder/dashboard/framework/sms/core/SmsResultDetail.java index 6ed9fbcae..67de28938 100644 --- a/src/main/java/cn/iocoder/dashboard/framework/sms/core/SmsResultDetail.java +++ b/src/main/java/cn/iocoder/dashboard/framework/sms/core/SmsResultDetail.java @@ -12,7 +12,7 @@ import java.util.Date; public class SmsResultDetail implements Serializable { /** - * 状态 1成功 2失败 3等待回执 + * 短信发送状态 {@link cn.iocoder.dashboard.modules.system.enums.sms.SmsSendStatusEnum} */ private Integer status; diff --git a/src/main/java/cn/iocoder/dashboard/framework/sms/core/property/SmsTemplateProperty.java b/src/main/java/cn/iocoder/dashboard/framework/sms/core/property/SmsTemplateProperty.java index a613a5453..961863cc9 100644 --- a/src/main/java/cn/iocoder/dashboard/framework/sms/core/property/SmsTemplateProperty.java +++ b/src/main/java/cn/iocoder/dashboard/framework/sms/core/property/SmsTemplateProperty.java @@ -7,7 +7,7 @@ import javax.validation.constraints.NotEmpty; /** * 渠道模板VO类 - * TODO FROM 芋艿 TO zzf:模板是不是不要提供到 client 里面,而是交给 factory 统一维护就好。不然,模板修改时候,刷新 client 会比较麻烦。 + * TODO FROM 芋艿 TO zzf:模板是不是不要提供到 client 里面,而是交给 factory 统一维护就好。不然,模板修改时候,刷新 client 会比较麻烦。 DONE * * * @author zzf diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/enums/sms/SmsSendStatusEnum.java b/src/main/java/cn/iocoder/dashboard/modules/system/enums/sms/SmsSendStatusEnum.java index 426e4cb80..846c70967 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/enums/sms/SmsSendStatusEnum.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/enums/sms/SmsSendStatusEnum.java @@ -22,8 +22,11 @@ public enum SmsSendStatusEnum { //失败 FAIL(3), + //等待回执 + WAITING(4), + //成功 - SUCCESS(4); + SUCCESS(5); private final int status; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/sms/impl/SysSmsLogServiceImpl.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/sms/impl/SysSmsLogServiceImpl.java index 7accf76db..a89f80ff7 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/service/sms/impl/SysSmsLogServiceImpl.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/sms/impl/SysSmsLogServiceImpl.java @@ -59,6 +59,14 @@ public class SysSmsLogServiceImpl implements SysSmsLogService { smsLog.setId(logId); if (result.getSuccess()) { smsLog.setSendStatus(SmsSendStatusEnum.SUCCESS.getStatus()); + SysSmsLogDO smsLogDO = logMapper.selectById(logId); + result.getResult().forEach(s -> { + smsLogDO.setPhones(s.getPhone()); + smsLogDO.setSendStatus(s.getStatus()); + smsLogDO.setRemark(s.getMessage()); + smsLogDO.setCreateTime(s.getCreateTime()); + logMapper.insert(smsLogDO); + }); } else { smsLog.setSendStatus(SmsSendStatusEnum.FAIL.getStatus()); smsLog.setRemark(result.getMessage() + JsonUtils.toJsonString(result.getResult()));