修复短信服务阿里云延迟
This commit is contained in:
parent
f4c488d763
commit
fa55722dec
@ -65,7 +65,7 @@ public class XhpcSmsController extends BaseController {
|
||||
templateId = "SMS_226935795";
|
||||
} else if (content.contains("设定的SOC")) {
|
||||
signatureName = "小华充电";
|
||||
templateId = "SMS_226826374";
|
||||
templateId = "SMS_227005968";
|
||||
}
|
||||
} else {
|
||||
phone = paramMap.get("phone");
|
||||
@ -84,7 +84,7 @@ public class XhpcSmsController extends BaseController {
|
||||
templateId = "SMS_226935795";
|
||||
} else if (content.contains("设定的SOC")) {
|
||||
signatureName = "小华充电";
|
||||
templateId = "SMS_226826374";
|
||||
templateId = "SMS_227005968";
|
||||
}
|
||||
}
|
||||
xhpcSmsService.sendNotice(phone, signatureName, templateId, paramMap);
|
||||
|
||||
@ -2,7 +2,6 @@ package com.xhpc.general.service;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.aliyun.dysmsapi20170525.Client;
|
||||
import com.aliyun.dysmsapi20170525.models.QuerySendDetailsRequest;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsResponseBody;
|
||||
@ -181,6 +180,7 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService {
|
||||
* @throws Exception
|
||||
*/
|
||||
public Map<String, String> aliyunSmsNotice(String phone, String signatureName, String templateId, Map<String, String> paramMap) throws Exception {
|
||||
|
||||
//调用阿里云API发送请求
|
||||
Client client = SmsUtil.createClient(accessKeyId, accessKeySecret);
|
||||
SendSmsRequest sendSmsRequest = new SendSmsRequest();
|
||||
@ -202,14 +202,18 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
||||
String formatData = sdf.format(realDate);
|
||||
|
||||
//获取所发送的模板信息
|
||||
QuerySendDetailsRequest querySendDetailsRequest = new QuerySendDetailsRequest();
|
||||
querySendDetailsRequest.setPhoneNumber(phone);
|
||||
querySendDetailsRequest.setBizId(bizId);
|
||||
querySendDetailsRequest.setSendDate(formatData);
|
||||
querySendDetailsRequest.setCurrentPage(1L);
|
||||
querySendDetailsRequest.setPageSize(10L);
|
||||
String templateContent = client.querySendDetails(querySendDetailsRequest).getBody().getSmsSendDetailDTOs().getSmsSendDetailDTO().get(0).getContent();
|
||||
//获取实际的模板内容
|
||||
String templateContent = getTemplateContent(templateId, paramMap);
|
||||
|
||||
// //获取所发送的模板信息
|
||||
// QuerySendDetailsRequest querySendDetailsRequest = new QuerySendDetailsRequest();
|
||||
// querySendDetailsRequest.setPhoneNumber(phone);
|
||||
// querySendDetailsRequest.setBizId(bizId);
|
||||
// querySendDetailsRequest.setSendDate(formatData);
|
||||
// querySendDetailsRequest.setCurrentPage(1L);
|
||||
// querySendDetailsRequest.setPageSize(10L);
|
||||
// Thread.sleep(400);
|
||||
// String templateContent = client.querySendDetails(querySendDetailsRequest).getBody().getSmsSendDetailDTOs().getSmsSendDetailDTO().get(0).getContent();
|
||||
|
||||
//获取阿里云的返回值json字符串
|
||||
SendSmsResponseBody body = sendSmsResponse.getBody();
|
||||
@ -223,5 +227,38 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService {
|
||||
return valueParam;
|
||||
}
|
||||
|
||||
private String getTemplateContent(String templateId, Map<String, String> paramMap) throws Exception {
|
||||
|
||||
if (templateId == "SMS_227005968") {
|
||||
String battery = paramMap.get("battery");
|
||||
String templateContent = "尊敬的用户,你的车辆已充电达至设定的SOC:" + battery + "%并停止充电,请您尽快将车辆挪走以方便他人使用充电桩,谢谢合作。";
|
||||
return templateContent;
|
||||
}
|
||||
if (templateId == "SMS_226935795") {
|
||||
String money = paramMap.get("money");
|
||||
String templateContent = "尊敬的用户,你的账户余额小于" + money + "元,为不影响您的正常充电,请您尽快充值交费,谢谢。";
|
||||
return templateContent;
|
||||
}
|
||||
if (templateId == "SMS_226786374") {
|
||||
String sumMoney = paramMap.get("sumMoney");
|
||||
String templateContent = "尊敬的用户,你的爱车已停止充电,请尽快挪车。总费用为:" + sumMoney + "元,充电费用明细,请查询小华充电小程序,谢谢。";
|
||||
return templateContent;
|
||||
}
|
||||
if (templateId == "SMS_227005968") {
|
||||
String elec = paramMap.get("elec");
|
||||
String sumMoney = paramMap.get("sumMoney");
|
||||
String templateContent = "尊敬的用户,你的爱车已停止充电,请尽快挪车。电量为:" + elec + ",总费用为:" + sumMoney + "元,充电费用明细,请查询小华充电小程序,谢谢。";
|
||||
return templateContent;
|
||||
}
|
||||
if (templateId == "SMS_226786362") {
|
||||
String code = paramMap.get("code");
|
||||
String templateContent = "您的验证码是:" + code + ",有效期为5分钟。如非本人操作,可不用理会。";
|
||||
return templateContent;
|
||||
}
|
||||
|
||||
throw new Exception("没有对应的模板id");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user