RechargeInfo.java 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. package com.ljsd.jieling.logic.dao;
  2. import com.ljsd.common.mogodb.MongoBase;
  3. import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
  4. import com.ljsd.jieling.logic.store.bean.*;
  5. import config.SRechargeCommodityConfig;
  6. import io.netty.util.internal.ConcurrentSet;
  7. import manager.STableManager;
  8. import org.springframework.data.annotation.Transient;
  9. import util.MathUtils;
  10. import java.util.*;
  11. public class RechargeInfo extends MongoBase{
  12. private double saveAmt;//累计充值
  13. private int soulCrystalAmt;//累计充值购买魂晶
  14. private double monthSaveAmt ; //月卡累计总额 monthRr
  15. private double smonthSaveAmt ; //豪华月卡累计总额 monthRr
  16. private int isFirst;
  17. private long createTime;
  18. private long firstTime;//首冲时间
  19. private int isDayFirst;
  20. private double maxSingleR;//单次最大充值金额
  21. private int pushpackCoun;
  22. @Transient
  23. private volatile Set<Integer> cacheSendedIds = new ConcurrentSet<>();
  24. private Map<Integer,Long> levelBagMap = new HashMap<>();//等级开启
  25. private Map<Integer,Long> levelAndMoneyBagMap = new HashMap<>();//等级礼包开启
  26. private Map<Integer,Long> refreshBagMap = new HashMap<>();
  27. private Map<Integer,Integer> buyGoodsTimes = new HashMap<>();
  28. private Map<Integer,Integer> goodseDurationMap = new HashMap<>();
  29. private Map<Integer,Integer> goodseSendDailyMap = new HashMap<>();
  30. private Map<Integer,Long> pushTimeMap = new HashMap<>();
  31. //特殊类型控制触发开启的商品表 如五星妖灵师类型5
  32. private Map<Integer,Long> typeBagMap = new HashMap<>();
  33. //动态商品可买数量
  34. private Map<Integer,Integer> dyGoodsCanBuyTimes = new HashMap<>();
  35. private Map<Integer, AbstractWelfareBag> perpetualMap = new HashMap<>();//永久礼包
  36. private Map<Integer,AbstractWelfareBag> timeLimitMap = new HashMap<>();//限时刷新礼包
  37. private Map<Integer,AbstractWelfareBag> receiveMap = new HashMap<>();//限时刷新礼包
  38. private Map<Integer,AbstractWelfareBag> pushMap = new HashMap<>();//推送礼包
  39. private long lostTime; //上次记录时间
  40. private int mainLineLost; //记录主线失败次数
  41. private int towerLost; //记录爬塔失败次数
  42. private long nextPushTime; //上次推送时间
  43. private long lastRefreshTime;
  44. public static int FIVESTARLIMIT = 999;//临时五星成长礼每天最多两次 ---2022.06.17不做限制了----
  45. private Map<Integer,Integer> tempLimitMap = new HashMap<>();//五星成长礼每天购买次数
  46. private Map<Integer,Integer> limitMap = new HashMap<>();//推送次数
  47. private Map<Integer,Integer> dailyLimitMap = new HashMap<>();//每日推送次数
  48. private long clubGiftBuyTime = 0;//俱乐部特权礼包购买激活时间
  49. private int clubGiftTaskRewardTimes = 0;//俱乐部特权礼包发奖次数
  50. private long voucherGiftBuyTime = 0;//现金券特权礼包购买激活时间
  51. private int voucherGiftTaskRewardTimes = 0;//现金券特权礼包发奖次数
  52. @Transient
  53. private Map<Integer,Long> cacheSendedTypes = new HashMap<>();
  54. public RechargeInfo(){
  55. }
  56. public boolean addNewSendId(int id){
  57. cacheSendedIds.remove(-id);
  58. return cacheSendedIds.add(id);
  59. }
  60. public void clearCacheSendId(){
  61. cacheSendedIds.clear();
  62. }
  63. public void setRefreshBagMap(Map<Integer, Long> refreshBagMap) {
  64. this.refreshBagMap = refreshBagMap;
  65. updateString("refreshBagMap", refreshBagMap);
  66. }
  67. //检测商品是否过期
  68. public Set<Integer> checkIsGoodsTypeOverTime(){
  69. int now = (int)(System.currentTimeMillis()/1000);
  70. Set<Integer> removeGoodsType = new HashSet<>();
  71. Iterator<Map.Entry<Integer, Integer>> iterator = goodseDurationMap.entrySet().iterator();
  72. while (iterator.hasNext()){
  73. Map.Entry<Integer, Integer> next = iterator.next();
  74. Integer key = next.getKey();
  75. Integer value = next.getValue();
  76. if(now> value){
  77. removeString(getMongoKey()+".goodseDurationMap." + key);
  78. iterator.remove();
  79. removeGoodsType.add(key);
  80. if(goodseSendDailyMap.containsKey(key)){
  81. removeString(getMongoKey()+".goodseSendDailyMap." + key);
  82. goodseSendDailyMap.remove(key);
  83. }
  84. }
  85. }
  86. return removeGoodsType;
  87. }
  88. public boolean checkOneGoodsIsOverTimeByPrivilege(int privilageId){
  89. for(Map.Entry<Integer,Integer> item: goodseDurationMap.entrySet()){
  90. SRechargeCommodityConfig sRechargeCommodityConfig = SRechargeCommodityConfig.rechargeCommodityConfigMap.get(item.getKey());
  91. int[] openPrivilege = sRechargeCommodityConfig.getOpenPrivilege();
  92. for(int privilege : openPrivilege){
  93. if(privilege == privilageId){
  94. if(System.currentTimeMillis()/1000 <= item.getValue()){
  95. return true;
  96. }
  97. break;
  98. }
  99. }
  100. }
  101. return false;
  102. }
  103. public void setSaveAmt(double saveAmt){
  104. if(this.saveAmt == 0){
  105. createTime = System.currentTimeMillis();
  106. updateString("createTime",createTime);
  107. }
  108. updateString("saveAmt",saveAmt);
  109. this.saveAmt = saveAmt;
  110. }
  111. public void addAmt(double amt) {
  112. this.saveAmt = MathUtils.doubleAdd(this.saveAmt, amt);
  113. updateString("saveAmt", this.saveAmt);
  114. }
  115. public void setFirst(int first) {
  116. updateString("isFirst",first);
  117. isFirst = first;
  118. }
  119. public void setDailyFirst(int first) {
  120. updateString("isDayFirst",first);
  121. isDayFirst = first;
  122. }
  123. public void setCreateTime(long createTime) {
  124. updateString("createTime",createTime);
  125. this.createTime = createTime;
  126. }
  127. public void setLevelBagMap(Map<Integer, Long> levelBagMap) {
  128. updateString("levelBagMap",levelBagMap);
  129. this.levelBagMap = levelBagMap;
  130. }
  131. public void setBuyGoodsTimes(Map<Integer, Integer> buyGoodsTimes) {
  132. updateString("buyGoodsTimes",buyGoodsTimes);
  133. this.buyGoodsTimes = buyGoodsTimes;
  134. }
  135. public void updateBuyGoodsTimes(int goodsId,int times) {
  136. updateString("buyGoodsTimes."+goodsId,times);
  137. this.buyGoodsTimes.put(goodsId,times);
  138. cacheSendedIds.remove(goodsId);
  139. }
  140. public void updateGoodsTypeDuration(int goodsId,int durTime) {
  141. updateString("goodseDurationMap." + goodsId,durTime);
  142. this.goodseDurationMap.put(goodsId,durTime);
  143. }
  144. public double getSaveAmt() {
  145. return saveAmt;
  146. }
  147. public long getCreateTime() {
  148. return createTime;
  149. }
  150. public Map<Integer, Long> getLevelBagMap() {
  151. return levelBagMap;
  152. }
  153. public Map<Integer, Integer> getBuyGoodsTimes() {
  154. return buyGoodsTimes;
  155. }
  156. public int getIsFirst() {
  157. return isFirst;
  158. }
  159. public int getIsDayFirst() {
  160. return isDayFirst;
  161. }
  162. public Map<Integer, Integer> getGoodsDurationMap() {
  163. return goodseDurationMap;
  164. }
  165. public Map<Integer, Integer> getGoodseSendDailyMap() {
  166. return goodseSendDailyMap;
  167. }
  168. public void updateGoodsSendTime(int goodsType,int sendTime) {
  169. updateString("goodseSendDailyMap." + goodsType,sendTime);
  170. this.goodseSendDailyMap.put(goodsType,sendTime);
  171. }
  172. // public int getSoulCrystalAmt() {
  173. // return soulCrystalAmt;
  174. // }
  175. //
  176. // public void addSoulCrystalAmt(int soulCrystalAmt) {
  177. // this.soulCrystalAmt += soulCrystalAmt;
  178. // updateString("soulCrystalAmt",soulCrystalAmt);
  179. // }
  180. public Map<Integer, Long> getTypeBagMap() {
  181. return typeBagMap;
  182. }
  183. public void addTypeBagMap(Integer type, Long createTime) {
  184. this.typeBagMap.put(type, createTime);
  185. updateString("typeBagMap",typeBagMap);
  186. }
  187. public void removeTypeBagMap(Integer type) {
  188. this.typeBagMap.remove(type);
  189. updateString("typeBagMap",typeBagMap);
  190. }
  191. public Map<Integer, Long> getCacheSendedTypes() {
  192. return cacheSendedTypes;
  193. }
  194. public void setCacheSendedTypes(Map<Integer, Long> cacheSendedTypes) {
  195. this.cacheSendedTypes = cacheSendedTypes;
  196. }
  197. public Map<Integer, Integer> getDyGoodsCanBuyTimes() {
  198. return dyGoodsCanBuyTimes;
  199. }
  200. public void addDyGoodsCanBuyTimes(Integer type) {
  201. this.dyGoodsCanBuyTimes.put(type,this.dyGoodsCanBuyTimes.getOrDefault(type,0)+1 );
  202. updateString("dyGoodsCanBuyTimes",dyGoodsCanBuyTimes);
  203. }
  204. public void putDyGoodsCanBuyTimes(Integer type,Integer value) {
  205. this.dyGoodsCanBuyTimes.put(type,value );
  206. cacheSendedIds.remove(type);
  207. updateString("dyGoodsCanBuyTimes",dyGoodsCanBuyTimes);
  208. }
  209. public void removeDyGoodsCanBuyTimes(Integer type) {
  210. this.dyGoodsCanBuyTimes.remove(type);
  211. updateString("dyGoodsCanBuyTimes",dyGoodsCanBuyTimes);
  212. }
  213. public void setDyGoodsCanBuyTimes(Map<Integer, Integer> dyGoodsCanBuyTimes) {
  214. updateString("dyGoodsCanBuyTimes",dyGoodsCanBuyTimes);
  215. this.dyGoodsCanBuyTimes = dyGoodsCanBuyTimes;
  216. }
  217. public Map<Integer, Long> getRefreshBagMap() {
  218. return refreshBagMap;
  219. }
  220. public void updateRefreshMapByKey(int key,Long time){
  221. refreshBagMap.put(key,time);
  222. updateString("refreshBagMap", refreshBagMap);
  223. }
  224. public double getMonthSaveAmt() {
  225. return monthSaveAmt;
  226. }
  227. public void setMonthSaveAmt(double monthSaveAmt) {
  228. this.monthSaveAmt = monthSaveAmt;
  229. updateString("monthSaveAmt",monthSaveAmt);
  230. }
  231. public double getSmonthSaveAmt() {
  232. return smonthSaveAmt;
  233. }
  234. public void setSmonthSaveAmt(double smonthSaveAmt) {
  235. this.smonthSaveAmt = smonthSaveAmt;
  236. updateString("smonthSaveAmt",smonthSaveAmt);
  237. }
  238. public Map<Integer, Long> getLevelAndMoneyBagMap() {
  239. return levelAndMoneyBagMap;
  240. }
  241. public void putLevelAndMoneyBagMap(Integer type,Long value) {
  242. this.levelAndMoneyBagMap.put(type,value );
  243. cacheSendedIds.remove(type);
  244. updateString("levelAndMoneyBagMap",levelAndMoneyBagMap);
  245. }
  246. public void removeLevelAndMoneyBagMap(Integer type) {
  247. this.levelAndMoneyBagMap.remove(type);
  248. cacheSendedIds.remove(type);
  249. updateString("levelAndMoneyBagMap",levelAndMoneyBagMap);
  250. }
  251. public List<AbstractWelfareBag> getTimeLimitBagList(){
  252. List<AbstractWelfareBag> list = new ArrayList<>();
  253. for(AbstractWelfareBag bag : timeLimitMap.values()){
  254. if(bag.isOpen() && bag.getEndTime() > 0){
  255. list.add(bag);
  256. }
  257. }
  258. for(AbstractWelfareBag bag : receiveMap.values()){
  259. bag = (ReceiveWelfareBag)bag;
  260. if(((ReceiveWelfareBag) bag).isBought()){
  261. list.add(bag);
  262. }
  263. }
  264. for(AbstractWelfareBag bag : pushMap.values()){
  265. if(bag.isOpen() && bag.getEndTime() > 0){
  266. list.add(bag);
  267. }
  268. }
  269. return list;
  270. }
  271. public List<Integer> getPushList(){
  272. List<Integer> list = new ArrayList<>();
  273. for(AbstractWelfareBag bag : pushMap.values()){
  274. if(bag.isOpen()){
  275. list.add(bag.getModId());
  276. }
  277. }
  278. return list;
  279. }
  280. public long getFirstTime() {
  281. return firstTime;
  282. }
  283. public void setFirstTime(long firstTime) {
  284. this.firstTime = firstTime;
  285. updateString("firstTime",firstTime);
  286. }
  287. public void setIsDayFirst(int isDayFirst) {
  288. this.isDayFirst = isDayFirst;
  289. updateString("isDayFirst",isDayFirst);
  290. }
  291. public Map<Integer, AbstractWelfareBag> getPerpetualMap() {
  292. return perpetualMap;
  293. }
  294. public Map<Integer, AbstractWelfareBag> getTimeLimitMap() {
  295. return timeLimitMap;
  296. }
  297. public Map<Integer, AbstractWelfareBag> getReceiveMap() {
  298. return receiveMap;
  299. }
  300. public Map<Integer, AbstractWelfareBag> getPushMap() {
  301. return pushMap;
  302. }
  303. public void addPerpetual(PerpetualWelfareBag bag){
  304. perpetualMap.put(bag.getModId(),bag);
  305. bag.init(this.getRootId(),getMongoKey() + ".perpetualMap." + bag.getModId());
  306. updateString("perpetualMap."+bag.getModId(),bag);
  307. }
  308. public void addTimeLimit(TimeLimitWelfareBag bag){
  309. timeLimitMap.put(bag.getModId(),bag);
  310. bag.init(this.getRootId(),getMongoKey() + ".timeLimitMap." + bag.getModId());
  311. updateString("timeLimitMap."+bag.getModId(),bag);
  312. }
  313. public void addReceive(ReceiveWelfareBag bag){
  314. receiveMap.put(bag.getModId(),bag);
  315. bag.init(this.getRootId(),getMongoKey() + ".receiveMap." + bag.getModId());
  316. updateString("receiveMap."+bag.getModId(),bag);
  317. }
  318. public void addPush(PushWelfareBag bag){
  319. pushMap.put(bag.getModId(),bag);
  320. bag.init(this.getRootId(),getMongoKey() + ".pushMap." + bag.getModId());
  321. updateString("pushMap."+bag.getModId(),bag);
  322. }
  323. public void removePush(PushWelfareBag bag){
  324. pushMap.remove(bag.getModId());
  325. removeString(getMongoKey() + ".pushMap."+bag.getModId());
  326. }
  327. public int getMainLineLost() {
  328. return mainLineLost;
  329. }
  330. public void setMainLineLost(int mainLineLost) {
  331. this.mainLineLost = mainLineLost;
  332. updateString("mainLineLost",mainLineLost);
  333. }
  334. public void addMainLineLost() {
  335. mainLineLost++;
  336. updateString("mainLineLost",mainLineLost);
  337. }
  338. public int getTowerLost() {
  339. return towerLost;
  340. }
  341. public void setTowerLost(int towerLost) {
  342. this.towerLost = towerLost;
  343. updateString("towerLost",towerLost);
  344. }
  345. public void addTowerLost() {
  346. towerLost++;
  347. updateString("towerLost",towerLost);
  348. }
  349. public void setPerpetualMap(Map<Integer, AbstractWelfareBag> perpetualMap) {
  350. this.perpetualMap = perpetualMap;
  351. updateString("perpetualMap",perpetualMap);
  352. }
  353. public void setTimeLimitMap(Map<Integer, AbstractWelfareBag> timeLimitMap) {
  354. this.timeLimitMap = timeLimitMap;
  355. }
  356. public void setReceiveMap(Map<Integer, AbstractWelfareBag> receiveMap) {
  357. this.receiveMap = receiveMap;
  358. }
  359. public void setPushMap(Map<Integer, AbstractWelfareBag> pushMap) {
  360. this.pushMap = pushMap;
  361. }
  362. public long getLostTime() {
  363. return lostTime;
  364. }
  365. public void setLostTime(long lostTime) {
  366. this.lostTime = lostTime;
  367. updateString("lostTime",lostTime);
  368. }
  369. public long getNextPushTime() {
  370. return nextPushTime;
  371. }
  372. public void setNextPushTime(long nextPushTime) {
  373. this.nextPushTime = nextPushTime;
  374. updateString("nextPushTime",nextPushTime);
  375. }
  376. public long getLastRefreshTime() {
  377. return lastRefreshTime;
  378. }
  379. public void setLastRefreshTime(long lastRefreshTime) {
  380. this.lastRefreshTime = lastRefreshTime;
  381. updateString("lastRefreshTime",lastRefreshTime);
  382. }
  383. public double getMaxSingleR() {
  384. return maxSingleR;
  385. }
  386. public void setMaxSingleR(double maxSingleR) {
  387. this.maxSingleR = maxSingleR;
  388. updateString("maxSingleR",maxSingleR);
  389. }
  390. public Map<Integer, Integer> getTempLimitMap() {
  391. return tempLimitMap;
  392. }
  393. public void setTempLimitMap(Map<Integer, Integer> tempLimitMap) {
  394. this.tempLimitMap = tempLimitMap;
  395. }
  396. public Map<Integer, Integer> getLimitMap() {
  397. return limitMap;
  398. }
  399. public void addlimit(int id){
  400. int num=limitMap.getOrDefault(id,0);
  401. num++;
  402. limitMap.put(id,num);
  403. updateString("limitMap." + id, num);
  404. }
  405. public int getPushpackCoun() {
  406. return pushpackCoun;
  407. }
  408. public void setPushpackCoun(int pushpackCoun) {
  409. this.pushpackCoun = pushpackCoun;
  410. updateString("pushpackCoun",pushpackCoun);
  411. }
  412. public void addPushpackCoun(int type) {
  413. if(type==1){
  414. this.pushpackCoun++;
  415. }else {
  416. this.pushpackCoun--;
  417. }
  418. int[] limit= STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getPushpackCountLimit();
  419. int low=limit[0];
  420. int max=limit[1];
  421. if(this.pushpackCoun<low){
  422. this.pushpackCoun=low;
  423. }
  424. if(this.pushpackCoun>max){
  425. this.pushpackCoun=max;
  426. }
  427. updateString("pushpackCoun",pushpackCoun);
  428. }
  429. public Map<Integer, Long> getPushTimeMap() {
  430. return pushTimeMap;
  431. }
  432. public void setPushTimeMap(Map<Integer, Long> pushTimeMap) {
  433. this.pushTimeMap = pushTimeMap;
  434. updateString("pushTimeMap",pushTimeMap);
  435. }
  436. public Map<Integer, Integer> getDailyLimitMap() {
  437. return dailyLimitMap;
  438. }
  439. public void addDailyLimit(int id){
  440. int value = dailyLimitMap.getOrDefault(id,0);
  441. int newValue = value + 1;
  442. dailyLimitMap.put(id,newValue);
  443. updateString("dailyLimitMap." + id, newValue);
  444. }
  445. public void cleanDailyLimit(){
  446. dailyLimitMap.clear();
  447. updateString("dailyLimitMap" , dailyLimitMap);
  448. }
  449. public long getClubGiftBuyTime() {
  450. return clubGiftBuyTime;
  451. }
  452. public void setClubGiftBuyTime(long clubGiftBuyTime) {
  453. this.clubGiftBuyTime = clubGiftBuyTime;
  454. updateString("clubGiftBuyTime" , clubGiftBuyTime);
  455. }
  456. public int getClubGiftTaskRewardTimes() {
  457. return clubGiftTaskRewardTimes;
  458. }
  459. public void setClubGiftTaskRewardTimes(int clubGiftTaskRewardTimes) {
  460. this.clubGiftTaskRewardTimes = clubGiftTaskRewardTimes;
  461. updateString("clubGiftTaskRewardTimes" , clubGiftTaskRewardTimes);
  462. }
  463. public long getVoucherGiftBuyTime() {
  464. return voucherGiftBuyTime;
  465. }
  466. public void setVoucherGiftBuyTime(long voucherGiftBuyTime) {
  467. this.voucherGiftBuyTime = voucherGiftBuyTime;
  468. updateString("voucherGiftBuyTime" , voucherGiftBuyTime);
  469. }
  470. public int getVoucherGiftTaskRewardTimes() {
  471. return voucherGiftTaskRewardTimes;
  472. }
  473. public void setVoucherGiftTaskRewardTimes(int voucherGiftTaskRewardTimes) {
  474. this.voucherGiftTaskRewardTimes = voucherGiftTaskRewardTimes;
  475. updateString("voucherGiftTaskRewardTimes" , voucherGiftTaskRewardTimes);
  476. }
  477. }