Parcourir la source

fix : 增加日志调试客服会话

bilingfeng il y a 1 an
Parent
commit
be31eba0e9

+ 89 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/CpCallServiceImpl.java

@@ -0,0 +1,89 @@
+package com.zanxiang.game.module.manage.service.impl;
+
+import com.zanxiang.module.util.JsonUtil;
+import org.springframework.web.client.RestTemplate;
+
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author : lingfeng
+ * @time : 2024-02-22
+ * @description : CP接口交互
+ */
+public class CpCallServiceImpl {
+
+    /**
+     * MD5加密
+     */
+    private static final String SIGN_MD5 = "MD5";
+
+//    public static void main(String[] args) throws Exception{
+//        test();
+//    }
+
+    public static void test() throws Exception {
+        RestTemplate restTemplate = new RestTemplate();
+
+        String url = "https://ht.lttx.t5yx.cn/extapi?action=BgzszhSendTip";
+
+        Map<String, Object> param = new HashMap<>();
+
+        String msgId = "testMsgId";
+        param.put("msgId", msgId);
+
+        String strRan = "strRan";
+        param.put("strRan", strRan);
+
+        Long time = 1708484041L;
+        param.put("time", time);
+
+        String signStr = "key=asd123&msgId=" + msgId + "&strRan=" + strRan + "&time=" + time;
+
+        System.out.println("加密字符串 : " + signStr);
+
+
+        param.put("sign", CpCallServiceImpl.MD5(signStr));
+
+        param.put("serverid", 226);
+        List<String> roleIds = new ArrayList<>();
+        roleIds.add("798136551028973749");
+        param.put("roleIds", roleIds);
+
+        param.put("pushType", 1);
+
+        Map<String, Object> msgContent = new HashMap<>();
+        msgContent.put("text", "测试消息");
+        List<String> imgs = new ArrayList<>();
+        imgs.add("https://t7.baidu.com/it/u=4162611394,4275913936&fm=193&f=GIF");
+        msgContent.put("imgs", JsonUtil.toString(imgs));
+        param.put("msgContent", msgContent);
+
+        System.out.println("接口参数 param :" + JsonUtil.toString(param));
+
+
+        String result = restTemplate.postForObject(url, JsonUtil.toString(param), String.class);
+
+        System.out.println("返回结果" + result);
+    }
+
+    /**
+     * MD5加密
+     *
+     * @param data 待处理数据
+     * @return MD5结果
+     */
+    public static String MD5(String data) throws Exception {
+        java.security.MessageDigest md = MessageDigest.getInstance(SIGN_MD5);
+        byte[] array = md.digest(data.getBytes(StandardCharsets.UTF_8));
+        StringBuilder sb = new StringBuilder();
+        for (byte item : array) {
+            sb.append(Integer.toHexString((item & 0xFF) | 0x100), 1, 3);
+        }
+        return sb.toString();
+    }
+}

+ 1 - 1
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/SDKApplication.java

@@ -23,7 +23,7 @@ public class SDKApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(SDKApplication.class, args);
-        System.out.println("赞象SDK服务启动成功 <渠道变更不上线时长更新为60天> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象SDK服务启动成功 <增加日志调试客服会话> ( ´・・)ノ(._.`) \n" +
                 " ___________ _   __\n" +
                 "/  ___|  _  \\ | / /\n" +
                 "\\ `--.| | | | |/ / \n" +

+ 3 - 0
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/GameAppletServiceImpl.java

@@ -109,6 +109,9 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
         }
         //消息内容
         AppletMsgDTO appletMsgDTO = JsonUtil.toObj(postData, AppletMsgDTO.class);
+
+        log.error("收到腾讯监听服务器内容, appletMsgDTO : {}", JsonUtil.toString(appletMsgDTO));
+
         //文本消息
         if (Objects.equals(appletMsgDTO.getMsgType(), AppletMsgDTO.MSG_TYPE_TEXT)) {
             //用户信息