From 0bd8b47da0932211becab94d81dc71422045c782 Mon Sep 17 00:00:00 2001 From: sg <2450572350@qq.com> Date: Fri, 8 Mar 2024 16:54:42 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/wxhk/model/PrivateChatMsg.java | 5 +++++ .../com/example/wxhk/model/request/OpenHook.java | 13 +++++++++++++ .../main/java/com/example/wxhk/msg/WxMsgHandle.java | 12 +++++++++--- .../example/wxhk/server/impl/WxSmgServerImpl.java | 4 +++- .../java/com/example/wxhk/tcp/vertx/VertxTcp.java | 8 ++++++-- 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/java_client/src/main/java/com/example/wxhk/model/PrivateChatMsg.java b/java_client/src/main/java/com/example/wxhk/model/PrivateChatMsg.java index 25424b7..efbf324 100644 --- a/java_client/src/main/java/com/example/wxhk/model/PrivateChatMsg.java +++ b/java_client/src/main/java/com/example/wxhk/model/PrivateChatMsg.java @@ -42,6 +42,11 @@ public class PrivateChatMsg implements Serializable { private String signature; private String time; private Integer timestamp; + + /** + * 对用户,如果是文件助手是filehelper + */ + private String toUser; /** * 类型 */ diff --git a/java_client/src/main/java/com/example/wxhk/model/request/OpenHook.java b/java_client/src/main/java/com/example/wxhk/model/request/OpenHook.java index 12929d0..62513a2 100644 --- a/java_client/src/main/java/com/example/wxhk/model/request/OpenHook.java +++ b/java_client/src/main/java/com/example/wxhk/model/request/OpenHook.java @@ -15,4 +15,17 @@ import lombok.experimental.Accessors; public class OpenHook implements SendMsg { String port; String ip; + /** + * 0/1 :1.启用http 0.不启用http + */ + boolean enableHttp; + /** + * 超时时间,单位ms + */ + String timeout; + + /** + * http的请求地址,enableHttp=1时,不能为空 + */ + String url; } diff --git a/java_client/src/main/java/com/example/wxhk/msg/WxMsgHandle.java b/java_client/src/main/java/com/example/wxhk/msg/WxMsgHandle.java index dbfc8aa..f6cf126 100644 --- a/java_client/src/main/java/com/example/wxhk/msg/WxMsgHandle.java +++ b/java_client/src/main/java/com/example/wxhk/msg/WxMsgHandle.java @@ -18,6 +18,7 @@ import org.w3c.dom.NodeList; import java.math.BigDecimal; import java.util.Iterator; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantReadWriteLock; @@ -50,7 +51,12 @@ public class WxMsgHandle { @PostConstruct public void init() { add(chatMsg -> { - wxSmgServer.私聊(chatMsg); + if(Objects.equals(chatMsg.getToUser(), FILEHELPER)){ + wxSmgServer.文件助手(chatMsg); + }else{ + wxSmgServer.私聊(chatMsg); + } + return null; }, WxMsgType.私聊信息); add(chatMsg -> { @@ -174,8 +180,8 @@ public class WxMsgHandle { if (monery.startsWith("¥")) { String substring = monery.substring(1); BigDecimal decimal = new BigDecimal(substring); - log.info("收款:{},付款人:{},付款备注:{}", decimal.stripTrailingZeros().toPlainString(), chatMsg.getFromUser(), remark); - wxSmgServer.收款之后(new PayoutInformation(chatMsg.getFromUser(), decimal, remark)); + log.info("收款:{},付款人:{},付款备注:{}", decimal.stripTrailingZeros().toPlainString(), receiver_username, remark); + wxSmgServer.收款之后(new PayoutInformation(receiver_username, decimal, remark)); return false; }; diff --git a/java_client/src/main/java/com/example/wxhk/server/impl/WxSmgServerImpl.java b/java_client/src/main/java/com/example/wxhk/server/impl/WxSmgServerImpl.java index 3bfebd9..b1c7cc3 100644 --- a/java_client/src/main/java/com/example/wxhk/server/impl/WxSmgServerImpl.java +++ b/java_client/src/main/java/com/example/wxhk/server/impl/WxSmgServerImpl.java @@ -32,12 +32,14 @@ public class WxSmgServerImpl implements com.example.wxhk.server.WxSmgServer { public void 私聊(PrivateChatMsg chatMsg) { if (Objects.equals(chatMsg.getIsSendMsg(), 1) && Objects.equals(chatMsg.getIsSendByPhone(), 1)) { log.info("手机端对:{}发出:{}", chatMsg.getFromUser(), chatMsg.getContent()); + }else{ + log.info("收到私聊{}",chatMsg); } } @Override public void 文件助手(PrivateChatMsg chatMsg) { - + log.info("文件助手:{}",chatMsg); } @Override diff --git a/java_client/src/main/java/com/example/wxhk/tcp/vertx/VertxTcp.java b/java_client/src/main/java/com/example/wxhk/tcp/vertx/VertxTcp.java index 069f603..5ba952b 100644 --- a/java_client/src/main/java/com/example/wxhk/tcp/vertx/VertxTcp.java +++ b/java_client/src/main/java/com/example/wxhk/tcp/vertx/VertxTcp.java @@ -2,7 +2,8 @@ package com.example.wxhk.tcp.vertx; import com.example.wxhk.WxhkApplication; import com.example.wxhk.constant.WxMsgType; -import com.example.wxhk.util.HttpAsyncUtil; +import com.example.wxhk.model.request.OpenHook; +import com.example.wxhk.util.HttpSendUtil; import io.vertx.core.AbstractVerticle; import io.vertx.core.DeploymentOptions; import io.vertx.core.Future; @@ -75,7 +76,10 @@ public class VertxTcp extends AbstractVerticle implements CommandLineRunner { listen.onComplete(event -> { boolean succeeded = event.succeeded(); if (succeeded) { - HttpAsyncUtil.exec(HttpAsyncUtil.Type.开启hook, new JsonObject().put("port", InitWeChat.getVertxPort().toString()).put("ip", "127.0.0.1")); + HttpSendUtil.开启hook(new OpenHook().setPort(InitWeChat.getVertxPort().toString()).setIp("127.0.0.1") + .setEnableHttp(false) + .setTimeout("5000")); + // HttpAsyncUtil.exec(HttpAsyncUtil.Type.开启hook, new JsonObject().put("port", InitWeChat.getVertxPort().toString()).put("ip", "127.0.0.1")); startPromise.complete(); } else { startPromise.fail(event.cause());