惊喜礼盒类型的活动,添加礼包购买次数校验
parent
a976c38c49
commit
dc90208c0d
|
@ -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<>();
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue