process openId

back_recharge
wangyuan 2019-08-21 20:31:29 +08:00
parent 2b78ebf9ea
commit 7b988d70c2
3 changed files with 24 additions and 7 deletions

View File

@ -73,8 +73,12 @@ public class LoginRequestHandler extends BaseHandler {
//登陆注册入内存
User user = UserManager.userLogin(userId,loginRequest.getOpenId());
user.getPlayerInfoManager().setOpenId(loginRequest.getOpenId());
String openIdFront = loginRequest.getOpenId();
String[] split = openIdFront.split("\\.");
String openId = split[0];
String chanel = split[1];
User user = UserManager.userLogin(userId,openId,chanel);
String newToken = UserManager.getNewToken(userId);

View File

@ -80,6 +80,8 @@ public class PlayerManager extends MongoBase {
private int sendDays;
private String channel;
private Map<Integer,Long> onlineTimeOfDay = new HashMap<>(); // 20190808
public PlayerManager(){
@ -464,6 +466,16 @@ public class PlayerManager extends MongoBase {
updateString("onlineTimeOfDay", this.onlineTimeOfDay);
}
public String getChannel() {
return channel;
}
public void setChannel(String channel) {
updateString("channel", this.channel);
this.channel = channel;
}
public Map<Integer, Long> getOnlineTimeOfDay() {
return onlineTimeOfDay;
}

View File

@ -31,12 +31,12 @@ public class UserManager {
return userMap.containsKey(uid);
}
public static User userLogin(int uid,String openId) throws Exception {
public static User userLogin(int uid,String openId,String channel) throws Exception {
User user = null;
if (!UserManager.isUserExist(uid)){
user = MongoUtil.getInstence().getMyMongoTemplate().findById(User.getCollectionName(), uid, User.class);
if (user == null) {
user = registerUser(uid,openId);
user = registerUser(uid,openId,channel);
}
UserManager.addUser(user);
}else{
@ -46,16 +46,16 @@ public class UserManager {
}
private static User registerUser(int uid,String openId) throws Exception {
private static User registerUser(int uid,String openId,String channel) throws Exception {
User user = new User(uid);
initPlayer(user,openId);
initPlayer(user,openId,channel);
UserManager.addUser(user);
MongoUtil.getInstence().getMyMongoTemplate().save(user);
PlayerLogic.getInstance().sendTestWelfareMail(user,1,1);
return user;
}
private static void initPlayer(User user,String openId) throws Exception {
private static void initPlayer(User user,String openId,String channel) throws Exception {
SGameSetting gameSetting = SGameSetting.getGameSetting();
PlayerManager playerManager = user.getPlayerInfoManager();
long now = TimeUtils.now();
@ -70,6 +70,7 @@ public class UserManager {
playerManager.setSendDays(1);
playerManager.updateVipInfo(user,0);
playerManager.setRechargeInfo(new RechargeInfo());
playerManager.setChannel(channel);
playerManager.setHeadFrame(SGameSetting.getGameSetting().getDefaultPicture());
SPlayerLevelConfig sPlayerLevelConfig = SPlayerLevelConfig.getsPlayerLevelConfigMap().get(1);
playerManager.setMaxStamina(sPlayerLevelConfig.getMaxEnergy());