送十万真充活动初版
parent
04197abb0c
commit
fd21726937
|
@ -528,8 +528,7 @@ public class TimeUtils {
|
|||
st.setTimeInMillis(start);
|
||||
Calendar et = Calendar.getInstance();
|
||||
et.setTimeInMillis(end);
|
||||
int days = Math.abs(TimeUtils.getSoFarWentDays(st, et));
|
||||
return days;
|
||||
return Math.abs(TimeUtils.getSoFarWentDays(st, et));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,18 +1,10 @@
|
|||
package com.global.logic;
|
||||
|
||||
|
||||
import com.global.redis.RedisKey;
|
||||
import com.global.redis.RedisUtil;
|
||||
import config.SMServerArenaSetting;
|
||||
import manager.STableManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
|
@ -20,6 +12,7 @@ import java.util.Set;
|
|||
* @discribe
|
||||
*/
|
||||
|
||||
@Deprecated
|
||||
public class GlobalLogic {
|
||||
|
||||
|
||||
|
|
|
@ -524,8 +524,10 @@ public class GlobalDataManaager implements IManager {
|
|||
if(abstractActivity instanceof WholeLifeActivity){
|
||||
((WholeLifeActivity)abstractActivity).calWhenLogin(user);
|
||||
}
|
||||
///清空当天推送的礼包次数
|
||||
// 清空当天推送的礼包次数
|
||||
user.getPlayerInfoManager().getNewRechargeInfo().ClearDayPushMap();
|
||||
// 清空当天在线时间
|
||||
user.getPlayerInfoManager().setDayOfOnlineTime(0);
|
||||
}
|
||||
user.getPlayerInfoManager().setLoginTime(TimeUtils.now());
|
||||
}
|
||||
|
|
|
@ -145,8 +145,8 @@ public interface ActivityType {
|
|||
int RECHARGE_FIRST = 108;//直充首冲活动
|
||||
int FREE_RECHARGE = 109;//免费充值,仙充
|
||||
int OPEN_SERVER_COMPETE_RANK = 110;//开服冲榜活动
|
||||
|
||||
int NEW_RECHARGE_SUM_DAY_6 = 90;//超值返利6
|
||||
int NEW_RECHARGE_SUM_DAY_12 = 111;//超值返利12
|
||||
int NEW_RECHARGE_SUM_DAY_30 = 92;//超值返利30
|
||||
int NEW_RECHARGE_SUM_DAY_12 = 111;//超值返利12
|
||||
int GIVE_ONE_HUNDRED_THOUSAND_RECHARGE = 112;//送十万真充
|
||||
}
|
||||
|
|
|
@ -123,6 +123,7 @@ public enum ActivityTypeEnum {
|
|||
RECHARGE_FIRST(ActivityType.RECHARGE_FIRST, RechargeFirstActivity::new),//直充购买礼包活动
|
||||
FREE_RECHARGE(ActivityType.FREE_RECHARGE, DefaultEmptyActivity::new),//免费充值,仙充
|
||||
OPEN_SERVER_COMPETE_RANK(ActivityType.OPEN_SERVER_COMPETE_RANK, OpenServerCompeteRankActivity::new),//开服冲榜
|
||||
GIVE_ONE_HUNDRED_THOUSAND_RECHARGE(ActivityType.GIVE_ONE_HUNDRED_THOUSAND_RECHARGE, GiveOneHundredThousandActivity::new)
|
||||
;
|
||||
|
||||
private int type;
|
||||
|
|
|
@ -0,0 +1,158 @@
|
|||
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.jbean.ActivityMission;
|
||||
import com.ljsd.jieling.jbean.ActivityProgressInfo;
|
||||
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.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SSuperZhenChong;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author hj
|
||||
* 送十万真充活动-bt版
|
||||
* 2022-9-6
|
||||
*/
|
||||
public class GiveOneHundredThousandActivity extends AbstractActivity {
|
||||
|
||||
GiveOneHundredThousandActivity(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initActivity(User user) throws Exception {
|
||||
// 活动信息初始化
|
||||
ActivityMission mission = new ActivityMission();
|
||||
ActivityLogic.getInstance().initOtherMission(mission, new ArrayList<>());
|
||||
user.getActivityManager().getActivityMissionMap().put(id, mission);
|
||||
LOGGER.info("送十万真充活动-bt版...uid={},activityId={}",user.getId(), id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommonProto.ActivityInfo.MissionInfo> getAllMissInfo(User user,ActivityMission activityMission, Set<Integer> filter) {
|
||||
if (activityMission == null){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
// 策划表的配置
|
||||
Map<Integer, SSuperZhenChong> zhenChongMap = SSuperZhenChong.getMap();
|
||||
// 返回对象
|
||||
List<CommonProto.ActivityInfo.MissionInfo> missionInfos = new ArrayList<>(zhenChongMap.size());
|
||||
int rewardValue = 0;
|
||||
for (SSuperZhenChong value : zhenChongMap.values()) {
|
||||
// 参数初始化
|
||||
int missionId = value.getId();
|
||||
int progress = user.getPlayerInfoManager().getDayOfOnlineTime();
|
||||
int state = getState(user,value);
|
||||
if (state >= 2){
|
||||
rewardValue += value.getRewardValue();
|
||||
}
|
||||
// 封装proto并返回
|
||||
CommonProto.ActivityInfo.MissionInfo build = CommonProto.ActivityInfo.MissionInfo.newBuilder()
|
||||
.setMissionId(missionId)
|
||||
.setProgress(progress)
|
||||
.setState(state)
|
||||
.build();
|
||||
missionInfos.add(build);
|
||||
}
|
||||
activityMission.setV(rewardValue);
|
||||
return missionInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态
|
||||
* @param user
|
||||
* @param config
|
||||
* @return
|
||||
* 0:不可领取
|
||||
* 1:可领取
|
||||
* 2:已领取
|
||||
* 3:已过期
|
||||
*/
|
||||
private int getState(User user, SSuperZhenChong config){
|
||||
if (config == null){
|
||||
return 0;
|
||||
}
|
||||
ActivityMission mission = user.getActivityManager().getActivityMissionMap().get(id);
|
||||
ActivityProgressInfo info = mission.getActivityMissionMap().get(config.getId());
|
||||
if (info != null && info.getState() == 2){
|
||||
return 2;
|
||||
}
|
||||
int soFarWentDays = TimeUtils.getSoFarWentDays(mission.getCreatTime(), TimeUtils.now())+1;
|
||||
int day = config.getDay();
|
||||
if (soFarWentDays < day){
|
||||
return 3;
|
||||
}
|
||||
if (soFarWentDays > day){
|
||||
return 0;
|
||||
}
|
||||
int time = user.getPlayerInfoManager().getDayOfOnlineTime();
|
||||
if (time >= config.getTime()){
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 领取奖励
|
||||
* @param session
|
||||
* @param missionId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public boolean takeReward(ISession session, int missionId) throws Exception {
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
// activity check
|
||||
ActivityMission mission = user.getActivityManager().getActivityMissionMap().get(id);
|
||||
if (mission == null){
|
||||
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"活动信息不存在:"+id);
|
||||
}
|
||||
// 根据天数获取当天的奖励内容
|
||||
int day = TimeUtils.getSoFarWentDays(mission.getCreatTime(), TimeUtils.now())+1;
|
||||
Map<Integer, SSuperZhenChong> zhenChongMap = SSuperZhenChong.getDayMap().get(day);
|
||||
|
||||
ArrayList<int[][]> rewardList = new ArrayList<>();
|
||||
for (SSuperZhenChong value : zhenChongMap.values()) {
|
||||
int state = getState(user, value);
|
||||
if (state == 1){
|
||||
// 奖励
|
||||
rewardList.add(new int[][]{value.getReward()});
|
||||
// 更新数据库
|
||||
ActivityProgressInfo info = new ActivityProgressInfo();
|
||||
info.setState(2);
|
||||
mission.getActivityMissionMap().put(missionId,info);
|
||||
}
|
||||
}
|
||||
if (rewardList.size() == 0){
|
||||
return false;
|
||||
}
|
||||
// reward
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, rewardList, BIReason.TAKE_ACTIVITY_REWARD);
|
||||
|
||||
PlayerInfoProto.TakeActivityRewardResponse build = PlayerInfoProto.TakeActivityRewardResponse.newBuilder().setDrop(drop).build();
|
||||
MessageUtil.sendMessage(session, 1, rewardResponseValue, build, true);
|
||||
// 状态推送
|
||||
sendActivityProgress(session, mission, null);
|
||||
// 打点上报
|
||||
reportTakeActivityReward(user,rewardList,missionId);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkActivityMissionFinishAndTake(int uid, int activityId, ActivityMission activityMission) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -121,6 +121,8 @@ public class PlayerManager extends MongoBase {
|
|||
|
||||
private long onlineTime;
|
||||
|
||||
private int dayOfOnlineTime;//当天在线时间,秒
|
||||
|
||||
private int isdayFirst = 0;//给客户端记录下
|
||||
|
||||
private Set<Integer> fixIds = new CopyOnWriteArraySet<>();
|
||||
|
@ -961,6 +963,20 @@ public class PlayerManager extends MongoBase {
|
|||
updateString("onlineTime", this.onlineTime);
|
||||
}
|
||||
|
||||
public int getDayOfOnlineTime() {
|
||||
return dayOfOnlineTime;
|
||||
}
|
||||
|
||||
public void setDayOfOnlineTime(int dayOfOnlineTime) {
|
||||
this.dayOfOnlineTime = dayOfOnlineTime;
|
||||
updateString("dayOfOnlineTime", this.dayOfOnlineTime);
|
||||
}
|
||||
|
||||
public void addDayOfOnlineTime(int time) {
|
||||
this.dayOfOnlineTime += time;
|
||||
updateString("dayOfOnlineTime", this.dayOfOnlineTime);
|
||||
}
|
||||
|
||||
public int getIsdayFirst() {
|
||||
return isdayFirst;
|
||||
}
|
||||
|
|
|
@ -430,10 +430,14 @@ public class SessionManager implements INetSession<ISession>, INetReceived<ISess
|
|||
try {
|
||||
// GuildLogic.updateMyPos(user);
|
||||
if(session.getFiveReady()==1){
|
||||
// 在线时间戳
|
||||
PlayerManager playerInfoManager = user.getPlayerInfoManager();
|
||||
playerInfoManager.setOffLineTime(TimeUtils.now());
|
||||
// 总在线时间
|
||||
long onlineTime = playerInfoManager.getOffLineTime() - session.getUserLoginTime();
|
||||
playerInfoManager.addOnlineTime(onlineTime);
|
||||
// 每日在线时间
|
||||
playerInfoManager.addDayOfOnlineTime((int) (onlineTime/1000));
|
||||
// 登出通知
|
||||
// ReportUtil.onReportEvent(user, ReportEventEnum.APP_LOGIN.getType());
|
||||
//更新在线时长
|
||||
|
|
Loading…
Reference in New Issue