Kaynağa Gözat

微信客服回调配置

wks 1 yıl önce
ebeveyn
işleme
119565d889

+ 2 - 0
src/main/java/com/ydtech/components/TokenInterceptor.java

@@ -83,6 +83,8 @@ public class TokenInterceptor {
         //企业微信绑定
         notMatchList.add("/wxWork/verifyBind");
         notMatchList.add("/wxWork/bind");
+        // 微信客服
+        notMatchList.add("/wechat/customer/callback");
 
         // 平安相关屏蔽地址
         notMatchList.add("/order/pingAnApi/getApplyVerifyCodeAndRecoverApplyVerifyCode");

+ 22 - 0
src/main/java/com/ydtech/config/properties/WechatCustomerProperties.java

@@ -0,0 +1,22 @@
+package com.ydtech.config.properties;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * @version
+ * @description: 企业微信客服接口
+ * @author: wenks
+ * @date: 2024/11/26 10:22
+ **/
+@Data
+@Component
+@ConfigurationProperties(prefix = "wechat.customer")
+public class WechatCustomerProperties {
+
+    private String token;
+
+    private String encodingAesKey;
+
+}

+ 10 - 1
src/main/java/com/ydtech/modules/admin/controller/WechatController.java

@@ -3,6 +3,7 @@ package com.ydtech.modules.admin.controller;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.exception.SystemException;
 import com.ydtech.modules.admin.model.vo.WechatBindVo;
+import com.ydtech.modules.admin.model.vo.WechatCustomerCallbackVo;
 import com.ydtech.modules.admin.model.vo.WechatLoginVo;
 import com.ydtech.modules.admin.model.vo.WechatVo;
 import com.ydtech.modules.admin.service.WechatService;
@@ -12,6 +13,7 @@ import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import me.chanjar.weixin.common.error.WxErrorException;
+import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -39,7 +41,7 @@ public class WechatController extends BaseController {
 
     @PostMapping("/bind")
     @ApiOperation(value = "工号绑定微信")
-    HttpResult<Object> bind(@RequestBody WechatBindVo wechatBindVo) throws WxErrorException {
+    public HttpResult<Object> bind(@RequestBody WechatBindVo wechatBindVo) throws WxErrorException {
         try {
             String userId = getUserId();
             return wechatService.bind(wechatBindVo, userId);
@@ -49,4 +51,11 @@ public class WechatController extends BaseController {
         }
     }
 
+    @PostMapping(path = "/customer/callback", consumes = MediaType.APPLICATION_XML_VALUE)
+    @ApiOperation(value = "客服回调")
+    HttpResult<String> customerCallback(@RequestBody WechatCustomerCallbackVo wechatCustomerCallbackVo) {
+        log.info(wechatCustomerCallbackVo.toString());
+        return null;
+    }
+
 }

+ 39 - 0
src/main/java/com/ydtech/modules/admin/model/vo/WechatCustomerCallbackVo.java

@@ -0,0 +1,39 @@
+package com.ydtech.modules.admin.model.vo;
+
+
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @description: 微信客服 回调实体
+ * @author: wenks
+ * @date: 2024/11/26 10:37
+ **/
+@AllArgsConstructor
+@NoArgsConstructor
+@Data
+@JacksonXmlRootElement(localName = "xml")
+public class WechatCustomerCallbackVo {
+
+    @JacksonXmlProperty(localName = "ToUserName")
+    private String toUserName;
+
+    @JacksonXmlProperty(localName = "CreateTime")
+    private String createTime;
+
+    @JacksonXmlProperty(localName = "MsgType")
+    private String msgType;
+
+    @JacksonXmlProperty(localName = "Event")
+    private String event;
+
+    @JacksonXmlProperty(localName = "Token")
+    private String token;
+
+    @JacksonXmlProperty(localName = "OpenKfId")
+    private String openKfId;
+
+}