绑定手机号
parent
b9f2d0d096
commit
716567ab68
|
@ -0,0 +1,61 @@
|
|||
package com.ljsd.jieling.config;
|
||||
|
||||
import com.ljsd.jieling.logic.STableManager;
|
||||
import com.ljsd.jieling.logic.Table;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Table(name = "SpecialConfig")
|
||||
public class SSpecialConfig implements BaseConfig {
|
||||
|
||||
private static Map<String, String> enumers;
|
||||
private int id;
|
||||
|
||||
private String key;
|
||||
|
||||
private String value;
|
||||
|
||||
public static final String PHONE_BINDING = "Phone_Binding";
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
||||
Map<Integer, SSpecialConfig> config = STableManager.getConfig(SSpecialConfig.class);
|
||||
Map<String, String> stringStringMap = new ConcurrentHashMap<>();
|
||||
for (Map.Entry<Integer, SSpecialConfig> entry : config.entrySet()) {
|
||||
SSpecialConfig sSpecialConfig = entry.getValue();
|
||||
stringStringMap.put(sSpecialConfig.getKey(), sSpecialConfig.getValue());
|
||||
}
|
||||
enumers = stringStringMap;
|
||||
}
|
||||
|
||||
|
||||
public static String getStringValue(String key) {
|
||||
String value = enumers.get(key);
|
||||
return value;
|
||||
}
|
||||
|
||||
public static int getIntegerValue(String key) {
|
||||
String value = enumers.get(key);
|
||||
if(value==null){
|
||||
return -1;
|
||||
}
|
||||
return Integer.valueOf(value);
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -77,6 +77,7 @@ public interface BIReason {
|
|||
int UPHERO_DECOMPOS_HERO_REWARD= 47 ;//进阶妖灵师返还奖励
|
||||
|
||||
int GM_CHANGENAME = 48; // gm改名赠送
|
||||
int BIND_PHONE = 49; // 修改手机号
|
||||
|
||||
//道具消耗原因 1000开头
|
||||
int ADVENTURE_UPLEVEL_CONSUME = 1000; //秘境升级
|
||||
|
|
|
@ -93,6 +93,9 @@ public class GetPlayerInfoHandler extends BaseHandler{
|
|||
.setHadTakeDailyBox(playerInfoManager.getHadTakeDailyBoxVip())
|
||||
.setHadTakeLevelBox(playerInfoManager.getHadTakeLevelBoxVip())
|
||||
.setVipLevel(playerInfoManager.getVipLevel()).build();
|
||||
CommonProto.PlayerBindPhone playerBindPhone = CommonProto.PlayerBindPhone.newBuilder()
|
||||
.setPhoneNum(user.getPlayerInfoManager().getPhoneBindInfo().getPhoneNum())
|
||||
.setState(user.getPlayerInfoManager().getPhoneBindInfo().getState()).build();
|
||||
RechargeInfo rechargeInfo = playerInfoManager.getRechargeInfo();
|
||||
Map<Integer, Integer> totalCountMap = user.getHeroManager().getTotalCount();
|
||||
int alreadyCount =0;
|
||||
|
@ -141,6 +144,7 @@ public class GetPlayerInfoHandler extends BaseHandler{
|
|||
.setFirstTenth(user.getHeroManager().getFirstTenth())
|
||||
.setIsDayFirst(playerInfoManager.getIsdayFirst())
|
||||
.setEndInfo(endless)
|
||||
.setPlayerBindPhone(playerBindPhone)
|
||||
.build();
|
||||
try {
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_PLAYERINFO_RESPONSE_VALUE, getPlayerInfoResponse, true);
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package com.ljsd.jieling.handler.phone;
|
||||
|
||||
import com.ljsd.jieling.config.SSpecialConfig;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
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 com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class GetPhoneRewardRequestHandler extends BaseHandler<PlayerInfoProto.GetPhoneRewardRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.GET_PHONE_REWARD_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, PlayerInfoProto.GetPhoneRewardRequest proto) throws Exception {
|
||||
|
||||
int reward = SSpecialConfig.getIntegerValue(SSpecialConfig.PHONE_BINDING);
|
||||
if (-1 == reward) {
|
||||
MessageUtil.sendErrorResponse(iSession, 0, MessageTypeProto.MessageType.GET_PHONE_REWARD_RESPONSE_VALUE, "手机号不合法");
|
||||
}
|
||||
|
||||
int[] rewardIds = new int[1];
|
||||
rewardIds[0] = reward;
|
||||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user,rewardIds, 1, 1, BIReason.BIND_PHONE);
|
||||
|
||||
PlayerInfoProto.GetPhoneRewardResponse.Builder builder = PlayerInfoProto.GetPhoneRewardResponse.newBuilder().setDrop(drop);
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_PHONE_REWARD_RESPONSE_VALUE,builder.build() , true);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.ljsd.jieling.handler.phone;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class UpdatePhoneinfoRequestHandler extends BaseHandler<PlayerInfoProto.UpdatePhoneinfoRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.UPDATE_PHONE_INFO_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, PlayerInfoProto.UpdatePhoneinfoRequest proto) throws Exception {
|
||||
|
||||
if(!proto.getPhoneNum().matches("(1[3-9])\\d{9}")){
|
||||
MessageUtil.sendErrorResponse(iSession, 0, MessageTypeProto.MessageType.UPDATE_PHONE_INFO_RESPONSE_VALUE,"手机号不合法");
|
||||
return;
|
||||
}
|
||||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
user.getPlayerInfoManager().getPhoneBindInfo().setPhoneNum(proto.getPhoneNum());
|
||||
if(user.getPlayerInfoManager().getPhoneBindInfo().getState()==0){
|
||||
user.getPlayerInfoManager().getPhoneBindInfo().setState(1);
|
||||
}
|
||||
PlayerInfoProto.UpdatePhoneinfoResponse.Builder builder = PlayerInfoProto.UpdatePhoneinfoResponse.newBuilder().setState( user.getPlayerInfoManager().getPhoneBindInfo().getState());
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.UPDATE_PHONE_INFO_RESPONSE_VALUE,builder.build() , true);
|
||||
|
||||
}
|
||||
}
|
|
@ -264,6 +264,7 @@ public class GlobalDataManaager {
|
|||
//活动刷新
|
||||
ActivityLogic.getInstance().flushEveryDay(user,fBuilder);
|
||||
PlayerLogic.getInstance().vipflushEveryDay(user,fBuilder);
|
||||
PlayerLogic.getInstance().flushUserdataEvery(user,fBuilder);
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.DAILY_REFRESH,0);
|
||||
FriendLogic.getInstance().refreshState(session);
|
||||
int sendDays = user.getPlayerInfoManager().getSendDays();
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
|
||||
public class PhoneBindInfo extends MongoBase {
|
||||
private String phoneNum ;
|
||||
private int state ;//本月绑定状态 0 未绑定 1已绑定未领奖 2已领奖
|
||||
|
||||
public String getPhoneNum() {
|
||||
return phoneNum;
|
||||
}
|
||||
|
||||
public void setPhoneNum(String phoneNum) {
|
||||
updateString("phoneNum",phoneNum);
|
||||
this.phoneNum = phoneNum;
|
||||
}
|
||||
|
||||
public int getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(int state) {
|
||||
updateString("state",state);
|
||||
this.state = state;
|
||||
}
|
||||
}
|
|
@ -84,7 +84,7 @@ public class PlayerManager extends MongoBase {
|
|||
|
||||
private int silence;//是否被禁言0为可发言,1为不可发言
|
||||
|
||||
private Map<Integer,Long> onlineTimeOfDay = new HashMap<>(); // 20190808
|
||||
private PhoneBindInfo phoneBindInfo;
|
||||
|
||||
public PlayerManager(){
|
||||
this.setRootCollection(User._COLLECTION_NAME);
|
||||
|
@ -440,7 +440,6 @@ public class PlayerManager extends MongoBase {
|
|||
|
||||
public void addOnlineTime(long onlineTime) {
|
||||
this.onlineTime += onlineTime;
|
||||
//setOnlineTimeOfDay(onlineTime);
|
||||
updateString("onlineTime", this.onlineTime);
|
||||
}
|
||||
|
||||
|
@ -462,13 +461,6 @@ public class PlayerManager extends MongoBase {
|
|||
this.sendDays = sendDays;
|
||||
}
|
||||
|
||||
private void setOnlineTimeOfDay(long time) {
|
||||
int day= Integer.valueOf(TimeUtils.getTimeStampYMD(System.currentTimeMillis()));
|
||||
this.onlineTimeOfDay.put(day,this.onlineTimeOfDay.getOrDefault(day,0L)+time);
|
||||
updateString("onlineTimeOfDay", this.onlineTimeOfDay);
|
||||
}
|
||||
|
||||
|
||||
public String getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
@ -478,10 +470,6 @@ public class PlayerManager extends MongoBase {
|
|||
this.channel = channel;
|
||||
}
|
||||
|
||||
public Map<Integer, Long> getOnlineTimeOfDay() {
|
||||
return onlineTimeOfDay;
|
||||
}
|
||||
|
||||
public int getSilence() {
|
||||
return silence;
|
||||
}
|
||||
|
@ -490,4 +478,13 @@ public class PlayerManager extends MongoBase {
|
|||
this.silence = silence;
|
||||
updateString("silence",silence);
|
||||
}
|
||||
|
||||
public PhoneBindInfo getPhoneBindInfo() {
|
||||
return phoneBindInfo;
|
||||
}
|
||||
|
||||
public void setPhoneBindInfo(PhoneBindInfo phoneBindInfo) {
|
||||
updateString("phoneBindInfo",phoneBindInfo);
|
||||
this.phoneBindInfo = phoneBindInfo;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ public class UserManager {
|
|||
playerManager.setSendDays(1);
|
||||
playerManager.updateVipInfo(user,0);
|
||||
playerManager.setRechargeInfo(new RechargeInfo());
|
||||
playerManager.setPhoneBindInfo(new PhoneBindInfo());
|
||||
playerManager.setChannel(channel);
|
||||
playerManager.setHeadFrame(SGameSetting.getGameSetting().getDefaultPicture());
|
||||
SPlayerLevelConfig sPlayerLevelConfig = SPlayerLevelConfig.getsPlayerLevelConfigMap().get(1);
|
||||
|
|
|
@ -333,6 +333,19 @@ public class PlayerLogic {
|
|||
|
||||
}
|
||||
|
||||
public void flushUserdataEvery(User user, PlayerInfoProto.FivePlayerUpdateIndication.Builder fBuilder) throws Exception {
|
||||
|
||||
//跟新签到天数
|
||||
if (!TimeUtils.isSameMonthFiveWithNow(user.getPlayerInfoManager().getOffLineTime())) {
|
||||
user.getPlayerInfoManager().getPhoneBindInfo().setState(0);
|
||||
}
|
||||
if(null!=fBuilder){
|
||||
PhoneBindInfo phoneBindInfo = user.getPlayerInfoManager().getPhoneBindInfo();
|
||||
fBuilder.setPlayerBindPhone(CommonProto.PlayerBindPhone.newBuilder().setPhoneNum(phoneBindInfo.getPhoneNum()).setState(phoneBindInfo.getState()).build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void modifyHeadFrame(ISession session, int frameId,MessageTypeProto.MessageType messageType) throws Exception {
|
||||
LOGGER.info("头像框id{}",frameId);
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
|
|
|
@ -40,7 +40,7 @@ public class RPCServerTask extends Thread{
|
|||
trArgs.processor(processor);
|
||||
TBinaryProtocol.Factory proFactory = new TBinaryProtocol.Factory(true, true);
|
||||
trArgs.protocolFactory(proFactory);
|
||||
trArgs.maxWorkerThreads(4096);
|
||||
trArgs.maxWorkerThreads(16);
|
||||
LOGGER.info("run->RPC services is starting.");
|
||||
final TServer server = new TThreadPoolServer(trArgs);
|
||||
while (true) {
|
||||
|
|
Loading…
Reference in New Issue