Commit 4e8fa188 by liushuangwu

Pain

1 parent 88bb9b4f
...@@ -133,8 +133,11 @@ public class FeiShuEventController { ...@@ -133,8 +133,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());
Integer givUpPainId = painService.findByOpenId(feiShuMsgCardEventDTO.getOpen_id()).getId();
String fileName = String.format("/templates/massage-msg-card-rob.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(), givUpPainId);
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"); String fileName1 = String.format("/templates/massage-singel-msg-card-end.json");
...@@ -183,15 +186,22 @@ public class FeiShuEventController { ...@@ -183,15 +186,22 @@ public class FeiShuEventController {
return null; return null;
} }
public synchronized JSONObject rob(FeiShuMsgCardEventDTO feiShuMsgCardEventDTO) { public JSONObject rob(FeiShuMsgCardEventDTO feiShuMsgCardEventDTO) {
String oldUserId = feiShuMsgCardEventDTO.getAction().getValue().getKey().split("\\.")[2]; String oldOpenId = feiShuMsgCardEventDTO.getAction().getValue().getKey().split("\\.")[2];
String robUserId = feiShuMsgCardEventDTO.getOpen_id(); Integer givUpPainId = Integer.parseInt(feiShuMsgCardEventDTO.getAction().getValue().getKey().split("\\.")[3]);
Employee employee = employeeService.findByOpenId(robUserId); String robOpenId = feiShuMsgCardEventDTO.getOpen_id();
synchronized (oldUserId) { Employee robEmployee = employeeService.findByOpenId(robOpenId);
massageService.robSingle(robUserId, oldUserId, employee.getName());
//oldOpenId 放弃人的openId, robOpenId 抢到人 openId
int update = painService.updateByOpenId(robOpenId, robEmployee.getName(), oldOpenId);
if (update >= 1) {
massageService.robSingle(robOpenId, robEmployee.getDepartmentId(), givUpPainId);
} }
Pain pain = painService.findById(givUpPainId);
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, "已经被" + pain.getName() + "抢啦,啦啦~");
} }
......
...@@ -30,4 +30,6 @@ public interface PainDao { ...@@ -30,4 +30,6 @@ public interface PainDao {
void deleteAllByFloor(int floor); void deleteAllByFloor(int floor);
List<Pain> findAllByFloor(@Param(value = "floor") int floor); List<Pain> findAllByFloor(@Param(value = "floor") int floor);
int updateByOpenId(@Param(value = "robOpenId")String robOpenId,@Param(value = "robName") String robName,@Param(value = "oldOpenId") String oldOpenId);
} }
...@@ -95,6 +95,10 @@ public class PainService { ...@@ -95,6 +95,10 @@ public class PainService {
painDao.deleteAllByFloor(floor); painDao.deleteAllByFloor(floor);
} }
public int updateByOpenId(String robOpenId, String robName, String oldOpenId) {
return painDao.updateByOpenId(robOpenId, robName, oldOpenId);
}
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public static class PindexFloor { public static class PindexFloor {
......
...@@ -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.chat.FeiShuChatDTO; import com.pipihelper.project.feishu.dto.chat.FeiShuChatDTO;
import com.pipihelper.project.feishu.dto.department.FeiShuDepartmentDTO;
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;
...@@ -125,18 +126,22 @@ public class MassageService { ...@@ -125,18 +126,22 @@ public class MassageService {
} }
@Async @Async
public void robSingle(String robUserId, String oldUserId, String name) { public void robSingle(String robOpenId, String robDepartmentId, Integer givUpPainId) {
Pain oldPain = painService.findByOpenId(oldUserId);
oldPain.setOpenId(robUserId);
oldPain.setName(name);
painService.update(oldPain);
FeiShuChatDTO feiShuChatDTO = new FeiShuChatDTO(); FeiShuChatDTO feiShuChatDTO = new FeiShuChatDTO();
feiShuChatDTO.setChatId((String) CacheUtil.get("chatId")); feiShuChatDTO.setChatId((String) CacheUtil.get("chatId"));
feiShuChatDTO.setIdList(new String[]{robUserId}); feiShuChatDTO.setIdList(new String[]{robOpenId});
feiShuApiService.joinChatList(feiShuChatDTO); feiShuApiService.joinChatList(feiShuChatDTO);
sendSingle(robUserId); /**
* 更新部门名
*/
FeiShuDepartmentDTO department = feiShuApiService.getDepartment(robDepartmentId);
Pain pain = new Pain();
pain.setId(givUpPainId);
pain.setDepartMentName(department.getName());
painService.update(pain);
sendSingle(robOpenId);
// 更新大群和按摩群的大卡片,异步 // 更新大群和按摩群的大卡片,异步
// 大群 // 大群
updateMassageMsgCardToPiPiChat(feiShuConfig.getChatId()); updateMassageMsgCardToPiPiChat(feiShuConfig.getChatId());
......
...@@ -65,6 +65,11 @@ ...@@ -65,6 +65,11 @@
</where> </where>
</select> </select>
<update id="updateByOpenId" parameterType="java.lang.Integer">
update t_pain set open_id = #{robOpenId},
name = #{robName} where open_id = #{oldOpenId}
</update>
<select id="findByOpenId" parameterType="java.lang.String" resultMap="PainResultMap"> <select id="findByOpenId" parameterType="java.lang.String" resultMap="PainResultMap">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
}, },
"type": "default", "type": "default",
"value": { "value": {
"key": "massage-singel.rob.%s" "key": "massage-singel.rob.%s.%s"
} }
} }
], ],
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!