TASK 【ID1006352】【活动需求】升级礼包推送
parent
908fdb1d5b
commit
7225ca8ab4
|
@ -48,8 +48,6 @@ public class CheckFight {
|
|||
//init();
|
||||
LOGGER.info("the luahotfix done");
|
||||
hotFixVersion.set(luaHotFixBean.getVersion());
|
||||
//tofix 不是原子操作
|
||||
this.localTransCoderObj = new ThreadLocal<LuaValue>();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -99,6 +99,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 +259,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");
|
||||
|
@ -390,6 +412,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 +447,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 +459,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)){
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
Loading…
Reference in New Issue