【ID1005921】【月卡优化】累计充值30/98分别赠送月卡/豪华月卡-后端

zhangshanxue 2020-05-04 05:07:01 +08:00
parent eb2259ac92
commit f1da1afbce
9 changed files with 247 additions and 18 deletions

View File

@ -68,7 +68,10 @@ public interface Global {
int VIPSTORID = 20; //vip商店id
int LUXURYMONTHCARDID =11;//6豪华月卡
int LUXURYMONTHCARDID =11;//6豪华月卡 废弃 改版
int WEEKCARDID = 10; //月卡
int MONTHCARDID =1;//1月卡
int LMONTHCARDID =2;//2豪华月卡
}

View File

@ -167,6 +167,7 @@ public class GetPlayerInfoHandler extends BaseHandler{
.setAmount(rechargeInfo.getSaveAmt())
.setVipDaily(playerInfoManager.getHadTakeDailyBoxVip())
.setMissingRefreshCount(vipPrivilageValue)
.addAllMonthinfos(PlayerLogic.getInstance().getMonthCardInfo(user))
.build();
try {
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_PLAYERINFO_RESPONSE_VALUE, getPlayerInfoResponse, true);

View File

@ -0,0 +1,47 @@
package com.ljsd.jieling.handler.vip;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
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.root.User;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.protocols.PlayerInfoProto;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
import config.SMonthcardConfig;
import manager.STableManager;
/**
* Description: des
* Author: zsx
* CreateDate: 2020/3/30 14:00
*/
public class MonthTakeDailyHandler extends BaseHandler <PlayerInfoProto.TakeMothDilyRequest>{
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.MONTHCARD_TAKE_DAILY_REQUEST;
}
@Override
public void processWithProto(ISession iSession, PlayerInfoProto.TakeMothDilyRequest proto) throws Exception {
User user = UserManager.getUser(iSession.getUid());
SMonthcardConfig config = STableManager.getConfig(SMonthcardConfig.class).get(proto.getType());
if(null == config){
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
if(user.getPlayerInfoManager().getMonthCardDailyTake().contains(proto.getType())){
throw new ErrorCodeException(ErrorCode.newDefineCode("had taked the month daily reward"));
}
user.getPlayerInfoManager().addMonthCardDailyTake(proto.getType());
CommonProto.Drop.Builder drop = ItemUtil.drop(user, config.getBaseReward(), BIReason.TAKE_VIP_DAILY_REWARD);
PlayerInfoProto.TakeMothDilyResponse build = PlayerInfoProto.TakeMothDilyResponse.newBuilder().setDrop(drop).build();
MessageUtil.sendMessage(iSession, 1,MessageTypeProto.MessageType.MONTHCARD_TAKE_DAILY_RESPONSE_VALUE, build, true);
}
}

View File

@ -35,7 +35,7 @@ public class VipTakeDailyHandler extends BaseHandler<PlayerInfoProto.VipTakeDily
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
if(!playerInfoManager.getRechargeInfo().getBuyGoodsTimes().containsKey(Global.LUXURYMONTHCARDID)){
if(!playerInfoManager.getMonthCard().containsKey(Global.LMONTHCARDID)){
throw new ErrorCodeException(ErrorCode.newDefineCode("未激活豪华月卡"));
}

View File

@ -2,14 +2,12 @@ package com.ljsd.jieling.logic.dao;
import com.ljsd.common.mogodb.MongoBase;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.core.VipPrivilegeType;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.mission.GameEvent;
import com.ljsd.jieling.logic.player.PlayerLogic;
import config.SMonthcardConfig;
import config.SPrivilegeTypeConfig;
import config.SVipLevelConfig;
import manager.STableManager;
import util.TimeUtils;
import java.util.*;
@ -68,6 +66,8 @@ public class PlayerManager extends MongoBase {
private Set<Integer> reds = new CopyOnWriteArraySet<>();
private RechargeInfo rechargeInfo;
private Map<Integer,Integer> monthCard = new HashMap<>();//月卡信息
private Set<Integer> monthCardDailyTake = new HashSet<>();
private int headFrame;
@ -578,4 +578,50 @@ public class PlayerManager extends MongoBase {
updateString("sex", sex);
this.sex = sex;
}
public Map<Integer, Integer> getMonthCard() {
Iterator<Map.Entry<Integer, Integer>> iterator = monthCard.entrySet().iterator();
while (iterator.hasNext()){
Map.Entry<Integer,Integer> map = iterator.next();
Integer key = map.getKey();
SMonthcardConfig config = STableManager.getConfig(SMonthcardConfig.class).get(key);
if(null==config){
iterator.remove();
continue;
}
if(((int)(System.currentTimeMillis()/1000)-map.getValue())>24*60*60*config.getContiueDays()){
iterator.remove();
if(key== Global.MONTHCARDID){
rechargeInfo.setMonthSaveAmt(0);
}else if(key ==Global.LMONTHCARDID){
rechargeInfo.setSmonthSaveAmt(0);
}
}
}
updateString("monthCard",monthCard);
return monthCard;
}
public void setMonthCard(Map<Integer, Integer> monthCard) {
updateString("monthCard",monthCard);
this.monthCard = monthCard;
}
public void putMonthCard(Integer id, Integer time) {
this.monthCard.put(id, time);
updateString("monthCard",this.monthCard);
}
public Set<Integer> getMonthCardDailyTake() {
return monthCardDailyTake;
}
public void addMonthCardDailyTake(Integer integer) {
this.monthCardDailyTake.add(integer);
updateString("monthCardDailyTake",monthCardDailyTake);
}
public void setMonthCardDailyTake(Set<Integer> monthCardDailyTake) {
this.monthCardDailyTake = monthCardDailyTake;
updateString("monthCardDailyTake",monthCardDailyTake);
}
}

View File

@ -11,6 +11,8 @@ public class RechargeInfo extends MongoBase{
private int saveAmt;//累计充值
private int soulCrystalAmt;//累计充值购买魂晶
private int monthSaveAmt ; //月卡累计总额
private int smonthSaveAmt ; //豪华月卡累计总额
private int isFirst;
private long createTime;
private int hadBuyFound;
@ -237,4 +239,22 @@ public class RechargeInfo extends MongoBase{
public Map<Integer, Long> getRefreshBagMap() {
return refreshBagMap;
}
public int getMonthSaveAmt() {
return monthSaveAmt;
}
public void setMonthSaveAmt(int monthSaveAmt) {
this.monthSaveAmt = monthSaveAmt;
updateString("monthSaveAmt",smonthSaveAmt);
}
public int getSmonthSaveAmt() {
return smonthSaveAmt;
}
public void setSmonthSaveAmt(int smonthSaveAmt) {
this.smonthSaveAmt = smonthSaveAmt;
updateString("smonthSaveAmt",smonthSaveAmt);
}
}

View File

@ -372,6 +372,7 @@ public class PlayerLogic {
if (!TimeUtils.isSameMonthFiveWithNow(user.getPlayerInfoManager().getOffLineTime())) {
user.getPlayerInfoManager().getPhoneBindInfo().setState(0);
}
user.getPlayerInfoManager().setMonthCardDailyTake(new HashSet<>());//刷新月卡信息
if(null!=fBuilder){
PhoneBindInfo phoneBindInfo = user.getPlayerInfoManager().getPhoneBindInfo();
fBuilder.setPlayerBindPhone(CommonProto.PlayerBindPhone.newBuilder().setPhoneNum(phoneBindInfo.getPhoneNum()).setState(phoneBindInfo.getState()).build());
@ -901,4 +902,18 @@ public class PlayerLogic {
}
return maxCount;
}
public List<CommonProto.MonthCardInfo> getMonthCardInfo(User user) {
List<CommonProto.MonthCardInfo> cardInfos = new LinkedList<>();
PlayerManager playerInfoManager = user.getPlayerInfoManager();
RechargeInfo rechargeInfo = playerInfoManager.getRechargeInfo();
STableManager.getConfig(SMonthcardConfig.class).forEach((integer, sMonthcardConfig) -> {
int state = playerInfoManager.getMonthCardDailyTake().contains(integer)?1:0;
int saveAmt = integer==1?rechargeInfo.getMonthSaveAmt():rechargeInfo.getSmonthSaveAmt();
int time = playerInfoManager.getMonthCard().getOrDefault(integer,0);
cardInfos.add(CommonProto.MonthCardInfo.newBuilder().setId(integer).setEndingTime(time).setState(state).setTotleAmt(saveAmt).build());
});
return cardInfos;
}
}

View File

@ -119,15 +119,40 @@ public class BuyGoodsLogic {
needSendMail = true;
}
if( (type == GiftGoodsType.MONTHCARD || type == GiftGoodsType.LUXURYMONTHCARD ) && nowTime<endTime-STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getNextAvailableTime()*3600){
resultRes.setResultCode(0);
resultRes.setResultMsg("不可以过早购买");
return resultRes;
}
//月卡不走购买逻辑
// if( (type == GiftGoodsType.MONTHCARD || type == GiftGoodsType.LUXURYMONTHCARD ) && nowTime<endTime-STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getNextAvailableTime()*3600){
// resultRes.setResultCode(0);
// resultRes.setResultMsg("不可以过早购买");
// return resultRes;
// }
endTime +=sRechargeCommodityConfig.getContiueDays() * 24 * 3600;
rechargeInfo.updateGoodsTypeDuration(sRechargeCommodityConfig.getId(),endTime);
}
if(sRechargeCommodityConfig.getAccumulativeRecharge() == 1){
int totle=price+rechargeInfo.getSaveAmt();
int monthline = STableManager.getConfig(SMonthcardConfig.class).get(Global.MONTHCARDID).getPrice();
int lmonthline = STableManager.getConfig(SMonthcardConfig.class).get(Global.LMONTHCARDID).getPrice();
boolean sendneed =false;
if(rechargeInfo.getMonthSaveAmt()<monthline&&totle>=monthline){
sendneed=true;
user.getPlayerInfoManager().getMonthCard().put(Global.MONTHCARDID, (int) (System.currentTimeMillis() / 1000));
}
if(rechargeInfo.getSmonthSaveAmt()<lmonthline&&totle>=lmonthline){
sendneed=true;
user.getPlayerInfoManager().getMonthCard().put(Global.LMONTHCARDID, (int) (System.currentTimeMillis() / 1000));
}
if(sendneed){
ISession session = OnlineUserManager.sessionMap.get(uid);
if(session!=null){
PlayerInfoProto.MonthCardIndication monthCardIndication = PlayerInfoProto.MonthCardIndication.newBuilder().addAllMonthinfos(PlayerLogic.getInstance().getMonthCardInfo(user)).build();
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.MONTHCARD_INDICATION_VALUE, monthCardIndication, true);
}
}
}
triggerEvent(user,sRechargeCommodityConfig,nowTime);
int[][] baseReward = sRechargeCommodityConfig.getBaseReward();
int length = baseReward.length;
@ -186,8 +211,10 @@ public class BuyGoodsLogic {
}
}
rechargeInfo.setSaveAmt(price+saveAmt);
user.getPlayerInfoManager().addRechargedaily(price);
rechargeInfo.setMonthSaveAmt(price+rechargeInfo.getMonthSaveAmt());
rechargeInfo.setSmonthSaveAmt(price+rechargeInfo.getSmonthSaveAmt());
//TODO 用事件分发
ActivityLogic.getInstance().updateActivityMissionProgress(user, ActivityType.RechargeTotal,price);
ActivityLogic.getInstance().updateActivityMissionProgress(user, ActivityType.LUCKYCAT,price);
@ -208,6 +235,8 @@ public class BuyGoodsLogic {
}
PlayerInfoProto.RefreshRechargeIndication.Builder builder = PlayerInfoProto.RefreshRechargeIndication.newBuilder();
builder.setAmount(rechargeInfo.getSaveAmt());
builder.setMonthSaveAmt(rechargeInfo.getMonthSaveAmt());
builder.setSmonthSaveAmt(rechargeInfo.getSmonthSaveAmt());
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.REFRESH_RECHARGE_INDICATION_VALUE,builder.build(),true);
}
@ -308,7 +337,9 @@ public class BuyGoodsLogic {
}
MessageUtil.sendIndicationMessage(OnlineUserManager.getSessionByUid(user.getId()), 1, MessageTypeProto.MessageType.PRIVILLEGE_ADD_INDICATION_VALUE, indication.build(), true);
}
if(goodsType == GiftGoodsType.LUXURYMONTHCARD){
if(user.getPlayerInfoManager().getMonthCard().containsKey(Global.LMONTHCARDID) ){
PlayerLogic.getInstance().sendDayilyMail(user,goodsType);
int starReward = user.getMapManager().getStarReward();
if(starReward == 0){
@ -329,7 +360,9 @@ public class BuyGoodsLogic {
String title = SErrorCodeEerverConfig.getI18NMessage("recharge_6_stars_title");
String content = SErrorCodeEerverConfig.getI18NMessage("recharge_6_stars_txt");
MailLogic.getInstance().sendMail(user.getId(),title,content,rewardStr.toString(),nowTime, Global.MAIL_EFFECTIVE_TIME);
}else if(goodsType == GiftGoodsType.MONTHCARD || goodsType == GiftGoodsType.WEEKCARD || goodsType == GiftGoodsType.FOUND_ONE || goodsType == GiftGoodsType.FOUND_TWO){
}
if(user.getPlayerInfoManager().getMonthCard().containsKey(Global.MONTHCARDID) || goodsType == GiftGoodsType.WEEKCARD || goodsType == GiftGoodsType.FOUND_ONE || goodsType == GiftGoodsType.FOUND_TWO){
PlayerLogic.getInstance().sendDayilyMail(user,goodsType);
}
@ -522,7 +555,4 @@ public class BuyGoodsLogic {
user.getPlayerInfoManager().getRechargeInfo().setRefreshBagMap(refreshBagMap);
}
}

View File

@ -0,0 +1,67 @@
package config;
import manager.STableManager;
import manager.Table;
import java.util.Map;
@Table(name ="MonthcardConfig")
public class SMonthcardConfig implements BaseConfig {
private int id;
private String name;
private int price;
private int[][] baseReward;
private int contiueDays;
private int time;
private String startTime;
private String endtime;
@Override
public void init() throws Exception {
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public int getPrice() {
return price;
}
public int[][] getBaseReward() {
return baseReward;
}
public int getContiueDays() {
return contiueDays;
}
public int getTime() {
return time;
}
public String getStartTime() {
return startTime;
}
public String getEndtime() {
return endtime;
}
}