def register(self, param, request, openid, idType, channel): gid = param['gameId'] l = [] if param['deviceId']: l.append(param['deviceId']) if param['deviceId2']: l.append(param['deviceId2']) if param['mac']: l.append(param['mac']) if param['imei']: l.append(param['imei']) if param['imsi']: l.append(param['imsi']) if l: deviceId = l[0] else: deviceId = 'DEVID' + str(Time.current_ms()) platform = param['platform'] # channel = param['channel'] nickName = param['devName'] if param.get('nickName'): nickName = param.get('nickName') dictInfo = { 'idType': idType, 'deviceId': deviceId, 'userName': openid, 'nick': nickName, 'createIp': request.getClientIP(), 'token': '', 'platform': platform, 'channel': channel, 'openid': openid } uid = Account.createUser(dictInfo) if uid is None: return None key = 'game.%d.info.hash' % gid pipe_args = [] if l: field = '%s.new.device.count' % channel pipe_args.append(field) pipe_args.append(1) field = '%s.new.user.count' % channel pipe_args.append(field) pipe_args.append(1) Context.RedisMix.hash_mincrby(key, *pipe_args) Context.Stat.mincr_daily_data(gid, *pipe_args) return uid
def catch_bounty_fish(self, goal, fish_type, multi): if fish_type not in self.bounty_task: self.bounty_task[fish_type] = 1 else: self.bounty_task[fish_type] += 1 if 'count' not in self.bounty_task: self.bounty_task['count'] = 1 else: self.bounty_task['count'] += 1 self.bounty_task['ts'] = Time.current_ms() for _t, _cnt in goal.iteritems(): if _cnt > self.bounty_task.get(_t, 0): return if multi not in self.bounty_task: self.bounty_task['multi'] = multi
def loginByGuest(self, mi, request): param = self.getParam(mi, 'devName') l = [] if param['deviceId']: l.append(param['deviceId']) if param['deviceId2']: l.append(param['deviceId2']) if param['mac']: l.append(param['mac']) if param['imei']: l.append(param['imei']) if param['imsi']: l.append(param['imsi']) gid = param['gameId'] idType = Const.IDTYPE_GUEST for dev in l: uid = Account.getUserIDByUserName(dev, idType) if uid: break else: if l: deviceId = l[0] else: deviceId = 'DEVID' + str(Time.current_ms()) platform = param['platform'] channel = param['channel'] clientId = param['clientId'] dictInfo = { 'idType': idType, 'deviceId': deviceId, 'userName': deviceId, 'nick': param['devName'], 'createIp': request.getClientIP(), 'token': '', 'platform': platform, 'channel': channel, 'clientId': clientId } Context.Log.info("dictInfo::", dictInfo) uid = Account.createUser(dictInfo) nick_name = "游客" + str(uid) Account.updateUserInfo(uid, nick=nick_name) if uid is None: return MsgPack.Error(0, Const.E_BAD_REDIS, Const.ES_BAD_REDIS) key = 'game.%d.info.hash' % gid pipe_args = [] if l: field = '%s.new.device.count' % channel pipe_args.append(field) pipe_args.append(1) field = '%s.new.user.count' % channel pipe_args.append(field) pipe_args.append(1) Context.RedisMix.hash_mincrby(key, *pipe_args) Context.Stat.mincr_daily_data(gid, *pipe_args) c_key = 'client:%s' % (clientId) Context.RedisMix.set_add(c_key) userInfo = Account.getUserInfo(uid) return self.getLoginInfo(request, 0, uid, gid, param, userInfo, True)