back_recharge
lvxinran 2020-06-17 19:09:16 +08:00
commit bc08a7f1e5
8 changed files with 209 additions and 35 deletions

View File

@ -48,8 +48,6 @@ public class CheckFight {
//init();
LOGGER.info("the luahotfix done");
hotFixVersion.set(luaHotFixBean.getVersion());
//tofix 不是原子操作
this.localTransCoderObj = new ThreadLocal<LuaValue>();
}
}

View File

@ -1,6 +1,7 @@
-- windows
package.path = package.path ..';luafight/?.lua';
-- linux
-- package.path = package.path ..';../luafight/?.lua';
package.path = package.path ..';../luafight/?.lua';
require("Modules.Battle.Logic.Misc.BattleDefine")
require("Modules.Battle.Logic.Misc.BattleUtil")
@ -20,6 +21,12 @@ require("Modules.Battle.Logic.Base.Passivity")
require("Modules.Battle.Logic.BattleLogic")
require("Modules.Battle.Logic.RoleLogic")
require("Modules.Battle.Logic.SkillManager")
require("Modules.Battle.Logic.RoleManager")
require("Modules.Battle.Logic.OutDataManager")
require("Modules.Battle.Logic.BattleLogManager")
local BattleMain = {}
local BattleLogic = BattleLogic
local Random = Random
@ -291,7 +298,25 @@ function BattleMain.Execute(args, fightData, optionData)
os.date("%H"),
os.date("%M"),
os.date("%S"))
local file = io.open("luafight/LogError/"..time..".txt", "a")
local file
local platform
-- linux
if not file then
file = io.open("../luafight/LogError/"..time..".txt", "a")
platform = "Linux"
end
-- local window server
if not file then
file = io.open("luafight/LogError/"..time..".txt", "a")
platform = "Local Windows Server"
end
-- local
if not file then
file = io.open("LogError/"..time..".txt", "a")
platform = "Local"
end
file:write(platform..":\n\n\n")
file:write(errorCache)
file:write("seed:\n"..tostring(args.seed).."\n")
file:write("type:\n"..tostring(args.type).."\n")

View File

@ -0,0 +1,86 @@
package com.ljsd.jieling.logic.activity.eventhandler;
import com.ljsd.jieling.core.SimpleTransaction;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.IEventHandler;
import com.ljsd.jieling.logic.activity.event.HeroFiveStarGetEvent;
import com.ljsd.jieling.logic.activity.event.IEvent;
import com.ljsd.jieling.logic.activity.event.UserLevelEvent;
import com.ljsd.jieling.logic.dao.CumulationData;
import com.ljsd.jieling.logic.dao.RechargeInfo;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.store.BuyGoodsLogic;
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 config.SRechargeCommodityConfig;
import config.SSpecialConfig;
import manager.STableManager;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Description:
* Author: zsx
* CreateDate: 2020/6/15 11:51
*/
public class LeveGiftEventHander implements IEventHandler {
@Override
public void onEvent(IEvent event) throws Exception {
if(event instanceof UserLevelEvent){
int[] onceArrayValue = SSpecialConfig.getOnceArrayValue(SSpecialConfig.DISCOUNT_LEVEL);
int start = onceArrayValue[0];
int inter = onceArrayValue[1];
if(((UserLevelEvent) event).getLevel()<start){
return;
}
User user = UserManager.getUser(((UserLevelEvent) event).getUid());
boolean b = (((UserLevelEvent) event).getLevel() - start) % inter == 0;
if(!b){
return;
}
RechargeInfo rechargeInfo = user.getPlayerInfoManager().getRechargeInfo();
int saveAmt = rechargeInfo.getSaveAmt();
Map.Entry<Integer, Integer> entry = SRechargeCommodityConfig.rechargePlayerLevelMap.floorEntry(saveAmt);
SRechargeCommodityConfig orDefault = STableManager.getConfig(SRechargeCommodityConfig.class).getOrDefault(entry.getValue(), null);
if(orDefault==null){
return;
}
if(rechargeInfo.getLevelAndMoneyBagMap().containsKey(entry.getKey())){
long lasttime = rechargeInfo.getLevelAndMoneyBagMap().get(entry.getKey());
long i = orDefault.getDiscountType()[3] * 3600*1000;
if(System.currentTimeMillis()-lasttime<i){
rechargeInfo.addDyGoodsCanBuyTimes(orDefault.getId());
}else {
rechargeInfo.putDyGoodsCanBuyTimes(orDefault.getId(),1);
}
}else {
rechargeInfo.putDyGoodsCanBuyTimes(orDefault.getId(),1);
}
rechargeInfo.putLevelAndMoneyBagMap(entry.getKey(),System.currentTimeMillis());
// BuyGoodsLogic.sendGiftGooodsIndication(user.getId());
List<CommonProto.GiftGoodsInfo> goodsBagInfo = new ArrayList<>(SRechargeCommodityConfig.rechargeCommodityConfigMap.size());
BuyGoodsLogic.getGoodsBagInfo(user.getId(), goodsBagInfo,false);
ISession session = OnlineUserManager.getSessionByUid(user.getId());
if(session!=null){
if(null!= SimpleTransaction.current()){
//获得多个英雄进行协议合并
PlayerInfoProto.AllGiftGoodsIndication.Builder build = PlayerInfoProto.AllGiftGoodsIndication.newBuilder().addAllGiftGoodsInfo(goodsBagInfo);
SimpleTransaction.current().dealWhileCommit(new SimpleTransaction.SendTask(build.build(), MessageTypeProto.MessageType.ALL_GIFTGOODS_INDICATION_VALUE));
}
}
}
}
}

View File

@ -20,7 +20,8 @@ public class RechargeInfo extends MongoBase{
@Transient
private volatile Set<Integer> cacheSendedIds = new ConcurrentSet<>();
private Map<Integer,Long> levelBagMap = new HashMap<>();
private Map<Integer,Long> levelBagMap = new HashMap<>();//等级开启
private Map<Integer,Long> levelAndMoneyBagMap = new HashMap<>();//等级礼包开启
private Map<Integer,Long> refreshBagMap = new HashMap<>();
@ -259,4 +260,22 @@ public class RechargeInfo extends MongoBase{
this.smonthSaveAmt = smonthSaveAmt;
updateString("smonthSaveAmt",smonthSaveAmt);
}
public Map<Integer, Long> getLevelAndMoneyBagMap() {
return levelAndMoneyBagMap;
}
public void putLevelAndMoneyBagMap(Integer type,Long value) {
this.levelAndMoneyBagMap.put(type,value );
cacheSendedIds.remove(type);
updateString("levelAndMoneyBagMap",levelAndMoneyBagMap);
}
public void removeLevelAndMoneyBagMap(Integer type) {
this.levelAndMoneyBagMap.remove(type);
cacheSendedIds.remove(type);
updateString("levelAndMoneyBagMap",levelAndMoneyBagMap);
}
}

View File

@ -16,6 +16,7 @@ import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.logic.activity.event.*;
import com.ljsd.jieling.logic.activity.eventhandler.HeroFiveStarGetEventHandler;
import com.ljsd.jieling.logic.activity.eventhandler.LeveGiftEventHander;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.expedition.ExpeditionLogic;
@ -52,6 +53,7 @@ public class HeroLogic{
private HeroLogic(){
//英雄事件监听
Poster.getPoster().listenEvent(new HeroFiveStarGetEventHandler(), HeroFiveStarGetEvent.class);
Poster.getPoster().listenEvent(new LeveGiftEventHander(), UserLevelEvent.class);
}

View File

@ -90,6 +90,8 @@ public class BuyGoodsLogic {
}
int price =sRechargeCommodityConfig.getPrice();
buyCount=buyCount+1;
//time check
int limit = sRechargeCommodityConfig.getLimit();
int type = sRechargeCommodityConfig.getType();
if(limit!=0){
@ -99,6 +101,22 @@ public class BuyGoodsLogic {
resultRes.setResultMsg("over limit");
return resultRes;
}
}else {
if(sRechargeCommodityConfig.getTime()==4&&(sRechargeCommodityConfig.getDiscountType().length==3||sRechargeCommodityConfig.getDiscountType().length==4)){
int[] discountType = sRechargeCommodityConfig.getDiscountType();
int temptype = discountType[0];
if(temptype == 4||temptype==3){
int dytime = rechargeInfo.getDyGoodsCanBuyTimes().getOrDefault(goodsId,0)-1;
if(dytime <0){
LOGGER.error("the uid={},the goodId={}, is over limit",uid,goodsId);
resultRes.setResultCode(0);
resultRes.setResultMsg("over limit");
return resultRes;
}
}
}
}
int nowTime =(int) (TimeUtils.now()/1000);
@ -243,39 +261,45 @@ public class BuyGoodsLogic {
}
rechargeInfo.updateBuyGoodsTimes(goodsId,buyCount);
ISession session = OnlineUserManager.getSessionByUid(uid);
//特殊礼包次数
if(sRechargeCommodityConfig.getTime()==4&&(sRechargeCommodityConfig.getDiscountType().length==3||sRechargeCommodityConfig.getDiscountType().length==4)){
int[] discountType = sRechargeCommodityConfig.getDiscountType();
int temptype = discountType[0];
int tempvalue = discountType[1];
if(temptype == 4||temptype==3){
int dytime = rechargeInfo.getDyGoodsCanBuyTimes().getOrDefault(goodsId,0)-1;
if(dytime <=0){
if (rechargeInfo.getTypeBagMap().containsKey(tempvalue)){
rechargeInfo.removeTypeBagMap(tempvalue);
}
if (rechargeInfo.getLevelAndMoneyBagMap().containsKey(tempvalue)){
rechargeInfo.removeLevelAndMoneyBagMap(tempvalue);
}
if (rechargeInfo.getCacheSendedTypes().containsKey(tempvalue)){
rechargeInfo.getCacheSendedTypes().remove(tempvalue);
}
rechargeInfo.putDyGoodsCanBuyTimes(goodsId,dytime);
}else {
rechargeInfo.putDyGoodsCanBuyTimes(goodsId,dytime);
}
// List<CommonProto.GiftGoodsInfo> goodsBagInfo = new ArrayList<>(SRechargeCommodityConfig.rechargeCommodityConfigMap.size());
// BuyGoodsLogic.getGoodsBagInfo(uid, goodsBagInfo,false);
// PlayerInfoProto.AllGiftGoodsIndication build = PlayerInfoProto.AllGiftGoodsIndication.newBuilder().addAllGiftGoodsInfo(goodsBagInfo).build();
// MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.ALL_GIFTGOODS_INDICATION_VALUE,build,true);
}
}
//直购礼包
if(type == GiftGoodsType.DIRECTBAG){
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sRechargeCommodityConfig.getBaseReward(), BIReason.DIRECT_BUY);
ISession session = OnlineUserManager.getSessionByUid(uid);
if(session!=null){
PlayerInfoProto.DirectBuyIndication build = PlayerInfoProto.DirectBuyIndication.newBuilder().setDrop(drop).build();
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.DIRECT_BUY_GOODS_INDICATION_VALUE,build,true);
}
if(sRechargeCommodityConfig.getTime()==4&&sRechargeCommodityConfig.getDiscountType().length==3){
int[] discountType = sRechargeCommodityConfig.getDiscountType();
int temptype = discountType[0];
int tempvalue = discountType[1];
if(temptype == 4){
int dytime = rechargeInfo.getDyGoodsCanBuyTimes().getOrDefault(goodsId,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(goodsId,dytime);
}
List<CommonProto.GiftGoodsInfo> goodsBagInfo = new ArrayList<>(SRechargeCommodityConfig.rechargeCommodityConfigMap.size());
BuyGoodsLogic.getGoodsBagInfo(uid, goodsBagInfo,false);
PlayerInfoProto.AllGiftGoodsIndication build = PlayerInfoProto.AllGiftGoodsIndication.newBuilder().addAllGiftGoodsInfo(goodsBagInfo).build();
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.ALL_GIFTGOODS_INDICATION_VALUE,build,true);
}
}
}else{
String title = SErrorCodeEerverConfig.getI18NMessage("recharge_" + sRechargeCommodityConfig.getType() + "_title");
@ -289,7 +313,10 @@ public class BuyGoodsLogic {
title = SErrorCodeEerverConfig.getI18NMessage("recharge_" + sRechargeCommodityConfig.getType() + "_title",new Object[]{sRechargeCommodityConfig.getName()});
content = SErrorCodeEerverConfig.getI18NMessage("recharge_" + sRechargeCommodityConfig.getType() + "_txt",new Object[]{sRechargeCommodityConfig.getName()});
}
MailLogic.getInstance().sendMail(user.getId(),title,content,rewardStr,nowTime, Global.MAIL_EFFECTIVE_TIME);
if(!rewardStr.isEmpty()){
MailLogic.getInstance().sendMail(user.getId(),title,content,rewardStr,nowTime, Global.MAIL_EFFECTIVE_TIME);
}
}
if(sRechargeCommodityConfig.getTime() ==5){
rechargeInfo.updateRefreshMapByKey(sRechargeCommodityConfig.getId(),TimeUtils.now()+sRechargeCommodityConfig.getDailyUpdate()*TimeUtils.DAY);
@ -390,6 +417,7 @@ public class BuyGoodsLogic {
long now = TimeUtils.now();
Map<Integer, Integer> buyGoodsTimes = rechargeInfo.getBuyGoodsTimes();
Map<Integer, Long> levelBagMap = rechargeInfo.getLevelBagMap();
Map<Integer, Long> levelAndMoneyBagMap = rechargeInfo.getLevelAndMoneyBagMap();
Map<Integer, Long> typeBagMap = rechargeInfo.getTypeBagMap();
Map<Integer, Long> refreshBagMap = rechargeInfo.getRefreshBagMap();
Map<Integer,Integer> goodsOrder = new HashMap<>(6);
@ -424,6 +452,7 @@ public class BuyGoodsLogic {
if(time == 4){
int type = discountType[0];
int value = discountType[1];
//等级商店
if(type == 2){
if(!levelBagMap.containsKey(value)){
continue;
@ -435,9 +464,24 @@ public class BuyGoodsLogic {
}
endTime = startTime + value*3600*1000;
}
//等级礼包
if(type==3){
if(!levelAndMoneyBagMap.containsKey(value)){
continue;
}
startTime = levelAndMoneyBagMap.get(value);
long i = discountType[3] * 3600*1000;
if(now-startTime>=i){
//超过2小时重置动态购买次数
rechargeInfo.removeDyGoodsCanBuyTimes(goodsId);
continue;
}
endTime = startTime + discountType[3]*3600*1000;
}
//成长礼
if(type == 4){
//4#妖灵师星级#持续时间
if(!typeBagMap.containsKey(value)){

View File

@ -79,8 +79,8 @@ public class SRechargeCommodityConfig implements BaseConfig {
int level = discountType[1];
rechargeLevelMapTmp.put(level,sRechargeCommodityConfig);
}
if(discountType!=null && discountType.length>0 &&sRechargeCommodityConfig.getTime()==4&&sRechargeCommodityConfig.getDiscountType().length==3) {
if (discountType[0] == 4) {
if(discountType!=null && discountType.length>0 &&sRechargeCommodityConfig.getTime()==4) {
if (discountType[0] == 4&&sRechargeCommodityConfig.getDiscountType().length==3) {
recharegeHeroTimeTmp.put(discountType[1], sRechargeCommodityConfig.getId());
} else if (discountType[0] == 3) {
rechargePlayerLevelTemp.put(discountType[1], sRechargeCommodityConfig.getId());

View File

@ -64,7 +64,7 @@ public class SSpecialConfig implements BaseConfig {
public static final String LOTTERY_ENERGY_COST = "lottery_energy_cost";//钻石抽积攒仙缘能量(原非酋气息)抽奖消耗
public static final String EXPEDITION_REBORN = "expedition_reborn";// 大闹天宫复活道具id
public static final String REWARD_OF_WORSHIP = "reward_of_worship";//膜拜获得金币奖励
public static final String DISCOUNT_LEVEL= "discount_level";//限时折扣推送等级#推送间隔等级
@Override
public void init() throws Exception {