Ejemplo n.º 1
0
def handleHttp(request: dict):
    # 更新轮播图信息
    bannerId = request.get('bannerId')
    title = request.get('title', '')
    link_url = request.get('link_url', '')
    bytesBase64Png = request.get("base64Png", "")

    if not bannerId:
        logging.debug(errorLogic.client_param_invalid)
        raise exceptionLogic(errorLogic.client_param_invalid)
    if bytesBase64Png:
        bannerName = hashlib.md5(bytesBase64Png.encode()).hexdigest()
        imageData = base64.b64decode(bytesBase64Png[22:])
        dirPrefix = "banner/"
        image_url = "http://probet-avator.oss-us-west-1.aliyuncs.com/{}{}.png".format(dirPrefix, bannerName)
        uploadDataFileToOss(imageData, dirPrefix, bannerName + ".png")
        sql = "update dj_banner set title='{}',link_url='{}',image_url='{}' WHERE id={} ".format(title, link_url,image_url, bannerId)
    else:
        sql = "update dj_banner set title='{}',link_url='{}' WHERE id={} ".format(title, link_url, bannerId)

    conn=classSqlBaseMgr.getInstance()
    try:
        yield from conn._exeCuteCommit(sql)

        sql="select * from dj_banner"
        listRest=yield from conn._exeCute(sql)
        banners=yield from listRest.fetchall()
        objRsp=cResp()
        if len(banners) == 0:
            return classJsonDump.dumps(objRsp)
        else:
            for var_row in banners:
                dataDict = cData()
                dataDict.index = var_row['index']
                dataDict.title = var_row['title']
                dataDict.image_url = var_row['image_url']
                dataDict.link_url = var_row['link_url']
                dataDict.update_time = var_row['update_time']
                dataDict.addAccount = var_row['addAccount']
                dataDict.id = var_row['id']
                objRsp.data.append(dataDict)

        fileName = __name__
        nameList = fileName.split('.')
        methodName = nameList.pop()
        # 日志
        dictActionBill = {
            'billType': 'adminActionBill',
            'accountId': request.get('accountId', ''),
            'action': "修改轮播图信息",
            'actionTime': timeHelp.getNow(),
            'actionMethod': methodName,
            'actionDetail': "修改轮播图信息Id:{}".format(bannerId),
            'actionIp': request.get('srcIp', ''),
        }
        logging.getLogger('bill').info(json.dumps(dictActionBill))
        return classJsonDump.dumps(objRsp)
    except Exception as e:
        logging.exception(e)
        raise exceptionLogic(errorLogic.db_error)
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
def get_permission(accountId):
    # 获取该用户的权限名
    try:
        conn = classSqlBaseMgr.getInstance()
        sql = select([tb_admin]).where(tb_admin.c.accountId == accountId)
        listRest = yield from conn._exeCute(sql)
        user = yield from listRest.fetchone()
        if not user:
            logging.debug(errorLogic.player_data_not_found)
            raise exceptionLogic(errorLogic.player_data_not_found)

        if not user['role_id']:
            logging.debug(errorLogic.player_data_not_found)
            raise exceptionLogic(errorLogic.player_data_not_found)

        sql = "SELECT dj_admin_action.action_name FROM dj_admin_action WHERE dj_admin_action.id IN (SELECT dj_admin_role_action.action_id FROM dj_admin_role_action WHERE dj_admin_role_action.role_id ={})".format(
            user['role_id'])
        listRest = yield from conn._exeCute(sql)
        objNames = yield from listRest.fetchall()
        action_names = []
        for x in objNames:
            action_names.append(x['action_name'])

        return action_names
    except Exception as e:
        logging.debug(e)
        raise exceptionLogic(errorLogic.db_error)
Ejemplo n.º 4
0
def handleHttp(dict_param: dict):
    """
    获取消息
    """
    objRsp = cResp()
    iPageNum = int(dict_param.get("pageNum", 1))
    iType = int(dict_param.get("type", 0))
    if not all([iType, iPageNum]):
        raise exceptionLogic(errorLogic.client_param_invalid)
    if iPageNum <= 0:
        raise exceptionLogic(errorLogic.client_param_invalid)

    MsgDataList, count = yield from classSqlBaseMgr.getInstance().getMsg(
        iType, iPageNum, 10)

    # 构造回包
    objRsp.data = MsgDataList
    objRsp.count = count
    fileName = __name__
    nameList = fileName.split('.')
    methodName = nameList.pop()
    # 日志
    dictActionBill = {
        'billType': 'adminActionBill',
        'accountId': dict_param.get('accountId', ''),
        'action': "获取新闻/公告",
        'actionTime': getNow(),
        'actionMethod': methodName,
        'actionDetail': "获取新闻/公告",
        'actionIp': dict_param.get('srcIp', ''),
    }
    logging.getLogger('bill').info(json.dumps(dictActionBill))
    yield from asyncio.sleep(1)
    return classJsonDump.dumps(objRsp)
Ejemplo n.º 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)
Ejemplo n.º 6
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)
Ejemplo n.º 7
0
    def wrapper(*args, **kwargs):
        conn = classSqlBaseMgr.getInstance()
        accountId = args[0].get('accountId', '')
        token = args[0].get('token', '')
        if not all([accountId, token]):
            logging.debug(errorLogic.client_param_invalid)
            raise exceptionLogic(errorLogic.client_param_invalid)
        try:
            sql = select([tb_admin]).where(tb_admin.c.accountId == accountId)
            listRest = yield from conn._exeCute(sql)
            account = yield from listRest.fetchone()
        except Exception as e:
            logging.debug(e)
            raise exceptionLogic(errorLogic.db_error)

        if not account:
            logging.debug(errorLogic.wrong_accountId_or_password)
            raise exceptionLogic(errorLogic.wrong_accountId_or_password)

        if account['token'] != token:
            logging.debug(errorLogic.token_not_valid)
            raise exceptionLogic(errorLogic.token_not_valid)
        is_pass = certify_admin_token(accountId, token)

        if not is_pass:
            #用户未登录
            logging.debug(errorLogic.token_not_valid)
            raise exceptionLogic(errorLogic.token_not_valid)
        args[0]['account'] = account
        a = yield from view_func(*args, **kwargs)
        return a
Ejemplo n.º 8
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)
Ejemplo n.º 9
0
def handleHttp(request: dict):
    # 获取用户列表接口 get
    url = tokenhelp.PINBO_URL + '/list-player/info'

    headers = tokenhelp.gen_headers()

    session = aiohttp.ClientSession()
    try:
        with aiohttp.Timeout(10):
            resp = session.get(url=url, headers=headers, verify_ssl=False)
            if resp.status != 200:
                raise exceptionLogic(errorLogic.client_param_invalid)

    except Exception as e:
        logging.exception(repr(e))
        raise exceptionLogic(errorLogic.sys_unknow_error)
    else:
        res = yield from resp.read()
        res = json.loads(res.decode())
        code = res.get('code', '')
        if code != '' and (code in errorLogic.pinbo_error_code.keys()):
            logging.debug(code + ":" + errorLogic.pinbo_error_code[code])

            raise exceptionLogic([code, errorLogic.pinbo_error_code[code]])

        return res
    finally:
        if session:
            yield from session.close()
Ejemplo n.º 10
0
def handleHttp(request:dict):
    # 获取玩家简单输赢
    headers=tokenhelp.gen_headers()

    url=tokenhelp.PINBO_URL+'/report/winloss-simple'

    params={}
    params['dateFrom'] = request["end"]#'2018-05-10'
    params['dateTo'] = request["begin"]#'2018-05-19'
    params['userCode']= request["loginId"]

    session = aiohttp.ClientSession()
    try:
        with aiohttp.Timeout(10):
            resp= session.get(url=url, headers=headers, params=params,verify_ssl=False)
            if resp.status != 200:
                raise exceptionLogic(errorLogic.client_param_invalid)

    except Exception as e:
        logging.exception(repr(e))
        raise exceptionLogic(errorLogic.sys_unknow_error)
    else:
        res = yield from resp.read()
        res = json.loads(res.decode())
        code = res.get('code', '')
        if code != '' and (code in errorLogic.pinbo_error_code.keys()):
            logging.debug(code + ":" + errorLogic.pinbo_error_code[code])

            raise exceptionLogic([code, errorLogic.pinbo_error_code[code]])
        return res
    finally:
        if session:
            yield from session.close()
Ejemplo n.º 11
0
def handleHttp(dictParam: dict):

    fRmbFen = float(dictParam.get('rmb', "0"))
    if not checkIsFloat(fRmbFen):
        raise exceptionLogic(errorLogic.client_param_invalid)
    # 客户的给的是分
    iRmbFen = int(fRmbFen * 100)

    if iRmbFen < 100 or iRmbFen > 300000:
        raise exceptionLogic(errorLogic.pay_online_amount_limit)

    try:
        #检查用户是否登录,检查用户token
        strAccountId = str(dictParam.get("accountId", ""))
        strToken = str(dictParam.get("token", ""))
    except:
        raise exceptionLogic(errorLogic.client_param_invalid)

    if len(strAccountId) <= 0:
        raise exceptionLogic(errorLogic.player_id_empty)
    """
    ret = certify_token(strAccountId,strToken)
    if not ret:
        raise exceptionLogic(errorLogic.login_token_expired)
    """

    strClientIp = str(dictParam.get("srcIp", ""))

    objResp = cResp()
    #objResp.data = yield from pocoPayOrder(strAccountId,iRmbFen,"qq","wap",strClientIp,pocoWrapPayOrderCall)
    objResp.data = yield from lpayPayOrder(strAccountId, iRmbFen, "qq_wap",
                                           dictParam.get("srcIp", ""))

    return classJsonDump.dumps(objResp)
Ejemplo n.º 12
0
def handleHttp(request:dict):
    # 修改用户状态
    headers=tokenhelp.gen_headers()

    url=tokenhelp.PINBO_URL+'/player/update-status'

    data={}
    data['userCode']='PSZ4000002'
    data['status']='ACTIVE'
    # 需要校验数据

    session = aiohttp.ClientSession()
    try:
        with aiohttp.Timeout(10):
            resp= session.post(url=url,headers=headers,data=data,verify_ssl=False)
            if resp.status!=200:
                raise exceptionLogic(errorLogic.client_param_invalid)

    except Exception as e:
        logging.exception(e)
        raise exceptionLogic(errorLogic.sys_unknow_error)
    else:
        res = yield from resp.read()
        res = json.loads(res.decode())
        code = res.get('code', '')
        if code != '' and (code in errorLogic.pinbo_error_code.keys()):
            logging.debug(code + ":" + errorLogic.pinbo_error_code[code])

            raise exceptionLogic([code, errorLogic.pinbo_error_code[code]])

        return res
    finally:
        if session:
            yield from session.close()
Ejemplo n.º 13
0
def get_my_bets_full(accountId):
    # 获取我的投注

    url=tokenhelp.PINBO_URL+'/player/account/my-bets-full'

    headers=tokenhelp.gen_headers()

    data={}
    data['loginId']= "probet." + accountId
    data['locale']='zh-cn'

    session=aiohttp.ClientSession()
    try:
        with aiohttp.Timeout(10):
            resp = yield from session.post(url=url, headers=headers, data=data,verify_ssl=False)
            if resp.status != 200:
                raise exceptionLogic(errorLogic.client_param_invalid)

    except Exception as e:
        logging.exception(repr(e))
        raise exceptionLogic(errorLogic.sys_unknow_error)
    else:
        res = yield from resp.read()
        res = json.loads(res.decode())
        code = res.get('code', '')
        if code != '' and (code in errorLogic.pinbo_error_code.keys()):
            logging.debug(code + ":" + errorLogic.pinbo_error_code[code])

            raise exceptionLogic([code, errorLogic.pinbo_error_code[code]])
        return res
    finally:
        if session:
            yield from session.close()
Ejemplo n.º 14
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)
Ejemplo n.º 15
0
def handleHttp(request: dict):
    role_id = request.get('role_id', '')
    account_ids = request.get('account_ids', [])
    if (not role_id) or (len(account_ids) == 0):
        logging.debug(exceptionLogic(errorLogic.client_param_invalid))
        raise exceptionLogic(errorLogic.client_param_invalid)
    try:
        conn = classSqlBaseMgr.getInstance()

        for x in account_ids:
            sql = "update dj_admin_account set role_id={} WHERE accountId='{}'".format(
                role_id, x)
            yield from conn._exeCuteCommit(sql)

        resp = cResp()
        sql = "select * from dj_admin_role"
        listRest = yield from conn._exeCute(sql)
        roles = yield from listRest.fetchall()
        for role in roles:
            data = cData()
            data.id = role['id']
            data.role_name = role['role_name']
            sql = "select accountId from dj_admin_account WHERE  role_id={}".format(
                role['id'])
            listRest = yield from conn._exeCute(sql)
            accounts = yield from listRest.fetchall()
            data.accounts = [{"id": x['accountId']} for x in accounts]
            sql = "select id,action_name from dj_admin_action WHERE(id IN (select action_id from dj_admin_role_action WHERE role_id={})) ".format(
                role['id'])
            listRest = yield from conn._exeCute(sql)
            actions = yield from listRest.fetchall()
            data.actions = [{
                "id": x['id'],
                "name": x['action_name']
            } for x in actions]
            resp.data.append(data)

        resp.ret = errorLogic.success[0]
        fileName = __name__
        nameList = fileName.split('.')
        methodName = nameList.pop()
        # 日志
        dictActionBill = {
            'billType': 'adminActionBill',
            'accountId': request.get('accountId', ''),
            'action': "修改角色权限",
            'actionTime': getNow(),
            'actionMethod': methodName,
            'actionDetail': "修改角色id:{} 权限".format(role_id),
            'actionIp': request.get('srcIp', ''),
        }
        logging.getLogger('bill').info(json.dumps(dictActionBill))
        return classJsonDump.dumps(resp)

    except IntegrityError as e:
        logging.debug(e)
        raise exceptionLogic(errorLogic.account_already_exists)
    except Exception as e:
        logging.debug(e)
        raise exceptionLogic(errorLogic.db_error)
Ejemplo n.º 16
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)
Ejemplo n.º 17
0
def handleHttp(dictParam: dict):

    fRmbFen = float(dictParam.get('rmb', "0"))
    if not checkIsFloat(fRmbFen):
        raise exceptionLogic(errorLogic.client_param_invalid)
    # 客户的给的是分
    iRmbFen = int(fRmbFen * 100)

    if iRmbFen < 100 or iRmbFen > 300000:
        raise exceptionLogic(errorLogic.pay_online_amount_limit)

    try:
        #检查用户是否登录,检查用户token
        strAccountId = str(dictParam.get("accountId", ""))
        strToken = str(dictParam.get("token", ""))
    except:
        raise exceptionLogic(errorLogic.client_param_invalid)

    if len(strAccountId) <= 0:
        raise exceptionLogic(errorLogic.player_id_empty)

    if not procVariable.debug:
        certify_token(strAccountId, strToken)

    objResp = cResp()
    objResp.data = yield from lpayPayOrder(strAccountId, iRmbFen, "wx_wap",
                                           dictParam.get("srcIp", ""))

    return classJsonDump.dumps(objResp)
Ejemplo n.º 18
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)
Ejemplo n.º 19
0
def loginout_pinbo(accountId):
    url = "/player/logout"
    data = {}
    data['userCode'] = 'probet.' + accountId
    headers = tokenhelp.gen_headers()

    if procVariable.debug:
        headers["refer"] = "probet"

    session = aiohttp.ClientSession()
    try:
        with aiohttp.Timeout(10):
            resp = yield from session.post(tokenhelp.PINBO_URL + url, headers=headers, data=data,verify_ssl=False)
            if resp.status != 200:
                logging.error("{}|{}".format(errorLogic.third_party_error[1],data))
                raise exceptionLogic(errorLogic.third_party_error)

    except Exception as e:
        logging.exception(e)
        raise exceptionLogic(errorLogic.sys_unknow_error)
    else:
        res = yield from resp.read()
        resp = json.loads(res.decode())

    finally:
        if session is not None:
            yield from session.close()

    return resp
Ejemplo n.º 20
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)
Ejemplo n.º 21
0
def handleHttp(request: dict):
    """获取渠道LTV数据"""
    channel = request.get('channel', '')
    startTime = request.get('startTime', 0)
    endTime = request.get('endTime', 0)

    objRep = cResp()

    if not all([startTime,endTime]):
        logging.debug(errorLogic.client_param_invalid)
        raise exceptionLogic(errorLogic.client_param_invalid)

    if (not checkIsInt(startTime)) or (not checkIsInt(endTime)):
        logging.debug(errorLogic.client_param_invalid)
        raise exceptionLogic(errorLogic.client_param_invalid)

    try:
        # conn=classSqlBaseMgr.getInstance(instanceName='probet_oss')
        with (yield from classSqlBaseMgr.getInstance().objDbMysqlMgr) as conn:
            over_all_data=cData()
            #todo
        return classJsonDump.dumps(objRep)
    except Exception as e:
        logging.exception(e)
        raise exceptionLogic(errorLogic.db_error)
Ejemplo n.º 22
0
def handleHttp(request: dict):
    delId = request.get('id', '')
    if not delId:
        logging.debug(errorLogic.client_param_invalid)
        raise exceptionLogic(errorLogic.client_param_invalid)

    try:
        conn = classSqlBaseMgr.getInstance()
        sql = "delete from dj_admin_account WHERE id={}".format(delId)
        yield from conn._exeCuteCommit(sql)

        sql = "select count(id) from dj_admin_account"
        listRest = yield from conn._exeCute(sql)
        count = yield from listRest.fetchone()

        sql = "select * from dj_admin_account order by dj_admin_account.id limit {}".format(
            MSG_PAGE_COUNT)
        listRest = yield from conn._exeCute(sql)
        accounts = yield from listRest.fetchall()
        resp = cResp()
        for x in accounts:
            data = cData()
            data.id = x['id']
            data.accountId = x['accountId']
            if x['role_id'] is None:
                data.role_name = ''
            else:
                sql = "select dj_admin_role.role_name from dj_admin_role WHERE dj_admin_role.id={}".format(
                    x['role_id'])
                listRest = yield from conn._exeCute(sql)
                role_name = yield from listRest.fetchone()
                data.role_name = role_name[0]
            resp.data.append(data)

        resp.count = count[0]
        resp.ret = errorLogic.success[0]
        fileName = __name__
        nameList = fileName.split('.')
        methodName = nameList.pop()
        # 日志
        dictActionBill = {
            'billType': 'adminActionBill',
            'accountId': request.get('accountId', ''),
            'action': "删除后台账号",
            'actionTime': getNow(),
            'actionMethod': methodName,
            'actionDetail': "删除后台账号:{}".format(delId),
            'actionIp': request.get('srcIp', ''),
        }
        logging.getLogger('bill').info(json.dumps(dictActionBill))
        return classJsonDump.dumps(resp)

    except exceptionLogic as e:
        logging.error(repr(e))
        raise e
    except Exception as e:
        logging.debug(e)
        raise exceptionLogic(errorLogic.db_error)
Ejemplo n.º 23
0
def handleHttp(request: dict):
    # 新增轮播图信息
    accountId = request.get('accountId')
    title = request.get('title', '')
    bytesBase64Png = request.get("base64Png", "")
    link_url = request.get('link_url', '')
    if not all([title, bytesBase64Png]):
        logging.debug(errorLogic.client_param_invalid)
        raise exceptionLogic(errorLogic.client_param_invalid)

    bannerName = hashlib.md5(bytesBase64Png.encode()).hexdigest()
    imageData = base64.b64decode(bytesBase64Png[22:])
    dirPrefix = "banner/"
    uploadDataFileToOss(imageData, dirPrefix, bannerName + ".png")

    try:
        sql = "select dj_banner.index from dj_banner"
        listRest = yield from classSqlBaseMgr.getInstance()._exeCute(sql)
        listRest = yield from listRest.fetchall()
        if len(listRest) == 0:
            index = 0
        else:
            sql = "select max(dj_banner.index) from dj_banner"
            ret = yield from classSqlBaseMgr.getInstance()._exeCute(sql)
            ret = yield from ret.fetchone()
            index = ret[0] + 1

        sql = tb_banner.insert().values(
            index=index,
            link_url=link_url,
            image_url="http://probet-avator.oss-us-west-1.aliyuncs.com/{}{}.png"
            .format(dirPrefix, bannerName),
            title=title,
            addAccount=accountId,
            create_time=timeHelp.getNow(),
            update_time=timeHelp.getNow())
        yield from classSqlBaseMgr.getInstance()._exeCuteCommit(sql)
        objResp = cResp()
        fileName = __name__
        nameList = fileName.split('.')
        methodName = nameList.pop()
        # 日志
        dictActionBill = {
            'billType': 'adminActionBill',
            'accountId': request.get('accountId', ''),
            'action': "新增轮播图",
            'actionTime': timeHelp.getNow(),
            'actionMethod': methodName,
            'actionDetail': "新增轮播图,标题:{}".format(title),
            'actionIp': request.get('srcIp', ''),
        }
        logging.getLogger('bill').info(json.dumps(dictActionBill))
        return classJsonDump.dumps(objResp)
    except Exception as e:
        logging.exception(e)
        raise exceptionLogic(errorLogic.db_error)
Ejemplo n.º 24
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
Ejemplo n.º 25
0
def handleHttp(request: dict):
    """新增推广素材"""
    objRep = cResp()

    bytesBase64Png = request.get("base64Png", "")
    imageSize = request.get("imageSize", "")

    if not all([bytesBase64Png, imageSize]):
        logging.debug(errorLogic.client_param_invalid)
        raise exceptionLogic(errorLogic.client_param_invalid)

    materialName = hashlib.md5(bytesBase64Png.encode()).hexdigest()
    imageData = base64.b64decode(bytesBase64Png[22:])
    dirPrefix = "material/"
    uploadDataFileToOss(imageData, dirPrefix, materialName + ".png")
    image_url = "http://probet-avator.oss-us-west-1.aliyuncs.com/{}{}.png".format(
        dirPrefix, materialName)
    imageId = str(uuid.uuid1())
    try:
        sql = tb_material.insert().values(imageId=imageId,
                                          image_url=image_url,
                                          imageSize=imageSize,
                                          create_time=timeHelp.getNow(),
                                          update_time=timeHelp.getNow())
        yield from classSqlBaseMgr.getInstance()._exeCuteCommit(sql)

        sql = "select * from dj_material order by update_time desc"
        result = yield from classSqlBaseMgr.getInstance()._exeCute(sql)
        if result.rowcount <= 0:
            return classJsonDump.dumps(objRep)
        else:
            for var in result:
                materialData = {}
                materialData['imageId'] = var.imageId
                materialData['image_url'] = var.image_url
                materialData['imageSize'] = var.imageSize
                objRep.data.append(materialData)
        fileName = __name__
        nameList = fileName.split('.')
        methodName = nameList.pop()
        # 日志
        dictActionBill = {
            'billType': 'adminActionBill',
            'accountId': request.get('accountId', ''),
            'action': "新增推广素材",
            'actionTime': timeHelp.getNow(),
            'actionMethod': methodName,
            'actionDetail': "新增推广素材imageId:{}".format(imageId),
            'actionIp': request.get('srcIp', ''),
        }
        logging.getLogger('bill').info(json.dumps(dictActionBill))
        return classJsonDump.dumps(objRep)

    except Exception as e:
        logging.exception(e)
        raise exceptionLogic(errorLogic.db_error)
Ejemplo n.º 26
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)
Ejemplo n.º 27
0
def handleHttp(dict_param: dict):
    """
    登陆应该传递的参数有用户名相关的信息
    """
    testUrl = "https://paapistg.oreo88.com/b2b/list-player/info"

    dictHead = {}
    dictHead["userCode"] = tokenhelp.agentCode
    dictHead["token"] = base64.b64encode(tokenhelp.token).decode()

    dictBody = {}

    try:
        with aiohttp.Timeout(10):  # 为aiohttp设置超时时间
            global client
            client = aiohttp.ClientSession()  # 设置aiohttp客户端对象

            # 这行代码就是用来发送信息的,代替request的,向安博发送请求,并得到响应
            result = yield from client.get(testUrl,
                                           data=dictBody,
                                           headers=dictHead)
            if result.status != 200:  # 发送请求失败
                print('get status failed [{}]'.format(result.status))
                raise exceptionLogic(errorLogic.client_param_invalid)
            else:  # 等到请求之后,再去读取返回来的信息
                ret = yield from result.read()
                ret = ret.decode('utf-8')
                print(ret)
                global dictDataInfo
                dictDataInfo = json.loads(ret)
                print(dictDataInfo)
    except Exception as e:
        raise exceptionLogic(errorLogic.sys_unknow_error)
    finally:
        if client is not None:
            yield from client.close()
    #构造回包

    objRsp = cResp()
    objEle = cElement()
    objEle.ele = cData()

    for dictDataInfo in dictDataInfo:
        objEle.ele.userCode = dictDataInfo["userCode"]
        objEle.ele.loginId = dictDataInfo["loginId"]
        objEle.ele.firstName = dictDataInfo["firstName"]
        objEle.ele.lastName = dictDataInfo["lastName"]
        objEle.ele.status = dictDataInfo["status"]
        objEle.ele.availableBalance = dictDataInfo["availableBalance"]
        objEle.ele.outstanding = dictDataInfo["outstanding"]
        objEle.ele.createdDate = dictDataInfo["createdDate"]
        objEle.ele.createdBy = dictDataInfo["createdBy"]
        objRsp.data.append(objEle.ele)

    return classJsonDump.dumps(objRsp)
Ejemplo n.º 28
0
def handleHttp(request:dict):
    # 修改密码
    accountId=request.get('accountId','')
    oldPassword=request.get('oldPassword','')
    password=request.get('password','')
    rePassword=request.get('rePassword','')

    if not all([accountId,password,rePassword]):
        logging.debug(errorLogic.client_param_invalid)
        raise exceptionLogic(errorLogic.client_param_invalid)

    if password!=rePassword:
        logging.debug(errorLogic.login_pwd_not_valid)
        raise exceptionLogic(errorLogic.login_pwd_not_valid)

    if len(password)<6 or len(password)>20:
        logging.debug(errorLogic.player_TradePwd_length_out_of_range)
        raise exceptionLogic(errorLogic.player_TradePwd_length_out_of_range)


    try:
        conn=classSqlBaseMgr.getInstance()
        sql="select passwordHash from dj_admin_account WHERE accountId='{}'".format(accountId)
        listRest=yield from conn._exeCute(sql)
        old_pwd=yield from listRest.fetchone()

        if not check_password(old_pwd['passwordHash'],oldPassword):
            logging.debug(errorLogic.login_only_old_pwd_not_valid)
            raise exceptionLogic(errorLogic.login_only_old_pwd_not_valid)

        sql="update dj_admin_account set passwordHash='{}' WHERE accountId='{}'".format(generate_password_hash(password),accountId)
        yield from conn._exeCuteCommit(sql)
        resp=cResp()
        resp.ret=errorLogic.success[0]
        fileName = __name__
        nameList = fileName.split('.')
        methodName = nameList.pop()
        # 日志
        dictActionBill = {
            'billType': 'adminActionBill',
            'accountId': request.get('accountId', ''),
            'action': "修改自己密码",
            'actionTime': getNow(),
            'actionMethod': methodName,
            'actionDetail': "修改自己密码",
            'actionIp': request.get('srcIp', ''),
        }
        logging.getLogger('bill').info(json.dumps(dictActionBill))

        return classJsonDump.dumps(resp)
    except exceptionLogic as e :
        raise e
    except Exception as e:
        logging.debug(e)
        raise exceptionLogic(errorLogic.db_error)
Ejemplo n.º 29
0
def handleHttp(request: dict):
    """代理账号管理"""
    agentId = request.get('agentId', '')
    lockTime = request.get('lockTime', '')
    lockReason = request.get('lockReason', '')
    status = request.get('status', '')

    if not agentId:
        logging.debug(errorLogic.client_param_invalid)
        raise exceptionLogic(errorLogic.client_param_invalid)
    try:
        objAgentData = yield from classDataBaseMgr.getInstance().getAgentData(
            agentId)
        if objAgentData is None:
            logging.debug(errorLogic.agent_data_not_found)
            raise exceptionLogic(errorLogic.agent_data_not_found)

        if status == 0:
            # 解封
            objAgentData.iStatus = status
            objAgentData.iLockStartTime = 0
            objAgentData.iLockEndTime = 0
            objAgentData.strLockReason = ""
        else:
            # 冻结账号
            if not all([lockTime, lockReason]):
                logging.debug(errorLogic.lockTime_or_lockReason_lack)
                raise exceptionLogic(errorLogic.lockTime_or_lockReason_lack)
            objAgentData.iStatus = 1
            objAgentData.iLockStartTime = timeHelp.getNow()
            objAgentData.iLockEndTime = timeHelp.getNow() + int(lockTime)
            objAgentData.strLockReason = lockReason

        yield from classDataBaseMgr.getInstance().setAgentData(objAgentData)

        resp = cResp()
        fileName = __name__
        nameList = fileName.split('.')
        methodName = nameList.pop()
        # 日志
        dictActionBill = {
            'billType': 'adminActionBill',
            'accountId': request.get('accountId', ''),
            'action': "代理账号管理修改",
            'actionTime': timeHelp.getNow(),
            'actionMethod': methodName,
            'actionDetail': "代理账号管理修改:{}".format(agentId),
            'actionIp': request.get('srcIp', ''),
        }
        logging.getLogger('bill').info(json.dumps(dictActionBill))
        return classJsonDump.dumps(resp)
    except exceptionLogic as e:
        logging.error(repr(e))
        raise e
Ejemplo n.º 30
0
def handleHttp(request: dict):
    # 获取充值账户下的待处理账单
    transTo = request.get('transTo', '')
    money = request.get('money', '')
    if not transTo:
        logging.debug(errorLogic.client_param_invalid)
        raise exceptionLogic(errorLogic.client_param_invalid)
    try:
        conn = classSqlBaseMgr.getInstance()
        if money:
            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)

            ids_sql = "select orderId from dj_coin_history WHERE transTo='{}' AND coinNum={} AND tradeState=2 AND tradeType=1 ".format(
                transTo, iCoin)

        else:
            ids_sql = "select orderId from dj_coin_history WHERE transTo='{}' AND tradeState=2 AND tradeType=1 ".format(
                transTo)

        sql = "select * from dj_pay_order WHERE payOrder IN (" + ids_sql + ") and orderTime between {} and {} order by status desc,orderTime desc".format(
            getNow() - 3600 * 24, getNow())
        listRest = yield from conn._exeCute(sql)
        pay_list = yield from listRest.fetchall()
        resp = cResp()
        for x in pay_list:
            data = cData()
            data.payOrder = x['payOrder']
            data.payChannel = x['payChannel']
            data.accountId = x['accountId']
            data.orderTime = x['orderTime']
            data.buyCoin = "%.2f" % round(x['buyCoin'] / 100, 2)
            data.ip = x['ip']
            data.status = x['status']
            resp.data.append(data)

        resp.ret = errorLogic.success[0]

        return classJsonDump.dumps(resp)
    except exceptionLogic as e:
        logging.error(repr(e))
        raise e
    except Exception as e:
        logging.exception(e)
        raise exceptionLogic(errorLogic.db_error)