【ID1005331】【星级成长礼】

back_recharge
zhangshanxue 2019-12-26 10:09:06 +08:00
parent d775ae739d
commit bb75dfbcfa
10 changed files with 121 additions and 23 deletions

View File

@ -22,6 +22,7 @@ import com.ljsd.jieling.util.ConfigurableApplicationContextManager;
import com.ljsd.jieling.util.KeyGenUtils;
import com.ljsd.jieling.util.SensitivewordFilter;
import com.ljsd.jieling.util.http.HttpPool;
import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader;
import manager.STableManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -41,6 +42,7 @@ public class GameLogicService implements IService {
public static GameLogicService getInstance() {
return instance;
}
private static volatile boolean isShutdown = false;
@Override
@ -107,8 +109,10 @@ public class GameLogicService implements IService {
LOGGER.info(resource.getFile());
}
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
LOGGER.info("ShutdownHook start");
isShutdown= true;
Thread.currentThread().setName("addShutdownHook");
try {
GameApplication.close();
@ -116,4 +120,8 @@ public class GameLogicService implements IService {
}));
}
public static boolean isServiceShutdown() {
return isShutdown;
}
}

View File

@ -5,6 +5,7 @@ import com.google.gson.FieldAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.ljsd.GameApplication;
import com.ljsd.GameLogicService;
import com.ljsd.common.mogodb.util.BlockingUniqueQueue;
import com.ljsd.jieling.config.json.SDK37Constans;
import com.ljsd.jieling.dataReport.reportBeans_37.*;
@ -37,10 +38,12 @@ public class DataMessageUtils {
private static final String sendChatContent37 = "http://cm3.api.37.com.cn/Content/_checkContent/";
//入队列
public static void addLogQueue(Object info) {
if (info instanceof KTParam) {
logQueue.offer(info);
} else if (info instanceof Report37Param && GameApplication.serverProperties.isSendlog37()) {
logQueue_37.offer(info);
if(!GameLogicService.isServiceShutdown()){
if (info instanceof KTParam) {
logQueue.offer(info);
} else if (info instanceof Report37Param && GameApplication.serverProperties.isSendlog37()) {
logQueue_37.offer(info);
}
}
}

View File

@ -7,6 +7,16 @@ package com.ljsd.jieling.logic.activity.event;
*/
public class HeroFiveStarGetEvent implements IEvent {
private int uid;
private int star;
public HeroFiveStarGetEvent(int uid, int star) {
this.uid = uid;
this.star = star;
}
public int getStar() {
return star;
}
public HeroFiveStarGetEvent(int uid) {
this.uid = uid;

View File

@ -2,6 +2,8 @@ package com.ljsd.jieling.logic.activity.eventhandler;
import com.ljsd.jieling.core.HandlerLogicThread;
import com.ljsd.jieling.core.SimpleTransaction;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.IEventHandler;
import com.ljsd.jieling.logic.activity.event.HeroFiveStarGetEvent;
@ -19,6 +21,7 @@ import config.SRechargeCommodityConfig;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Description: des
@ -34,10 +37,33 @@ public class HeroFiveStarGetEventHandler implements IEventHandler {
User user = UserManager.getUser(((HeroFiveStarGetEvent) event).getUid());
RechargeInfo rechargeInfo = user.getPlayerInfoManager().getRechargeInfo();
rechargeInfo.addTypeBagMap(5,System.currentTimeMillis());
long now = System.currentTimeMillis();
Map<Integer, Long> typeBagMap = rechargeInfo.getTypeBagMap();
int goodsId =SRechargeCommodityConfig.getRecharegeHeroTime().getOrDefault(((HeroFiveStarGetEvent) event).getStar(),0);
if(goodsId!=0){
if(typeBagMap.containsKey(((HeroFiveStarGetEvent) event).getStar())){
long lasttime = rechargeInfo.getTypeBagMap().get(((HeroFiveStarGetEvent) event).getStar());
int diffHourTemp = (int) ((now - lasttime) / 3600 / 1000);
if (diffHourTemp < 2) {
rechargeInfo.addDyGoodsCanBuyTimes(goodsId);
}else {
rechargeInfo.putDyGoodsCanBuyTimes(goodsId,1);
}
}else {
rechargeInfo.putDyGoodsCanBuyTimes(goodsId,1);
}
}else {
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
rechargeInfo.addTypeBagMap(((HeroFiveStarGetEvent) event).getStar(),System.currentTimeMillis());
List<CommonProto.GiftGoodsInfo> goodsBagInfo = new ArrayList<>(SRechargeCommodityConfig.rechargeCommodityConfigMap.size());
BuyGoodsLogic.getGoodsBagInfo(user.getId(), goodsBagInfo,false);
System.out.print(goodsBagInfo.toString());
ISession session = OnlineUserManager.getSessionByUid(user.getId());
if(session!=null){
if(null!= HandlerLogicThread.current()){

View File

@ -29,11 +29,12 @@ public class RechargeInfo extends MongoBase{
//特殊类型控制触发开启的商品表 如五星妖灵师类型5
private Map<Integer,Long> typeBagMap = new HashMap<>();
//动态商品可买数量
private Map<Integer,Integer> dyGoodsCanBuyTimes = new HashMap<>();
@Transient
private Map<Integer,Long> cacheSendedTypes = new HashMap<>();
public RechargeInfo(){
}
@ -201,4 +202,27 @@ public class RechargeInfo extends MongoBase{
public void setCacheSendedTypes(Map<Integer, Long> cacheSendedTypes) {
this.cacheSendedTypes = cacheSendedTypes;
}
public Map<Integer, Integer> getDyGoodsCanBuyTimes() {
return dyGoodsCanBuyTimes;
}
public void addDyGoodsCanBuyTimes(Integer type) {
this.dyGoodsCanBuyTimes.put(type,this.dyGoodsCanBuyTimes.get(type)+1 );
updateString("dyGoodsCanBuyTimes",dyGoodsCanBuyTimes);
}
public void putDyGoodsCanBuyTimes(Integer type,Integer value) {
this.dyGoodsCanBuyTimes.put(type,value );
updateString("dyGoodsCanBuyTimes",dyGoodsCanBuyTimes);
}
public void removeDyGoodsCanBuyTimes(Integer type) {
this.dyGoodsCanBuyTimes.remove(type);
updateString("dyGoodsCanBuyTimes",dyGoodsCanBuyTimes);
}
public void setDyGoodsCanBuyTimes(Map<Integer, Integer> dyGoodsCanBuyTimes) {
updateString("dyGoodsCanBuyTimes",dyGoodsCanBuyTimes);
this.dyGoodsCanBuyTimes = dyGoodsCanBuyTimes;
}
}

View File

@ -785,6 +785,11 @@ public class HeroLogic{
// recyleHeroBySystem(user,removeHeroIds);
targetHero.upStar( 1 );
Poster.getPoster().dispatchEvent(new HeroUpStarEvent(user.getId(),targetHero.getStar()));
if(targetHero.getStar()>=5&&targetHero.getStar()!=15){
if(SItem.getsItemMap().get(scHero.getId()).getQuantity()>=5)
Poster.getPoster().dispatchEvent(new HeroFiveStarGetEvent(user.getId(),targetHero.getStar()));
}
// if(targetHero.getStar()==5){
// Poster.getPoster().dispatchEvent(new HeroFiveStarGetEvent(user.getId()));
// }

View File

@ -1,5 +1,6 @@
package com.ljsd.jieling.logic.item;
import com.ljsd.GameLogicService;
import com.ljsd.common.mogodb.util.BlockingUniqueQueue;
import com.ljsd.jieling.db.mongo.MongoUtil;
@ -11,7 +12,9 @@ public class ItemLogUtil {
public static BlockingQueue<ItemLog> logQueue = new BlockingUniqueQueue<>();
public static void addLogQueue(ItemLog itemLog) {
logQueue.offer(itemLog);
if(!GameLogicService.isServiceShutdown()){
logQueue.offer(itemLog);
}
}
public static void record () {
List<ItemLog> sendDataList = new ArrayList<>(10);

View File

@ -228,12 +228,18 @@ public class BuyGoodsLogic {
int[] discountType = sRechargeCommodityConfig.getDiscountType();
int temptype = discountType[0];
int tempvalue = discountType[1];
if(temptype == 4&&tempvalue==5){
if (rechargeInfo.getTypeBagMap().containsKey(tempvalue)){
rechargeInfo.removeTypeBagMap(tempvalue);
}
if (rechargeInfo.getCacheSendedTypes().containsKey(tempvalue)){
rechargeInfo.getCacheSendedTypes().remove(tempvalue);
if(temptype == 4){
int dytime = rechargeInfo.getDyGoodsCanBuyTimes().getOrDefault(tempvalue,0)-1;
if(dytime <=0){
if (rechargeInfo.getTypeBagMap().containsKey(tempvalue)){
rechargeInfo.removeTypeBagMap(tempvalue);
}
if (rechargeInfo.getCacheSendedTypes().containsKey(tempvalue)){
rechargeInfo.getCacheSendedTypes().remove(tempvalue);
}
}else {
rechargeInfo.putDyGoodsCanBuyTimes(dytime,dytime);
}
List<CommonProto.GiftGoodsInfo> goodsBagInfo = new ArrayList<>(SRechargeCommodityConfig.rechargeCommodityConfigMap.size());
@ -364,6 +370,7 @@ public class BuyGoodsLogic {
int time = sRechargeCommodityConfig.getTime();
long startTime=0;
long endTime=0;
int dybuytime = 0;
if(time == 4){
int type = discountType[0];
int value = discountType[1];
@ -388,6 +395,7 @@ public class BuyGoodsLogic {
int addtime = discountType[2];
int diffHour = (int) ((now - startTime) / 3600 / 1000);
if (diffHour >= addtime) {
rechargeInfo.removeDyGoodsCanBuyTimes(value);
continue;
}
endTime = startTime + addtime * 3600 * 1000;
@ -405,7 +413,7 @@ public class BuyGoodsLogic {
}else {
rechargeInfo.getCacheSendedTypes().put(value, startTime);
}
dybuytime = rechargeInfo.getDyGoodsCanBuyTimes().getOrDefault(value,0);
}
}else{
@ -431,7 +439,8 @@ public class BuyGoodsLogic {
}
}
goodsOrder.put(sRechargeCommodityConfig.getType(),order*10000 + goodsId);
giftGoodsInfoMap.put(goodsId,CommonProto.GiftGoodsInfo.newBuilder().setGoodsId(goodsId).setStartTime((int)(startTime/1000)).setBuyTimes(buyTimes).setEndTime((int)(endTime/1000)).build());
giftGoodsInfoMap.put(goodsId,CommonProto.GiftGoodsInfo.newBuilder().setGoodsId(goodsId).setStartTime((int)(startTime/1000)).setBuyTimes(buyTimes).setEndTime((int)(endTime/1000))
.setDynamicBuyTimes(dybuytime).build());
boolean isNew = rechargeInfo.addNewSendId(goodsId);
if(isNew){
needChange = true;

View File

@ -1205,8 +1205,9 @@ public class ItemUtil {
}
}
user.getUserMissionManager().onGameEvent(user,GameEvent.GET_HERO,heroStar[0],heroStar[1]);
if(scHero.getStar()==5){
Poster.getPoster().dispatchEvent(new HeroFiveStarGetEvent(user.getId()));
if(scHero.getStar()>=5){
if(SItem.getsItemMap().get(scHero.getId()).getQuantity()>=5)
Poster.getPoster().dispatchEvent(new HeroFiveStarGetEvent(user.getId(),scHero.getStar()));
}
KtEventUtils.onKtEvent(user, ParamEventBean.UserItemEvent,reason,GlobalsDef.addReason,cardId,1,heroStar[1]);
}

View File

@ -5,10 +5,7 @@ import manager.Table;
import util.TimeUtils;
import util.StringUtil;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.*;
@Table(name ="RechargeCommodityConfig")
public class SRechargeCommodityConfig implements BaseConfig {
@ -59,21 +56,24 @@ public class SRechargeCommodityConfig implements BaseConfig {
public static Map<Integer, SRechargeCommodityConfig> rechargeCommodityConfigMap;
public static Map<Integer, SRechargeCommodityConfig> rechargeLevelMap;
private static Set<Integer> rchargeHeroGet;
private static Map<Integer,Integer> recharegeHeroTime;
@Override
public void init() throws Exception {
Map<Integer, SRechargeCommodityConfig> config = STableManager.getConfig(SRechargeCommodityConfig.class);
Map<Integer, SRechargeCommodityConfig> rechargeLevelMapTmp = new HashMap<>();
Set<Integer> rchargeHeroGetTemp = new HashSet<>();
Map<Integer, Integer> recharegeHeroTimeTmp = new HashMap<>();
for(SRechargeCommodityConfig sRechargeCommodityConfig : config.values()){
int[] discountType = sRechargeCommodityConfig.getDiscountType();
if(discountType!=null && discountType.length>0 &&discountType[0] == 2){
int level = discountType[1];
rechargeLevelMapTmp.put(level,sRechargeCommodityConfig);
}
if(discountType!=null && discountType.length>0 &&discountType[0] == 4){
if(discountType!=null && discountType.length>0 &&discountType[0] == 4&&sRechargeCommodityConfig.getTime()==4&&sRechargeCommodityConfig.getDiscountType().length==3){
rchargeHeroGetTemp.add(sRechargeCommodityConfig.getId());
recharegeHeroTimeTmp.put(discountType[1],sRechargeCommodityConfig.getId());
}
int time = sRechargeCommodityConfig.getTime();
@ -99,6 +99,7 @@ public class SRechargeCommodityConfig implements BaseConfig {
rechargeCommodityConfigMap = config;
rechargeLevelMap = rechargeLevelMapTmp;
rchargeHeroGet = rchargeHeroGetTemp;
recharegeHeroTime = recharegeHeroTimeTmp;
}
@ -202,4 +203,12 @@ public class SRechargeCommodityConfig implements BaseConfig {
public static Set<Integer> getRchargeHeroGet() {
return rchargeHeroGet;
}
public static Map<Integer, Integer> getRecharegeHeroTime() {
return recharegeHeroTime;
}
public static void setRecharegeHeroTime(Map<Integer, Integer> recharegeHeroTime) {
SRechargeCommodityConfig.recharegeHeroTime = recharegeHeroTime;
}
}