From 2b69527d0d8efd948af76a1b3dd25ddbacb4988f Mon Sep 17 00:00:00 2001 From: changyang liu <477915244@qq.com> Date: Fri, 21 Aug 2020 16:41:08 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=BF=E9=87=8C=E4=BA=91=E5=8F=91=E9=80=81?= =?UTF-8?q?=E7=9F=AD=E4=BF=A1=E4=BC=98=E5=8C=96=EF=BC=8C=E5=9C=A8=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E9=94=99=E8=AF=AF=E5=90=8E=E8=AE=B0=E5=BD=95=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E4=BB=A5=E5=8F=8A=E8=BF=94=E5=9B=9E=E5=8F=91=E9=80=81?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=8A=B6=E6=80=81=20(#429)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: yang <477915244yang@gmail.com> --- .../litemall/core/notify/AliyunSmsSender.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/litemall-core/src/main/java/org/linlinjava/litemall/core/notify/AliyunSmsSender.java b/litemall-core/src/main/java/org/linlinjava/litemall/core/notify/AliyunSmsSender.java index bcc33f88..5898e092 100644 --- a/litemall-core/src/main/java/org/linlinjava/litemall/core/notify/AliyunSmsSender.java +++ b/litemall-core/src/main/java/org/linlinjava/litemall/core/notify/AliyunSmsSender.java @@ -8,6 +8,7 @@ import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.exceptions.ServerException; import com.aliyuncs.http.MethodType; import com.aliyuncs.profile.DefaultProfile; +import com.qcloud.cos.utils.Jackson; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.linlinjava.litemall.core.util.JacksonUtil; @@ -26,6 +27,8 @@ public class AliyunSmsSender implements SmsSender { private String accessKeySecret; private String sign; + private final String okCode = "OK"; + public String getRegionId() { return regionId; } @@ -106,8 +109,15 @@ public class AliyunSmsSender implements SmsSender { try { CommonResponse response = client.getCommonResponse(request); SmsResult smsResult = new SmsResult(); - smsResult.setSuccessful(true); smsResult.setResult(response); + String code = Jackson.jsonNodeOf(response.getData()).get("Code").asText(); + if (response.getHttpResponse().isSuccess() && okCode.equals(code) ){ + smsResult.setSuccessful(true); + }else { + smsResult.setSuccessful(false); + logger.error("短信发送失败:"+response.getData()); + } + return smsResult; } catch (ServerException e) { e.printStackTrace();