推送礼包优化

back_recharge
mengchengzhen 2021-07-01 14:27:56 +08:00
parent a0c902347e
commit 7ed896b78c
4 changed files with 34 additions and 33 deletions

View File

@ -460,10 +460,6 @@ public class BuyGoodsNewLogic {
result = true;
}
}else{
if(bag.getType() == RechargeType.push.getType() && !bag.isOpen()){
user.getPlayerInfoManager().getNewRechargeInfo().removePush((PushWelfareBag) bag);
return true;
}
if(bag.getType() == RechargeType.timeLimit.getType()){
//活动类型特殊处理
for(String[] s : configById.getCondition()){
@ -543,6 +539,15 @@ public class BuyGoodsNewLogic {
return bag;
}
/**
* setPush
*/
public static void setInitPushInfo(PushWelfareBag bag,SRechargeCommodityNewConfig config){
bag.setStartTime(System.currentTimeMillis());
bag.setEndTime(System.currentTimeMillis() + bag.getTime() * TimeUtils.HOUR);
bag.setOpen(true);
}
/**
*
*/
@ -551,7 +556,7 @@ public class BuyGoodsNewLogic {
bag.setLastBuyTime(0);
bag.setBuyTimes(0);
if(bag.getType() == RechargeType.push.getType()){
user.getPlayerInfoManager().getNewRechargeInfo().removePush((PushWelfareBag) bag);
clearPushBag((PushWelfareBag) bag);
}
}
@ -881,36 +886,26 @@ public class BuyGoodsNewLogic {
}else{
info.getTempLimitMap().put(bagId,num);
}
if(isFiveStarBag(bagId) && info.getPushMap().get(bagId) != null){
AbstractWelfareBag bag = info.getPushMap().get(bagId);
bag.setLimit((bag.getLimit()+num)>info.FIVESTARLIMIT?info.FIVESTARLIMIT:(bag.getLimit()+num));
bag.setStartTime(System.currentTimeMillis());
bag.setEndTime(bag.getStartTime() + getTime(bag) * TimeUtils.HOUR);
}else{
SRechargeCommodityNewConfig config = SRechargeCommodityNewConfig.getConfigById(bagId);
AbstractWelfareBag bag = initUnitWF(user,config);
if(num != 0 && num+hasOpen > info.FIVESTARLIMIT){
bag.setLimit(info.FIVESTARLIMIT-hasOpen);
if(info.getPushMap().get(bagId) != null){
AbstractWelfareBag bag = info.getPushMap().get(bagId);
setInitPushInfo((PushWelfareBag) bag,config);
if(isFiveStarBag(bagId)){
bag.setLimit((bag.getLimit()+num)>info.FIVESTARLIMIT?info.FIVESTARLIMIT:(bag.getLimit()+num));
}
}else{
bag.setLimit(num);
AbstractWelfareBag bag = initUnitWF(user,config);
if(isFiveStarBag(bagId)){
bag.setLimit(num>info.FIVESTARLIMIT?info.FIVESTARLIMIT:num);
}
}
return true;
}
/**
*
* @param bag
* @return
*
*/
private static int getTime(AbstractWelfareBag bag){
int i = 2;
for(String[] s : bag.getCondition()){
if(s[0].equals("6")){
i = Integer.parseInt(s[1]);
break;
}
}
return i;
private static void clearPushBag(PushWelfareBag bag){
bag.clear();
}
}

View File

@ -184,11 +184,6 @@ public class NewRechargeInfo extends MongoBase {
updateString("pushMap."+bag.getModId(),bag);
}
public void removePush(PushWelfareBag bag){
pushMap.remove(bag.getModId());
removeString(getMongoKey() + ".pushMap."+bag.getModId());
}
public int getMainLineLost() {
return mainLineLost;
}

View File

@ -35,6 +35,9 @@ public class AbstractWelfareBag extends MongoBase{
setModId(config.getId());
setType(config.getOtype());
setLimit(config.getLimit());
if(config.getOtype() == 4){
setLimit(1);
}
setTimeType(config.getTime());
setDailyUpdate(config.getDailyUpdate());
setContinueDays(config.getContiueDays());

View File

@ -27,12 +27,20 @@ public class PushWelfareBag extends AbstractWelfareBag {
public boolean buy() {
setBuyTimes(getBuyTimes()+1);
if(getLimit()<=getBuyTimes()){
setOpen(false);
clear();
}
return true;
}
private int getTime(){
public void clear(){
setOpen(false);
setLimit(1);
setBuyTimes(0);
setStartTime(0);
setEndTime(0);
}
public int getTime(){
int i = 2;
for(String[] s : getCondition()){
if(s[0].equals("6")){