From bbe0a2fd03063316e50cf141986bda984599bbda Mon Sep 17 00:00:00 2001
From: 935090232@qq.com <ak473600000>
Date: Tue, 22 Feb 2022 23:41:42 +0800
Subject: [PATCH] Merge branch 'developer'
---
zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/UniformMsgSentTask.java | 49 ++++++++++++++++++++-----------------------------
1 files changed, 20 insertions(+), 29 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/UniformMsgSentTask.java b/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/UniformMsgSentTask.java
index 3549c4a..9680fbb 100644
--- a/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/UniformMsgSentTask.java
+++ b/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/UniformMsgSentTask.java
@@ -2,29 +2,18 @@
import com.alibaba.fastjson.JSONObject;
-import com.matrix.biz.bean.BizUser;
-import com.matrix.biz.service.BizUserService;
+import com.matrix.component.asyncmessage.MessageHandler;
import com.matrix.component.tools.HttpClientUtil;
-import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.tools.LogUtil;
import com.matrix.core.tools.rr.GlueFactory;
import com.matrix.system.common.bean.BusParameterSettings;
import com.matrix.system.common.constance.AppConstance;
import com.matrix.system.common.dao.BusParameterSettingsDao;
-import com.matrix.system.constance.Dictionary;
-import com.matrix.system.hive.bean.SysProjServices;
-import com.matrix.system.hive.bean.SysVipInfo;
-import com.matrix.system.hive.dao.SysProjServicesDao;
-import com.matrix.system.hive.dao.SysShopInfoDao;
-import com.matrix.system.hive.dao.SysVipInfoDao;
import com.matrix.system.shopXcx.api.WeChatGzhApiTools;
import com.matrix.system.shopXcx.bean.ShopWxtemplateMsg;
import com.matrix.system.shopXcx.dao.ShopWxtemplateMsgDao;
-import com.matrix.system.wechart.templateMsg.GzhTemplateMessagePojo;
+import com.matrix.system.shopXcx.mqTask.AsyncMessageRouting;
import com.matrix.system.wechart.templateMsg.UniformMsgPojo;
-import com.rabbitmq.client.DeliverCallback;
-import com.rabbitmq.client.Delivery;
-import io.swagger.models.auth.In;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -38,7 +27,7 @@
* @author jyy
*/
@Component
-public class UniformMsgSentTask implements DeliverCallback {
+public class UniformMsgSentTask implements MessageHandler {
@Autowired
private ShopWxtemplateMsgDao shopWxtemplateMsgDao;
@@ -46,28 +35,33 @@
@Autowired
private BusParameterSettingsDao busParameterSettingsDao;
+ @Override
+ public String getName() {
+ return "小程序统一消息模板消息发送提醒";
+ }
+
+ @Override
+ public String getRouteKey() {
+ return AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG;
+ }
+
/**
* 发送模板消息需要传JSONO字符串作为格式
* 例如:{"companyId":17}
* companyId 是必须属性
- * @param consumerTag
- * @param message
* @throws IOException
*/
@Override
- public void handle(String consumerTag, Delivery message) throws IOException {
+ public void handle(Map<String,Object> param){
try {
- String messages = new String(message.getBody(), "UTF-8");
- JSONObject messageJsonParam=JSONObject.parseObject(messages);
-
- if(!messageJsonParam.containsKey("companyId")||(!messageJsonParam.containsKey("templateCode"))){
+ if(!param.containsKey("companyId")||(!param.containsKey("templateCode"))){
LogUtil.error("小程序消息推送参数格式异常发送模板消息需要传JSONO字符串作为格式 例如:{\"companyId\":17,\"templateCode\":10000} companyId 、templateCode 是必须属性");
return;
}
- Long companyId = Long.parseLong( messageJsonParam.get("companyId").toString());
- Integer templateCode = Integer.parseInt( messageJsonParam.get("templateCode").toString());
+ Long companyId = Long.parseLong( param.get("companyId").toString());
+ Integer templateCode = Integer.parseInt( param.get("templateCode").toString());
//获取公司微信配置参数
BusParameterSettings xcxAppId = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.MINIPROGRAM_APPID, companyId);
@@ -87,15 +81,13 @@
bulderParam.put("xcxAppId", xcxAppId.getParamValue());
bulderParam.put("gzhAppid", gzhAppid.getParamValue());
bulderParam.put("template_id", template.getUuid());
- bulderParam.put("messageJsonParam", messageJsonParam);
-
-
+ bulderParam.put("messageJsonParam", param);
//调用模板计算出消息体
Map msgResult = templateMessageBulder.buildMsg(bulderParam);
if(msgResult.containsKey("error")){
//错误消息处理
- LogUtil.error("模板消息发送失败:"+msgResult.get("error"));
+ LogUtil.error("模板消息发送内容:"+msgResult.get("error"));
return;
}else{
//正常返回消息
@@ -105,16 +97,15 @@
String url = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN".replaceAll("ACCESS_TOKEN", ACCESS_TOKEN);
for (Object msg : msgList) {
UniformMsgPojo uniformMsgPojo = (UniformMsgPojo) msg;
+ LogUtil.debug("微信小程序模板消息推送:" + JSONObject.toJSON(uniformMsgPojo).toString());
//推送消息到微信
JSONObject result = HttpClientUtil.sendPostWithJson(url, JSONObject.toJSON(uniformMsgPojo).toString());
//微信返回值
LogUtil.debug("微信小程序模板消息推送结果:" + result.toString());
}
}
-
} catch (Exception e) {
LogUtil.error("消费者执行异常", e);
}
-
}
}
--
Gitblit v1.9.1