SendMessageUtil.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package com.iamberry.wechat.utils;
  2. import java.util.HashMap;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.stereotype.Component;
  5. import com.iamberry.wechat.tools.NameUtils;
  6. import com.iamberry.wechat.tools.ResultInfo;
  7. import com.iamberry.wechat.tools.WeixinUtil;
  8. /**
  9. * @company 深圳爱贝源科技有限公司
  10. * @website www.iamberry.com
  11. * @author 献
  12. * @tel 18271840547
  13. * @date 2016年11月3日
  14. * @explain 发送消息通知工具类类
  15. */
  16. @Component
  17. public class SendMessageUtil {
  18. //快递公司列表
  19. public static HashMap<String, String> hashmap = new HashMap<String, String>();
  20. //正式环境
  21. {
  22. hashmap.put("shentong", "申通快递");
  23. hashmap.put("yuantong", "圆通快递");
  24. hashmap.put("shunfeng", "顺丰快递");
  25. hashmap.put("longbanwuliu", "龙邦快递");
  26. }
  27. /**
  28. * 发送模板通知给用户
  29. * @param date data 日期
  30. * @param openId 接受的用户id
  31. * @param url 点击打开的url
  32. * @param type 发送类型 1,收益成功通知 2,发货提醒通知 3、收入提醒通知,4、订单未支付通知
  33. * @return
  34. */
  35. public boolean sendTemplateMessageToOpenid(String date,String openId, String url,Integer type) {
  36. boolean result =false;
  37. switch (type) {
  38. case 1: //1,收益成功通知
  39. WeixinUtil.sendTemplateMessage(NameUtils.appId, NameUtils.appSecret, openId,ResultInfo.rewards_template_id, date, url);
  40. break;
  41. case 2: // 2,发货提醒通知
  42. WeixinUtil.sendTemplateMessage(NameUtils.appId, NameUtils.appSecret, openId, ResultInfo.Shipment_template_id, date, url);
  43. break;
  44. case 3: //3、收入提醒通知
  45. WeixinUtil.sendTemplateMessage(NameUtils.appId, NameUtils.appSecret, openId, ResultInfo.Income_template_id, date, url);
  46. break;
  47. case 4: //4、订单未支付通知
  48. WeixinUtil.sendTemplateMessage(NameUtils.appId, NameUtils.appSecret, openId, ResultInfo.Order_template_id, date, url);
  49. break;
  50. default:
  51. break;
  52. }
  53. result = true;
  54. return result;
  55. }
  56. }