Beispiel #1
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)
Beispiel #2
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)
Beispiel #3
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)
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)
Beispiel #5
0
def handleHttp(dictParam: dict):
    objResp = cResp()

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

    strAccountId = str(dictParam["accountId"])

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

    return classJsonDump.dumps(objResp)
Beispiel #6
0
def handleHttp(dictParam: dict):
    objResp = cResp()

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

    strAccountId = str(dictParam["accountId"])
    strToken = str(dictParam.get("token", ""))

    if not procVariable.debug:
        certify_token(strAccountId, strToken)
    #这里用web的
    objResp.data = yield from lpayPayOrder(strAccountId, iRmbFen,
                                           "unionpay_wap",
                                           dictParam.get("srcIp", ""))

    return classJsonDump.dumps(objResp)
Beispiel #7
0
def handleHttp(request: dict):
    userId = request.get('userId', '')
    kind = request.get('kind', '')
    money = request.get('money', 0)
    reason = request.get('reason', '')
    wallet = request.get('wallet', '')

    if not all([userId, money, kind, reason]):
        logging.debug(errorLogic.client_param_invalid)
        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)

    if kind not in ['recharge', 'deductions']:
        logging.debug(errorLogic.client_param_invalid)
        raise exceptionLogic(errorLogic.client_param_invalid)

    try:
        objPlayerData, objLock = yield from classDataBaseMgr.getInstance(
        ).getPlayerDataByLock(userId)
        if objPlayerData is None:
            raise exceptionLogic(errorLogic.player_data_not_found)

        objUserCoinHis = classUserCoinHistory()
        objUserCoinHis.strOrderId = str(uuid.uuid1())
        objUserCoinHis.iTime = timeHelp.getNow()
        objUserCoinHis.iCoin = iCoin
        objUserCoinHis.iTradeState = 1
        objUserCoinHis.strAccountId = userId
        objUserCoinHis.strIp = request.get('srcIp', '')
        objUserCoinHis.iEndTime = timeHelp.getNow()
        objUserCoinHis.strTransFrom = '后台'
        objUserCoinHis.strTransTo = '中心钱包'
        objUserCoinHis.strReviewer = request.get('accountId', '')
        objUserCoinHis.strReason = reason
        if kind == 'recharge':
            objUserCoinHis.iTradeType = 11
            objPlayerData.iCoin += iCoin
            objNewPayOrder = classPayData()
            objNewPayOrder.strPayOrder = objUserCoinHis.strOrderId
            objNewPayOrder.strAccountId = userId
            objNewPayOrder.iBuyCoin = iCoin
            objNewPayOrder.iOrderTime = timeHelp.getNow()
            objNewPayOrder.strIp = request.get(
                "srcIp", "")  # str(dictParam.get("srcIp", ""))
            objNewPayOrder.strPayChannel = '后台'
            yield from classDataBaseMgr.getInstance().setPayOrderByLock(
                objNewPayOrder, save=False, new=True)
            walletName = 'center'
            coin = objPlayerData.iCoin
        else:
            if wallet not in ['center', 'pingboCoin', 'betCoin', 'shabaCoin']:
                logging.debug(errorLogic.client_param_invalid)
                raise exceptionLogic(errorLogic.client_param_invalid)
            objUserCoinHis.iTradeType = 6
            objUserCoinHis.strTransTo = '后台'
            if wallet == "center":
                objPlayerData.iCoin -= iCoin
                objUserCoinHis.strTransFrom = '中心钱包'
                coin = objPlayerData.iCoin
            elif wallet == "pingboCoin":
                status = yield from deposit(kind='withdraw',
                                            accountId=userId,
                                            amount=fMoney)
                if status != 1:
                    yield from classDataBaseMgr.getInstance(
                    ).releasePlayerDataLock(userId, objLock)
                    logging.debug(errorLogic.third_deductions_failed)
                    raise exceptionLogic(errorLogic.third_deductions_failed)
                coin = objPlayerData.iPingboCoin
                if objPlayerData.iPingboCoin - iCoin < 0:
                    logging.debug(errorLogic.third_deductions_failed)
                    raise exceptionLogic(errorLogic.third_deductions_failed)
                objPlayerData.iPingboCoin -= iCoin
                objUserCoinHis.strTransFrom = '平博钱包'
            elif wallet == "betCoin":
                coin = objPlayerData.iGuessCoin
                objPlayerData.iGuessCoin -= iCoin
                objUserCoinHis.strTransFrom = '竞猜钱包'
            else:
                coin = objPlayerData.iShabaCoin
                objPlayerData.iShabaCoin -= iCoin
                #todo 调用沙巴扣钱api
                objUserCoinHis.strTransFrom = '沙巴钱包'
            walletName = wallet

        yield from classDataBaseMgr.getInstance().addPlayerCoinRecord(
            userId, objUserCoinHis)
        yield from classDataBaseMgr.getInstance().setPlayerDataByLock(
            objPlayerData, objLock)

        # 推送用户金币
        yield from coroPushPlayerCenterCoin(objPlayerData.strAccountId, coin,
                                            walletName)
        yield from asyncio.sleep(1)
        sql = "select * from dj_account WHERE accountId='{}' ".format(userId)
        conn = classSqlBaseMgr.getInstance()
        listRest = yield from conn._exeCute(sql)
        user = yield from listRest.fetchone()
        objRsp = cResp()
        data = cData()
        data.accountId = user['accountId']
        data.phone = user['phone']
        data.coin = "%.2f" % round(user['coin'] / 100, 2)
        data.guessCoin = "%.2f" % round(user['guessCoin'] / 100, 2)
        data.pinboCoin = "%.2f" % round(user['pingboCoin'] / 100, 2)
        #todo
        data.coin188 = "%.2f" % round(123123 / 100, 2)
        data.regTime = user['regTime']
        data.email = user['email']
        data.loginTime = user['loginTime']
        data.loginIp = [user['loginIp'], user['loginAddress']]
        data.logoutTime = user['logoutTime']
        data.level = user['level']
        data.status = [user['status'], user['lockEndTime'], user['lockReason']]
        data.bankcard = ast.literal_eval(user['bankcard'])
        data.loginDeviceUdid = user['loginDeviceUdid']
        data.realName = user['realName']
        objRsp.data.append(data)
        fileName = __name__
        nameList = fileName.split('.')
        methodName = nameList.pop()
        # 日志
        dictActionBill = {
            'billType':
            'adminActionBill',
            'accountId':
            request.get('accountId', ''),
            'action':
            "给用户充值/补发" if kind == 'recharge' else "给用户扣款",
            'actionTime':
            timeHelp.getNow(),
            'actionMethod':
            methodName,
            'actionDetail':
            "给用户:{},充值/补发:{},单号:{}".format(userId, money,
                                           objUserCoinHis.strOrderId)
            if kind == 'recharge' else "给用户:{},扣款{},单号:{}".format(
                userId, money, objUserCoinHis.strOrderId),
            'actionIp':
            request.get('srcIp', ''),
        }
        logging.getLogger('bill').info(json.dumps(dictActionBill))
        return classJsonDump.dumps(objRsp)
    except Exception as e:
        logging.exception(e)
        raise e
Beispiel #8
0
def handleGuessBet(objHead: classSSHead, objFbReq: dict):
    objResp = protoGuessBetResp()

    try:
        # 查找用户数据
        if cpv.checkStringEmpty(objHead.strAccountId):
            raise exceptionLogic(errorLogic.player_account_id_empty)

        if not cpv.checkIsString(objHead.strToken):
            raise exceptionLogic(errorLogic.client_param_invalid)

        if cpv.checkStringEmpty(objHead.strToken):
            raise exceptionLogic(errorLogic.client_param_invalid)
        # 将客户端发来的请求参数及值经过处理后获取相应值
        iBetCoin, strMatchId, strBetChooseId, strGuessId, fBetRate, iBetRateIgnore = cpv.getDictStrParam(
            objFbReq, 'iBetCoin', 'strMatchId', 'strChooseId', "strGuessId",
            "fBetRate", "iBetRateIgnore")

        if not cpv.checkIsInt(iBetCoin):
            raise exceptionLogic(errorLogic.client_param_invalid)

        #默认转成元单位
        iBetCoin *= 100

        if not cpv.checkIsString(strMatchId):
            raise exceptionLogic(errorLogic.client_param_invalid)

        if not cpv.checkIsString(strBetChooseId):
            raise exceptionLogic(errorLogic.client_param_invalid)

        if not cpv.checkIsString(strGuessId):
            raise exceptionLogic(errorLogic.client_param_invalid)

        if fBetRate is not None:
            fBetRate = float(fBetRate)
            if not cpv.checkIsFloat(fBetRate):
                raise exceptionLogic(errorLogic.client_param_invalid)

        if iBetRateIgnore is not None:
            if not cpv.checkIsInt(iBetRateIgnore):
                raise exceptionLogic(errorLogic.client_param_invalid)

    except:
        raise exceptionLogic(errorLogic.client_param_invalid)

    # 查看最小押注额度
    if iBetCoin < 1000 or iBetCoin > 200000:
        raise exceptionLogic(errorLogic.guess_bet_num_min_limit)

    # 查看是否限制本题的竞猜
    iAlreadyBetNum = yield from classDataBaseMgr.getInstance(
    ).getAccountGuessBet(objHead.strAccountId, strGuessId)

    objPlayerData, strPlayerDataLock, objMatchData, objGuess, strGuessLock = yield from classDataBaseMgr.getInstance(
    ).getBetData(objHead.strAccountId, strMatchId, strGuessId)

    try:
        if objPlayerData is None:  # 用户不存在
            raise exceptionLogic(errorLogic.player_data_not_found)
        """
        if objPlayerData.strToken != objHead.strToken:  # 鉴权信息已过期
            raise exceptionLogic(errorLogic.login_token_not_valid)
        """
        if objMatchData is None:  # 比赛不存在
            raise exceptionLogic(errorLogic.match_data_not_found)

        if objMatchData.iMatchState >= 3:  # 比赛已结束
            raise exceptionLogic(errorLogic.match_state_close)

        if objGuess is None:
            raise exceptionLogic(errorLogic.match_guess_not_found)  # 竞猜不存在
        else:
            if objGuess.iGuessState >= 1:
                raise exceptionLogic(
                    errorLogic.match_guess_state_close)  # 本竞猜已封盘

        if (iAlreadyBetNum + iBetCoin) > objGuess.iLimitPerAccount:
            raise exceptionLogic([
                errorLogic.guess_bet_num_max_limit[0],
                errorLogic.guess_bet_num_max_limit[1].format(iAlreadyBetNum)
            ])

        if strBetChooseId not in objGuess.dictCTR:
            raise exceptionLogic(errorLogic.match_guess_not_found)  # 竞猜未找到

        if objPlayerData.iGuessCoin < iBetCoin:
            raise exceptionLogic(errorLogic.player_coin_not_enough)  # 用户金币不足

        fCurrentRate = round(objGuess.dictCTR[strBetChooseId].fRate, 2)
        # 不忽略赔率变化
        iBillCoinBeforeBet = objPlayerData.iBetCoin
        objPlayerData.iGuessCoin -= iBetCoin

        objNewBetHis = classUserBetHistory()
        # 竞猜id由 uuid4组成
        objNewBetHis.strGuessUId = orderGeneral.generalOrderId()
        objNewBetHis.iBetCoin = iBetCoin
        objNewBetHis.strMatchId = strMatchId
        objNewBetHis.strMatchType = objMatchData.strMatchType
        objNewBetHis.strGuessId = strGuessId
        objNewBetHis.strGuessName = objGuess.strGuessName
        objNewBetHis.iRoundNum = objGuess.iRoundNum
        objNewBetHis.iTime = timeHelp.getNow()
        objNewBetHis.strChooseId = strBetChooseId
        objNewBetHis.strAccountId = objPlayerData.strAccountId
        objNewBetHis.strTeamAName = objMatchData.strTeamAName
        objNewBetHis.strTeamBName = objMatchData.strTeamBName

        # 竞猜id,竞猜信息
        for var_id, var_crt in objGuess.dictCTR.items():
            objBetCTR = classBetCTR()
            objBetCTR.strId = var_id
            objBetCTR.fRate = var_crt.fRate
            objBetCTR.strChooseName = var_crt.strChooseName
            objNewBetHis.dictCTR[var_id] = objBetCTR

        objGuess.dictCTR[strBetChooseId].iTotalCoin += iBetCoin
        objGuess.dictCTR[strBetChooseId].iTotalBetNum += 1
        objGuess.dictCTR[strBetChooseId].iReturnCoin += (
            iBetCoin * objGuess.dictCTR[strBetChooseId].fRate)

    except:
        # 要把锁都还回去
        if objPlayerData is not None:
            yield from classDataBaseMgr.getInstance().releasePlayerDataLock(
                objPlayerData.strAccountId, strPlayerDataLock)
        if objGuess is not None:
            yield from classDataBaseMgr.getInstance().releaseGuessLock(
                objGuess.strGuessId, strGuessLock)

        raise

    # 将当前用户的竞猜信息插入DB
    iNowTime = timeHelp.getNow()
    yield from classDataBaseMgr.getInstance().addBetData(
        strBetChooseId, objGuess, objPlayerData, strGuessLock,
        strPlayerDataLock, objNewBetHis, iNowTime)
    # 推送用户当前的金币
    #yield from pushPlayerCoin(objPlayerData.strAccountId,objPlayerData.iCoin)

    # 添加后台统计柱状图,统一去重用户的押注量,押注用户统计
    fGraphIndex = gmProtocol.getGraphIndex(fCurrentRate)
    yield from classDataBaseMgr.getInstance().addGraphBetRange(
        objPlayerData.strAccountId, strMatchId, strGuessId, iBetCoin,
        fGraphIndex, strBetChooseId, iNowTime, fCurrentRate)

    # 写入金币消耗日志
    if objGuess.iRoundNum == 0:
        coinHisDes = "本场比赛\n {}\n {}".format(
            objGuess.strGuessName,
            objGuess.dictCTR[strBetChooseId].strChooseName)
    else:
        coinHisDes = "{}局\n {}\n {}".format(
            objGuess.iRoundNum, objGuess.strGuessName,
            objGuess.dictCTR[strBetChooseId].strChooseName)

    #gmProtocol.gameTypeMap.get(objMatchData.strMatchType)

    # 给用户推送一下投注单
    yield from pushPlayerData(objPlayerData, objNewBetHis)

    logging.getLogger('logic').info("bet account[{}] ip[{}]".format(
        objPlayerData.strAccountId, objHead.strClientIp))

    dictBill = {
        'billType': "betBill",
        'betHisUId': objNewBetHis.strGuessUId,
        'accountId': objPlayerData.strAccountId,
        'agentId': objPlayerData.strAgentId,
        #'nick': objPlayerData.strNick,
        'matchId': objMatchData.strMatchId,
        'guessId': objGuess.strGuessId,
        'roundNum': objGuess.iRoundNum,
        'supportType': strBetChooseId,
        'betCoinNum': iBetCoin,  #竞猜金额
        'coinBeforeBet': iBillCoinBeforeBet,
        'coinAfterBet': objPlayerData.iBetCoin,
        'projectType': objMatchData.strMatchType,
        'betTime': timeHelp.getNow(),
    }

    logging.getLogger('bill').info(json.dumps(dictBill))

    return objResp
Beispiel #9
0
def handleHttp(dict_param: dict):
    """转账"""
    objRsp = cResp()

    strAccountId = dict_param.get("accountId", "")
    TurnOut = dict_param.get("Turnout", "")
    TurnIn = dict_param.get("Turnin", "")
    money = dict_param.get("money", "")

    if not all([TurnOut, TurnIn, 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)
    fMoney = float("%.2f" % fMoney)

    iCoin = int(fMoney * 100)
    if not cpv.checkIsInt(iCoin):
        raise exceptionLogic(errorLogic.client_param_invalid)

    if TurnOut != "中心钱包" and TurnIn != "中心钱包":
        raise exceptionLogic(errorLogic.client_param_invalid)

    objPlayerData, objLock = yield from classDataBaseMgr.getInstance(
    ).getPlayerDataByLock(strAccountId)
    tradeData = None
    if TurnOut == "中心钱包" and TurnIn == "平博钱包":
        if iCoin > int(objPlayerData.iCoin):
            raise exceptionLogic(errorLogic.player_coin_not_enough)
        objPlayerData.iCoin -= iCoin
        iBalance = objPlayerData.iCoin - iCoin

        # 触发另一个平台的转账功能
        status = yield from pinboDeposit.deposit(kind='deposit',
                                                 accountId=strAccountId,
                                                 amount=fMoney)
        if status == 1:
            objPlayerData.iPingboCoin += iCoin
        yield from classDataBaseMgr.getInstance().setPlayerDataByLock(
            objPlayerData, objLock)

        tradeData = yield from addPlayerBill(strAccountId, iCoin, iBalance,
                                             CoinOp.coinOpTrans, status,
                                             TurnOut, TurnIn)

    elif TurnOut == "中心钱包" and TurnIn == "电竞钱包":
        if iCoin > int(objPlayerData.iCoin):
            raise exceptionLogic(errorLogic.player_coin_not_enough)
        objPlayerData.iCoin -= iCoin
        objPlayerData.iGuessCoin += iCoin
        iBalance = objPlayerData.iCoin - iCoin
        yield from classDataBaseMgr.getInstance().setPlayerDataByLock(
            objPlayerData, objLock)

        tradeData = yield from addPlayerBill(strAccountId, iCoin, iBalance,
                                             CoinOp.coinOpTrans, 1, TurnOut,
                                             TurnIn)

    elif TurnIn == "中心钱包" and TurnOut == "平博钱包":
        # 触发另一个平台的转账功能
        status = yield from pinboDeposit.deposit(kind='withdraw',
                                                 accountId=strAccountId,
                                                 amount=fMoney)
        if status == 1:
            objPlayerData.iCoin += iCoin
            objPlayerData.iPingboCoin -= iCoin
            iBalance = objPlayerData.iCoin + iCoin
            yield from classDataBaseMgr.getInstance().setPlayerDataByLock(
                objPlayerData, objLock)

        tradeData = yield from addPlayerBill(strAccountId, iCoin, iBalance,
                                             CoinOp.coinOpTrans, status,
                                             TurnOut, TurnIn)

    elif TurnIn == "中心钱包" and TurnOut == "电竞钱包":
        if iCoin > int(objPlayerData.iGuessCoin):
            raise exceptionLogic(errorLogic.player_coin_not_enough)

        objPlayerData.iCoin += iCoin
        objPlayerData.iGuessCoin -= iCoin
        iBalance = objPlayerData.iCoin + iCoin
        yield from classDataBaseMgr.getInstance().setPlayerDataByLock(
            objPlayerData, objLock)
        tradeData = yield from addPlayerBill(strAccountId, iCoin, iBalance,
                                             CoinOp.coinOpTrans, 1, TurnOut,
                                             TurnIn)
    else:
        logging.error("unkown trun way {} {}".format(TurnIn, TurnOut))

    objRsp.data = cData()
    objRsp.data.iCoin = "%.2f" % round(objPlayerData.iCoin / 100, 2)
    objRsp.data.iGuessCoin = "%.2f" % round(objPlayerData.iGuessCoin / 100, 2)
    tradeData.iCoin = float("%.2f" % round(tradeData.iCoin / 100, 2))
    objRsp.data.orderdata = tradeData

    return classJsonDump.dumps(objRsp)
Beispiel #10
0
def handleHttp(dict_param: dict):
    """存款"""
    objRsp = cResp()

    strAccountId = dict_param.get("accountId", "")
    strToken = dict_param.get("token", "")
    strPayType = dict_param.get("payType", "")
    # iTradeType = dict_param.get("tradeType", 0)
    money = dict_param.get("money", "")
    if not all([strAccountId, strToken, 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)

    certifytoken.certify_token(strAccountId, strToken)

    objPlayerData = yield from classDataBaseMgr.getInstance().getPlayerData(strAccountId)
    if objPlayerData is None:
        raise exceptionLogic(errorLogic.player_data_not_found)
    if strToken != objPlayerData.strToken:
        raise exceptionLogic(errorLogic.login_token_not_valid)

    PayTypeList = []
    for var in constants.DEPOSIT_LIST:
        PayTypeList.append(var["desc"])

    if strPayType not in PayTypeList:
        raise exceptionLogic(errorLogic.pay_type_not_valid)

    if strPayType == enumPayType.BankTransfer:
        # 银行转账
        accountInfoList = yield from classSqlBaseMgr.getInstance().getAllBankInfo()

        objRsp.data = cData()
        objRsp.data.iCoin = "%.2f" % round(objPlayerData.iCoin / 100, 2)
        objRsp.data.iSaveCoin = "%.2f" % round(iCoin / 100, 2)
        try:
            objRsp.data.payeeCardInfo = random.choice(accountInfoList)
        except Exception as e:
            logging.error(repr(e))
            raise exceptionLogic(errorLogic.pay_channel_not_support)
        orderId=orderGeneral.generalOrderId()
        yield from generalPayOrder(orderId,"","",strAccountId,iCoin,dict_param.get("srcIp",""),"银行卡转账",
                               objRsp.data.payeeCardInfo["accountId"])

        # 构造回包
        objRsp.data.payOrder = orderId
        return classJsonDump.dumps(objRsp)

    elif strPayType == enumPayType.AlipayTransfer:
        # 支付宝转账
        accountInfoList = yield from classSqlBaseMgr.getInstance().getAllAlipayInfo()

        objRsp.data = cData()
        objRsp.data.iCoin = "%.2f" % round(objPlayerData.iCoin / 100, 2)
        objRsp.data.iSaveCoin = "%.2f" % round(iCoin / 100, 2)
        try:
            objRsp.data.payeeCardInfo = random.choice(accountInfoList)
        except Exception as e:
            logging.error(repr(e))
            raise exceptionLogic(errorLogic.pay_channel_not_support)
        orderId = orderGeneral.generalOrderId()
        yield from generalPayOrder(orderId, "","", strAccountId, iCoin, dict_param.get("srcIp", ""),
                                   "支付宝转账",objRsp.data.payeeCardInfo["accountId"])
        objRsp.data.payOrder = orderId
        return classJsonDump.dumps(objRsp)

    elif strPayType == enumPayType.WeixinTransfer:
        # 微信转账
        accountInfoList = yield from classSqlBaseMgr.getInstance().getAllWeixinInfo()

        objRsp.data = cData()
        objRsp.data.iCoin = "%.2f" % round(objPlayerData.iCoin / 100, 2)
        objRsp.data.iSaveCoin = "%.2f" % round(iCoin / 100, 2)
        try:
            objRsp.data.payeeCardInfo = random.choice(accountInfoList)
        except Exception as e:
            logging.error(repr(e))
            raise exceptionLogic(errorLogic.pay_channel_not_support)
        orderId = orderGeneral.generalOrderId()
        yield from generalPayOrder(orderId, "","", strAccountId, iCoin, dict_param.get("srcIp", ""),
                                   "微信转账",objRsp.data.payeeCardInfo["accountId"])
        objRsp.data.payOrder = orderId
        return classJsonDump.dumps(objRsp)