|
|
@@ -1,17 +1,22 @@
|
|
|
package com.tzld.piaoquan.api.service.wecom.thirdparty.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.tzld.piaoquan.api.common.enums.wecom.WeComThirdPartyCallBackTypeEnum;
|
|
|
import com.tzld.piaoquan.api.component.WeComThirdPartyApiClient;
|
|
|
-import com.tzld.piaoquan.api.dao.mapper.wecom.thirdpart.ThirdPartWeComCorpMapper;
|
|
|
-import com.tzld.piaoquan.api.dao.mapper.wecom.thirdpart.ThirdPartWeComRoomMapper;
|
|
|
-import com.tzld.piaoquan.api.dao.mapper.wecom.thirdpart.ThirdPartWeComStaffMapper;
|
|
|
+import com.tzld.piaoquan.api.model.param.wecom.thirdpart.UuidRequest;
|
|
|
import com.tzld.piaoquan.api.model.param.wecom.thirdpart.WeComThirdPartyCallBackParam;
|
|
|
+import com.tzld.piaoquan.api.model.po.wecom.thirdpart.ThirdPartWeComStaff;
|
|
|
import com.tzld.piaoquan.api.service.wecom.thirdparty.WeComThirdPartyCallBackService;
|
|
|
+import com.tzld.piaoquan.api.service.wecom.thirdparty.WeComThirdPartyService;
|
|
|
+import com.tzld.piaoquan.growth.common.utils.LarkRobotUtil;
|
|
|
import com.tzld.piaoquan.growth.common.utils.RedisUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class WeComThirdPartyCallBackServiceImpl implements WeComThirdPartyCallBackService {
|
|
|
@@ -19,11 +24,7 @@ public class WeComThirdPartyCallBackServiceImpl implements WeComThirdPartyCallBa
|
|
|
@Autowired
|
|
|
private WeComThirdPartyApiClient apiClient;
|
|
|
@Autowired
|
|
|
- private ThirdPartWeComStaffMapper thirdPartWeComStaffMapper;
|
|
|
- @Autowired
|
|
|
- private ThirdPartWeComRoomMapper thirdPartWeComRoomMapper;
|
|
|
- @Autowired
|
|
|
- private ThirdPartWeComCorpMapper thirdPartWeComCorpMapper;
|
|
|
+ private WeComThirdPartyService weComThirdPartyService;
|
|
|
|
|
|
@Autowired
|
|
|
private RedisUtils redisUtils;
|
|
|
@@ -31,5 +32,48 @@ public class WeComThirdPartyCallBackServiceImpl implements WeComThirdPartyCallBa
|
|
|
@Override
|
|
|
public void handleCallback(WeComThirdPartyCallBackParam param) {
|
|
|
log.info("handleCallback param: {}", JSONObject.toJSONString(param));
|
|
|
+ WeComThirdPartyCallBackTypeEnum typeEnum = WeComThirdPartyCallBackTypeEnum.from(param.getType());
|
|
|
+ if (typeEnum == WeComThirdPartyCallBackTypeEnum.other) {
|
|
|
+ log.info("三方平台企微回调类型未处理:type={}, json={}", param.getType(), param.getJson());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ handle(param, typeEnum);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void handle(WeComThirdPartyCallBackParam param, WeComThirdPartyCallBackTypeEnum typeEnum) {
|
|
|
+ if (typeEnum == WeComThirdPartyCallBackTypeEnum.LOGIN_SUCCESS) {
|
|
|
+ weComThirdPartyService.getRunClientByUuid(new UuidRequest(param.getUuid()));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (typeEnum == WeComThirdPartyCallBackTypeEnum.NEED_VERIFY_CODE) {
|
|
|
+ String needVerifyCode = "needVerifyCode:uuid:" + param.getUuid();
|
|
|
+ redisUtils.set(needVerifyCode, "1", 120);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONObject json = JSONObject.parseObject(param.getJson());
|
|
|
+ List<Integer> disconnectCallBackTypes = getDisconnectCallBackTypes();
|
|
|
+ if (disconnectCallBackTypes.contains(typeEnum.getVal())) {
|
|
|
+ ThirdPartWeComStaff staff = weComThirdPartyService.getStaffByUuid(param.getUuid());
|
|
|
+ if (staff == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ LarkRobotUtil.sendWeComThirdPartMessage(
|
|
|
+ "【账号掉线回调通知】\n" +
|
|
|
+ "账号名称:" + staff.getName() + "\n" +
|
|
|
+ "账号VID:" + staff.getThirdStaffId() + "\n" +
|
|
|
+ "账号UUID:" + staff.getThirdUuid() + "\n" +
|
|
|
+ "回调信息:" + json.toJSONString());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Integer> getDisconnectCallBackTypes() {
|
|
|
+ List<Integer> result = new ArrayList<>();
|
|
|
+ result.add(WeComThirdPartyCallBackTypeEnum.SECOND_VERIFY_NOTIFY.getVal());
|
|
|
+ result.add(WeComThirdPartyCallBackTypeEnum.LOGIN_END.getVal());
|
|
|
+ result.add(WeComThirdPartyCallBackTypeEnum.OTHER_DEVICE_LOGIN.getVal());
|
|
|
+ result.add(WeComThirdPartyCallBackTypeEnum.QR_CODE_SCAN_TIMEOUT.getVal());
|
|
|
+ result.add(WeComThirdPartyCallBackTypeEnum.EXCEPTION_DISCONNECT.getVal());
|
|
|
+ return result;
|
|
|
}
|
|
|
}
|