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()));