package com.seeyon.apps.src_automatic.util;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import www.seeyon.com.utils.MD5Util;

/**
 * Description
 * <pre></pre>
 * Date 2020年12月3日 下午9:00:27<br>
 * Copyright(c) Beijing Seeyon Software Co.,LTD
 */
public class MoblieMsgUtil {
	
	public static String sendMsg(String phone, String id, String content) throws Exception {
		Map<String, Object> params = new HashMap<>();
		String url = PropKit.getProp(PropKit.URL);
//		String url = "http://120.55.193.51:8098/smtp/http/submit";
		String userName = PropKit.getProp(PropKit.USER_NAME);
//		String userName = "ycjyjtgs";
//		String serviceCode = "ycjyjtgs";
		String timestamp = System.currentTimeMillis() + "";
		String serviceCode = PropKit.getProp(PropKit.SERVICE_CODE);
		String priority = "5";
		String encoding = "utf-8";
		String reportFlag = "0";
		String sign = getSign(timestamp);
		params.put("timestamp", timestamp);
		params.put("userName", userName);
		params.put("serviceCode", serviceCode);
		params.put("priority", priority);
		params.put("encoding", encoding);
		params.put("reportFlag", reportFlag);
		params.put("sign", sign);
		params.put("phones", phone);
		params.put("mhtMsgIds", id);
		params.put("msgContent", content);
		String res = HttpKit.post(url, params);
		return res;
	}
	
	private static String getSign(String timestamp) throws FileNotFoundException, IOException {
		String sign = PropKit.getProp(PropKit.USER_PASSWORD) + timestamp;
//		String sign = "qRJmZ5fL3AI7" + timestamp;
		return MD5Util.MD5(sign).toUpperCase();
	}

	public static void main(String[] args) throws Exception {
//		System.out.println(System.currentTimeMillis());
		sendMsg("18164170159", "264", "这是一条测试短信");
	}
}
