use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameClubService method joinClub.
/**
* 加入俱乐部
*
* @param msgKey
* @param userId
* @param clubId
* @return
*/
public int joinClub(KafkaMsgKey msgKey, long userId, String clubId, String mark) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club == null) {
return ErrorCode.CLUB_NO_THIS;
}
// 自己加入了几个俱乐部
List<String> joinList = ClubManager.getInstance().getUserClubs(userId);
if (joinList.size() >= JOIN_LIMIT) {
return ErrorCode.CLUB_CANNOT_NUM;
}
if (joinList.contains(clubId)) {
return ErrorCode.CLUB_CANNOT_JOIN;
}
// 加入申请列表
if (isInApplyList(club, userId)) {
return ErrorCode.CLUB_CANNOT_JOIN;
}
UserBean userBean = RedisManager.getUserRedisService().getUserBean(userId);
String name = userBean.getUsername();
String image = userBean.getImage();
ClubMember apply = new ClubMember().setTime(System.currentTimeMillis()).setUserId(userId).setMark(mark).setName(name).setImage(image);
club.getClubInfo().getApplyList().add(apply);
Map<String, Object> result = new HashMap<>();
sendMsg(msgKey, new ResponseVo("clubService", "joinClub", result));
return 0;
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameClubService method setClub.
/**
* 设置俱乐部
*
* @param msgKey
* @param userId
* @param clubId
* @param clubName
* @param wx
* @param area
* @param desc
* @return
*/
public int setClub(KafkaMsgKey msgKey, long userId, String clubId, String clubName, String wx, String area, String desc) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club == null) {
return ErrorCode.CLUB_NO_THIS;
}
if (userId != club.getPresident()) {
return ErrorCode.CLUB_CANNOT_NO_PRESIDENT;
}
club.setName(clubName).setPresidentWx(wx).setArea(area).setClubDesc(desc);
sendMsg(msgKey, new ResponseVo("clubService", "setClub", getClubVo_simple(club)));
return 0;
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameClubService method getChargeRecord.
public int getChargeRecord(KafkaMsgKey msgKey, long userId, String clubId) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club == null) {
return ErrorCode.CLUB_NO_THIS;
}
if (club.getPresident() != userId) {
return ErrorCode.CLUB_NOT_PRESIDENT;
}
List<ClubCharge> list = clubChargeService.getClubChargeDao().getClubChargesByClubId(clubId);
sendMsg(msgKey, new ResponseVo("clubService", "getChargeRecord", list));
return 0;
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameClubService method dissolve.
/**
* 解散
*
* @param msgKey
* @param userId
* @param clubId
* @return
*/
public int dissolve(KafkaMsgKey msgKey, long userId, String clubId) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club == null) {
return ErrorCode.CLUB_NO_THIS;
}
if (userId != club.getPresident()) {
return ErrorCode.CLUB_CANNOT_NO_PRESIDENT;
}
// 玩家删除id
List<String> removeList = new ArrayList<>();
removeList.addAll(club.getClubInfo().getMember().keySet());
for (String uid : removeList) {
clubRemoveMember(club, Long.valueOf(uid));
}
// 删除club
ClubManager.getInstance().getClubMap().remove(clubId);
// 把钱加回去
RedisManager.getUserRedisService().addUserMoney(userId, club.getMoney());
// todo 在建的房间 是否退钱
sendMsg(msgKey, new ResponseVo("clubService", "dissolve", club));
return 0;
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameClubService method createClub.
/**
* 创建俱乐部
*
* @param msgKey
* @param userId
* @param clubName
* @param wx
* @param area
* @param desc
* @return
*/
public int createClub(KafkaMsgKey msgKey, long userId, String clubName, String wx, String area, String desc) {
// 钱是否够
double money = RedisManager.getUserRedisService().getUserMoney(userId);
if (money < getCreateMoney()) {
return ErrorCode.CLUB_CANNOT_MONEY;
}
// 多于5个俱乐部 不可以创建
int num = ClubManager.getInstance().getUserClubNum(userId);
if (num >= JOIN_LIMIT) {
return ErrorCode.CLUB_CANNOT_NUM;
}
// 人减钱
RedisManager.getUserRedisService().addUserMoney(userId, -getCreateMoney());
Club club = new Club();
UserBean userBean = RedisManager.getUserRedisService().getUserBean(userId);
// id
club.setId(ClubManager.getInstance().getClubId());
club.setPresident(userId);
club.setName(clubName);
club.setPresidentName(userBean.getUsername());
club.setPresidentWx(wx);
club.setArea(area);
club.setMoney(getCreateMoney());
club.setClubDesc(desc);
clubAddMember(club, userBean);
clubService.getClubDao().save(club);
ClubManager.getInstance().getClubMap().put(club.getId(), club);
ResponseVo vo = new ResponseVo("clubService", "createClub", club);
sendMsg(msgKey, vo);
return 0;
}
Aggregations