Commit 4775603b by weiss

1

1 parent f24b5258
package com.pipihelper.project.feishu.controller; package com.pipihelper.project.feishu.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -23,7 +22,6 @@ import com.pipihelper.project.feishu.service.massage.MassageMsgCardSerivce; ...@@ -23,7 +22,6 @@ import com.pipihelper.project.feishu.service.massage.MassageMsgCardSerivce;
import com.pipihelper.project.feishu.service.massage.MassageService; import com.pipihelper.project.feishu.service.massage.MassageService;
import com.pipihelper.project.feishu.utils.FeiShuEventDataDecrypter; import com.pipihelper.project.feishu.utils.FeiShuEventDataDecrypter;
import com.pipihelper.project.utils.CacheUtil; import com.pipihelper.project.utils.CacheUtil;
import jdk.nashorn.internal.ir.CatchNode;
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.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -108,7 +106,7 @@ public class FeiShuEventController { ...@@ -108,7 +106,7 @@ public class FeiShuEventController {
// 都需要返回 不能点击的卡片json // 都需要返回 不能点击的卡片json
if ("revice".equals(actionTypeSecond)) { if ("revice".equals(actionTypeSecond)) {
// 接受按摩 // 接受按摩
String fileName = String.format("/templates/massage-singel-msg-card-end.json.json"); String fileName = String.format("/templates/massage-singel-msg-card-end.json");
return getInteractiveCardStr(fileName, "感谢支持"); return getInteractiveCardStr(fileName, "感谢支持");
} else if ("giveUp".equals(actionTypeSecond)) { } else if ("giveUp".equals(actionTypeSecond)) {
...@@ -116,11 +114,11 @@ public class FeiShuEventController { ...@@ -116,11 +114,11 @@ public class FeiShuEventController {
FeiShuMsgDTO feiShuMsgDTO = new FeiShuMsgDTO(); FeiShuMsgDTO feiShuMsgDTO = new FeiShuMsgDTO();
feiShuMsgDTO.setMsgType("interactive"); feiShuMsgDTO.setMsgType("interactive");
feiShuMsgDTO.setReceiveId(feiShuConfig.getChatId()); feiShuMsgDTO.setReceiveId(feiShuConfig.getChatId());
String fileName = String.format("/templates/massage-msg-card-rob.json.json"); String fileName = String.format("/templates/massage-msg-card-rob.json");
String msgCardContent = String.format(massageMsgCardSerivce.getInteractiveCardStr(fileName), feiShuMsgCardEventDTO.getOpen_id()); String msgCardContent = String.format(massageMsgCardSerivce.getInteractiveCardStr(fileName), feiShuMsgCardEventDTO.getOpen_id());
feiShuMsgDTO.setContent(msgCardContent); feiShuMsgDTO.setContent(msgCardContent);
feiShuApiService.sendMsg(feiShuMsgDTO, "chat_id"); feiShuApiService.sendMsg(feiShuMsgDTO, "chat_id");
String fileName1 = String.format("/templates/massage-singel-msg-card-end.json.json"); String fileName1 = String.format("/templates/massage-singel-msg-card-end.json");
return getInteractiveCardStr(fileName1, "遗憾放弃"); return getInteractiveCardStr(fileName1, "遗憾放弃");
} else if ("wait".equals(actionTypeSecond)) { } else if ("wait".equals(actionTypeSecond)) {
...@@ -131,7 +129,7 @@ public class FeiShuEventController { ...@@ -131,7 +129,7 @@ public class FeiShuEventController {
massageService.updateMassageMsgCardToPiPiChat(feiShuConfig.getChatId()); massageService.updateMassageMsgCardToPiPiChat(feiShuConfig.getChatId());
//没有按摩群的id //没有按摩群的id
// massageService.updateMassageMsgCardToPiPiChat(); // massageService.updateMassageMsgCardToPiPiChat();
String fileName1 = String.format("/templates/massage-singel-msg-card-end.json.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)) {
// 抢名额 - 掉延迟更新卡片接口 更新大群、按摩群的按摩时间安排卡片 // 抢名额 - 掉延迟更新卡片接口 更新大群、按摩群的按摩时间安排卡片
...@@ -144,14 +142,14 @@ public class FeiShuEventController { ...@@ -144,14 +142,14 @@ public class FeiShuEventController {
Pain oldPain = painService.findByOpenId(endUserId); Pain oldPain = painService.findByOpenId(endUserId);
oldPain.setStatus(2); oldPain.setStatus(2);
painService.update(oldPain); painService.update(oldPain);
List<Pain> painList = painService.findBackIndex(oldPain.getIndex(), 1); List<Pain> painList = painService.findBackIndex(oldPain.getPindex(), 1);
if (CollectionUtil.isNotEmpty(painList)) { if (CollectionUtil.isNotEmpty(painList)) {
Pain noticePain = CollectionUtil.getFirst(painList); Pain noticePain = CollectionUtil.getFirst(painList);
noticePain.setStatus(1); noticePain.setStatus(1);
painService.update(noticePain); painService.update(noticePain);
massageService.updateSingleMassageMsgCardWhenBegin(noticePain.getMessageId()); massageService.updateSingleMassageMsgCardWhenBegin(noticePain.getMessageId());
} }
String fileName1 = String.format("/templates/massage-singel-msg-card-end.json.json"); String fileName1 = String.format("/templates/massage-singel-msg-card-end.json");
return getInteractiveCardStr(fileName1, "欢迎下次光临~"); return getInteractiveCardStr(fileName1, "欢迎下次光临~");
} }
default: default:
...@@ -170,7 +168,7 @@ public class FeiShuEventController { ...@@ -170,7 +168,7 @@ public class FeiShuEventController {
feiShuChatDTO.setIdList(new String[]{feiShuMsgCardEventDTO.getOpen_id()}); feiShuChatDTO.setIdList(new String[]{feiShuMsgCardEventDTO.getOpen_id()});
feiShuApiService.joinChatList(feiShuChatDTO); feiShuApiService.joinChatList(feiShuChatDTO);
//ToDo 更新大群和按摩群的大卡片,异步 //ToDo 更新大群和按摩群的大卡片,异步
String fileName1 = String.format("/templates/massage-msg-card-rob-end.json.json.json"); String fileName1 = String.format("/templates/massage-msg-card-rob-end.json");
return getInteractiveCardStr(fileName1, "已经被抢啦啦啦~"); return getInteractiveCardStr(fileName1, "已经被抢啦啦啦~");
} }
...@@ -237,7 +235,7 @@ public class FeiShuEventController { ...@@ -237,7 +235,7 @@ public class FeiShuEventController {
pain.setStatus(0); pain.setStatus(0);
pain.setFloor(Optional.ofNullable(it.getFloor()).orElse(14)); pain.setFloor(Optional.ofNullable(it.getFloor()).orElse(14));
int increment = i.getAndIncrement(); int increment = i.getAndIncrement();
pain.setIndex(increment); pain.setPindex(increment);
pain.setName(it.getName()); pain.setName(it.getName());
String departMentName = departmentMap.getOrDefault(it.getDepartmentId(), new FeiShuDepartmentDTO()).getName(); String departMentName = departmentMap.getOrDefault(it.getDepartmentId(), new FeiShuDepartmentDTO()).getName();
pain.setDepartMentName(departMentName); pain.setDepartMentName(departMentName);
......
...@@ -8,7 +8,7 @@ import java.util.Date; ...@@ -8,7 +8,7 @@ import java.util.Date;
public class Pain { public class Pain {
private Integer id; private Integer id;
private String openId; private String openId;
private Integer index; private Integer pindex;
private String name; private String name;
private Integer status; private Integer status;
private Date startTime; private Date startTime;
......
...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,6 +4,7 @@ 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.msg.FeiShuMsgDTO; import com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO;
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;
...@@ -76,7 +77,14 @@ public class MassageService { ...@@ -76,7 +77,14 @@ public class MassageService {
feiShuMsgDTO.setContent(content); feiShuMsgDTO.setContent(content);
feiShuMsgDTO.setReceiveId(chatId); feiShuMsgDTO.setReceiveId(chatId);
log.info(feiShuMsgDTO.toString()); log.info(feiShuMsgDTO.toString());
feiShuApiService.sendMsg(feiShuMsgDTO, "chat_id"); JSONObject rep = feiShuApiService.sendMsg(feiShuMsgDTO, "chat_id");
String messageId = rep.getJSONObject("data").getString("message_id");
ChatMessage chatMessage = new ChatMessage();
chatMessage.setChatId(chatId);
chatMessage.setMessageId(messageId);
chatMessage.setType(1);
chatMessageService.create(chatMessage);
} }
...@@ -96,10 +104,10 @@ public class MassageService { ...@@ -96,10 +104,10 @@ public class MassageService {
for(Pain pain:pains){ for(Pain pain:pains){
List<String> user = new ArrayList<>(); List<String> user = new ArrayList<>();
//构建给大群发送的名单 //构建给大群发送的名单
user.add(pain.getIndex().toString()); user.add(pain.getPindex().toString());
user.add(pain.getName()); user.add(pain.getName());
user.add(pain.getDepartMentName()); user.add(pain.getDepartMentName());
user.add(pain.getTimeRange()); user.add("15:00-18:00");
user.add(""); user.add("");
pushUser.add(user); pushUser.add(user);
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<result column="message_id" property="messageId"/> <result column="message_id" property="messageId"/>
<result column="name" property="name"/> <result column="name" property="name"/>
<result column="depart_ment_name" property="departMentName"/> <result column="depart_ment_name" property="departMentName"/>
<result column="index" property="index"/> <result column="pindex" property="pindex"/>
</resultMap> </resultMap>
<!-- <resultMap id="BuffConfigResultBOMap" type="com.pipihelper.project.feishu.entity.Deployee" <!-- <resultMap id="BuffConfigResultBOMap" type="com.pipihelper.project.feishu.entity.Deployee"
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
</resultMap>--> </resultMap>-->
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id,open_id,start_time,end_time,status,floor,message_id,name,depart_ment_name id
,open_id,start_time,end_time,status,floor,message_id,name,depart_ment_name,`pindex`
</sql> </sql>
<select id="findById" parameterType="java.lang.Integer" resultMap="PainResultMap"> <select id="findById" parameterType="java.lang.Integer" resultMap="PainResultMap">
...@@ -37,9 +38,9 @@ ...@@ -37,9 +38,9 @@
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from t_pain from t_pain
<where> <where>
index >= #{index} pindex >= #{pindex}
and status = 0 and status = 0
order by index asc order by pindex asc
limit #{limit} limit #{limit}
</where> </where>
</select> </select>
...@@ -50,7 +51,7 @@ ...@@ -50,7 +51,7 @@
from t_pain from t_pain
<where> <where>
status = 0 status = 0
order by index asc order by pindex asc
limit #{limit} limit #{limit}
</where> </where>
</select> </select>
...@@ -65,7 +66,9 @@ ...@@ -65,7 +66,9 @@
</select> </select>
<delete id="deleteAllByFloor"> <delete id="deleteAllByFloor">
delete from t_pain where floor = #{floor} delete
from t_pain
where floor = #{floor}
</delete> </delete>
<select id="findByIndex" parameterType="java.lang.String" resultMap="PainResultMap"> <select id="findByIndex" parameterType="java.lang.String" resultMap="PainResultMap">
...@@ -73,7 +76,7 @@ ...@@ -73,7 +76,7 @@
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from t_pain from t_pain
<where> <where>
index = #{index} pindex = #{pindex}
</where> </where>
</select> </select>
...@@ -92,12 +95,12 @@ ...@@ -92,12 +95,12 @@
<insert id="create" useGeneratedKeys="true" keyProperty="id" <insert id="create" useGeneratedKeys="true" keyProperty="id"
parameterType="com.pipihelper.project.feishu.entity.Pain"> parameterType="com.pipihelper.project.feishu.entity.Pain">
insert into t_pain (open_id, start_time, end_time, status, floor,message_id,name,depart_ment_name) insert into t_pain (open_id, start_time, end_time, status, floor, message_id, name, depart_ment_name, pindex)
values (#{openId}, #{startTime}, #{endTime}, #{status},#{floor},#{messageId},#{name},#{departMentName}) values (#{openId}, #{startTime}, #{endTime}, #{status}, #{floor}, #{messageId}, #{name}, #{departMentName},#{pindex})
</insert> </insert>
<update id="waitPain" parameterType="com.pipihelper.project.feishu.entity.Pain"> <update id="waitPain" parameterType="com.pipihelper.project.feishu.entity.Pain">
UPDATE t_pain set `index` = ((SELECT selected_value FROM (SELECT MAX(`index`) AS selected_value FROM t_pain) AS UPDATE t_pain set pindex = ((SELECT selected_value FROM (SELECT MAX(pindex) AS selected_value FROM t_pain) AS
sub_selected_value) + 1) sub_selected_value) + 1)
<where> <where>
open_id = #{openId} open_id = #{openId}
...@@ -133,6 +136,9 @@ ...@@ -133,6 +136,9 @@
<if test="departMentName != null"> <if test="departMentName != null">
depart_ment_name = #{departMentName}, depart_ment_name = #{departMentName},
</if> </if>
<if test="pindex != null">
pindex = #{pindex},
</if>
</set> </set>
<where> <where>
id = #{id} id = #{id}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!