sendResult = client.sms().batch_send(paramMap);
+ boolean success = sendResult.getCode().equals(Code.OK);
+
+ if (!success) {
+ log.debug("send fail[code={}, message={}]", sendResult.getCode(), sendResult.getDetail());
+ }
+ return new SmsResult()
+ .setSuccess(success)
+ .setMessage(sendResult.getDetail())
+ .setCode(sendResult.getCode().toString())
+ .setApiId(sendResult.getData().getData().get(0).getSid().toString());
+ }
+
+
+ /**
+ * 格式化短信内容,将参数注入到模板中
+ *
+ * @param smsBody 短信信息
+ * @return 格式化后的短信内容
+ */
+ private String formatContent(SmsBody smsBody) {
+ StringBuilder result = new StringBuilder(smsBody.getTemplateContent());
+ smsBody.getParams().forEach((key, val) -> {
+ String param = parseParamToPlaceholder(key);
+ result.replace(result.indexOf(param), result.indexOf(param + param.length()), val);
+ });
+ return result.toString();
+ }
+
+ /**
+ * 将指定参数改成对应的占位字符
+ *
+ * 云片的是 #param# 的形式作为占位符
+ *
+ * @param key 参数名
+ * @return 对应的占位字符
+ */
+ private String parseParamToPlaceholder(String key) {
+ return SmsConstants.JING_HAO + key + SmsConstants.JING_HAO;
+ }
+
+
+ @Override
+ public List getSmsSendResult(ServletRequest request) throws UnsupportedEncodingException {
+ List