|
@@ -0,0 +1,197 @@
|
|
|
+package com.iamberry.wechat.tools;
|
|
|
+
|
|
|
+import com.iamberry.wechat.tools.NameUtils;
|
|
|
+import com.iamberry.wechat.tools.ResultInfo;
|
|
|
+import com.iamberry.wechat.tools.WeixinUtil;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+/**
|
|
|
+ * @company 深圳爱贝源科技有限公司
|
|
|
+ * @website www.iamberry.com
|
|
|
+ * @author 献
|
|
|
+ * @tel 18271840547
|
|
|
+ * @date 2016年11月3日
|
|
|
+ * @explain 发送消息通知工具类类
|
|
|
+ */
|
|
|
+@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、订单未支付通知
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public boolean sendTemplateMessageToOpenid(String date,String openId, String url,Integer type) {
|
|
|
+ boolean result =false;
|
|
|
+ switch (type) {
|
|
|
+ case 1: //1,收益成功通知
|
|
|
+ WeixinUtil.sendTemplateMessage(NameUtils.appId, NameUtils.appSecret, openId,ResultInfo.rewards_template_id, date, url);
|
|
|
+ break;
|
|
|
+ case 2: // 2,发货提醒通知
|
|
|
+ WeixinUtil.sendTemplateMessage(NameUtils.appId, NameUtils.appSecret, openId, ResultInfo.Shipment_template_id, date, url);
|
|
|
+ break;
|
|
|
+ case 3: //3、收入提醒通知
|
|
|
+ WeixinUtil.sendTemplateMessage(NameUtils.appId, NameUtils.appSecret, openId, ResultInfo.Income_template_id, date, url);
|
|
|
+ break;
|
|
|
+ case 4: //4、订单未支付通知
|
|
|
+ WeixinUtil.sendTemplateMessage(NameUtils.appId, NameUtils.appSecret, openId, ResultInfo.Order_template_id, date, url);
|
|
|
+ break;
|
|
|
+ case 5: //5、支付成功
|
|
|
+ WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.probation_pay_success, date, url);
|
|
|
+ break;
|
|
|
+ case 6: //6、用户申请退款提醒
|
|
|
+ WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.order_apply_refund, date, url);
|
|
|
+ break;
|
|
|
+ case 7: //7、用户 申请退货 提醒
|
|
|
+ WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.order_apply_return, date, url);
|
|
|
+ break;
|
|
|
+ case 8: //8、用户 申请换货 提醒
|
|
|
+ WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.order_apply_barter, date, url);
|
|
|
+ break;
|
|
|
+ case 9: //9、发货后 提醒
|
|
|
+ WeixinUtil.sendTemplateMessage(NameUtils.getConfig("appId"), NameUtils.getConfig("appSecret"), openId, ResultInfo.order_send_success, date, url);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ result = true;
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 支付成功
|
|
|
+ * @param first
|
|
|
+ * @param keyword1
|
|
|
+ * @param keyword2
|
|
|
+ * @param keyword3
|
|
|
+ * @param remark
|
|
|
+ * @param openId
|
|
|
+ * @param url
|
|
|
+ */
|
|
|
+ public void probationPaySuccess(String first,String keyword1,String keyword2,String keyword3,String remark,String openId,String url){
|
|
|
+ String temp = ResultInfo.PROBATIONPAYSUCCESS;
|
|
|
+ temp = temp.replaceFirst("first", first)
|
|
|
+ .replaceFirst("keyword1",keyword1)
|
|
|
+ .replaceFirst("keyword2",keyword2)
|
|
|
+ .replaceFirst("keyword3",keyword3)
|
|
|
+ .replaceFirst("colorValue","#1C86EE")
|
|
|
+ .replaceFirst("remark",remark);
|
|
|
+ sendTemplateMessageToOpenid(temp, openId, url,5);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户申请退款提醒
|
|
|
+ * @param first
|
|
|
+ * @param keyword1
|
|
|
+ * @param keyword2
|
|
|
+ * @param keyword3
|
|
|
+ * @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("first", first)
|
|
|
+ .replaceFirst("keyword1",keyword1)
|
|
|
+ .replaceFirst("keyword2",keyword2)
|
|
|
+ .replaceFirst("keyword3",keyword3)
|
|
|
+ .replaceFirst("colorValue","#1C86EE")
|
|
|
+ .replaceFirst("remark",remark);
|
|
|
+ sendTemplateMessageToOpenid(temp, openId, url,6);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 退货
|
|
|
+ * @param first
|
|
|
+ * @param keyword1
|
|
|
+ * @param keyword2
|
|
|
+ * @param keyword3
|
|
|
+ * @param keyword4
|
|
|
+ * @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("first", first)
|
|
|
+ .replaceFirst("keyword1",keyword1)
|
|
|
+ .replaceFirst("keyword2",keyword2)
|
|
|
+ .replaceFirst("keyword3",keyword3)
|
|
|
+ .replaceFirst("keyword4",keyword4)
|
|
|
+ .replaceFirst("colorValue","#1C86EE")
|
|
|
+ .replaceFirst("remark",remark);
|
|
|
+ sendTemplateMessageToOpenid(temp, openId, url,7);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 申请换货
|
|
|
+ * @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("first", first)
|
|
|
+ .replaceFirst("keyword1",keyword1)
|
|
|
+ .replaceFirst("keyword2",keyword2)
|
|
|
+ .replaceFirst("colorValue","#1C86EE")
|
|
|
+ .replaceFirst("remark",remark);
|
|
|
+ sendTemplateMessageToOpenid(temp, openId, url,8);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发货后提醒
|
|
|
+ * @param first
|
|
|
+ * @param keyword1
|
|
|
+ * @param keyword2
|
|
|
+ * @param keyword3
|
|
|
+ * @param keyword4
|
|
|
+ * @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("first", first)
|
|
|
+ .replaceFirst("keyword1",keyword1)
|
|
|
+ .replaceFirst("keyword2",keyword2)
|
|
|
+ .replaceFirst("keyword3",keyword3)
|
|
|
+ .replaceFirst("keyword4",keyword4)
|
|
|
+ .replaceFirst("colorValue","#1C86EE")
|
|
|
+ .replaceFirst("remark",remark);
|
|
|
+ sendTemplateMessageToOpenid(temp, openId, url,9);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|