天降礼包初版
parent
9f1150aa0c
commit
3bbafe19c4
|
@ -26,8 +26,6 @@ public class DbClear {
|
|||
StringRedisTemplate redisTemplate = getRedisTemplate();
|
||||
redisTemplate.delete(redisTemplate.keys(properties.get("server.id")+"*"));
|
||||
System.out.println("the mongo url=" + property);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static StringRedisTemplate getRedisTemplate(){
|
||||
|
|
|
@ -16,26 +16,22 @@ public class MongoRechargeConverter implements Converter<BasicDBObject, Abstract
|
|||
public AbstractWelfareBag convert(BasicDBObject source) {
|
||||
Gson gson = new Gson();
|
||||
SRechargeCommodityNewConfig config = STableManager.getConfig(SRechargeCommodityNewConfig.class).get(source.getInt("modId"));
|
||||
Class<? extends AbstractWelfareBag> target =null;
|
||||
|
||||
if(config==null){
|
||||
target=PerpetualWelfareBag.class;
|
||||
}else{
|
||||
|
||||
Class<? extends AbstractWelfareBag> target = PerpetualWelfareBag.class;
|
||||
if (config != null){
|
||||
if(config.getOtype() == RechargeType.timeLimit.getType()){
|
||||
target = TimeLimitWelfareBag.class;
|
||||
}else if(config.getOtype() ==RechargeType.perpetual.getType()){
|
||||
}
|
||||
if(config.getOtype() ==RechargeType.perpetual.getType()){
|
||||
target = PerpetualWelfareBag.class;
|
||||
|
||||
}else if(config.getOtype()==RechargeType.receive.getType()){
|
||||
}
|
||||
if(config.getOtype()==RechargeType.receive.getType()){
|
||||
target = ReceiveWelfareBag.class;
|
||||
}else if(config.getOtype()==RechargeType.push.getType()){
|
||||
}
|
||||
if(config.getOtype()==RechargeType.push.getType()){
|
||||
target = PushWelfareBag.class;
|
||||
}
|
||||
}
|
||||
|
||||
String s = gson.toJson(source);
|
||||
AbstractWelfareBag abstractWelfareBag = JSON.parseObject(s, target);
|
||||
return abstractWelfareBag;
|
||||
return JSON.parseObject(s, target);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
package com.ljsd.jieling.db.mongo.gmActivity;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Document(collection = "c_gift_activity")
|
||||
public class GiftActivity {
|
||||
|
||||
@Id
|
||||
private int id;
|
||||
|
||||
private String name;
|
||||
|
||||
private long startTime;
|
||||
|
||||
private long endTime;
|
||||
|
||||
private int openLimitDay;
|
||||
|
||||
private long createTime;
|
||||
|
||||
private Set<String> serverIds = new HashSet<>();
|
||||
|
||||
private Map<Integer, GiftMission> missionMap = new HashMap<>();
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
public void setStartTime(long startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public long getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(long endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public int getOpenLimitDay() {
|
||||
return openLimitDay;
|
||||
}
|
||||
|
||||
public void setOpenLimitDay(int openLimitDay) {
|
||||
this.openLimitDay = openLimitDay;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Set<String> getServerIds() {
|
||||
return serverIds;
|
||||
}
|
||||
|
||||
public void setServerIds(Set<String> serverIds) {
|
||||
this.serverIds = serverIds;
|
||||
}
|
||||
|
||||
public Map<Integer, GiftMission> getMissionMap() {
|
||||
return missionMap;
|
||||
}
|
||||
|
||||
public void setMissionMap(Map<Integer, GiftMission> missionMap) {
|
||||
this.missionMap = missionMap;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.ljsd.jieling.db.mongo.gmActivity;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
@Document(collection = "c_gift_mission")
|
||||
public class GiftMission {
|
||||
|
||||
@Id
|
||||
private int id;
|
||||
|
||||
private int sort;
|
||||
|
||||
private String name;
|
||||
|
||||
private String discount;
|
||||
|
||||
private int buyLimitCount;
|
||||
|
||||
private int activityId;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDiscount() {
|
||||
return discount;
|
||||
}
|
||||
|
||||
public void setDiscount(String discount) {
|
||||
this.discount = discount;
|
||||
}
|
||||
|
||||
public int getBuyLimitCount() {
|
||||
return buyLimitCount;
|
||||
}
|
||||
|
||||
public void setBuyLimitCount(int buyLimitCount) {
|
||||
this.buyLimitCount = buyLimitCount;
|
||||
}
|
||||
|
||||
public int getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(int sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public int getActivityId() {
|
||||
return activityId;
|
||||
}
|
||||
|
||||
public void setActivityId(int activityId) {
|
||||
this.activityId = activityId;
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ import com.ljsd.jieling.logic.activity.ActivityTypeEnum;
|
|||
import com.ljsd.jieling.logic.activity.ChoiceDrawCardActivity;
|
||||
import com.ljsd.jieling.logic.activity.LimitRandomSpecialMonsterActivityNew;
|
||||
import com.ljsd.jieling.logic.activity.activityLogic.GmActivityLogic;
|
||||
import com.ljsd.jieling.logic.activity.activityLogic.GmSingleActivityLogic;
|
||||
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
|
||||
import com.ljsd.jieling.logic.activity.event.HeroUpStarEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
|
@ -76,6 +77,7 @@ public class GetPlayerInfoHandler extends BaseHandler{
|
|||
PlayerManager playerInfoManager = user.getPlayerInfoManager();
|
||||
ActivityLogic.getInstance().flushForLogin(user,iSession);
|
||||
GlobalDataManaager.checkNeedReFlush(iSession,user,null);
|
||||
GmSingleActivityLogic.getInstance().updateGmSingle(user);
|
||||
BuyGoodsNewLogic.refreshWelfareState(user);
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.LOGIN_GAME,0);
|
||||
long now = TimeUtils.now();
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package com.ljsd.jieling.handler.activity;
|
||||
|
||||
import com.ljsd.jieling.db.mongo.gmActivity.GiftActivity;
|
||||
import com.ljsd.jieling.db.mongo.gmActivity.GiftMission;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.activity.activityLogic.GmSingleActivityLogic;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
import rpc.protocols.ActivityProto;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Description: gm单笔活动信息
|
||||
* Author: zsx
|
||||
* CreateDate: 2019/9/25 20:31
|
||||
*/
|
||||
@Component
|
||||
public class GmSingleActivityHandler extends BaseHandler<ActivityProto.GetGmSingleActivityRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.GetGmSingleActivityRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, ActivityProto.GetGmSingleActivityRequest proto) throws Exception {
|
||||
User user = UserManager.getUser(iSession.getUid());
|
||||
ActivityProto.GetGmSingleActivityResponse.Builder builder = ActivityProto.GetGmSingleActivityResponse.newBuilder();
|
||||
Map<Integer, List<Integer>> singleIdMap = user.getGmActivityManager().getGmSingleIdMap();
|
||||
Map<Integer, GiftActivity> activityMap = GmSingleActivityLogic.getInstance().findGmSingleMap();
|
||||
for (Map.Entry<Integer, List<Integer>> entry : singleIdMap.entrySet()) {
|
||||
Integer activityId = entry.getKey();
|
||||
GiftActivity activity = activityMap.get(activityId);
|
||||
if (activity == null){
|
||||
continue;
|
||||
}
|
||||
CommonProto.GmSingleActivity.Builder single = CommonProto.GmSingleActivity.newBuilder();
|
||||
single.setId(activityId);
|
||||
single.setName(activity.getName());
|
||||
single.setEndTime(activity.getEndTime());
|
||||
Map<Integer, GiftMission> missionMap = GmSingleActivityLogic.getInstance().findGmSingleMissionMap(activityId);
|
||||
for (Integer giftId : entry.getValue()) {
|
||||
GiftMission mission = missionMap.get(giftId);
|
||||
if (mission == null){
|
||||
continue;
|
||||
}
|
||||
CommonProto.GmSingleGift.Builder gift = CommonProto.GmSingleGift.newBuilder()
|
||||
.setGiftId(mission.getId())
|
||||
.setSort(mission.getSort())
|
||||
.setName(mission.getName())
|
||||
.setDiscount(mission.getDiscount());
|
||||
single.addMissions(gift);
|
||||
}
|
||||
builder.addGmSingle(single);
|
||||
}
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GetGmSingleActivityResponse_VALUE, builder.build(), true);
|
||||
}
|
||||
}
|
|
@ -3,6 +3,8 @@ package com.ljsd.jieling.jbean.gm;
|
|||
import com.ljsd.common.mogodb.MongoBase;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 说明:gm活动
|
||||
|
@ -13,7 +15,10 @@ import java.util.HashMap;
|
|||
public class GmActivityManager extends MongoBase {
|
||||
|
||||
private long updateTime;
|
||||
// 线下返利礼包
|
||||
private HashMap<String, GmActivity> activityMap = new HashMap<>();
|
||||
// 单笔充值礼包
|
||||
private Map<Integer, List<Integer>> gmSingleIdMap = new HashMap<>();
|
||||
|
||||
public HashMap<String, GmActivity> getActivityMap() {
|
||||
return activityMap;
|
||||
|
@ -42,4 +47,13 @@ public class GmActivityManager extends MongoBase {
|
|||
this.activityMap.remove(activityId);
|
||||
updateString("activityMap",activityMap);
|
||||
}
|
||||
|
||||
public Map<Integer, List<Integer>> getGmSingleIdMap() {
|
||||
return gmSingleIdMap;
|
||||
}
|
||||
|
||||
public void setGmSingleIdMap(Map<Integer, List<Integer>> gmSingleIdMap) {
|
||||
this.gmSingleIdMap = gmSingleIdMap;
|
||||
updateString("gmSingleIdMap",gmSingleIdMap);
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ import com.ljsd.jieling.db.mongo.MongoUtil;
|
|||
import com.ljsd.jieling.handler.map.MapLogic;
|
||||
import com.ljsd.jieling.logic.activity.*;
|
||||
import com.ljsd.jieling.logic.activity.activityLogic.GmActivityLogic;
|
||||
import com.ljsd.jieling.logic.activity.activityLogic.GmSingleActivityLogic;
|
||||
import com.ljsd.jieling.logic.activity.activityLogic.WeekCardLogic;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.activity.event.SuperBoxEvent;
|
||||
|
@ -443,6 +444,8 @@ public class GlobalDataManaager implements IManager {
|
|||
GuildLogic.getInstance().guildHelpDayHandler(user);
|
||||
// 罗浮称号
|
||||
ArenaLogic.getInstance().takeTitleReward(user);
|
||||
// gm单笔更新
|
||||
GmSingleActivityLogic.getInstance().updateGmSingle(user);
|
||||
|
||||
WeekCardLogic.getInstance().weekCardInfoIndication(user,0,0);
|
||||
ChallengeLogic.getInstance().ChallengeInfoIndication(session);
|
||||
|
|
|
@ -33,12 +33,8 @@ class RechargeSumDayActivity extends AbstractActivity {
|
|||
return;
|
||||
}
|
||||
if (user.getPlayerInfoManager().getRechargedaily() >= 6 ) {//充值小于六块不触发修改
|
||||
// SActivityRewardConfig.getsActivityRewardConfigByMissionId(missionId).getValues()[0][0]
|
||||
activityMission.setV(activityMission.getV() + 1);
|
||||
}
|
||||
// if (activityMission.getV() >= SActivityRewardConfig.getsActivityRewardConfigByActivityId(id).size()) {
|
||||
// ActivityLogic.getInstance().initMissionInfo(activityMission,id);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -400,22 +400,6 @@ public class GmActivityLogic implements IEventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
// for (GmActivity gmActivity : manager.getActivityMap().values()) {
|
||||
// ARBActivity arbActivity = arbActivityMap.get(gmActivity.getId());
|
||||
// // 活动已经从gm上删除了,在这里删除数据库中的
|
||||
// if (arbActivity == null){
|
||||
// manager.removeActivity(gmActivity.getId());
|
||||
// LOGGER.info("返利活动删除,uid:{},活动id:{}",user.getId(),gmActivity.getId());
|
||||
// continue;
|
||||
// }
|
||||
// // 单日累充和妖晶返利每日清零
|
||||
// if (gmActivity.getType() == 1 || gmActivity.getType() == 2 || gmActivity.getType() == 4){
|
||||
// gmActivity.setValue(0);
|
||||
// gmActivity.setMissionMap(new HashMap<>());
|
||||
// LOGGER.info("返利活动重置,uid:{},活动id:{}",user.getId(),gmActivity.getId());
|
||||
// }
|
||||
// }
|
||||
|
||||
manager.setUpdateTime(nowTime);
|
||||
LOGGER.info("返利活动重置结束,uid:{},刷新时间:{}",user.getId(),manager.getUpdateTime());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
package com.ljsd.jieling.logic.activity.activityLogic;
|
||||
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||
import com.ljsd.jieling.db.mongo.gmActivity.GiftActivity;
|
||||
import com.ljsd.jieling.db.mongo.gmActivity.GiftMission;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 说明:gm活动处理类
|
||||
*
|
||||
* @author ascend
|
||||
* 2022/10/27 16:20:08
|
||||
*/
|
||||
public class GmSingleActivityLogic {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GmSingleActivityLogic.class);
|
||||
|
||||
public static class Instance {
|
||||
public final static GmSingleActivityLogic instance = new GmSingleActivityLogic();
|
||||
}
|
||||
public static GmSingleActivityLogic getInstance() {
|
||||
return GmSingleActivityLogic.Instance.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新gm单笔充值活动
|
||||
* @param user
|
||||
*/
|
||||
public void updateGmSingle(User user){
|
||||
try {
|
||||
Map<Integer, List<Integer>> listMap = new HashMap<>();
|
||||
long now = TimeUtils.now();
|
||||
long openTime = GameApplication.serverConfig.getCacheOpenTime();
|
||||
for (GiftActivity activity : findAllGmSingle()) {
|
||||
// 开启时间判断
|
||||
if (now < activity.getStartTime() || now >= activity.getEndTime()){
|
||||
continue;
|
||||
}
|
||||
// 开服时间判断
|
||||
if (now < openTime+activity.getOpenLimitDay()*TimeUtils.DAY){
|
||||
continue;
|
||||
}
|
||||
ArrayList<Integer> list = new ArrayList<>();
|
||||
for (GiftMission mission : findAllMission(activity.getId())) {
|
||||
list.add(mission.getId());
|
||||
}
|
||||
listMap.put(activity.getId(),list);
|
||||
}
|
||||
user.getGmActivityManager().setGmSingleIdMap(listMap);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public List<GiftActivity> findAllGmSingle() {
|
||||
MongoTemplate coreMonoTemplate = MongoUtil.getCoreMongoTemplate();
|
||||
return coreMonoTemplate.findAll(GiftActivity.class);
|
||||
}
|
||||
|
||||
public Map<Integer, GiftActivity> findGmSingleMap() {
|
||||
HashMap<Integer, GiftActivity> map = new HashMap<>();
|
||||
for (GiftActivity activity : findAllGmSingle()) {
|
||||
map.put(activity.getId(),activity);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public List<GiftMission> findAllMission(int activityId) {
|
||||
MongoTemplate coreMonoTemplate = MongoUtil.getCoreMongoTemplate();
|
||||
Query query = new Query(Criteria.where("activityId").is(activityId));
|
||||
return coreMonoTemplate.find(query, GiftMission.class);
|
||||
}
|
||||
|
||||
public Map<Integer, GiftMission> findGmSingleMissionMap(int activityId) {
|
||||
HashMap<Integer, GiftMission> map = new HashMap<>();
|
||||
for (GiftMission mission : findAllMission(activityId)) {
|
||||
map.put(mission.getId(), mission);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public GiftMission findGiftMission(int giftId) {
|
||||
MongoTemplate coreMonoTemplate = MongoUtil.getCoreMongoTemplate();
|
||||
Query query = new Query(Criteria.where("_id").is(giftId));
|
||||
return coreMonoTemplate.findOne(query, GiftMission.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
||||
public class Gift extends MongoBase {
|
||||
private String id;
|
||||
private int amount;
|
||||
private int count;
|
||||
private String createTime;
|
||||
|
||||
public Gift(){
|
||||
//绑定关系
|
||||
this.setRootCollection(User._COLLECTION_NAME);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class GiftManager extends MongoBase {
|
||||
private final Map<String, Gift> giftMap = new HashMap<>();
|
||||
|
||||
public GiftManager() {
|
||||
this.setRootCollection(User._COLLECTION_NAME);
|
||||
}
|
||||
|
||||
|
||||
public void putGift(Gift gift){
|
||||
giftMap.put(gift.getId(), gift);
|
||||
updateString("giftMap",giftMap);
|
||||
}
|
||||
|
||||
public Map<String, Gift> getGiftMap() {
|
||||
return giftMap;
|
||||
}
|
||||
|
||||
public Gift getGift(String id){
|
||||
return giftMap.get(id);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
public class RechargeManager extends MongoBase {
|
||||
|
||||
}
|
|
@ -15,8 +15,6 @@ public class User {
|
|||
|
||||
private PlayerManager playerManager;
|
||||
|
||||
private GiftManager giftManager;
|
||||
|
||||
private ItemManager itemManager;
|
||||
|
||||
private HeroManager heroManager;
|
||||
|
@ -88,7 +86,6 @@ public class User {
|
|||
this.hardStageManager = new HardStageManager();
|
||||
this.gmActivityManager = new GmActivityManager();
|
||||
this.magicSoldierManager = new MagicSoldierManager();
|
||||
this.giftManager = new GiftManager();
|
||||
//綁定关系
|
||||
|
||||
this.playerManager.init(id, MongoKey.playerManager);
|
||||
|
@ -115,7 +112,6 @@ public class User {
|
|||
this.hardStageManager.init(id,MongoKey.hardStageManager);
|
||||
this.gmActivityManager.init(id,MongoKey.gmActivityManager);
|
||||
this.magicSoldierManager.init(id,MongoKey.magicSoldierManager);
|
||||
this.giftManager.init(id,MongoKey.giftManager);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
|
@ -218,14 +214,6 @@ public class User {
|
|||
return guildMyInfo;
|
||||
}
|
||||
|
||||
public GiftManager getGiftManager() {
|
||||
return giftManager;
|
||||
}
|
||||
|
||||
public void setGiftManager(GiftManager giftManager) {
|
||||
this.giftManager = giftManager;
|
||||
}
|
||||
|
||||
public ExpeditionManager getExpeditionManager() {
|
||||
if(null ==expeditionManager){
|
||||
this.expeditionManager = new ExpeditionManager();
|
||||
|
|
|
@ -12,7 +12,6 @@ import com.ljsd.jieling.globals.Global;
|
|||
import com.ljsd.jieling.jbean.ActivityMission;
|
||||
import com.ljsd.jieling.ktbeans.KtEventUtils;
|
||||
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
|
||||
import com.ljsd.jieling.logic.GlobalDataManaager;
|
||||
import com.ljsd.jieling.logic.GlobleSystemLogic;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.activity.AbstractActivity;
|
||||
|
@ -94,6 +93,7 @@ public class BuyGoodsNewLogic {
|
|||
AbstractWelfareBag bag = rechargeHandler.initUnitWF(user, config);
|
||||
rechargeHandler.addNew(user,bag);
|
||||
}
|
||||
// 刷新
|
||||
needChange = rechargeHandler.refreshStatus(user, config.getId());
|
||||
}
|
||||
return needChange;
|
||||
|
@ -422,7 +422,8 @@ public class BuyGoodsNewLogic {
|
|||
ActivityLogic.getInstance().updateActivityMissionProgress(user, ActivityType.NEW_WELFARE, (int)(info.getRr()));
|
||||
|
||||
info.addRmb(price);
|
||||
user.getPlayerInfoManager().setRechargedaily(user.getPlayerInfoManager().getRechargedaily()+price);
|
||||
info.setRechargeList(TimeUtils.now(),price);
|
||||
user.getPlayerInfoManager().addRechargedaily(price);
|
||||
|
||||
AyyncWorker ayyncWorker = new AyyncWorker(user, true, new AynMissionWorker(GameEvent.RECHARGE_TOTAL,(int)(price*1000))) ;
|
||||
ProtocolsManager.getInstance().updateAyncWorker(ayyncWorker);
|
||||
|
@ -432,9 +433,6 @@ public class BuyGoodsNewLogic {
|
|||
ISession session = OnlineUserManager.getSessionByUid(user.getId());
|
||||
PlayerInfoProto.RefreshRechargeIndication.Builder builder = PlayerInfoProto.RefreshRechargeIndication.newBuilder();
|
||||
builder.setAmount(info.getRr());
|
||||
builder.setMonthSaveAmt(info.getMonthRr());
|
||||
builder.setSmonthSaveAmt(info.getsMonthRr());
|
||||
builder.setSincereMonth(info.getSinceremonth());
|
||||
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.REFRESH_RECHARGE_INDICATION_VALUE,builder.build(),true);
|
||||
}
|
||||
|
||||
|
@ -686,16 +684,16 @@ public class BuyGoodsNewLogic {
|
|||
CommonProto.GiftGoodsInfo giftGoodsInfo = buildGoodsInfo(bag);
|
||||
if (giftGoodsInfo == null) {
|
||||
needRemoveIds.add(bag.getModId());
|
||||
continue;
|
||||
}
|
||||
}else {
|
||||
giftGoodsInfoList.add(giftGoodsInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 删除礼包
|
||||
if (!needRemoveIds.isEmpty()) {
|
||||
for (Integer needRemoveId : needRemoveIds) {
|
||||
rechargeInfo.removePush(needRemoveId);
|
||||
rechargeInfo.removeBag(needRemoveId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -717,96 +715,97 @@ public class BuyGoodsNewLogic {
|
|||
* @throws Exception
|
||||
*/
|
||||
public static Set<Integer> getGoodsBagInfoFromDelive(int uid) throws Exception {
|
||||
User user = UserManager.getUser(uid);
|
||||
Set<Integer> list = new HashSet<>();
|
||||
// 礼包是否打开
|
||||
NewRechargeInfo rechargeInfo = user.getPlayerInfoManager().getNewRechargeInfo();
|
||||
Map<Integer, SRechargeCommodityNewConfig> configMap = SRechargeCommodityNewConfig.configMap;
|
||||
// 次数,推送,永久礼包一起处理
|
||||
ArrayList<AbstractWelfareBag> welfareBags = new ArrayList<>(rechargeInfo.getPerpetualMap().values());
|
||||
welfareBags.addAll(rechargeInfo.getTimeLimitMap().values());
|
||||
welfareBags.addAll(rechargeInfo.getReceiveMap().values());
|
||||
for (AbstractWelfareBag bag : welfareBags) {
|
||||
if(bag.isOpen()){
|
||||
if (bag.getLimit() == 0 || bag.getLimit() > bag.getBuyTimes()){
|
||||
list.add(bag.getModId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// getLimit方法实现不同,需要特殊处理
|
||||
for (AbstractWelfareBag value : rechargeInfo.getPushMap().values()) {
|
||||
PushWelfareBag bag = (PushWelfareBag) value;
|
||||
if(bag.isOpen()){
|
||||
if (bag.getLimit() == 0 || bag.getLimit() > bag.getBuyTimes()){
|
||||
list.add(bag.getModId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 走表判断开启的礼包
|
||||
Map<Integer, SGlobalActivity> activityMap = SGlobalActivity.getsGlobalActivityMap();
|
||||
Map<Integer, ActivityMission> missionMap = user.getActivityManager().getActivityMissionMap();
|
||||
|
||||
for (Map.Entry<Integer, ActivityMission> entry : missionMap.entrySet()) {
|
||||
int activityId = entry.getKey();
|
||||
ActivityMission mission = entry.getValue();
|
||||
// 遍历
|
||||
Iterator<Integer> iterator = list.iterator();
|
||||
while (iterator.hasNext()){
|
||||
SRechargeCommodityNewConfig config = configMap.get(iterator.next());
|
||||
// 表控制不显示
|
||||
if (config.getIsShowInWeb() == 0){
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
// 未加入公会,不显示公会红包
|
||||
if (user.getPlayerInfoManager().getGuildId() == 0 && config.getType() == 10){
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
// 一键购买处理
|
||||
if (config.getForbid() != null) {
|
||||
config.getForbid();
|
||||
for (int i : config.getForbid()) {
|
||||
// 已购买任意礼包,不能获取一键购买
|
||||
if (!list.contains(i)) {
|
||||
iterator.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int[] open : config.getOnSaleRule()) {
|
||||
// 活动未开启的礼包
|
||||
if (open[0] == 3){
|
||||
if (mission.getActivityState() != ActivityType.OPEN_STATE){
|
||||
if (open[1] == activityId){
|
||||
iterator.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 功能未开启的表
|
||||
if (open[0] == 2){
|
||||
if (!GlobalDataManaager.getInstance().checkIsOpen(open[1])){
|
||||
iterator.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 单独活动信息处理
|
||||
SGlobalActivity activity = activityMap.get(activityId);
|
||||
if (activity == null){
|
||||
continue;
|
||||
}
|
||||
AbstractActivity activityType = ActivityTypeEnum.getActicityById(activityId);
|
||||
if (activityType == null || list.isEmpty()){
|
||||
continue;
|
||||
}
|
||||
list.removeAll(activityType.getCloseGoods(user));
|
||||
}
|
||||
return list;
|
||||
// User user = UserManager.getUser(uid);
|
||||
// Set<Integer> list = new HashSet<>();
|
||||
// // 礼包是否打开
|
||||
// NewRechargeInfo rechargeInfo = user.getPlayerInfoManager().getNewRechargeInfo();
|
||||
// Map<Integer, SRechargeCommodityNewConfig> configMap = SRechargeCommodityNewConfig.configMap;
|
||||
// // 次数,推送,永久礼包一起处理
|
||||
// ArrayList<AbstractWelfareBag> welfareBags = new ArrayList<>(rechargeInfo.getPerpetualMap().values());
|
||||
// welfareBags.addAll(rechargeInfo.getTimeLimitMap().values());
|
||||
// welfareBags.addAll(rechargeInfo.getReceiveMap().values());
|
||||
// for (AbstractWelfareBag bag : welfareBags) {
|
||||
// if(bag.isOpen()){
|
||||
// if (bag.getLimit() == 0 || bag.getLimit() > bag.getBuyTimes()){
|
||||
// list.add(bag.getModId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // getLimit方法实现不同,需要特殊处理
|
||||
// for (AbstractWelfareBag value : rechargeInfo.getPushMap().values()) {
|
||||
// PushWelfareBag bag = (PushWelfareBag) value;
|
||||
// if(bag.isOpen()){
|
||||
// if (bag.getLimit() == 0 || bag.getLimit() > bag.getBuyTimes()){
|
||||
// list.add(bag.getModId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 走表判断开启的礼包
|
||||
// Map<Integer, SGlobalActivity> activityMap = SGlobalActivity.getsGlobalActivityMap();
|
||||
// Map<Integer, ActivityMission> missionMap = user.getActivityManager().getActivityMissionMap();
|
||||
//
|
||||
// for (Map.Entry<Integer, ActivityMission> entry : missionMap.entrySet()) {
|
||||
// int activityId = entry.getKey();
|
||||
// ActivityMission mission = entry.getValue();
|
||||
// // 遍历
|
||||
// Iterator<Integer> iterator = list.iterator();
|
||||
// while (iterator.hasNext()){
|
||||
// SRechargeCommodityNewConfig config = configMap.get(iterator.next());
|
||||
// // 表控制不显示
|
||||
// if (config.getIsShowInWeb() == 0){
|
||||
// iterator.remove();
|
||||
// continue;
|
||||
// }
|
||||
// // 未加入公会,不显示公会红包
|
||||
// if (user.getPlayerInfoManager().getGuildId() == 0 && config.getType() == 10){
|
||||
// iterator.remove();
|
||||
// continue;
|
||||
// }
|
||||
// // 一键购买处理
|
||||
// if (config.getForbid() != null) {
|
||||
// config.getForbid();
|
||||
// for (int i : config.getForbid()) {
|
||||
// // 已购买任意礼包,不能获取一键购买
|
||||
// if (!list.contains(i)) {
|
||||
// iterator.remove();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// for (int[] open : config.getOnSaleRule()) {
|
||||
// // 活动未开启的礼包
|
||||
// if (open[0] == 3){
|
||||
// if (mission.getActivityState() != ActivityType.OPEN_STATE){
|
||||
// if (open[1] == activityId){
|
||||
// iterator.remove();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // 功能未开启的表
|
||||
// if (open[0] == 2){
|
||||
// if (!GlobalDataManaager.getInstance().checkIsOpen(open[1])){
|
||||
// iterator.remove();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // 单独活动信息处理
|
||||
// SGlobalActivity activity = activityMap.get(activityId);
|
||||
// if (activity == null){
|
||||
// continue;
|
||||
// }
|
||||
// AbstractActivity activityType = ActivityTypeEnum.getActicityById(activityId);
|
||||
// if (activityType == null || list.isEmpty()){
|
||||
// continue;
|
||||
// }
|
||||
// list.removeAll(activityType.getCloseGoods(user));
|
||||
// }
|
||||
// return list;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static CommonProto.GiftGoodsInfo buildGoodsInfo(AbstractWelfareBag bag){
|
||||
|
@ -832,18 +831,25 @@ public class BuyGoodsNewLogic {
|
|||
builder.setEndTime((int)(bag.getRefreshTime()/1000));
|
||||
}
|
||||
}
|
||||
|
||||
if(bag.getType() == RechargeType.receive.getType() && bag.getEndTime() == 0){
|
||||
builder.setEndTime((int)((bag.getStartTime() + bag.getContinueDays() * TimeUtils.DAY)/1000));
|
||||
}
|
||||
|
||||
// 礼包类型特殊处理,使用bought字段验证是否购买
|
||||
if(bag.getType() == RechargeType.receive.getType()){
|
||||
ReceiveWelfareBag receiveBag = (ReceiveWelfareBag) bag;
|
||||
int bought = receiveBag.isBought()?1:0;
|
||||
builder.setIsBought(bought);
|
||||
}
|
||||
|
||||
if (bag.getType() == RechargeType.push.getType() && builder.getDynamicBuyTimes() <= 0){
|
||||
return null;
|
||||
}
|
||||
|
||||
if (bag.getType() == RechargeType.gmSingle.getType()){
|
||||
builder.setStartTime(0);
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,13 +13,7 @@ import java.util.Map;
|
|||
public class NewRechargeInfo extends MongoBase {
|
||||
|
||||
private double rr;//累计充值
|
||||
|
||||
private double realityRmb;
|
||||
private double maxSingleR;//单次最大充值金额
|
||||
|
||||
private double monthRr ; //月卡累计总额
|
||||
private double sMonthRr ; //豪华月卡累计总额
|
||||
private double sinceremonth ; //挚礼月卡累计总额
|
||||
private double realityRmb;//rmb累计金额
|
||||
|
||||
private Map<Long, Double> rechargeList = new HashMap<>();//充值记录
|
||||
|
||||
|
@ -27,12 +21,11 @@ public class NewRechargeInfo extends MongoBase {
|
|||
private Map<Integer, AbstractWelfareBag> timeLimitMap = new HashMap<>();//限时刷新礼包
|
||||
private Map<Integer, AbstractWelfareBag> receiveMap = new HashMap<>();//限时刷新礼包
|
||||
private Map<Integer, AbstractWelfareBag> pushMap = new HashMap<>();//推送礼包
|
||||
private Map<Integer, AbstractWelfareBag> gmSingleMap = new HashMap<>();//gm单笔礼包
|
||||
|
||||
private long nextPushTime; //上次推送时间
|
||||
|
||||
private Map<Integer,Long>typePushTimeMap=new HashMap<>();//记录推送条件类型cd时间
|
||||
|
||||
private Map<Integer,Integer> dayPushNumMap =new HashMap<>();//记录当天推送次数
|
||||
|
||||
private Map<Integer,Integer> allPushNumMap =new HashMap<>();//记录历史推送次数
|
||||
|
||||
private long lastRefreshTime;
|
||||
|
@ -111,52 +104,21 @@ public class NewRechargeInfo extends MongoBase {
|
|||
updateString("rr",rr);
|
||||
}
|
||||
|
||||
public double getMonthRr() {
|
||||
return monthRr;
|
||||
}
|
||||
|
||||
public void setMonthRr(double monthRr) {
|
||||
this.monthRr = monthRr;
|
||||
updateString("monthRr",monthRr);
|
||||
|
||||
}
|
||||
|
||||
public double getsMonthRr() {
|
||||
return sMonthRr;
|
||||
}
|
||||
|
||||
public void setsMonthRr(double sMonthRr) {
|
||||
this.sMonthRr = sMonthRr;
|
||||
updateString("sMonthRr",sMonthRr);
|
||||
}
|
||||
|
||||
public double getSinceremonth() {
|
||||
return sinceremonth;
|
||||
}
|
||||
|
||||
public void setSinceremonth(double sinceremonth) {
|
||||
this.sinceremonth = sinceremonth;
|
||||
updateString("sinceremonth",sinceremonth);
|
||||
}
|
||||
|
||||
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 Map<Integer, AbstractWelfareBag> getGmSingleMap() {
|
||||
return gmSingleMap;
|
||||
}
|
||||
|
||||
public void addPerpetual(PerpetualWelfareBag bag){
|
||||
perpetualMap.put(bag.getModId(),bag);
|
||||
|
@ -182,6 +144,12 @@ public class NewRechargeInfo extends MongoBase {
|
|||
updateString("pushMap."+bag.getModId(),bag);
|
||||
}
|
||||
|
||||
public void addGmSingle(GmSingleWelfareBag bag) {
|
||||
gmSingleMap.put(bag.getModId(),bag);
|
||||
bag.init(this.getRootId(),getMongoKey() + ".gmSingleMap." + bag.getModId());
|
||||
updateString("gmSingleMap."+bag.getModId(),bag);
|
||||
}
|
||||
|
||||
public void removePerpetualMap(int modId){
|
||||
perpetualMap.remove(modId);
|
||||
removeString(getMongoKey() + ".perpetualMap."+modId);
|
||||
|
@ -201,6 +169,28 @@ public class NewRechargeInfo extends MongoBase {
|
|||
pushMap.remove(modId);
|
||||
removeString(getMongoKey() + ".pushMap."+modId);
|
||||
}
|
||||
|
||||
public void removeGmSingle(int modId) {
|
||||
gmSingleMap.remove(modId);
|
||||
removeString(getMongoKey() + ".gmSingleMap."+modId);
|
||||
}
|
||||
|
||||
public void removeBag(int modId){
|
||||
if (getPerpetualMap().containsKey(modId)){
|
||||
removePerpetualMap(modId);
|
||||
}
|
||||
if (getTimeLimitMap().containsKey(modId)){
|
||||
removeTimeLimitMap(modId);
|
||||
}
|
||||
if (getReceiveMap().containsKey(modId)){
|
||||
removeReceiveMap(modId);
|
||||
}
|
||||
if (getPushMap().containsKey(modId)){
|
||||
removePush(modId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public long getNextPushTime() {
|
||||
return nextPushTime;
|
||||
}
|
||||
|
@ -267,6 +257,11 @@ public class NewRechargeInfo extends MongoBase {
|
|||
updateString("lastRefreshTime",lastRefreshTime);
|
||||
}
|
||||
|
||||
public void setRechargeList(long _rechargeTime,double _rechargePrice) {
|
||||
this.rechargeList.put(_rechargeTime,_rechargePrice);
|
||||
updateString("rechargeList",this.rechargeList);
|
||||
}
|
||||
|
||||
///获取指定天数内累计充值金额
|
||||
public double GetAllRechargeNum(int _deyNum){
|
||||
double rechargeNum=0;
|
||||
|
|
|
@ -11,6 +11,7 @@ public enum RechargeType {
|
|||
timeLimit(2,new TimeLimitHandler()),
|
||||
receive(3,new ReceiveHandler()),
|
||||
push(4,new PushHandler()),
|
||||
gmSingle(5,new GmSingleHandler()),
|
||||
;
|
||||
|
||||
private int type;
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package com.ljsd.jieling.logic.store.newRechargeInfo.bean;
|
||||
|
||||
import com.ljsd.jieling.db.mongo.gmActivity.GiftMission;
|
||||
import com.ljsd.jieling.logic.activity.activityLogic.GmSingleActivityLogic;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
||||
/**
|
||||
* 永久礼包
|
||||
*/
|
||||
public class GmSingleWelfareBag extends AbstractWelfareBag {
|
||||
|
||||
public GmSingleWelfareBag(){}
|
||||
|
||||
public GmSingleWelfareBag(int giftId, int activityId) {
|
||||
setModId(giftId);
|
||||
setStartTime(activityId);
|
||||
setOpen(true);
|
||||
this.setRootCollection(User._COLLECTION_NAME);
|
||||
}
|
||||
public void buy() {
|
||||
addBuyTimes(1);
|
||||
}
|
||||
|
||||
public int getLimit(){
|
||||
GiftMission mission = GmSingleActivityLogic.getInstance().findGiftMission(super.getModId());
|
||||
if (mission != null){
|
||||
return mission.getBuyLimitCount();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package com.ljsd.jieling.logic.store.newRechargeInfo.rechargeHandler;
|
||||
|
||||
import com.ljsd.jieling.db.mongo.gmActivity.GiftMission;
|
||||
import com.ljsd.jieling.logic.activity.activityLogic.GmSingleActivityLogic;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.store.newRechargeInfo.bean.AbstractWelfareBag;
|
||||
import com.ljsd.jieling.logic.store.newRechargeInfo.bean.GmSingleWelfareBag;
|
||||
import config.SRechargeCommodityNewConfig;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2021/4/20
|
||||
* @discribe
|
||||
*/
|
||||
public class GmSingleHandler extends AbstractRechargeHandler {
|
||||
|
||||
@Override
|
||||
public boolean refreshStatus(User user, int rechargeId){
|
||||
boolean result = false;
|
||||
AbstractWelfareBag bag = getRechargeMap(user).get(rechargeId);
|
||||
if (bag == null){
|
||||
return false;
|
||||
}
|
||||
GiftMission mission = GmSingleActivityLogic.getInstance().findGiftMission(rechargeId);
|
||||
if (mission == null){
|
||||
user.getPlayerInfoManager().getNewRechargeInfo().removeGmSingle(rechargeId);
|
||||
result = true;
|
||||
}
|
||||
else if (bag.getStartTime() != mission.getActivityId()){
|
||||
bag.setStartTime(mission.getActivityId());
|
||||
bag.resetBuyTimes();
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ? extends AbstractWelfareBag> getRechargeMap(User user) {
|
||||
return user.getPlayerInfoManager().getNewRechargeInfo().getGmSingleMap();
|
||||
}
|
||||
|
||||
public boolean rechargeIsInBag(User user, int rechargeId) {
|
||||
return getRechargeMap(user).containsKey(rechargeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractWelfareBag initUnitWF(User user, SRechargeCommodityNewConfig config) {
|
||||
Map<Integer, List<Integer>> singleIdMap = user.getGmActivityManager().getGmSingleIdMap();
|
||||
GmSingleWelfareBag bag = null;
|
||||
for (Map.Entry<Integer, List<Integer>> entry : singleIdMap.entrySet()) {
|
||||
Integer activityId = entry.getKey();
|
||||
List<Integer> idList = entry.getValue();
|
||||
if (idList.contains(config.getId())){
|
||||
bag = new GmSingleWelfareBag(config.getId(), activityId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return bag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNew(User user, AbstractWelfareBag bag) {
|
||||
if (bag == null){
|
||||
return;
|
||||
}
|
||||
user.getPlayerInfoManager().getNewRechargeInfo().addGmSingle((GmSingleWelfareBag) bag);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package com.ljsd.jieling.util;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ExpiryHashMap<K, V> extends HashMap<K, V> {
|
||||
/**
|
||||
* 记录每个entry的到期时间
|
||||
*/
|
||||
private HashMap<K, Date> expireMap = new HashMap<K, Date>();
|
||||
|
||||
/**
|
||||
* 判断entry是否到期
|
||||
*/
|
||||
private boolean isExpire(K key) {
|
||||
if (!super.containsKey(key)) return true;
|
||||
|
||||
Date expireDate = this.expireMap.get(key);
|
||||
return DateUtil.now().after(expireDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 存
|
||||
*
|
||||
* @param survivalTime 该entry的存活时间,单位毫秒
|
||||
*/
|
||||
public V put(K key, V value, Long survivalTime) {
|
||||
this.expireMap.put(key, DateUtil.afterDate(DateUtil.now(), survivalTime));
|
||||
return super.put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取
|
||||
*/
|
||||
@Override
|
||||
public V get(Object key) {
|
||||
K k = (K) key;
|
||||
if (isExpire(k)) return null;
|
||||
return super.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
K k = (K) key;
|
||||
if (isExpire(k)) return false;
|
||||
return super.containsKey(key);
|
||||
}
|
||||
|
||||
|
||||
private static class DateUtil {
|
||||
private static Date now() {
|
||||
return new Date();
|
||||
}
|
||||
|
||||
/**
|
||||
* date后ms毫秒的时间
|
||||
*
|
||||
* @param ms 毫秒数
|
||||
*/
|
||||
private static Date afterDate(Date date, Long ms) {
|
||||
return new Date(date.getTime() + ms);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
ExpiryHashMap<String, String> expiryHashMap = new ExpiryHashMap<>();
|
||||
expiryHashMap.put("name", "smlt", 1000L);
|
||||
System.out.println(expiryHashMap.get("name"));// smlt
|
||||
Thread.sleep(2000);
|
||||
System.out.println(expiryHashMap.get("name"));// null
|
||||
}
|
||||
}
|
|
@ -20,7 +20,6 @@ public class SRechargeCommodityNewConfig implements BaseConfig {
|
|||
private int type;
|
||||
|
||||
private double price;
|
||||
private int tianJianglibao;
|
||||
private int[][] firstMultiple;
|
||||
private int[] continuedMultiple;
|
||||
private int[][] baseReward;
|
||||
|
@ -195,8 +194,4 @@ public class SRechargeCommodityNewConfig implements BaseConfig {
|
|||
public int[][] getGainCrystal() {
|
||||
return gainCrystal;
|
||||
}
|
||||
|
||||
public int getTianJianglibao() {
|
||||
return tianJianglibao;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue