|
@@ -1,97 +1,24 @@
|
|
|
package com.iamberry.wechat.tools;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
-
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import com.iamberry.wechat.tools.NameUtils;
|
|
|
-import com.iamberry.wechat.tools.ResultInfo;
|
|
|
-import com.iamberry.wechat.tools.WeixinUtil;
|
|
|
-
|
|
|
@Component
|
|
|
public class SendMessageUtil {
|
|
|
|
|
|
- //快递公司列表
|
|
|
- public static HashMap<String, String> hashmap = new HashMap<String, String>();
|
|
|
- //正式环境
|
|
|
- {
|
|
|
- hashmap.put("sto", "申通快递");
|
|
|
- hashmap.put("yto", "圆通快递");
|
|
|
- hashmap.put("sf", "顺丰快递");
|
|
|
- hashmap.put("longbanwuliu", "龙邦快递");
|
|
|
- hashmap.put("ems", "邮政EMS");
|
|
|
- hashmap.put("zto", "中通快递");
|
|
|
- hashmap.put("zjs", "宅急送");
|
|
|
- hashmap.put("yunda", "韵达快递");
|
|
|
- hashmap.put("cces", "cces快递");
|
|
|
- hashmap.put("pick", "上门提货");
|
|
|
- hashmap.put("htky", "汇通快递");
|
|
|
- hashmap.put("ttkdex", "天天快递");
|
|
|
- hashmap.put("stars", "邮政EMS");
|
|
|
- hashmap.put("jd", "星晨急便");
|
|
|
- hashmap.put("01", "其他");
|
|
|
- hashmap.put("02", "上门送货");
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 发送模板通知给用户
|
|
|
* @param date data 日期
|
|
|
* @param openId 接受的用户id
|
|
|
* @param url 点击打开的url
|
|
|
- * @param type 发送类型 1,收益成功通知 2,发货提醒通知 3、收入提醒通知,4、订单未支付通知 5、试用进度提醒
|
|
|
+ * @param type
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean sendTemplateMessageToOpenid(String date,String openId, String url,Integer type) {
|
|
|
boolean result = false;
|
|
|
switch (type) {
|
|
|
- case 4: //4、订单未支付通知
|
|
|
+ case 1:
|
|
|
WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.Order_template_id, date, url);
|
|
|
break;
|
|
|
- case 8: //8、订单支付成功
|
|
|
- WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.probation_pay_success, date, url);
|
|
|
- break;
|
|
|
- case 9: //9、订单关闭成功
|
|
|
- WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.probation_shut_down, date, url);
|
|
|
- break;
|
|
|
- case 11: //11、服务进度
|
|
|
- WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.update_tooth_hint, date, url);
|
|
|
- break;
|
|
|
- case 12: //12、用户申请退款提醒
|
|
|
- WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.order_apply_refund, date, url);
|
|
|
- break;
|
|
|
- case 13: //13、用户 申请退货 提醒
|
|
|
- WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.order_apply_return, date, url);
|
|
|
- break;
|
|
|
- case 14: //14、用户 申请换货 提醒
|
|
|
- WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.order_apply_barter, date, url);
|
|
|
- break;
|
|
|
- case 15: //15、发货后 提醒
|
|
|
- WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.order_send_success, date, url);
|
|
|
- break;
|
|
|
- case 16: //16、退款申请驳回
|
|
|
- WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.refund_to_dismiss, date, url);
|
|
|
- break;
|
|
|
- case 17: //17、退款申请通知
|
|
|
- WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.refund_application_notice, date, url);
|
|
|
- break;
|
|
|
- case 18: //18、购买失败
|
|
|
- WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.refund_application_notice, date, url);
|
|
|
- break;
|
|
|
- case 19: //19、首次注册推送信息
|
|
|
- WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.registered_template, date, url);
|
|
|
- break;
|
|
|
- case 20: //20、生日赠送积分推送
|
|
|
- WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.birthday_template, date, url);
|
|
|
- break;
|
|
|
- case 21: //21参与成功
|
|
|
- WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.participate_in_success, date, url);
|
|
|
- break;
|
|
|
- case 22: //积分变更
|
|
|
- WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.point_change, date, url);
|
|
|
- break;
|
|
|
- case 23: //生日赠送
|
|
|
- WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.birthday_gift, date, url);
|
|
|
- break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -99,24 +26,6 @@ public class SendMessageUtil {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- //基本样式:
|
|
|
- //{"topcolor":"#173177","data":{"first":{"color":"#173177","value":"biaosti"},"keyword1":{"color":"#173177","value":"biaosti"},"keyword2":{"color":"#173177","value":"biaosti"},"keyword3":{"color":"#173177","value":"biaosti"},"keyword4":{"color":"#173177","value":"biaosti"},"remark":{"color":"#173177","value":"xx"}},"template_id":"EAHie4LJAWr82FfNiClPCr9zA4OEiiqvB2wINfUaT_k","touser":"oZ9pv02WMRQgyDVRY1a_daYecwHI","url":"https://s.iamberry.com/soodo/wechat/index.html"}
|
|
|
-
|
|
|
- /*public static void main(String[] args) {
|
|
|
-// String date = "{'first':{'color':'#173177', 'value':'尊敬的客户您好~您的订单已发货~'}, 'order_id':{'color':'#173177','value':'1009145345B11792L'}, 'package_id':{'color':'#173177','value':'yuantong:34234234'}, 'remark':{'color':'#173177', 'value':'点击进入商城查看-->>'}}";
|
|
|
- String date = "{'name':{'color':'#173177','value':'上朵柔羽呵护刷头 (冰川蓝)'}, 'remark':{'color':'#173177','value':'您在soodo上朵购买的刷头未填写收货地址,为了尽快为您发货,麻烦您提供一下您的收货地址。(请您尽快在公众号联系客服人员)'}}";
|
|
|
- String openId = "oZ9pv0_3_d3o7n7mye9R0WLZB8QA";
|
|
|
- String appId = "wxdb090f0af89e0be3";// 应用ID
|
|
|
- String appSecret = "518114a120274f625530750c1803921b";// 应用密钥
|
|
|
-
|
|
|
- WeixinUtil.sendTemplateMessage(appId, appSecret, openId, "gnk9JaOkAaumN1qNUjxH5IHTjundAj_-O9_G531FpH4", date, "https://s.iamberry.com/soodo/wechat/index.html");
|
|
|
- System.out.println("发送成功");
|
|
|
-
|
|
|
-// SendMessageUtil sendMessageUtil = new SendMessageUtil();
|
|
|
-// sendMessageUtil.failedPurchase("上朵柔羽呵护刷头 (冰川蓝)",
|
|
|
-// "您在soodo上朵购买的刷头未填写收货地址,为了尽快为您发货,麻烦您提供一下您的收货地址。(请您尽快在公众号联系客服人员)","oZ9pv02WMRQgyDVRY1a_daYecwHI","https://s.iamberry.com/soodo/wechat/index.html");
|
|
|
- }*/
|
|
|
-
|
|
|
public static void main(String[] args) {
|
|
|
// {{first.DATA}}用户名:{{keyword1.DATA}} 活动主题:{{keyword2.DATA}} 活动时间:{{keyword3.DATA}} 活动地点:{{keyword4.DATA}} {{remark.DATA}}
|
|
|
String date = "{'first':{'color':'#173177','value':'biaosti'},'keyword1':{'color':'#173177','value':'biaosti'},'keyword2':{'color':'#173177','value':'biaosti'},'keyword3':{'color':'#173177','value':'biaosti'},'keyword4':{'color':'#173177','value':'biaosti'}, 'remark':{'color':'#1C86EE','value':'xx'}}";
|
|
@@ -140,7 +49,6 @@ public class SendMessageUtil {
|
|
|
// System.out.println("发送成功");
|
|
|
// }
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 试用订单支付成功
|
|
|
* @param first 标题
|
|
@@ -158,268 +66,4 @@ public class SendMessageUtil {
|
|
|
.replaceFirst("remarkValue",remark);
|
|
|
sendTemplateMessageToOpenid(temp, openId, url,8);
|
|
|
}
|
|
|
- /**
|
|
|
- * 试用订单关闭成功
|
|
|
- * @param first 标题
|
|
|
- * @param keyword1 支付金额
|
|
|
- * @param keyword2 商品信息
|
|
|
- * @param remark 全部内容
|
|
|
- * @param openId 用户openid
|
|
|
- * @param url 地址
|
|
|
- */
|
|
|
- public void probationShutDown(String first,String transid,String fee,String pay_time,String remark,String openId,String url){
|
|
|
- String temp = ResultInfo.PROBATIONSHUTDOWN;
|
|
|
- temp = temp.replaceFirst("firstValueIamberry", first)
|
|
|
- .replaceFirst("transidValue",transid)
|
|
|
- .replaceFirst("feeValue",fee)
|
|
|
- .replaceFirst("pay_timeValue",pay_time)
|
|
|
- .replaceFirst("remarkValue",remark);
|
|
|
- sendTemplateMessageToOpenid(temp, openId, url,9);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 服务进度
|
|
|
- * @param first
|
|
|
- * @param keyword1
|
|
|
- * @param keyword2
|
|
|
- * @param remark
|
|
|
- * @param openId
|
|
|
- * @param url
|
|
|
- */
|
|
|
- public void serviceProgress(String first,String keyword1,String keyword2,String remark,String openId,String url){
|
|
|
- String temp = ResultInfo.UPDATETOOTHHINT;
|
|
|
- temp = temp.replaceFirst("firstValueIamberry", first)
|
|
|
- .replaceFirst("keyword1Value",keyword1)
|
|
|
- .replaceFirst("keyword2Value",keyword2)
|
|
|
- .replaceFirst("remarkValue",remark);
|
|
|
- sendTemplateMessageToOpenid(temp, openId, url,11);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 换货提醒信息
|
|
|
- * @param first
|
|
|
- * @param keyword1
|
|
|
- * @param keyword2
|
|
|
- * @param remark
|
|
|
- * @param openId
|
|
|
- * @param url
|
|
|
- */
|
|
|
- public void orderApplyBarter(String first,String keyword1,String keyword2,String remark,String openId,String url){
|
|
|
- String temp = ResultInfo.APPLYBARTER;
|
|
|
- temp = temp.replaceFirst("firstValueIamberry", first)
|
|
|
- .replaceFirst("keyword1Value",keyword1)
|
|
|
- .replaceFirst("keyword2Value",keyword2)
|
|
|
- .replaceFirst("colorValue","#1C86EE")
|
|
|
- .replaceFirst("remarkValue",remark);
|
|
|
- sendTemplateMessageToOpenid(temp, openId, url,14);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 退款提醒信息
|
|
|
- * @param first
|
|
|
- * @param keyword1
|
|
|
- * @param keyword2
|
|
|
- * @param remark
|
|
|
- * @param openId
|
|
|
- * @param url
|
|
|
- */
|
|
|
- public void orderApplyRefund(String first,String keyword1,String keyword2,String keyword3,String remark,String openId,String url){
|
|
|
- String temp = ResultInfo.APPLYREFUND;
|
|
|
- temp = temp.replaceFirst("firstValueIamberry", first)
|
|
|
- .replaceFirst("keyword1Value",keyword1)
|
|
|
- .replaceFirst("keyword2Value",keyword2)
|
|
|
- .replaceFirst("keyword3Value",keyword3)
|
|
|
- .replaceFirst("colorValue","#1C86EE")
|
|
|
- .replaceFirst("remarkValue",remark);
|
|
|
- sendTemplateMessageToOpenid(temp, openId, url,12);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 退货提醒信息
|
|
|
- * @param first
|
|
|
- * @param keyword1
|
|
|
- * @param keyword2
|
|
|
- * @param remark
|
|
|
- * @param openId
|
|
|
- * @param url
|
|
|
- */
|
|
|
- public void orderApplyReturn(String first,String keyword1,String keyword2,String keyword3,String keyword4,String remark,String openId,String url){
|
|
|
- String temp = ResultInfo.APPLYRETURN;
|
|
|
- temp = temp.replaceFirst("firstValueIamberry", first)
|
|
|
- .replaceFirst("keyword1Value",keyword1)
|
|
|
- .replaceFirst("keyword2Value",keyword2)
|
|
|
- .replaceFirst("keyword3Value",keyword3)
|
|
|
- .replaceFirst("keyword4Value",keyword4)
|
|
|
- .replaceFirst("colorValue","#1C86EE")
|
|
|
- .replaceFirst("remarkValue",remark);
|
|
|
- sendTemplateMessageToOpenid(temp, openId, url,13);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 发货提醒信息
|
|
|
- * @param first
|
|
|
- * @param keyword1
|
|
|
- * @param keyword2
|
|
|
- * @param remark
|
|
|
- * @param openId
|
|
|
- * @param url
|
|
|
- */
|
|
|
- public void orderSendSuccess(String first,String keyword1,String keyword2,String keyword3,String keyword4,String remark,String openId,String url){
|
|
|
- String temp = ResultInfo.SENDSUCCESS;
|
|
|
- temp = temp.replaceFirst("firstValueIamberry", first)
|
|
|
- .replaceFirst("keyword1Value",keyword1)
|
|
|
- .replaceFirst("keyword2Value",keyword2)
|
|
|
- .replaceFirst("keyword3Value",keyword3)
|
|
|
- .replaceFirst("keyword4Value",keyword4)
|
|
|
- .replaceFirst("colorValue","#1C86EE")
|
|
|
- .replaceFirst("remarkValue",remark);
|
|
|
- sendTemplateMessageToOpenid(temp, openId, url,15);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 退款申请驳回
|
|
|
- * @param first
|
|
|
- * @param keyword1 退款金额
|
|
|
- * @param keyword2 商品详情
|
|
|
- * @param keyword3 订单编号
|
|
|
- * @param remark
|
|
|
- * @param openId
|
|
|
- * @param url
|
|
|
- */
|
|
|
- public void refundToDismiss(String first,String keyword1,String keyword2,String keyword3,String remark,String openId,String url){
|
|
|
- String temp = ResultInfo.REFUNDSPPLICATIONREJECTED;
|
|
|
- temp = temp.replaceFirst("firstValueIamberry", first)
|
|
|
- .replaceFirst("keyword1Value",keyword1)
|
|
|
- .replaceFirst("keyword2Value",keyword2)
|
|
|
- .replaceFirst("keyword3Value",keyword3)
|
|
|
- .replaceFirst("colorValue","#1C86EE")
|
|
|
- .replaceFirst("remarkValue",remark);
|
|
|
- sendTemplateMessageToOpenid(temp, openId, url,16);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 退款申请通知
|
|
|
- * @param first
|
|
|
- * @param keyword1
|
|
|
- * @param keyword2
|
|
|
- * @param remark
|
|
|
- * @param openId
|
|
|
- * @param url
|
|
|
- */
|
|
|
- public void refundApplicationNotice(String first,String keyword1,String keyword2,String keyword3,String remark,String openId,String url){
|
|
|
- String temp = ResultInfo.REFUNDAPPLICATIONNOTICE;
|
|
|
- temp = temp.replaceFirst("firstValueIamberry", first)
|
|
|
- .replaceFirst("keyword1Value",keyword1)
|
|
|
- .replaceFirst("keyword2Value",keyword2)
|
|
|
- .replaceFirst("keyword3Value",keyword3)
|
|
|
- .replaceFirst("colorValue","#1C86EE")
|
|
|
- .replaceFirst("remarkValue",remark);
|
|
|
- sendTemplateMessageToOpenid(temp, openId, url,17);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 购买失败
|
|
|
- * @param first
|
|
|
- * @param remark
|
|
|
- * @param openId
|
|
|
- * @param url
|
|
|
- */
|
|
|
- public void failedPurchase(String first,String remark,String openId,String url){
|
|
|
- String temp = ResultInfo.REFUNDAPPLICATIONNOTICE;
|
|
|
- temp = temp.replaceFirst("nameValueIamberry", first)
|
|
|
- .replaceFirst("colorValue","#1C86EE")
|
|
|
- .replaceFirst("remarkValue",remark);
|
|
|
- sendTemplateMessageToOpenid(temp, openId, url,18);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 首次注册推送信息
|
|
|
- * @param first
|
|
|
- * @param remark
|
|
|
- * @param openId
|
|
|
- * @param url
|
|
|
- */
|
|
|
- public void registeredTemplate(String first,String keyword1,String keyword2,String keyword3,String remark,String openId,String url){
|
|
|
- String temp = ResultInfo.REGISTEREDTEMPLATE;
|
|
|
- temp = temp.replaceFirst("firstValueIamberry", first)
|
|
|
- .replaceFirst("keyword1Value",keyword1)
|
|
|
- .replaceFirst("keyword2Value",keyword2)
|
|
|
- .replaceFirst("keyword3Value",keyword3)
|
|
|
- .replaceFirst("colorValue","#1C86EE")
|
|
|
- .replaceFirst("remarkValue",remark);
|
|
|
- sendTemplateMessageToOpenid(temp, openId, url,19);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生日赠送积分推送
|
|
|
- * @param first
|
|
|
- * @param remark
|
|
|
- * @param openId
|
|
|
- * @param url
|
|
|
- */
|
|
|
- public void birthdayTemplate(String first,String keyword1,String keyword2,String keyword3,String remark,String openId,String url){
|
|
|
- String temp = ResultInfo.BIRTHDAYTEMPLATE;
|
|
|
- temp = temp.replaceFirst("nameValueIamberry", first)
|
|
|
- .replaceFirst("colorValue","#1C86EE")
|
|
|
- .replaceFirst("remarkValue",remark);
|
|
|
- sendTemplateMessageToOpenid(temp, openId, url,20);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 618活动 参与成功
|
|
|
- * @param first
|
|
|
- * @param remark
|
|
|
- * @param openId
|
|
|
- * @param url
|
|
|
- */
|
|
|
- public void participateInSuccess(String first,String keyword1,String keyword2,String keyword3,String keyword4,String remark,String openId,String url){
|
|
|
- String temp = ResultInfo.PARTICIPATEINSUCCESS;
|
|
|
- temp = temp.replaceFirst("firstValueIamberry", first)
|
|
|
- .replaceFirst("keyword1Value",keyword1)
|
|
|
- .replaceFirst("keyword2Value",keyword2)
|
|
|
- .replaceFirst("keyword3Value",keyword3)
|
|
|
- .replaceFirst("keyword4Value",keyword4)
|
|
|
- .replaceFirst("colorValue","#1C86EE")
|
|
|
- .replaceFirst("remarkValue",remark);
|
|
|
- sendTemplateMessageToOpenid(temp, openId, url,21);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 积分变更
|
|
|
- * @param first
|
|
|
- * @param remark
|
|
|
- * @param openId
|
|
|
- * @param url
|
|
|
- */
|
|
|
- public void pointChange(String first,String keyword1,String keyword2,String remark,String openId,String url){
|
|
|
- String temp = ResultInfo.POINTCHANGE;
|
|
|
- temp = temp.replaceFirst("firstValueIamberry", first)
|
|
|
- .replaceFirst("keyword1Value",keyword1)
|
|
|
- .replaceFirst("keyword2Value",keyword2)
|
|
|
- .replaceFirst("colorValue","#1C86EE")
|
|
|
- .replaceFirst("remarkValue",remark);
|
|
|
- sendTemplateMessageToOpenid(temp, openId, url,22);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 积分变更
|
|
|
- * @param first
|
|
|
- * @param remark
|
|
|
- * @param openId
|
|
|
- * @param url
|
|
|
- */
|
|
|
- public void birthdayGift(String first,String keyword1,String keyword2,String keyword3,String keyword4,String remark,String openId,String url){
|
|
|
- String temp = ResultInfo.BIRTHDAYGIFT;
|
|
|
- temp = temp.replaceFirst("firstValueIamberry", first)
|
|
|
- .replaceFirst("keyword1Value",keyword1)
|
|
|
- .replaceFirst("keyword2Value",keyword2)
|
|
|
- .replaceFirst("keyword3Value",keyword3)
|
|
|
- .replaceFirst("keyword4Value",keyword4)
|
|
|
- .replaceFirst("colorValue","#1C86EE")
|
|
|
- .replaceFirst("remarkValue",remark);
|
|
|
- sendTemplateMessageToOpenid(temp, openId, url,23);
|
|
|
- }
|
|
|
-
|
|
|
}
|