def _incrUserDatasLimit(userId, field, value, lowLimit, highLimit, chipNotEnoughOpMode, dataKey=None): from poker.entity.dao import sessiondata _, numberClientId = sessiondata.getClientIdNum(userId, None) appId = sessiondata.getGameId(userId) if dataKey == None: dataKey = UserDataSchema.mkey(userId) trueDetal, finalCount, fixCount = daobase.executeUserLua(userId, user_scripts.MAIN_INCR_CHIP_LUA_SCRIPT, 6, value, lowLimit, highLimit, chipNotEnoughOpMode, dataKey, field) if dataKey == UserDataSchema.mkey(userId): if _CACHE_USER_ENABLE: _cacheUser.replace_group_dict_data(userId, dataKey, field, finalCount) return trueDetal, finalCount, fixCount, appId, numberClientId
def _setUserDatas(userId, datas): dataKey = UserDataSchema.mkey(userId) params = UserDataSchema.paramsDict2List(datas) ret = daobase.executeUserCmd(userId, 'HMSET', dataKey, *params) if _CACHE_USER_ENABLE: _cacheUser.update_group_dict_data(userId, dataKey, datas) return ret
def _getSessionDataRedis(userId, dataKey): values = daobase.executeUserCmd(userId, 'HMGET', dataKey, *UserSessionSchema.FIELD_GROUP_SESSION) if values[0] == None: # 补丁, 数据上线期间, 有些用户还没有建立session数据, 重主数据中获取 values = daobase.executeUserCmd(userId, 'HMGET', UserDataSchema.mkey(userId), *UserDataSchema.FIELD_GROUP_SESSION) datas = UserSessionSchema.checkDataDict(UserSessionSchema.FIELD_GROUP_SESSION, values, None) return datas
def _setUserDatasForce(userId, datas): dataKey = UserDataSchema.mkey(userId) params = UserDataSchema.paramsDict2List(datas, 0) ret = daobase.executeUserLua(userId, user_scripts.MAIN_SET_HASH_DATA_FORCE, 2, dataKey, json.dumps(params)) if _CACHE_USER_ENABLE: _cacheUser.update_group_dict_data(userId, dataKey, datas) return ret
def _getUserDatas(userId, fieldList): dataKey = UserDataSchema.mkey(userId) if _CACHE_USER_ENABLE: alldata = _cacheUser(userId, dataKey) else: alldata = _getUserDataRedis(userId, dataKey) vals = [] for f in fieldList: vals.append(alldata.get(f)) return vals
def _setTableChipToRange(userId, gameid, _min, _max, eventId, intEventParam, clientId, tableId, rhashkey, rfield): from poker.entity.dao import sessiondata _, numberClientId = sessiondata.getClientIdNum(userId, None) appId = sessiondata.getGameId(userId) tdelta, tfinal, tfixed, delta, final, fixed = daobase.executeUserLua(userId, user_scripts.MAIN_MOVE_CHIP_TO_TABLE_LUA_SCRIPT, 6, userId, gameid, _min, _max, rhashkey, rfield) if _CACHE_USER_ENABLE: _cacheUser.replace_group_dict_data(userId, UserDataSchema.mkey(userId), UserDataSchema.CHIP, final) # TODO 替换GAME DATA中的金币数据值 ftlog.debug('dbuser->_setTableChipToRange', userId, gameid, _min, _max, eventId, intEventParam, clientId, tableId, rhashkey, 'result->', tdelta, tfinal, tfixed, delta, final, fixed) return tdelta, tfinal, tfixed, delta, final, fixed, appId, numberClientId
def _setSessionDatas(userId, datas): # TODO 补充user表中的几个数据至用户的session中sessionAppId, sessionDevId,city_code atts = [ UserDataSchema.SESSION_APPID, UserDataSchema.SESSION_DEVID, UserDataSchema.SESSION_CITY_CODE, UserDataSchema.SESSION_IP ] values = daobase.executeUserCmd(userId, 'HMGET', UserDataSchema.mkey(userId), *atts) values = UserDataSchema.checkDataList(atts, values, None) if not UserSessionSchema.APPID in datas: datas[UserSessionSchema.APPID] = values[0] if not UserSessionSchema.DEVICEID in datas: datas[UserSessionSchema.DEVICEID] = values[1] if not UserSessionSchema.CITYCODE in datas: datas[UserSessionSchema.CITYCODE] = values[2] datas[UserSessionSchema.IPADDRESS] = values[ 3] # TODO 加了阿里云代理后,CO服务的带的IP都是阿里的IP地址,只能在重SDK的数据中再取一次 dataKey = UserSessionSchema.mkey(userId) params = UserSessionSchema.paramsDict2List(datas) ret = daobase.sendUserCmd(userId, 'HMSET', dataKey, *params) return ret
def _incrUserDatas(userId, field, value): dataKey = UserDataSchema.mkey(userId) ret = daobase.executeUserCmd(userId, 'HINCRBY', dataKey, field, value) if _CACHE_USER_ENABLE: _cacheUser.incrby_group_dict_data(userId, dataKey, field, value) return ret
def _delUserDatas(userId, datas): dataKey = UserDataSchema.mkey(userId) ret = daobase.executeUserCmd(userId, 'HDEL', dataKey, *datas.keys()) if _CACHE_USER_ENABLE: _cacheUser.remove_group_dict_data(userId, dataKey, datas) return ret
def _setUserDatas(userId, datas): dataKey = UserDataSchema.mkey(userId) params = UserDataSchema.paramsDict2List(datas) ret = daobase.executeUserCmd(userId, 'HMSET', dataKey, *params) return ret
def _getUserDatas(userId, fieldList): dataKey = UserDataSchema.mkey(userId) values = daobase.executeUserCmd(userId, 'HMGET', dataKey, *fieldList) values = UserDataSchema.checkDataList(fieldList, values, None) ftlog.debug('_getUserDatas->', userId, fieldList, values) return values
def _incrUserDatas(userId, field, value): dataKey = UserDataSchema.mkey(userId) ret = daobase.executeUserCmd(userId, 'HINCRBY', dataKey, field, value) return ret
def _delUserDatas(userId, datas): dataKey = UserDataSchema.mkey(userId) ret = daobase.executeUserCmd(userId, 'HDEL', dataKey, *datas.keys()) return ret
def _setUserDatasForce(userId, datas): dataKey = UserDataSchema.mkey(userId) params = UserDataSchema.paramsDict2List(datas, 0) ret = daobase.executeUserLua(userId, user_scripts.MAIN_SET_HASH_DATA_FORCE, 2, dataKey, json.dumps(params)) return ret