diff --git a/serverlogic/src/main/java/com/ljsd/jieling/globals/Global.java b/serverlogic/src/main/java/com/ljsd/jieling/globals/Global.java index c50bb723c..c40ff7737 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/globals/Global.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/globals/Global.java @@ -68,7 +68,10 @@ public interface Global { int VIPSTORID = 20; //vip商店id - int LUXURYMONTHCARDID =11;//6豪华月卡 + int LUXURYMONTHCARDID =11;//6豪华月卡 废弃 改版 int WEEKCARDID = 10; //月卡 + + int MONTHCARDID =1;//1月卡 + int LMONTHCARDID =2;//2豪华月卡 } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java index fa1c87577..f6c2b4c46 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java @@ -167,6 +167,7 @@ public class GetPlayerInfoHandler extends BaseHandler{ .setAmount(rechargeInfo.getSaveAmt()) .setVipDaily(playerInfoManager.getHadTakeDailyBoxVip()) .setMissingRefreshCount(vipPrivilageValue) + .addAllMonthinfos(PlayerLogic.getInstance().getMonthCardInfo(user)) .build(); try { MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_PLAYERINFO_RESPONSE_VALUE, getPlayerInfoResponse, true); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/vip/MonthTakeDailyHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/vip/MonthTakeDailyHandler.java new file mode 100644 index 000000000..eea109724 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/vip/MonthTakeDailyHandler.java @@ -0,0 +1,47 @@ +package com.ljsd.jieling.handler.vip; + +import com.ljsd.jieling.exception.ErrorCode; +import com.ljsd.jieling.exception.ErrorCodeException; +import com.ljsd.jieling.globals.BIReason; +import com.ljsd.jieling.handler.BaseHandler; +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.protocols.CommonProto; +import com.ljsd.jieling.protocols.MessageTypeProto; +import com.ljsd.jieling.protocols.PlayerInfoProto; +import com.ljsd.jieling.util.ItemUtil; +import com.ljsd.jieling.util.MessageUtil; +import config.SMonthcardConfig; +import manager.STableManager; + +/** + * Description: des + * Author: zsx + * CreateDate: 2020/3/30 14:00 + */ +public class MonthTakeDailyHandler extends BaseHandler { + + @Override + public MessageTypeProto.MessageType getMessageCode() { + return MessageTypeProto.MessageType.MONTHCARD_TAKE_DAILY_REQUEST; + } + + @Override + public void processWithProto(ISession iSession, PlayerInfoProto.TakeMothDilyRequest proto) throws Exception { + User user = UserManager.getUser(iSession.getUid()); + + SMonthcardConfig config = STableManager.getConfig(SMonthcardConfig.class).get(proto.getType()); + if(null == config){ + throw new ErrorCodeException(ErrorCode.CFG_NULL); + } + + if(user.getPlayerInfoManager().getMonthCardDailyTake().contains(proto.getType())){ + throw new ErrorCodeException(ErrorCode.newDefineCode("had taked the month daily reward")); + } + user.getPlayerInfoManager().addMonthCardDailyTake(proto.getType()); + CommonProto.Drop.Builder drop = ItemUtil.drop(user, config.getBaseReward(), BIReason.TAKE_VIP_DAILY_REWARD); + PlayerInfoProto.TakeMothDilyResponse build = PlayerInfoProto.TakeMothDilyResponse.newBuilder().setDrop(drop).build(); + MessageUtil.sendMessage(iSession, 1,MessageTypeProto.MessageType.MONTHCARD_TAKE_DAILY_RESPONSE_VALUE, build, true); + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/vip/VipTakeDailyHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/vip/VipTakeDailyHandler.java index 9069d3dd6..65107b73a 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/vip/VipTakeDailyHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/vip/VipTakeDailyHandler.java @@ -35,7 +35,7 @@ public class VipTakeDailyHandler extends BaseHandler reds = new CopyOnWriteArraySet<>(); private RechargeInfo rechargeInfo; + private Map monthCard = new HashMap<>();//月卡信息 + private Set monthCardDailyTake = new HashSet<>(); private int headFrame; @@ -578,4 +578,50 @@ public class PlayerManager extends MongoBase { updateString("sex", sex); this.sex = sex; } + + public Map getMonthCard() { + Iterator> iterator = monthCard.entrySet().iterator(); + while (iterator.hasNext()){ + Map.Entry map = iterator.next(); + Integer key = map.getKey(); + SMonthcardConfig config = STableManager.getConfig(SMonthcardConfig.class).get(key); + if(null==config){ + iterator.remove(); + continue; + } + if(((int)(System.currentTimeMillis()/1000)-map.getValue())>24*60*60*config.getContiueDays()){ + iterator.remove(); + if(key== Global.MONTHCARDID){ + rechargeInfo.setMonthSaveAmt(0); + }else if(key ==Global.LMONTHCARDID){ + rechargeInfo.setSmonthSaveAmt(0); + } + } + } + updateString("monthCard",monthCard); + return monthCard; + } + + public void setMonthCard(Map monthCard) { + updateString("monthCard",monthCard); + this.monthCard = monthCard; + } + public void putMonthCard(Integer id, Integer time) { + this.monthCard.put(id, time); + updateString("monthCard",this.monthCard); + } + + public Set getMonthCardDailyTake() { + return monthCardDailyTake; + } + public void addMonthCardDailyTake(Integer integer) { + this.monthCardDailyTake.add(integer); + updateString("monthCardDailyTake",monthCardDailyTake); + } + + public void setMonthCardDailyTake(Set monthCardDailyTake) { + this.monthCardDailyTake = monthCardDailyTake; + updateString("monthCardDailyTake",monthCardDailyTake); + } + } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/RechargeInfo.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/RechargeInfo.java index 6b5a03070..4cc10e184 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/RechargeInfo.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/RechargeInfo.java @@ -11,6 +11,8 @@ public class RechargeInfo extends MongoBase{ private int saveAmt;//累计充值 private int soulCrystalAmt;//累计充值购买魂晶 + private int monthSaveAmt ; //月卡累计总额 + private int smonthSaveAmt ; //豪华月卡累计总额 private int isFirst; private long createTime; private int hadBuyFound; @@ -237,4 +239,22 @@ public class RechargeInfo extends MongoBase{ public Map getRefreshBagMap() { return refreshBagMap; } + + public int getMonthSaveAmt() { + return monthSaveAmt; + } + + public void setMonthSaveAmt(int monthSaveAmt) { + this.monthSaveAmt = monthSaveAmt; + updateString("monthSaveAmt",smonthSaveAmt); + } + + public int getSmonthSaveAmt() { + return smonthSaveAmt; + } + + public void setSmonthSaveAmt(int smonthSaveAmt) { + this.smonthSaveAmt = smonthSaveAmt; + updateString("smonthSaveAmt",smonthSaveAmt); + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/player/PlayerLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/player/PlayerLogic.java index da9ce2946..76156db9f 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/player/PlayerLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/player/PlayerLogic.java @@ -372,6 +372,7 @@ public class PlayerLogic { if (!TimeUtils.isSameMonthFiveWithNow(user.getPlayerInfoManager().getOffLineTime())) { user.getPlayerInfoManager().getPhoneBindInfo().setState(0); } + user.getPlayerInfoManager().setMonthCardDailyTake(new HashSet<>());//刷新月卡信息 if(null!=fBuilder){ PhoneBindInfo phoneBindInfo = user.getPlayerInfoManager().getPhoneBindInfo(); fBuilder.setPlayerBindPhone(CommonProto.PlayerBindPhone.newBuilder().setPhoneNum(phoneBindInfo.getPhoneNum()).setState(phoneBindInfo.getState()).build()); @@ -901,4 +902,18 @@ public class PlayerLogic { } return maxCount; } + + public List getMonthCardInfo(User user) { + List cardInfos = new LinkedList<>(); + PlayerManager playerInfoManager = user.getPlayerInfoManager(); + RechargeInfo rechargeInfo = playerInfoManager.getRechargeInfo(); + STableManager.getConfig(SMonthcardConfig.class).forEach((integer, sMonthcardConfig) -> { + int state = playerInfoManager.getMonthCardDailyTake().contains(integer)?1:0; + int saveAmt = integer==1?rechargeInfo.getMonthSaveAmt():rechargeInfo.getSmonthSaveAmt(); + int time = playerInfoManager.getMonthCard().getOrDefault(integer,0); + cardInfos.add(CommonProto.MonthCardInfo.newBuilder().setId(integer).setEndingTime(time).setState(state).setTotleAmt(saveAmt).build()); + }); + + return cardInfos; + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/BuyGoodsLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/BuyGoodsLogic.java index d2bcc2767..30e4646e1 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/BuyGoodsLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/BuyGoodsLogic.java @@ -119,15 +119,40 @@ public class BuyGoodsLogic { needSendMail = true; } - if( (type == GiftGoodsType.MONTHCARD || type == GiftGoodsType.LUXURYMONTHCARD ) && nowTime=monthline){ + sendneed=true; + user.getPlayerInfoManager().getMonthCard().put(Global.MONTHCARDID, (int) (System.currentTimeMillis() / 1000)); + } + if(rechargeInfo.getSmonthSaveAmt()=lmonthline){ + sendneed=true; + user.getPlayerInfoManager().getMonthCard().put(Global.LMONTHCARDID, (int) (System.currentTimeMillis() / 1000)); + } + if(sendneed){ + ISession session = OnlineUserManager.sessionMap.get(uid); + if(session!=null){ + PlayerInfoProto.MonthCardIndication monthCardIndication = PlayerInfoProto.MonthCardIndication.newBuilder().addAllMonthinfos(PlayerLogic.getInstance().getMonthCardInfo(user)).build(); + MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.MONTHCARD_INDICATION_VALUE, monthCardIndication, true); + } + } + + } + triggerEvent(user,sRechargeCommodityConfig,nowTime); int[][] baseReward = sRechargeCommodityConfig.getBaseReward(); int length = baseReward.length; @@ -186,8 +211,10 @@ public class BuyGoodsLogic { } } rechargeInfo.setSaveAmt(price+saveAmt); - user.getPlayerInfoManager().addRechargedaily(price); + rechargeInfo.setMonthSaveAmt(price+rechargeInfo.getMonthSaveAmt()); + rechargeInfo.setSmonthSaveAmt(price+rechargeInfo.getSmonthSaveAmt()); + //TODO 用事件分发 ActivityLogic.getInstance().updateActivityMissionProgress(user, ActivityType.RechargeTotal,price); ActivityLogic.getInstance().updateActivityMissionProgress(user, ActivityType.LUCKYCAT,price); @@ -208,6 +235,8 @@ public class BuyGoodsLogic { } PlayerInfoProto.RefreshRechargeIndication.Builder builder = PlayerInfoProto.RefreshRechargeIndication.newBuilder(); builder.setAmount(rechargeInfo.getSaveAmt()); + builder.setMonthSaveAmt(rechargeInfo.getMonthSaveAmt()); + builder.setSmonthSaveAmt(rechargeInfo.getSmonthSaveAmt()); MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.REFRESH_RECHARGE_INDICATION_VALUE,builder.build(),true); } @@ -308,7 +337,9 @@ public class BuyGoodsLogic { } MessageUtil.sendIndicationMessage(OnlineUserManager.getSessionByUid(user.getId()), 1, MessageTypeProto.MessageType.PRIVILLEGE_ADD_INDICATION_VALUE, indication.build(), true); } - if(goodsType == GiftGoodsType.LUXURYMONTHCARD){ + + + if(user.getPlayerInfoManager().getMonthCard().containsKey(Global.LMONTHCARDID) ){ PlayerLogic.getInstance().sendDayilyMail(user,goodsType); int starReward = user.getMapManager().getStarReward(); if(starReward == 0){ @@ -329,7 +360,9 @@ public class BuyGoodsLogic { String title = SErrorCodeEerverConfig.getI18NMessage("recharge_6_stars_title"); String content = SErrorCodeEerverConfig.getI18NMessage("recharge_6_stars_txt"); MailLogic.getInstance().sendMail(user.getId(),title,content,rewardStr.toString(),nowTime, Global.MAIL_EFFECTIVE_TIME); - }else if(goodsType == GiftGoodsType.MONTHCARD || goodsType == GiftGoodsType.WEEKCARD || goodsType == GiftGoodsType.FOUND_ONE || goodsType == GiftGoodsType.FOUND_TWO){ + } + + if(user.getPlayerInfoManager().getMonthCard().containsKey(Global.MONTHCARDID) || goodsType == GiftGoodsType.WEEKCARD || goodsType == GiftGoodsType.FOUND_ONE || goodsType == GiftGoodsType.FOUND_TWO){ PlayerLogic.getInstance().sendDayilyMail(user,goodsType); } @@ -522,7 +555,4 @@ public class BuyGoodsLogic { user.getPlayerInfoManager().getRechargeInfo().setRefreshBagMap(refreshBagMap); } - - - } diff --git a/tablemanager/src/main/java/config/SMonthcardConfig.java b/tablemanager/src/main/java/config/SMonthcardConfig.java new file mode 100644 index 000000000..e682b78c5 --- /dev/null +++ b/tablemanager/src/main/java/config/SMonthcardConfig.java @@ -0,0 +1,67 @@ +package config; + +import manager.STableManager; +import manager.Table; + +import java.util.Map; + +@Table(name ="MonthcardConfig") +public class SMonthcardConfig implements BaseConfig { + + private int id; + + private String name; + + private int price; + + private int[][] baseReward; + + private int contiueDays; + + private int time; + + private String startTime; + + private String endtime; + + + @Override + public void init() throws Exception { + + } + + + public int getId() { + return id; + } + + public String getName() { + return name; + } + + public int getPrice() { + return price; + } + + public int[][] getBaseReward() { + return baseReward; + } + + public int getContiueDays() { + return contiueDays; + } + + public int getTime() { + return time; + } + + public String getStartTime() { + return startTime; + } + + public String getEndtime() { + return endtime; + } + + +} \ No newline at end of file