puzhibing
2023-04-01 36ad91a6d6887c60bfa1dc101dbfa9758a471dbc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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;
        }
    }
 
}