礼包继承类型转换bug修复

master_longzhu
grimm 2024-08-20 16:05:22 +08:00
parent b527298c7f
commit c068430102
1 changed files with 16 additions and 13 deletions

View File

@ -757,24 +757,22 @@ public class BuyGoodsNewLogic {
boolean needChange = refreshWelfareState(user); boolean needChange = refreshWelfareState(user);
NewRechargeInfo rechargeInfo = user.getPlayerInfoManager().getNewRechargeInfo(); NewRechargeInfo rechargeInfo = user.getPlayerInfoManager().getNewRechargeInfo();
Set<Integer> needRemoveIds = new HashSet<>(); Set<Integer> needRemoveIds = new HashSet<>();
ArrayList<Integer> list = new ArrayList<>();
// 永久礼包 // 永久礼包
ArrayList<AbstractWelfareBag> list = new ArrayList<>(rechargeInfo.getPerpetualMap().values()); list.addAll(rechargeInfo.getPerpetualMap().keySet());
// 活动礼包 // 活动礼包
list.addAll(rechargeInfo.getTimeLimitMap().values()); list.addAll(rechargeInfo.getTimeLimitMap().keySet());
// 领取礼包 // 领取礼包
list.addAll(rechargeInfo.getReceiveMap().values()); list.addAll(rechargeInfo.getReceiveMap().keySet());
// 推送礼包 // 推送礼包
list.addAll(rechargeInfo.getPushMap().values()); list.addAll(rechargeInfo.getPushMap().keySet());
// gm礼包 // gm礼包
list.addAll(rechargeInfo.getGmSingleMap().values()); list.addAll(rechargeInfo.getGmSingleMap().keySet());
for(AbstractWelfareBag bag : list){ for(int goodId : list){
if (bag == null || !bag.isOpen()){ CommonProto.GiftGoodsInfo giftGoodsInfo = buildGoodsInfo(user, goodId);
continue;
}
CommonProto.GiftGoodsInfo giftGoodsInfo = buildGoodsInfo(bag);
if (giftGoodsInfo == null) { if (giftGoodsInfo == null) {
needRemoveIds.add(bag.getModId()); needRemoveIds.add(goodId);
}else { }else {
giftGoodsInfoList.add(giftGoodsInfo); giftGoodsInfoList.add(giftGoodsInfo);
} }
@ -898,12 +896,17 @@ public class BuyGoodsNewLogic {
return null; return null;
} }
public static CommonProto.GiftGoodsInfo buildGoodsInfo(AbstractWelfareBag bag){ public static CommonProto.GiftGoodsInfo buildGoodsInfo(User user, int goodsId){
SRechargeCommodityNewConfig configById = SRechargeCommodityNewConfig.getConfigById(bag.getModId()); SRechargeCommodityNewConfig configById = SRechargeCommodityNewConfig.getConfigById(goodsId);
// 配置表里已删除的礼包 删除 // 配置表里已删除的礼包 删除
if (configById == null) { if (configById == null) {
return null; return null;
} }
RechargeHandler rechargeHandler = getRechargeHandler(configById.getOtype());
AbstractWelfareBag bag = rechargeHandler.getBag(user, goodsId);
if (bag == null || !bag.isOpen()){
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());