Exemple #1
0
void CDealFrame18::Deal( CRCClient* poClinet,UINT32 dwSerialNumber,UINT32 dwAreaID,UINT32 dwPlayerID,map<string,string> &mapField )
{
    if (NULL == poClinet)
    {
        return;
    }

    if (mapField[ALL_GOLD_COUNT_PARAM].empty())
    {
        string strErrorMsg = GetRsponeResult(ERR_GM_PARM_INFO::ID_PARAM_ERR);
        poClinet->Rspone(strErrorMsg.c_str());
        return;
    }

    UINT32 qwParam1 = SDAtou(mapField[ALL_GOLD_COUNT_PARAM].c_str());
    UINT16 wErrCode = CGMProcessor::GmReq(dwSerialNumber,(UINT8)GetFrameType(), 0,qwParam1,0,0,"",poClinet->GetCliSessionID(), mapField["desc"].c_str());
    if (ERR_GM_PARM_INFO::ID_PLAYER_NOT_MEMORT == wErrCode)
        return;
    const CID2PlayerMap &mapID2PlayerMap = CPlayerMgr::Instance()->GetID2PlayerMap();

    if (0 == mapID2PlayerMap.size())
    {
        string strErrorMsg = GetRsponeResult(ERR_GM_PARM_INFO::ID_NOT_DATA);
        poClinet->Rspone(strErrorMsg.c_str());
        return;
    }

    CID2PlayerMapConstItr iter;

    for (iter = mapID2PlayerMap.begin(); iter != mapID2PlayerMap.end(); iter++)
    {
        CPlayer *pPlayer = iter->second;

        if (NULL == pPlayer)
        {
            continue;
        }

        pPlayer->AddGold(qwParam1,CRecordMgr::EGGT_GETGIVEGM);
    }


    string strRetInfo = GetRsponeResult(ERR_GM_PARM_INFO::ID_SUCCESS);
    poClinet->Rspone(strRetInfo.c_str());
}
/**
* @brief 同步执行SQL命令相关的逻辑部分
* @return VOID
*/
VOID SDAPI CSetAppPayProcessed::OnExecuted()
{
    if( !m_bSuccess )
    {
        return;
    }

    //数据处理成功,增加元宝,通知客户端(如果接收元宝的玩家和接收通知的玩家不是同一个,那么则需要分开取数据)
    CPlayer *pPlayer = CPlayerMgr::Instance()->FindPlayer( m_stAppPayProcessed.dwPlayerID );
    if( NULL == pPlayer )
    {

        //如果玩家不在线,则调出玩家,以设置数据
        CGetPlayerDataMgr::Instance()->GetPlayerData(0 , GET_PLAYERDATATYPE_EXCHANGE, m_stAppPayProcessed.dwPlayerID,
                m_stAppPayProcessed.dwQueryPlayer, m_stAppPayProcessed.dwGold, m_stAppPayProcessed.dwRMB, (char *)m_stAppPayProcessed.strOrderID.c_str() );
        return;
    }

    //玩家在线,则增加元宝
    pPlayer->AddGold( m_stAppPayProcessed.dwGold, CRecordMgr::EGGT_ADDFLAGEXCHANGE, 0, 0, 0, 0, m_stAppPayProcessed.strOrderID, m_stAppPayProcessed.dwRMB);
    _SDTStrcpy( pPlayer->GetLastOrderID(), m_stAppPayProcessed.strOrderID.c_str() );

    //并且通知玩家
    CPlayer *pNotifyPlayer = CPlayerMgr::Instance()->FindPlayer( m_stAppPayProcessed.dwQueryPlayer );
    if( !pNotifyPlayer )
    {
        //被通知玩家不在线,则不通知
        USR_INFO( _SDT("[%s:%d]Query player pay, but can't find query player:%u in memory"), MSG_MARK, m_stAppPayProcessed.dwQueryPlayer );
        return;
    }

    UINT32 dwMsgID = INVALID_MSGID;
    //基础数据(如果被通知玩家和充值玩家不是同一个,那么这么做也没关系,因为如果不是同一个,那么客户端不提示具体的充值情况,所以可以随便赋值)
    DT_PLAYER_BASE_DATA stDT_PLAYER_BASE_DATA = pNotifyPlayer->GetDT_PLAYER_BASE_DATA();
    dwMsgID = CGTPktBuilder::Instance()->OnAppPaySuccess( stDT_PLAYER_BASE_DATA.byVipLevel, stDT_PLAYER_BASE_DATA.dwTotalAmount, stDT_PLAYER_BASE_DATA.qwGold, m_stAppPayProcessed.dwGold, m_stAppPayProcessed.strOrderID, stDT_PLAYER_BASE_DATA.dwID);
    if( dwMsgID == INVALID_MSGID )
    {
        return;
    }

    pNotifyPlayer->SendMsg( CGTPktBuilder::Instance()->GetPacketBuffer(), dwMsgID );
}