福利红包

back_recharge
mengchengzhen 2021-05-21 18:52:19 +08:00
parent 97d32d93dd
commit 4a2df26e2e
13 changed files with 167 additions and 9 deletions

View File

@ -168,7 +168,8 @@ public enum ErrorCode implements IErrorCode {
HONGMENG_ING(139,"英雄在鸿蒙阵中,操作失败"),
LOCK_FILL(138,"锁定数量已满,无法刷新"),
LOCK_FILL(140,"锁定数量已满,无法刷新"),
REDPACKET_DAILY_LIMIT(141,"今日福利红包已达领取上限"),
;
private static final Set<Integer> CodeSet = new HashSet<>();

View File

@ -18,6 +18,7 @@ import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.GlobalSystemControl;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.family.GuildLogic;
import com.ljsd.jieling.logic.mission.GameEvent;
import com.ljsd.jieling.logic.player.PlayerLogic;
import com.ljsd.jieling.logic.question.QuestionLogic;
@ -70,7 +71,7 @@ public class GetPlayerInfoHandler extends BaseHandler{
PlayerManager playerInfoManager = user.getPlayerInfoManager();
ActivityLogic.getInstance().flushForLogin(user,iSession);
GlobalDataManaager.checkNeedReFlush(iSession,user,null);
GuildLogic.sendWelfareRedPacketInfo(user);
BuyGoodsNewLogic.refreshWelfareState(user);
// Poster.getPoster().dispatchEvent(new UserOnlineEvent(userId));
user.getUserMissionManager().onGameEvent(user, GameEvent.LOGIN_GAME,0);
@ -219,6 +220,7 @@ public class GetPlayerInfoHandler extends BaseHandler{
.addAllUserMountList(CBean2Proto.getUserMountList(user))
.addAllUserSkinList(CBean2Proto.getUserSkinList(user))
.addAllUserTitleList(CBean2Proto.getUserTitleList(user))
.setDailyredpack(playerInfoManager.getDailyWelfareRedPacket())
.build();
ReportUtil.onReportEvent(user, ReportEventEnum.APP_LOGIN.getType());
try {

View File

@ -40,6 +40,8 @@ import com.ljsd.jieling.logic.player.PlayerLogic;
import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank;
import com.ljsd.jieling.logic.rank.RankContext;
import com.ljsd.jieling.logic.rank.RankEnum;
import com.ljsd.jieling.logic.redpacket.WelfareRedPackEvent;
import com.ljsd.jieling.logic.redpacket.WelfareRedPacketType;
import com.ljsd.jieling.logic.store.BuyGoodsNewLogic;
import com.ljsd.jieling.logic.store.StoreLogic;
import com.ljsd.jieling.logic.store.StoreType;
@ -2288,6 +2290,8 @@ public class MapLogic {
itemIdList.add(item.getItemId());
itemNumList.add((int)item.getItemNum());
});
//发福利红包
Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.soul_demon.getType(),checkFightId));
ReportUtil.onReportEvent(user,ReportEventEnum.COMPLETE_XINMO.getType(),checkFightId,sFloodConfig.getMonster(),MonsterUtil.getMonsterForce(new int[]{sFloodConfig.getMonster()}),new Date(),"",itemIdList,itemNumList,"成功");
}

View File

@ -2,7 +2,14 @@ package com.ljsd.jieling.handler.map.miniGame;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.handler.map.MapGameInfo;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.redpacket.WelfareRedPackEvent;
import com.ljsd.jieling.logic.redpacket.WelfareRedPacketType;
import com.ljsd.jieling.logic.store.BuyGoodsNewLogic;
import com.ljsd.jieling.network.session.ISession;
import config.SSpiritAnimal;
import rpc.protocols.CommonProto;
import rpc.protocols.MapInfoProto;
import com.ljsd.jieling.util.ItemUtil;
@ -63,7 +70,9 @@ public class CircleGame extends ColorGame{
//todo 需要告诉前端一个拿到的id
STrialGameConfig config = STrialGameConfig.trialGameConfigMap.get(id[0]);
CommonProto.Drop.Builder drop = ItemUtil.drop(user, new int[][]{{config.getRewardID(), config.getMin()}}, BIReason.MAP_EVENET_REWARD);
if(drop.getPokemonList().size()>0){
fiveStarPokemonPushByRandom(user,drop.getPokemonList().get(0).getTempId());
}
MapInfoProto.MapGameUpdateResponse response = MapInfoProto.MapGameUpdateResponse.newBuilder()
.setGameStatus(0)
@ -73,4 +82,13 @@ public class CircleGame extends ColorGame{
user.getMapManager().updateMapGameInfo(new MapGameInfo());
return response;
}
private void fiveStarPokemonPushByRandom(User user,int itemId) throws Exception{
SSpiritAnimal ssa = SSpiritAnimal.mapConfig.get(itemId);
if(ssa != null && ssa.getQuality()==5){
Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.game_pokemon.getType(),1));
ISession session = OnlineUserManager.getSessionByUid(user.getId());
BuyGoodsNewLogic.openPush(session,user,8,5,1);
}
}
}

View File

@ -15,6 +15,7 @@ import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
import com.ljsd.jieling.logic.GlobalDataManaager;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.fight.*;
@ -24,6 +25,8 @@ import com.ljsd.jieling.logic.mail.MailLogic;
import com.ljsd.jieling.logic.mission.GameEvent;
import com.ljsd.jieling.logic.mission.event.MissionEventDistributor;
import com.ljsd.jieling.logic.player.PlayerLogic;
import com.ljsd.jieling.logic.redpacket.WelfareRedPackEvent;
import com.ljsd.jieling.logic.redpacket.WelfareRedPacketType;
import com.ljsd.jieling.network.server.GlobalidHelper;
import com.ljsd.jieling.network.server.WorldHelper;
import com.ljsd.jieling.network.session.ISession;
@ -565,6 +568,9 @@ public class ArenaLogic {
if(!"".equals(rewardByRank)){
MailLogic.getInstance().sendMail(user.getId(),title,content,rewardByRank,nowTime, Global.MAIL_EFFECTIVE_TIME);
}
if(rank == 1){
Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.arena_rank.getType(),1));
}
}
MongoUtil.getInstence().lastUpdate();
}

View File

@ -19,6 +19,7 @@ import com.ljsd.jieling.ktbeans.ReportEventEnum;
import com.ljsd.jieling.ktbeans.ReportUtil;
import com.ljsd.jieling.logic.GlobalDataManaager;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.arena.ArenaLogic;
import com.ljsd.jieling.logic.blood.BloodLogic;
import com.ljsd.jieling.logic.dao.*;
@ -28,6 +29,8 @@ import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.logic.mail.MailLogic;
import com.ljsd.jieling.logic.mission.GameEvent;
import com.ljsd.jieling.logic.player.PlayerLogic;
import com.ljsd.jieling.logic.redpacket.WelfareRedPackEvent;
import com.ljsd.jieling.logic.redpacket.WelfareRedPacketType;
import com.ljsd.jieling.network.server.ProtocolsManager;
import com.ljsd.jieling.network.session.ISession;
import rpc.protocols.ArenaInfoProto;
@ -415,6 +418,9 @@ public class ChampionshipLogic {
String title = SErrorCodeEerverConfig.getI18NMessage("champion_reward_title");
String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("champion_reward_txt", new Object[]{sChampionshipReward.getTitleDesc()},new int[]{1},"#");
MailLogic.getInstance().sendMail(user.getId(), title, content, ItemUtil.getMailReward(sChampionshipReward.getSeasonReward()), nowTime, Global.MAIL_EFFECTIVE_TIME);
if(rank == 1){
Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.top_match_rank.getType(),1));
}
}
}catch (Exception e){
LOGGER.info("Exception e = "+"size"+ arenaRankInfo.size()+ e.toString());

View File

@ -151,6 +151,8 @@ public class PlayerManager extends MongoBase {
private Map<Integer,Integer> welfareRedPackets = new HashMap<>();
private int dailyWelfareRedPacket;
public PlayerManager(){
this.setRootCollection(User._COLLECTION_NAME);
@ -1049,4 +1051,13 @@ public class PlayerManager extends MongoBase {
this.newRechargeInfo = newRechargeInfo;
updateString("newRechargeInfo", newRechargeInfo);
}
public int getDailyWelfareRedPacket() {
return dailyWelfareRedPacket;
}
public void setDailyWelfareRedPacket(int dailyWelfareRedPacket) {
this.dailyWelfareRedPacket = dailyWelfareRedPacket;
updateString("dailyWelfareRedPacket",dailyWelfareRedPacket);
}
}

View File

@ -25,6 +25,8 @@ import com.ljsd.jieling.logic.player.PlayerLogic;
import com.ljsd.jieling.logic.rank.RankContext;
import com.ljsd.jieling.logic.rank.RankEnum;
import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank;
import com.ljsd.jieling.logic.redpacket.WelfareRedPackEvent;
import com.ljsd.jieling.logic.redpacket.WelfareRedPacketType;
import com.ljsd.jieling.logic.store.StoreLogic;
import com.ljsd.jieling.network.server.ProtocolsManager;
import com.ljsd.jieling.network.session.ISession;
@ -620,7 +622,7 @@ public class GuildLogic {
}
targetUser.getGuildMyInfo().setJoinTime(TimeUtils.nowInt());
ReportUtil.onReportEvent(targetUser, ReportEventEnum.JOIN_GUILD.getType(),String.valueOf(guildInfo.getId()),guildInfo.getName(),guildInfo.getLevel(),guildInfo.getTotalMembers());
sendNewGuyRedPacket(guildInfo);
}
/**
@ -1171,21 +1173,46 @@ public class GuildLogic {
}else{
price+=scoreById;
}
if(config.getBaseType() == 2){
if(config.getBaseType() == 2){//福利红包
Map<Integer,Integer> map = user.getPlayerInfoManager().getWelfareRedPackets();
int old = map.get(redId);
SGuildRedPackConfig redPacket = SGuildRedPackConfig.sGuildRedPackConfigMap.get(redId);
if(redPacket.getRuleType() != 1){
map.put(redId,-1);
if(redPacket.getRuleType() == 3){
openNext(map,redPacket.getGroupId(),redId);
}
}else{
map.put(redId,old-1);
}
user.getPlayerInfoManager().setWelfareRedPackets(map);
PlayerInfoProto.WelfareRedPacketSendResponse.Builder build = PlayerInfoProto.WelfareRedPacketSendResponse.newBuilder();
for(Map.Entry<Integer,Integer> entry : map.entrySet()){
if(entry.getValue() >= 0){
build.addRedpacket(CommonProto.WelfareRedPacket.newBuilder().setId(entry.getKey()).setNum(entry.getValue()));
}
}
ISession session = OnlineUserManager.getSessionByUid(user.getId());
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.WELFARE_RED_PACKET_SEND_RESPONSE.getNumber(),build.build());
}
rank.addRank(uid,String.valueOf(user.getPlayerInfoManager().getGuildId()),price);
RedisUtil.getInstence().lSet(RedisKey.getKey("red_remain_list",String.valueOf(increment),false),reward,config.getLastTime());
}
public static void openNext(Map<Integer,Integer> map,int groupId,int cur){
boolean f = false;
for(SGuildRedPackConfig config : SGuildRedPackConfig.welfareRedPackBySerise.get(groupId)){
if(f){
map.put(config.getId(),0);
break;
}
if(config.getId() == cur){
f = true;
}
}
}
/**
*
* @param uid
@ -1237,10 +1264,25 @@ public class GuildLogic {
break;
}
user.getPlayerInfoManager().setWelfareRedPackets(redPacketsMap);
sendWelfareRedPacketInfo(user);
sendWelfareRedPacketInfoIndication(user);
}
public static void sendWelfareRedPacketInfo(User user){
Map<Integer,Integer> redPacketsMap = user.getPlayerInfoManager().getWelfareRedPackets();
if(redPacketsMap.size() == 0){//初始化
initWelfareRedPacketInfo(user);
}
PlayerInfoProto.WelfareRedPacketPush.Builder build = PlayerInfoProto.WelfareRedPacketPush.newBuilder();
for(Map.Entry<Integer,Integer> entry : redPacketsMap.entrySet()){
if(entry.getValue() >= 0){
build.addRedpacket(CommonProto.WelfareRedPacket.newBuilder().setId(entry.getKey()).setNum(entry.getValue()));
}
}
ISession session = OnlineUserManager.getSessionByUid(user.getId());
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.WELFARE_RED_PACKET_INFO.getNumber(),build.build(),true);
}
public static void sendWelfareRedPacketInfoIndication(User user){
Map<Integer,Integer> redPacketsMap = user.getPlayerInfoManager().getWelfareRedPackets();
if(redPacketsMap.size() == 0){//初始化
initWelfareRedPacketInfo(user);
@ -1317,6 +1359,7 @@ public class GuildLogic {
*/
public static void robRedPackage(ISession session, int redId, MessageTypeProto.MessageType messageType) throws Exception{
int uid = session.getUid();
AcceptRedInfo isAlready = RedisUtil.getInstence().getMapValue("red_already_list", String.valueOf(redId), String.valueOf(uid), AcceptRedInfo.class);
if(isAlready!=null){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
@ -1329,6 +1372,17 @@ public class GuildLogic {
if(packInfo==null){
throw new ErrorCodeException(ErrorCode.FAMILY_NULL);
}
//福利红包
if(SGuildRedPackConfig.welfareRedPackIds.contains(packInfo.getTypeId())){
User user = UserManager.getUser(uid);
int dailyGet = user.getPlayerInfoManager().getDailyWelfareRedPacket();
int maxGet = SSpecialConfig.getIntegerValue(SSpecialConfig.WELFAREREDPACKET_LIMIT);
if(dailyGet < maxGet){
user.getPlayerInfoManager().setDailyWelfareRedPacket(dailyGet+1);
}else{
throw new ErrorCodeException(ErrorCode.REDPACKET_DAILY_LIMIT);
}
}
SGuildRedPackConfig config = SGuildRedPackConfig.sGuildRedPackConfigMap.get(packInfo.getTypeId());
int count = Integer.parseInt(String.valueOf(redPackage));
ItemUtil.drop(UserManager.getUser(uid),new int[][]{new int[]{config.getTotalMoney()[0],count}},BIReason.RED_PACKAGE_REWARD);
@ -1647,5 +1701,13 @@ public class GuildLogic {
return true;
}
private static void sendNewGuyRedPacket(GuildInfo guildInfo) throws Exception{
for(int id : guildInfo.getMembers().get(GlobalsDef.CHAIRMAN)){
User user = UserManager.getUser(id);
if(user == null)
continue;
Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.newfish_come.getType(),0));
}
}
}

View File

@ -18,6 +18,7 @@ import com.ljsd.jieling.jbean.ActivityMission;
import com.ljsd.jieling.jbean.ActivityProgressInfo;
import com.ljsd.jieling.ktbeans.ReportEventEnum;
import com.ljsd.jieling.ktbeans.ReportUtil;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.ActivityType;
import com.ljsd.jieling.logic.activity.event.*;
import com.ljsd.jieling.logic.activity.eventhandler.HeroFiveStarGetEventHandler;
@ -29,6 +30,9 @@ import com.ljsd.jieling.logic.fight.passiveSkillCal.PassiveskillCalEnum;
import com.ljsd.jieling.logic.item.ItemLogic;
import com.ljsd.jieling.logic.mission.GameEvent;
import com.ljsd.jieling.logic.player.PlayerLogic;
import com.ljsd.jieling.logic.redpacket.WelfareRedPackEvent;
import com.ljsd.jieling.logic.redpacket.WelfareRedPacketType;
import com.ljsd.jieling.logic.store.BuyGoodsNewLogic;
import com.ljsd.jieling.network.server.ProtocolsManager;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.util.*;
@ -344,6 +348,7 @@ public class HeroLogic{
heroManager.updateRandCount(type,perCount);
CommonProto.Drop.Builder drop = ItemUtil.dropPer(user, resultRandom,BIReason.HERO_RANDOM);
fiveStarPushByRandom(user,resultRandom);
fiveStarPokemonPushByRandom(user,resultRandom);
builder.setDrop(drop);
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.HERO_RAND_RESPONSE_VALUE, builder.build(), true);
// System.out.println(System.currentTimeMillis()-time);
@ -1152,6 +1157,7 @@ public class HeroLogic{
}
String consume = StringUtil.parseArrayToString(consumeMaterial);
Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.hero_star.getType(),targetHero.getStar()));
ReportUtil.onReportEvent(user, ReportEventEnum.HERO_STRENGTHEN.getType(),String.valueOf(targetHero.getTemplateId()),String.valueOf(oldStar),String.valueOf(targetHero.getStar()),consume,reportConsumeHero.toString());
}
@ -2455,6 +2461,9 @@ public class HeroLogic{
if(drop.getHeroList().size()>0){
fiveStarPushByCombine(user,drop.getHero(0).getHeroId(), composeNum);
}
if(drop.getPokemonList().size()>0){
fiveStarPokemonPushByCombine(user,drop.getPokemonList().get(0).getTempId());
}
HeroInfoProto.HeroComposeResponse heroComposeResponse = HeroInfoProto.HeroComposeResponse
.newBuilder()
.setDrop(drop)
@ -3645,7 +3654,7 @@ public class HeroLogic{
consumeBuilder.append(consume[0]).append("#").append(consume[1]);
}
ReportUtil.onReportEvent(user,ReportEventEnum.BEAST_STAR.getType(),pokemon.getTmpId(),oldStar,pokemon.getStar(),consumeBuilder.toString());
BuyGoodsNewLogic.openPush(session,user,9,pokemon.getStar(),1);
}
@ -4562,4 +4571,32 @@ public class HeroLogic{
}
}
/**
*
*/
public static void fiveStarPokemonPushByRandom(User user,int[][] getHeros) throws Exception{
int fiveStarNum = 0;
for(int[] i : getHeros){
SSpiritAnimal ssa = SSpiritAnimal.mapConfig.get(i);
if(ssa != null && ssa.getQuality()==5){
fiveStarNum = 1;
Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.random_pokemon.getType(),1));
}
}
if(fiveStarNum > 0){
ISession session = OnlineUserManager.getSessionByUid(user.getId());
BuyGoodsNewLogic.openPush(session,user,8,5,fiveStarNum);
}
}
/**
*
*/
public static void fiveStarPokemonPushByCombine(User user,int itemId) throws Exception{
SSpiritAnimal ssa = SSpiritAnimal.mapConfig.get(itemId);
if(ssa != null && ssa.getQuality()==5){
ISession session = OnlineUserManager.getSessionByUid(user.getId());
BuyGoodsNewLogic.openPush(session,user,8,5,1);
}
}
}

View File

@ -423,7 +423,7 @@ public class PlayerLogic {
}
}
playerInfoManager.setDailyWelfareRedPacket(0);
}
public void modifyDecoration(ISession session, int type,int decorationId,MessageTypeProto.MessageType messageType) throws Exception {

View File

@ -48,6 +48,8 @@ public class SGuildRedPackConfig implements BaseConfig {
public static Map<Integer, List<SGuildRedPackConfig>> welfareRedPackBySerise;
public static List<Integer> welfareRedPackIds;
@Override
public void init() throws Exception {
sGuildRedPackConfigMap = STableManager.getConfig(SGuildRedPackConfig.class);
@ -55,12 +57,16 @@ public class SGuildRedPackConfig implements BaseConfig {
sWelfareRedPackByRule = new HashMap<>();
welfareRedPackBySerise = new HashMap<>();
welfareRedPackIds = new ArrayList<>();
for(Map.Entry<Integer,SGuildRedPackConfig> entry:sGuildRedPackConfigMap.entrySet()){
int tradeId = entry.getValue().getTradeId();
if(entry.getValue().getBaseType() == 1 && !sGuildRedPackConfigMap.containsKey(tradeId)){
sGuildRedPackByGoodsId.put(tradeId,entry.getValue());
}
if(entry.getValue().getBaseType() == 2 && !sWelfareRedPackByRule.containsKey(entry.getValue().getRuleId())){
if(entry.getValue().getBaseType() == 2){
welfareRedPackIds.add(entry.getKey());
}
if(entry.getValue().getBaseType() == 2 && !sWelfareRedPackByRule.containsKey(entry.getValue().getRuleId()[0])){
sWelfareRedPackByRule.put(entry.getValue().getRuleId()[0],entry.getValue());
}
if(entry.getValue().getRuleType() == 3){

View File

@ -100,6 +100,7 @@ public class SSpecialConfig implements BaseConfig {
public static final String FU_XING = "FuXing";//福星高照可购买天数和可领取天数
public static final String FU_XING_STORE = "FuXingStore";//福星高照购买解锁奖励
public static final String YIJIANGOUMAI = "YiJianGouMai";//一件购买
public static final String WELFAREREDPACKET_LIMIT = "RedPackMaxGainNum";//每日领取红包数量上限
@Override
public void init() throws Exception {

View File

@ -44,15 +44,19 @@ public class SSpiritAnimal implements BaseConfig {
private int[] returnCost;
public static Map<Integer,SSpiritAnimal> pieceConfig;
public static Map<Integer,SSpiritAnimal> mapConfig;
@Override
public void init() throws Exception {
Map<Integer, SSpiritAnimal> config = STableManager.getConfig(SSpiritAnimal.class);
Map<Integer,SSpiritAnimal> pieceConfigTemp = new HashMap<>();
Map<Integer,SSpiritAnimal> tempMap = new HashMap<>();
for(Map.Entry<Integer,SSpiritAnimal> entry :config.entrySet()){
pieceConfigTemp.put(entry.getValue().getPiecesId(),entry.getValue());
tempMap.put(entry.getKey(),entry.getValue());
}
pieceConfig = pieceConfigTemp;
mapConfig = tempMap;
}