예제 #1
0
def handleHttp(dict_param:dict):
    strMatchId = dict_param["strMatchId"]
    strGuessId = dict_param["strGuessId"]

    objMatchData, objMatchDataLock = yield from classDataBaseMgr.getInstance().getMatchDataByLock(strMatchId)
    if objMatchData != None:

        #记录要删除的场次id array
        iCheckDeleteRound = -1
        if strGuessId in objMatchData.arrayGuess:
            objMatchData.arrayGuess.remove(strGuessId)

        for var_round,var_list_guess in objMatchData.dictGuess.items():
            if strGuessId in var_list_guess:
                var_list_guess.remove(strGuessId)
                iCheckDeleteRound = var_round
                break

        if iCheckDeleteRound != -1:
            if len(objMatchData.dictGuess[iCheckDeleteRound]) <= 0:
                #如果这个对应的round 没有了,则删除这个round的key,免得这个客户端数据为空的值
                objMatchData.dictGuess.pop(iCheckDeleteRound)

        yield from classDataBaseMgr.getInstance().delGuessData(strGuessId)
        yield from classDataBaseMgr.getInstance().setMatchDataByLock(objMatchData,objMatchDataLock)

        #如果删错玩法,也看看是否已经派往完奖励
        if len(objMatchData.arrayAwardGuess) > 0:
            if len(objMatchData.arrayAwardGuess) == len(objMatchData.arrayGuess) and objMatchData.iMatchState <= 0:
                yield from classDataBaseMgr.getInstance().setMatchResultFinish(objMatchData.strMatchType,strMatchId,timeHelp.getNow())

    else:
        raise exceptionLogic(errorLogic.match_data_not_found)
예제 #2
0
def handleHttp(dict_param: dict):

    strMatchId = dict_param["strMatchId"]

    objMatchData, objMatchDataLock = yield from classDataBaseMgr.getInstance(
    ).getMatchDataByLock(strMatchId)
    if objMatchData is None:
        # TODO release lock
        raise exceptionLogic(errorLogic.guess_data_not_found)

    objMatchData.iAwardFlag = 1
    yield from classDataBaseMgr.getInstance().setMatchDataByLock(
        objMatchData, objMatchDataLock)

    yield from classDataBaseMgr.getInstance().delMatchAwardedList(
        objMatchData.strMatchId)
    yield from classDataBaseMgr.getInstance().addMatchCancelAwardedList(
        objMatchData.strMatchId)

    #全部奖励
    msgHead = dataHeaderDefine.classResultHead()
    msgHead.strMsgId = result_msgId.msg_cancel_award
    msgBody = CancelAwardReq()
    msgBody.strMatchId = strMatchId
    #msgBody.strGuessId = strGuessId
    #msgBody.strDictKey = var_key
    msgBody.iWinOrLose = objMatchData.iWinOrLose
    msgBody.iCancelCoin = objMatchData.iAwardFlag
    msgBody.iCancelNum = objMatchData.iAwardNum
    yield from classPubMgr.getInstance("resultPub").publish(msgHead, msgBody)
예제 #3
0
def handleHttp(dict_param: dict):

    strGuessId = dict_param['strGuessId']
    iCursor = int(dict_param['iCursor'])
    iLen = yield from classDataBaseMgr.getInstance().getCurrentGuessMemberLen(
        strGuessId)
    if iLen > 15:
        iCursor = iLen - 15

    listCurrent = yield from classDataBaseMgr.getInstance(
    ).getCurrentGuessMember(strGuessId, iCursor, iLen)
    objResp = gmProtocol.classGmRecentPlayerData()
    objResp.iCursor = iLen
    if len(listCurrent) > 0:
        objGuessData = yield from classDataBaseMgr.getInstance().getGuessData(
            strGuessId)

        objResp.arrChooseName = list(objGuessData.dictCTR.keys())
        for var_member in listCurrent:
            objNewData = gmProtocol.classGmRecentBetItem()
            objNewData.strAccountId = var_member["id"]
            objNewData.strChooseId = var_member["type"]
            objNewData.iBetNum = var_member["num"]
            objResp.arrCurrentBetInfo.append(objNewData)
    #print(classJsonDump.dumps(objResp))
    return classJsonDump.dumps(objResp)
예제 #4
0
def __initLogicDataMgr():
    classSqlBaseMgr()
    classSqlBaseMgr(__instanceName__='probet_oss')
    if procVariable.debug:
        yield from classSqlBaseMgr.getInstance(instanceName='probet_oss').connetSql(gmweb_config.mysqlAddress_debug, 3306,
                                                                                  'root',gmweb_config.mysqlPwd_debug,'probet_oss',
                                                                                  g_obj_loop,'utf8')

        yield from classSqlBaseMgr.getInstance().connetSql(gmweb_config.mysqlAddress_debug, 3306,
                                                           'root', gmweb_config.mysqlPwd_debug, 'probet_data',
                                                           g_obj_loop)
        classDataBaseMgr(
            gmweb_config.redis_config_debug, g_obj_loop,procVariable.debug,  1, 1)
    else:

        yield from classSqlBaseMgr.getInstance(instanceName='probet_oss').connetSql(gmweb_config.mysqlAddress, 3306,
                                                                                  'root', gmweb_config.mysqlPwd,
                                                                                  'probet_oss',
                                                                                  g_obj_loop, 'utf8')

        yield from classSqlBaseMgr.getInstance().connetSql(gmweb_config.mysqlAddress, 3306,
                                                           'root', gmweb_config.mysqlPwd, 'probet_data',
                                                           g_obj_loop)
        classDataBaseMgr(gmweb_config.redis_config, g_obj_loop,procVariable.debug, 1,1)

    yield from classDataBaseMgr.getInstance().connectRedis()
    yield from classDataBaseMgr.getInstance().loadRedisLuaScript()
예제 #5
0
def handleHttp(dict_param: dict):

    strProjectName = dict_param['strProjectName']
    iPageSize = int(dict_param['iPageSize'])
    iPageNum = int(dict_param['iPageNum'])
    iPageNum -= 1
    if strProjectName == 'all':
        pass
    else:
        if not (strProjectName in gmProtocol.gameType):
            raise exceptionLogic(errorLogic.projectNameNotValid)

    iBeginIndex = iPageNum * iPageSize
    iEndIndex = iBeginIndex + iPageSize

    listMatchIds = yield from classDataBaseMgr.getInstance(
    ).getFinishResultMatch(iBeginIndex, iEndIndex)
    listMatchData = yield from classDataBaseMgr.getInstance().getMatchDataList(
        listMatchIds)
    objResp = gmProtocol.classGmMatchTotal()
    objResp.iTotalNum = yield from classDataBaseMgr.getInstance(
    ).getRecentMatchFinishDataCount()

    if len(listMatchData) != len(listMatchData):
        raise exceptionLogic(errorLogic.sys_unknow_error)

    for iIndex in range(0, len(listMatchData)):
        matchData = listMatchData[iIndex]

        objNewData = gmProtocol.classGmMatchData()
        objNewData.strProjectName = matchData.strMatchType
        objNewData.strMatchId = matchData.strMatchId
        objNewData.iGameState = matchData.iMatchState
        objNewData.strActivityName = matchData.strMatchName
        objNewData.strGameStartTime = timeHelp.timestamp2Str(
            matchData.iMatchStartTimestamp)
        objNewData.strTeam1Name = matchData.strTeamAName
        objNewData.strTeam2Name = matchData.strTeamBName
        objNewData.strTeam1Logo = matchData.strTeamALogoUrl
        objNewData.strTeam2Logo = matchData.strTeamBLogoUrl
        objNewData.iMatchRoundNum = matchData.iMatchRoundNum
        objNewData.iHideFlag = matchData.iHideFlag
        objNewData.strTeamAId = matchData.strTeamAId
        objNewData.strTeamBId = matchData.strTeamBId
        objNewData.iTeamAScore = matchData.iTeamAScore
        objNewData.iTeamBScore = matchData.iTeamBScore
        objNewData.iSupportA = matchData.iSupportA
        objNewData.iSupportB = matchData.iSupportB

        objNewData.iAwardFlag = matchData.iAwardFlag
        objNewData.iAwardNum = matchData.iAwardNum
        objNewData.iAwardType = matchData.iAwardType
        objNewData.iWinOrLose = matchData.iWinOrLose
        objNewData.iCancelResultFlag = matchData.iCancelResultFlag
        objNewData.iCancelResultBeginTime = matchData.iCancelResultBeginTime
        objNewData.iCancelResultEndTime = matchData.iCancelResultEndTime

        objResp.arrMatchData.append(objNewData)

    return classJsonDump.dumps(objResp)
예제 #6
0
def handleHttp(dict_param: dict):
    """更改密码"""
    objRsp = cResp()

    strOldPwd = dict_param.get("oldPwd", "")
    Newpwd = dict_param.get("newPwd", "")
    Newpwd2 = dict_param.get("newPwd2", "")
    strAccountId = dict_param.get("accountId", "")
    if not all([strOldPwd, Newpwd, Newpwd2]):
        raise exceptionLogic(errorLogic.client_param_invalid)
    if precompile.Password.search(Newpwd) is None:
        raise exceptionLogic(errorLogic.player_pwd_length_out_of_range)
    objPlayerData, objLock = yield from classDataBaseMgr.getInstance(
    ).getPlayerDataByLock(strAccountId)
    strPwd = PwdEncrypt().create_md5(strOldPwd)
    strNewpwd = PwdEncrypt().create_md5(Newpwd)

    if strPwd != objPlayerData.strPassword:
        raise exceptionLogic(errorLogic.login_only_old_pwd_not_valid)

    if objPlayerData.strPassword == strNewpwd:
        raise exceptionLogic(errorLogic.login_pwd_same_old)
    if Newpwd != Newpwd2:
        raise exceptionLogic(errorLogic.player_pwd_pwd2_not_same)
    else:
        objPlayerData.strPassword = strNewpwd
        yield from classDataBaseMgr.getInstance().setPlayerDataByLock(
            objPlayerData, objLock)

    return classJsonDump.dumps(objRsp)
예제 #7
0
def handleHttp(dict_param: dict):

    strGuessId = dict_param['strGuessId']
    iPage = dict_param["iPage"]
    iNum = dict_param["iNum"]

    iBeginIndex = iPage * iNum
    iEndIndex = iBeginIndex + iNum

    objResp = gmProtocol.classGmAllPlayerData()
    objGuessData = yield from classDataBaseMgr.getInstance(
    ).getGuessDataByLock(strGuessId)
    objResp.arrChooseName = list(objGuessData.dictCTR.keys())
    objResp.iTotal = yield from classDataBaseMgr.getInstance(
    ).getCurrentGuessMemberLen(strGuessId)
    listCurrent = yield from classDataBaseMgr.getInstance(
    ).getCurrentGuessMember(strGuessId, iBeginIndex, iEndIndex)

    if len(listCurrent) > 0:

        for var_member in listCurrent:
            objNewData = gmProtocol.classGmRecentBetItem()
            objNewData.strAccountId = var_member["id"]
            objNewData.strChooseId = var_member["type"]
            objNewData.iBetNum = var_member["num"]
            objResp.arrCurrentBetInfo.append(objNewData)

    return classJsonDump.dumps(objResp)
def handleCancelResultGuessByUId(objHead:dataHeaderDefine.classResultHead,objDataCenterReq,*args,**kwargs):
    strMatchId = objDataCenterReq.strMatchId
    strGuessId = objDataCenterReq.strGuessId

    logging.getLogger("result").info("matchId[{}] guessId[{}] cancel result by guessUId".format(strMatchId,strGuessId))

    objMatchData = yield from classDataBaseMgr.getInstance().getMatchData(strMatchId)
    if objMatchData is None:
        logging.getLogger('result').error("result match data not found [{}]".format(strMatchId))
        return

    objGuessData = yield from classDataBaseMgr.getInstance().getGuessData(strGuessId)
    if objGuessData is None:
        logging.getLogger('result').error("result guess data not found [{}]".format(strGuessId))
        return

    boolLoopFlag = True

    while boolLoopFlag:

        try:
            strGuessUId = yield from classDataBaseMgr.getInstance().getMatchCancelResultGuessUIds(strGuessId)
            if strGuessUId is None:
                logging.getLogger("result").error("guessId:[{}] getResultUId is None".format(objGuessData.strGuessId))
            else:
                yield from doGuessMemberTask(objMatchData, objGuessData, strGuessUId)

        except Exception as e:
            logging.getLogger('result').error(repr(e))
예제 #9
0
def updateMatchState():
    objRedis = classDataBaseMgr.getInstance()
    iNowTime = timeHelp.getNow()

    # 获取当前比赛的数据
    listMatchData = yield from objRedis.getMatchDataListByScore(0,-1,"all")

    iMatchIndex = 0
    for iIndex in range(0, len(listMatchData)):
        try:
            var_match = listMatchData[iIndex]

            if var_match.iMatchState == 3:
                continue

            if iNowTime >= var_match.iMatchStartTimestamp:
                if var_match.iMatchState < 2:
                    # 如果状态没有被 数据中心回调,这里继续增加竞猜延迟
                    objMatchData,objMatchLock = yield from objRedis.getMatchDataByLock(var_match.strMatchId)
                    objMatchData.iMatchState = 2
                    yield from classDataBaseMgr.getInstance().setMatchDataByLock(objMatchData,objMatchLock)
            else:
                pass

        finally:
            iMatchIndex += 1
예제 #10
0
def msgNoResultGuess(objHead: dataHeaderDefine.classResultHead,
                     objDataCenterReq, *args, **kwargs):
    strMatchId = objDataCenterReq.strMatchId
    strGuessId = objDataCenterReq.strGuessId
    strTeamKey = objDataCenterReq.strDictKey

    logging.getLogger("result").info(
        "matchId [{}] guessId[{}] dictKey[{}] result".format(
            strMatchId, strGuessId, strTeamKey))

    objMatchData = yield from classDataBaseMgr.getInstance().getMatchData(
        strMatchId)
    if objMatchData is None:
        logging.getLogger("result").error(
            "result match data not found [{}]".format(strMatchId))
        return

    # 获取竞猜比赛的比例
    objGuessData = yield from classDataBaseMgr.getInstance().getGuessData(
        strGuessId)
    if objGuessData is None:
        logging.getLogger("result").error(
            "result guess data not found [{}]".format(strGuessId))
        return

    yield from doFindMemberTask(objMatchData, objGuessData, strTeamKey)
예제 #11
0
def handleHttp(dict_param: dict):
    """
    后台添加新闻公告系统消息
    """
    objRsp = cResp()
    strAccountId = dict_param.get('accountId')
    iMsgType = int(dict_param.get("type", 0))
    strMsgTitle = dict_param.get("title", "")
    strMsgDetail = dict_param.get("detail", "")
    strMsgId = dict_param.get("msgId", "")
    if not all([iMsgType, strMsgTitle, strMsgDetail]):
        raise exceptionLogic(errorLogic.client_param_invalid)

    if iMsgType == getMsgType.getNoticeType:

        iBroadcast = int(dict_param.get("broadcast", 0))

        objNewMsg = addMsgInfo(strMsgTitle, strMsgDetail, iMsgType,
                               strAccountId, strMsgId)
        objNewMsg.iBroadcast = iBroadcast
        yield from classDataBaseMgr.getInstance().addMsg(
            iMsgType, objNewMsg, strMsgId)
        # 构造回包
        objRsp.data = cData(objNewMsg.strMsgId, objNewMsg.strMsgTitle,
                            objNewMsg.strMsgDetail, objNewMsg.iMsgTime,
                            iMsgType)
        objRsp.data.iBroadcast = iBroadcast
        yield from asyncio.sleep(1)
        return classJsonDump.dumps(objRsp)

    elif iMsgType == getMsgType.getNewsType:
        objNewMsg = addMsgInfo(strMsgTitle, strMsgDetail, iMsgType,
                               strAccountId, strMsgId)
        yield from classDataBaseMgr.getInstance().addMsg(
            iMsgType, objNewMsg, strMsgId)
        # 构造回包
        objRsp.data = cData(objNewMsg.strMsgId, objNewMsg.strMsgTitle,
                            objNewMsg.strMsgDetail, objNewMsg.iMsgTime,
                            iMsgType)

        yield from asyncio.sleep(1)
        fileName = __name__
        nameList = fileName.split('.')
        methodName = nameList.pop()
        # 日志
        dictActionBill = {
            'billType': 'adminActionBill',
            'accountId': dict_param.get('accountId', ''),
            'action': "发送新闻公告",
            'actionTime': timeHelp.getNow(),
            'actionMethod': methodName,
            'actionDetail': "发送新闻公告Id:{},标题:{}".format(strMsgId, strMsgTitle),
            'actionIp': dict_param.get('srcIp', ''),
        }
        logging.getLogger('bill').info(json.dumps(dictActionBill))
        return classJsonDump.dumps(objRsp)

    else:
        logging.error("unknown msg type [{}]".format(iMsgType))
        raise exceptionLogic(errorLogic.client_param_invalid)
예제 #12
0
def handleHttp(dict_param: dict):
    """绑定手机"""
    objRsp = cResp()

    strAccountId = dict_param.get("accountId", "")
    objPlayerData, objLock = yield from classDataBaseMgr.getInstance(
    ).getPlayerDataByLock(strAccountId)
    if objPlayerData.strPhone:
        # 构造回包
        objRsp.data = cData()
        objRsp.data.phone = objPlayerData.strPhone
        return classJsonDump.dumps(objRsp)
    else:
        sCode = str(dict_param.get("iCode", ""))
        strPhone = dict_param.get("phoneNum", "")
        if not all([sCode, strPhone]):
            raise exceptionLogic(errorLogic.client_param_invalid)
        iCode = yield from classDataBaseMgr.getInstance().getPhoneVerify(
            strPhone)
        if not iCode:
            raise exceptionLogic(errorLogic.verify_code_expired)
        if iCode != sCode:
            raise exceptionLogic(errorLogic.verify_code_not_valid)
        else:
            yield from classDataBaseMgr.getInstance().delPhoneVerify(strPhone)
            objPlayerData.strPhone = strPhone
            yield from classDataBaseMgr.getInstance().setPlayerDataByLock(
                objPlayerData, objLock)
            yield from classDataBaseMgr.getInstance().setPhoneAccountMapping(
                strPhone, strAccountId)

        # 构造回包
        objRsp.data = cData()
        objRsp.data.phone = strPhone
        return classJsonDump.dumps(objRsp)
예제 #13
0
    def update(self, *args, **kwargs):
        if len(args) <= 0:
            logging.error("[{}] event args is null".format(self.eventName))
            return

        #第一个拿用户数据
        objPlayerData = kwargs["playerData"]
        iPayCoin = kwargs["payCoin"]
        iOrderTime = kwargs["orderTime"]

        objActiveData, objActiveLock = yield from classDataBaseMgr.getInstance(
        ).getActiveDataByLock(objPlayerData.strAccountId)
        if objActiveData is None:
            return

        # 检查 首冲返利活动
        objActiveTypeItem = objActiveData.getTypeItemByType(
            enumActiveType.activePayRebate)
        if objActiveTypeItem is not None:
            self.updateActive(objPlayerData, iPayCoin, iOrderTime,
                              objActiveTypeItem)

        # 检查 vip 首冲返利活动
        objActiveTypeItem = objActiveData.getTypeItemByType(
            enumActiveType.activeVipPayRebate)
        if objActiveTypeItem is not None:
            self.updateActive(objPlayerData, iPayCoin, iOrderTime,
                              objActiveTypeItem)

        yield from classDataBaseMgr.getInstance().setActiveDataByLock(
            objActiveData, objActiveLock)
예제 #14
0
def handleHttp(dict_param: dict):
    """个人信息"""
    objRsp = cResp()

    agentId = dict_param.get("agentId", "")
    objPlayerData = yield from classDataBaseMgr.getInstance().getPlayerData(
        agentId)
    objAgentData = yield from classDataBaseMgr.getInstance().getAgentData(
        agentId)
    allAccountNum = yield from classSqlBaseMgr.getInstance(
    ).getAccountCountByAgent(agentId)
    unReadNum = yield from classSqlBaseMgr.getInstance().getAgentMsgUnReadNum(
        agentId)

    # 构造回包
    objRsp.data = cData()
    objRsp.data.agentId = agentId
    objRsp.data.realName = objPlayerData.strRealName
    objRsp.data.phoneNum = objPlayerData.strPhone
    objRsp.data.email = objPlayerData.strEmail
    objRsp.data.count = allAccountNum
    objRsp.data.balance = objPlayerData.iCoin
    objRsp.data.loginTime = objPlayerData.iLastLoginTime
    objRsp.data.cid = objAgentData.iCid
    objRsp.data.unReadNum = unReadNum

    return classJsonDump.dumps(objRsp)
예제 #15
0
def doCheck():
    #检查写入新信息
    var_aio_redis = classDataBaseMgr.getInstance(
    ).dictAioRedis[userConfig].objAioRedis
    try:
        accountId = yield from classDataBaseMgr.getInstance(
        ).getUpdatePingboAccountId(var_aio_redis)
        if accountId is None:
            pass
        else:
            accountId = accountId.decode()
            objPlayerData, objLock = yield from classDataBaseMgr.getInstance(
            ).getPlayerDataByLock(accountId)
            if objPlayerData is None:
                # TODO log
                logging.info("用户为空")
                return
            pingbo_info = yield from get_pingbo_player_info(accountId)
            objPlayerData.iPingboCoin = pingbo_info['availableBalance'] * 100
            yield from classDataBaseMgr.getInstance().setPlayerDataByLock(
                objPlayerData, objLock)
            logging.info("update player[{}] pingboCoin".format(accountId))
    except Exception as e:
        logging.error(str(e))
        yield from classDataBaseMgr.getInstance().releasePlayerDataLock(
            accountId, objLock)
예제 #16
0
def handleHttp(dict_param: dict):
    """更改交易密码"""

    OldTradePwd = dict_param.get("oldTradePwd", "")
    NewTradepwd = dict_param.get("newTradePwd", "")
    NewTradepwd2 = dict_param.get("newTradePwd2", "")
    strAccountId = dict_param.get("accountId", "")
    if not all([OldTradePwd, NewTradepwd, NewTradepwd2]):
        raise exceptionLogic(errorLogic.client_param_invalid)
    if precompile.TradePassword.search(NewTradepwd) is None:
        raise exceptionLogic(errorLogic.player_TradePwd_length_out_of_range)
    if NewTradepwd != NewTradepwd2:
        raise exceptionLogic(errorLogic.player_pwd_pwd2_not_same)
    strTradePwd = PwdEncrypt().create_md5(NewTradepwd)
    strOldTradePwd = PwdEncrypt().create_md5(OldTradePwd)

    objPlayerData, objLock = yield from classDataBaseMgr.getInstance(
    ).getPlayerDataByLock(strAccountId)

    if objPlayerData.strTradePassword == strTradePwd:
        raise exceptionLogic(errorLogic.login_pwd_same_old)

    if objPlayerData.strTradePassword != strOldTradePwd:
        raise exceptionLogic(errorLogic.login_only_old_pwd_not_valid)

    if objPlayerData.strTradePassword == strTradePwd:
        raise exceptionLogic(errorLogic.login_pwd_same_old)
    else:
        objPlayerData.strTradePassword = strTradePwd
        yield from classDataBaseMgr.getInstance().setPlayerDataByLock(
            objPlayerData, objLock)
예제 #17
0
def initActiveData(strAccountId):
    # 初始化 活动数据
    objActiveData = yield from classDataBaseMgr.getInstance().getActiveData(
        strAccountId)
    if objActiveData is not None:
        # raise exceptionLogic(errorLogic.active_already_exist)
        logging.error(
            "account[{}] active data already exist".format(strAccountId))
        return

    objNewActiveData = classActiveData()
    objNewActiveData.strAccountId = strAccountId

    iNowTime = timeHelp.getNow()
    for var_cfg in activeConfig_cfg.values():
        if (var_cfg["actStartTime"] < iNowTime) and (iNowTime <
                                                     var_cfg["actEndTime"]):
            #在活动有效时间内
            if var_cfg["getTaskCondition"] == enumActiveStartType.startRegist:
                objNewActiveItem = classActiveItem()
                objNewActiveItem.iActiveId = int(var_cfg['id'])
                # objNewActiveItem.iActiveTime = timeHelp.getNow()
                objNewActiveItem.iActiveTime = 0
                objNewActiveItem.iActiveState = enumActiveState.stateGet
                objNewActiveData.dictActiveItem[
                    objNewActiveItem.iActiveId] = objNewActiveItem

    for var_active_type_id in g_activeTypeIdCfg:
        objNewActiveTypeItem = classActiveTypeItem()
        objNewActiveTypeItem.iActiveTypeId = var_active_type_id
        objNewActiveData.dictActiveTypeItem[
            var_active_type_id] = objNewActiveTypeItem

    yield from classDataBaseMgr.getInstance().setActiveDataByLock(
        objNewActiveData, "", False, True)
예제 #18
0
def handleHttp(dict_param: dict):
    """设置基本信息"""
    objRsp = cResp()

    strAccountId = dict_param.get('accountId', '')
    strRealName = dict_param.get('realName')
    strSex = dict_param.get('sex', '')
    strBorn = dict_param.get('born', '')
    if not all([strRealName, strSex, strBorn]):
        raise exceptionLogic(errorLogic.client_param_invalid)

    objPlayerData, objLock = yield from classDataBaseMgr.getInstance(
    ).getPlayerDataByLock(strAccountId)
    if objPlayerData.strRealName:
        raise exceptionLogic(errorLogic.client_param_invalid)

    objPlayerData.strRealName = strRealName
    objPlayerData.strSex = strSex
    objPlayerData.strBorn = strBorn
    objPlayerData.dictAddress = dict_param.get('address', '')
    yield from classDataBaseMgr.getInstance().setPlayerDataByLock(
        objPlayerData, objLock)

    # 构造回包
    objRsp.data = cAccountBaseData()
    objRsp.data.realName = objPlayerData.strRealName
    objRsp.data.sex = objPlayerData.strSex
    objRsp.data.born = objPlayerData.strBorn
    objRsp.data.address = objPlayerData.dictAddress

    return classJsonDump.dumps(objRsp)
예제 #19
0
def handleHttp(dict_param:dict):

    strGuessId = dict_param['strGuessId']

    objGuessData,objGuessLock = yield from classDataBaseMgr.getInstance().getGuessDataByLock(strGuessId)
    if objGuessData is not None:

        #锁定,拿到当前的返还率
        fTempCalcRefund = 0
        for var_ctr_key, var_ctr_value in objGuessData.dictCTR.items():
            fTempCalcRefund += 1.0 / var_ctr_value.fRate

        fReturnRate = 1.0 / fTempCalcRefund
        fCalcEach = 0.9 / fReturnRate

        for var_ctr_key, var_ctr_value in objGuessData.dictCTR.items():
            var_ctr_value.fRate = round(var_ctr_value.fRate * fCalcEach,2)
            if var_ctr_value.fRate <= 1.0:
                yield from classDataBaseMgr.getInstance().releaseGuessLock(strGuessId, objGuessLock)
                raise exceptionLogic([errorLogic.guess_return_rate_fixUpDownRateFailed_Less1Value.value[0],
                                   errorLogic.guess_return_rate_fixUpDownRateFailed_Less1Value.value[1].format(
                                       var_ctr_key)])

            yield from classDataBaseMgr.getInstance().setGuessDataByLock(objGuessData, objGuessLock)
    else:
        raise exceptionLogic(errorLogic.guess_data_not_found)
예제 #20
0
def doFindMemberTask(objMatchData, objGuessData, strTeamKey):

    while True:

        iTaskPos = yield from classDataBaseMgr.getInstance(
        ).getSetResultRedisList(objGuessData.strGuessId, strTeamKey,
                                result_config.batch_get_task_num)

        arrayGuessMember = yield from classDataBaseMgr.getInstance(
        ).getResultRedisList(objGuessData.strGuessId, strTeamKey,
                             iTaskPos - result_config.batch_get_task_num,
                             iTaskPos)
        if arrayGuessMember is None:
            # 结算这个竞猜数据
            return

        if arrayGuessMember.__len__() <= 0:
            return

        listAsynicoTask = []
        for var_member_uid in arrayGuessMember:
            #objMember = pickle.loads(varMemberBytes)
            objAsynicoTask = asyncio.ensure_future(
                doGuessMemberTask(objMatchData, objGuessData,
                                  var_member_uid.decode(), strTeamKey))
            objAsynicoTask.add_done_callback(
                functools.partial(memberTaskCallBack, var_member_uid))
            listAsynicoTask.append(objAsynicoTask)

        try:
            yield from asyncio.wait(listAsynicoTask, timeout=200)

        except Exception as e:
            logging.getLogger("result").error(repr(e))
예제 #21
0
def doCheck():
    from datawrapper.sqlBaseMgr import classSqlBaseMgr
    engine = classSqlBaseMgr.getInstance().getEngine()
    with (yield from engine) as conn:
        # 检查写入新信息
        var_aio_redis = classDataBaseMgr.getInstance(
        ).dictAioRedis[userConfig].objAioRedis
        try:
            # 获取新生成的佣金账单信息
            new_commission_bill_list = yield from classDataBaseMgr.getInstance(
            ).getAgentCommissionDataNewList(var_aio_redis)
            #logging.debug(new_coin_history_list)
            if len(new_commission_bill_list) <= 0:
                pass
            else:
                for var_id in new_commission_bill_list:
                    try:
                        if var_id is None:
                            logging.error(
                                "[{}] bill id is none".format(var_id))
                            continue
                        yield from flushInsertToDb(var_id.decode(),
                                                   var_aio_redis, conn)
                        yield from classDataBaseMgr.getInstance(
                        ).removeAgentCommissionDataNew(var_aio_redis, var_id)
                        logging.info(
                            "Save new commission bill [{}]".format(var_id))
                    except Exception as e:
                        logging.error(
                            "Save new commission bill exception bill id=[{}], error=[{}]"
                            .format(var_id, str(e)))

            dirty_commission_bill_list = yield from classDataBaseMgr.getInstance(
            ).getAgentCommissionDataDirtyList(var_aio_redis)
            # logging.debug(new_coin_history_list)
            if len(dirty_commission_bill_list) <= 0:
                pass
            else:
                for var_id in dirty_commission_bill_list:
                    try:
                        if var_id is None:
                            logging.error(
                                "[{}] order id is none".format(var_id))
                            continue
                        yield from flushUpdateToDb(var_id.decode(),
                                                   var_aio_redis, conn)
                        yield from classDataBaseMgr.getInstance(
                        ).removeAgentCommissionDataDirty(
                            var_aio_redis, var_id)
                        logging.info(
                            "Save dirty commission bill [{}]".format(var_id))
                    except Exception as e:
                        logging.error(
                            "Save dirty commission bill exception order id=[{}], error=[{}]"
                            .format(var_id, str(e)))

        except Exception as e:
            logging.error(str(e))
        finally:
            pass
예제 #22
0
def handleHttp(dict_param: dict):
    """删除银行卡"""
    objRsp = cResp()

    strAccountId = dict_param.get("accountId", "")
    strCardNum = str(dict_param.get("cardNum", ""))
    if not strCardNum:
        raise exceptionLogic(errorLogic.client_param_invalid)
    objPlayerData, objLock = yield from classDataBaseMgr.getInstance(
    ).getPlayerDataByLock(strAccountId)
    for var in objPlayerData.arrayBankCard:
        ret = list(var.values())
        print(type(ret))
        if strCardNum in ret:
            try:
                objPlayerData.arrayBankCard.remove(var)
            except Exception as e:
                logging.exception(e)
    yield from classDataBaseMgr.getInstance().setPlayerDataByLock(
        objPlayerData, objLock)

    objRsp.data = cData()
    objRsp.data.BankCard = objPlayerData.arrayBankCard

    return classJsonDump.dumps(objRsp)
예제 #23
0
def handleHttp(dict_param: dict):
    """找回密码时获取邮件验证码"""
    objRsp = cResp()

    strEmail = dict_param.get('email', '')
    if not strEmail:
        raise exceptionLogic(errorLogic.player_Email_is_none)

    if precompile.EmailRegex.search(strEmail) is None:
        raise exceptionLogic(errorLogic.player_Email_invalid)

    accountId = yield from classDataBaseMgr.getInstance(
    ).getEmailAccountMapping(strEmail)
    if not accountId:
        raise exceptionLogic(errorLogic.player_Email_is_not_bind)

    iCode = random.randint(1000, 9999)

    future = asyncio.get_event_loop().run_in_executor(None,
                                                      sendmailsms.send_mail,
                                                      strEmail, iCode)
    ret = yield from asyncio.wait_for(future, 10)

    logging.debug("send sms email{} response:".format(strEmail) + str(ret))

    yield from classDataBaseMgr.getInstance().setEmailVerify(strEmail, iCode)

    # 构造回包
    objRsp.data = cData()
    objRsp.data.iCode = iCode

    return classJsonDump.dumps(objRsp)
예제 #24
0
def handleHttp(dict_param: dict):
    """修改头像"""
    objRsp = cResp()

    strAccountId = dict_param.get("accountId", "")
    bytesBase64Png = dict_param.get("base64Png", "")
    if not bytesBase64Png:
        raise exceptionLogic(errorLogic.client_param_invalid)
    objPlayerData, objLock = yield from classDataBaseMgr.getInstance(
    ).getPlayerDataByLock(strAccountId)
    try:
        avatorName = hashlib.md5(bytesBase64Png.encode()).hexdigest()
        imageData = base64.b64decode(bytesBase64Png[22:])
        #objFileHandle = yield from aiofiles.open("/var/www/html/avator/" + avatorName + ".png", "wb")
        #yield from objFileHandle.write(imageData)
        #yield from objFileHandle.close()
        dirPrefix = "avator/"
        uploadDataFileToOss(imageData, dirPrefix, avatorName + ".png")

    except Exception as e:
        logging.exception(e)
    if procVariable.debug:
        objPlayerData.strHeadAddress = "http://probet-avator.oss-us-west-1.aliyuncs.com/{}{}.png".format(
            dirPrefix, avatorName)
    else:
        objPlayerData.strHeadAddress = "http://probet-avator.oss-us-west-1.aliyuncs.com/{}{}.png".format(
            dirPrefix, avatorName)
    yield from classDataBaseMgr.getInstance().setPlayerDataByLock(
        objPlayerData, objLock)
    # 构造回包
    objRsp.data = cData()
    objRsp.data.headAddress = objPlayerData.strHeadAddress

    return classJsonDump.dumps(objRsp)
예제 #25
0
def handleHttp(dict_param: dict):
    """设置交易密码"""
    objRsp = cResp()

    TradePwd = dict_param.get("tradePwd", "")
    TradePwd2 = dict_param.get("tradePwd2", "")
    strAccountId = dict_param.get("accountId", "")

    if not all([TradePwd, TradePwd2]):
        raise exceptionLogic(errorLogic.client_param_invalid)
    if TradePwd != TradePwd2:
        raise exceptionLogic(errorLogic.player_pwd_pwd2_not_same)
    if precompile.TradePassword.search(TradePwd) is None:
        raise exceptionLogic(errorLogic.player_TradePwd_length_out_of_range)
    objPlayerData, objLock = yield from classDataBaseMgr.getInstance().getPlayerDataByLock(strAccountId)
    strTradePwd = PwdEncrypt().create_md5(TradePwd)
    objPlayerData.strTradePassword = strTradePwd
    yield from classDataBaseMgr.getInstance().setPlayerDataByLock(objPlayerData, objLock)

    objRsp.data = cData()
    if objPlayerData.strTradePassword:
        objRsp.data.tradePwd = 1
    else:
        objRsp.data.tradePwd = 0

    return classJsonDump.dumps(objRsp)
예제 #26
0
def handleHttp(dict_param: dict):

    strGuessId = dict_param['strGuessId']
    fReturnRate = float(dict_param['strReturnRate'])

    objGuessData, objGuessDataLock = yield from classDataBaseMgr.getInstance(
    ).getGuessDataByLock(strGuessId)
    if objGuessData is None:
        raise exceptionLogic(errorLogic.guess_data_not_found)

    #current return rate
    fTempCalcRefund = 0
    for var_ctr_key, var_ctr_value in objGuessData.dictCTR.items():
        fTempCalcRefund += 1 / var_ctr_value.fRate

    #fRefund = round(1 / fTempCalcRefund, 2)
    fCale = (1 / fReturnRate) / fTempCalcRefund
    for var_ctr_key, var_ctr_value in objGuessData.dictCTR.items():
        var_ctr_value.fRate *= fCale
        var_ctr_value.fRate = round(var_ctr_value.fRate, 2)

    yield from classDataBaseMgr.getInstance().setGuessDataByLock(
        objGuessData, objGuessDataLock)

    # 推送赔率包到客户的
    yield from broadCastGuessData([objGuessData], "broadCastPub")
예제 #27
0
def scanAwardMemberTask(objMatchData, iAwardNum, iAwardType, iWinOrLose):

    try:

        #iNowTime = timeHelp.getNow()
        if iWinOrLose == 0:
            strSKeyAward = "matchLoseUniqueAward".format(
                objMatchData.strMatchId)
            strSKeyNotAward = "matchLoseUniqueAwarded".format(
                objMatchData.strMatchId)
        elif iWinOrLose == 1:
            strSKeyAward = "matchWinUniqueAward".format(
                objMatchData.strMatchId)
            strSKeyNotAward = "matchWinUniqueAwarded".format(
                objMatchData.strMatchId)
        else:
            strSKeyAward = "matchAllUniqueAward".format(
                objMatchData.strMatchId)
            strSKeyNotAward = "matchAllUniqueAwarded".format(
                objMatchData.strMatchId)

        iPopId = yield from classDataBaseMgr.getInstance().getRandomSetItem(
            strSKeyAward)
        logging.getLogger("result").info("pop [{}]".format(iPopId))

        while iPopId != None and len(iPopId) > 0:
            try:
                yield from classDataBaseMgr.getInstance().changeTwoSetList(
                    strSKeyAward, strSKeyNotAward, iPopId)

                strAccountId = iPopId
                objPlayerData, objPlayerLock = yield from classDataBaseMgr.getInstance(
                ).getPlayerDataByLock(strAccountId)
                if objPlayerData is None:
                    logging.getLogger("result").error(
                        "player data not found account[{}]".format(
                            strAccountId))
                else:
                    if iAwardType == 0:
                        objPlayerData.iCoin -= iAwardNum
                    else:
                        objPlayerData.fDiamond -= iAwardNum

                    yield from classDataBaseMgr.getInstance(
                    ).setPlayerDataByLock(objPlayerData, objPlayerLock)

                    # 最后推送一波到客户端
                    #yield from pushPlayer.pushMsg(objPlayerData,objBetHis)
                    yield from coroPushPlayerCoin(objPlayerData.strAccountId,
                                                  objPlayerData.iGuessCoin)

            except Exception as e:
                logging.getLogger("result").error(repr(e))
            finally:
                iPopId = yield from classDataBaseMgr.getInstance(
                ).getRandomSetItem(strSKeyAward)

    except Exception as e:
        logging.getLogger('result').error(repr(e))
예제 #28
0
def handleHttp(dictParam: dict):
    #每月VIP活动
    objResp = cResp()
    strAccountId = dictParam.get('accountId', '')
    strToken = dictParam.get('token', '')

    certifytoken.certify_token(strAccountId, strToken)
    objPlayerData = yield from classDataBaseMgr.getInstance().getPlayerData(
        strAccountId)
    objActiveData = yield from classDataBaseMgr.getInstance().getActiveData(
        strAccountId)
    if objPlayerData is None:
        raise exceptionLogic(errorLogic.player_data_not_found)
    if objActiveData is None:
        raise exceptionLogic(errorLogic.active_not_find)
    #判断活动是否完成
    objActiveItme = objActiveData.dictActiveItem.get(2001)
    if objActiveItme is None:
        raise exceptionLogic(errorLogic.active_not_find)
    if objActiveItme.iActiveState == 1:
        raise exceptionLogic(errorLogic.active_have_already_get)

    #升级需要的流水
    upWater = vipConfig.vip_config[objPlayerData.iLevel].get(
        'upGradeValidWater')
    #保级需要的流水
    keepWater = vipConfig.vip_config[objPlayerData.iLevel].get(
        'keepValidWater')
    #这个月24小时内充值存款
    payMonthly, orderTime = yield from classSqlBaseMgr.getInstance(
    ).getAccountFirstPayByDay(strAccountId)
    # 获取当月有效流水自己平台
    validWater = yield from classSqlBaseMgr.getInstance().getValidWaterMonthly(
        strAccountId)
    #获取平博当月有效流水
    pingboValidWater = yield from classSqlBaseMgr.getInstance(
    ).getAccountPinboHistoryValidWater(timeHelp.monthStartTimestamp(),
                                       timeHelp.nextMonthStartTimestamp(),
                                       strAccountId)
    pingboValidWater = 0 if pingboValidWater.get(
        'validWaterCoin') is None else pingboValidWater.get('validWaterCoin')
    data = cData()
    data.accountId = strAccountId
    #升级还需要的流水
    data.upLevelWater = "%.2f" % round(
        (upWater - objPlayerData.iLevelValidWater) / 100, 2)
    data.keepLevelWater = "%.2f" % round(
        (keepWater - (validWater + pingboValidWater)) / 100, 2)
    data.level = objPlayerData.iLevel
    data.rebate = vipConfig.vip_config[objPlayerData.iLevel].get('rebate')
    data.recharge = "%.2f" % round(payMonthly / 100, 2)
    data.activeTime = objActiveData.dictActiveItem.get(2001).iActiveTime
    data.validWater = "%.2f" % round((pingboValidWater + validWater) / 100, 2)
    data.activeId = 2001
    objResp.data = data
    return classJsonDump.dumps(objResp)
예제 #29
0
def handleHttp(request: dict):
    """代理新增线下用户"""
    objRep = cResp()

    agentId = request.get('agentId', '')
    offlineUser = request.get('offlineUser', '')

    if not all([agentId, offlineUser]):
        raise exceptionLogic(errorLogic.client_param_invalid)

    try:
        agentData = yield from classDataBaseMgr.getInstance().getAgentData(
            agentId)
        if agentData is None:
            # 判断是否是代理
            logging.debug(errorLogic.agent_data_not_found)
            raise exceptionLogic(errorLogic.agent_data_not_found)

        userIsAgent = yield from classDataBaseMgr.getInstance().getAgentData(
            offlineUser)
        if userIsAgent is not None:
            # 判断新增用户是否是代理
            logging.debug(errorLogic.user_is_agent)
            raise exceptionLogic(errorLogic.user_is_agent)
        # 判断新增用户是否是有代理
        userData, objPlayerLock = yield from classDataBaseMgr.getInstance(
        ).getPlayerDataByLock(offlineUser)
        if userData is None:
            logging.debug(errorLogic.player_data_not_found)
            raise exceptionLogic(errorLogic.player_data_not_found)
        if userData.strAgentId != '':
            logging.debug(errorLogic.user_has_agent)
            raise exceptionLogic(errorLogic.user_has_agent)
        userData.strAgentId = agentId
        yield from classDataBaseMgr.getInstance().setPlayerDataByLock(
            userData, objPlayerLock)

        fileName = __name__
        nameList = fileName.split('.')
        methodName = nameList.pop()
        # 日志
        dictActionBill = {
            'billType': 'adminActionBill',
            'accountId': request.get('accountId', ''),
            'action': "代理新增下线用户",
            'actionTime': getNow(),
            'actionMethod': methodName,
            'actionDetail': "给代理:{} 新增下线用户:{}".format(agentId, offlineUser),
            'actionIp': request.get('srcIp', ''),
        }
        logging.getLogger('bill').info(json.dumps(dictActionBill))
        return classJsonDump.dumps(objRep)

    except Exception as e:
        logging.exception(e)
        raise e
예제 #30
0
def handleHttp(dict_param: dict):
    """提款"""
    objRsp = cResp()

    strAccountId = dict_param.get("accountId", "")
    strCardNum = str(dict_param.get("cardNum", ""))
    TradePwd = dict_param.get("tradePwd", "")
    money = dict_param.get("money", "")
    if not all([strCardNum, money]):
        raise exceptionLogic(errorLogic.client_param_invalid)
    if cpv.checkIsString(money):
        raise exceptionLogic(errorLogic.client_param_invalid)
    fMoney = float(money)
    if not cpv.checkIsFloat(fMoney):
        raise exceptionLogic(errorLogic.client_param_invalid)
    iCoin = int(fMoney * 100)
    if not cpv.checkIsInt(iCoin):
        raise exceptionLogic(errorLogic.client_param_invalid)

    strTradePwd = PwdEncrypt().create_md5(TradePwd)

    objPlayerData, objLock = yield from classDataBaseMgr.getInstance(
    ).getPlayerDataByLock(strAccountId)
    if not objPlayerData.strTradePassword:
        raise exceptionLogic(errorLogic.trade_pwde_not_bind)
    if strTradePwd != objPlayerData.strTradePassword:
        raise exceptionLogic(errorLogic.trade_pwde_not_valid)

    # 获取可提现额度
    drawinglimit = round(
        (objPlayerData.iCoin - objPlayerData.iNotDrawingCoin) / 100, 2)

    Coin = round(iCoin / 100)
    if not cpv.checkIsInt(Coin):
        raise exceptionLogic(errorLogic.player_drawing_coin_not_int)
    if Coin > drawinglimit:
        raise exceptionLogic(errorLogic.player_drawing_not_enough)
    if objPlayerData.iCoin < iCoin:
        raise exceptionLogic(errorLogic.player_coin_not_enough)
    else:
        balance = objPlayerData.iCoin - iCoin
        # redis 事务操作以及余额的处理
        objPlayerData.iCoin -= iCoin
        yield from classDataBaseMgr.getInstance().setPlayerDataByLock(
            objPlayerData, objLock)

        yield from addPlayerBill(strAccountId, iCoin, balance,
                                 CoinOp.coinOpDraw, 2, "中心钱包", strCardNum)

    newdrawinglimit = drawinglimit - Coin
    objRsp.data = cData()
    objRsp.data.iCoin = "%.2f" % round(objPlayerData.iCoin / 100, 2)
    objRsp.data.newDrawingLimit = newdrawinglimit

    return classJsonDump.dumps(objRsp)