mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
优化短信日志相关逻辑
This commit is contained in:
parent
b4be8e987a
commit
2a4d9f43eb
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import java.util.List;
|
||||
public class SmsResult implements Serializable {
|
||||
|
||||
/**
|
||||
* 是否成功
|
||||
* 是否成功(发送短信的请求是否成功)
|
||||
*/
|
||||
// TODO FROM 芋艿 to zzf:未来要加一个 code,将不同平台的短信失败的情况,做一次统一的收敛。 DONE
|
||||
private Boolean success;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -22,8 +22,11 @@ public enum SmsSendStatusEnum {
|
||||
//失败
|
||||
FAIL(3),
|
||||
|
||||
//等待回执
|
||||
WAITING(4),
|
||||
|
||||
//成功
|
||||
SUCCESS(4);
|
||||
SUCCESS(5);
|
||||
|
||||
private final int status;
|
||||
|
||||
|
@ -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()));
|
||||
|
Loading…
Reference in New Issue
Block a user