|
@@ -126,13 +126,48 @@ public class KfAppletMsgServiceImpl implements IKfAppletMsgService {
|
|
|
.gameId(gameApplet.getGameId())
|
|
|
.userId(user == null ? null : user.getId())
|
|
|
.isWait(Boolean.FALSE)
|
|
|
- .lastRoleId(gameUserRole == null ? null : gameUserRole.getRoleId())
|
|
|
- .lastRoleName(gameUserRole == null ? null : gameUserRole.getRoleName())
|
|
|
+ .lastRoleId(gameUserRole == null ? "0" : gameUserRole.getRoleId())
|
|
|
+ .lastRoleName(gameUserRole == null ? kfAppletMsgDTO.getFromUserName() : gameUserRole.getRoleName())
|
|
|
.createTime(LocalDateTime.now())
|
|
|
.updateTime(LocalDateTime.now())
|
|
|
.build();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private void kfSessionUserUpdateSave(KfAppletMsgDTO kfAppletMsgDTO, GameApplet gameApplet) {
|
|
|
+ KfSessionUser kfSessionUser = kfSessionUserService.getById(kfAppletMsgDTO.getFromUserName());
|
|
|
+ //查询用户
|
|
|
+ User user = userService.getOne(new LambdaQueryWrapper<User>().eq(User::getOpenId, kfAppletMsgDTO.getFromUserName()));
|
|
|
+ //最近角色信息
|
|
|
+ GameUserRole gameUserRole = null;
|
|
|
+ if (user != null) {
|
|
|
+ gameUserRole = gameUserRoleService.getLastGameUserRoleName(user.getId(), user.getGameId());
|
|
|
+ }
|
|
|
+ //不存在玩家信息, 创建保存
|
|
|
+ if (kfSessionUser == null) {
|
|
|
+ kfSessionUserService.save(this.transform(kfAppletMsgDTO, gameApplet, user, gameUserRole));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //存在, 更新玩家信息
|
|
|
+// kfSessionUserService.update()
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private KfSessionUser transform(KfAppletMsgDTO kfAppletMsgDTO, GameApplet gameApplet, User user, GameUserRole gameUserRole) {
|
|
|
+ return KfSessionUser.builder()
|
|
|
+ .openId(kfAppletMsgDTO.getFromUserName())
|
|
|
+ .gameId(gameApplet.getGameId())
|
|
|
+ .userId(user == null ? null : user.getId())
|
|
|
+ .isWait(Boolean.FALSE)
|
|
|
+ .lastRoleId(gameUserRole == null ? "0" : gameUserRole.getRoleId())
|
|
|
+ .lastRoleName(gameUserRole == null ? kfAppletMsgDTO.getFromUserName() : gameUserRole.getRoleName())
|
|
|
+ .createTime(LocalDateTime.now())
|
|
|
+ .updateTime(LocalDateTime.now())
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private KfRoomMsg transform(KfAppletMsgDTO kfAppletMsgDTO, GameApplet gameApplet, KfRoom kfRoom, String postData,
|
|
|
KfWebSocketMsgDTO.MsgContentBean msgContent) {
|
|
|
return KfRoomMsg.builder()
|
|
@@ -146,6 +181,7 @@ public class KfAppletMsgServiceImpl implements IKfAppletMsgService {
|
|
|
.content(JsonUtil.toString(msgContent))
|
|
|
.source(postData)
|
|
|
.createTime(LocalDateTime.now())
|
|
|
+ .updateTime(LocalDateTime.now())
|
|
|
.build();
|
|
|
}
|
|
|
|