示例#1
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()
示例#2
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
示例#3
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()
示例#4
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()
示例#5
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()
示例#6
0
def get_wagers(startTime=None, endTime=None, accountId=None):
    # 投注
    # 修改用户状态
    headers = tokenhelp.gen_headers()

    url = tokenhelp.PINBO_URL + '/report/all-wagers'

    data = {}
    if accountId:
        data['userCode'] = "probet." + accountId
    # 时间转换
    if startTime and endTime:
        if endTime - startTime >= 24 * 3600:
            logging.debug(errorLogic.client_param_invalid)
            raise exceptionLogic(errorLogic.client_param_invalid)
        startTime = timestamp2Str(startTime - 12 * 3600)
        endTime = timestamp2Str(endTime - 12 * 3600)
        data['dateFrom'] = startTime  # '2018-05-19 00:00:00'
        data['dateTo'] = endTime  # '2018-05-19 23:40:30'
    data['locale'] = 'zh-cn'

    # 需要校验数据
    session = aiohttp.ClientSession()
    try:
        with aiohttp.Timeout(180):
            resp = yield from session.get(url=url,
                                          headers=headers,
                                          params=data,
                                          verify_ssl=False)
            #print(resp.status)
            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())
        if type(res) == list:
            pass
        else:
            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()
示例#7
0
def deposit(kind, accountId, amount):

    headers = tokenhelp.gen_headers()
    if kind not in ['deposit', 'withdraw']:
        raise exceptionLogic(errorLogic.client_param_invalid)

    # 用户存款
    if kind == 'deposit':
        url = tokenhelp.PINBO_URL + '/player/deposit'
    else:
        # 用户提款
        url = tokenhelp.PINBO_URL + '/player/withdraw'
    data = {}
    data['userCode'] = 'probet.' + accountId
    data['amount'] = amount
    if amount <= 0:
        logging.debug(errorLogic.client_param_invalid)
        raise exceptionLogic(errorLogic.client_param_invalid)

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

    except Exception as e:
        logging.debug(e)
        return 4

    else:
        res = yield from resp.read()
        res = json.loads(res.decode())
        print(res)
        code = res.get('code', '')
        if code != '' and (code in errorLogic.pinbo_error_code.keys()):
            logging.debug(code + ":" + errorLogic.pinbo_error_code[code])

            return 4

        return 1

    finally:
        if session:
            yield from session.close()
示例#8
0
def handleHttp(request: dict):
    # 投注
    # 修改用户状态
    headers = tokenhelp.gen_headers()

    url = tokenhelp.PINBO_URL + '/report/wagers'

    data = {}
    data['userCode'] = 'PSZ4000002'
    data['locale'] = 'zh-cn'
    data['dateFrom'] = '2018-05-19 00:00:00'
    data['dateTo'] = '2018-05-19 23:40:30'
    data['product'] = 'SB'
    data['settle'] = True
    data['filterBy'] = 'event_date'

    resp = requests.get(url=url, headers=headers, params=data)
    print(resp.content)

    # 需要校验数据
    session = aiohttp.ClientSession()
    try:
        with aiohttp.Timeout(10):
            resp = session.get(url=url,
                               headers=headers,
                               params=data,
                               verify_ssl=False)
            print(resp.status)
            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()
示例#9
0
def handleHttp(dict_param: dict):
    """
    登陆应该传递的参数有用户名相关的信息
    """
    testUrl = "https://paapistg.oreo88.com/b2b/player/withdraw"

    dictHead = tokenhelp.gen_headers()

    dictBody = {}
    dictBody["userCode"] = "a111112"
    dictBody["amount"] = 100

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

            # 这行代码就是用来发送信息的,代替request的,向安博发送请求,并得到响应
            result = yield from client.post(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(
    )  # 包含ret和retDes这两个是状态码相关的,这个不用我们设置,会自动设置的,另外一个存放的cData的实例对象。
    objRsp.data = cData()  # 这个类对象包含token值,账号,昵称

    objRsp.data.userCode = dictDataInfo["userCode"]  # 用户的账号
    objRsp.data.loginId = dictDataInfo["loginId"]  # 用户存的钱
    objRsp.data.availableBalance = dictDataInfo["availableBalance"]  # 用户账户总额
    objRsp.data.amount = dictDataInfo["amount"]

    return classJsonDump.dumps(objRsp)
示例#10
0
def get_pingbo_player_info(accountId):
    """获取用户信息接口
    """
    url=tokenhelp.PINBO_URL+"/player/info"
    headers=tokenhelp.gen_headers()

    params={}
    params['userCode']='probet.' + accountId

    try:
        with (aiohttp.ClientSession()) as session:
            with aiohttp.Timeout(2):
                resp = yield from session.get(url=url,params=params,headers=headers,verify_ssl=False)
                if resp.status!=200:
                    logging.debug(errorLogic.third_party_error)
                    raise exceptionLogic(errorLogic.third_party_error)

    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]])

        availableBalance = res.get("availableBalance")
        if availableBalance is None:
            logging.debug(errorLogic.third_party_error)
            raise exceptionLogic(errorLogic.third_party_error)

        objPlayerData,objLock=yield from classDataBaseMgr.getInstance().getPlayerDataByLock(accountId)
        if objPlayerData is None:
            logging.debug("account: [{}] is not Exist".format(objPlayerData.strAccountId))
        else:
            objPlayerData.iPingboCoin=availableBalance * 100
            objPlayerData.iLastPBCRefreshTime=getNow()
            yield from classDataBaseMgr.getInstance().setPlayerDataByLock(objPlayerData,objLock)

        return res
示例#11
0
def register_pinbo(accountId):
    """pinbo注册接口
    """
    url = '/player/create'
    headers = tokenhelp.gen_headers()

    data = {}
    data['loginId'] = 'probet.' + accountId

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

    except Exception as e:
        logging.error(e)
        raise exceptionLogic(errorLogic.third_party_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])
            if code == "111":
                raise exceptionLogic(errorLogic.player_id_already_exist)
            raise exceptionLogic([code, errorLogic.pinbo_error_code[code]])

        if res.get('loginId') is None:
            ret = data['loginId']
            return ret
        return res.get('loginId')

    finally:
        if session is not None:
            yield from session.close()
示例#12
0
def handleHttp(request: dict):
    """对接pinbo登陆接口
    """
    headers = tokenhelp.gen_headers()
    accountId = request.get("accountId")
    token = request.get("token")

    if not accountId:
        raise exceptionLogic(errorLogic.client_param_invalid)
    # userCode= 获取userCode通过user_id
    url = "/player/login"

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

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

    except Exception as e:
        logging.error(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.exception(code + ":" + errorLogic.pinbo_error_code[code])
            raise exceptionLogic([code, errorLogic.pinbo_error_code[code]])

        res = json.loads(res)
        login_url = res.get('loginUrl')
        return login_url
示例#13
0
def update_status(accountId, status):
    """更改用户状态
    """

    url = tokenhelp.PINBO_URL + "/player/update-status"
    headers = tokenhelp.gen_headers()

    params = {}
    params['userCode'] = 'probet.' + accountId
    params['status'] = status

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

    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 is not None:
            yield from session.close()
示例#14
0
def get_settle_wagers(session):
    headers = tokenhelp.gen_headers()
    url = tokenhelp.PINBO_URL + '/report/all-wagers'

    data = {}
    data['settle'] = 1
    data['locale'] = 'zh-cn'
    startTime = timestamp2Str(getNow() - 17 * 3600)
    endTime = timestamp2Str(getNow() - 12 * 3600)
    data['dateFrom'] = startTime  # '2018-05-19 00:00:00'
    data['dateTo'] = endTime  # '2018-05-19 23:40:30'

    # 需要校验数据

    try:
        with aiohttp.Timeout(180):
            resp = yield from session.get(url=url,
                                          headers=headers,
                                          params=data,
                                          verify_ssl=False,
                                          timeout=180)
            if resp.status != 200:
                logging.exception('pingbo network error [{}]'.format(resp))
                return []
    except Exception as e:
        logging.exception(repr(e))
        return []
    else:
        res = yield from resp.read()
        res = json.loads(res.decode())
        if isinstance(res, list):
            return res
        else:
            code = res.get('code', '')
            if code != '' and (code in errorLogic.pinbo_error_code.keys()):
                logging.exception(code + ":" +
                                  errorLogic.pinbo_error_code[code])
                return []
示例#15
0
def handleHttp(request: dict):
    # 获取所有投注
    url = tokenhelp.PINBO_URL + '/report/all-wagers'

    headers = tokenhelp.gen_headers()

    params = {}
    params['dateFrom'] = '2018-05-18 10:00:00'
    params['dateTo'] = '2018-05-19 10:00:00'

    # 需要校验数据
    session = aiohttp.ClientSession()
    try:
        with aiohttp.Timeout(10):
            resp = yield from session.get(url=url,
                                          headers=headers,
                                          params=params,
                                          verify_ssl=False)
            print(resp.status)
            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()
示例#16
0
def handleHttp(request:dict):
    """获取用户信息接口
    """
    url=tokenhelp.PINBO_URL+"/player/info"
    headers=tokenhelp.gen_headers()
    accountId=request.get('accountId','')
    token = request.get('token','')
    source = request.get('source', 'pc')
    if not all([accountId, source]):
        logging.debug(errorLogic.client_param_invalid)
        raise exceptionLogic(errorLogic.client_param_invalid)

    certify_token(accountId, token)

    objPlayerData = yield from classDataBaseMgr.getInstance().getPlayerData(accountId)
    if source == 'pc':
        if objPlayerData.strToken!=token:
            logging.debug(errorLogic.login_token_not_valid)
            raise exceptionLogic(errorLogic.login_token_not_valid)
    elif source == 'app':
        if objPlayerData.strAppToken!=token:
            logging.debug(errorLogic.login_token_not_valid)
            raise exceptionLogic(errorLogic.login_token_not_valid)

    params={}
    params['userCode']='probet.'+accountId

    try:
        with (aiohttp.ClientSession()) as session:
            with aiohttp.Timeout(10):
                resp = yield from session.get(url=url,params=params,headers=headers,verify_ssl=False)
                if resp.status!=200:
                    logging.exception(errorLogic.third_party_error)
                    raise exceptionLogic(errorLogic.third_party_error)

    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]])

        availableBalance=res.get("availableBalance")
        if availableBalance is None:
            logging.debug(errorLogic.third_party_error)
            raise exceptionLogic(errorLogic.third_party_error)
        objPlayerData, objLock = yield from classDataBaseMgr.getInstance().getPlayerDataByLock(accountId)

        objPlayerData.iPingboCoin = availableBalance * 100
        objPlayerData.iLastPBCRefreshTime=getNow()
        yield from classDataBaseMgr.getInstance().setPlayerDataByLock(objPlayerData, objLock)
        res['availableBalance']="%.2f"%round(availableBalance,2)
        ret={}
        ret['ret']=errorLogic.success[0]
        ret['data']=res
        ret['retDes']=errorLogic.success[1]

        return classJsonDump.dumps(ret)