新礼包

back_recharge
mengchengzhen 2021-04-26 17:27:54 +08:00
parent 972806ba8f
commit 27aa32bd23
5 changed files with 100 additions and 21 deletions

View File

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

View File

@ -67,6 +67,7 @@ public class BuyGoodsNewLogic {
* *
*/ */
public static boolean refreshWelfareState(User user) throws Exception { public static boolean refreshWelfareState(User user) throws Exception {
sendDailyMailReward(user);
boolean needChange = false; boolean needChange = false;
List<AbstractWelfareBag> pAddList = new ArrayList<>(); List<AbstractWelfareBag> pAddList = new ArrayList<>();
NewRechargeInfo info = user.getPlayerInfoManager().getNewRechargeInfo(); NewRechargeInfo info = user.getPlayerInfoManager().getNewRechargeInfo();
@ -85,6 +86,7 @@ public class BuyGoodsNewLogic {
} }
}else{ }else{
//没有的话新初始化信息 //没有的话新初始化信息
if(entry.getValue().getOtype() != RechargeType.push.getType()){//推送不在此初始化
AbstractWelfareBag bag = rechargeHandler.initUnitWF(user, entry.getValue()); AbstractWelfareBag bag = rechargeHandler.initUnitWF(user, entry.getValue());
pAddList.add(bag); pAddList.add(bag);
if(refreshUnitWF(bag,user) && !needChange){ if(refreshUnitWF(bag,user) && !needChange){
@ -92,6 +94,7 @@ public class BuyGoodsNewLogic {
} }
} }
} }
}
//添加新增礼包 //添加新增礼包
for(AbstractWelfareBag bag : pAddList){ for(AbstractWelfareBag bag : pAddList){
int type = bag.getType(); int type = bag.getType();
@ -150,9 +153,6 @@ public class BuyGoodsNewLogic {
return resultRes; return resultRes;
} }
goodsId = config.getId(); goodsId = config.getId();
if(goodsId == 507){
System.out.println();
}
double priceTemp =config.getPrice(); double priceTemp =config.getPrice();
int cfgType = SSpecialConfig.getIntegerValue(SSpecialConfig.EXCHANGE_FORCE_TYPE); int cfgType = SSpecialConfig.getIntegerValue(SSpecialConfig.EXCHANGE_FORCE_TYPE);
double price = priceTemp==0?0: SExchangeRate.doubleIntegerHashMap.get(cfgType).get((int)priceTemp); double price = priceTemp==0?0: SExchangeRate.doubleIntegerHashMap.get(cfgType).get((int)priceTemp);
@ -164,15 +164,6 @@ public class BuyGoodsNewLogic {
NewRechargeInfo info = user.getPlayerInfoManager().getNewRechargeInfo(); NewRechargeInfo info = user.getPlayerInfoManager().getNewRechargeInfo();
AbstractWelfareBag bag = null; AbstractWelfareBag bag = null;
RechargeHandler rechargeHandler = getRechargeHandler(config.getOtype()); RechargeHandler rechargeHandler = getRechargeHandler(config.getOtype());
// if(config.getOtype() == RechargeType.perpetual.getType()){
// bag = info.getPerpetualMap().get(goodsId);
// }else if(config.getOtype() == RechargeType.timeLimit.getType()){
// bag = info.getTimeLimitMap().get(goodsId);
// }else if(config.getOtype() == RechargeType.receive.getType()){
// bag = info.getReceiveMap().get(goodsId);
// }else if(config.getOtype() == RechargeType.push.getType()){
// bag = info.getPushMap().get(goodsId);
// }
bag = rechargeHandler.getRechargeMap(user).get(goodsId); bag = rechargeHandler.getRechargeMap(user).get(goodsId);
String rewardStr=""; String rewardStr="";
if(bag == null || !bag.buy()){ if(bag == null || !bag.buy()){
@ -579,6 +570,17 @@ public class BuyGoodsNewLogic {
giftGoodsInfoList.add(buildGoodsInfo(bag)); giftGoodsInfoList.add(buildGoodsInfo(bag));
} }
} }
giftGoodsInfoList.sort(new Comparator<CommonProto.GiftGoodsInfo>() {
@Override
public int compare(CommonProto.GiftGoodsInfo o1, CommonProto.GiftGoodsInfo o2) {
if(o1.getGoodsId() > o2.getGoodsId()){
return 1;
}else if(o1.getGoodsId() < o2.getGoodsId()){
return -1;
}
return 0;
}
});
return needChange; return needChange;
} }
@ -587,7 +589,11 @@ public class BuyGoodsNewLogic {
builder.setGoodsId(bag.getModId()); builder.setGoodsId(bag.getModId());
builder.setBuyTimes(bag.getBuyTimes()); builder.setBuyTimes(bag.getBuyTimes());
builder.setStartTime((int)(bag.getStartTime()/1000)); builder.setStartTime((int)(bag.getStartTime()/1000));
if(bag.getType() == RechargeType.perpetual.getType() && bag.getRefreshTime() > 0){
builder.setEndTime((int)(bag.getRefreshTime()/1000));
}else{
builder.setEndTime((int)(bag.getEndTime()/1000)); builder.setEndTime((int)(bag.getEndTime()/1000));
}
if(bag.getLimit() == 0){ if(bag.getLimit() == 0){
builder.setDynamicBuyTimes(1); builder.setDynamicBuyTimes(1);
}else{ }else{
@ -683,4 +689,59 @@ public class BuyGoodsNewLogic {
} }
return list; return list;
} }
/**
*
*/
public static void sendDailyMailReward(User user) throws Exception{
NewRechargeInfo info = user.getPlayerInfoManager().getNewRechargeInfo();
List<Integer> found1 = SRechargeCommodityNewConfig.getConfigListByType(GiftGoodsType.FOUND_ONE);
List<Integer> found2 = SRechargeCommodityNewConfig.getConfigListByType(GiftGoodsType.FOUND_TWO);
for(ReceiveWelfareBag bag : info.getReceiveMap().values()){
for(int id :found1){
if(bag.getModId() == id && canReward(bag)){
sendReward(user.getId(),id,bag,GiftGoodsType.FOUND_ONE);
}
}
for(int id :found2){
if(bag.getModId() == id && canReward(bag)){
sendReward(user.getId(),id,bag,GiftGoodsType.FOUND_TWO);
}
}
}
}
public static void sendReward(int uid,int id,ReceiveWelfareBag bag,int type) throws Exception{
int nowTime = (int)(System.currentTimeMillis()/1000);
int getDays = TimeUtils.differentDays(bag.getLastBuyTime(),bag.getGetRewardTime());
int canget = TimeUtils.differentDays(bag.getGetRewardTime(),System.currentTimeMillis());
getRewards(uid,id,getDays,canget,bag.getContinueDays());
bag.setGetRewardTime(TimeUtils.getTodayZero());
}
public static boolean canReward(ReceiveWelfareBag bag){
if(!bag.isOpen()){
return false;
}
if(!bag.isBought()){
return false;
}
if(TimeUtils.differentDays(bag.getGetRewardTime(),System.currentTimeMillis())<1){
return false;
}
return true;
}
public static void getRewards(int uid,int type,int startDay,int cDay,int continueDays) throws Exception{
int nowTime = (int)(System.currentTimeMillis()/1000);
for(int i = 1;i<=cDay;i++){
SLuxuryFund fund = SLuxuryFund.getByFoundIdAndDay(type,startDay+i);
String reward = ItemUtil.getMailReward(fund.getreward());
String title = SErrorCodeEerverConfig.getI18NMessage("recharge_"+type+"_daily_title");
String content;
content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("recharge_"+type+"_daily_txt",
new Object[]{continueDays-startDay-cDay},new int[]{0},"#");
MailLogic.getInstance().sendMail(uid,title,content,reward,nowTime, Global.MAIL_EFFECTIVE_TIME);
}
}
} }

View File

@ -69,8 +69,10 @@ public class NewRechargeInfo extends MongoBase {
public List<Integer> getPushList(){ public List<Integer> getPushList(){
List<Integer> list = new ArrayList<>(); List<Integer> list = new ArrayList<>();
for(int i : pushMap.keySet()){ for(PushWelfareBag bag : pushMap.values()){
list.add(i); if(bag.isOpen()){
list.add(bag.getModId());
}
} }
return list; return list;
} }

View File

@ -1253,7 +1253,7 @@ public class ItemUtil {
} }
} }
user.getUserMissionManager().onGameEvent(user,GameEvent.GET_HERO,heroStar[0],heroStar[1]); user.getUserMissionManager().onGameEvent(user,GameEvent.GET_HERO,heroStar[0],heroStar[1]);
if(scHero.getStar()>=5){ if(scHero.getStar()==5){
if(SItem.getsItemMap().get(scHero.getId()).getQuantity()>=5) if(SItem.getsItemMap().get(scHero.getId()).getQuantity()>=5)
Poster.getPoster().dispatchEvent(new HeroFiveStarGetEvent(user.getId(),scHero.getStar())); Poster.getPoster().dispatchEvent(new HeroFiveStarGetEvent(user.getId(),scHero.getStar()));
} }

View File

@ -3,7 +3,9 @@ package config;
import manager.STableManager; import manager.STableManager;
import manager.Table; import manager.Table;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
@Table(name ="RechargeCommodityConfig") @Table(name ="RechargeCommodityConfig")
@ -56,20 +58,30 @@ public class SRechargeCommodityNewConfig implements BaseConfig {
public static Map<Integer,SRechargeCommodityNewConfig> configMap; public static Map<Integer,SRechargeCommodityNewConfig> configMap;
public static Map<String,SRechargeCommodityNewConfig> sdkconfigMap; public static Map<String,SRechargeCommodityNewConfig> sdkconfigMap;
public static Map<Integer, List<Integer>> configTypeMap;
public void init() throws Exception { public void init() throws Exception {
Map<Integer, SRechargeCommodityNewConfig> config = STableManager.getConfig(SRechargeCommodityNewConfig.class); Map<Integer, SRechargeCommodityNewConfig> config = STableManager.getConfig(SRechargeCommodityNewConfig.class);
Map<Integer,SRechargeCommodityNewConfig> tempConfigMap = new HashMap<>(); Map<Integer,SRechargeCommodityNewConfig> tempConfigMap = new HashMap<>();
Map<String,SRechargeCommodityNewConfig> tempSdkConfigMap = new HashMap<>(); Map<String,SRechargeCommodityNewConfig> tempSdkConfigMap = new HashMap<>();
Map<Integer, List<Integer>> tempConfigTypeMap = new HashMap<>();
for(SRechargeCommodityNewConfig newConfig : config.values()){ for(SRechargeCommodityNewConfig newConfig : config.values()){
tempConfigMap.put(newConfig.getId(),newConfig); tempConfigMap.put(newConfig.getId(),newConfig);
tempSdkConfigMap.put(newConfig.getRechargeId(),newConfig); tempSdkConfigMap.put(newConfig.getRechargeId(),newConfig);
tempSdkConfigMap.put(newConfig.getRechargeId2(),newConfig); tempSdkConfigMap.put(newConfig.getRechargeId2(),newConfig);
tempSdkConfigMap.put(newConfig.getRechargeId3(),newConfig); tempSdkConfigMap.put(newConfig.getRechargeId3(),newConfig);
if(tempConfigTypeMap.containsKey(newConfig.getType())){
tempConfigTypeMap.get(newConfig.getType()).add(newConfig.getId());
}else{
List<Integer> list = new ArrayList<>();
list.add(newConfig.getId());
tempConfigTypeMap.put(newConfig.getType(),list);
}
} }
if(configMap == null){ if(configMap == null){
configMap = tempConfigMap; configMap = tempConfigMap;
sdkconfigMap = tempSdkConfigMap; sdkconfigMap = tempSdkConfigMap;
configTypeMap = tempConfigTypeMap;
} }
} }
@ -77,6 +89,10 @@ public class SRechargeCommodityNewConfig implements BaseConfig {
return configMap.get(id); return configMap.get(id);
} }
public static List<Integer> getConfigListByType(int type){
return configTypeMap.get(type);
}
public int getId() { return id; } public int getId() { return id; }
public String getRechargeId() { return rechargeId; } public String getRechargeId() { return rechargeId; }