back_recharge
lvxinran 2019-09-17 15:57:39 +08:00
commit 611dd26e04
11 changed files with 57 additions and 66 deletions

View File

@ -93,8 +93,6 @@ public class BloodyProtocolsManager implements ProtocolsAbstract {
MessageUtil.sendErrorCode(session,0,"您的账号token不正确请退出游戏重新登陆!");
return;
}
//处理多设备重登
dealRepeatLogin(session.getUid());
//刷新token
refreshToken(session);
//踢下线
@ -110,11 +108,6 @@ public class BloodyProtocolsManager implements ProtocolsAbstract {
dealHeartBeat(session);
return;
}
//检查token
// if (checkToken(session,packetNetData) != 0 ){
// MessageUtil.sendErrorCode(session,0,"您的账号token不正确请退出游戏重新登陆!");
// return;
// }
if( packetNetData.getMsgId()== MessageTypeProto.MessageType.RECONNECT_REQUEST_VALUE){
processReconnect(session);
@ -122,9 +115,7 @@ public class BloodyProtocolsManager implements ProtocolsAbstract {
return;
}
if (checkIndex(session,packetNetData) != 0){
return;
}
LOGGER.info("request commond : " + packetNetData.getMsgId());
BaseHandler baseHandler = handlers.get(packetNetData.getMsgId());
if (baseHandler == null) {
@ -212,36 +203,6 @@ public class BloodyProtocolsManager implements ProtocolsAbstract {
}
private int dealRepeatLogin(int uid) {
if (OnlineUserManager.checkUidOnline(uid)){
ISession iSession = OnlineUserManager.getSessionByUid(uid);
MessageUtil.sendErrorCode(iSession, ErrorCode.reloginCode,"您的账号已经在其他设备上登陆,请确认账号安全!");
iSession.setOfflineType(ErrorCode.reloginCode);
return 1;
}
return 0;
}
private int checkIndex(ISession iSession, PacketNetData packetNetData) {
int index = packetNetData.getIndex();
if (iSession.getIndex() >= index){
byte[] message = iSession.getCacheMessage(index);
if (message==null &&( packetNetData.getMsgId() != MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE || packetNetData.getMsgId() != MessageTypeProto.MessageType.RECONNECT_REQUEST_VALUE)){
//TODO error
LOGGER.info("the uid={},the msg={} is processing",iSession.getUid(), MessageTypeProto.MessageType.valueOf(packetNetData.getMsgId()));
return 1;
}else {
LOGGER.info("the uid={},the msg={} reback",iSession.getUid(), MessageTypeProto.MessageType.valueOf(packetNetData.getMsgId()));
iSession.writeAndFlush(message);
return 1;
}
}else {
iSession.setIndex(index);
iSession.setLoginTime(System.currentTimeMillis());
}
return 0;
}
private void ackIndication(ISession iSession, int ackId) {
LOGGER.info("the uid={},the ackId={}",iSession.getUid(),ackId);
iSession.clearIndication(ackId);

View File

@ -173,7 +173,7 @@ public class GameApplication {
public static void register(ConfigurableApplicationContext configurableApplicationContext){
CoreSettings coreSettings = configurableApplicationContext.getBean(CoreSettings.class);
String ip = coreSettings.getIp();
int port = coreSettings.getPort();
int port = coreSettings.getGmport();
String rpcUrl = ip + ":" + port;
RedisUtil.getInstence().set(RedisKey.LOGIC_SERVER_INFO+RedisKey.Delimiter_colon+GameApplication.serverId,gson.toJson(rpcUrl));
}

View File

@ -46,7 +46,9 @@ public class SGlobalSystemConfig implements BaseConfig {
@Override
public void init() throws Exception {
Map<Integer,SGlobalSystemConfig> sGlobalSystemConfigMapTmp = new HashMap<>();
if( GameApplication.serverConfig == null){
return;
}
Map<Integer, SGlobalSystemConfig> config = STableManager.getConfig(SGlobalSystemConfig.class);
Iterator<Map.Entry<Integer, SGlobalSystemConfig>> iterator = config.entrySet().iterator();
while (iterator.hasNext()){

View File

@ -12,6 +12,7 @@ public class CoreSettings {
private String ip;
private int port;
private int gmport;
private int area;
private int id;
private int weight;
@ -55,4 +56,12 @@ public class CoreSettings {
public void setPort(int port) {
this.port = port;
}
public int getGmport() {
return gmport;
}
public void setGmport(int gmport) {
this.gmport = gmport;
}
}

View File

@ -82,6 +82,8 @@ public interface BIReason {
int ENDLESS_REASON_CHANGE = 50;//无尽副本赛季更换
int RANDOM_SOULEQUIP = 51;//占星
int DIRECT_BUY = 52; // 直购
//道具消耗原因 1000开头
int ADVENTURE_UPLEVEL_CONSUME = 1000; //秘境升级

View File

@ -44,7 +44,7 @@ public class ExchangeCdkHandler extends BaseHandler<PlayerInfoProto.ExchangeCdkR
User user = UserManager.getUser(session.getUid());
Map<Integer, SCdkInfo> sCdkInfosCacheMap = CoreLogic.getInstance().getsCdkInfosCacheMap();
if (cdk.length() != 18 || sCdkInfosCacheMap == null || sCdkInfosCacheMap.isEmpty()) {
MessageUtil.sendErrorResponse(session, 0, MessageTypeProto.MessageType.EXCHANGE_CDK_RESPONSE_VALUE, "cdk.wrong");
MessageUtil.sendErrorResponse(session, 0, MessageTypeProto.MessageType.EXCHANGE_CDK_RESPONSE_VALUE, "兑换码无效");
return;
}
boolean distributedLock = RedisUtil.getInstence().tryGetDistributedLock(RedisKey.CDKEY,cdk , Integer.toString(uid),500);
@ -58,33 +58,33 @@ public class ExchangeCdkHandler extends BaseHandler<PlayerInfoProto.ExchangeCdkR
try {
cdkInfo = MongoUtil.getCoreMongoTemplate().findById(cdk, CdkInfo.class);
if (cdkInfo == null) {
MessageUtil.sendErrorResponse(session, 0, MessageTypeProto.MessageType.EXCHANGE_CDK_RESPONSE_VALUE, "cdk.wrong");
MessageUtil.sendErrorResponse(session, 0, MessageTypeProto.MessageType.EXCHANGE_CDK_RESPONSE_VALUE, "兑换码无效");
return;
}
goodsId = cdkInfo.getGoodsId();
//礼包信息
SCdkInfo scdkInfo = sCdkInfosCacheMap.get(goodsId);
if (scdkInfo == null) {
MessageUtil.sendErrorResponse(session, 0, MessageTypeProto.MessageType.EXCHANGE_CDK_RESPONSE_VALUE, "cdk.wrong");
MessageUtil.sendErrorResponse(session, 0, MessageTypeProto.MessageType.EXCHANGE_CDK_RESPONSE_VALUE, "兑换码无效");
return;
}
//pid
if(user.getPlayerInfoManager().getPid()!=scdkInfo.getPid())
{
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.EXCHANGE_CDK_REQUEST_VALUE,"cdk wrong");
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.EXCHANGE_CDK_REQUEST_VALUE,"兑换码无效");
return;
}
int usetype = scdkInfo.getUsetype();
if (usetype == 0) {//只能兑换一次
if (cdkInfo.getStatus() == 1) {
MessageUtil.sendErrorResponse(session, 0, MessageTypeProto.MessageType.EXCHANGE_CDK_RESPONSE_VALUE, "cdk.used");
MessageUtil.sendErrorResponse(session, 0, MessageTypeProto.MessageType.EXCHANGE_CDK_RESPONSE_VALUE, "兑换码已使用");
return;
}
} else {
boolean exists = MongoUtil.getCoreMongoTemplate().exists(new BasicQuery(new BasicDBObject("uid", uid).append("cdk_num", cdk)), CdkUseInfo.class);
if(exists){
MessageUtil.sendErrorResponse(session, 0, MessageTypeProto.MessageType.EXCHANGE_CDK_RESPONSE_VALUE, "cdk.role used");
MessageUtil.sendErrorResponse(session, 0, MessageTypeProto.MessageType.EXCHANGE_CDK_RESPONSE_VALUE, "该角色已兑换");
return;
}
}

View File

@ -74,6 +74,10 @@ public class RoomMatchRequestHandler extends BaseHandler{
return ;
}
User user = UserManager.getUser(iSession.getUid());
if( !user.getTeamPosManager().getTeamPosForHero().containsKey(GlobalsDef.BLOODY_TEAM)){
MessageUtil.sendErrorResponse(iSession,0,responseMsgId,"未设置编队");
return;
}
snapUserFightInfo(user);
RedisUtil.getInstence().set(RedisKey.MATCH_UID_KEY + ":" + uid,gson.toJson("1"));
List<String> matchAddressInfos = RedisUtil.getInstence().getAllSetToList(RedisKey.MATCH_SERVER_INFO + ":" + GameApplication.areaId, String.class);

View File

@ -193,7 +193,6 @@ public class BloodLogic {
int uid = session.getUid();
User user = UserManager.getUser(uid);
BloodyInfo bloodyInfo = user.getBloodyInfo();
bloodyInfo.setScore(99999);
Map<Integer, SBloodyBattleTreasure> sBloodyBattleTreasureMap = SBloodyBattleTreasure.sBloodyBattleTreasureMap;
RoomProto.GetBloodyScoreInfoResponse.Builder builder = RoomProto.GetBloodyScoreInfoResponse.newBuilder().setScore(bloodyInfo.getScore()).setHadBuy(bloodyInfo.getHadBuy());
if(bloodyInfo.getStateInfo().isEmpty()){
@ -302,12 +301,11 @@ public class BloodLogic {
}
public void calBloodyMissionInfo(User user,SortDataBean sortDataBean) throws Exception {
int killNums = sortDataBean.getKillNums();
BloodyInfo bloodyInfo = user.getBloodyInfo();
bloodyInfo.setKillNums(bloodyInfo.getKillNums() + 9999);
bloodyInfo.setKillNums(bloodyInfo.getKillNums());
int changeScore = calScore(sortDataBean);
if(changeScore>0){
bloodyInfo.setScore(bloodyInfo.getScore() + calScore(sortDataBean));
bloodyInfo.setScore(bloodyInfo.getScore() + changeScore);
}
MissionEventDistributor.requestStart();
user.getUserMissionManager().onGameEvent(user, GameEvent.BLOODY_END);

View File

@ -2,6 +2,7 @@ package com.ljsd.jieling.logic.store;
import com.ljsd.jieling.config.*;
import com.ljsd.jieling.core.VipPrivilegeType;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.ktbeans.KtEventUtils;
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
@ -45,7 +46,7 @@ public class BuyGoodsLogic {
return;
}
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.TEST_BUY_GIGT_GOODS_RESPONSE_VALUE,null,true);
Result result = sendGoods(uid, goodsId, "gm-test", "111111", System.currentTimeMillis(), -1);
Result result = sendGoods(uid, goodsId, "gm-test", "111111", System.currentTimeMillis(), -999);
User user = UserManager.getUser(uid);
int price =sRechargeCommodityConfig.getPrice();
int isDiscount = sRechargeCommodityConfig.getIsDiscount();
@ -190,22 +191,35 @@ public class BuyGoodsLogic {
buyGoodsTimes.put(goodsId,buyCount);
rechargeInfo.setBuyGoodsTimes(buyGoodsTimes);
//妖精
//直购礼包
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);
}
}else{
String title = SErrorCodeEerverConfig.getI18NMessage("recharge_" + sRechargeCommodityConfig.getType() + "_title");
String content = SErrorCodeEerverConfig.getI18NMessage("recharge_" + sRechargeCommodityConfig.getType() + "_txt");
if(type== 3 || type==1 || type==6){
content = SErrorCodeEerverConfig.getI18NMessage("recharge_" + sRechargeCommodityConfig.getType() + "_txt",new Object[]{rewardStr.split("#")[1]});
}
MailLogic.getInstance().sendMail(user.getId(),title,content,rewardStr,nowTime, Global.MAIL_EFFECTIVE_TIME);
}
resultRes.setResultCode(1);
KtEventUtils.onKtEvent(user, ParamEventBean.UserPayEvent,goodsId,orderId,resultRes.getResultCode(),price);
notifyPaySuccessFul(uid,goodsId);
notifyPaySuccessFul(uid,goodsId,amount != -999);
return resultRes;
}
//通知前端充值成功
public static void notifyPaySuccessFul(int uid,int goodsId){
public static void notifyPaySuccessFul(int uid,int goodsId,boolean needNotify){
if(!needNotify){
return;
}
ISession session = OnlineUserManager.getSessionByUid(uid);
if(session!=null){
PlayerInfoProto.NotifyPaySuccessfulIndicaiton build = PlayerInfoProto.NotifyPaySuccessfulIndicaiton.newBuilder().setGoodsId(goodsId).build();

View File

@ -298,7 +298,8 @@ public class ProtocolsManager implements ProtocolsAbstract {
MessageUtil.sendErrorCode(iSession, ErrorCode.reloginCode,"您的账号已经在其他设备上登陆,请确认账号安全!");
iSession.setOfflineType(ErrorCode.reloginCode);
backUpMsgToRedis(iSession);
offLine(iSession);
OnlineUserManager.userOffline(uid);
LOGGER.info("the channel={}",iSession.getCtx().channel());
return 1;
}
return 0;
@ -351,6 +352,9 @@ public class ProtocolsManager implements ProtocolsAbstract {
LOGGER.info("player offLine ...");
ISession session = (ISession) gameSession;
synchronized (session) {
if(session.getOfflineType() == ErrorCode.reloginCode){
return;
}
User user = UserManager.getUserInMem(session.getUid());
if(user == null){
return;
@ -358,9 +362,6 @@ public class ProtocolsManager implements ProtocolsAbstract {
KtEventUtils.onKtEvent(user, ParamEventBean.UserLoginOutEvent,1);
KtEventUtils.onKtEvent(user, ParamEventBean.UserLogin,1);
LOGGER.info("player={} offLine ...",user.getId());
if(session.getOfflineType() == ErrorCode.reloginCode){
return;
}
OnlineUserManager.userOffline(session.getUid());
if (session.getCtx() != null) {
GameMessageHandler.allChannels.remove(session.getCtx().channel());

View File

@ -36,7 +36,7 @@ public class RPCGmServerTask extends Thread{
@Override
public void run() {
try {
TServerSocket serverTransport = new TServerSocket(new InetSocketAddress(coreSettings.getIp(), coreSettings.getPort()+1));
TServerSocket serverTransport = new TServerSocket(new InetSocketAddress(coreSettings.getIp(), coreSettings.getGmport()));
LOGGER.info("run->coreip={},corePort={}", coreSettings.getIp(), coreSettings.getPort()+1);
TThreadPoolServer.Args trArgs = new TThreadPoolServer.Args(serverTransport);
TProcessor processor = new RPCRequestGMIFace.Processor<RPCRequestGMIFace.Iface>(new GmService());