giftgoods
parent
b4e7cf3e5d
commit
3486dbe98c
|
|
@ -1,7 +1,9 @@
|
|||
package com.ljsd.jieling.config;
|
||||
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.jieling.logic.STableManager;
|
||||
import com.ljsd.jieling.logic.Table;
|
||||
import com.ljsd.jieling.logic.activity.ActivityType;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
@ -37,6 +39,16 @@ public class SRechargeCommodityConfig implements BaseConfig {
|
|||
|
||||
private int[] openPrivilege;
|
||||
|
||||
|
||||
|
||||
private int time;
|
||||
private String startTime;
|
||||
private String endtime;
|
||||
|
||||
|
||||
private long startTimeLong;
|
||||
private long endTimeLong;
|
||||
|
||||
public static Map<Integer, SRechargeCommodityConfig> rechargeCommodityConfigMap;
|
||||
public static Map<Integer, SRechargeCommodityConfig> rechargeLevelMap;
|
||||
|
||||
|
|
@ -57,6 +69,23 @@ public class SRechargeCommodityConfig implements BaseConfig {
|
|||
|
||||
}
|
||||
|
||||
public long getTimeLong(long createUserTime,int type) {
|
||||
long baseTime = startTimeLong;
|
||||
if(type == 2){
|
||||
baseTime = endTimeLong;
|
||||
}
|
||||
long startTime=0;
|
||||
if(time == ActivityType.OPEN_TYPE_TIME){
|
||||
startTime = baseTime;
|
||||
}else if(time == ActivityType.OPEN_TYPE_SERVER){
|
||||
long serverOpenTime = GameApplication.serverConfig.getCacheOpenTime();
|
||||
startTime = serverOpenTime + baseTime*1000;
|
||||
}else if(time == ActivityType.OPEN_TYPE_ROLE){
|
||||
startTime =createUserTime+baseTime*1000;
|
||||
}
|
||||
return startTime;
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
|
|
@ -113,4 +142,16 @@ public class SRechargeCommodityConfig implements BaseConfig {
|
|||
public int[] getOpenPrivilege() {
|
||||
return openPrivilege;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public String getEndtime() {
|
||||
return endtime;
|
||||
}
|
||||
}
|
||||
|
|
@ -59,8 +59,8 @@ public class ActivityLogic {
|
|||
if(time ==2 ){
|
||||
continue;
|
||||
}
|
||||
long startTime = sGlobalActivity.getTimeLong(0,time);
|
||||
long endTime = sGlobalActivity.getTimeLong(0,time);
|
||||
long startTime = sGlobalActivity.getTimeLong(0,1);
|
||||
long endTime = sGlobalActivity.getTimeLong(0,2);
|
||||
if(now<startTime){
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.ljsd.common.mogodb.MongoBase;
|
|||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
|
@ -28,6 +29,12 @@ public class GuildInfo extends MongoBase {
|
|||
|
||||
private long createTime;
|
||||
|
||||
private int level;
|
||||
|
||||
private int exp;
|
||||
|
||||
private int totalMembers;
|
||||
|
||||
|
||||
public GuildInfo() {
|
||||
setRootCollection(_COLLECTION_NAME);
|
||||
|
|
@ -46,6 +53,8 @@ public class GuildInfo extends MongoBase {
|
|||
this.init(id,"");
|
||||
setRootCollection(_COLLECTION_NAME);
|
||||
joinType =1;
|
||||
level = 1;
|
||||
totalMembers=1;
|
||||
}
|
||||
|
||||
public void addMembers(int type,int uid){
|
||||
|
|
@ -53,11 +62,18 @@ public class GuildInfo extends MongoBase {
|
|||
members.put(type,new HashSet<>());
|
||||
}
|
||||
members.get(type).add(uid);
|
||||
totalMembers++;
|
||||
updateString("members." + type,members.get(type));
|
||||
updateString("totalMembers",totalMembers);
|
||||
}
|
||||
public void removeMember(int type,int uid){
|
||||
members.get(type).remove(uid);
|
||||
updateString("members." + type,members.get(type));
|
||||
public boolean removeMember(int type,int uid){
|
||||
boolean remove = members.get(type).remove(uid);
|
||||
if(remove){
|
||||
totalMembers--;
|
||||
updateString("members." + type,members.get(type));
|
||||
updateString("totalMembers",totalMembers);
|
||||
}
|
||||
return remove;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -102,4 +118,16 @@ public class GuildInfo extends MongoBase {
|
|||
this.joinType = joinType;
|
||||
updateString("joinType",joinType);
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public int getExp() {
|
||||
return exp;
|
||||
}
|
||||
|
||||
public int getTotalMembers() {
|
||||
return totalMembers;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -383,13 +383,13 @@ public class GuildLogic {
|
|||
User targetUser = UserManager.getUser(applyId);
|
||||
targetUser.getPlayerInfoManager().setGuildId(guildInfo.getId());
|
||||
GuilidManager.removeMineApplyGuildInfos(guildInfo.getId(),applyId);
|
||||
GuilidManager.removeOneApplyGuildInfos(guildInfo.getId(),applyId);
|
||||
}catch (Exception e){
|
||||
LOGGER.error("the exception={}",e);
|
||||
}finally {
|
||||
RedisUtil.getInstence().releaseDistributedLock(RedisKey.OPERATE_FAMILY_APPLY_JOIN,Integer.toString(applyId), Integer.toString(applyId));
|
||||
}
|
||||
if(isApply){
|
||||
GuilidManager.removeOneApplyGuildInfos(guildInfo.getId(),applyId);
|
||||
sendFamilyJoinIndication(applyId,guildInfo);
|
||||
}
|
||||
|
||||
|
|
@ -415,23 +415,16 @@ public class GuildLogic {
|
|||
}
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
||||
int uidType = getMemberType(uid, guildInfo.getMembers());
|
||||
int targetType = getMemberType(uid, guildInfo.getMembers());
|
||||
int targetType = getMemberType(targetUid, guildInfo.getMembers());
|
||||
if(uidType>targetType){
|
||||
MessageUtil.sendErrorResponse(session,0,msgId,"无权操作");
|
||||
return;
|
||||
}
|
||||
boolean canKickOut = false;
|
||||
for (Map.Entry<Integer, Set<Integer>> entry : guildInfo.getMembers().entrySet()) {
|
||||
if (entry.getValue().contains(targetUid)) {
|
||||
canKickOut = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!canKickOut){
|
||||
MessageUtil.sendErrorResponse(session,0,msgId,"无权操作");
|
||||
boolean remove = guildInfo.removeMember(targetType, targetUid);
|
||||
if(!remove){
|
||||
MessageUtil.sendErrorResponse(session,0,msgId,"该人已被踢出");
|
||||
return;
|
||||
}
|
||||
guildInfo.removeMember(targetType,targetUid);
|
||||
User targetUser = UserManager.getUser(targetUid);
|
||||
targetUser.getPlayerInfoManager().setGuildId(0);
|
||||
addGuildLog(guildInfo.getId(),GuildDef.Log.KICK,user.getPlayerInfoManager().getNickName());
|
||||
|
|
@ -440,7 +433,6 @@ public class GuildLogic {
|
|||
if(targetSession!=null){
|
||||
MessageUtil.sendIndicationMessage(targetSession,1, MessageTypeProto.MessageType.FAMILY_KICK_INDICATION_VALUE,build,true);
|
||||
}
|
||||
|
||||
MessageUtil.sendMessage(session,1,msgId,null,true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -237,6 +237,7 @@ public class BuyGoodsLogic {
|
|||
Map<Integer,Integer> goodsOrder = new HashMap<>(6);
|
||||
List<CommonProto.GiftGoodsInfo> giftGoodsInfoList = new ArrayList<>(SRechargeCommodityConfig.rechargeCommodityConfigMap.size());
|
||||
Map<Integer,CommonProto.GiftGoodsInfo> giftGoodsInfoMap = new HashMap<>();
|
||||
long createTime = user.getPlayerInfoManager().getCreateTime();
|
||||
for(SRechargeCommodityConfig sRechargeCommodityConfig :SRechargeCommodityConfig.rechargeCommodityConfigMap.values()){
|
||||
int limit = sRechargeCommodityConfig.getLimit();
|
||||
int goodsId = sRechargeCommodityConfig.getId();
|
||||
|
|
@ -253,21 +254,29 @@ public class BuyGoodsLogic {
|
|||
continue;
|
||||
}
|
||||
int[] discountType = sRechargeCommodityConfig.getDiscountType();
|
||||
int time = sRechargeCommodityConfig.getTime();
|
||||
long startTime=0;
|
||||
long endTime=0;
|
||||
if(discountType!=null && discountType.length>0){
|
||||
if(time == 4){
|
||||
int type = discountType[0];
|
||||
int value = discountType[1];
|
||||
if(type == 2){
|
||||
Long startTime = levelBagMap.get(value);
|
||||
if(startTime == null){
|
||||
if(!levelBagMap.containsKey(value)){
|
||||
continue;
|
||||
}
|
||||
startTime = levelBagMap.get(value);
|
||||
int diffHour = (int)((now-startTime)/3600/1000);
|
||||
if(diffHour>=value){
|
||||
continue;
|
||||
}
|
||||
endTime = startTime + value*3600*1000;
|
||||
}
|
||||
}else{
|
||||
startTime = sRechargeCommodityConfig.getTimeLong(createTime,1);
|
||||
endTime = sRechargeCommodityConfig.getTimeLong(createTime,2);
|
||||
}
|
||||
if(now<startTime){
|
||||
continue;
|
||||
}
|
||||
int order = sRechargeCommodityConfig.getOrder();
|
||||
if(order!=0){
|
||||
|
|
@ -278,10 +287,10 @@ public class BuyGoodsLogic {
|
|||
}
|
||||
}
|
||||
goodsOrder.put(sRechargeCommodityConfig.getType(),order*10000 + goodsId);
|
||||
giftGoodsInfoMap.put(goodsId,CommonProto.GiftGoodsInfo.newBuilder().setGoodsId(goodsId).setBuyTimes(buyTimes).setEndTime((int)(endTime/1000)).build());
|
||||
giftGoodsInfoMap.put(goodsId,CommonProto.GiftGoodsInfo.newBuilder().setGoodsId(goodsId).setStartTime((int)(startTime/1000)).setBuyTimes(buyTimes).setEndTime((int)(endTime/1000)).build());
|
||||
continue;
|
||||
}
|
||||
giftGoodsInfoList.add(CommonProto.GiftGoodsInfo.newBuilder().setGoodsId(goodsId).setBuyTimes(buyTimes).setEndTime((int)(endTime/1000)).build());
|
||||
giftGoodsInfoList.add(CommonProto.GiftGoodsInfo.newBuilder().setGoodsId(goodsId).setBuyTimes(buyTimes).setStartTime((int)(startTime/1000)).setEndTime((int)(endTime/1000)).build());
|
||||
}
|
||||
giftGoodsInfoList.addAll(giftGoodsInfoMap.values());
|
||||
return giftGoodsInfoList;
|
||||
|
|
|
|||
|
|
@ -346,13 +346,15 @@ public class CBean2Proto {
|
|||
public static CommonProto.FamilyBaseInfo getFamilyBaseInfo(GuildInfo guildInfo){
|
||||
return CommonProto.FamilyBaseInfo.newBuilder()
|
||||
.setId(guildInfo.getId())
|
||||
.setLevle(1)
|
||||
.setAnnouce(guildInfo.getAnnounce())
|
||||
.setName(guildInfo.getName())
|
||||
.setJoinType(guildInfo.getJoinType())
|
||||
.setMaxNum(30)
|
||||
.setLevle(guildInfo.getLevelTime())
|
||||
.setTotalNum(1).build();
|
||||
.setLevle(guildInfo.getLevel())
|
||||
.setExp(guildInfo.getExp())
|
||||
.setTotalNum(guildInfo.getTotalMembers())
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue