pay beta
This commit is contained in:
parent
3bba37972a
commit
3d63d7e92a
@ -11,11 +11,14 @@
|
|||||||
#include <a8/uuid.h>
|
#include <a8/uuid.h>
|
||||||
|
|
||||||
#include "framework/cpp/netmsghandler.h"
|
#include "framework/cpp/netmsghandler.h"
|
||||||
|
#include "framework/cpp/msgqueue.h"
|
||||||
|
#include "framework/cpp/httpclientpool.h"
|
||||||
|
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "jsondatamgr.h"
|
#include "jsondatamgr.h"
|
||||||
#include "handlermgr.h"
|
#include "handlermgr.h"
|
||||||
#include "ApiListener.h"
|
#include "ApiListener.h"
|
||||||
|
#include "ordermgr.h"
|
||||||
|
|
||||||
struct MsgNode
|
struct MsgNode
|
||||||
{
|
{
|
||||||
@ -78,6 +81,8 @@ void App::Init(int argc, char* argv[])
|
|||||||
msg_mutex_ = new std::mutex();
|
msg_mutex_ = new std::mutex();
|
||||||
im_msg_mutex_ = new std::mutex();
|
im_msg_mutex_ = new std::mutex();
|
||||||
|
|
||||||
|
g_nowtime = time(nullptr);
|
||||||
|
|
||||||
srand(time(nullptr));
|
srand(time(nullptr));
|
||||||
InitLog();
|
InitLog();
|
||||||
HandlerMgr::Instance()->Init();
|
HandlerMgr::Instance()->Init();
|
||||||
@ -85,6 +90,9 @@ void App::Init(int argc, char* argv[])
|
|||||||
JsonDataMgr::Instance()->Init();
|
JsonDataMgr::Instance()->Init();
|
||||||
uuid.SetMachineId(instance_id);
|
uuid.SetMachineId(instance_id);
|
||||||
ApiListener::Instance()->Init();
|
ApiListener::Instance()->Init();
|
||||||
|
OrderMgr::Instance()->Init();
|
||||||
|
f8::MsgQueue::Instance()->Init();
|
||||||
|
f8::HttpClientPool::Instance()->Init(10);
|
||||||
|
|
||||||
a8::UdpLog::Instance()->Info("payserver starting instance_id:%d pid:%d", {instance_id, getpid()});
|
a8::UdpLog::Instance()->Info("payserver starting instance_id:%d pid:%d", {instance_id, getpid()});
|
||||||
{
|
{
|
||||||
@ -110,6 +118,8 @@ void App::UnInit()
|
|||||||
JsonDataMgr::Instance()->UnInit();
|
JsonDataMgr::Instance()->UnInit();
|
||||||
a8::Timer::Instance()->UnInit();
|
a8::Timer::Instance()->UnInit();
|
||||||
HandlerMgr::Instance()->UnInit();
|
HandlerMgr::Instance()->UnInit();
|
||||||
|
f8::HttpClientPool::Instance()->UnInit();
|
||||||
|
f8::MsgQueue::Instance()->UnInit();
|
||||||
UnInitLog();
|
UnInitLog();
|
||||||
|
|
||||||
delete im_msg_mutex_;
|
delete im_msg_mutex_;
|
||||||
@ -130,6 +140,7 @@ int App::Run()
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
a8::UdpLog::Instance()->Info("payserver running", {});
|
a8::UdpLog::Instance()->Info("payserver running", {});
|
||||||
while (!terminated) {
|
while (!terminated) {
|
||||||
|
g_nowtime = time(nullptr);
|
||||||
a8::tick_t begin_tick = a8::XGetTickCount();
|
a8::tick_t begin_tick = a8::XGetTickCount();
|
||||||
QuickExecute();
|
QuickExecute();
|
||||||
SlowerExecute();
|
SlowerExecute();
|
||||||
@ -199,6 +210,7 @@ void App::QuickExecute()
|
|||||||
ProcessIMMsg();
|
ProcessIMMsg();
|
||||||
DispatchMsg();
|
DispatchMsg();
|
||||||
a8::Timer::Instance()->Update();
|
a8::Timer::Instance()->Update();
|
||||||
|
OrderMgr::Instance()->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::SlowerExecute()
|
void App::SlowerExecute()
|
||||||
@ -310,6 +322,15 @@ void App::ProcessIMMsg()
|
|||||||
while (im_work_node_) {
|
while (im_work_node_) {
|
||||||
IMMsgNode *pdelnode = im_work_node_;
|
IMMsgNode *pdelnode = im_work_node_;
|
||||||
switch (im_work_node_->msgid) {
|
switch (im_work_node_->msgid) {
|
||||||
|
case f8::IM_SysMsgQueue:
|
||||||
|
{
|
||||||
|
const a8::XParams* param = (const a8::XParams*)pdelnode->params.param1.GetUserData();
|
||||||
|
f8::MsgQueue::Instance()->ProcessMsg(pdelnode->params.sender.GetInt(),
|
||||||
|
*param
|
||||||
|
);
|
||||||
|
delete param;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case IM_ExecGM:
|
case IM_ExecGM:
|
||||||
{
|
{
|
||||||
HandlerMgr::Instance()->ProcGMMsg(pdelnode->params.param3,
|
HandlerMgr::Instance()->ProcGMMsg(pdelnode->params.param3,
|
||||||
|
4
server/payserver/global.cc
Normal file
4
server/payserver/global.cc
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#include "precompile.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
time_t g_nowtime = 0;
|
3
server/payserver/global.h
Normal file
3
server/payserver/global.h
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
extern time_t g_nowtime;
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "handlermgr.h"
|
#include "handlermgr.h"
|
||||||
#include "ApiListener.h"
|
#include "ApiListener.h"
|
||||||
|
#include "ordermgr.h"
|
||||||
|
|
||||||
static void _GMOpsSelfChecking(f8::JsonHttpRequest* request)
|
static void _GMOpsSelfChecking(f8::JsonHttpRequest* request)
|
||||||
{
|
{
|
||||||
@ -15,14 +16,114 @@ static void _GMOpsSelfChecking(f8::JsonHttpRequest* request)
|
|||||||
|
|
||||||
static void _GMPayGetOrderId(f8::JsonHttpRequest* request)
|
static void _GMPayGetOrderId(f8::JsonHttpRequest* request)
|
||||||
{
|
{
|
||||||
request->resp_xobj->SetVal("errcode", 0);
|
int errcode = 0;
|
||||||
request->resp_xobj->SetVal("errmsg", "");
|
std::string errmsg = "";
|
||||||
|
#if 0
|
||||||
|
int seqid = OrderMgr::Instance()->AddOrder(
|
||||||
|
"",
|
||||||
|
request->request.Get("accountid").GetString(),
|
||||||
|
request->request.Get("roleid").GetString(),
|
||||||
|
request->request.Get("rolename").GetString(),
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
0,
|
||||||
|
request->request.Get("itemid").GetInt(),
|
||||||
|
request->request.Get("price").GetInt(),
|
||||||
|
request->request.Get("sp_orderid").GetString()
|
||||||
|
);
|
||||||
|
AddOrderResult addresult;
|
||||||
|
if (OrderMgr::Instance()->WaitForAddOrderFinished(seqid, addresult, 20)) {
|
||||||
|
if (addresult.isok) {
|
||||||
|
request->resp_xobj->SetVal("orderid", addresult.orderinfo.orderid);
|
||||||
|
request->resp_xobj->SetVal("itemid", addresult.orderinfo.itemid);
|
||||||
|
request->resp_xobj->SetVal("price", addresult.orderinfo.price);
|
||||||
|
request->resp_xobj->SetVal("roleid", addresult.orderinfo.roleid);
|
||||||
|
request->resp_xobj->SetVal("channel", addresult.orderinfo.channel);
|
||||||
|
#if 0
|
||||||
|
request->resp_xobj->SetVal("PartnerUserID", addresult.orderinfo.sp_accountid);
|
||||||
|
request->resp_xobj->SetVal("PrivateInfo", "");
|
||||||
|
request->resp_xobj->SetVal("ProductName", addresult.orderinfo.itemname);
|
||||||
|
request->resp_xobj->SetVal("ProductMemo", addresult.orderinfo.itemmemo);
|
||||||
|
request->resp_xobj->SetVal("Channel", addresult.orderinfo.channel);
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
errcode = 1;
|
||||||
|
errmsg = "道具id不存在";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errcode = 2;
|
||||||
|
errmsg = "Fail";
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
OrderInfo orderinfo;
|
||||||
|
if (OrderMgr::Instance()->AddNewOrder(
|
||||||
|
request->request.Get("accountid").GetString(),
|
||||||
|
request->request.Get("serverid").GetInt(),
|
||||||
|
request->request.Get("roleid").GetString(),
|
||||||
|
request->request.Get("rolename").GetString(),
|
||||||
|
request->request.Get("itemid").GetInt(),
|
||||||
|
request->request.Get("price").GetInt(),
|
||||||
|
request->request.Get("sp_orderid").GetString(),
|
||||||
|
orderinfo
|
||||||
|
)) {
|
||||||
|
request->resp_xobj->SetVal("orderid", orderinfo.orderid);
|
||||||
|
request->resp_xobj->SetVal("itemid", orderinfo.itemid);
|
||||||
|
request->resp_xobj->SetVal("price", orderinfo.price);
|
||||||
|
request->resp_xobj->SetVal("roleid", orderinfo.roleid);
|
||||||
|
request->resp_xobj->SetVal("channel", orderinfo.channel);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
errcode = 1;
|
||||||
|
errmsg = "Fail";
|
||||||
|
}
|
||||||
|
request->resp_xobj->SetVal("errcode", errcode);
|
||||||
|
request->resp_xobj->SetVal("errmsg", errmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _GMPayNotify(f8::JsonHttpRequest* request)
|
static void _GMPayNotify(f8::JsonHttpRequest* request)
|
||||||
{
|
{
|
||||||
request->resp_xobj->SetVal("errcode", 0);
|
int errcode = 0;
|
||||||
request->resp_xobj->SetVal("errmsg", "");
|
std::string errmsg = "";
|
||||||
|
#if 0
|
||||||
|
int seqid = OrderMgr::Instance()->AddPayNotify(
|
||||||
|
request->request.Get("pay_type").GetInt(),
|
||||||
|
request->request.Get("accountid").GetString(),
|
||||||
|
request->request.Get("roleid").GetString(),
|
||||||
|
request->request.Get("rolename").GetString(),
|
||||||
|
0,
|
||||||
|
request->request.Get("itemid").GetInt(),
|
||||||
|
"",
|
||||||
|
request->request.Get("orderid").GetString(),
|
||||||
|
request->request.Get("sp_orderid").GetString(),
|
||||||
|
request->request.Get("fee").GetDouble(),
|
||||||
|
request->request.Get("payresult").GetInt()
|
||||||
|
);
|
||||||
|
int result = 1;
|
||||||
|
if (OrderMgr::Instance()->WaitForPayNotifyFinished(seqid, result, 20)) {
|
||||||
|
if (result == 0) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
errcode = 1;
|
||||||
|
errmsg = "failed";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errcode = 2;
|
||||||
|
errmsg = "failed";
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
int result = 1;
|
||||||
|
OrderMgr::Instance()->AddNewPayNotify(
|
||||||
|
request->request.Get("pay_type").GetInt(),
|
||||||
|
request->request.Get("orderid").GetString(),
|
||||||
|
request->request.Get("payresult").GetInt(),
|
||||||
|
result
|
||||||
|
);
|
||||||
|
if (result != 0) {
|
||||||
|
errcode = 1;
|
||||||
|
errmsg = "failed";
|
||||||
|
}
|
||||||
|
request->resp_xobj->SetVal("errcode", errcode);
|
||||||
|
request->resp_xobj->SetVal("errmsg", errmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandlerMgr::Init()
|
void HandlerMgr::Init()
|
||||||
|
@ -7,17 +7,22 @@ void JsonDataMgr::Init()
|
|||||||
{
|
{
|
||||||
std::string payserverserver_cluster_json_file;
|
std::string payserverserver_cluster_json_file;
|
||||||
std::string targetserver_cluster_json_file;
|
std::string targetserver_cluster_json_file;
|
||||||
|
std::string mysql_cluster_json_file;
|
||||||
if (f8::IsOnlineEnv()) {
|
if (f8::IsOnlineEnv()) {
|
||||||
payserverserver_cluster_json_file = a8::Format("../config/game%d.payserver.cluster.json", {GAME_ID});
|
payserverserver_cluster_json_file = a8::Format("../config/game%d.payserver.cluster.json", {GAME_ID});
|
||||||
targetserver_cluster_json_file = a8::Format("../config/game%d.gameserver.cluster.json", {GAME_ID});
|
targetserver_cluster_json_file = a8::Format("../config/game%d.gameserver.cluster.json", {GAME_ID});
|
||||||
|
mysql_cluster_json_file = a8::Format("../config/game%d.payserver.mysql.cluster.json", {GAME_ID});
|
||||||
} else {
|
} else {
|
||||||
payserverserver_cluster_json_file = a8::Format("/var/data/conf_test/game%d/payserver/game%d.payserver.cluster.json",
|
payserverserver_cluster_json_file = a8::Format("/var/data/conf_test/game%d/payserver/game%d.payserver.cluster.json",
|
||||||
{GAME_ID, GAME_ID});
|
{GAME_ID, GAME_ID});
|
||||||
targetserver_cluster_json_file = a8::Format("/var/data/conf_test/game%d/payserver/game%d.gameserver.cluster.json",
|
targetserver_cluster_json_file = a8::Format("/var/data/conf_test/game%d/payserver/game%d.gameserver.cluster.json",
|
||||||
{GAME_ID, GAME_ID});
|
{GAME_ID, GAME_ID});
|
||||||
|
mysql_cluster_json_file = a8::Format("/var/data/conf_test/game%d/payserver/game%d.payserver.mysql.cluster.json",
|
||||||
|
{GAME_ID, GAME_ID});
|
||||||
}
|
}
|
||||||
payserverserver_cluster_json_.ReadFromFile(payserverserver_cluster_json_file);
|
payserverserver_cluster_json_.ReadFromFile(payserverserver_cluster_json_file);
|
||||||
targetserver_cluster_json_.ReadFromFile(targetserver_cluster_json_file);
|
targetserver_cluster_json_.ReadFromFile(targetserver_cluster_json_file);
|
||||||
|
mysql_cluster_json_.ReadFromFile(mysql_cluster_json_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonDataMgr::UnInit()
|
void JsonDataMgr::UnInit()
|
||||||
@ -36,3 +41,19 @@ std::shared_ptr<a8::XObject> JsonDataMgr::GetTargetServerClusterConf()
|
|||||||
{
|
{
|
||||||
return std::make_shared<a8::XObject>(targetserver_cluster_json_);
|
return std::make_shared<a8::XObject>(targetserver_cluster_json_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<a8::XObject> JsonDataMgr::GetTargetServerClusterConf(int serverid)
|
||||||
|
{
|
||||||
|
if (serverid < 1 || serverid > targetserver_cluster_json_.Size()) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
return targetserver_cluster_json_[serverid - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<a8::XObject> JsonDataMgr::GetMysqlConf()
|
||||||
|
{
|
||||||
|
if (App::Instance()->instance_id < 1 || App::Instance()->instance_id > mysql_cluster_json_.Size()) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
return mysql_cluster_json_[App::Instance()->instance_id - 1];
|
||||||
|
}
|
||||||
|
@ -12,9 +12,12 @@ class JsonDataMgr : public a8::Singleton<JsonDataMgr>
|
|||||||
|
|
||||||
std::shared_ptr<a8::XObject> GetConf();
|
std::shared_ptr<a8::XObject> GetConf();
|
||||||
std::shared_ptr<a8::XObject> GetTargetServerClusterConf();
|
std::shared_ptr<a8::XObject> GetTargetServerClusterConf();
|
||||||
|
std::shared_ptr<a8::XObject> GetTargetServerClusterConf(int serverid);
|
||||||
|
std::shared_ptr<a8::XObject> GetMysqlConf();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
a8::XObject payserverserver_cluster_json_;
|
a8::XObject payserverserver_cluster_json_;
|
||||||
a8::XObject targetserver_cluster_json_;
|
a8::XObject targetserver_cluster_json_;
|
||||||
|
a8::XObject mysql_cluster_json_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
#include "precompile.h"
|
#include "precompile.h"
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include "ordermgr.h"
|
#include "ordermgr.h"
|
||||||
|
#include <a8/mysql.h>
|
||||||
|
#include <a8/udplog.h>
|
||||||
|
#include "jsondatamgr.h"
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "framework/cpp/utils.h"
|
||||||
|
#include "framework/cpp/httpclientpool.h"
|
||||||
|
#include <a8/mutable_xobject.h>
|
||||||
#if 0
|
#if 0
|
||||||
#include "DBSListener.h"
|
#include "DBSListener.h"
|
||||||
#endif
|
#endif
|
||||||
@ -68,14 +75,18 @@ void OrderMgr::Init()
|
|||||||
|
|
||||||
current_seqid_ = 1000;
|
current_seqid_ = 1000;
|
||||||
sub_orderid_ = 1;
|
sub_orderid_ = 1;
|
||||||
#if 0
|
|
||||||
last_gen_order_time_ = g_nowtime;
|
last_gen_order_time_ = g_nowtime;
|
||||||
#endif
|
|
||||||
last_ping_db_tick_ = a8::XGetTickCount();
|
last_ping_db_tick_ = a8::XGetTickCount();
|
||||||
#if 0
|
|
||||||
//assert(mysql_conn_.Connect("127.0.0.1", 3306, "root", "keji178", "paydb"));
|
//assert(mysql_conn_.Connect("127.0.0.1", 3306, "root", "keji178", "paydb"));
|
||||||
assert(mysql_conn_.Connect(g_mysql_host, 3306, g_mysql_user, g_mysql_passwd, "paydb"));
|
mysql_conn_ = new a8::mysql::Connection();
|
||||||
query_.SetConnection(&mysql_conn_);
|
query_ = mysql_conn_->CreateQuery();
|
||||||
|
assert(mysql_conn_->Connect(JsonDataMgr::Instance()->GetMysqlConf()->At("host")->AsXValue(),
|
||||||
|
JsonDataMgr::Instance()->GetMysqlConf()->At("port")->AsXValue(),
|
||||||
|
JsonDataMgr::Instance()->GetMysqlConf()->At("user")->AsXValue(),
|
||||||
|
JsonDataMgr::Instance()->GetMysqlConf()->At("passwd")->AsXValue(),
|
||||||
|
"paydb"));
|
||||||
|
f8::InitMysqlConnection(query_);
|
||||||
|
#if 0
|
||||||
DumpMysqlInfo(query_);
|
DumpMysqlInfo(query_);
|
||||||
RegisterNetMsgHandler<OrderMgr, SSMPing>(g_dbsmsghandler, &OrderMgr::_SSMPing);
|
RegisterNetMsgHandler<OrderMgr, SSMPing>(g_dbsmsghandler, &OrderMgr::_SSMPing);
|
||||||
RegisterNetMsgHandler<OrderMgr, D2PPayNotifyACK>(g_dbsmsghandler, &OrderMgr::_D2PPayNotifyACK);
|
RegisterNetMsgHandler<OrderMgr, D2PPayNotifyACK>(g_dbsmsghandler, &OrderMgr::_D2PPayNotifyACK);
|
||||||
@ -92,7 +103,7 @@ void OrderMgr::Update()
|
|||||||
if (a8::XGetTickCount() - last_ping_db_tick_ > 1000 * 60 * 5) {
|
if (a8::XGetTickCount() - last_ping_db_tick_ > 1000 * 60 * 5) {
|
||||||
last_ping_db_tick_ = a8::XGetTickCount();
|
last_ping_db_tick_ = a8::XGetTickCount();
|
||||||
#if 0
|
#if 0
|
||||||
if (query_.ExecQuery("SELECT 1;", {}) <= 0) {
|
if (query_->ExecQuery("SELECT 1;", {}) <= 0) {
|
||||||
g_udplog->Warning("mysql disconnect", {});
|
g_udplog->Warning("mysql disconnect", {});
|
||||||
if (mysql_conn_.Connect()) {
|
if (mysql_conn_.Connect()) {
|
||||||
DumpMysqlInfo(query_);
|
DumpMysqlInfo(query_);
|
||||||
@ -103,9 +114,11 @@ void OrderMgr::Update()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
ProcessOrderMsg();
|
ProcessOrderMsg();
|
||||||
ProcessNotifyMsg();
|
ProcessNotifyMsg();
|
||||||
ProcessReissueMsg();
|
ProcessReissueMsg();
|
||||||
|
#endif
|
||||||
UpdatePedingOrders();
|
UpdatePedingOrders();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,9 +216,6 @@ bool OrderMgr::WaitForAddOrderFinished(int seqid, AddOrderResult& addresult, int
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
add_order_result_mutex_->unlock();
|
add_order_result_mutex_->unlock();
|
||||||
#if 0
|
|
||||||
g_application->NotifyLoopCond();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -377,10 +387,7 @@ void OrderMgr::ProcessNotifyMsg()
|
|||||||
|
|
||||||
bool OrderMgr::ProcAddOrder(OrderInfo& orderinfo)
|
bool OrderMgr::ProcAddOrder(OrderInfo& orderinfo)
|
||||||
{
|
{
|
||||||
#if 1
|
return query_->ExecScript("INSERT INTO orderinfo(orderid, serverid, roleid, rolename, channel, itemid, price, status, createtime, accountid, sp_orderid)" \
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
return query_.ExecScript("INSERT INTO orderinfo(orderid, serverid, roleid, rolename, channel, itemid, price, status, createtime, accountid, sp_orderid)" \
|
|
||||||
"VALUES('%s', %d, '%s', '%s', '%s', '%s', %d, %d, %d, '%s','%s');",
|
"VALUES('%s', %d, '%s', '%s', '%s', '%s', %d, %d, %d, '%s','%s');",
|
||||||
{
|
{
|
||||||
orderinfo.orderid,
|
orderinfo.orderid,
|
||||||
@ -395,8 +402,6 @@ bool OrderMgr::ProcAddOrder(OrderInfo& orderinfo)
|
|||||||
orderinfo.accountid,
|
orderinfo.accountid,
|
||||||
orderinfo.sp_accountid
|
orderinfo.sp_accountid
|
||||||
});
|
});
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int OrderMgr::ProcOrderNotify(PayNotifyNode* node)
|
int OrderMgr::ProcOrderNotify(PayNotifyNode* node)
|
||||||
@ -407,20 +412,20 @@ int OrderMgr::ProcOrderNotify(PayNotifyNode* node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
int ret = query_.ExecQuery("SELECT orderid, itemid, roleid, rolename, price, sp_pay_result, serverid "
|
int ret = query_->ExecQuery("SELECT orderid, itemid, roleid, rolename, price, sp_pay_result, serverid "
|
||||||
"FROM orderinfo WHERE orderid='%s' and sp_confirm_time=0;",
|
"FROM orderinfo WHERE orderid='%s' and sp_confirm_time=0;",
|
||||||
{ node->orderid});
|
{ node->orderid});
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
if (query_.GetValue(5).GetInt() == 0) {
|
if (query_->GetValue(5).GetInt() == 0) {
|
||||||
OrderInfo info;
|
OrderInfo info;
|
||||||
info.orderid = query_.GetValue(0).GetString();
|
info.orderid = query_->GetValue(0).GetString();
|
||||||
info.itemid = query_.GetValue(1);
|
info.itemid = query_->GetValue(1);
|
||||||
info.roleid = query_.GetValue(2).GetString();
|
info.roleid = query_->GetValue(2).GetString();
|
||||||
info.rolename = query_.GetValue(3).GetString();
|
info.rolename = query_->GetValue(3).GetString();
|
||||||
info.price = query_.GetValue(4);
|
info.price = query_->GetValue(4);
|
||||||
info.lastchecktime = g_nowtime - 60 * 3;
|
info.lastchecktime = g_nowtime - 60 * 3;
|
||||||
info.serverid = query_.GetValue(6);
|
info.serverid = query_->GetValue(6);
|
||||||
if (query_.ExecScript("UPDATE orderinfo SET sp_pay_result=%d, sp_confirm_time=%d, sp_orderid='%s' WHERE orderid='%s';",
|
if (query_->ExecScript("UPDATE orderinfo SET sp_pay_result=%d, sp_confirm_time=%d, sp_orderid='%s' WHERE orderid='%s';",
|
||||||
{
|
{
|
||||||
node->payresult,
|
node->payresult,
|
||||||
g_nowtime,
|
g_nowtime,
|
||||||
@ -448,7 +453,7 @@ int OrderMgr::ContinueSubscriptions(PayNotifyNode* node)
|
|||||||
#if 1
|
#if 1
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
int ret = query_.ExecQuery("SELECT orderid, itemid, roleid, rolename, price, sp_pay_result, serverid "
|
int ret = query_->ExecQuery("SELECT orderid, itemid, roleid, rolename, price, sp_pay_result, serverid "
|
||||||
"FROM orderinfo WHERE orderid='%s' ",
|
"FROM orderinfo WHERE orderid='%s' ",
|
||||||
{ node->orderid });
|
{ node->orderid });
|
||||||
|
|
||||||
@ -456,13 +461,13 @@ int OrderMgr::ContinueSubscriptions(PayNotifyNode* node)
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
OrderInfo info;
|
OrderInfo info;
|
||||||
info.orderid = query_.GetValue(0).GetString();
|
info.orderid = query_->GetValue(0).GetString();
|
||||||
info.itemid = query_.GetValue(1);
|
info.itemid = query_->GetValue(1);
|
||||||
info.roleid = query_.GetValue(2).GetString();
|
info.roleid = query_->GetValue(2).GetString();
|
||||||
info.rolename = query_.GetValue(3).GetString();
|
info.rolename = query_->GetValue(3).GetString();
|
||||||
info.price = query_.GetValue(4);
|
info.price = query_->GetValue(4);
|
||||||
info.lastchecktime = g_nowtime - 60 * 3;
|
info.lastchecktime = g_nowtime - 60 * 3;
|
||||||
info.serverid = query_.GetValue(6);
|
info.serverid = query_->GetValue(6);
|
||||||
peding_orders_[info.orderid] = info;
|
peding_orders_[info.orderid] = info;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -477,7 +482,7 @@ int OrderMgr::ProcIosPayOrderNotify(PayNotifyNode* node)
|
|||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
int retcode = query_.ExecQuery("SELECT orderid FROM orderinfo WHERE channel='%s' and sp_orderid='%s';",
|
int retcode = query_->ExecQuery("SELECT orderid FROM orderinfo WHERE channel='%s' and sp_orderid='%s';",
|
||||||
{
|
{
|
||||||
std::string(IOS_CHANNEL),
|
std::string(IOS_CHANNEL),
|
||||||
node->sp_orderid
|
node->sp_orderid
|
||||||
@ -490,7 +495,7 @@ int OrderMgr::ProcIosPayOrderNotify(PayNotifyNode* node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string orderid = GenOrderId(node->itemid);
|
std::string orderid = GenOrderId(node->itemid);
|
||||||
bool ret = query_.ExecScript("INSERT INTO orderinfo(orderid, accountid, roleid, rolename, channel, serverid, itemid, price, status, createtime, sp_orderid, sp_accountid, sp_confirm_time, sp_pay_result)"
|
bool ret = query_->ExecScript("INSERT INTO orderinfo(orderid, accountid, roleid, rolename, channel, serverid, itemid, price, status, createtime, sp_orderid, sp_accountid, sp_confirm_time, sp_pay_result)"
|
||||||
"VALUES('%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, %d, '%s', '%s', %d, 1);",
|
"VALUES('%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, %d, '%s', '%s', %d, 1);",
|
||||||
{
|
{
|
||||||
orderid,
|
orderid,
|
||||||
@ -508,6 +513,7 @@ int OrderMgr::ProcIosPayOrderNotify(PayNotifyNode* node)
|
|||||||
});
|
});
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
printf("prociospaynotify %s\n", mysql_conn_.GetError().c_str());
|
printf("prociospaynotify %s\n", mysql_conn_.GetError().c_str());
|
||||||
|
a8::UdpLog::Instance()->Error("load role_index %s", {mysql_conn_->GetError()});
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
OrderInfo info;
|
OrderInfo info;
|
||||||
@ -530,7 +536,7 @@ void OrderMgr::ProcReissue(const std::string& orderid)
|
|||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
//超过30天的不能补发
|
//超过30天的不能补发
|
||||||
int ret = query_.ExecQuery("SELECT orderid, itemid, roleid, rolename, price, sp_pay_result, serverid "
|
int ret = query_->ExecQuery("SELECT orderid, itemid, roleid, rolename, price, sp_pay_result, serverid "
|
||||||
"FROM orderinfo WHERE orderid='%s' AND status=1 AND confirmtime + 3600 * 24 * 30 > %d;",
|
"FROM orderinfo WHERE orderid='%s' AND status=1 AND confirmtime + 3600 * 24 * 30 > %d;",
|
||||||
{
|
{
|
||||||
orderid,
|
orderid,
|
||||||
@ -538,14 +544,14 @@ void OrderMgr::ProcReissue(const std::string& orderid)
|
|||||||
});
|
});
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
OrderInfo info;
|
OrderInfo info;
|
||||||
info.orderid = query_.GetValue(0).GetString();
|
info.orderid = query_->GetValue(0).GetString();
|
||||||
info.itemid = query_.GetValue(1);
|
info.itemid = query_->GetValue(1);
|
||||||
info.roleid = query_.GetValue(2).GetString();
|
info.roleid = query_->GetValue(2).GetString();
|
||||||
info.rolename = query_.GetValue(3).GetString();
|
info.rolename = query_->GetValue(3).GetString();
|
||||||
info.price = query_.GetValue(4);
|
info.price = query_->GetValue(4);
|
||||||
info.lastchecktime = g_nowtime - 60 * 3;
|
info.lastchecktime = g_nowtime - 60 * 3;
|
||||||
info.serverid = query_.GetValue(6);
|
info.serverid = query_->GetValue(6);
|
||||||
if (query_.ExecScript("UPDATE orderinfo SET status=0, confirmtime=0 WHERE orderid='%s';",
|
if (query_->ExecScript("UPDATE orderinfo SET status=0, confirmtime=0 WHERE orderid='%s';",
|
||||||
{orderid})) {
|
{orderid})) {
|
||||||
peding_orders_[info.orderid] = info;
|
peding_orders_[info.orderid] = info;
|
||||||
}
|
}
|
||||||
@ -555,12 +561,21 @@ void OrderMgr::ProcReissue(const std::string& orderid)
|
|||||||
|
|
||||||
void OrderMgr::UpdatePedingOrders()
|
void OrderMgr::UpdatePedingOrders()
|
||||||
{
|
{
|
||||||
#if 0
|
a8::UdpLog::Instance()->Debug("UpdatePedingOrders peding_orders_ size:%d", { peding_orders_.size() });
|
||||||
g_udplog->Debug("UpdatePedingOrders peding_orders_ size:%d", { peding_orders_.size() });
|
|
||||||
for (std::map<std::string, OrderInfo>::iterator itr = peding_orders_.begin();
|
for (std::map<std::string, OrderInfo>::iterator itr = peding_orders_.begin();
|
||||||
itr != peding_orders_.end(); ++itr){
|
itr != peding_orders_.end(); ++itr){
|
||||||
if (g_nowtime - itr->second.lastchecktime > 15) {
|
if (g_nowtime - itr->second.lastchecktime > 15) {
|
||||||
itr->second.lastchecktime = g_nowtime;
|
itr->second.lastchecktime = g_nowtime;
|
||||||
|
OrderInfo info = itr->second;
|
||||||
|
SendGMMsg(
|
||||||
|
info.serverid,
|
||||||
|
info.orderid,
|
||||||
|
info.roleid,
|
||||||
|
info.itemid,
|
||||||
|
info.price,
|
||||||
|
info.rolename
|
||||||
|
);
|
||||||
|
#if 0
|
||||||
P2DPayNotify msg;
|
P2DPayNotify msg;
|
||||||
msg.orderid = itr->second.orderid;
|
msg.orderid = itr->second.orderid;
|
||||||
msg.roleid = itr->second.roleid;
|
msg.roleid = itr->second.roleid;
|
||||||
@ -569,10 +584,10 @@ void OrderMgr::UpdatePedingOrders()
|
|||||||
msg.price = itr->second.price;
|
msg.price = itr->second.price;
|
||||||
msg.serverid = itr->second.serverid;
|
msg.serverid = itr->second.serverid;
|
||||||
g_dbslistener->SendToDBServer(msg);
|
g_dbslistener->SendToDBServer(msg);
|
||||||
g_udplog->Debug("UpdatePedingOrders send P2DPayNotify orderid:%s roleid:%d name:%s serverid:%d", { msg.orderid,msg.roleid,msg.name,msg.serverid });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
a8::UdpLog::Instance()->Debug("UpdatePedingOrders orderid:%s roleid:%d name:%s serverid:%d", { info.orderid,info.roleid,info.rolename,info.serverid });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -585,7 +600,7 @@ void OrderMgr::_SSMPing(MsgHdr& hdr, const SSMPing& msg)
|
|||||||
void OrderMgr::_D2PPayNotifyACK(MsgHdr& hdr, const D2PPayNotifyACK& msg)
|
void OrderMgr::_D2PPayNotifyACK(MsgHdr& hdr, const D2PPayNotifyACK& msg)
|
||||||
{
|
{
|
||||||
if (peding_orders_.find(msg.orderid) != peding_orders_.end()) {
|
if (peding_orders_.find(msg.orderid) != peding_orders_.end()) {
|
||||||
if (query_.ExecScript("UPDATE orderinfo SET status=%d, confirmtime=%d WHERE orderid='%s';",
|
if (query_->ExecScript("UPDATE orderinfo SET status=%d, confirmtime=%d WHERE orderid='%s';",
|
||||||
{
|
{
|
||||||
1,
|
1,
|
||||||
g_nowtime,
|
g_nowtime,
|
||||||
@ -600,26 +615,24 @@ void OrderMgr::_D2PPayNotifyACK(MsgHdr& hdr, const D2PPayNotifyACK& msg)
|
|||||||
//支付成功并且gameserver没有确认的订单
|
//支付成功并且gameserver没有确认的订单
|
||||||
void OrderMgr::LoadPedingOrders()
|
void OrderMgr::LoadPedingOrders()
|
||||||
{
|
{
|
||||||
#if 0
|
int ret = query_->ExecQuery("SELECT orderid, itemid, roleid, rolename, price, serverid, accountid "
|
||||||
int ret = query_.ExecQuery("SELECT orderid, itemid, roleid, rolename, price, serverid, accountid "
|
|
||||||
"FROM orderinfo WHERE sp_pay_result=1 AND status=0;", {});
|
"FROM orderinfo WHERE sp_pay_result=1 AND status=0;", {});
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (!query_.Eof()) {
|
while (!query_->Eof()) {
|
||||||
OrderInfo info;
|
OrderInfo info;
|
||||||
info.orderid = query_.GetValue(0).GetString();
|
info.orderid = query_->GetValue(0).GetString();
|
||||||
info.itemid = query_.GetValue(1);
|
info.itemid = query_->GetValue(1);
|
||||||
info.roleid = query_.GetValue(2).GetString();
|
info.roleid = query_->GetValue(2).GetString();
|
||||||
info.rolename = query_.GetValue(3).GetString();
|
info.rolename = query_->GetValue(3).GetString();
|
||||||
info.price = query_.GetValue(4);
|
info.price = query_->GetValue(4);
|
||||||
info.lastchecktime = g_nowtime - 60 * 1;
|
info.lastchecktime = g_nowtime - 60 * 1;
|
||||||
info.serverid = query_.GetValue(5);
|
info.serverid = query_->GetValue(5);
|
||||||
info.accountid = query_.GetValue(6).GetString();
|
info.accountid = query_->GetValue(6).GetString();
|
||||||
peding_orders_[info.orderid] = info;
|
peding_orders_[info.orderid] = info;
|
||||||
query_.Next();
|
query_->Next();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long OrderMgr::GenSeqId()
|
long OrderMgr::GenSeqId()
|
||||||
@ -631,11 +644,8 @@ long OrderMgr::GenSeqId()
|
|||||||
return new_seqid;
|
return new_seqid;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string OrderMgr::GenOrderId(int itemid)
|
std::string OrderMgr::GenOrderId(int itemid, int price)
|
||||||
{
|
{
|
||||||
#if 1
|
|
||||||
return "";
|
|
||||||
#else
|
|
||||||
char orderid[80] = {0};
|
char orderid[80] = {0};
|
||||||
{
|
{
|
||||||
time_t nowtime = time(NULL);
|
time_t nowtime = time(NULL);
|
||||||
@ -659,20 +669,22 @@ std::string OrderMgr::GenOrderId(int itemid)
|
|||||||
strftime(strtime, 80, "%y%m%d%H%M%S", ptr);
|
strftime(strtime, 80, "%y%m%d%H%M%S", ptr);
|
||||||
|
|
||||||
sprintf(orderid, "%s%5d", strtime, sub_orderid_);
|
sprintf(orderid, "%s%5d", strtime, sub_orderid_);
|
||||||
for (int i = 0; i < a8::arraysize(orderid); i++) {
|
for (int i = 0; i < a8::ArraySize(orderid); i++) {
|
||||||
if (orderid[i] == ' ') {
|
if (orderid[i] == ' ') {
|
||||||
orderid[i] = '0';
|
orderid[i] = '0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
int price = 0;
|
int price = 0;
|
||||||
Template::RechargeCard *cardtpl = g_configtable->GetRechargeCard(itemid);
|
Template::RechargeCard *cardtpl = g_configtable->GetRechargeCard(itemid);
|
||||||
if (cardtpl) {
|
if (cardtpl) {
|
||||||
price = cardtpl->price * 10;
|
price = cardtpl->price * 10;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string strorderid;
|
std::string strorderid;
|
||||||
strorderid = a8::format("%d_%d_%s",
|
strorderid = a8::Format("%d_%d_%s",
|
||||||
{
|
{
|
||||||
itemid,
|
itemid,
|
||||||
price,
|
price,
|
||||||
@ -680,5 +692,180 @@ std::string OrderMgr::GenOrderId(int itemid)
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
return strorderid;
|
return strorderid;
|
||||||
#endif
|
}
|
||||||
|
|
||||||
|
//new
|
||||||
|
bool OrderMgr::AddNewOrder(const std::string& accountid,
|
||||||
|
int serverid,
|
||||||
|
const std::string& roleid,
|
||||||
|
const std::string& rolename,
|
||||||
|
int itemid, int price,
|
||||||
|
const std::string& sp_orderid,
|
||||||
|
OrderInfo& orderinfo)
|
||||||
|
{
|
||||||
|
std::string orderid = GenOrderId(itemid, price);
|
||||||
|
//int serverid = f8::ExtractGameIdFromAccountId(accountid);
|
||||||
|
int channel = f8::ExtractChannelIdFromAccountId(accountid);
|
||||||
|
|
||||||
|
orderinfo.orderid = orderid;
|
||||||
|
orderinfo.serverid = serverid;
|
||||||
|
orderinfo.roleid = roleid;
|
||||||
|
orderinfo.rolename = rolename;
|
||||||
|
orderinfo.channel = a8::XValue(channel).GetString();
|
||||||
|
orderinfo.itemid = itemid;
|
||||||
|
orderinfo.price = price;
|
||||||
|
orderinfo.accountid = accountid;
|
||||||
|
orderinfo.sp_orderid = sp_orderid;
|
||||||
|
|
||||||
|
return query_->ExecScript("INSERT INTO orderinfo(orderid, serverid, roleid, rolename, channel, itemid, price, status, createtime, accountid, sp_orderid)" \
|
||||||
|
"VALUES('%s', %d, '%s', '%s', '%s', '%s', %d, %d, %d, '%s','%s');",
|
||||||
|
{
|
||||||
|
orderinfo.orderid,
|
||||||
|
orderinfo.serverid,
|
||||||
|
orderinfo.roleid,
|
||||||
|
orderinfo.rolename,
|
||||||
|
orderinfo.channel,
|
||||||
|
orderinfo.itemid,
|
||||||
|
orderinfo.price,
|
||||||
|
0,
|
||||||
|
g_nowtime,
|
||||||
|
orderinfo.accountid,
|
||||||
|
orderinfo.sp_orderid
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void OrderMgr::AddNewPayNotify(
|
||||||
|
int pay_type,
|
||||||
|
const std::string& orderid,
|
||||||
|
int payresult,
|
||||||
|
int& result)
|
||||||
|
{
|
||||||
|
switch (pay_type) {
|
||||||
|
case 1:
|
||||||
|
result = ProcOrderNotifyNew(pay_type, orderid, payresult);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
#if 0
|
||||||
|
result = ProcIosPayOrderNotify(delnode);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
#if 0
|
||||||
|
result = ContinueSubscriptions(delnode);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
result = 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OrderMgr::G2PPayNotifyACK(a8::XParams& param, a8::XObject& data)
|
||||||
|
{
|
||||||
|
int errcode = data.Get("errcode").GetInt();
|
||||||
|
if (errcode == 0) {
|
||||||
|
std::string orderid = param.sender;
|
||||||
|
if (peding_orders_.find(orderid) != peding_orders_.end()) {
|
||||||
|
if (query_->ExecScript("UPDATE orderinfo SET status=%d, confirmtime=%d WHERE orderid='%s';",
|
||||||
|
{
|
||||||
|
1,
|
||||||
|
g_nowtime,
|
||||||
|
orderid
|
||||||
|
})) {
|
||||||
|
peding_orders_.erase(orderid);
|
||||||
|
} else {
|
||||||
|
a8::UdpLog::Instance()->Warning("update orderinfo error %s", {query_->GetError()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
a8::UdpLog::Instance()->Warning("G2PPayNotifyACK resp error %s",
|
||||||
|
{
|
||||||
|
data.Get("errmsg").GetString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int OrderMgr::ProcOrderNotifyNew(int pay_type,
|
||||||
|
const std::string& orderid,
|
||||||
|
int payresult)
|
||||||
|
{
|
||||||
|
if (payresult != 0 && payresult != 1) {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ret = query_->ExecQuery("SELECT orderid, itemid, roleid, rolename, price, sp_pay_result, serverid "
|
||||||
|
"FROM orderinfo WHERE orderid='%s' and sp_confirm_time=0;",
|
||||||
|
{ orderid});
|
||||||
|
if (ret > 0) {
|
||||||
|
if (query_->GetValue(5).GetInt() == 0) {
|
||||||
|
OrderInfo info;
|
||||||
|
info.orderid = query_->GetValue(0).GetString();
|
||||||
|
info.itemid = query_->GetValue(1);
|
||||||
|
info.roleid = query_->GetValue(2).GetString();
|
||||||
|
info.rolename = query_->GetValue(3).GetString();
|
||||||
|
info.price = query_->GetValue(4);
|
||||||
|
info.serverid = query_->GetValue(6);
|
||||||
|
if (query_->ExecScript("UPDATE orderinfo SET sp_pay_result=%d, sp_confirm_time=%d WHERE orderid='%s';",
|
||||||
|
{
|
||||||
|
payresult,
|
||||||
|
g_nowtime,
|
||||||
|
orderid
|
||||||
|
})) {
|
||||||
|
if (payresult == 1) {
|
||||||
|
//http 异步,加入队列主线程循环执行
|
||||||
|
peding_orders_[info.orderid] = info;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OrderMgr::SendGMMsg(int serverid,
|
||||||
|
const std::string& orderid,
|
||||||
|
const std::string& roleid,
|
||||||
|
int itemid, int price,
|
||||||
|
const std::string& rolename)
|
||||||
|
{
|
||||||
|
std::string url;
|
||||||
|
{
|
||||||
|
std::string ip = JsonDataMgr::Instance()->GetTargetServerClusterConf(serverid)->At("ip")->AsXValue();
|
||||||
|
std::string port = JsonDataMgr::Instance()->GetTargetServerClusterConf(serverid)->At("port")->AsXValue();
|
||||||
|
url = "http://" + ip + ":" + port + "/webapp/index.php?c=Pay&a=payNotify";
|
||||||
|
url = url + "&orderid=" + orderid
|
||||||
|
+ "&roleid=" + roleid
|
||||||
|
+ "&itemid=" + a8::XValue(itemid).GetString()
|
||||||
|
+ "&price=" + a8::XValue(price).GetString()
|
||||||
|
+ "&name=" + rolename;
|
||||||
|
}
|
||||||
|
|
||||||
|
a8::MutableXObject* params_xobj = a8::MutableXObject::NewObject();
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
auto on_ok = [] (a8::XParams& param, a8::XObject& data)
|
||||||
|
{
|
||||||
|
OrderMgr::Instance()->G2PPayNotifyACK(param, data);
|
||||||
|
};
|
||||||
|
auto on_error = [] (a8::XParams& param, const std::string& response)
|
||||||
|
{
|
||||||
|
a8::UdpLog::Instance()->Warning("http gameserver error %s", {response});
|
||||||
|
};
|
||||||
|
f8::HttpClientPool::Instance()->HttpGet(
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(orderid)
|
||||||
|
,
|
||||||
|
on_ok,
|
||||||
|
on_error,
|
||||||
|
url.c_str(),
|
||||||
|
*params_xobj,
|
||||||
|
rand()
|
||||||
|
);
|
||||||
|
delete params_xobj;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
namespace a8
|
||||||
|
{
|
||||||
|
namespace mysql
|
||||||
|
{
|
||||||
|
class Query;
|
||||||
|
class Connection;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct OrderInfo
|
struct OrderInfo
|
||||||
{
|
{
|
||||||
std::string seqid;
|
std::string seqid;
|
||||||
@ -85,6 +94,21 @@ class OrderMgr : public a8::Singleton<OrderMgr>
|
|||||||
int AddReissue(const std::string& orderid);
|
int AddReissue(const std::string& orderid);
|
||||||
bool WaitForReissueFinished(int seqid, int& result, int seconds);
|
bool WaitForReissueFinished(int seqid, int& result, int seconds);
|
||||||
|
|
||||||
|
//new
|
||||||
|
bool AddNewOrder(const std::string& accountid,
|
||||||
|
int serverid,
|
||||||
|
const std::string& roleid,
|
||||||
|
const std::string& rolename,
|
||||||
|
int itemid, int price,
|
||||||
|
const std::string& sp_orderid,
|
||||||
|
OrderInfo& orderinfo);
|
||||||
|
void AddNewPayNotify(
|
||||||
|
int pay_type,
|
||||||
|
const std::string& orderid,
|
||||||
|
int payresult,
|
||||||
|
int& result);
|
||||||
|
void G2PPayNotifyACK(a8::XParams& param, a8::XObject& data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ProcessOrderMsg();
|
void ProcessOrderMsg();
|
||||||
void ProcessNotifyMsg();
|
void ProcessNotifyMsg();
|
||||||
@ -96,7 +120,7 @@ class OrderMgr : public a8::Singleton<OrderMgr>
|
|||||||
void ProcReissue(const std::string& orderid);
|
void ProcReissue(const std::string& orderid);
|
||||||
void UpdatePedingOrders();
|
void UpdatePedingOrders();
|
||||||
void LoadPedingOrders();
|
void LoadPedingOrders();
|
||||||
std::string GenOrderId(int itemid);
|
std::string GenOrderId(int itemid, int price = 0);
|
||||||
long GenSeqId();
|
long GenSeqId();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -104,11 +128,20 @@ class OrderMgr : public a8::Singleton<OrderMgr>
|
|||||||
|
|
||||||
void _D2PPayNotifyACK(MsgHdr& hdr, const D2PPayNotifyACK& msg);
|
void _D2PPayNotifyACK(MsgHdr& hdr, const D2PPayNotifyACK& msg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//new
|
||||||
|
int ProcOrderNotifyNew(int pay_type,
|
||||||
|
const std::string& orderid,
|
||||||
|
int payresult);
|
||||||
|
void SendGMMsg(int serverid,
|
||||||
|
const std::string& orderid,
|
||||||
|
const std::string& roleid,
|
||||||
|
int itemid, int price,
|
||||||
|
const std::string& rolename);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if 0
|
a8::mysql::Connection* mysql_conn_;
|
||||||
a8::mysql::Connection mysql_conn_;
|
a8::mysql::Query* query_;
|
||||||
a8::mysql::Query query_;
|
|
||||||
#endif
|
|
||||||
a8::tick_t last_ping_db_tick_ = 0;
|
a8::tick_t last_ping_db_tick_ = 0;
|
||||||
|
|
||||||
std::mutex *add_order_mutex_ = nullptr;
|
std::mutex *add_order_mutex_ = nullptr;
|
||||||
|
@ -18,3 +18,5 @@ namespace google
|
|||||||
#include "framework/cpp/types.h"
|
#include "framework/cpp/types.h"
|
||||||
#include "framework/cpp/utils.h"
|
#include "framework/cpp/utils.h"
|
||||||
#include "framework/cpp/protoutils.h"
|
#include "framework/cpp/protoutils.h"
|
||||||
|
|
||||||
|
#include "global.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user