支持删 RechargeCommodityConfig

back_recharge
jiahuiwen 2021-11-25 17:41:32 +08:00
parent 31859110b4
commit af0b9547c5
2 changed files with 73 additions and 9 deletions

View File

@ -496,7 +496,7 @@ public class BuyGoodsNewLogic {
} }
}else{ }else{
if(bag.getType() == RechargeType.push.getType() && !bag.isOpen()){ if(bag.getType() == RechargeType.push.getType() && !bag.isOpen()){
user.getPlayerInfoManager().getNewRechargeInfo().removePush((PushWelfareBag) bag); user.getPlayerInfoManager().getNewRechargeInfo().removePush(bag.getModId());
return true; return true;
} }
if(bag.getType() == RechargeType.timeLimit.getType()){ if(bag.getType() == RechargeType.timeLimit.getType()){
@ -586,7 +586,7 @@ public class BuyGoodsNewLogic {
bag.setLastBuyTime(0); bag.setLastBuyTime(0);
bag.setBuyTimes(0); bag.setBuyTimes(0);
if(bag.getType() == RechargeType.push.getType()){ if(bag.getType() == RechargeType.push.getType()){
user.getPlayerInfoManager().getNewRechargeInfo().removePush((PushWelfareBag) bag); user.getPlayerInfoManager().getNewRechargeInfo().removePush(bag.getModId());
} }
} }
@ -640,26 +640,71 @@ public class BuyGoodsNewLogic {
User user = UserManager.getUser(uid); User user = UserManager.getUser(uid);
boolean needChange = refreshWelfareState(user); boolean needChange = refreshWelfareState(user);
NewRechargeInfo rechargeInfo = user.getPlayerInfoManager().getNewRechargeInfo(); NewRechargeInfo rechargeInfo = user.getPlayerInfoManager().getNewRechargeInfo();
Set<Integer> needRemoveIds = new HashSet<>();
for(AbstractWelfareBag bag : rechargeInfo.getPerpetualMap().values()){ for(AbstractWelfareBag bag : rechargeInfo.getPerpetualMap().values()){
if(bag.isOpen()){ if(bag.isOpen()){
giftGoodsInfoList.add(buildGoodsInfo(bag)); CommonProto.GiftGoodsInfo giftGoodsInfo = buildGoodsInfo(bag);
if (giftGoodsInfo == null) {
needRemoveIds.add(bag.getModId());
continue;
}
giftGoodsInfoList.add(giftGoodsInfo);
} }
} }
if (!needRemoveIds.isEmpty()) {
for (Integer needRemoveId : needRemoveIds) {
rechargeInfo.removePerpetualMap(needRemoveId);
}
needRemoveIds.clear();
}
for(AbstractWelfareBag bag : rechargeInfo.getTimeLimitMap().values()){ for(AbstractWelfareBag bag : rechargeInfo.getTimeLimitMap().values()){
if(bag.isOpen()){ if(bag.isOpen()){
giftGoodsInfoList.add(buildGoodsInfo(bag)); CommonProto.GiftGoodsInfo giftGoodsInfo = buildGoodsInfo(bag);
if (giftGoodsInfo == null) {
needRemoveIds.add(bag.getModId());
continue;
}
giftGoodsInfoList.add(giftGoodsInfo);
} }
} }
if (!needRemoveIds.isEmpty()) {
for (Integer needRemoveId : needRemoveIds) {
rechargeInfo.removeTimeLimitMap(needRemoveId);
}
needRemoveIds.clear();
}
for(AbstractWelfareBag bag : rechargeInfo.getReceiveMap().values()){ for(AbstractWelfareBag bag : rechargeInfo.getReceiveMap().values()){
if(bag.isOpen()){ if(bag.isOpen()){
giftGoodsInfoList.add(buildGoodsInfo(bag)); CommonProto.GiftGoodsInfo giftGoodsInfo = buildGoodsInfo(bag);
if (giftGoodsInfo == null) {
needRemoveIds.add(bag.getModId());
continue;
}
giftGoodsInfoList.add(giftGoodsInfo);
} }
} }
if (!needRemoveIds.isEmpty()) {
for (Integer needRemoveId : needRemoveIds) {
rechargeInfo.removeReceiveMap(needRemoveId);
}
needRemoveIds.clear();
}
for(AbstractWelfareBag bag : rechargeInfo.getPushMap().values()){ for(AbstractWelfareBag bag : rechargeInfo.getPushMap().values()){
if(bag.isOpen()){ if(bag.isOpen()){
giftGoodsInfoList.add(buildGoodsInfo(bag)); CommonProto.GiftGoodsInfo giftGoodsInfo = buildGoodsInfo(bag);
if (giftGoodsInfo == null) {
needRemoveIds.add(bag.getModId());
continue;
}
giftGoodsInfoList.add(giftGoodsInfo);
} }
} }
if (!needRemoveIds.isEmpty()) {
for (Integer needRemoveId : needRemoveIds) {
rechargeInfo.removePush(needRemoveId);
}
needRemoveIds.clear();
}
giftGoodsInfoList.sort((o1, o2) -> { giftGoodsInfoList.sort((o1, o2) -> {
if(o1.getGoodsId() > o2.getGoodsId()){ if(o1.getGoodsId() > o2.getGoodsId()){
return 1; return 1;
@ -770,6 +815,10 @@ public class BuyGoodsNewLogic {
} }
public static CommonProto.GiftGoodsInfo buildGoodsInfo(AbstractWelfareBag bag){ public static CommonProto.GiftGoodsInfo buildGoodsInfo(AbstractWelfareBag bag){
SRechargeCommodityNewConfig configById = SRechargeCommodityNewConfig.getConfigById(bag.getModId());
if (configById == null) {
return null;
}
CommonProto.GiftGoodsInfo.Builder builder = CommonProto.GiftGoodsInfo.newBuilder(); CommonProto.GiftGoodsInfo.Builder builder = CommonProto.GiftGoodsInfo.newBuilder();
builder.setGoodsId(bag.getModId()); builder.setGoodsId(bag.getModId());
builder.setBuyTimes(bag.getBuyTimes()); builder.setBuyTimes(bag.getBuyTimes());

View File

@ -204,9 +204,24 @@ public class NewRechargeInfo extends MongoBase {
updateString("pushMap."+bag.getModId(),bag); updateString("pushMap."+bag.getModId(),bag);
} }
public void removePush(PushWelfareBag bag){ public void removePerpetualMap(int modId){
pushMap.remove(bag.getModId()); perpetualMap.remove(modId);
removeString(getMongoKey() + ".pushMap."+bag.getModId()); removeString(getMongoKey() + ".perpetualMap."+modId);
}
public void removeTimeLimitMap(int modId){
timeLimitMap.remove(modId);
removeString(getMongoKey() + ".timeLimitMap."+modId);
}
public void removeReceiveMap(int modId){
receiveMap.remove(modId);
removeString(getMongoKey() + ".receiveMap."+modId);
}
public void removePush(int modId){
pushMap.remove(modId);
removeString(getMongoKey() + ".pushMap."+modId);
} }
public int getMainLineLost() { public int getMainLineLost() {