新礼包

back_recharge
mengchengzhen 2021-04-30 01:44:11 +08:00
parent 832a767b77
commit 7d41aeec3a
3 changed files with 53 additions and 6 deletions

View File

@ -67,6 +67,7 @@ public class BuyGoodsNewLogic {
*
*/
public static boolean refreshWelfareState(User user) throws Exception {
dailyRefresh(user);
sendDailyMailReward(user);
boolean needChange = false;
List<AbstractWelfareBag> pAddList = new ArrayList<>();
@ -668,8 +669,16 @@ public class BuyGoodsNewLogic {
PlayerInfoProto.AllGiftGoodsIndication goodsBuild = PlayerInfoProto.AllGiftGoodsIndication.newBuilder().addAllGiftGoodsInfo(goodsBagInfo).build();
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.ALL_GIFTGOODS_INDICATION_VALUE, goodsBuild, true);
if(popup != 0){
PlayerInfoProto.PushWelfareResponse pushWelfareResponse = PlayerInfoProto.PushWelfareResponse.newBuilder().addId(popup).build();
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.PUSH_WELFARE_RESPONSE.getNumber(), pushWelfareResponse, true);
if(popup == 21 || popup == 400 || popup == 401 || popup == 402 ){
if(info.getTEMP_LIMIT()>0){
info.setTEMP_LIMIT(info.getTEMP_LIMIT() - 1);
PlayerInfoProto.PushWelfareResponse pushWelfareResponse = PlayerInfoProto.PushWelfareResponse.newBuilder().addId(popup).build();
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.PUSH_WELFARE_RESPONSE.getNumber(), pushWelfareResponse, true);
}
}else{
PlayerInfoProto.PushWelfareResponse pushWelfareResponse = PlayerInfoProto.PushWelfareResponse.newBuilder().addId(popup).build();
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.PUSH_WELFARE_RESPONSE.getNumber(), pushWelfareResponse, true);
}
}
}
@ -709,9 +718,15 @@ public class BuyGoodsNewLogic {
List<CommonProto.GoodsTypeDuration> list = new ArrayList<>();
NewRechargeInfo info = user.getPlayerInfoManager().getNewRechargeInfo();
for(AbstractWelfareBag bag : info.getTimeLimitBagList()){
CommonProto.GoodsTypeDuration goodsTypeDuration = CommonProto.GoodsTypeDuration.newBuilder()
.setGoodsType(bag.getModId()).setEndTime((int)(bag.getEndTime()/1000)).build();
list.add(goodsTypeDuration);
if(bag.getType() == RechargeType.receive.getType()){
CommonProto.GoodsTypeDuration goodsTypeDuration = CommonProto.GoodsTypeDuration.newBuilder()
.setGoodsType(bag.getModId()).setEndTime((int)((bag.getStartTime() + bag.getContinueDays() * TimeUtils.DAY)/1000)).build();
list.add(goodsTypeDuration);
}else{
CommonProto.GoodsTypeDuration goodsTypeDuration = CommonProto.GoodsTypeDuration.newBuilder()
.setGoodsType(bag.getModId()).setEndTime((int)(bag.getEndTime()/1000)).build();
list.add(goodsTypeDuration);
}
}
return list;
}
@ -776,4 +791,13 @@ public class BuyGoodsNewLogic {
MailLogic.getInstance().sendMail(uid,title,content,reward,nowTime, Global.MAIL_EFFECTIVE_TIME);
}
}
public static void dailyRefresh(User user){
NewRechargeInfo info = user.getPlayerInfoManager().getNewRechargeInfo();
if(TimeUtils.differentDays(info.getLastRefreshTime(),System.currentTimeMillis())<1){
return;
}
info.setLastRefreshTime(System.currentTimeMillis());
info.setTEMP_LIMIT(2);
}
}

View File

@ -29,6 +29,9 @@ public class NewRechargeInfo extends MongoBase {
private int towerLost; //记录爬塔失败次数
private long nextPushTime; //上次推送时间
private long lastRefreshTime;
private int TEMP_LIMIT = 2;//临时五星成长礼每天最多两次
public boolean checkOneGoodsIsOverTimeByPrivilege(int privilegeId){
for(AbstractWelfareBag bag : perpetualMap.values()){
@ -55,7 +58,8 @@ public class NewRechargeInfo extends MongoBase {
}
}
for(AbstractWelfareBag bag : receiveMap.values()){
if(bag.isOpen() && bag.getEndTime() > 0){
bag = (ReceiveWelfareBag)bag;
if(((ReceiveWelfareBag) bag).isBought()){
list.add(bag);
}
}
@ -253,4 +257,22 @@ public class NewRechargeInfo extends MongoBase {
this.nextPushTime = nextPushTime;
updateString("nextPushTime",nextPushTime);
}
public int getTEMP_LIMIT() {
return TEMP_LIMIT;
}
public void setTEMP_LIMIT(int TEMP_LIMIT) {
this.TEMP_LIMIT = TEMP_LIMIT;
updateString("TEMP_LIMIT",TEMP_LIMIT);
}
public long getLastRefreshTime() {
return lastRefreshTime;
}
public void setLastRefreshTime(long lastRefreshTime) {
this.lastRefreshTime = lastRefreshTime;
updateString("lastRefreshTime",lastRefreshTime);
}
}

View File

@ -64,6 +64,7 @@ public class ReceiveWelfareBag extends AbstractWelfareBag {
}
}
setBought(true);
setStartTime(TimeUtils.getTodayZero());
if(getEndTime()!=0){
setEndTime(TimeUtils.getTodayZero() + getContinueDays() * TimeUtils.DAY);
}