Skip to content

Commit d41c583

Browse files
committed
准备添加充值机制
1 parent f855ba3 commit d41c583

6 files changed

Lines changed: 63 additions & 24 deletions

File tree

‎kbe/res/server/kbengine_defs.xml‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@
3737
<host> localhost </host>
3838
<port> 30099 </port>
3939

40-
<!-- 第三方运营服务接口 如: www.google.com, 当type是thirdparty时有效 -->
41-
<thirdpartyService_addr></thirdpartyService_addr>
42-
<thirdpartyService_port> 80 </thirdpartyService_port>
40+
<!-- 第三方运营账号服务接口 如: www.google.com, 当type是thirdparty时有效 -->
41+
<thirdpartyAccountService_addr></thirdpartyAccountService_addr>
42+
<thirdpartyAccountService_port> 80 </thirdpartyAccountService_port>
43+
44+
<!-- 第三方运营充值服务接口 如: www.google.com, 当type是thirdparty时有效 -->
45+
<thirdpartyChargeService_addr></thirdpartyChargeService_addr>
46+
<thirdpartyChargeService_port> 80 </thirdpartyChargeService_port>
4347
</billingSystem>
4448

4549
<dbmgr>

‎kbe/src/lib/entitydef/datatype.cpp‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,8 +1443,8 @@ bool FixedDictType::isSameType(PyObject* pyValue)
14431443
if(dictSize != (Py_ssize_t)keyTypes_.size())
14441444
{
14451445
PyErr_Format(PyExc_TypeError,
1446-
"FIXED_DICT key no match. size:%d-%d, keyNames=[%s].",
1447-
dictSize, keyTypes_.size(),
1446+
"FIXED_DICT(%s) key no match. size:%d-%d, keyNames=[%s].",
1447+
this->aliasName(),dictSize, keyTypes_.size(),
14481448
getKeyNames().c_str());
14491449

14501450
PyErr_PrintEx(0);
@@ -1528,7 +1528,14 @@ void FixedDictType::addToStreamEx(MemoryStream* mstream, PyObject* pyValue, bool
15281528
PyObject* pyObject =
15291529
PyDict_GetItemString(pydict, const_cast<char*>(iter->first.c_str()));
15301530

1531-
KBE_ASSERT(pyObject != NULL);
1531+
if(pyObject == NULL)
1532+
{
1533+
ERROR_MSG(boost::format("FixedDictType::addToStreamEx: %1% not found key[%2%]. keyNames:%3%\n") %
1534+
this->aliasName_ % iter->first % this->getKeyNames());
1535+
1536+
KBE_ASSERT(pyObject != NULL);
1537+
}
1538+
15321539
iter->second->dataType->addToStream(mstream, pyObject);
15331540
}
15341541

‎kbe/src/lib/server/serverconfig.cpp‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ ServerConfig::ServerConfig():
3232
gameUpdateHertz_(10),
3333
billingSystemAddr_(),
3434
billingSystem_type_(""),
35-
billingSystem_thirdpartyServiceAddr_(""),
36-
billingSystem_thirdpartyServicePort_(80)
35+
billingSystem_thirdpartyAccountServiceAddr_(""),
36+
billingSystem_thirdpartyAccountServicePort_(80),
37+
billingSystem_thirdpartyChargeServiceAddr_(""),
38+
billingSystem_thirdpartyChargeServicePort_(80)
3739
{
3840
}
3941

@@ -164,17 +166,31 @@ bool ServerConfig::loadConfig(std::string fileName)
164166
}
165167

166168
childnode = NULL;
167-
childnode = xml->enterNode(rootNode, "thirdpartyService_addr");
169+
childnode = xml->enterNode(rootNode, "thirdpartyAccountService_addr");
168170
if(childnode)
169171
{
170-
billingSystem_thirdpartyServiceAddr_ = xml->getValStr(childnode);
172+
billingSystem_thirdpartyAccountServiceAddr_ = xml->getValStr(childnode);
171173
}
172174

173175
childnode = NULL;
174-
childnode = xml->enterNode(rootNode, "thirdpartyService_port");
176+
childnode = xml->enterNode(rootNode, "thirdpartyAccountService_port");
175177
if(childnode)
176178
{
177-
billingSystem_thirdpartyServicePort_ = xml->getValInt(childnode);
179+
billingSystem_thirdpartyAccountServicePort_ = xml->getValInt(childnode);
180+
}
181+
182+
childnode = NULL;
183+
childnode = xml->enterNode(rootNode, "thirdpartyChargeService_addr");
184+
if(childnode)
185+
{
186+
billingSystem_thirdpartyChargeServiceAddr_ = xml->getValStr(childnode);
187+
}
188+
189+
childnode = NULL;
190+
childnode = xml->enterNode(rootNode, "thirdpartyChargeService_port");
191+
if(childnode)
192+
{
193+
billingSystem_thirdpartyChargeServicePort_ = xml->getValInt(childnode);
178194
}
179195
}
180196

‎kbe/src/lib/server/serverconfig.hpp‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,11 @@ class ServerConfig : public Singleton<ServerConfig>
130130

131131
inline const char* billingSystemType()const { return billingSystem_type_.c_str(); }
132132

133-
inline const char* billingSystemThirdpartyServiceAddr()const { return billingSystem_thirdpartyServiceAddr_.c_str(); }
134-
inline uint16 billingSystemThirdpartyServicePort()const { return billingSystem_thirdpartyServicePort_; }
133+
inline const char* billingSystemThirdpartyAccountServiceAddr()const { return billingSystem_thirdpartyAccountServiceAddr_.c_str(); }
134+
inline uint16 billingSystemThirdpartyAccountServicePort()const { return billingSystem_thirdpartyAccountServicePort_; }
135+
136+
inline const char* billingSystemThirdpartyChargeServiceAddr()const { return billingSystem_thirdpartyChargeServiceAddr_.c_str(); }
137+
inline uint16 billingSystemThirdpartyChargeServicePort()const { return billingSystem_thirdpartyChargeServicePort_; }
135138
private:
136139
ENGINE_COMPONENT_INFO _cellAppInfo;
137140
ENGINE_COMPONENT_INFO _baseAppInfo;
@@ -151,9 +154,11 @@ class ServerConfig : public Singleton<ServerConfig>
151154
uint32 bitsPerSecondToClient_;
152155

153156
Mercury::Address billingSystemAddr_;
154-
std::string billingSystem_type_; // 计费系统类别
155-
std::string billingSystem_thirdpartyServiceAddr_; // 第三方运营服务地址(当type是thirdparty时有效)
156-
uint16 billingSystem_thirdpartyServicePort_;
157+
std::string billingSystem_type_; // 计费系统类别
158+
std::string billingSystem_thirdpartyAccountServiceAddr_; // 第三方运营账号服务地址(当type是thirdparty时有效)
159+
uint16 billingSystem_thirdpartyAccountServicePort_;
160+
std::string billingSystem_thirdpartyChargeServiceAddr_; // 第三方运营充值服务地址(当type是thirdparty时有效)
161+
uint16 billingSystem_thirdpartyChargeServicePort_;
157162
};
158163

159164
#define g_kbeSrvConfig ServerConfig::getSingleton()

‎kbe/src/server/dbmgr/dbmgr.cpp‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,18 @@ bool Dbmgr::initBillingHandler()
186186
g_kbeSrvConfig.billingSystemAddr().c_str() %
187187
g_kbeSrvConfig.billingSystemType());
188188

189-
if(strlen(g_kbeSrvConfig.billingSystemThirdpartyServiceAddr()) > 0)
189+
if(strlen(g_kbeSrvConfig.billingSystemThirdpartyAccountServiceAddr()) > 0)
190190
{
191-
INFO_MSG(boost::format("Dbmgr::initBillingHandler: thirdpartyService_addr(%1%:%2%).\n") %
192-
g_kbeSrvConfig.billingSystemThirdpartyServiceAddr() %
193-
g_kbeSrvConfig.billingSystemThirdpartyServicePort());
191+
INFO_MSG(boost::format("Dbmgr::initBillingHandler: thirdpartyAccountService_addr(%1%:%2%).\n") %
192+
g_kbeSrvConfig.billingSystemThirdpartyAccountServiceAddr() %
193+
g_kbeSrvConfig.billingSystemThirdpartyAccountServicePort());
194+
}
195+
196+
if(strlen(g_kbeSrvConfig.billingSystemThirdpartyChargeServiceAddr()) > 0)
197+
{
198+
INFO_MSG(boost::format("Dbmgr::initBillingHandler: thirdpartyChargeService_addr(%1%:%2%).\n") %
199+
g_kbeSrvConfig.billingSystemThirdpartyChargeServiceAddr() %
200+
g_kbeSrvConfig.billingSystemThirdpartyChargeServicePort());
194201
}
195202

196203
return pBillingHandler_->initialize();

‎kbe/src/server/tools/billing_system/billing_tasks.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ CreateAccountTask::~CreateAccountTask()
7373
bool CreateAccountTask::process()
7474
{
7575
// 如果没有设置第三方服务地址则我们默认为成功
76-
if(strlen(g_kbeSrvConfig.billingSystemThirdpartyServiceAddr()) == 0)
76+
if(strlen(g_kbeSrvConfig.billingSystemThirdpartyAccountServiceAddr()) == 0)
7777
{
7878
success = true;
7979
getDatas = postDatas;
@@ -98,7 +98,7 @@ bool CreateAccountTask::process()
9898
endpoint.setnonblocking(true);
9999

100100
u_int32_t addr;
101-
KBEngine::Mercury::EndPoint::convertAddress(g_kbeSrvConfig.billingSystemThirdpartyServiceAddr(), addr);
101+
KBEngine::Mercury::EndPoint::convertAddress(g_kbeSrvConfig.billingSystemThirdpartyAccountServiceAddr(), addr);
102102

103103
int trycount = 0;
104104

@@ -112,7 +112,7 @@ bool CreateAccountTask::process()
112112
FD_SET((int)endpoint, &frds);
113113
FD_SET((int)endpoint, &fwds);
114114

115-
if(endpoint.connect(htons(g_kbeSrvConfig.billingSystemThirdpartyServicePort()), addr) == -1)
115+
if(endpoint.connect(htons(g_kbeSrvConfig.billingSystemThirdpartyAccountServicePort()), addr) == -1)
116116
{
117117
int selgot = select(endpoint+1, &frds, &fwds, NULL, &tv);
118118
if(selgot > 0)

0 commit comments

Comments
 (0)