package template;
import java.util.HashMap;
import java.util.Map;
import utils.HttpClientUtils;
public class TemplateMes {
// 验证码下发通知
private static String CAPTCHA = "C6prQJL-_B0WXTEg6tEzFOhYAF7XTx3MQkGm8AqNgX4";
// 微信绑定成功通知
private static String BINDINGSUCC = "G9ZAmT7dlrdhj2erL9oXIyoghNiAAwTaBwVgJ2NUauA";
// 订单状态更新
private static String UPDATEORDER = "J-_E4A7R3y_m_b3Qh0X2OzIuAjxoI1BOGPX7uuCJtoU";
// 找回密码通知
private static String FINDPWD = "K0S1umgygvbJ1UwWbzGyONIOFGckae_eT2hdxY4bts0";
// 领取红包通知
private static String RECEIVERED = "Zoi2Hmbm0vl8InrxewOYNsIP346WZE6Qi6nM21YJKiA";
// 订单支付成功
private static String PAYSUCC = "_AHJzOER3yJb3Vf43vWpw3Id76QwE9oZ6_3cDH8qGRM";
// 订单签收提醒
private static String RECEIPTORDER = "mqHiKAQ5D5o6VWlzkEXcnHhnyuFsoB1LE9wemKOwy_Q";
private static String MESSAGE_TYPE_CAPTCHA = "captcha";
private static String MESSAGE_TYPE_BINDINGSUCC = "bindingsucc";
private static String MESSAGE_TYPE_UPDATEORDER = "updateorder";
private static String MESSAGE_TYPE_FINDPWD = "findpwd";
private static String MESSAGE_TYPE_RECEIVERED = "receivered";
private static String MESSAGE_TYPE_PAYSUCC = "paysucc";
private static String MESSAGE_TYPE_RECEIPTORDER = "receiptorder";
public String sendWXMes(String type, Map<String, String> mesinfo)
throws Exception {
String jsoninfo = null;
if (MESSAGE_TYPE_CAPTCHA.equals(type.trim())) {
// 验证码下发通知
jsoninfo = TemplateMes.sendCaptcha(mesinfo);
} else if (MESSAGE_TYPE_BINDINGSUCC.equals(type.trim())) {
// 微信绑定成功通知
jsoninfo = TemplateMes.sendBindingsucc(mesinfo);
} else if (MESSAGE_TYPE_UPDATEORDER.equals(type.trim())) {
// 订单状态更新
jsoninfo = TemplateMes.sendUpdateorder(mesinfo);
} else if (MESSAGE_TYPE_FINDPWD.equals(type.trim())) {
// 找回密码通知
jsoninfo = TemplateMes.sendFindpwd(mesinfo);
} else if (MESSAGE_TYPE_RECEIVERED.equals(type.trim())) {
// 领取红包通知
jsoninfo = TemplateMes.sendReceivered(mesinfo);
} else if (MESSAGE_TYPE_PAYSUCC.equals(type.trim())) {
// 订单支付成功
jsoninfo = TemplateMes.sendPaysucc(mesinfo);
} else if (MESSAGE_TYPE_RECEIPTORDER.equals(type.trim())) {
// 订单签收提醒
jsoninfo = TemplateMes.sendReceiptorder(mesinfo);
}
String strUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=7NtH118fqTJk0lRQq-swYTgyEHeCVMTnBJ3cVZlcbWwkDYxYza97Yvtgwo9_RyeX3o-wQr0NuN6IaMx_GFvHtg";
// + TokenThread.accessToken.getToken();
return HttpClientUtils.postJSON(strUrl, jsoninfo);
}
private static String sendCaptcha(Map<String, String> mesinfo) {
String jsoninfo = "{\"template_id\": \""+CAPTCHA+"\",\"topcolor\": \"#FF0000\",\"touser\": \""+mesinfo.get("openid")+"\",\"url\": \""+mesinfo.get("url")+"\", "
+ "\"data\":"
+ "{\"first\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("first")+"\" },\"remark\": {\"color\": \"#173177\",\"value\":\""+mesinfo.get("remark")+"\"}, "
+ "\"number\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("number")+"\" }}}";
return jsoninfo;
}
private static String sendBindingsucc(Map<String, String> mesinfo) {
String jsoninfo = "{\"template_id\": \""+BINDINGSUCC+"\",\"topcolor\": \"#FF0000\",\"touser\": \""+mesinfo.get("openid")+"\",\"url\": \""+mesinfo.get("url")+"\", "
+ "\"data\":"
+ "{\"first\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("first")+"\" },\"remark\": {\"color\": \"#173177\",\"value\":\""+mesinfo.get("remark")+"\"},"
+ " \"keyword1\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("wechatid")+"\"},"
+ "\"keyword2\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("bindid")+"\"},"
+ "\"keyword3\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("features")+"\" }}}";
return jsoninfo;
}
private static String sendUpdateorder(Map<String, String> mesinfo) {
String jsoninfo = "{\"template_id\": \""+UPDATEORDER+"\",\"topcolor\": \"#FF0000\",\"touser\": \""+mesinfo.get("openid")+"\",\"url\": \""+mesinfo.get("url")+"\", "
+ "\"data\":"
+ "{\"first\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("first")+"\" },\"remark\": {\"color\": \"#173177\",\"value\":\""+mesinfo.get("remark")+"\"},"
+ " \"OrderSn\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("ordersn")+"\"},"
+ "\"OrderStatus\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("orderstatus")+"\" }}}";
return jsoninfo;
}
private static String sendFindpwd(Map<String, String> mesinfo) {
String jsoninfo = "{\"template_id\": \""+FINDPWD+"\",\"topcolor\": \"#FF0000\",\"touser\": \""+mesinfo.get("openid")+"\",\"url\": \""+mesinfo.get("url")+"\", "
+ "\"data\":"
+ "{\"first\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("first")+"\" },\"remark\": {\"color\": \"#173177\",\"value\":\""+mesinfo.get("remark")+"\"},"
+ " \"keyword1\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("username")+"\"},"
+ "\"keyword2\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("password")+"\" }}}";
return jsoninfo;
}
private static String sendReceivered(Map<String, String> mesinfo) {
String jsoninfo = "{\"template_id\": \""+RECEIVERED+"\",\"topcolor\": \"#FF0000\",\"touser\": \""+mesinfo.get("openid")+"\",\"url\": \""+mesinfo.get("url")+"\", "
+ "\"data\":"
+ "{\"first\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("first")+"\" },\"remark\": {\"color\": \"#173177\",\"value\":\""+mesinfo.get("remark")+"\"},"
+ " \"keyword1\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("redEnvelope")+"\"},"
+ "\"keyword2\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("amount")+"\" }}}";
return jsoninfo;
}
private static String sendPaysucc(Map<String, String> mesinfo) {
String jsoninfo = "{\"template_id\": \""+PAYSUCC+"\",\"topcolor\": \"#FF0000\",\"touser\": \""+mesinfo.get("openid")+"\",\"url\": \""+mesinfo.get("url")+"\", "
+ "\"data\":"
+ "{\"first\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("first")+"\" },\"remark\": {\"color\": \"#173177\",\"value\":\""+mesinfo.get("remark")+"\"},"
+ " \"orderMoneySum\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("orderMoneySum")+"\"},"
+ "\"orderProductName\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("orderProductName")+"\" }}}";
return jsoninfo;
}
private static String sendReceiptorder(Map<String, String> mesinfo) {
String jsoninfo = "{\"template_id\": \""+RECEIPTORDER+"\",\"topcolor\": \"#FF0000\",\"touser\": \""+mesinfo.get("openid")+"\",\"url\": \""+mesinfo.get("url")+"\", "
+ "\"data\":"
+ "{\"first\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("first")+"\" },\"remark\": {\"color\": \"#173177\",\"value\":\""+mesinfo.get("remark")+"\"},"
+ " \"Content1\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("content")+"\"},"
+ " \"Good\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("good")+"\"},"
+ " \"OrderSn1\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("ordersn1")+"\"},"
+ " \"OrderSn2\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("ordersn2")+"\"},"
+ " \"OrderSn3\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("ordersn3")+"\"},"
+ "\"Eval\": {\"color\": \"#173177\",\"value\": \""+mesinfo.get("eval")+"\" }}}";
return jsoninfo;
}
public static void main(String[] args) {
TemplateMes wm=new TemplateMes();
String type="receiptorder";//换这里测试
Map<String, String> mesinfo = new HashMap<String, String>();
mesinfo.put("openid", "oXvtwt39xHYF-EspDz1GMVDniWI0");//微信openid
mesinfo.put("url", "www.baidu.com");//点击以后跳转的链接地址
if (type.equals("captcha")) {
/* 验证码下发通知
* 尊敬的顾客,手机动态验证码为123456。
* 该验证码有效期30分钟可输入1次,转发无效。
*/
mesinfo.put("first", "尊敬的顾客,");
mesinfo.put("remark", "该验证码有效期30分钟可�
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
WXTemplateMes.zip (16个子文件)
WXTemplateMes
WebContent
META-INF
MANIFEST.MF 39B
WEB-INF
lib
commons-httpclient-3.1_2.jar 313KB
log4j-1.2.17.jar 478KB
.settings
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.project.facet.core.xml 305B
org.eclipse.core.resources.prefs 102B
org.eclipse.wst.common.component 493B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 503B
org.eclipse.jdt.core.prefs 364B
src
utils
HttpClientUtils.java 8KB
template
TemplateMes.java 11KB
.project 1KB
.classpath 588B
build
classes
utils
HttpClientUtils.class 9KB
template
TemplateMes.class 9KB
共 16 条
- 1
资源评论
- English_Cander2016-03-21可以作为参考,具体的需要自己进一步调试
- litiangang19892015-11-17可以作为参考,具体的需要自己进一步调试。
- kinghsheng2015-10-04java 感觉用不上,希望出点php
- clx_09142015-06-03java的,真心不需要啊
- mayqewasd2014-12-19真心没什么内容,只是个模板消息的生成,无法实现啃网线的耗子2014-12-23ctrl+f11无法实现?你没配置对吧
啃网线的耗子
- 粉丝: 7
- 资源: 11
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- CVPR2024-用于多传感器全息交叉口和车辆基础设施合作的大规模数据集和基准-英文论文
- IoT安全漏洞检测平台(中国民航大学本科毕业设计).zip
- Grooo外卖,在校参与创业&比赛&毕业设计作品 一个完整的iOS app,有配套后端 .zip
- go-socket.io 的 Redis 适配器.zip
- go zero gorm扩展,db模型与Redis缓存的集成处理.zip
- 电线线路破损损坏检测50-YOLO(v5至v9)、COCO、CreateML、Darknet、Paligemma、TFRecord、VOC数据集合集.rar
- ToDoList.zip
- CVPR-DiffAssemble: A Unified Graph-Diffusion Model for 2D and 3D Reassembly(用于二维和三维重构的统一图扩散模型)含论文及代码
- Fluent 事件收集器的 Redis 输出插件.zip
- 深度学习领域的卷积神经网络结构解析与实践应用
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功