package com.stylefeng.guns.modular.system.util;
|
|
import com.stylefeng.guns.core.util.ToolUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
|
import java.util.Arrays;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* @author zhibing.pu
|
* @Date 2023/3/31 10:05
|
*/
|
@Component
|
public class SMSUtil {
|
|
@Autowired
|
private HttpClientUtil httpClientUtil;
|
|
private String username = "Ztrbkjhy";
|
|
private String password = "Zycx2023Rbkj";
|
|
private String signature = "【昭阳出行】";
|
|
|
/**
|
* 模板短信发送
|
* @param mobile 手机号
|
* @param tpId 模板id
|
* @param records 模板变量[
|
* {
|
* "mobile":"138****0000"
|
* },
|
* {
|
* "mobile":"138****0001"
|
* }
|
* ]
|
*/
|
public void sendSmsTp(String mobile, Long tpId, List<Object> records){
|
String url = "https://api.mix2.zthysms.com/v2/sendSmsTp";
|
Map<String, Object> params = new HashMap<>();
|
params.put("username", username);
|
params.put("password", password);
|
params.put("tKey", System.currentTimeMillis() / 1000);
|
params.put("signature", signature);
|
params.put("tpId", tpId);
|
params.put("mobile", mobile);
|
params.put("records", records);
|
String s = httpClientUtil.pushHttpRequset("POST", url, params, null, "json");
|
if(ToolUtil.isEmpty(s)){
|
return;
|
}
|
}
|
|
}
|