福利红包

back_recharge
mengchengzhen 2021-05-19 11:18:46 +08:00
parent d8e16aae9a
commit 97d32d93dd
4 changed files with 172 additions and 2 deletions

View File

@ -13,6 +13,7 @@ import com.ljsd.jieling.logic.activity.ActivityLogic;
import com.ljsd.jieling.logic.activity.FightMainEventHandler;
import com.ljsd.jieling.logic.activity.RemoveEventHeroHandler;
import com.ljsd.jieling.logic.activity.UserLevelEventHandler;
import com.ljsd.jieling.logic.redpacket.WelfareRedPackSendHandler;
import com.ljsd.jieling.logic.activity.eventhandler.ActivityStateChangeHandler;
import com.ljsd.jieling.logic.activity.eventhandler.BuyGoodsDirectHandler;
import com.ljsd.jieling.logic.activity.eventhandler.GuildForceChangeEventHandler;
@ -256,6 +257,7 @@ public class GlobalDataManaager implements IManager {
new RemoveEventHeroHandler();
new FightMainEventHandler();
new BuyGoodsDirectHandler();
new WelfareRedPackSendHandler();
new ActivityStateChangeHandler();
new GuildForceChangeEventHandler();
ChampionshipLogic.minuteCheck(true);

View File

@ -149,6 +149,8 @@ public class PlayerManager extends MongoBase {
private Map<Integer,Integer> situationPass = new HashMap<>();
private Map<Integer,Integer> welfareRedPackets = new HashMap<>();
public PlayerManager(){
this.setRootCollection(User._COLLECTION_NAME);
@ -1011,6 +1013,15 @@ public class PlayerManager extends MongoBase {
updateString("situationPass",situationPass);
}
public Map<Integer, Integer> getWelfareRedPackets() {
return welfareRedPackets;
}
public void setWelfareRedPackets(Map<Integer, Integer> welfareRedPackets) {
this.welfareRedPackets = welfareRedPackets;
updateString("welfareRedPackets",welfareRedPackets);
}
public int getSheJiOpenTime() {
return sheJiOpenTime;
}

View File

@ -1,6 +1,7 @@
package com.ljsd.jieling.logic.family;
import com.google.protobuf.GeneratedMessage;
import com.google.protobuf.Message;
import com.ljsd.GameApplication;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.dataReport.reportBeans_37.ChatContentType;
@ -1161,16 +1162,123 @@ public class GuildLogic {
}
AbstractRank rank = RankContext.getRankEnum(RankEnum.GUILD_RED_PACKAGE_RANK.getType());
double scoreById = rank.getScoreById(uid, String.valueOf(user.getPlayerInfoManager().getGuildId()));
double price = SRechargeCommodityNewConfig.configMap.get(config.getTradeId()).getPrice();
double price = 0;
if(config.getBaseType() == 1){
price = SRechargeCommodityNewConfig.configMap.get(config.getTradeId()).getPrice();
}
if(scoreById==-1||scoreById==0){
price+=TimeUtils.getDoubleTime();
}else{
price+=scoreById;
}
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);
}else{
map.put(redId,old-1);
}
user.getPlayerInfoManager().setWelfareRedPackets(map);
}
rank.addRank(uid,String.valueOf(user.getPlayerInfoManager().getGuildId()),price);
RedisUtil.getInstence().lSet(RedisKey.getKey("red_remain_list",String.valueOf(increment),false),reward,config.getLastTime());
}
/**
*
* @param uid
* @param redId
* @throws Exception
*/
public static void addWelfareRedPacket(int uid,int redId) throws Exception {
User user = UserManager.getUser(uid);
SGuildRedPackConfig config = SGuildRedPackConfig.sGuildRedPackConfigMap.get(redId);
if(config==null || config.getBaseType() != 2){
return;
}
Map<Integer,Integer> redPacketsMap = user.getPlayerInfoManager().getWelfareRedPackets();
switch (config.getRuleType()){
case 1:
if(redPacketsMap.get(config.getId())>0){
if(redPacketsMap.get(config.getId()) < config.getMaxNum()){
redPacketsMap.put(config.getId(),redPacketsMap.get(config.getId())+1);
}
}else{
redPacketsMap.put(config.getId(),1);
}
break;
case 2:
if(redPacketsMap.get(config.getId())>=0){
redPacketsMap.put(config.getId(),1);
}
break;
case 3:
List<SGuildRedPackConfig> serise = SGuildRedPackConfig.welfareRedPackBySerise.get(config.getGroupId());
for(SGuildRedPackConfig c : serise){
if(redPacketsMap.containsKey(c.getId())){
if(redPacketsMap.get(c.getId())>-1){
if(c.getId() == config.getId()){
redPacketsMap.put(c.getId(),1);
break;
}
}else{
continue;
}
}else{
if(c.getId() == config.getId()){
redPacketsMap.put(config.getId(),1);
}else{
break;
}
}
}
break;
}
user.getPlayerInfoManager().setWelfareRedPackets(redPacketsMap);
sendWelfareRedPacketInfo(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.sendIndicationMessage(session,1, MessageTypeProto.MessageType.WELFARE_RED_PACKET_INFO.getNumber(),build.build(),true);
}
public static void initWelfareRedPacketInfo(User user){
Map<Integer,Integer> redPacketsMap = user.getPlayerInfoManager().getWelfareRedPackets();
for(SGuildRedPackConfig config : SGuildRedPackConfig.sWelfareRedPackByRule.values()){
if(config.getRuleType() == 3){
if(config.getGroupId() == 2){
int num = user.getMapManager().getLastMonsterAttack();
for(SGuildRedPackConfig config1 : SGuildRedPackConfig.welfareRedPackBySerise.get(config.getGroupId())){
if(num >= config1.getRuleId()[1]){
redPacketsMap.put(config.getId(),1);
}else{
redPacketsMap.put(config.getId(),0);
break;
}
}
}else{
if(config.getId()==SGuildRedPackConfig.welfareRedPackBySerise.get(config.getGroupId()).get(0).getId())
redPacketsMap.put(config.getId(),0);
}
}else{
redPacketsMap.put(config.getId(),0);
}
}
}
/**
*
* @param session

View File

@ -4,7 +4,9 @@ package config;
import manager.STableManager;
import manager.Table;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Table(name ="GuildRedPackConfig")
@ -28,19 +30,48 @@ public class SGuildRedPackConfig implements BaseConfig {
private int tradeId;
private int baseType;
private int ruleType;
private int maxNum;
private int groupId;
private int[] ruleId;
public static Map<Integer,SGuildRedPackConfig> sGuildRedPackConfigMap;
public static Map<Integer,SGuildRedPackConfig> sGuildRedPackByGoodsId;
public static Map<Integer,SGuildRedPackConfig> sWelfareRedPackByRule;
public static Map<Integer, List<SGuildRedPackConfig>> welfareRedPackBySerise;
@Override
public void init() throws Exception {
sGuildRedPackConfigMap = STableManager.getConfig(SGuildRedPackConfig.class);
sGuildRedPackByGoodsId = new HashMap<>();
sWelfareRedPackByRule = new HashMap<>();
welfareRedPackBySerise = new HashMap<>();
for(Map.Entry<Integer,SGuildRedPackConfig> entry:sGuildRedPackConfigMap.entrySet()){
int tradeId = entry.getValue().getTradeId();
if(!sGuildRedPackConfigMap.containsKey(tradeId)){
if(entry.getValue().getBaseType() == 1 && !sGuildRedPackConfigMap.containsKey(tradeId)){
sGuildRedPackByGoodsId.put(tradeId,entry.getValue());
}
if(entry.getValue().getBaseType() == 2 && !sWelfareRedPackByRule.containsKey(entry.getValue().getRuleId())){
sWelfareRedPackByRule.put(entry.getValue().getRuleId()[0],entry.getValue());
}
if(entry.getValue().getRuleType() == 3){
if(welfareRedPackBySerise.containsKey(entry.getValue().getGroupId())){
welfareRedPackBySerise.get(entry.getValue().getGroupId()).add(entry.getValue());
}else{
List<SGuildRedPackConfig> list = new ArrayList<>();
list.add(entry.getValue());
welfareRedPackBySerise.put(entry.getValue().getGroupId(),list);
}
}
}
}
@ -81,5 +112,23 @@ public class SGuildRedPackConfig implements BaseConfig {
return tradeId;
}
public int getBaseType() {
return baseType;
}
public int getRuleType() {
return ruleType;
}
public int getMaxNum() {
return maxNum;
}
public int getGroupId() {
return groupId;
}
public int[] getRuleId() {
return ruleId;
}
}