推送礼包优化
parent
a0c902347e
commit
7ed896b78c
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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")){
|
||||
|
|
Loading…
Reference in New Issue