package cc.mrbird.febs.common.utils; 
 | 
  
 | 
import cn.hutool.core.date.DatePattern; 
 | 
import cn.hutool.core.date.DateUtil; 
 | 
import cn.hutool.core.util.StrUtil; 
 | 
import cn.hutool.core.util.XmlUtil; 
 | 
import cn.hutool.crypto.SecureUtil; 
 | 
import cn.hutool.http.HttpUtil; 
 | 
import lombok.extern.slf4j.Slf4j; 
 | 
  
 | 
import java.util.Date; 
 | 
import java.util.HashMap; 
 | 
import java.util.Map; 
 | 
  
 | 
/** 
 | 
 * @author wzy 
 | 
 * @date 2021-03-25 
 | 
 **/ 
 | 
@Slf4j 
 | 
public class ZzSmsSend { 
 | 
  
 | 
    private static final String URL = "http://zzsms365.com/v2sms.aspx?action=send"; 
 | 
  
 | 
    private static final String USER_ID = "1654"; 
 | 
    private static final String ACCOUNT = "1369815429"; 
 | 
    private static final String PWD = "1369815429"; 
 | 
  
 | 
    public static boolean sendVerifyCode(String telphone, String code, int time) { 
 | 
        String content = "【MaShiMar】您的验证码是{},请在{}分钟内输入,请勿泄露给他人,如非本人操作,请及时修改密码。"; 
 | 
        return send(telphone, StrUtil.format(content, code, time)); 
 | 
    } 
 | 
  
 | 
    private static boolean send(String telphone, String content) { 
 | 
        Map<String, Object> data = new HashMap<>(); 
 | 
        Long time = System.currentTimeMillis(); 
 | 
        data.put("userid", USER_ID); 
 | 
        data.put("timestamp", time); 
 | 
        data.put("mobile", telphone); 
 | 
        String signStr = ACCOUNT + PWD + time; 
 | 
        String sign = SecureUtil.md5(signStr); 
 | 
        data.put("sign", sign); 
 | 
        data.put("content", content); 
 | 
  
 | 
        String response = HttpUtil.post(URL, data); 
 | 
        log.info("短信发送:{}", response); 
 | 
        if ("Success".equals(XmlUtil.xmlToMap(response).get("returnstatus"))) { 
 | 
            return true; 
 | 
        } else { 
 | 
//            throw new GlobalException((String) XmlUtil.xmlToMap(response).get("message")); 
 | 
            return false; 
 | 
        } 
 | 
    } 
 | 
  
 | 
    public static void main(String[] args) { 
 | 
        Map<String, Object> data = new HashMap<>(); 
 | 
        Long time = System.currentTimeMillis(); 
 | 
        data.put("userid", USER_ID); 
 | 
        data.put("timestamp", time); 
 | 
        data.put("mobile", "15274802129"); 
 | 
        String signStr = ACCOUNT + PWD + time; 
 | 
        String sign = SecureUtil.md5(signStr); 
 | 
        data.put("sign", sign); 
 | 
        data.put("content", "【HiBit】尊敬的用户,恭喜您于2010-03-25有一笔充值已成功到账,充值数量为10。"); 
 | 
  
 | 
        String post = HttpUtil.post(URL, data); 
 | 
        System.out.println(post); 
 | 
    } 
 | 
} 
 |