惊喜礼盒类型的活动,添加礼包购买次数校验

back_recharge
duhui 2021-10-22 15:36:27 +08:00
parent a976c38c49
commit dc90208c0d
2 changed files with 40 additions and 7 deletions

View File

@ -11,8 +11,12 @@ import com.ljsd.jieling.logic.activity.event.SuperBoxEvent;
import com.ljsd.jieling.logic.dao.ServerConfig;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.store.BuyGoodsNewLogic;
import com.ljsd.jieling.logic.store.newRechargeInfo.bean.AbstractWelfareBag;
import com.ljsd.jieling.logic.store.newRechargeInfo.rechargeHandler.RechargeHandler;
import com.ljsd.jieling.network.session.ISession;
import config.SGlobalActivity;
import config.SRechargeCommodityNewConfig;
import config.SSurpriseBox;
import manager.STableManager;
import util.TimeUtils;
@ -97,7 +101,7 @@ public class SuperBoxActivity extends AbstractActivity {
if (box.getPackId() == giftId){
// 当前礼包状态处理
ActivityProgressInfo current = missionMap.get(box.getId());
if (current != null){
if (current != null && !checkBuyGiftCount(user,giftId)){
current.setState(ActivityType.HAD_TAKED);
current.setProgrss(8);
missionMap.put(box.getId(),current);
@ -267,6 +271,27 @@ public class SuperBoxActivity extends AbstractActivity {
return result;
}
/**
*
* @param user
* @param giftId
* @return
*/
private boolean checkBuyGiftCount(User user, int giftId){
// 礼包不存在
SRechargeCommodityNewConfig config = SRechargeCommodityNewConfig.getConfigById(giftId);
if (config == null){
return false;
}
RechargeHandler rechargeHandler = BuyGoodsNewLogic.getRechargeHandler(config.getOtype());
AbstractWelfareBag bag = rechargeHandler.getRechargeMap(user).get(giftId);
// 是否可买
if (bag != null && bag.checkBuy()){
return true;
}
return false;
}
@Override
public Set<Integer> getCloseGoods(User user){
HashSet<Integer> set = new HashSet<>();

View File

@ -79,12 +79,7 @@ public class AbstractWelfareBag extends MongoBase{
}
public boolean buy() {
if(!open){
LOGGER.error("礼包:{}未开启",modId);
return false;
}
if(getLimit() != 0 && buyTimes >=getLimit()){
LOGGER.error("礼包:{}购买次数为:{}超过限制:{}",modId,buyTimes,getLimit());
if (!checkBuy()){
return false;
}
if(isUserBuyRefresh && getRefreshTime() == 0){
@ -94,6 +89,19 @@ public class AbstractWelfareBag extends MongoBase{
setLastBuyTime(TimeUtils.getTodayZero());
return true;
}
public boolean checkBuy() {
if(!open){
LOGGER.error("礼包:{}未开启",modId);
return false;
}
if(getLimit() != 0 && buyTimes >=getLimit()){
LOGGER.error("礼包:{}购买次数为:{}超过限制:{}",modId,buyTimes,getLimit());
return false;
}
return true;
}
public int[][] getDropByBag() throws Exception{
SRechargeCommodityNewConfig config = SRechargeCommodityNewConfig.getConfigById(modId);
if (config == null) {