This commit is contained in:
Leo
2025-12-05 22:35:51 +08:00
parent ee67d1ae8f
commit 8445b500ae
5 changed files with 68 additions and 7 deletions

View File

@@ -133,6 +133,26 @@ public class WXUtil {
return result;
}
/**
* 根据unionId获取SuperAdmin的接收人列表
* @param unionId 联盟ID
* @return 接收人列表企业微信用户ID多个用逗号分隔如果未配置则返回null
*/
public static String getTouserByUnionId(String unionId) {
if (unionId == null || unionId.trim().isEmpty()) {
return null;
}
for (SuperAdmin admin : super_admins.values()) {
if (unionId.equals(admin.getUnionId())) {
String touser = admin.getTouser();
if (touser != null && !touser.trim().isEmpty()) {
return touser.trim();
}
}
}
return null;
}
public static List<String> splitStringByLength(String input, int length) {
List<String> result = new ArrayList<>();
@@ -218,6 +238,10 @@ public class WXUtil {
}
public void sendTextMessage(String wxid, String content, Integer msgType, String fromwxid, Boolean hiddenTime) {
sendTextMessage(wxid, content, msgType, fromwxid, hiddenTime, null);
}
public void sendTextMessage(String wxid, String content, Integer msgType, String fromwxid, Boolean hiddenTime, String touser) {
// 全部打印
//logger.info("发送文本消息 msgType: {} wxid: {} fromwxid: {} content: {}", msgType, wxid, fromwxid, content);
// 先在content顶部插入时间戳
@@ -264,6 +288,10 @@ public class WXUtil {
data.put("msgType", msgType);
data.put("fromWxid", fromwxid);
data.put("hiddenTime", hiddenTime);
// 如果提供了接收人列表,添加到数据中
if (touser != null && !touser.trim().isEmpty()) {
data.put("touser", touser.trim());
}
wxReqDate.setData(data);
// wxReqDate 转成 JSONObject
JSONObject message = JSON.parseObject(JSON.toJSONString(wxReqDate));