def do_player_bindBankAccount(self): if ftlog.is_debug(): request = runhttp.getRequest() ftlog.debug('ErdayiHttpHandler.do_player_bindBankAccount', 'params=', runhttp.getDict()) ftlog.debug('ErdayiHttpHandler.do_player_bindBankAccount', 'request=', request) try: userId, err = self.checkBaseParams() if err: return err.pack() bankNo = runhttp.getParamStr('bankNo') if not bankNo: return PlayerControl.makeResponse(userId, ErrorEnum.ERR_BAD_PARAM) bankName = runhttp.getParamStr('bankName') if not bankName: return PlayerControl.makeResponse(userId, ErrorEnum.ERR_BAD_PARAM) bankAccount = runhttp.getParamStr('bankAccount') if not bankAccount: return PlayerControl.makeResponse(userId, ErrorEnum.ERR_BAD_PARAM) ftlog.debug('do_player_bindBankAccount', 'userId=', userId, 'bankNo=', bankNo, 'bankName=', bankName, 'bankAccount=', bankAccount) response = PlayerControl.bindBankAccount(userId, bankNo, bankName, bankAccount) return response.pack() except: ftlog.error() return PlayerControl.makeResponse(userId, ErrorEnum.ERR_UNKNOWN).pack()
def do_player_ex_getMasterInfo(self): try: userId, err = self.checkBaseParams() if err: return err.pack() ftlog.debug('do_player_ex_getMasterInfo', 'userId=', userId) response = PlayerControl.getMasterInfo(userId) return response.pack() except: ftlog.error() return PlayerControl.makeResponse(userId, ErrorEnum.ERR_UNKNOWN).pack()
def checkBaseParams(self): userId = runhttp.getParamInt('userId') if userId <= 0: return userId, PlayerControl.makeResponse(userId, ErrorEnum.ERR_BAD_USERID) # sign = runhttp.getParamStr('sign') # if not sign: # return userId, PlayerControl.makeResponse(userId, ErrorEnum.ERR_BAD_SIGN) authInfo = runhttp.getParamStr('authInfo') if not authInfo: return userId, PlayerControl.makeResponse(userId, ErrorEnum.ERR_BAD_AUTHINFO) return userId, None
def do_player_getBindMobile(self): try: userId, err = self.checkBaseParams() if err: return err.pack() ftlog.debug('do_player_ex_getBindMobile', 'userId=', userId) import poker.entity.dao.userdata as pkuserdata bindMobile = pkuserdata.getAttr(userId, 'bindMobile') response = PlayerControl.makeResponse() response.setResult('bindMobile', bindMobile) return response.pack() except: ftlog.error() return PlayerControl.makeResponse(userId, ErrorEnum.ERR_UNKNOWN).pack()
def do_player_getVCode(self): try: userId, err = self.checkBaseParams() if err: return err.pack() mobile = runhttp.getParamStr('mobile') if not mobile: return PlayerControl.makeResponse(userId, ErrorEnum.ERR_BAD_MOBILE) ftlog.debug('do_player_getVCode', 'userId=', userId, 'mobile=', mobile) response = PlayerControl.getVCode(userId, mobile) return response.pack() except: ftlog.error() return PlayerControl.makeResponse(userId, ErrorEnum.ERR_UNKNOWN).pack()
def matchCheck(cls, matchId): ''' 比赛报名 GET:match/check ''' params = { 'cp_id': str(PlayerControl.getConf('3rdapi.cpid')), 'match_id': str(matchId), } host = PlayerControl.getConf('3rdapi.host') response = HttpGetRequest.request(host, 'match/check', params) ftlog.debug('Report3rdInterface.matchCheck:', 'matchId=', matchId, 'params=', params, 'path=match/check' 'response=', response) response = Erdayi3rdInterface.translateResponse(response) return response.get('resp_code'), response.get('resp_msg')
def do_player_ex_reportEviewRound(self): try: userId, err = self.checkBaseParams() if err: return err.pack() ftlog.debug('do_player_ex_reportEviewRound', 'userId=', userId) from dizhu.erdayimatch.erdayi3api import Report3rdInterface roomId = runhttp.getParamStr('roomId') matchId = runhttp.getParamStr('matchId') tableId = runhttp.getParamStr('tableId') seatId = runhttp.getParamStr('seatId') groupId = runhttp.getParamStr('groupId') score = runhttp.getParamStr('score') mpscore = runhttp.getParamStr('mpscore') mpRatio = runhttp.getParamStr('mpRatio') mpRatioRank = runhttp.getParamStr('mpRatioRank') mpRatioScore = runhttp.getParamStr('mpRatioScore') cardType = runhttp.getParamStr('cardType') cardHole = runhttp.getParamStr('cardHole') Report3rdInterface.reportEviewRound(int(roomId), matchId, userId, tableId, seatId, groupId, score, mpscore, mpRatio, mpRatioRank, mpRatioScore, cardType, cardHole) return {'status':'ok'} except: ftlog.error() return PlayerControl.makeResponse(userId, ErrorEnum.ERR_UNKNOWN).pack()
def reportRankFinish(cls, roomId, matchId): ''' 名次上传完毕 match/ranks/sent ''' params = { 'cp_id': str(PlayerControl.getConf('3rdapi.cpid')), 'match_id': str(matchId), } model = ReportEntryModel(ReportEntryModel.ReportType_RankFinish, params) ReporterManager.getOrCreateReporter(roomId).enqueue(model)
def do_player_bindRealInfo(self): try: userId, err = self.checkBaseParams() if err: return err.pack() realname = runhttp.getParamStr('realname') if not realname or len(realname)<=0: return PlayerControl.makeResponse(userId, ErrorEnum.ERR_BAD_PARAM) idNo = runhttp.getParamStr('idNo') if not idNo: return PlayerControl.makeResponse(userId, ErrorEnum.ERR_BAD_PARAM) mobile = runhttp.getParamStr('mobile') if not mobile: return PlayerControl.makeResponse(userId, ErrorEnum.ERR_BAD_PARAM) vcode = runhttp.getParamInt('vcode') if not vcode: return PlayerControl.makeResponse(userId, ErrorEnum.ERR_BAD_VCODE) ftlog.debug('do_player_bindRealInfo', 'userId=', userId, 'realname=', realname, 'idNo=', idNo, 'mobile=', mobile, 'vcode=', vcode) response = PlayerControl.bindRealInfo(userId, realname, idNo, mobile, vcode) return response.pack() except: ftlog.error() return PlayerControl.makeResponse(userId, ErrorEnum.ERR_UNKNOWN).pack()
def matchReg(cls, roomId, matchId, userId, userName): ''' 比赛报名 match/reg ''' params = { 'cp_id': str(PlayerControl.getConf('3rdapi.cpid')), 'match_id': str(matchId), 'player_name': userName, 'player_id': str(userId) } model = ReportEntryModel(ReportEntryModel.ReportType_MatchReg, params) ReporterManager.getOrCreateReporter(roomId).enqueue(model)
def haiXuanLevelUpList(cls, roomId, matchId, promotion_match_id, promotion_player_list): ''' 海选赛晋级名单上报 :param matchId: 晋级用户所参加的海选赛的20位比赛ID :param promotion_match_id: 晋级用户所要晋级到的某一场B级赛(或B级以上赛事)的18位比赛ID :param promotion_player_list: 最大200条(超出200条需分两次调接口上报) GET: match/promotion/ranks/send :return: model = ReportEntryModel(ReportEntryModel.ReportType_Rank, params) ReporterManager.getOrCreateReporter(roomId).enqueue(model) ''' playerIdList = [] for playerInfo in promotion_player_list: if playerInfo.get('player_id'): playerIdList.append({"player_id": playerInfo.get('player_id')}) params = { 'cp_id': str(PlayerControl.getConf('3rdapi.cpid')), 'match_id': str(matchId), 'promotion_match_id': str(promotion_match_id), 'promotion_player_list': playerIdList } model = ReportEntryModel( ReportEntryModel.ReportType_HaiXuanLevelUpList, params) ReporterManager.getOrCreateReporter(roomId).enqueue(model) host = PlayerControl.getConf('3rdapi.host') response = HttpGetRequest.request(host, 'match/promotion/ranks/send', params) response = Erdayi3rdInterface.translateResponse(response) if ftlog.is_debug(): ftlog.debug('Report3rdInterface.haiXuanLevelUpList: matchId=', matchId, 'params=', params, 'path=match/promotion/ranks/send. response=', response) return response.get('resp_code'), response.get('resp_msg')
def reportEviewRound(cls, roomId, matchId, userId, tableId, cardPlayerId, cardGroupId, score, mpscore, mpRatio, mpRatioRank, mpRatioScore, cardType, cardHole=None): ''' 人机对局结果上报 match/eview/round/send ''' params = { 'cp_id': str(PlayerControl.getConf('3rdapi.cpid')), 'match_id': str(matchId), # 厂商4位+ 平台自定义10位+厂商自定义6位 'player_id': str(userId), 'card_player_id': str(cardPlayerId), # 纯数字, 从1开始顺序排列 'card_group_id': str(cardGroupId), # 纯数字, 从1开始顺序排列 'card_desk_id': str(tableId), # 纯数字, 从1开始顺序排列 'card_score': '%.4f' % score, # 纯数字,保留四位小数 'mp_score': '%.4f' % mpscore, # 纯数字,保留四位小数 'mp_ratio': '%.4f' % mpRatio, # 纯数字,保留四位小数 'mp_ratio_rank': str(mpRatioRank), # 纯数字(从1开始, 可重复) 'mp_ratio_score': '%.4f' % mpRatioScore, # 纯数字,保留四位小数 'card_type': ','.join(map(lambda x: str(x), cardType)), 'card_hole': ','.join(map(lambda x: str(x), cardHole)) if cardHole else cardHole, # (如果该条数据用户为庄家则字段必传,用户为防守方则不传)见数据字典 } model = ReportEntryModel(ReportEntryModel.ReportType_EviewRound, params) ReporterManager.getOrCreateReporter(roomId).enqueue(model)
def reportRank(cls, roomId, matchId, rankList): ''' 最终大排名结果上报 match/ranks/send ''' ranks = rankList params = { 'cp_id': str(PlayerControl.getConf('3rdapi.cpid')), 'match_id': str(matchId), 'ranks': ranks, # (最大200条)[{'player_id':0, 'ranking': 1, 'status':'0'}] } model = ReportEntryModel(ReportEntryModel.ReportType_Rank, params) ReporterManager.getOrCreateReporter(roomId).enqueue(model)
def do_player_ex_matchReg(self): try: userId, err = self.checkBaseParams() if err: return err.pack() ftlog.debug('do_player_ex_matchReg', 'userId=', userId) from dizhu.erdayimatch.erdayi3api import Report3rdInterface roomId = runhttp.getParamStr('roomId') matchId = runhttp.getParamStr('matchId') Report3rdInterface.matchReg(roomId, matchId, userId, 'luwei') return {'status':'ok'} except: ftlog.error() return PlayerControl.makeResponse(userId, ErrorEnum.ERR_UNKNOWN).pack()
def _report(self, model): host = PlayerControl.getConf('3rdapi.host') path = model.getUrl() params = model.params ftlog.debug('AsyncReporter._report', 'path=', path, 'params=', params) try: response = HttpPostRequest.request(host, path, params) response = Erdayi3rdInterface.translateResponse(response) except: ftlog.error('AsyncReporter._report', 'path=', path, 'params=', params) ftlog.debug('AsyncReporter._report', 'path=', path, 'params=', params, 'response=', response) return response.get('resp_code'), response.get('resp_msg')
def reportRoundRank(cls, roomId, matchId, stageIndex, rankList): ''' 移位排名结果上报 match/round/rank/send ''' rank_list = rankList params = { 'cp_id': str(PlayerControl.getConf('3rdapi.cpid')), 'match_id': str(matchId), # 厂商4位+ 平台自定义10位+厂商自定义6位 'round_id': str(stageIndex), # 纯数字, 从0开始顺序排列(每移位一次即+1) 'rank_list': rank_list, #(最大200条)[{'player_id':0, 'card_rank':1}, 'status':'0'] //'card_rank' 从1开始的纯数字(不可重复) } model = ReportEntryModel(ReportEntryModel.ReportType_RoundRank, params) ReporterManager.getOrCreateReporter(roomId).enqueue(model)
def check(self, gameId, userId, clientId, timestamp, **kwargs): mo = PlayerControl.getMasterInfo(userId) if not mo: return False masterinfo = mo.getResult('rating') ftlog.debug('UserConditionErdayiMasterscore.check', 'userId=', userId, 'mo.code=', mo.getResult('code'), 'masterinfo=', masterinfo) if not masterinfo: return False ok = True g = float(masterinfo.get('g', '0.0')) s = float(masterinfo.get('s', '0.0')) r = float(masterinfo.get('r', '0.0')) ftlog.debug('UserConditionErdayiMasterscore.check', 'userId=', userId, 'minScoreG=', self.minScoreG, 'maxScoreG=', self.maxScoreG, 'minScoreS=', self.minScoreS, 'maxScoreS=', self.maxScoreS, 'minScoreR=', self.minScoreR, 'maxScoreR=', self.maxScoreR, 'g=', g, 's=', s, 'r=', r) if (self.minScoreG != None) and self.minScoreG > g: ok = False if (self.maxScoreG != None) and self.maxScoreG < g: ok = False if (self.minScoreS != None) and self.minScoreS > s: ok = False if (self.maxScoreS != None) and self.maxScoreS < s: ok = False if (self.minScoreR != None) and self.minScoreR > r: ok = False if (self.maxScoreR != None) and self.maxScoreR < r: ok = False ftlog.debug('UserConditionErdayiMasterscore.check', 'userId=', userId, 'ok=', ok) return ok