新周卡功能
parent
9f3e6f2efe
commit
8e3cc63702
|
@ -0,0 +1,37 @@
|
||||||
|
package com.ljsd.jieling.handler.activity;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.exception.ErrorCode;
|
||||||
|
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||||
|
import com.ljsd.jieling.handler.BaseHandler;
|
||||||
|
import com.ljsd.jieling.logic.activity.activityLogic.WeekCardLogic;
|
||||||
|
import com.ljsd.jieling.logic.dao.UserManager;
|
||||||
|
import com.ljsd.jieling.logic.dao.root.User;
|
||||||
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import rpc.protocols.MessageTypeProto;
|
||||||
|
import rpc.protocols.PlayerInfoProto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author hj
|
||||||
|
* @Date 2021/6/8 15:40
|
||||||
|
* @Description: 查询周卡信息
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class GetWeekCardRewardHandler extends BaseHandler<PlayerInfoProto.GetWeekCardRewardRequest> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MessageTypeProto.MessageType getMessageCode() {
|
||||||
|
return MessageTypeProto.MessageType.GetWeekCardRewardRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processWithProto(ISession iSession, PlayerInfoProto.GetWeekCardRewardRequest proto) throws Exception {
|
||||||
|
// 用户信息
|
||||||
|
User user = UserManager.getUser(iSession.getUid());
|
||||||
|
if (user == null) {
|
||||||
|
throw new ErrorCodeException(ErrorCode.UNKNOWN);
|
||||||
|
}
|
||||||
|
WeekCardLogic.getInstance().getWeekCardReward(user,proto);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.ljsd.jieling.handler.activity;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.exception.ErrorCode;
|
||||||
|
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||||
|
import com.ljsd.jieling.handler.BaseHandler;
|
||||||
|
import com.ljsd.jieling.logic.activity.activityLogic.WeekCardLogic;
|
||||||
|
import com.ljsd.jieling.logic.dao.UserManager;
|
||||||
|
import com.ljsd.jieling.logic.dao.root.User;
|
||||||
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import rpc.protocols.MessageTypeProto;
|
||||||
|
import rpc.protocols.PlayerInfoProto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author hj
|
||||||
|
* @Date 2021/6/8 15:40
|
||||||
|
* @Description: 查询周卡信息
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class QueryWeekCardInfoHandler extends BaseHandler<PlayerInfoProto.QueryWeekCardInfoRequest> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MessageTypeProto.MessageType getMessageCode() {
|
||||||
|
return MessageTypeProto.MessageType.QueryWeekCardInfoRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processWithProto(ISession iSession, PlayerInfoProto.QueryWeekCardInfoRequest proto) throws Exception {
|
||||||
|
// 用户信息
|
||||||
|
User user = UserManager.getUser(iSession.getUid());
|
||||||
|
if (user == null) {
|
||||||
|
throw new ErrorCodeException(ErrorCode.UNKNOWN);
|
||||||
|
}
|
||||||
|
WeekCardLogic.getInstance().queryWeekCardInfo(user,proto.getActiviteId());
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,73 +0,0 @@
|
||||||
package com.ljsd.jieling.handler.activity;
|
|
||||||
|
|
||||||
import com.ljsd.jieling.globals.BIReason;
|
|
||||||
import com.ljsd.jieling.handler.BaseHandler;
|
|
||||||
import com.ljsd.jieling.logic.dao.UserManager;
|
|
||||||
import com.ljsd.jieling.logic.dao.WeekCardInfo;
|
|
||||||
import com.ljsd.jieling.logic.dao.root.User;
|
|
||||||
import com.ljsd.jieling.network.session.ISession;
|
|
||||||
import com.ljsd.jieling.util.ItemUtil;
|
|
||||||
import com.ljsd.jieling.util.MessageUtil;
|
|
||||||
import config.SWeekcardConfig;
|
|
||||||
import manager.STableManager;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import rpc.protocols.ActivityProto;
|
|
||||||
import rpc.protocols.CommonProto;
|
|
||||||
import rpc.protocols.MessageTypeProto;
|
|
||||||
import util.TimeUtils;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 周卡领奖
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class WeekCardHandler extends BaseHandler<ActivityProto.WeekCardRewardRequest> {
|
|
||||||
@Override
|
|
||||||
public MessageTypeProto.MessageType getMessageCode() {
|
|
||||||
return MessageTypeProto.MessageType.WeekCardRewardRequest;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void processWithProto(ISession session, ActivityProto.WeekCardRewardRequest proto) throws Exception{
|
|
||||||
User user = UserManager.getUser(session.getUid());
|
|
||||||
int weekId = proto.getId();
|
|
||||||
Map<Integer, WeekCardInfo> weekCard = user.getPlayerInfoManager().getWeekCard();
|
|
||||||
ActivityProto.WeekCardRewardResponse.Builder res = ActivityProto.WeekCardRewardResponse.newBuilder();
|
|
||||||
if(!weekCard.containsKey(weekId)){
|
|
||||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.WeekCardRewardResponse.getNumber(), res.build(), true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
WeekCardInfo singleWeekCard = weekCard.get(weekId);
|
|
||||||
//没买或者过期
|
|
||||||
if(!singleWeekCard.isBuy()&&!TimeUtils.isSameWeek7(singleWeekCard.getBugTime())){
|
|
||||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.WeekCardRewardResponse.getNumber(), res.build(), true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Map<Integer, SWeekcardConfig> config = STableManager.getConfig(SWeekcardConfig.class);
|
|
||||||
if(!config.containsKey(weekId)){
|
|
||||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.WeekCardRewardResponse.getNumber(), res.build(), true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Map<Integer,Integer>dropMap = new HashMap<>();
|
|
||||||
for(int i=TimeUtils.getDayOfWeek()-singleWeekCard.getLeaveGetRewardDays();i>0;i--){
|
|
||||||
int [][]drop =config.get(weekId).getBaseReward();
|
|
||||||
for(int[] single:drop){
|
|
||||||
if(dropMap.containsKey(single[0])){
|
|
||||||
dropMap.put(single[0],dropMap.get(single[0])+single[1]);
|
|
||||||
}else{
|
|
||||||
dropMap.put(single[0],single[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int [][] dropArray= dropMap.entrySet().stream().map(n->new int[]{n.getKey(),n.getValue()}).toArray(int[][]::new);
|
|
||||||
CommonProto.Drop.Builder drop = ItemUtil.dropPer(user, dropArray, BIReason.WEEK_CARD_REWARD);
|
|
||||||
res.setDrop(drop);
|
|
||||||
singleWeekCard.setLeaveGetRewardDays(TimeUtils.getDayOfWeek());
|
|
||||||
user.getPlayerInfoManager().setWeekCard(weekCard);
|
|
||||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.WeekCardRewardResponse.getNumber(), res.build(), true);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
package com.ljsd.jieling.handler.activity;
|
|
||||||
|
|
||||||
import com.ljsd.jieling.handler.BaseHandler;
|
|
||||||
import com.ljsd.jieling.logic.activity.activityLogic.WeekCardLogic;
|
|
||||||
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 rpc.protocols.ActivityProto;
|
|
||||||
import rpc.protocols.CommonProto;
|
|
||||||
import rpc.protocols.MessageTypeProto;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class WeekCardInfoHandler extends BaseHandler<ActivityProto.WeekCardInfoRequest> {
|
|
||||||
@Override
|
|
||||||
public MessageTypeProto.MessageType getMessageCode() {
|
|
||||||
return MessageTypeProto.MessageType.WeekCardInfoRequest;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取可购买的周卡列表
|
|
||||||
* @param session
|
|
||||||
* @param proto
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void processWithProto(ISession session, ActivityProto.WeekCardInfoRequest proto) throws Exception{
|
|
||||||
ActivityProto.WeekCardInfoResponse.Builder res = ActivityProto.WeekCardInfoResponse.newBuilder();
|
|
||||||
User user = UserManager.getUser(session.getUid());
|
|
||||||
int[] weekType = WeekCardLogic.getInstance().getWeekCardType(user);
|
|
||||||
if(weekType == null){
|
|
||||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.WeekCardInfoResponse.getNumber(), res.build(), true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<CommonProto.WeekCard> weekCardList = WeekCardLogic.getInstance().initAllWeekCardInfo(user);
|
|
||||||
res.addAllAllWeekCardInfo(weekCardList);
|
|
||||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.WeekCardInfoResponse.getNumber(), res.build(), true);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -461,9 +461,8 @@ public class GlobalDataManaager implements IManager {
|
||||||
// 御剑行
|
// 御剑行
|
||||||
RidingSwardLogic.getInstance().zeroClearRidingSwardByUser(user);
|
RidingSwardLogic.getInstance().zeroClearRidingSwardByUser(user);
|
||||||
//周卡邮件发放未领取奖励
|
//周卡邮件发放未领取奖励
|
||||||
WeekCardLogic.getInstance().sendWeekCardRewardMail(session);
|
// WeekCardLogic.getInstance().sendWeekCardRewardMail(session);
|
||||||
//周卡每日刷新
|
WeekCardLogic.getInstance().weekCardInfoIndication(user,0,0);
|
||||||
WeekCardLogic.getInstance().sendWeekCardInitInfo(session);
|
|
||||||
//TODO
|
//TODO
|
||||||
ChallengeLogic.getInstance().ChallengeInfoIndication(session);
|
ChallengeLogic.getInstance().ChallengeInfoIndication(session);
|
||||||
// GuildChallengeLogic.getInstance().resetBossDamage(user);
|
// GuildChallengeLogic.getInstance().resetBossDamage(user);
|
||||||
|
|
|
@ -132,4 +132,6 @@ public interface ActivityType {
|
||||||
|
|
||||||
int DAILY_SPECIAL = 10004;//每日特惠
|
int DAILY_SPECIAL = 10004;//每日特惠
|
||||||
int WHOLE_LIFE_CARD = 99;//终生卡
|
int WHOLE_LIFE_CARD = 99;//终生卡
|
||||||
|
|
||||||
|
int WEEK_CARD = 102;//月卡
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,8 @@ public enum ActivityTypeEnum {
|
||||||
POWER_RICE_ACTIVITY(ActivityType.POWER_RICE_ACTIVITY,PowerRiceActivity::new),//战力冲刺
|
POWER_RICE_ACTIVITY(ActivityType.POWER_RICE_ACTIVITY,PowerRiceActivity::new),//战力冲刺
|
||||||
DONGHAI_XUNXIAN_ACTIVITY(ActivityType.DonghaiXunxian,DonghaiXunxianActivity::new),//东海寻仙
|
DONGHAI_XUNXIAN_ACTIVITY(ActivityType.DonghaiXunxian,DonghaiXunxianActivity::new),//东海寻仙
|
||||||
WHOEL_LIFE_ACTIVITY(ActivityType.WHOLE_LIFE_CARD,WholeLifeActivity::new),//东海寻仙
|
WHOEL_LIFE_ACTIVITY(ActivityType.WHOLE_LIFE_CARD,WholeLifeActivity::new),//东海寻仙
|
||||||
|
|
||||||
|
WEEK_CARD(ActivityType.WEEK_CARD,WeekCardActivity::new),//月卡
|
||||||
;
|
;
|
||||||
|
|
||||||
private int type;
|
private int type;
|
||||||
|
|
|
@ -0,0 +1,141 @@
|
||||||
|
package com.ljsd.jieling.logic.activity;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.exception.ErrorCode;
|
||||||
|
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||||
|
import com.ljsd.jieling.globals.BIReason;
|
||||||
|
import com.ljsd.jieling.globals.Global;
|
||||||
|
import com.ljsd.jieling.jbean.ActivityMission;
|
||||||
|
import com.ljsd.jieling.jbean.ActivityProgressInfo;
|
||||||
|
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||||
|
import com.ljsd.jieling.logic.activity.activityLogic.WeekCardLogic;
|
||||||
|
import com.ljsd.jieling.logic.activity.event.IEvent;
|
||||||
|
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||||
|
import com.ljsd.jieling.logic.activity.event.SuperBoxEvent;
|
||||||
|
import com.ljsd.jieling.logic.dao.UserManager;
|
||||||
|
import com.ljsd.jieling.logic.dao.root.User;
|
||||||
|
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||||
|
import com.ljsd.jieling.logic.store.newRechargeInfo.NewRechargeInfo;
|
||||||
|
import com.ljsd.jieling.logic.store.newRechargeInfo.RechargeType;
|
||||||
|
import com.ljsd.jieling.logic.store.newRechargeInfo.bean.AbstractWelfareBag;
|
||||||
|
import com.ljsd.jieling.logic.store.newRechargeInfo.bean.PerpetualWelfareBag;
|
||||||
|
import com.ljsd.jieling.logic.store.newRechargeInfo.bean.ReceiveWelfareBag;
|
||||||
|
import com.ljsd.jieling.logic.store.newRechargeInfo.rechargeHandler.RechargeHandler;
|
||||||
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
import com.ljsd.jieling.util.ItemUtil;
|
||||||
|
import com.ljsd.jieling.util.MessageUtil;
|
||||||
|
import config.*;
|
||||||
|
import manager.STableManager;
|
||||||
|
import rpc.protocols.CommonProto;
|
||||||
|
import rpc.protocols.PlayerInfoProto;
|
||||||
|
import util.TimeUtils;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hj
|
||||||
|
* 超值基金活动新
|
||||||
|
* 2022-1-24
|
||||||
|
*/
|
||||||
|
public class WeekCardActivity extends AbstractActivity {
|
||||||
|
|
||||||
|
WeekCardActivity(int id) {
|
||||||
|
super(id);
|
||||||
|
Poster.getPoster().listenEvent(this, SuperBoxEvent.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initActivity(User user) throws Exception {
|
||||||
|
ActivityMission mission = new ActivityMission();
|
||||||
|
// 活动信息初始化
|
||||||
|
ActivityLogic.getInstance().initOtherMission(mission, new ArrayList<>());
|
||||||
|
user.getActivityManager().getActivityMissionMap().put(id, mission);
|
||||||
|
|
||||||
|
// 初始化礼包信息
|
||||||
|
user.getPlayerInfoManager().setWeekCard(new HashMap<>());
|
||||||
|
|
||||||
|
LOGGER.info("月卡初始化...uid={} activityId={}",user.getId(), id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEvent(IEvent event) throws Exception {
|
||||||
|
// 类型验证
|
||||||
|
if (!(event instanceof SuperBoxEvent)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 获取信息
|
||||||
|
SuperBoxEvent event1 = (SuperBoxEvent) event;
|
||||||
|
User user = UserManager.getUser(event1.getUserId());
|
||||||
|
Map<Integer, Map<Integer, Integer>> weekCard = user.getPlayerInfoManager().getWeekCard();
|
||||||
|
|
||||||
|
List<SWeekcardRotationConfig> rotationConfigs = SWeekcardRotationConfig.getMap().get(id);
|
||||||
|
for (SWeekcardRotationConfig config : rotationConfigs) {
|
||||||
|
for (int[] ints : config.getWeekcardType()) {
|
||||||
|
if (ints[2] == event1.getGiftId() && weekCard.get(event1.getGiftId()) == null){
|
||||||
|
weekCard.put(event1.getGiftId(),new HashMap<>());
|
||||||
|
user.getPlayerInfoManager().setWeekCard(weekCard);
|
||||||
|
WeekCardLogic.getInstance().weekCardInfoIndication(user,event1.getGiftId(),id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityEndDealReward(User user) throws Exception {
|
||||||
|
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id);
|
||||||
|
if (null == sGlobalActivity) {
|
||||||
|
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH,"周卡活动不存在:"+id);
|
||||||
|
}
|
||||||
|
List<int[][]> itemArrs = new LinkedList<>();
|
||||||
|
Map<Integer, Map<Integer, Integer>> weekCard = user.getPlayerInfoManager().getWeekCard();
|
||||||
|
Map<Integer, SWeekRewardConfig> rewardConfigMap = STableManager.getConfig(SWeekRewardConfig.class);
|
||||||
|
Map<Integer, SWeekcardConfig> configMap = STableManager.getConfig(SWeekcardConfig.class);
|
||||||
|
// 计算间隔时间
|
||||||
|
long startTimeLong = sGlobalActivity.getStartTimeLong();
|
||||||
|
int days = TimeUtils.differentDays(startTimeLong, TimeUtils.now());
|
||||||
|
for (Map.Entry<Integer, Map<Integer, Integer>> entry : weekCard.entrySet()) {
|
||||||
|
|
||||||
|
Integer weekCardId = entry.getKey();
|
||||||
|
Map<Integer, Integer> value = entry.getValue();
|
||||||
|
|
||||||
|
SWeekcardConfig weekcardConfig = configMap.get(weekCardId);
|
||||||
|
if (weekcardConfig == null){
|
||||||
|
LOGGER.error("月卡活动结束发送奖励,月卡不存在,月卡id:"+weekCard);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (Map.Entry<Integer, Integer> valueEntry : value.entrySet()) {
|
||||||
|
if (valueEntry.getValue() == 2){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (days > valueEntry.getKey()){
|
||||||
|
LOGGER.error("月卡活动结束发送奖励,存在超过活动天数的月卡奖励,月卡id:"+weekCard+",活动开启时间+活动结束时间:"+startTimeLong+"+"+TimeUtils.now()+",月卡需求天数:"+valueEntry.getKey());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (valueEntry.getKey() > weekcardConfig.getBaseRewardID().length){
|
||||||
|
LOGGER.error("月卡活动结束发送奖励,存在超过配置天数的月卡奖励,月卡id:"+weekCard+",月卡需求天数:"+valueEntry.getKey());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int[] ints = weekcardConfig.getBaseRewardID()[valueEntry.getKey() - 1];
|
||||||
|
SWeekRewardConfig rewardConfig = rewardConfigMap.get(ints[1]);
|
||||||
|
if (rewardConfig == null){
|
||||||
|
LOGGER.error("月卡活动结束发送奖励,存在没有配置的奖励id,月卡id:"+weekCard+",奖励id:"+ints[1]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
itemArrs.add(new int[][]{rewardConfig.getBaseReward()});
|
||||||
|
value.put(valueEntry.getKey(),2);
|
||||||
|
}
|
||||||
|
weekCard.put(weekCardId,value);
|
||||||
|
}
|
||||||
|
if (itemArrs.size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 更新数据
|
||||||
|
user.getPlayerInfoManager().setWeekCard(weekCard);
|
||||||
|
// 发送邮件
|
||||||
|
String title = SErrorCodeEerverConfig.getI18NMessageNeedConvert("receive_activity_title", new Object[]{sGlobalActivity.getSesc()},new int[]{1},"#");
|
||||||
|
String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("receive_activity_txt", new Object[]{sGlobalActivity.getSesc()},new int[]{1},"#");
|
||||||
|
String mailReward = ItemUtil.getMailReward(itemArrs);
|
||||||
|
MailLogic.getInstance().sendMail(user.getId(), title, content, mailReward, TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,26 +1,32 @@
|
||||||
package com.ljsd.jieling.logic.activity.activityLogic;
|
package com.ljsd.jieling.logic.activity.activityLogic;
|
||||||
|
|
||||||
|
|
||||||
import com.ljsd.jieling.globals.Global;
|
import com.ljsd.jieling.exception.ErrorCode;
|
||||||
import com.ljsd.jieling.logic.activity.ActivityType;
|
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||||
|
import com.ljsd.jieling.globals.BIReason;
|
||||||
|
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||||
import com.ljsd.jieling.logic.dao.UserManager;
|
import com.ljsd.jieling.logic.dao.UserManager;
|
||||||
import com.ljsd.jieling.logic.dao.WeekCardInfo;
|
|
||||||
import com.ljsd.jieling.logic.dao.root.User;
|
import com.ljsd.jieling.logic.dao.root.User;
|
||||||
import com.ljsd.jieling.logic.mail.MailLogic;
|
import com.ljsd.jieling.logic.store.newRechargeInfo.RechargeType;
|
||||||
|
import com.ljsd.jieling.logic.store.newRechargeInfo.bean.AbstractWelfareBag;
|
||||||
|
import com.ljsd.jieling.logic.store.newRechargeInfo.rechargeHandler.RechargeHandler;
|
||||||
|
import com.ljsd.jieling.network.server.SessionManager;
|
||||||
import com.ljsd.jieling.network.session.ISession;
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
import com.ljsd.jieling.util.ItemUtil;
|
||||||
import com.ljsd.jieling.util.MessageUtil;
|
import com.ljsd.jieling.util.MessageUtil;
|
||||||
import com.ljsd.jieling.util.ToolsUtil;
|
import config.SGlobalActivity;
|
||||||
import config.SErrorCodeEerverConfig;
|
import config.SRechargeCommodityNewConfig;
|
||||||
|
import config.SWeekRewardConfig;
|
||||||
import config.SWeekcardConfig;
|
import config.SWeekcardConfig;
|
||||||
import config.SWeekcardRotationConfig;
|
|
||||||
import manager.STableManager;
|
import manager.STableManager;
|
||||||
import rpc.protocols.ActivityProto;
|
|
||||||
import rpc.protocols.CommonProto;
|
import rpc.protocols.CommonProto;
|
||||||
import rpc.protocols.MessageTypeProto;
|
import rpc.protocols.MessageTypeProto;
|
||||||
import util.StringUtil;
|
import rpc.protocols.PlayerInfoProto;
|
||||||
import util.TimeUtils;
|
import util.TimeUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class WeekCardLogic {
|
public class WeekCardLogic {
|
||||||
|
|
||||||
|
@ -31,174 +37,139 @@ public class WeekCardLogic {
|
||||||
return WeekCardLogic.Instance.instance;
|
return WeekCardLogic.Instance.instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendWeekCardInitInfo(ISession session) throws Exception {
|
|
||||||
ActivityProto.WeekCardIndicationInfoResponse.Builder res = ActivityProto.WeekCardIndicationInfoResponse.newBuilder();
|
|
||||||
User user = UserManager.getUser(session.getUid());
|
|
||||||
List<CommonProto.WeekCard> weekCardList = initAllWeekCardInfo(user);
|
|
||||||
res.addAllAllWeekCardInfo(weekCardList);
|
|
||||||
//MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.WeekCardIndicationInfoResponse, res.build(), true);
|
|
||||||
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.WeekCardIndicationInfoResponse_VALUE, res.build(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendWeekCardRewardMail(ISession session) throws Exception {
|
|
||||||
//发每周未领取的奖励
|
|
||||||
User user = UserManager.getUser(session.getUid());
|
|
||||||
Map<Integer, WeekCardInfo> weekCard = user.getPlayerInfoManager().getWeekCard();
|
|
||||||
Map<Integer, Integer> dropMap = new HashMap<>();
|
|
||||||
boolean isSave = false;
|
|
||||||
for (WeekCardInfo weekCardVal : weekCard.values()) {
|
|
||||||
Map<Integer, SWeekcardConfig> config = STableManager.getConfig(SWeekcardConfig.class);
|
|
||||||
if (!config.containsKey(weekCardVal.getId())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!weekCardVal.isBuy()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (TimeUtils.isSameWeek7(weekCardVal.getBugTime())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (Calendar.DAY_OF_WEEK - weekCardVal.getLeaveGetRewardDays() > 0) {
|
|
||||||
for (int i = (Calendar.DAY_OF_WEEK - weekCardVal.getLeaveGetRewardDays()); i > 0; i--) {
|
|
||||||
int[][] drop = config.get(weekCardVal.getId()).getBaseReward();
|
|
||||||
for (int[] single : drop) {
|
|
||||||
if (dropMap.containsKey(single[0])) {
|
|
||||||
dropMap.put(single[0], dropMap.get(single[0]) + single[1]);
|
|
||||||
} else {
|
|
||||||
dropMap.put(single[0], single[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
weekCardVal.setBuy(false);
|
|
||||||
weekCardVal.setBugTime(0);
|
|
||||||
isSave = true;
|
|
||||||
} else {
|
|
||||||
weekCardVal.setBuy(false);
|
|
||||||
weekCardVal.setBugTime(0);
|
|
||||||
isSave = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isSave) {
|
|
||||||
user.getPlayerInfoManager().setWeekCard(weekCard);
|
|
||||||
}
|
|
||||||
if (dropMap.size() > 0) {
|
|
||||||
int[][] dropArray = dropMap.entrySet().stream().map(n -> new int[]{n.getKey(), n.getValue()}).toArray(int[][]::new);
|
|
||||||
String title = SErrorCodeEerverConfig.getI18NMessage("WeekcardReward_mail_title");
|
|
||||||
String content = SErrorCodeEerverConfig.getI18NMessage("WeekcardReward_mail_txt");
|
|
||||||
// 排行奖励
|
|
||||||
MailLogic.getInstance().sendMail(user.getId(), title, content,
|
|
||||||
StringUtil.parseArrayToString(dropArray), TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CommonProto.WeekCard> initAllWeekCardInfo(User user) throws Exception {
|
|
||||||
long time = user.getPlayerInfoManager().getWeekCardTimeFirst();
|
|
||||||
if (!TimeUtils.isSameWeek7(time)) {
|
|
||||||
user.getPlayerInfoManager().setWeekCardTimeFirstLevel(user.getPlayerInfoManager().getLevel());
|
|
||||||
user.getPlayerInfoManager().setWeekCardTimeFirst(TimeUtils.now());
|
|
||||||
}
|
|
||||||
int[] weekCardType = getWeekCardType(user);
|
|
||||||
Map<Integer, WeekCardInfo> weekCard = user.getPlayerInfoManager().getWeekCard();
|
|
||||||
Map<Integer, SWeekcardRotationConfig> config = STableManager.getConfig(SWeekcardRotationConfig.class);
|
|
||||||
boolean isSaveToDb = false;
|
|
||||||
List<CommonProto.WeekCard> weekCardList = new ArrayList<>();
|
|
||||||
if (weekCardType == null || weekCardType.length == 0) {
|
|
||||||
return weekCardList;
|
|
||||||
}
|
|
||||||
for (int i = 1; i < weekCardType.length; i++) {
|
|
||||||
CommonProto.WeekCard.Builder weekCardProto = CommonProto.WeekCard.newBuilder();
|
|
||||||
//周卡是否存在 判断是否过期
|
|
||||||
if (!weekCard.containsKey(weekCardType[i])) {
|
|
||||||
weekCard.put(weekCardType[i], new WeekCardInfo(weekCardType[i], false, 0, 0));
|
|
||||||
isSaveToDb = true;
|
|
||||||
}
|
|
||||||
WeekCardInfo singleWeekCard = weekCard.get(weekCardType[i]);
|
|
||||||
if (singleWeekCard.isBuy()) {
|
|
||||||
//买过周卡
|
|
||||||
if (!TimeUtils.isSameWeek7(singleWeekCard.getBugTime())) {
|
|
||||||
//周卡已经过期
|
|
||||||
singleWeekCard.setBuy(false);
|
|
||||||
singleWeekCard.setLeaveGetRewardDays(0);
|
|
||||||
isSaveToDb = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
weekCardProto.setId(singleWeekCard.getId());
|
|
||||||
weekCardProto.setIsBuy(singleWeekCard.isBuy());
|
|
||||||
weekCardProto.setLeaveGetRewardDays(TimeUtils.getDayOfWeek() - singleWeekCard.getLeaveGetRewardDays());
|
|
||||||
weekCardList.add(weekCardProto.build());
|
|
||||||
}
|
|
||||||
if (isSaveToDb) {
|
|
||||||
user.getPlayerInfoManager().setWeekCard(weekCard);
|
|
||||||
}
|
|
||||||
return weekCardList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void buyWeekCard(User user, int weekCardType) throws Exception {
|
|
||||||
Map<Integer, WeekCardInfo> weekCard = user.getPlayerInfoManager().getWeekCard();
|
|
||||||
int[] weekType = WeekCardLogic.getInstance().getWeekCardType(user);
|
|
||||||
if (weekType == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//根据礼包id 找出此时开卖的周卡id
|
|
||||||
int id = 0;
|
|
||||||
Map<Integer, SWeekcardConfig> config = STableManager.getConfig(SWeekcardConfig.class);
|
|
||||||
for (int i = 1; i < weekType.length; i++) {
|
|
||||||
if (config.containsKey(weekType[i])) {
|
|
||||||
if (config.get(weekType[i]).getRechargeId() == weekCardType) {
|
|
||||||
id = config.get(weekType[i]).getId();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (id == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!weekCard.containsKey(id)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
WeekCardInfo singleWeekCard = weekCard.get(id);
|
|
||||||
singleWeekCard.setBuy(true);
|
|
||||||
singleWeekCard.setBugTime(TimeUtils.now());
|
|
||||||
singleWeekCard.setLeaveGetRewardDays(0);
|
|
||||||
user.getPlayerInfoManager().setWeekCard(weekCard);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] getWeekCardType(User user) throws Exception {
|
|
||||||
Map<Integer, SWeekcardRotationConfig> config = STableManager.getConfig(SWeekcardRotationConfig.class);
|
|
||||||
for (SWeekcardRotationConfig con : config.values()) {
|
|
||||||
if (con.getTime() == ActivityType.OPEN_TYPE_ROLE) {
|
|
||||||
long userCreateTime = user.getPlayerInfoManager().getCreateTime();
|
|
||||||
long startTime = ToolsUtil.getTimeLong(Long.parseLong(con.getStartTime()), Long.parseLong(con.getEndtime()), con.getTime(), userCreateTime, 1);
|
|
||||||
long endTime = ToolsUtil.getTimeLong(Long.parseLong(con.getStartTime()), Long.parseLong(con.getEndtime()), con.getTime(), userCreateTime, 2);
|
|
||||||
if (TimeUtils.now() >= startTime && TimeUtils.now() <= endTime) {
|
|
||||||
return con.getWeekcardType()[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (con.getTime() == ActivityType.OPEN_TYPE_TIME) {
|
|
||||||
if (TimeUtils.now() >= TimeUtils.parseTimeToMiles(con.getStartTime(), TimeUtils.Stand_CeHua_Data_format)
|
|
||||||
&& TimeUtils.now() <= TimeUtils.parseTimeToMiles(con.getEndtime(), TimeUtils.Stand_CeHua_Data_format)) {
|
|
||||||
int[][] cardType = con.getWeekcardType();
|
|
||||||
int level = user.getPlayerInfoManager().getWeekCardTimeFirstLevel();
|
|
||||||
if (level == 0) {
|
|
||||||
level = user.getPlayerInfoManager().getLevel();
|
|
||||||
}
|
|
||||||
if (cardType.length > 1) {
|
|
||||||
if (level >= cardType[0][0] && level <= cardType[1][0]) {
|
|
||||||
return cardType[0];
|
|
||||||
} else {
|
|
||||||
return cardType[1];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return cardType[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Instance {
|
public static class Instance {
|
||||||
public final static WeekCardLogic instance = new WeekCardLogic();
|
public final static WeekCardLogic instance = new WeekCardLogic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取礼包信息
|
||||||
|
* @param user
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private AbstractWelfareBag getGift(User user, int giftId){
|
||||||
|
SRechargeCommodityNewConfig config = SRechargeCommodityNewConfig.configMap.get(giftId);
|
||||||
|
RechargeHandler rechargeHandler = RechargeType.getHandler(config.getOtype());
|
||||||
|
return rechargeHandler.getRechargeMap(user).get(giftId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 封装周卡信息
|
||||||
|
* @param cardId
|
||||||
|
* @param activityId
|
||||||
|
* @param valueMap
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private CommonProto.WeekCardInfo packagingWeekCardBuilder(int activityId, int cardId, Map<Integer,Integer> valueMap){
|
||||||
|
Map<Integer, SWeekcardConfig> config = STableManager.getConfig(SWeekcardConfig.class);
|
||||||
|
CommonProto.WeekCardInfo.Builder weekCardInfo = CommonProto.WeekCardInfo.newBuilder();
|
||||||
|
// 周卡id
|
||||||
|
weekCardInfo.setWeekcardId(cardId);
|
||||||
|
|
||||||
|
SWeekcardConfig sWeekcardConfig = config.get(cardId);
|
||||||
|
ArrayList<CommonProto.WeekCardDay> list1 = new ArrayList<>();
|
||||||
|
|
||||||
|
// 计算间隔时间
|
||||||
|
long startTimeLong = SGlobalActivity.getsGlobalActivityMap().get(activityId).getStartTimeLong();
|
||||||
|
int days = TimeUtils.differentDays(startTimeLong, TimeUtils.now());
|
||||||
|
|
||||||
|
for (int[] ints : sWeekcardConfig.getBaseRewardID()) {
|
||||||
|
int day = ints[0];
|
||||||
|
// 天数
|
||||||
|
CommonProto.WeekCardDay.Builder weekCardDay = CommonProto.WeekCardDay.newBuilder();
|
||||||
|
weekCardDay.setDay(day);
|
||||||
|
// 状态
|
||||||
|
int state = 0;
|
||||||
|
if (valueMap.getOrDefault(day,0) == 2){
|
||||||
|
state = 2;
|
||||||
|
}else {
|
||||||
|
if (days >= day){
|
||||||
|
state = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
weekCardDay.setState(state);
|
||||||
|
list1.add(weekCardDay.build());
|
||||||
|
}
|
||||||
|
weekCardInfo.addAllDay(list1);
|
||||||
|
return weekCardInfo.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询周卡信息
|
||||||
|
* @param user
|
||||||
|
* @param activtiyId
|
||||||
|
*/
|
||||||
|
public void queryWeekCardInfo(User user, int activtiyId){
|
||||||
|
ArrayList<CommonProto.WeekCardInfo> list = new ArrayList<>();
|
||||||
|
Map<Integer, Map<Integer, Integer>> weekCard = user.getPlayerInfoManager().getWeekCard();
|
||||||
|
for (Map.Entry<Integer, Map<Integer, Integer>> entry : weekCard.entrySet()) {
|
||||||
|
CommonProto.WeekCardInfo weekCardInfo = packagingWeekCardBuilder(activtiyId, entry.getKey(), entry.getValue());
|
||||||
|
list.add(weekCardInfo);
|
||||||
|
}
|
||||||
|
PlayerInfoProto.QueryWeekCardInfoResponse.Builder builder = PlayerInfoProto.QueryWeekCardInfoResponse.newBuilder().addAllWeekcard(list);
|
||||||
|
MessageUtil.sendMessage(user.getId(), 1, MessageTypeProto.MessageType.QueryWeekCardInfoResponse_VALUE, builder.build(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 领取周卡奖励
|
||||||
|
* @param user
|
||||||
|
* @param proto
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void getWeekCardReward(User user, PlayerInfoProto.GetWeekCardRewardRequest proto) throws Exception {
|
||||||
|
Map<Integer, Integer> map = user.getPlayerInfoManager().getWeekCard().get(proto.getWeekcardId());
|
||||||
|
if (map == null){
|
||||||
|
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE,"月卡id不存在:"+proto.getWeekcardId());
|
||||||
|
}
|
||||||
|
SWeekcardConfig weekcardConfig = STableManager.getConfig(SWeekcardConfig.class).get(proto.getWeekcardId());
|
||||||
|
if (weekcardConfig == null){
|
||||||
|
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE,"月卡id不存在配置表:"+proto.getWeekcardId());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 配置表
|
||||||
|
Map<Integer, SWeekRewardConfig> rewardConfigMap = STableManager.getConfig(SWeekRewardConfig.class);
|
||||||
|
CommonProto.WeekCardInfo weekCardInfo = packagingWeekCardBuilder(proto.getActiviteId(), proto.getWeekcardId(), map);
|
||||||
|
List<CommonProto.WeekCardDay> dayList = weekCardInfo.getDayList();
|
||||||
|
// 奖励
|
||||||
|
ArrayList<int[][]> reward = new ArrayList<>();
|
||||||
|
for (CommonProto.WeekCardDay day : dayList) {
|
||||||
|
// 可领取的奖励
|
||||||
|
if (day.getState() == 1){
|
||||||
|
int[] ints = weekcardConfig.getBaseRewardID()[day.getDay() - 1];
|
||||||
|
SWeekRewardConfig rewardConfig = rewardConfigMap.get(ints[1]);
|
||||||
|
if (rewardConfig == null){
|
||||||
|
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE,"月卡奖励id不存在表中:"+ints[1]);
|
||||||
|
}
|
||||||
|
reward.add(new int[][]{rewardConfig.getBaseReward()});
|
||||||
|
// 更新数据库
|
||||||
|
map.put(day.getDay(),2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CommonProto.Drop.Builder drop = ItemUtil.drop(user, reward, BIReason.WEEK_CARD_REWARD);
|
||||||
|
user.getPlayerInfoManager().putWeekCard(proto.getWeekcardId(),map);
|
||||||
|
|
||||||
|
PlayerInfoProto.GetWeekCardRewardResponse build = PlayerInfoProto.GetWeekCardRewardResponse.newBuilder().setDrop(drop).build();
|
||||||
|
MessageUtil.sendMessage(user.getId(), 1, MessageTypeProto.MessageType.GetWeekCardRewardResponse_VALUE, build, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送
|
||||||
|
* @param user
|
||||||
|
* @param weekCardId
|
||||||
|
* @param activityId
|
||||||
|
*/
|
||||||
|
public void weekCardInfoIndication(User user, int weekCardId, int activityId){
|
||||||
|
ISession session = OnlineUserManager.getSessionByUid(user.getId());
|
||||||
|
if (weekCardId == 0){
|
||||||
|
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.WeekCardInfoIndication_VALUE, null, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Integer, Integer> map = user.getPlayerInfoManager().getWeekCard().get(weekCardId);
|
||||||
|
CommonProto.WeekCardInfo weekCardInfo = packagingWeekCardBuilder(activityId, weekCardId, map);
|
||||||
|
PlayerInfoProto.WeekCardInfoIndication.Builder builder = PlayerInfoProto.WeekCardInfoIndication.newBuilder().setWeekcard(weekCardInfo);
|
||||||
|
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.WeekCardInfoIndication_VALUE, builder.build(), true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,10 +191,11 @@ public class PlayerManager extends MongoBase {
|
||||||
// 御剑行游玩次数
|
// 御剑行游玩次数
|
||||||
private int ridingSwardNum;
|
private int ridingSwardNum;
|
||||||
|
|
||||||
//周卡
|
/**
|
||||||
private Map<Integer,WeekCardInfo> weekCard = new HashMap<>();
|
* 周卡
|
||||||
private long weekCardTimeFirst;//本周第一次看到周卡的时间
|
* key:周卡id,v:key:天数,value:领取状态:0:未领取,1:已领取
|
||||||
private int weekCardTimeFirstLevel;//本周第一次看到周卡时人物等级
|
*/
|
||||||
|
private Map<Integer,Map<Integer,Integer>> weekCard = new HashMap<>();
|
||||||
|
|
||||||
//玩家抽取到的五星次数,目前只应用于招募基金使用
|
//玩家抽取到的五星次数,目前只应用于招募基金使用
|
||||||
private int getFiveStarHeroNum;
|
private int getFiveStarHeroNum;
|
||||||
|
@ -1391,32 +1392,18 @@ public class PlayerManager extends MongoBase {
|
||||||
updateString("versionCode",versionCode);
|
updateString("versionCode",versionCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, WeekCardInfo> getWeekCard() {
|
public Map<Integer, Map<Integer, Integer>> getWeekCard() {
|
||||||
return weekCard;
|
return weekCard;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWeekCard(Map<Integer, WeekCardInfo> weekCard) {
|
public void setWeekCard(Map<Integer, Map<Integer, Integer>> weekCard) {
|
||||||
this.weekCard = weekCard;
|
this.weekCard = weekCard;
|
||||||
updateString("weekCard",weekCard);
|
updateString("weekCard",weekCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void putWeekCard(int key, Map<Integer, Integer> value) {
|
||||||
public long getWeekCardTimeFirst() {
|
this.weekCard.put(key,value);
|
||||||
return weekCardTimeFirst;
|
updateString("weekCard",weekCard);
|
||||||
}
|
|
||||||
|
|
||||||
public void setWeekCardTimeFirst(long weekCardTimeFirst) {
|
|
||||||
this.weekCardTimeFirst = weekCardTimeFirst;
|
|
||||||
updateString("weekCardTimeFirst",weekCardTimeFirst);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWeekCardTimeFirstLevel() {
|
|
||||||
return weekCardTimeFirstLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWeekCardTimeFirstLevel(int weekCardTimeFirstLevel) {
|
|
||||||
this.weekCardTimeFirstLevel = weekCardTimeFirstLevel;
|
|
||||||
updateString("weekCardTimeFirstLevel",weekCardTimeFirstLevel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, ExplorerInfo> getExplorer() {
|
public Map<Integer, ExplorerInfo> getExplorer() {
|
||||||
|
|
|
@ -463,11 +463,6 @@ public class BuyGoodsNewLogic {
|
||||||
if(type==GiftGoodsType.ENDLESS_TREASURE){
|
if(type==GiftGoodsType.ENDLESS_TREASURE){
|
||||||
user.getMapManager().setTreasureIsBuy(1);
|
user.getMapManager().setTreasureIsBuy(1);
|
||||||
}
|
}
|
||||||
//周卡
|
|
||||||
if(type==GiftGoodsType.WEEKCARD){
|
|
||||||
WeekCardLogic.getInstance().buyWeekCard(user,config.getId());
|
|
||||||
WeekCardLogic.getInstance().sendWeekCardInitInfo(session);
|
|
||||||
}
|
|
||||||
//礼包开启活动
|
//礼包开启活动
|
||||||
if(type ==GiftGoodsType.DailyPreferentialGift){
|
if(type ==GiftGoodsType.DailyPreferentialGift){
|
||||||
AbstractActivity abstractActivity = ActivityTypeEnum.getActicityType(ActivityType.DAILY_PREFERENTIAL_GIFT);
|
AbstractActivity abstractActivity = ActivityTypeEnum.getActicityType(ActivityType.DAILY_PREFERENTIAL_GIFT);
|
||||||
|
|
|
@ -2,14 +2,9 @@ package com.ljsd.jieling.logic.store.newRechargeInfo.bean;
|
||||||
|
|
||||||
import com.ljsd.common.mogodb.MongoBase;
|
import com.ljsd.common.mogodb.MongoBase;
|
||||||
import com.ljsd.jieling.logic.dao.root.User;
|
import com.ljsd.jieling.logic.dao.root.User;
|
||||||
import com.ljsd.jieling.util.ItemUtil;
|
|
||||||
import com.ljsd.jieling.util.KeyGenUtils;
|
|
||||||
import com.ljsd.jieling.util.UUIDEnum;
|
|
||||||
import config.SRechargeCommodityNewConfig;
|
import config.SRechargeCommodityNewConfig;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.annotation.Id;
|
|
||||||
import org.springframework.data.annotation.Transient;
|
|
||||||
import util.TimeUtils;
|
import util.TimeUtils;
|
||||||
|
|
||||||
public class AbstractWelfareBag extends MongoBase{
|
public class AbstractWelfareBag extends MongoBase{
|
||||||
|
@ -78,6 +73,10 @@ public class AbstractWelfareBag extends MongoBase{
|
||||||
this.setRootId(rootId);
|
this.setRootId(rootId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查礼包是否可以购买
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean buy() {
|
public boolean buy() {
|
||||||
if (!checkBuy()){
|
if (!checkBuy()){
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package config;
|
||||||
|
|
||||||
|
import manager.STableManager;
|
||||||
|
import manager.Table;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Table(name ="WeekRewardConfig")
|
||||||
|
public class SWeekRewardConfig implements BaseConfig {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
private int[] baseReward;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getBaseReward() {
|
||||||
|
return baseReward;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -10,27 +10,22 @@ public class SWeekcardConfig implements BaseConfig {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
|
private int type;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private int price;
|
private int[][] baseRewardID;
|
||||||
|
|
||||||
private int[][] baseReward;
|
private int rechargeId;
|
||||||
|
|
||||||
private int contiueDays;
|
private int weekcardType;
|
||||||
|
|
||||||
private int time;
|
private int priority;
|
||||||
|
|
||||||
private String startTime;
|
|
||||||
|
|
||||||
private String endtime;
|
|
||||||
|
|
||||||
private int rechargeId;
|
|
||||||
|
|
||||||
public static Map<Integer,SWeekcardConfig> weekcardConfig;
|
|
||||||
@Override
|
@Override
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
weekcardConfig = STableManager.getConfig(SWeekcardConfig.class);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,35 +33,27 @@ public class SWeekcardConfig implements BaseConfig {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPrice() {
|
public int[][] getBaseRewardID() {
|
||||||
return price;
|
return baseRewardID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[][] getBaseReward() {
|
public int getRechargeId() {
|
||||||
return baseReward;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getContiueDays() {
|
|
||||||
return contiueDays;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTime() {
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStartTime() {
|
|
||||||
return startTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEndtime() {
|
|
||||||
return endtime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRechargeId() {
|
|
||||||
return rechargeId;
|
return rechargeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getWeekcardType() {
|
||||||
|
return weekcardType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPriority() {
|
||||||
|
return priority;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -3,6 +3,9 @@ package config;
|
||||||
import manager.STableManager;
|
import manager.STableManager;
|
||||||
import manager.Table;
|
import manager.Table;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Table(name ="WeekcardRotationConfig")
|
@Table(name ="WeekcardRotationConfig")
|
||||||
|
@ -12,20 +15,31 @@ public class SWeekcardRotationConfig implements BaseConfig {
|
||||||
|
|
||||||
private int[][] weekcardType;
|
private int[][] weekcardType;
|
||||||
|
|
||||||
private int time;
|
private int globalActivity;
|
||||||
|
|
||||||
private String startTime;
|
|
||||||
|
|
||||||
private String endtime;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* key:活动id
|
||||||
|
*/
|
||||||
|
private static Map<Integer, List<SWeekcardRotationConfig>> map = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
|
Map<Integer, SWeekcardRotationConfig> config = STableManager.getConfig(SWeekcardRotationConfig.class);
|
||||||
|
HashMap<Integer, List<SWeekcardRotationConfig>> map1 = new HashMap<>();
|
||||||
|
for (SWeekcardRotationConfig value : config.values()) {
|
||||||
|
List<SWeekcardRotationConfig> list = map1.getOrDefault(value.getGlobalActivity(), new ArrayList<>());
|
||||||
|
list.add(value);
|
||||||
|
map1.put(value.getGlobalActivity(),list);
|
||||||
|
}
|
||||||
|
map.clear();
|
||||||
|
map = map1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Map<Integer, List<SWeekcardRotationConfig>> getMap() {
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,16 +47,8 @@ public class SWeekcardRotationConfig implements BaseConfig {
|
||||||
return weekcardType;
|
return weekcardType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTime() {
|
public int getGlobalActivity() {
|
||||||
return time;
|
return globalActivity;
|
||||||
}
|
|
||||||
|
|
||||||
public String getStartTime() {
|
|
||||||
return startTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEndtime() {
|
|
||||||
return endtime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue