|
|
@@ -3,23 +3,24 @@ package com.ydtech.modules.admin.service.impl;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
|
|
import com.ydtech.modules.admin.components.WechatCustomerComponents;
|
|
|
+import com.ydtech.modules.admin.components.wechat.customer.request.CustomerAddContactWayRequest;
|
|
|
+import com.ydtech.modules.admin.components.wechat.customer.request.CustomerListRequest;
|
|
|
import com.ydtech.modules.admin.components.wechat.customer.request.CustomerSendMsgOnEventRequest;
|
|
|
import com.ydtech.modules.admin.components.wechat.customer.request.CustomerSyncMsgRequest;
|
|
|
+import com.ydtech.modules.admin.components.wechat.customer.response.CustomerAddContactWayResponse;
|
|
|
+import com.ydtech.modules.admin.components.wechat.customer.response.CustomerListResponse;
|
|
|
import com.ydtech.modules.admin.components.wechat.customer.response.CustomerSyncMsgResponse;
|
|
|
-import com.ydtech.modules.admin.model.SysDept;
|
|
|
import com.ydtech.modules.admin.model.SysUser;
|
|
|
import com.ydtech.modules.admin.model.vo.wechat.WechatCustomerCallbackVo;
|
|
|
import com.ydtech.modules.admin.model.vo.wechat.WechatEncryptVo;
|
|
|
-import com.ydtech.modules.admin.service.SysDeptService;
|
|
|
import com.ydtech.modules.admin.service.SysUserService;
|
|
|
import com.ydtech.modules.admin.service.WechatCustomerService;
|
|
|
import com.ydtech.utils.StringUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import me.chanjar.weixin.common.util.crypto.WxCryptUtil;
|
|
|
-import me.chanjar.weixin.cp.bean.kf.WxCpKfMsgListResp;
|
|
|
-import me.chanjar.weixin.cp.bean.kf.WxCpKfMsgSendRequest;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -32,7 +33,7 @@ public class WechatCustomerServiceImpl implements WechatCustomerService {
|
|
|
|
|
|
private final SysUserService sysUserService;
|
|
|
|
|
|
- private final XmlMapper xmlMapper;
|
|
|
+ private final XmlMapper xmlMapper = new XmlMapper();
|
|
|
|
|
|
@Override
|
|
|
public String customerCallback(String msgSignature, String timestamp, String nonce, String echoStr) {
|
|
|
@@ -59,14 +60,30 @@ public class WechatCustomerServiceImpl implements WechatCustomerService {
|
|
|
CustomerSyncMsgResponse.MsgListDTO msgListDTO = customerSyncMsgResponse.getMsgList().get(msgList.size() - 1);
|
|
|
|
|
|
CustomerSyncMsgResponse.MsgListDTO.EventDTO event = msgListDTO.getEvent();
|
|
|
+ if(ObjectUtils.isEmpty(event)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
String sceneParam = event.getSceneParam();
|
|
|
if (StringUtils.isEmpty(sceneParam)) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
SysUser sysUser = sysUserService.getById(sceneParam);
|
|
|
- CustomerSendMsgOnEventRequest customerSendMsgOnEventRequest = CustomerSendMsgOnEventRequest.sendMsgOnEvent(sysUser, msgListDTO.getMsgid(),event.getWelcomeCode());
|
|
|
+ CustomerSendMsgOnEventRequest customerSendMsgOnEventRequest = CustomerSendMsgOnEventRequest.sendMsgOnEvent(sysUser, msgListDTO.getMsgid(), event.getWelcomeCode());
|
|
|
wechatCustomerComponents.sendMsgOnEvent(customerSendMsgOnEventRequest);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<CustomerListResponse.AccountListDTO> list() {
|
|
|
+ CustomerListRequest customerListResponse = new CustomerListRequest(0, 100);
|
|
|
+ return wechatCustomerComponents.list(customerListResponse).getAccountList();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String addContactWay(String openKfId) {
|
|
|
+ CustomerAddContactWayRequest customerAddContactWayRequest = new CustomerAddContactWayRequest(openKfId, "WELCOME_MESSAGE");
|
|
|
+ CustomerAddContactWayResponse customerAddContactWayResponse = wechatCustomerComponents.addContactWay(customerAddContactWayRequest);
|
|
|
+ return customerAddContactWayResponse.getUrl();
|
|
|
+ }
|
|
|
+
|
|
|
}
|