📄 shopdemon.cpp
字号:
// ShopDemon.cpp: implementation of the CShopDemon class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ShopDemon.h"
#include "./China/QueryDBSocket.h"
#include "LottoDBMgr.h"
extern CQueryDBSocket *ConQ;
extern int GetLoginIdByName( char *name, char *login_id );
extern char* EatRearWhiteChar( char* pStr );
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CShopDemon* CShopDemon::m_pClass = NULL;
CShopDemon::CShopDemon()
{
m_pClass = this;
}
CShopDemon::~CShopDemon()
{
m_pClass = NULL;
}
//讥矫胶袍篮. 蜡历狼 汗鼻荤扁 夸没沥焊甫 苞陛 矫胶袍狼 牢刘阑 扁促府扁 困秦 烙矫 焊包 秦敌促.
//捞皋技瘤绰 搞辑滚俊辑 罐绰促.
void CShopDemon::RecvCanBuyLotto(t_BUY_LOTTO *pCanBuy, int cn)
{
t_LottoBuySave LottoBuySave = {0,};
char LogInID[20] = {NULL,};
memcpy(&LottoBuySave.Buy_Lotto,pCanBuy,sizeof(t_BUY_LOTTO));
LottoBuySave.cn = cn;
if(!::GetLoginIdByName(pCanBuy->strCharName,LogInID))
{
DebugPrintf("CShopDemon::RecvCanBuyLotto() Error ==> GetLoginIdByName: CharName = %s",pCanBuy->strCharName);
return;
}
memcpy(LottoBuySave.szUserID,LogInID,sizeof(char)*20);
::EatRearWhiteChar(LottoBuySave.szUserID);
DebugPrintf("ShopSytem Push LottoUser char : %s , UserID : %s",LottoBuySave.Buy_Lotto.strCharName,LottoBuySave.szUserID);
m_ltLottoBuySaveList.push_back(LottoBuySave);//烙矫府胶飘俊 历厘.
//咯扁辑 苞陛 辑滚肺 倔付唱 捣捞 乐绰瘤 舅酒 焊扁 困秦 焊辰促.
//荤侩磊 酒捞叼客 捣阑 淬阑荐 乐绰 函荐客 绢恫 前格阑 荤扁困茄 沥焊牢瘤 淬阑荐 乐绰 函荐甫 父甸绢具瘤.^^
st_SHOP_SYSTEM_POINT stPoint = {0,};
stPoint.nPoint = -1;
stPoint.nShoppingType = LOTTO_SYSTEM;
stPoint.nSuccess = 0;
memcpy(stPoint.szID,LogInID,sizeof(char)*20);
::EatRearWhiteChar(stPoint.szID);
//咯扁辑 苞陛 辑滚肺 焊辰促.
if(ConQ != NULL)
{
DebugPrintf("ShopSystem Send : ConQ->Send_Data_To_Server ======> RecvCanBuyLotto()");
ConQ->Send_Data_To_Server(SHOP_SYSTEM_POINT_INFO,&stPoint,sizeof(st_SHOP_SYSTEM_POINT));
}
else
{
DebugPrintf("CShopDemon::RecvCanBuyLotto() ======> ConQ is NULL");
}
}
void CShopDemon::RecvShopProcess(int nProtocol, void *data, int datasize)
{
switch(nProtocol)
{
case SHOP_SYSTEM_POINT_INFO_RETURN:
{
st_SHOP_SYSTEM_POINT stPoint = {0,};
memcpy(&stPoint,data,datasize);
::EatRearWhiteChar(stPoint.szID);
if(stPoint.nSuccess == SHOP_OK)//己傍 沁促.
{
switch(stPoint.nShoppingType)
{
case LOTTO_SYSTEM:
{
for(ITOR_BUYSAVE i = m_ltLottoBuySaveList.begin();i != m_ltLottoBuySaveList.end();++i)
{
if(strcmp((*i).szUserID,stPoint.szID) == 0)//府胶飘俊 乐促.
{
if( stPoint.nPoint >= LottoDBMgr()->GetLottoPay() )//捣篮 面盒窍促.
{
t_packet p;
p.h.header.type = CMD_CAN_BUY;
p.h.header.size = sizeof(t_BUY_LOTTO);
strcpy(p.u.Lotto_Buy.strCharName,(*i).Buy_Lotto.strCharName);
p.u.Lotto_Buy.nLottoID = (*i).Buy_Lotto.nLottoID;
int nBuyCount = LottoDBMgr()->GetBuyCountByUser((*i).szUserID, (*i).Buy_Lotto.nLottoID);
if(nBuyCount == 0)//公炼扒 混荐 乐促.
{
memcpy(p.u.Lotto_Buy.anLottoNumber,(*i).Buy_Lotto.anLottoNumber,sizeof(int)*10);
}
else//soto-Lotto眠啊 if(nBuyCount < 5)// 吝汗 锅龋 八荤甫 秦具茄促.
{
if(!LottoDBMgr()->ExistLottoNumber((*i).Buy_Lotto.anLottoNumber,(*i).szUserID,(*i).Buy_Lotto.nLottoID))//吝汗 登瘤 臼疽促.
{
memcpy(p.u.Lotto_Buy.anLottoNumber,(*i).Buy_Lotto.anLottoNumber,sizeof(int)*10);
}
else//吝汗 登绰 锅龋啊 乐促.
{
p.u.Lotto_Buy.anLottoNumber[0] = -3; // -3 吝汗 登绰 锅龋.
}
}
//soto-Lotto 眠啊
/*
else//混荐 乐绰 父怒 促或促.
{
p.u.Lotto_Buy.anLottoNumber[0] = -2; // -2 汗鼻阑 腹捞 或促.
}
*/
QueuePacket(connections,(*i).cn,&p,1);
}
else// 捣捞 葛磊扼促.
{
DebugPrintf("ShopSystem : Less Money");
t_packet p2;
p2.h.header.type = CMD_CAN_BUY;
p2.h.header.size = sizeof(t_BUY_LOTTO);
strcpy(p2.u.Lotto_Buy.strCharName,(*i).Buy_Lotto.strCharName);
p2.u.Lotto_Buy.nLottoID = (*i).Buy_Lotto.nLottoID;
p2.u.Lotto_Buy.anLottoNumber[0] = 0;//锅龋狼 盖菊捞 0捞搁 捣捞 葛磊扼促.
QueuePacket(connections,(*i).cn,&p2,1);
}
m_ltLottoBuySaveList.erase(i);
break;//for 巩阑 狐廉 唱埃促.
}
}
}
break;
}
}
else
{
}
}
break;
case SHOP_SYSTEM_DEDUCT_POINT_RETURN:
{
st_SHOP_SYSTEM_POINT_REDUCT stRecvPointReturn;
memcpy(&stRecvPointReturn,data,datasize);
if(stRecvPointReturn.stShopSystemPoint.nSuccess == SHOP_OK)
{
/* switch(stRecvPointReturn.stShopSystemPoint.nShoppingType)
{
case LOTTO_SYSTEM:
{
for(ITOR_BUYSAVE i = m_ltLottoBuySaveList.begin();i != m_ltLottoBuySaveList.end();++i)
{
}
}
break;
}
*/
}
else//己傍 窍瘤 给沁促. //point DB 俊 绝芭唱..//捣捞 葛磊扼促.
{
switch(stRecvPointReturn.stShopSystemPoint.nShoppingType)
{
case LOTTO_SYSTEM:
{
DebugPrintf("ShopSystem Deduct failed : ID = %s, DeductPoint = %d,",stRecvPointReturn.stShopSystemPoint.szID,
stRecvPointReturn.nDeductPoint);
}
break;
}
}
}
break;
}
}
void CShopDemon::RecvLottoBuy(t_BUY_LOTTO *pBuyLotto, int cn)
{
LottoDBMgr()->RecvLottoBuy(pBuyLotto);//叼厚俊 扁废阑 茄促.
char LogInID[20] = {NULL,};
::GetLoginIdByName(pBuyLotto->strCharName,LogInID);
st_SHOP_SYSTEM_POINT_REDUCT stLottoBuy = {0,};
memcpy(stLottoBuy.stShopSystemPoint.szID,LogInID,sizeof(char)*20);
::EatRearWhiteChar(stLottoBuy.stShopSystemPoint.szID);
stLottoBuy.stShopSystemPoint.nPoint = -1;
stLottoBuy.stShopSystemPoint.nShoppingType = LOTTO_SYSTEM;
stLottoBuy.stShopSystemPoint.nSuccess = 0;
stLottoBuy.nDeductPoint = LottoDBMgr()->GetLottoPay();
stLottoBuy.szKey[0] = (char)pBuyLotto->anLottoNumber[0];//咯扁俊 肺肚 锅龋啊 甸绢埃促.
stLottoBuy.szKey[1] = (char)pBuyLotto->anLottoNumber[1];
stLottoBuy.szKey[2] = (char)pBuyLotto->anLottoNumber[2];
stLottoBuy.szKey[3] = (char)pBuyLotto->anLottoNumber[3];
stLottoBuy.szKey[4] = (char)pBuyLotto->anLottoNumber[4];
stLottoBuy.szKey[5] = (char)pBuyLotto->anLottoNumber[5];
stLottoBuy.szKey[6] = (char)pBuyLotto->anLottoNumber[6];
stLottoBuy.szKey[7] = (char)pBuyLotto->anLottoNumber[7];
stLottoBuy.szKey[8] = (char)pBuyLotto->anLottoNumber[8];
stLottoBuy.szKey[9] = (char)pBuyLotto->anLottoNumber[9];
if(ConQ)
{
DebugPrintf("ShopSytem Send: ConQ->Send_Data_To_Server() =====> RecvLottoBuy()");
ConQ->Send_Data_To_Server(SHOP_SYSTEM_DEDUCT_POINT,&stLottoBuy,sizeof(st_SHOP_SYSTEM_POINT_REDUCT));
}
else
{
DebugPrintf("CShopDemon::RecvLottoBuy() ======> ConQ is NULL");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -