fix luosimao的手机号不需要+86前缀

This commit is contained in:
LiYaoheng 2024-11-04 17:07:09 +08:00
parent 109f50cfd1
commit 1c0d518fdb

View File

@ -1,6 +1,5 @@
package org.dromara.sms4j.luosimao.utils; package org.dromara.sms4j.luosimao.utils;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.dromara.sms4j.comm.constant.Constant; import org.dromara.sms4j.comm.constant.Constant;
import org.dromara.sms4j.comm.utils.SmsDateUtils; import org.dromara.sms4j.comm.utils.SmsDateUtils;
@ -13,24 +12,24 @@ import java.util.List;
@Slf4j @Slf4j
public class LuoSiMaoUtils { public class LuoSiMaoUtils {
public static LinkedHashMap<String, String> buildHeaders(){ public static LinkedHashMap<String, String> buildHeaders() {
LinkedHashMap<String, String> headers = new LinkedHashMap<>(1); LinkedHashMap<String, String> headers = new LinkedHashMap<>(1);
headers.put(Constant.CONTENT_TYPE, Constant.APPLICATION_FROM_URLENCODED); headers.put(Constant.CONTENT_TYPE, Constant.APPLICATION_FROM_URLENCODED);
return headers; return headers;
} }
public static LinkedHashMap<String, Object> buildBody(String phone, String message){ public static LinkedHashMap<String, Object> buildBody(String phone, String message) {
LinkedHashMap<String, Object> body = new LinkedHashMap<>(2); LinkedHashMap<String, Object> body = new LinkedHashMap<>(2);
body.put("mobile", StrUtil.addPrefixIfNot(phone, "+86")); body.put("mobile", phone);
body.put("message", message); body.put("message", message);
return body; return body;
} }
public static LinkedHashMap<String, Object> buildBody(List<String> phones, String message, Date date){ public static LinkedHashMap<String, Object> buildBody(List<String> phones, String message, Date date) {
LinkedHashMap<String, Object> body = new LinkedHashMap<>(2); LinkedHashMap<String, Object> body = new LinkedHashMap<>(2);
body.put("mobile", SmsUtils.addCodePrefixIfNot(phones)); body.put("mobile", SmsUtils.joinComma(phones));
body.put("message", message); body.put("message", message);
if (date != null){ if (date != null) {
body.put("time", SmsDateUtils.normDatetimeGmt8(date)); body.put("time", SmsDateUtils.normDatetimeGmt8(date));
} }
return body; return body;