Commit 3a35fbaf by zhaolianjie

卡片流程 - 删除群组

1 parent 8f4a428a
...@@ -178,45 +178,13 @@ public class FeiShuEventController { ...@@ -178,45 +178,13 @@ public class FeiShuEventController {
String oldUserId = feiShuMsgCardEventDTO.getAction().getValue().getKey().split("\\.")[2]; String oldUserId = feiShuMsgCardEventDTO.getAction().getValue().getKey().split("\\.")[2];
String robUserId = feiShuMsgCardEventDTO.getOpen_id(); String robUserId = feiShuMsgCardEventDTO.getOpen_id();
Employee employee = employeeService.findByOpenId(robUserId); Employee employee = employeeService.findByOpenId(robUserId);
Pain oldPain = painService.findByOpenId(oldUserId);
if (oldPain == null) {
String fileName1 = String.format("/templates/massage-msg-card-rob-end.json");
return getInteractiveCardStr(fileName1, "已经被" + employee.getName() + "抢啦,啦啦~");
}
oldPain.setOpenId(robUserId);
oldPain.setName(employee.getName());
painService.update(oldPain);
FeiShuChatDTO feiShuChatDTO = new FeiShuChatDTO();
feiShuChatDTO.setChatId((String) CacheUtil.get("chatId"));
feiShuChatDTO.setIdList(new String[]{feiShuMsgCardEventDTO.getOpen_id()});
feiShuApiService.joinChatList(feiShuChatDTO);
sendSingle(robUserId);
// 更新大群和按摩群的大卡片,异步
// 大群
massageService.updateMassageMsgCardToPiPiChat(feiShuConfig.getChatId());
//按摩群
massageService.updateMassageMsgCardToPiPiChat((String) CacheUtil.get("chatId"));
massageService.robSingle(robUserId,oldUserId,employee.getName());
String fileName1 = String.format("/templates/massage-msg-card-rob-end.json"); String fileName1 = String.format("/templates/massage-msg-card-rob-end.json");
return getInteractiveCardStr(fileName1, "已经被" + employee.getName() + "抢啦,啦啦~"); return getInteractiveCardStr(fileName1, "已经被" + employee.getName() + "抢啦,啦啦~");
} }
private void sendSingle(String openId){
//给单个用户发送
String singleContent = massageMsgCardSerivce.genMassageMsgCardForSingle();
log.info("给单个用户发送按摩消息:{}", singleContent);
FeiShuMsgDTO feiShuMsgDTO = new FeiShuMsgDTO();
feiShuMsgDTO.setMsgType("interactive");
feiShuMsgDTO.setContent(singleContent);
feiShuMsgDTO.setReceiveId(openId);
log.info(feiShuMsgDTO.toString());
JSONObject sendMsgResponse = feiShuApiService.sendMsg(feiShuMsgDTO, "open_id");
String messageId = sendMsgResponse.getJSONObject("data").getString("message_id");
//更新按摩记录表中的messageId
Pain pain = painService.findByOpenId(openId);
pain.setMessageId(messageId);
painService.update(pain);
}
/** /**
* 读取模板文件 * 读取模板文件
* *
......
...@@ -432,7 +432,7 @@ public class FeiShuApiService { ...@@ -432,7 +432,7 @@ public class FeiShuApiService {
throw new ServiceException("飞书:" + api + "接口调用失败" + "\n" + e); throw new ServiceException("飞书:" + api + "接口调用失败" + "\n" + e);
} }
} }
@Async
public String joinChatList(FeiShuChatDTO feiShuChatDTO) { public String joinChatList(FeiShuChatDTO feiShuChatDTO) {
String api = "/im/v1/chats/{chat_id}/members"; String api = "/im/v1/chats/{chat_id}/members";
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
......
...@@ -3,12 +3,14 @@ package com.pipihelper.project.feishu.service.massage; ...@@ -3,12 +3,14 @@ package com.pipihelper.project.feishu.service.massage;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.pipihelper.project.feishu.bo.PushPainBO; import com.pipihelper.project.feishu.bo.PushPainBO;
import com.pipihelper.project.feishu.dto.FeiShuConfig; import com.pipihelper.project.feishu.dto.FeiShuConfig;
import com.pipihelper.project.feishu.dto.chat.FeiShuChatDTO;
import com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO; import com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO;
import com.pipihelper.project.feishu.entity.ChatMessage; import com.pipihelper.project.feishu.entity.ChatMessage;
import com.pipihelper.project.feishu.entity.Pain; import com.pipihelper.project.feishu.entity.Pain;
import com.pipihelper.project.feishu.service.ChatMessageService; import com.pipihelper.project.feishu.service.ChatMessageService;
import com.pipihelper.project.feishu.service.FeiShuApiService; import com.pipihelper.project.feishu.service.FeiShuApiService;
import com.pipihelper.project.feishu.service.PainService; import com.pipihelper.project.feishu.service.PainService;
import com.pipihelper.project.utils.CacheUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
...@@ -47,7 +49,7 @@ public class MassageService { ...@@ -47,7 +49,7 @@ public class MassageService {
List<List<String>> pushUser = new ArrayList<>(); List<List<String>> pushUser = new ArrayList<>();
for (PushPainBO pushPainBO : pushPainBOList) { for (PushPainBO pushPainBO : pushPainBOList) {
List<String> user = new ArrayList<>(); List<String> user = new ArrayList<>();
if(chatId.equals(feiShuConfig.getChatId())){ if (chatId.equals(feiShuConfig.getChatId())) {
//给单个用户发送 //给单个用户发送
String singleContent = massageMsgCardSerivce.genMassageMsgCardForSingle(); String singleContent = massageMsgCardSerivce.genMassageMsgCardForSingle();
log.info("给单个用户发送按摩消息:{}", singleContent); log.info("给单个用户发送按摩消息:{}", singleContent);
...@@ -122,5 +124,42 @@ public class MassageService { ...@@ -122,5 +124,42 @@ public class MassageService {
feiShuApiService.patchMsg(messageId, patchMsg); feiShuApiService.patchMsg(messageId, patchMsg);
} }
@Async
public void robSingle(String robUserId, String oldUserId, String name) {
Pain oldPain = painService.findByOpenId(oldUserId);
oldPain.setOpenId(robUserId);
oldPain.setName(name);
painService.update(oldPain);
FeiShuChatDTO feiShuChatDTO = new FeiShuChatDTO();
feiShuChatDTO.setChatId((String) CacheUtil.get("chatId"));
feiShuChatDTO.setIdList(new String[]{robUserId});
feiShuApiService.joinChatList(feiShuChatDTO);
sendSingle(robUserId);
// 更新大群和按摩群的大卡片,异步
// 大群
updateMassageMsgCardToPiPiChat(feiShuConfig.getChatId());
//按摩群
updateMassageMsgCardToPiPiChat((String) CacheUtil.get("chatId"));
}
public void sendSingle(String openId) {
//给单个用户发送
String singleContent = massageMsgCardSerivce.genMassageMsgCardForSingle();
log.info("给单个用户发送按摩消息:{}", singleContent);
FeiShuMsgDTO feiShuMsgDTO = new FeiShuMsgDTO();
feiShuMsgDTO.setMsgType("interactive");
feiShuMsgDTO.setContent(singleContent);
feiShuMsgDTO.setReceiveId(openId);
log.info(feiShuMsgDTO.toString());
JSONObject sendMsgResponse = feiShuApiService.sendMsg(feiShuMsgDTO, "open_id");
String messageId = sendMsgResponse.getJSONObject("data").getString("message_id");
//更新按摩记录表中的messageId
Pain pain = painService.findByOpenId(openId);
pain.setMessageId(messageId);
painService.update(pain);
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!