back_recharge
parent
741a182c9a
commit
f90bbee15a
|
@ -59,14 +59,8 @@ public class LjsdMongoTemplate {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean remove(String collectionName, Object id) throws Exception {
|
public boolean remove(Query query, String collection) throws Exception {
|
||||||
//TODO 正确性未知,未测试
|
mongoTemplate.remove(query,collection);
|
||||||
DBCollection coll = mongoTemplate.getCollection(collectionName);
|
|
||||||
DBObject doc = coll.findOne(id);
|
|
||||||
if(doc == null){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
coll.remove(doc);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.ljsd.jieling.handler.BaseHandler;
|
||||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
import com.ljsd.jieling.logic.family.GuildLogic;
|
||||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||||
import com.ljsd.jieling.network.session.ISession;
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
import com.ljsd.jieling.protocols.Family;
|
||||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -16,6 +17,8 @@ public class FamilyDissolutionHandler extends BaseHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||||
GuildLogic.dissolution(iSession);
|
byte[] bytes = netData.parseClientProtoNetData();
|
||||||
|
Family.FamilyDissolutionRequest familyDissolutionRequest = Family.FamilyDissolutionRequest.parseFrom(bytes);
|
||||||
|
GuildLogic.dissolution(iSession,familyDissolutionRequest.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ import com.ljsd.jieling.logic.dao.root.GuildApply;
|
||||||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||||
import com.ljsd.jieling.logic.dao.root.GuildLog;
|
import com.ljsd.jieling.logic.dao.root.GuildLog;
|
||||||
import com.ljsd.jieling.logic.dao.root.User;
|
import com.ljsd.jieling.logic.dao.root.User;
|
||||||
|
import com.mongodb.BasicDBObject;
|
||||||
|
import org.springframework.data.mongodb.core.query.BasicQuery;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
@ -21,6 +23,15 @@ public class GuilidManager {
|
||||||
guildNameInfoMap.put(guildInfo.getName(),guildInfo);
|
guildNameInfoMap.put(guildInfo.getName(),guildInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void removeGuildInfo(GuildInfo guildInfo) throws Exception {
|
||||||
|
int guildId = guildInfo.getId();
|
||||||
|
guildInfoMap.remove(guildId);
|
||||||
|
guildNameInfoMap.remove(guildInfo.getName());
|
||||||
|
guildLogInfoMap.remove(guildId);
|
||||||
|
MongoUtil.getInstence().getMyMongoTemplate().remove(new BasicQuery(new BasicDBObject("_id",guildId)),"guildInfo");
|
||||||
|
MongoUtil.getInstence().getMyMongoTemplate().remove(new BasicQuery(new BasicDBObject("guildId",guildId)),"guildLog");
|
||||||
|
}
|
||||||
|
|
||||||
public static void addApplyGuildInfo(GuildApply guildApply){
|
public static void addApplyGuildInfo(GuildApply guildApply){
|
||||||
RedisUtil.getInstence().hset( RedisUtil.getInstence().getKey("apply-user-play",Integer.toString(guildApply.getId())),Integer.toString(guildApply.getGuildId()),guildApply);
|
RedisUtil.getInstence().hset( RedisUtil.getInstence().getKey("apply-user-play",Integer.toString(guildApply.getId())),Integer.toString(guildApply.getGuildId()),guildApply);
|
||||||
RedisUtil.getInstence().hset(RedisUtil.getInstence().getKey("apply-user-guild",Integer.toString(guildApply.getGuildId())),Integer.toString(guildApply.getId()),guildApply);
|
RedisUtil.getInstence().hset(RedisUtil.getInstence().getKey("apply-user-guild",Integer.toString(guildApply.getGuildId())),Integer.toString(guildApply.getId()),guildApply);
|
||||||
|
@ -44,6 +55,10 @@ public class GuilidManager {
|
||||||
RedisUtil.getInstence().removeMapEntrys("apply-user-play",Integer.toString(uid),guild);
|
RedisUtil.getInstence().removeMapEntrys("apply-user-play",Integer.toString(uid),guild);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void removeMineApplyGuildInfos(int guild,int uid){
|
||||||
|
RedisUtil.getInstence().removeMapEntrys("apply-user-play",Integer.toString(uid),guild);
|
||||||
|
}
|
||||||
|
|
||||||
public static void addGuildLog(GuildLog guildLog) throws Exception {
|
public static void addGuildLog(GuildLog guildLog) throws Exception {
|
||||||
MongoUtil.getInstence().getMyMongoTemplate().save(guildLog);
|
MongoUtil.getInstence().getMyMongoTemplate().save(guildLog);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@ public class GuildInfo extends MongoBase {
|
||||||
|
|
||||||
private Map<Integer, Set<Integer>> members ;
|
private Map<Integer, Set<Integer>> members ;
|
||||||
|
|
||||||
|
private int levelTime;
|
||||||
|
|
||||||
private long createTime;
|
private long createTime;
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,8 +89,14 @@ public class GuildInfo extends MongoBase {
|
||||||
return createTime;
|
return createTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getLevelTime() {
|
||||||
|
return levelTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLevelTime(int levelTime) {
|
||||||
|
this.levelTime = levelTime;
|
||||||
|
updateString("levelTime",levelTime);
|
||||||
|
}
|
||||||
|
|
||||||
public void setJoinType(int joinType) {
|
public void setJoinType(int joinType) {
|
||||||
this.joinType = joinType;
|
this.joinType = joinType;
|
||||||
|
|
|
@ -282,11 +282,12 @@ public class GuildLogic {
|
||||||
int uid = session.getUid();
|
int uid = session.getUid();
|
||||||
User user = UserManager.getUser(uid);
|
User user = UserManager.getUser(uid);
|
||||||
int msgId = MessageTypeProto.MessageType.FAMILY_GET_APPLY_RESPOSNE_VALUE;
|
int msgId = MessageTypeProto.MessageType.FAMILY_GET_APPLY_RESPOSNE_VALUE;
|
||||||
if(user.getPlayerInfoManager().getGuildId()==0){
|
int guildId = user.getPlayerInfoManager().getGuildId();
|
||||||
|
if(guildId==0){
|
||||||
MessageUtil.sendErrorResponse(session,0,msgId,"未加入公会");
|
MessageUtil.sendErrorResponse(session,0,msgId,"未加入公会");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Map<Integer, GuildApply> applyGuildInfos = GuilidManager.getApplyGuildInfos(user.getPlayerInfoManager().getGuildId(), 0);
|
Map<Integer, GuildApply> applyGuildInfos = GuilidManager.getApplyGuildInfos(guildId, 0);
|
||||||
List<GuildApply> guildApplies = new ArrayList<>();
|
List<GuildApply> guildApplies = new ArrayList<>();
|
||||||
int now =(int)(System.currentTimeMillis()/1000);
|
int now =(int)(System.currentTimeMillis()/1000);
|
||||||
for(GuildApply guildApply :applyGuildInfos.values()){
|
for(GuildApply guildApply :applyGuildInfos.values()){
|
||||||
|
@ -294,6 +295,13 @@ public class GuildLogic {
|
||||||
GuilidManager.removeOneApplyGuildInfos(guildApply.getGuildId(),guildApply.getId());
|
GuilidManager.removeOneApplyGuildInfos(guildApply.getGuildId(),guildApply.getId());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
int id = guildApply.getId();
|
||||||
|
User userApply = UserManager.getUser(id);
|
||||||
|
if(userApply.getPlayerInfoManager().getGuildId()!=0){
|
||||||
|
GuilidManager.removeOneApplyGuildInfos(guildId,uid);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
guildApplies.add(guildApply);
|
guildApplies.add(guildApply);
|
||||||
}
|
}
|
||||||
Collections.sort(guildApplies);
|
Collections.sort(guildApplies);
|
||||||
|
@ -374,6 +382,7 @@ public class GuildLogic {
|
||||||
guildInfo.addMembers(GlobalsDef.MEMBER,applyId);
|
guildInfo.addMembers(GlobalsDef.MEMBER,applyId);
|
||||||
User targetUser = UserManager.getUser(applyId);
|
User targetUser = UserManager.getUser(applyId);
|
||||||
targetUser.getPlayerInfoManager().setGuildId(guildInfo.getId());
|
targetUser.getPlayerInfoManager().setGuildId(guildInfo.getId());
|
||||||
|
GuilidManager.removeMineApplyGuildInfos(guildInfo.getId(),applyId);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
LOGGER.error("the exception={}",e);
|
LOGGER.error("the exception={}",e);
|
||||||
}finally {
|
}finally {
|
||||||
|
@ -426,8 +435,9 @@ public class GuildLogic {
|
||||||
User targetUser = UserManager.getUser(targetUid);
|
User targetUser = UserManager.getUser(targetUid);
|
||||||
targetUser.getPlayerInfoManager().setGuildId(0);
|
targetUser.getPlayerInfoManager().setGuildId(0);
|
||||||
addGuildLog(guildInfo.getId(),GuildDef.Log.KICK,user.getPlayerInfoManager().getNickName());
|
addGuildLog(guildInfo.getId(),GuildDef.Log.KICK,user.getPlayerInfoManager().getNickName());
|
||||||
|
Family.FamilyKickIndication build = Family.FamilyKickIndication.newBuilder().setType(1).build();
|
||||||
|
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.FAMILY_KICK_INDICATION_VALUE,build,true);
|
||||||
MessageUtil.sendMessage(session,1,msgId,null,true);
|
MessageUtil.sendMessage(session,1,msgId,null,true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -447,7 +457,7 @@ public class GuildLogic {
|
||||||
}
|
}
|
||||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
||||||
int uidType = getMemberType(uid, guildInfo.getMembers());
|
int uidType = getMemberType(uid, guildInfo.getMembers());
|
||||||
int targetType = getMemberType(uid, guildInfo.getMembers());
|
int targetType = getMemberType(targetUid, guildInfo.getMembers());
|
||||||
if(uidType>1 || uidType>targetType){
|
if(uidType>1 || uidType>targetType){
|
||||||
MessageUtil.sendErrorResponse(session,0,msgId,"无权操作");
|
MessageUtil.sendErrorResponse(session,0,msgId,"无权操作");
|
||||||
return;
|
return;
|
||||||
|
@ -467,10 +477,32 @@ public class GuildLogic {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解散公会
|
* 解散公会
|
||||||
* @param iSession
|
* @param session
|
||||||
*/
|
*/
|
||||||
public static void dissolution(ISession iSession){
|
public static void dissolution(ISession session,int type) throws Exception {
|
||||||
|
int msgId = MessageTypeProto.MessageType.FAMILY_DISSOLUTION_RESPONSE_VALUE;
|
||||||
|
int uid = session.getUid();
|
||||||
|
User user = UserManager.getUser(uid);
|
||||||
|
int guildId = user.getPlayerInfoManager().getGuildId();
|
||||||
|
if(guildId == 0){
|
||||||
|
MessageUtil.sendErrorResponse(session,0,msgId,"未加入公会");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
||||||
|
int uidType = getMemberType(uid, guildInfo.getMembers());
|
||||||
|
if(uidType!=1){
|
||||||
|
MessageUtil.sendErrorResponse(session,0,msgId,"无权操作");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//解散公会
|
||||||
|
if(type == 1){
|
||||||
|
guildInfo.setLevelTime((int)(System.currentTimeMillis()/1000));
|
||||||
|
}else{
|
||||||
|
guildInfo.setLevelTime(0);
|
||||||
|
}
|
||||||
|
sendFamilyBaseUpdateIndication(guildInfo);
|
||||||
|
releaseGuild(guildInfo);
|
||||||
|
MessageUtil.sendMessage(session,1,msgId,null,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -539,6 +571,25 @@ public class GuildLogic {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void releaseGuild(GuildInfo guildInfo) throws Exception {
|
||||||
|
Map<Integer, Set<Integer>> members = guildInfo.getMembers();
|
||||||
|
Family.FamilyKickIndication build = Family.FamilyKickIndication.newBuilder().setType(2).build();
|
||||||
|
for(Set<Integer> items : members.values()){
|
||||||
|
for(Integer sendUid : items){
|
||||||
|
ISession session = OnlineUserManager.getSessionByUid(sendUid);
|
||||||
|
if(session!=null){
|
||||||
|
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.FAMILY_KICK_INDICATION_VALUE,build,true);
|
||||||
|
}
|
||||||
|
User user = UserManager.getUser(sendUid);
|
||||||
|
user.getPlayerInfoManager().setGuildId(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GuilidManager.removeGuildInfo(guildInfo);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void chairmanChange(ISession session,int targetUid) throws Exception {
|
public static void chairmanChange(ISession session,int targetUid) throws Exception {
|
||||||
int msgId = MessageTypeProto.MessageType.FAMILY_TRANSFER_CHAIRMAN_RESPONSE_VALUE;
|
int msgId = MessageTypeProto.MessageType.FAMILY_TRANSFER_CHAIRMAN_RESPONSE_VALUE;
|
||||||
int uid = session.getUid();
|
int uid = session.getUid();
|
||||||
|
@ -578,7 +629,8 @@ public class GuildLogic {
|
||||||
MessageUtil.sendErrorResponse(session,0,msgId,"会长不能退出公会");
|
MessageUtil.sendErrorResponse(session,0,msgId,"会长不能退出公会");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
user.getPlayerInfoManager().setGuildId(uid);
|
guildInfo.removeMember(uidType,uid);
|
||||||
|
user.getPlayerInfoManager().setGuildId(0);
|
||||||
MessageUtil.sendMessage(session,1,msgId,null,true);
|
MessageUtil.sendMessage(session,1,msgId,null,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -351,6 +351,7 @@ public class CBean2Proto {
|
||||||
.setName(guildInfo.getName())
|
.setName(guildInfo.getName())
|
||||||
.setJoinType(guildInfo.getJoinType())
|
.setJoinType(guildInfo.getJoinType())
|
||||||
.setMaxNum(30)
|
.setMaxNum(30)
|
||||||
|
.setLevle(guildInfo.getLevelTime())
|
||||||
.setTotalNum(1).build();
|
.setTotalNum(1).build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue