6 changed files with 167 additions and 7 deletions
@ -0,0 +1,70 @@ |
|||
package com.qs.serve.common.util; |
|||
|
|||
import cn.hutool.crypto.digest.DigestUtil; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.io.UnsupportedEncodingException; |
|||
import java.net.URLEncoder; |
|||
import java.time.LocalDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
|
|||
/** |
|||
* @author YenHex |
|||
* @since 2024/1/26 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
public class TianYiYunSmsUtil { |
|||
|
|||
private final static String url = "http://sms.189ek.com/yktsms/send?"; |
|||
|
|||
private final static String appId = "WIgWyCFn4DnHLtjKBIXBVyZbGevFg3J4"; |
|||
|
|||
private final static String appKey = "bjfsZlF01OZPUzyiCLSFOrOOnfsZhYZJ"; |
|||
|
|||
/** |
|||
* 发送短信 |
|||
* @param mobiles 需要发送的手机号(多个号码以英文逗号 “,”分隔) 一次性最多 100 个号码 |
|||
* @param message |
|||
*/ |
|||
public static void send(String mobiles,String message){ |
|||
String sign = DigestUtil.md5Hex(appId+mobiles+message+appKey); |
|||
try { |
|||
String msg = URLEncoder.encode(message,"utf-8"); |
|||
String params = "appid="+ appId + |
|||
"&mobile="+ mobiles + |
|||
"&msg=" + msg + |
|||
"&sign=" + sign + |
|||
"&extPort="; |
|||
String result = HttpUtil.doPost(url + params,"{}",null); |
|||
log.debug("sms result = > {}",result); |
|||
} catch (UnsupportedEncodingException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 发送短信通知申请人 |
|||
* @param mobile 手机号 |
|||
* @param url 拜访申请实例页面地址 |
|||
* @param visitDate 来访时间 |
|||
* @param accessUser 拜访的人员 |
|||
*/ |
|||
public static void sendVisitSuccess(String mobile,String url,LocalDateTime visitDate,String accessUser){ |
|||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH时mm分"); |
|||
String visitDateFormat = visitDate.format(df); |
|||
String msg = "【嘉士利】预约成功通知:您的预约已被确认,请您于"+visitDateFormat +"访问:"+accessUser+ |
|||
",您的访问信息如下:"+url+",点击链接展示来访二维码,门卫扫码即可完成登记。期待您的到访。"; |
|||
send(mobile,msg); |
|||
} |
|||
|
|||
public static void main(String[] args) { |
|||
String url = "https://crm.gdjsl.com/#/department-list"; |
|||
LocalDateTime visitStartDate = LocalDateTime.now(); |
|||
String accessUser = "员工2"; |
|||
sendVisitSuccess("13286630016",url,visitStartDate,accessUser); |
|||
} |
|||
|
|||
|
|||
} |
Loading…
Reference in new issue