|
@@ -24,6 +24,7 @@ import com.zanxiang.game.module.manage.pojo.vo.UserVO;
|
|
|
import com.zanxiang.game.module.manage.pojo.vo.UserWeChatVO;
|
|
|
import com.zanxiang.game.module.manage.service.*;
|
|
|
import com.zanxiang.game.module.mybatis.entity.Agent;
|
|
|
+import com.zanxiang.game.module.mybatis.entity.GameUser;
|
|
|
import com.zanxiang.game.module.mybatis.entity.GameUserRole;
|
|
|
import com.zanxiang.game.module.mybatis.entity.User;
|
|
|
import com.zanxiang.game.module.mybatis.mapper.UserMapper;
|
|
@@ -75,6 +76,79 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
@DubboReference(providedBy = CorpServer.SERVER_DUBBO_NAME)
|
|
|
private ICorpExternalUserServiceRpc corpExternalUserServiceRpc;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IGameUserService gameUserService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean appletToH5(Long userId, String mobile) {
|
|
|
+ //用户信息
|
|
|
+ User user = super.getById(userId);
|
|
|
+ if (user == null) {
|
|
|
+ throw new BaseException("参数错误, 用户信息不存在");
|
|
|
+ }
|
|
|
+ //查询H5游戏
|
|
|
+ GameDTO h5GameDTO = gameService.getById(gameService.getById(user.getGameId()).getH5GameId());
|
|
|
+ if (h5GameDTO == null) {
|
|
|
+ throw new BaseException("参数错误, 关联H5游戏信息不存在");
|
|
|
+ }
|
|
|
+ //复制用户信息
|
|
|
+ User h5User = BeanUtil.copy(user, User.class);
|
|
|
+ h5User.setId(null);
|
|
|
+ h5User.setGameId(h5GameDTO.getId());
|
|
|
+ h5User.setMobile(mobile);
|
|
|
+ h5User.setRelationUserId(user.getId());
|
|
|
+ h5User.setRelationCreateTime(LocalDateTime.now());
|
|
|
+ super.save(h5User);
|
|
|
+ //复制玩家信息
|
|
|
+ GameUser gameUser = gameUserService.getOne(new LambdaQueryWrapper<GameUser>()
|
|
|
+ .eq(GameUser::getUserId, user.getId())
|
|
|
+ .eq(GameUser::getGameId, user.getGameId()));
|
|
|
+ if (gameUser == null) {
|
|
|
+ throw new BaseException("参数错误, 玩家游戏信息不存在");
|
|
|
+ }
|
|
|
+ GameUser h5GameUser = GameUser.builder()
|
|
|
+ .userId(h5User.getId())
|
|
|
+ .gameId(h5User.getGameId())
|
|
|
+ .nickname(gameUser.getNickname())
|
|
|
+ .regTime(gameUser.getRegTime())
|
|
|
+ .createTime(gameUser.getCreateTime())
|
|
|
+ .updateTime(gameUser.getUpdateTime())
|
|
|
+ .build();
|
|
|
+ gameUserService.save(h5GameUser);
|
|
|
+ //复制角色
|
|
|
+ List<GameUserRole> gameUserRoleList = gameUserRoleService.list(new LambdaQueryWrapper<GameUserRole>()
|
|
|
+ .eq(GameUserRole::getUserId, user.getId())
|
|
|
+ .eq(GameUserRole::getGameId, user.getGameId()));
|
|
|
+ if (CollectionUtils.isNotEmpty(gameUserRoleList)) {
|
|
|
+ throw new BaseException("参数错误, 用户不存在角色信息");
|
|
|
+ }
|
|
|
+ List<GameUserRole> h5GameUserRoleList = gameUserRoleList.stream().map(gameUserRole -> GameUserRole.builder()
|
|
|
+ .userId(h5User.getId())
|
|
|
+ .gameUserId(h5GameUser.getId())
|
|
|
+ .gameId(h5User.getGameId())
|
|
|
+ .serverId(gameUserRole.getServerId())
|
|
|
+ .serverName(gameUserRole.getServerName())
|
|
|
+ .roleId(gameUserRole.getRoleId())
|
|
|
+ .roleName(gameUserRole.getRoleName())
|
|
|
+ .roleLevel(gameUserRole.getRoleLevel())
|
|
|
+ .roleVipLevel(gameUserRole.getRoleVipLevel())
|
|
|
+ .rolePower(gameUserRole.getRolePower())
|
|
|
+ .os(gameUserRole.getOs())
|
|
|
+ .regTime(gameUserRole.getCreateTime())
|
|
|
+ .createTime(gameUserRole.getCreateTime())
|
|
|
+ .updateTime(gameUserRole.getUpdateTime())
|
|
|
+ .lastLoginTime(gameUserRole.getLastLoginTime())
|
|
|
+ .build()
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+ gameUserRoleService.saveBatch(h5GameUserRoleList);
|
|
|
+ //用户更新
|
|
|
+ return super.update(new LambdaUpdateWrapper<User>()
|
|
|
+ .set(User::getRelationUserId, h5User)
|
|
|
+ .set(User::getRelationCreateTime, LocalDateTime.now())
|
|
|
+ .eq(User::getId, userId));
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public UserWeChatVO getUserWeChat(Long userId) {
|
|
|
User user = super.getById(userId);
|