储值活动、聊天修改 提交

back_recharge
lvxinran 2021-04-01 13:57:12 +08:00
parent c4b4415e00
commit bfe16940b2
7 changed files with 149 additions and 9 deletions

View File

@ -66,6 +66,13 @@ public class ChatLogic {
case 1: //世界
chatInfoList = MessageCache.worldMsg.getObjs(messageId);
break;
case 2://公会
int guildId = UserManager.getUser(uid).getPlayerInfoManager().getGuildId();
if(guildId!=0&&MessageCache.guildMsg.containsKey(guildId)){
chatInfoList = MessageCache.guildMsg.get(guildId).getObjs(messageId);
}
break;
case 3: //好友
Map<Object, Object> hmget = RedisUtil.getInstence().hmget(GameApplication.serverId + RedisKey.CUser_Chat + uid);
if (hmget != null && hmget.size() != 0){
@ -183,17 +190,21 @@ public class ChatLogic {
break;
case 2: //公会
int guildId = user.getPlayerInfoManager().getGuildId();
messageId = RedisUtil.getInstence().increment(GameApplication.serverId + RedisKey.CHAT_GUILD_MSG_ID +guildId);
if(guildId==0){
throw new ErrorCodeException(ErrorCode.CHAT_NO_FAMILY);
}
chatInfo = CBean2Proto.getChatInfoBuilder(user,message,nowTime,0);
ChatProto.SendChatInfoIndication sendChatInfoIndication = ChatProto.SendChatInfoIndication.newBuilder()
.setChatInfo(chatInfo)
.setType(2)
.build();
GuildLogic.sendIndicationToMember(GuilidManager.guildInfoMap.get(guildId),MessageTypeProto.MessageType.SEND_CHAT_INFO_INDICATION,sendChatInfoIndication);
chatInfo = CBean2Proto.getChatInfoBuilder(user,message,nowTime,messageId);
// = ChatProto.SendChatInfoIndication.newBuilder()
// .setChatInfo(chatInfo)
// .setType(2)
// .build();
MessageCache.addGuildMsg(chatInfo,messageId,guildId);
// GuildLogic.sendIndicationToMember(GuilidManager.guildInfoMap.get(guildId),MessageTypeProto.MessageType.SEND_CHAT_INFO_INDICATION,sendChatInfoIndication);
break;
case 3: //好友
ChatProto.SendChatInfoIndication sendChatInfoIndication = null;
List<Integer> friends = friendManager.getFriends();
if (!friends.contains(friendId)) {
throw new ErrorCodeException(ErrorCode.CHAT_NOT_FRIENDS);

View File

@ -71,7 +71,7 @@ public class LoopQueue<T> {
}
if(needCompareTime){
if( (curTime - queueList[nextIndex].timestamp) >= diffTime){
if(diffTime!=-1&& (curTime - queueList[nextIndex].timestamp) >= diffTime){
break;
}
}

View File

@ -2,13 +2,17 @@ package com.ljsd.jieling.chat.messge;
import rpc.protocols.ChatProto;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class MessageCache {
private static final int capuatiy =200;
private static final int msgInterval = 24*3600*1000;
private static final int perCaught= 20;
private static final int perCaught= 30;
public static LoopQueue worldMsg = new LoopQueue(capuatiy,perCaught,msgInterval);
public static LoopQueue worldMsg = new LoopQueue(capuatiy,perCaught,-1);
public static LoopQueue sysMsg = new LoopQueue(capuatiy,perCaught,msgInterval);
public static Map<Integer,LoopQueue> guildMsg = new ConcurrentHashMap();
public static void addWordMsg(ChatProto.ChatInfo chatInfo,long messageId){
@ -18,5 +22,11 @@ public class MessageCache {
public static void addSystemMsg(ChatProto.ChatInfo chatInfo,long messageId ){
sysMsg.push(chatInfo,messageId);
}
public static void addGuildMsg(ChatProto.ChatInfo chatInfo,long messageId,int guildId){
if(!guildMsg.containsKey(guildId)){
guildMsg.put(guildId,new LoopQueue(capuatiy,perCaught,-1));
}
guildMsg.get(guildId).push(chatInfo,messageId);
}
}

View File

@ -70,6 +70,7 @@ public interface Global {
int VIPSTORID = 20; //vip商店id
int GODSTORID = 57; //vip商店id
int LUCKY_GET= 70;//5000储值
int LUXURYMONTHCARDID =11;//6豪华月卡 废弃 改版
int WEEKCARDID = 10; //月卡

View File

@ -0,0 +1,89 @@
package com.ljsd.jieling.logic.activity;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.jbean.ActivityManager;
import com.ljsd.jieling.jbean.ActivityMission;
import com.ljsd.jieling.jbean.ActivityProgressInfo;
import com.ljsd.jieling.logic.activity.event.IEvent;
import com.ljsd.jieling.logic.activity.event.LuckyGetBuyEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
import config.SActivityRewardConfig;
import rpc.protocols.CommonProto;
import rpc.protocols.PlayerInfoProto;
import util.TimeUtils;
import java.util.*;
/**
* @author lvxinran
* @date 2021/3/30
* @discribe
*/
public class LuckyGetActivity extends AbstractActivity{
public LuckyGetActivity(int id) {
super(id);
Poster.getPoster().listenEvent(this, LuckyGetBuyEvent.class);
}
@Override
public void onEvent(IEvent event) throws Exception {
if (!(event instanceof LuckyGetBuyEvent))
return;
LuckyGetBuyEvent buyEvent = (LuckyGetBuyEvent) event;
ActivityManager activityManager = buyEvent.getUser().getActivityManager();
if(!activityManager.getActivityMissionMap().containsKey(id)){
return;
}
ActivityMission activityMission = activityManager.getActivityMissionMap().get(id);
List<SActivityRewardConfig> sActivityRewardConfigs = SActivityRewardConfig.getsActivityRewardConfigByActivityId(id);
if(sActivityRewardConfigs == null){return;}
//已经激活购买的商品
activityMission.setV(1);
//拿到激活当天0点
long beginOfDay = TimeUtils.getBeginOfDay(TimeUtils.now());
for(SActivityRewardConfig sActivityRewardConfig : sActivityRewardConfigs){
ActivityProgressInfo activityProgressInfo = new ActivityProgressInfo();
activityProgressInfo.setProgrss((int)(beginOfDay/1000)+(sActivityRewardConfig.getValues()[1][1]-1)*(int)(TimeUtils.ONE_DAY/1000));
activityMission.getActivityMissionMap().put(sActivityRewardConfig.getId(), activityProgressInfo);
}
}
public boolean takeReward(ISession session, int missionId) throws Exception {
if(missionId!=-1){
return super.takeReward(session, missionId);
}
User user = UserManager.getUser(session.getUid());
List<int[][]> reward = new ArrayList<>();
getAllMissRewards(user,session,reward);
Map<Integer,Integer> itemMap = new HashMap<>();
reward.forEach(n-> Arrays.stream(n).forEach(m->itemMap.put(m[0],itemMap.getOrDefault(m[0], 0)+m[1])));
int[][] rewardArray = ItemUtil.mapToArray(itemMap);
CommonProto.Drop.Builder drop = ItemUtil.drop(user, rewardArray, BIReason.TAKE_ACTIVITY_REWARD);
PlayerInfoProto.TakeActivityRewardResponse build = PlayerInfoProto.TakeActivityRewardResponse.newBuilder().setDrop(drop).build();
reportTakeActivityReward(user,rewardArray,missionId);
MessageUtil.sendMessage(session, 1, rewardResponseValue, build, true);
return true;
}
@Override
boolean takeRewardsProcess(ISession session, SActivityRewardConfig sActivityRewardConfig, ActivityProgressInfo activityProgressInfo) throws Exception {
if(activityProgressInfo.getProgrss()==0||TimeUtils.nowInt()<activityProgressInfo.getProgrss()){
return false;
}
return true;
}
}

View File

@ -0,0 +1,26 @@
package com.ljsd.jieling.logic.activity.event;
import com.ljsd.jieling.logic.dao.root.User;
/**
* @author lvxinran
* @date 2021/3/30
* @discribe
*/
public class LuckyGetBuyEvent implements IEvent {
private User user;
public LuckyGetBuyEvent(User user) {
this.user = user;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
}

View File

@ -500,6 +500,9 @@ public class StoreLogic implements IEventHandler {
int vipLeve = user.getPlayerInfoManager().getVipLevel();
user.getPlayerInfoManager().setHadTakeLevelBoxVip(vipLeve);
}
if(storeId==Global.LUCKY_GET){
Poster.getPoster().dispatchEvent(new LuckyGetBuyEvent(user));
}
if(sStoreConfig.getOpenPrivilege()!=null){
PlayerInfoProto.PrivilegeIndication.Builder indication = PlayerInfoProto.PrivilegeIndication.newBuilder();
int[] openPrivilege = sStoreConfig.getOpenPrivilege();