!96 修改腾讯短信Success返回值判断

Merge pull request !96 from handy/dev-3.0.x
This commit is contained in:
风如歌 2023-09-18 07:00:15 +00:00 committed by Gitee
commit a84bd25cb3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -1,6 +1,7 @@
package org.dromara.sms4j.tencent.service;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.dromara.sms4j.api.entity.SmsResponse;
@ -117,10 +118,20 @@ public class TencentSmsImpl extends AbstractSmsBlend<TencentConfig> {
private SmsResponse getResponse(JSONObject resJson) {
SmsResponse smsResponse = new SmsResponse();
JSONObject response = resJson.getJSONObject("Response");
String error = response.getStr("Error");
smsResponse.setSuccess(StrUtil.isBlank(error));
JSONArray sendStatusSet = response.getJSONArray("SendStatusSet");
boolean success = true;
for (Object obj : sendStatusSet) {
JSONObject jsonObject = (JSONObject) obj;
String code = jsonObject.getStr("Code");
if (!"Ok".equals(code)) {
success = false;
break;
}
}
smsResponse.setSuccess(success);
smsResponse.setData(resJson);
smsResponse.setConfigId(getConfigId());
return smsResponse;
}
}