Commit f6f7af3e by liushuangwu

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/com/pipihelper/project/scheduled/MassageNoticeScheduleService.java
2 parents 23aee837 3fd3867e
...@@ -126,16 +126,14 @@ public class FeiShuEventController { ...@@ -126,16 +126,14 @@ public class FeiShuEventController {
// 推迟 将当前用户放到队列最后 - 掉延迟更新卡片接口 更新大群、按摩群的按摩时间安排卡片 // 推迟 将当前用户放到队列最后 - 掉延迟更新卡片接口 更新大群、按摩群的按摩时间安排卡片
String waitUserId = feiShuMsgCardEventDTO.getOpen_id(); String waitUserId = feiShuMsgCardEventDTO.getOpen_id();
painService.waitPain(waitUserId); painService.waitPain(waitUserId);
//ToDo 没有按摩群的id //更新大群
massageService.updateMassageMsgCardToPiPiChat(feiShuConfig.getChatId()); massageService.updateMassageMsgCardToPiPiChat(feiShuConfig.getChatId());
//没有按摩群的id //更新按摩群
// massageService.updateMassageMsgCardToPiPiChat(); massageService.updateMassageMsgCardToPiPiChat((String) CacheUtil.get("chatId"));
String fileName1 = String.format("/templates/massage-singel-msg-card-end.json"); String fileName1 = String.format("/templates/massage-singel-msg-card-end.json");
return getInteractiveCardStr(fileName1, "已为你推迟到最后"); return getInteractiveCardStr(fileName1, "已为你推迟到最后");
} else if ("rob".equals(actionTypeSecond)) { } else if ("rob".equals(actionTypeSecond)) {
// 抢名额 - 掉延迟更新卡片接口 更新大群、按摩群的按摩时间安排卡片 // 抢名额 - 掉延迟更新卡片接口 更新大群、按摩群的按摩时间安排卡片
massageService.updateMassageMsgCardToPiPiChat(feiShuConfig.getChatId());
return rob(feiShuMsgCardEventDTO); return rob(feiShuMsgCardEventDTO);
} else if ("next".equals(actionTypeSecond)) { } else if ("next".equals(actionTypeSecond)) {
// 当前按完,有请下一位 // 当前按完,有请下一位
...@@ -149,6 +147,15 @@ public class FeiShuEventController { ...@@ -149,6 +147,15 @@ public class FeiShuEventController {
noticePain.setStatus(1); noticePain.setStatus(1);
painService.update(noticePain); painService.update(noticePain);
massageService.updateSingleMassageMsgCardWhenBegin(noticePain.getMessageId()); massageService.updateSingleMassageMsgCardWhenBegin(noticePain.getMessageId());
//按摩群中同步发送按摩进度信息
FeiShuMsgDTO feiShuMsgDTO = new FeiShuMsgDTO();
String msg = "当前按摩进度:" + String.format("<at user_id=\\\"%s\\\">%s</at>", noticePain.getOpenId(), noticePain.getName());
JSONObject content = new JSONObject();
content.put("text", msg);
feiShuMsgDTO.setMsgType("text");
feiShuMsgDTO.setContent(content.toString());
feiShuMsgDTO.setReceiveId((String) CacheUtil.get("chatId"));
feiShuApiService.sendMsg(feiShuMsgDTO, "chat_id");
} }
String fileName1 = String.format("/templates/massage-singel-msg-card-end.json"); String fileName1 = String.format("/templates/massage-singel-msg-card-end.json");
return getInteractiveCardStr(fileName1, "欢迎下次光临~"); return getInteractiveCardStr(fileName1, "欢迎下次光临~");
...@@ -168,7 +175,12 @@ public class FeiShuEventController { ...@@ -168,7 +175,12 @@ public class FeiShuEventController {
feiShuChatDTO.setChatId((String) CacheUtil.get("chatId")); feiShuChatDTO.setChatId((String) CacheUtil.get("chatId"));
feiShuChatDTO.setIdList(new String[]{feiShuMsgCardEventDTO.getOpen_id()}); feiShuChatDTO.setIdList(new String[]{feiShuMsgCardEventDTO.getOpen_id()});
feiShuApiService.joinChatList(feiShuChatDTO); feiShuApiService.joinChatList(feiShuChatDTO);
//ToDo 更新大群和按摩群的大卡片,异步 // 更新大群和按摩群的大卡片,异步
// 大群
massageService.updateMassageMsgCardToPiPiChat(feiShuConfig.getChatId());
//按摩群
massageService.updateMassageMsgCardToPiPiChat((String) CacheUtil.get("chatId"));
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, "已经被抢啦啦啦~"); return getInteractiveCardStr(fileName1, "已经被抢啦啦啦~");
} }
...@@ -313,9 +325,13 @@ public class FeiShuEventController { ...@@ -313,9 +325,13 @@ public class FeiShuEventController {
@PostMapping("/start") @PostMapping("/start")
public Result start() { public Result start() {
List<Pain> pains = painService.findListAsc(3); List<Pain> pains = painService.findListAsc(3);
StringBuilder userString = new StringBuilder();
for (Pain pain : pains) { for (Pain pain : pains) {
String messageId = pain.getMessageId(); String messageId = pain.getMessageId();
massageService.updateSingleMassageMsgCardWhenBegin(messageId); massageService.updateSingleMassageMsgCardWhenBegin(messageId);
userString.append(String.format("<at user_id=\\\"%s\\\">%s</at>", pain.getOpenId(), pain.getName()));
//1代表正在按 //1代表正在按
pain.setStatus(1); pain.setStatus(1);
painService.update(pain); painService.update(pain);
...@@ -325,6 +341,30 @@ public class FeiShuEventController { ...@@ -325,6 +341,30 @@ public class FeiShuEventController {
log.info("发送应用内容消息提醒"); log.info("发送应用内容消息提醒");
feiShuApiService.patchUrgentApp(messageId, noticeMsg); feiShuApiService.patchUrgentApp(messageId, noticeMsg);
} }
//按摩群中同步发送按摩进度信息
FeiShuMsgDTO feiShuMsgDTO = new FeiShuMsgDTO();
String msg = "当前按摩进度:" + userString;
JSONObject content = new JSONObject();
content.put("text", msg);
feiShuMsgDTO.setMsgType("text");
feiShuMsgDTO.setContent(content.toString());
feiShuMsgDTO.setReceiveId((String) CacheUtil.get("chatId"));
feiShuApiService.sendMsg(feiShuMsgDTO, "chat_id");
return ResultGenerator.genSuccessResult();
}
@PostMapping("/send-msg")
public Result sendMsg(String receiveId, String msg, String receiveIdType){
FeiShuMsgDTO feiShuMsgDTO = new FeiShuMsgDTO();
JSONObject content = new JSONObject();
content.put("text", msg);
feiShuMsgDTO.setMsgType("text");
feiShuMsgDTO.setContent(content.toString());
if(receiveId.equals("-1")){
receiveId = (String) CacheUtil.get("chatId");
}
feiShuMsgDTO.setReceiveId(receiveId);
feiShuApiService.sendMsg(feiShuMsgDTO, receiveIdType);
return ResultGenerator.genSuccessResult(); return ResultGenerator.genSuccessResult();
} }
......
...@@ -156,7 +156,7 @@ public class FeiShuApiService { ...@@ -156,7 +156,7 @@ public class FeiShuApiService {
@Async @Async
public JSONObject patchUrgentApp(String message_id, JSONObject content) { public JSONObject patchUrgentApp(String message_id, JSONObject content) {
String api = "/im/v1/messages/" + message_id + "/urgent_sms?user_id_type=user_id"; String api = "/im/v1/messages/" + message_id + "/urgent_app?user_id_type=open_id";
OkHttpClient client = new OkHttpClient(); OkHttpClient client = new OkHttpClient();
String url = feiShuConfig.getFeiShuOpenApiHost() + api; String url = feiShuConfig.getFeiShuOpenApiHost() + api;
RequestBody requestBody = RequestBody.create(content.toString(), MediaType.parse("application/json")); RequestBody requestBody = RequestBody.create(content.toString(), MediaType.parse("application/json"));
...@@ -180,7 +180,7 @@ public class FeiShuApiService { ...@@ -180,7 +180,7 @@ public class FeiShuApiService {
@Async @Async
public JSONObject patchUrgentSms(String message_id, JSONObject content) { public JSONObject patchUrgentSms(String message_id, JSONObject content) {
String api = "/im/v1/messages/" + message_id + "/urgent_app?user_id_type=open_id"; String api = "/im/v1/messages/" + message_id + "/urgent_sms?user_id_type=user_id";
OkHttpClient client = new OkHttpClient(); OkHttpClient client = new OkHttpClient();
String url = feiShuConfig.getFeiShuOpenApiHost() + api; String url = feiShuConfig.getFeiShuOpenApiHost() + api;
RequestBody requestBody = RequestBody.create(content.toString(), MediaType.parse("application/json")); RequestBody requestBody = RequestBody.create(content.toString(), MediaType.parse("application/json"));
......
...@@ -47,20 +47,22 @@ public class MassageService { ...@@ -47,20 +47,22 @@ 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())){
String singleContent = massageMsgCardSerivce.genMassageMsgCardForSingle(); //给单个用户发送
log.info("给单个用户发送按摩消息:{}", singleContent); String singleContent = massageMsgCardSerivce.genMassageMsgCardForSingle();
FeiShuMsgDTO feiShuMsgDTO = new FeiShuMsgDTO(); log.info("给单个用户发送按摩消息:{}", singleContent);
feiShuMsgDTO.setMsgType("interactive"); FeiShuMsgDTO feiShuMsgDTO = new FeiShuMsgDTO();
feiShuMsgDTO.setContent(singleContent); feiShuMsgDTO.setMsgType("interactive");
feiShuMsgDTO.setReceiveId(pushPainBO.getOpenId()); feiShuMsgDTO.setContent(singleContent);
log.info(feiShuMsgDTO.toString()); feiShuMsgDTO.setReceiveId(pushPainBO.getOpenId());
JSONObject sendMsgResponse = feiShuApiService.sendMsg(feiShuMsgDTO, "open_id"); log.info(feiShuMsgDTO.toString());
String messageId = sendMsgResponse.getJSONObject("data").getString("message_id"); JSONObject sendMsgResponse = feiShuApiService.sendMsg(feiShuMsgDTO, "open_id");
//更新按摩记录表中的messageId String messageId = sendMsgResponse.getJSONObject("data").getString("message_id");
Pain pain = painService.findByOpenId(pushPainBO.getOpenId()); //更新按摩记录表中的messageId
pain.setMessageId(messageId); Pain pain = painService.findByOpenId(pushPainBO.getOpenId());
painService.update(pain); pain.setMessageId(messageId);
painService.update(pain);
}
//构建给大群发送的名单 //构建给大群发送的名单
user.add(pushPainBO.getIndex().toString()); user.add(pushPainBO.getIndex().toString());
user.add(pushPainBO.getName()); user.add(pushPainBO.getName());
......
...@@ -16,6 +16,7 @@ import com.pipihelper.project.feishu.service.FeiShuApiService; ...@@ -16,6 +16,7 @@ import com.pipihelper.project.feishu.service.FeiShuApiService;
import com.pipihelper.project.feishu.service.LastMaxPainService; import com.pipihelper.project.feishu.service.LastMaxPainService;
import com.pipihelper.project.feishu.service.PainService; import com.pipihelper.project.feishu.service.PainService;
import com.pipihelper.project.feishu.service.massage.MassageService; import com.pipihelper.project.feishu.service.massage.MassageService;
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;
...@@ -157,43 +158,34 @@ public class MassageNoticeScheduleService { ...@@ -157,43 +158,34 @@ public class MassageNoticeScheduleService {
*/ */
// @Async // @Async
// @Scheduled(cron = "0 0 10 * * ?") // @Scheduled(cron = "0 0 10 * * ?")
public void massageStart() { public void massageStart(){
List<Pain> pains = painService.findListAsc(3); List<Pain> pains = painService.findListAsc(3);
for (Pain pain : pains) { // String msg = "{\"text\":\"当前按摩进度:<at user_id=\\\"%s\\\">%s</at> <at user_id=\\\"%s\\\">%s</at> <at user_id=\\\"%s\\\">%s</at>\"}";
StringBuilder userString = new StringBuilder();
for(Pain pain:pains){
String messageId = pain.getMessageId(); String messageId = pain.getMessageId();
massageService.updateSingleMassageMsgCardWhenBegin(messageId); massageService.updateSingleMassageMsgCardWhenBegin(messageId);
userString.append(String.format("<at user_id=\\\"%s\\\">%s</at>", pain.getOpenId(), pain.getName()));
//1代表正在按 //1代表正在按
pain.setStatus(1); pain.setStatus(1);
painService.update(pain); painService.update(pain);
//发送应用内提醒
JSONObject noticeMsg = new JSONObject(); JSONObject noticeMsg = new JSONObject();
noticeMsg.put("user_id_list", Arrays.asList(pain.getOpenId())); noticeMsg.put("user_id_list", Arrays.asList(pain.getOpenId()));
//发送应用内提醒
log.info("发送应用内容消息提醒"); log.info("发送应用内容消息提醒");
feiShuApiService.patchUrgentApp(messageId, noticeMsg); feiShuApiService.patchUrgentApp(messageId, noticeMsg);
} }
//按摩群中同步发送按摩进度信息
FeiShuMsgDTO feiShuMsgDTO = new FeiShuMsgDTO();
String msg = "当前按摩进度:" + userString;
JSONObject content = new JSONObject();
content.put("text", msg);
feiShuMsgDTO.setMsgType("text");
feiShuMsgDTO.setContent(content.toString());
feiShuMsgDTO.setReceiveId((String) CacheUtil.get("chatId"));
feiShuApiService.sendMsg(feiShuMsgDTO, "chat_id");
} }
// /**
// * 当天时间2:55,给第一波三个人更新卡片,并发送应用内提醒
// */
// @Async
// @Scheduled(cron = "0 0 10 * * ?")
// public void massageStart(){
// List<Pain> pains = painService.findListAsc(3);
// for(Pain pain:pains){
// String messageId = pain.getMessageId();
// massageService.updateSingleMassageMsgCardWhenBegin(messageId);
// //1代表正在按
// pain.setStatus(1);
// painService.update(pain);
// JSONObject noticeMsg = new JSONObject();
// noticeMsg.put("user_id_list", Arrays.asList(pain.getOpenId()));
// //发送应用内提醒
// log.info("发送应用内容消息提醒");
// feiShuApiService.patchUrgentApp(messageId, noticeMsg);
// }
//
// }
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
{ {
"tag": "div", "tag": "div",
"text": { "text": {
"content": "已经被抢啦啦啦~", "content": "已抢完~",
"tag": "lark_md" "tag": "lark_md"
} }
} }
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
"header": { "header": {
"template": "turquoise", "template": "turquoise",
"title": { "title": {
"content": "👻 按摩提醒请查收!", "content": "👻 有按摩名额空余啦!",
"tag": "plain_text" "tag": "plain_text"
} }
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
{ {
"tag": "div", "tag": "div",
"text": { "text": {
"content": "当前空余一个名额", "content": "有人怕疼放弃了,快来抢吧!",
"tag": "lark_md" "tag": "lark_md"
} }
}, },
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
{ {
"tag": "button", "tag": "button",
"text": { "text": {
"content": "😁 我", "content": "😁 我不怕",
"tag": "plain_text" "tag": "plain_text"
}, },
"type": "default", "type": "default",
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
"header": { "header": {
"template": "turquoise", "template": "turquoise",
"title": { "title": {
"content": "👻 按摩提醒请查收!", "content": "👻 有按摩名额空余啦!",
"tag": "plain_text" "tag": "plain_text"
} }
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
{ {
"tag": "div", "tag": "div",
"text": { "text": {
"content": "欢呼吧,你排到了按摩哦!", "content": "欢呼吧,你本周有按摩名额哦!",
"tag": "lark_md" "tag": "lark_md"
} }
}, },
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
{ {
"tag": "button", "tag": "button",
"text": { "text": {
"content": "😢 等一下", "content": "😢 我最后来",
"tag": "plain_text" "tag": "plain_text"
}, },
"type": "default", "type": "default",
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
{ {
"tag": "div", "tag": "div",
"text": { "text": {
"content": "欢呼吧,你排到了按摩哦!", "content": "按摩到你了哦!",
"tag": "lark_md" "tag": "lark_md"
} }
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!