buy goods

back_recharge
wangyuan 2019-07-22 13:45:47 +08:00
parent 8ba85e72fc
commit e90e414522
5 changed files with 47 additions and 9 deletions

View File

@ -9,6 +9,7 @@ import com.ljsd.jieling.logic.GlobalDataManaager;
import com.ljsd.jieling.logic.activity.ActivityLogic;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.player.PlayerLogic;
import com.ljsd.jieling.logic.store.BuyGoodsLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
@ -52,6 +53,7 @@ public class GetPlayerInfoHandler extends BaseHandler{
userId, token,msgId,msgIndex,getPlayerInfoRequest.getNum(),getPlayerInfoRequest.getStr());
User user = UserManager.getUser(userId);
PlayerLogic.getInstance().sendDayilyMail(user,-1);
PlayerManager playerInfoManager = user.getPlayerInfoManager();
GlobalDataManaager.checkNeedReFlush(iSession,user,null);
playerInfoManager.setLoginTime(TimeUtils.now());

View File

@ -1,7 +1,10 @@
package com.ljsd.jieling.handler;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.player.PlayerLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@ -14,6 +17,6 @@ public class ServerZeroHandler extends BaseHandler {
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
PlayerLogic.getInstance().sendDayilyMail(UserManager.getUser(iSession.getUid()),-1);
}
}

View File

@ -19,6 +19,8 @@ public class RechargeInfo extends MongoBase{
private Map<Integer,Integer> goodseDurationMap = new HashMap<>();
private Map<Integer,Integer> goodseSendDailyMap = new HashMap<>();
public RechargeInfo(){
}
@ -130,4 +132,13 @@ public class RechargeInfo extends MongoBase{
public Map<Integer, Integer> getGoodsDurationMap() {
return goodseDurationMap;
}
public Map<Integer, Integer> getGoodseSendDailyMap() {
return goodseSendDailyMap;
}
public void updateGoodsSendTime(int goodsType,int sendTime) {
updateString("goodseSendDailyMap." + goodsType,sendTime);
this.goodseSendDailyMap.put(goodsType,sendTime);
}
}

View File

@ -277,19 +277,34 @@ public class PlayerLogic {
MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true);
}
public void sendDayilyMail(User user) throws Exception {
public void sendDayilyMail(User user,int goodsType) throws Exception {
int nowTime = (int)(System.currentTimeMillis()/1000);
int level = user.getPlayerInfoManager().getLevel();
Map<Integer, Integer> goodsTypeDurationMap = user.getPlayerInfoManager().getRechargeInfo().getGoodsDurationMap();
Map<Integer, Integer> goodseSendDailyMap = user.getPlayerInfoManager().getRechargeInfo().getGoodseSendDailyMap();
for(Map.Entry<Integer,Integer> goodsInfo:goodsTypeDurationMap.entrySet()){
SRechargeCommodityConfig sRechargeCommodityConfig = SRechargeCommodityConfig.rechargeCommodityConfigMap.get(goodsInfo.getKey());
int type = sRechargeCommodityConfig.getType();
if(goodsType!=-1 && type!=goodsType){
continue;
}
int days =1;
if(goodsType == -1){
Integer lastSendTime = goodseSendDailyMap.get(type);
if(lastSendTime!=null){
days = TimeUtils.differentDays(lastSendTime * 1000L,nowTime * 1000L);
}
}
user.getPlayerInfoManager().getRechargeInfo().updateGoodsSendTime(type,nowTime);
int theIndexByTarget = MathUtils.getTheIndexByTarget(sRechargeCommodityConfig.getPlayerLevel(), level);
int[][] extraReward = sRechargeCommodityConfig.getExtraReward()[theIndexByTarget];
String mailReward = ItemUtil.getMailReward(extraReward);
String title = SErrorCodeEerverConfig.getI18NMessage("recharge_"+type+"_equip_title");
String content = SErrorCodeEerverConfig.getI18NMessage("recharge_"+type+"_equip_txt");
MailLogic.getInstance().sendMail(user.getId(),title,content,mailReward,nowTime, Global.MAIL_EFFECTIVE_TIME);
String title = SErrorCodeEerverConfig.getI18NMessage("recharge_"+type+"_daily_title");
String content = SErrorCodeEerverConfig.getI18NMessage("recharge_"+type+"_daily_txt");
int sendTims = days;
while (sendTims-->0){
MailLogic.getInstance().sendMail(user.getId(),title,content,mailReward,nowTime, Global.MAIL_EFFECTIVE_TIME);
}
if(sRechargeCommodityConfig.getType() == GiftGoodsType.LUXURYMONTHCARD){
Map<Integer, SLuxuriousCardEquipConfig> configMap = SLuxuriousCardEquipConfig.configMap;
for(SLuxuriousCardEquipConfig sLuxuriousCardEquipConfig : configMap.values()){
@ -299,7 +314,10 @@ public class PlayerLogic {
mailReward = ItemUtil.getMailReward(reward, 1.0f);
title = SErrorCodeEerverConfig.getI18NMessage("recharge_6_equip_title");
content = SErrorCodeEerverConfig.getI18NMessage("recharge_6_equip_txt");
MailLogic.getInstance().sendMail(user.getId(),title,content,mailReward,nowTime, Global.MAIL_EFFECTIVE_TIME);
sendTims = days;
while (sendTims-->0){
MailLogic.getInstance().sendMail(user.getId(),title,content,mailReward,nowTime, Global.MAIL_EFFECTIVE_TIME);
}
break;
}
}

View File

@ -99,6 +99,7 @@ public class BuyGoodsLogic {
if(type == GiftGoodsType.MONTHCARD || type == GiftGoodsType.LUXURYMONTHCARD ){
Integer endTime = null;
Map<Integer, Integer> goodsDurationMap = rechargeInfo.getGoodsDurationMap();
boolean needSendMail = false;
for(Map.Entry<Integer,Integer> goodsDurationItem : goodsDurationMap.entrySet()){
if(SRechargeCommodityConfig.rechargeCommodityConfigMap.get(goodsDurationItem.getKey()).getType() == type){
endTime = goodsDurationItem.getValue();
@ -106,7 +107,7 @@ public class BuyGoodsLogic {
}
if(endTime == null || nowTime>endTime){
endTime = nowTime;
triggerEvent(user,type,nowTime);
needSendMail = true;
}
if(nowTime<endTime-SGameSetting.getGameSetting().getNextAvailableTime()*3600){
@ -116,6 +117,9 @@ public class BuyGoodsLogic {
}
endTime += 30 * 24 * 3600;
rechargeInfo.updateGoodsTypeDuration(sRechargeCommodityConfig.getId(),endTime);
if(needSendMail){
triggerEvent(user,type,nowTime);
}
}
@ -191,6 +195,7 @@ public class BuyGoodsLogic {
*/
public static void triggerEvent(User user,int goodsType,int nowTime) throws Exception {
if(goodsType == GiftGoodsType.LUXURYMONTHCARD){
PlayerLogic.getInstance().sendDayilyMail(user,goodsType);
int starReward = user.getMapManager().getStarReward();
if(starReward == 0){
return;
@ -206,10 +211,9 @@ public class BuyGoodsLogic {
String title = SErrorCodeEerverConfig.getI18NMessage("recharge_6_star_title");
String content = SErrorCodeEerverConfig.getI18NMessage("recharge_6_star_txt");
MailLogic.getInstance().sendMail(user.getId(),title,content,rewardStr.toString(),nowTime, Global.MAIL_EFFECTIVE_TIME);
PlayerLogic.getInstance().sendDayilyMail(user);
}else if(goodsType == GiftGoodsType.MONTHCARD){
user.getPlayerInfoManager().addVipInfo(VipPrivilegeType.UNLOCK_TRIAL_BOMB_REWARD);
PlayerLogic.getInstance().sendDayilyMail(user);
PlayerLogic.getInstance().sendDayilyMail(user,goodsType);
}
}