| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599 |
- package com.ljsd.jieling.logic.dao;
- import com.ljsd.common.mogodb.MongoBase;
- import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
- import com.ljsd.jieling.logic.store.bean.*;
- import config.SRechargeCommodityConfig;
- import io.netty.util.internal.ConcurrentSet;
- import manager.STableManager;
- import org.springframework.data.annotation.Transient;
- import util.MathUtils;
- import java.util.*;
- public class RechargeInfo extends MongoBase{
- private double saveAmt;//累计充值
- private int soulCrystalAmt;//累计充值购买魂晶
- private double monthSaveAmt ; //月卡累计总额 monthRr
- private double smonthSaveAmt ; //豪华月卡累计总额 monthRr
- private int isFirst;
- private long createTime;
- private long firstTime;//首冲时间
- private int isDayFirst;
- private double maxSingleR;//单次最大充值金额
- private int pushpackCoun;
- @Transient
- private volatile Set<Integer> cacheSendedIds = new ConcurrentSet<>();
- private Map<Integer,Long> levelBagMap = new HashMap<>();//等级开启
- private Map<Integer,Long> levelAndMoneyBagMap = new HashMap<>();//等级礼包开启
- private Map<Integer,Long> refreshBagMap = new HashMap<>();
- private Map<Integer,Integer> buyGoodsTimes = new HashMap<>();
- private Map<Integer,Integer> goodseDurationMap = new HashMap<>();
- private Map<Integer,Integer> goodseSendDailyMap = new HashMap<>();
- private Map<Integer,Long> pushTimeMap = new HashMap<>();
- //特殊类型控制触发开启的商品表 如五星妖灵师类型5
- private Map<Integer,Long> typeBagMap = new HashMap<>();
- //动态商品可买数量
- private Map<Integer,Integer> dyGoodsCanBuyTimes = new HashMap<>();
- private Map<Integer, AbstractWelfareBag> perpetualMap = new HashMap<>();//永久礼包
- private Map<Integer,AbstractWelfareBag> timeLimitMap = new HashMap<>();//限时刷新礼包
- private Map<Integer,AbstractWelfareBag> receiveMap = new HashMap<>();//限时刷新礼包
- private Map<Integer,AbstractWelfareBag> pushMap = new HashMap<>();//推送礼包
- private long lostTime; //上次记录时间
- private int mainLineLost; //记录主线失败次数
- private int towerLost; //记录爬塔失败次数
- private long nextPushTime; //上次推送时间
- private long lastRefreshTime;
- public static int FIVESTARLIMIT = 999;//临时五星成长礼每天最多两次 ---2022.06.17不做限制了----
- private Map<Integer,Integer> tempLimitMap = new HashMap<>();//五星成长礼每天购买次数
- private Map<Integer,Integer> limitMap = new HashMap<>();//推送次数
- private Map<Integer,Integer> dailyLimitMap = new HashMap<>();//每日推送次数
- private long clubGiftBuyTime = 0;//俱乐部特权礼包购买激活时间
- private int clubGiftTaskRewardTimes = 0;//俱乐部特权礼包发奖次数
- private long voucherGiftBuyTime = 0;//现金券特权礼包购买激活时间
- private int voucherGiftTaskRewardTimes = 0;//现金券特权礼包发奖次数
- @Transient
- private Map<Integer,Long> cacheSendedTypes = new HashMap<>();
- public RechargeInfo(){
- }
- public boolean addNewSendId(int id){
- cacheSendedIds.remove(-id);
- return cacheSendedIds.add(id);
- }
- public void clearCacheSendId(){
- cacheSendedIds.clear();
- }
- public void setRefreshBagMap(Map<Integer, Long> refreshBagMap) {
- this.refreshBagMap = refreshBagMap;
- updateString("refreshBagMap", refreshBagMap);
- }
- //检测商品是否过期
- public Set<Integer> checkIsGoodsTypeOverTime(){
- int now = (int)(System.currentTimeMillis()/1000);
- Set<Integer> removeGoodsType = new HashSet<>();
- Iterator<Map.Entry<Integer, Integer>> iterator = goodseDurationMap.entrySet().iterator();
- while (iterator.hasNext()){
- Map.Entry<Integer, Integer> next = iterator.next();
- Integer key = next.getKey();
- Integer value = next.getValue();
- if(now> value){
- removeString(getMongoKey()+".goodseDurationMap." + key);
- iterator.remove();
- removeGoodsType.add(key);
- if(goodseSendDailyMap.containsKey(key)){
- removeString(getMongoKey()+".goodseSendDailyMap." + key);
- goodseSendDailyMap.remove(key);
- }
- }
- }
- return removeGoodsType;
- }
- public boolean checkOneGoodsIsOverTimeByPrivilege(int privilageId){
- for(Map.Entry<Integer,Integer> item: goodseDurationMap.entrySet()){
- SRechargeCommodityConfig sRechargeCommodityConfig = SRechargeCommodityConfig.rechargeCommodityConfigMap.get(item.getKey());
- int[] openPrivilege = sRechargeCommodityConfig.getOpenPrivilege();
- for(int privilege : openPrivilege){
- if(privilege == privilageId){
- if(System.currentTimeMillis()/1000 <= item.getValue()){
- return true;
- }
- break;
- }
- }
- }
- return false;
- }
- public void setSaveAmt(double saveAmt){
- if(this.saveAmt == 0){
- createTime = System.currentTimeMillis();
- updateString("createTime",createTime);
- }
- updateString("saveAmt",saveAmt);
- this.saveAmt = saveAmt;
- }
- public void addAmt(double amt) {
- this.saveAmt = MathUtils.doubleAdd(this.saveAmt, amt);
- updateString("saveAmt", this.saveAmt);
- }
- public void setFirst(int first) {
- updateString("isFirst",first);
- isFirst = first;
- }
- public void setDailyFirst(int first) {
- updateString("isDayFirst",first);
- isDayFirst = first;
- }
- public void setCreateTime(long createTime) {
- updateString("createTime",createTime);
- this.createTime = createTime;
- }
- public void setLevelBagMap(Map<Integer, Long> levelBagMap) {
- updateString("levelBagMap",levelBagMap);
- this.levelBagMap = levelBagMap;
- }
- public void setBuyGoodsTimes(Map<Integer, Integer> buyGoodsTimes) {
- updateString("buyGoodsTimes",buyGoodsTimes);
- this.buyGoodsTimes = buyGoodsTimes;
- }
- public void updateBuyGoodsTimes(int goodsId,int times) {
- updateString("buyGoodsTimes."+goodsId,times);
- this.buyGoodsTimes.put(goodsId,times);
- cacheSendedIds.remove(goodsId);
- }
- public void updateGoodsTypeDuration(int goodsId,int durTime) {
- updateString("goodseDurationMap." + goodsId,durTime);
- this.goodseDurationMap.put(goodsId,durTime);
- }
- public double getSaveAmt() {
- return saveAmt;
- }
- public long getCreateTime() {
- return createTime;
- }
- public Map<Integer, Long> getLevelBagMap() {
- return levelBagMap;
- }
- public Map<Integer, Integer> getBuyGoodsTimes() {
- return buyGoodsTimes;
- }
- public int getIsFirst() {
- return isFirst;
- }
- public int getIsDayFirst() {
- return isDayFirst;
- }
- public Map<Integer, Integer> getGoodsDurationMap() {
- return goodseDurationMap;
- }
- public Map<Integer, Integer> getGoodseSendDailyMap() {
- return goodseSendDailyMap;
- }
- public void updateGoodsSendTime(int goodsType,int sendTime) {
- updateString("goodseSendDailyMap." + goodsType,sendTime);
- this.goodseSendDailyMap.put(goodsType,sendTime);
- }
- // public int getSoulCrystalAmt() {
- // return soulCrystalAmt;
- // }
- //
- // public void addSoulCrystalAmt(int soulCrystalAmt) {
- // this.soulCrystalAmt += soulCrystalAmt;
- // updateString("soulCrystalAmt",soulCrystalAmt);
- // }
- public Map<Integer, Long> getTypeBagMap() {
- return typeBagMap;
- }
- public void addTypeBagMap(Integer type, Long createTime) {
- this.typeBagMap.put(type, createTime);
- updateString("typeBagMap",typeBagMap);
- }
- public void removeTypeBagMap(Integer type) {
- this.typeBagMap.remove(type);
- updateString("typeBagMap",typeBagMap);
- }
- public Map<Integer, Long> getCacheSendedTypes() {
- return cacheSendedTypes;
- }
- public void setCacheSendedTypes(Map<Integer, Long> cacheSendedTypes) {
- this.cacheSendedTypes = cacheSendedTypes;
- }
- public Map<Integer, Integer> getDyGoodsCanBuyTimes() {
- return dyGoodsCanBuyTimes;
- }
- public void addDyGoodsCanBuyTimes(Integer type) {
- this.dyGoodsCanBuyTimes.put(type,this.dyGoodsCanBuyTimes.getOrDefault(type,0)+1 );
- updateString("dyGoodsCanBuyTimes",dyGoodsCanBuyTimes);
- }
- public void putDyGoodsCanBuyTimes(Integer type,Integer value) {
- this.dyGoodsCanBuyTimes.put(type,value );
- cacheSendedIds.remove(type);
- updateString("dyGoodsCanBuyTimes",dyGoodsCanBuyTimes);
- }
- public void removeDyGoodsCanBuyTimes(Integer type) {
- this.dyGoodsCanBuyTimes.remove(type);
- updateString("dyGoodsCanBuyTimes",dyGoodsCanBuyTimes);
- }
- public void setDyGoodsCanBuyTimes(Map<Integer, Integer> dyGoodsCanBuyTimes) {
- updateString("dyGoodsCanBuyTimes",dyGoodsCanBuyTimes);
- this.dyGoodsCanBuyTimes = dyGoodsCanBuyTimes;
- }
- public Map<Integer, Long> getRefreshBagMap() {
- return refreshBagMap;
- }
- public void updateRefreshMapByKey(int key,Long time){
- refreshBagMap.put(key,time);
- updateString("refreshBagMap", refreshBagMap);
- }
- public double getMonthSaveAmt() {
- return monthSaveAmt;
- }
- public void setMonthSaveAmt(double monthSaveAmt) {
- this.monthSaveAmt = monthSaveAmt;
- updateString("monthSaveAmt",monthSaveAmt);
- }
- public double getSmonthSaveAmt() {
- return smonthSaveAmt;
- }
- public void setSmonthSaveAmt(double smonthSaveAmt) {
- this.smonthSaveAmt = smonthSaveAmt;
- updateString("smonthSaveAmt",smonthSaveAmt);
- }
- public Map<Integer, Long> getLevelAndMoneyBagMap() {
- return levelAndMoneyBagMap;
- }
- public void putLevelAndMoneyBagMap(Integer type,Long value) {
- this.levelAndMoneyBagMap.put(type,value );
- cacheSendedIds.remove(type);
- updateString("levelAndMoneyBagMap",levelAndMoneyBagMap);
- }
- public void removeLevelAndMoneyBagMap(Integer type) {
- this.levelAndMoneyBagMap.remove(type);
- cacheSendedIds.remove(type);
- updateString("levelAndMoneyBagMap",levelAndMoneyBagMap);
- }
- public List<AbstractWelfareBag> getTimeLimitBagList(){
- List<AbstractWelfareBag> list = new ArrayList<>();
- for(AbstractWelfareBag bag : timeLimitMap.values()){
- if(bag.isOpen() && bag.getEndTime() > 0){
- list.add(bag);
- }
- }
- for(AbstractWelfareBag bag : receiveMap.values()){
- bag = (ReceiveWelfareBag)bag;
- if(((ReceiveWelfareBag) bag).isBought()){
- list.add(bag);
- }
- }
- for(AbstractWelfareBag bag : pushMap.values()){
- if(bag.isOpen() && bag.getEndTime() > 0){
- list.add(bag);
- }
- }
- return list;
- }
- public List<Integer> getPushList(){
- List<Integer> list = new ArrayList<>();
- for(AbstractWelfareBag bag : pushMap.values()){
- if(bag.isOpen()){
- list.add(bag.getModId());
- }
- }
- return list;
- }
- public long getFirstTime() {
- return firstTime;
- }
- public void setFirstTime(long firstTime) {
- this.firstTime = firstTime;
- updateString("firstTime",firstTime);
- }
- public void setIsDayFirst(int isDayFirst) {
- this.isDayFirst = isDayFirst;
- updateString("isDayFirst",isDayFirst);
- }
- public Map<Integer, AbstractWelfareBag> getPerpetualMap() {
- return perpetualMap;
- }
- public Map<Integer, AbstractWelfareBag> getTimeLimitMap() {
- return timeLimitMap;
- }
- public Map<Integer, AbstractWelfareBag> getReceiveMap() {
- return receiveMap;
- }
- public Map<Integer, AbstractWelfareBag> getPushMap() {
- return pushMap;
- }
- public void addPerpetual(PerpetualWelfareBag bag){
- perpetualMap.put(bag.getModId(),bag);
- bag.init(this.getRootId(),getMongoKey() + ".perpetualMap." + bag.getModId());
- updateString("perpetualMap."+bag.getModId(),bag);
- }
- public void addTimeLimit(TimeLimitWelfareBag bag){
- timeLimitMap.put(bag.getModId(),bag);
- bag.init(this.getRootId(),getMongoKey() + ".timeLimitMap." + bag.getModId());
- updateString("timeLimitMap."+bag.getModId(),bag);
- }
- public void addReceive(ReceiveWelfareBag bag){
- receiveMap.put(bag.getModId(),bag);
- bag.init(this.getRootId(),getMongoKey() + ".receiveMap." + bag.getModId());
- updateString("receiveMap."+bag.getModId(),bag);
- }
- public void addPush(PushWelfareBag bag){
- pushMap.put(bag.getModId(),bag);
- bag.init(this.getRootId(),getMongoKey() + ".pushMap." + bag.getModId());
- updateString("pushMap."+bag.getModId(),bag);
- }
- public void removePush(PushWelfareBag bag){
- pushMap.remove(bag.getModId());
- removeString(getMongoKey() + ".pushMap."+bag.getModId());
- }
- public int getMainLineLost() {
- return mainLineLost;
- }
- public void setMainLineLost(int mainLineLost) {
- this.mainLineLost = mainLineLost;
- updateString("mainLineLost",mainLineLost);
- }
- public void addMainLineLost() {
- mainLineLost++;
- updateString("mainLineLost",mainLineLost);
- }
- public int getTowerLost() {
- return towerLost;
- }
- public void setTowerLost(int towerLost) {
- this.towerLost = towerLost;
- updateString("towerLost",towerLost);
- }
- public void addTowerLost() {
- towerLost++;
- updateString("towerLost",towerLost);
- }
- public void setPerpetualMap(Map<Integer, AbstractWelfareBag> perpetualMap) {
- this.perpetualMap = perpetualMap;
- updateString("perpetualMap",perpetualMap);
- }
- public void setTimeLimitMap(Map<Integer, AbstractWelfareBag> timeLimitMap) {
- this.timeLimitMap = timeLimitMap;
- }
- public void setReceiveMap(Map<Integer, AbstractWelfareBag> receiveMap) {
- this.receiveMap = receiveMap;
- }
- public void setPushMap(Map<Integer, AbstractWelfareBag> pushMap) {
- this.pushMap = pushMap;
- }
- public long getLostTime() {
- return lostTime;
- }
- public void setLostTime(long lostTime) {
- this.lostTime = lostTime;
- updateString("lostTime",lostTime);
- }
- public long getNextPushTime() {
- return nextPushTime;
- }
- public void setNextPushTime(long nextPushTime) {
- this.nextPushTime = nextPushTime;
- updateString("nextPushTime",nextPushTime);
- }
- public long getLastRefreshTime() {
- return lastRefreshTime;
- }
- public void setLastRefreshTime(long lastRefreshTime) {
- this.lastRefreshTime = lastRefreshTime;
- updateString("lastRefreshTime",lastRefreshTime);
- }
- public double getMaxSingleR() {
- return maxSingleR;
- }
- public void setMaxSingleR(double maxSingleR) {
- this.maxSingleR = maxSingleR;
- updateString("maxSingleR",maxSingleR);
- }
- public Map<Integer, Integer> getTempLimitMap() {
- return tempLimitMap;
- }
- public void setTempLimitMap(Map<Integer, Integer> tempLimitMap) {
- this.tempLimitMap = tempLimitMap;
- }
- public Map<Integer, Integer> getLimitMap() {
- return limitMap;
- }
- public void addlimit(int id){
- int num=limitMap.getOrDefault(id,0);
- num++;
- limitMap.put(id,num);
- updateString("limitMap." + id, num);
- }
- public int getPushpackCoun() {
- return pushpackCoun;
- }
- public void setPushpackCoun(int pushpackCoun) {
- this.pushpackCoun = pushpackCoun;
- updateString("pushpackCoun",pushpackCoun);
- }
- public void addPushpackCoun(int type) {
- if(type==1){
- this.pushpackCoun++;
- }else {
- this.pushpackCoun--;
- }
- int[] limit= STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getPushpackCountLimit();
- int low=limit[0];
- int max=limit[1];
- if(this.pushpackCoun<low){
- this.pushpackCoun=low;
- }
- if(this.pushpackCoun>max){
- this.pushpackCoun=max;
- }
- updateString("pushpackCoun",pushpackCoun);
- }
- public Map<Integer, Long> getPushTimeMap() {
- return pushTimeMap;
- }
- public void setPushTimeMap(Map<Integer, Long> pushTimeMap) {
- this.pushTimeMap = pushTimeMap;
- updateString("pushTimeMap",pushTimeMap);
- }
- public Map<Integer, Integer> getDailyLimitMap() {
- return dailyLimitMap;
- }
- public void addDailyLimit(int id){
- int value = dailyLimitMap.getOrDefault(id,0);
- int newValue = value + 1;
- dailyLimitMap.put(id,newValue);
- updateString("dailyLimitMap." + id, newValue);
- }
- public void cleanDailyLimit(){
- dailyLimitMap.clear();
- updateString("dailyLimitMap" , dailyLimitMap);
- }
- public long getClubGiftBuyTime() {
- return clubGiftBuyTime;
- }
- public void setClubGiftBuyTime(long clubGiftBuyTime) {
- this.clubGiftBuyTime = clubGiftBuyTime;
- updateString("clubGiftBuyTime" , clubGiftBuyTime);
- }
- public int getClubGiftTaskRewardTimes() {
- return clubGiftTaskRewardTimes;
- }
- public void setClubGiftTaskRewardTimes(int clubGiftTaskRewardTimes) {
- this.clubGiftTaskRewardTimes = clubGiftTaskRewardTimes;
- updateString("clubGiftTaskRewardTimes" , clubGiftTaskRewardTimes);
- }
- public long getVoucherGiftBuyTime() {
- return voucherGiftBuyTime;
- }
- public void setVoucherGiftBuyTime(long voucherGiftBuyTime) {
- this.voucherGiftBuyTime = voucherGiftBuyTime;
- updateString("voucherGiftBuyTime" , voucherGiftBuyTime);
- }
- public int getVoucherGiftTaskRewardTimes() {
- return voucherGiftTaskRewardTimes;
- }
- public void setVoucherGiftTaskRewardTimes(int voucherGiftTaskRewardTimes) {
- this.voucherGiftTaskRewardTimes = voucherGiftTaskRewardTimes;
- updateString("voucherGiftTaskRewardTimes" , voucherGiftTaskRewardTimes);
- }
- }
|