优化
This commit is contained in:
parent
cf7cd445e7
commit
ccef3d74b4
@ -265,7 +265,7 @@ bool App::HasTask()
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return OrderMgr::Instance()->HasTask();
|
||||
return false;
|
||||
}
|
||||
|
||||
void App::DispatchMsg()
|
||||
|
@ -9,49 +9,8 @@
|
||||
#include "framework/cpp/httpclientpool.h"
|
||||
#include <a8/mutable_xobject.h>
|
||||
|
||||
struct AddOrderNode
|
||||
{
|
||||
int seqid = 0;
|
||||
int payresult = 0;
|
||||
OrderInfo orderinfo;
|
||||
AddOrderNode* next = nullptr;
|
||||
};
|
||||
|
||||
struct PayNotifyNode
|
||||
{
|
||||
int seqid = 0;
|
||||
int pay_type = 0;//0:normal 1:ios 2:jinqi
|
||||
std::string accountid;
|
||||
std::string roleid;
|
||||
std::string rolename;
|
||||
int serverid = 0;
|
||||
int itemid = 0;
|
||||
std::string itemid_str;
|
||||
std::string orderid;
|
||||
std::string sp_orderid;
|
||||
std::string sp_accountid;
|
||||
double fee = 0.0f;
|
||||
int payresult = 0;
|
||||
PayNotifyNode* next = nullptr;
|
||||
};
|
||||
|
||||
struct ReissueNode
|
||||
{
|
||||
int seqid = 0;
|
||||
std::string orderid;
|
||||
ReissueNode* next = nullptr;
|
||||
};
|
||||
|
||||
void OrderMgr::Init()
|
||||
{
|
||||
add_order_mutex_ = new std::mutex();
|
||||
pay_notify_mutex_ = new std::mutex();
|
||||
reissue_mutex_ = new std::mutex();
|
||||
seq_mutex_ = new std::mutex();
|
||||
add_order_result_mutex_ = new std::mutex();
|
||||
pay_notify_result_mutex_ = new std::mutex();
|
||||
|
||||
current_seqid_ = 1000;
|
||||
sub_orderid_ = 1;
|
||||
last_gen_order_time_ = g_nowtime;
|
||||
last_ping_db_tick_ = a8::XGetTickCount();
|
||||
@ -89,456 +48,9 @@ void OrderMgr::Update()
|
||||
}
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
ProcessOrderMsg();
|
||||
ProcessNotifyMsg();
|
||||
ProcessReissueMsg();
|
||||
#endif
|
||||
UpdatePedingOrders();
|
||||
}
|
||||
|
||||
bool OrderMgr::HasTask()
|
||||
{
|
||||
{
|
||||
if (!work_node_) {
|
||||
add_order_mutex_->lock();
|
||||
if (!work_node_ && top_node_) {
|
||||
work_node_ = top_node_;
|
||||
top_node_ = nullptr;
|
||||
bot_node_ = nullptr;
|
||||
}
|
||||
add_order_mutex_->unlock();
|
||||
}
|
||||
if (work_node_) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (!pay_notify_work_node_) {
|
||||
pay_notify_mutex_->lock();
|
||||
if (!pay_notify_work_node_ && pay_notify_top_node_) {
|
||||
pay_notify_work_node_ = pay_notify_top_node_;
|
||||
pay_notify_top_node_ = nullptr;
|
||||
pay_notify_bot_node_ = nullptr;
|
||||
}
|
||||
pay_notify_mutex_->unlock();
|
||||
}
|
||||
if (pay_notify_work_node_) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (!reissue_work_node_) {
|
||||
reissue_mutex_->lock();
|
||||
if (!reissue_work_node_ && reissue_top_node_) {
|
||||
reissue_work_node_ = reissue_top_node_;
|
||||
reissue_top_node_ = nullptr;
|
||||
reissue_bot_node_ = nullptr;
|
||||
}
|
||||
reissue_mutex_->unlock();
|
||||
}
|
||||
if (reissue_work_node_) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int OrderMgr::AddOrder(const std::string& seqid, const std::string& accountid,
|
||||
const std::string& roleid, const std::string& rolename,
|
||||
const std::string& channel, const std::string& sp_accountid, int serverid,
|
||||
int productid, int price,const std::string& sp_orderid)
|
||||
{
|
||||
int new_seqid = GenSeqId();
|
||||
AddOrderNode *p = new AddOrderNode();
|
||||
p->orderinfo.seqid = seqid;
|
||||
p->orderinfo.accountid = accountid;
|
||||
p->orderinfo.orderid = GenOrderId(productid);
|
||||
p->orderinfo.roleid = roleid;
|
||||
p->orderinfo.rolename = rolename;
|
||||
p->orderinfo.sp_accountid = sp_accountid;
|
||||
p->orderinfo.channel = channel;
|
||||
p->orderinfo.itemid = productid;
|
||||
p->orderinfo.price = price;
|
||||
p->orderinfo.serverid = serverid;
|
||||
p->orderinfo.sp_accountid = sp_orderid;
|
||||
p->seqid = new_seqid;
|
||||
add_order_mutex_->lock();
|
||||
if (bot_node_) {
|
||||
bot_node_->next = p;
|
||||
bot_node_ = p;
|
||||
} else {
|
||||
top_node_ = p;
|
||||
bot_node_ = p;
|
||||
}
|
||||
add_order_mutex_->unlock();
|
||||
return new_seqid;
|
||||
}
|
||||
|
||||
bool OrderMgr::WaitForAddOrderFinished(int seqid, AddOrderResult& addresult, int seconds)
|
||||
{
|
||||
a8::tick_t tick = a8::XGetTickCount();
|
||||
while (true) {
|
||||
if (a8::XGetTickCount() - tick > 1000 * seconds) { //timeout
|
||||
return false;
|
||||
}
|
||||
add_order_result_mutex_->lock();
|
||||
std::map<int, AddOrderResult>::iterator itr = add_order_results_.find(seqid);
|
||||
if (itr != add_order_results_.end()) {
|
||||
addresult = itr->second;
|
||||
add_order_results_.erase(itr);
|
||||
add_order_result_mutex_->unlock();
|
||||
return true;
|
||||
} else {
|
||||
add_order_result_mutex_->unlock();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int OrderMgr::AddPayNotify(int pay_type,
|
||||
const std::string& accountid,
|
||||
const std::string& roleid,
|
||||
const std::string& rolename,
|
||||
int serverid,
|
||||
int itemid,
|
||||
const std::string& itemid_str,
|
||||
const std::string& orderid,
|
||||
const std::string& sp_orderid,
|
||||
double fee,
|
||||
int payresult)
|
||||
{
|
||||
int new_seqid = GenSeqId();
|
||||
PayNotifyNode *p = new PayNotifyNode();
|
||||
p->seqid = new_seqid;
|
||||
p->pay_type = pay_type;
|
||||
p->accountid = accountid;
|
||||
p->roleid = roleid;
|
||||
p->rolename = rolename;
|
||||
p->serverid = serverid;
|
||||
p->itemid = itemid;
|
||||
p->itemid_str = itemid_str;
|
||||
p->orderid = orderid;
|
||||
p->sp_orderid = sp_orderid;
|
||||
p->fee = fee;
|
||||
p->payresult = payresult;
|
||||
pay_notify_mutex_->lock();
|
||||
if (pay_notify_bot_node_) {
|
||||
pay_notify_bot_node_->next = p;
|
||||
pay_notify_bot_node_ = p;
|
||||
} else {
|
||||
pay_notify_top_node_ = p;
|
||||
pay_notify_bot_node_ = p;
|
||||
}
|
||||
pay_notify_mutex_->unlock();
|
||||
return new_seqid;
|
||||
}
|
||||
|
||||
int OrderMgr::AddReissue(const std::string& orderid)
|
||||
{
|
||||
int new_seqid = GenSeqId();
|
||||
ReissueNode *p = new ReissueNode();
|
||||
p->seqid = new_seqid;
|
||||
p->orderid = orderid;
|
||||
reissue_mutex_->lock();
|
||||
if (reissue_bot_node_) {
|
||||
reissue_bot_node_->next = p;
|
||||
reissue_bot_node_ = p;
|
||||
} else {
|
||||
reissue_top_node_ = p;
|
||||
reissue_bot_node_ = p;
|
||||
}
|
||||
reissue_mutex_->unlock();
|
||||
return new_seqid;
|
||||
}
|
||||
|
||||
bool OrderMgr::WaitForReissueFinished(int seqid, int& result, int seconds)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool OrderMgr::WaitForPayNotifyFinished(int seqid, int& result, int seconds)
|
||||
{
|
||||
a8::tick_t tick = a8::XGetTickCount();
|
||||
while (true) {
|
||||
if (a8::XGetTickCount() - tick > 1000 * seconds) { //timeout
|
||||
return false;
|
||||
}
|
||||
pay_notify_result_mutex_->lock();
|
||||
std::map<int, int>::iterator itr = pay_notify_results_.find(seqid);
|
||||
if (itr != pay_notify_results_.end()) {
|
||||
result = itr->second;
|
||||
pay_notify_results_.erase(itr);
|
||||
pay_notify_result_mutex_->unlock();
|
||||
return true;
|
||||
} else {
|
||||
pay_notify_result_mutex_->unlock();
|
||||
#if 0
|
||||
g_application->NotifyLoopCond();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void OrderMgr::ProcessOrderMsg()
|
||||
{
|
||||
if (!work_node_ && top_node_) {
|
||||
add_order_mutex_->lock();
|
||||
work_node_ = top_node_;
|
||||
top_node_ = nullptr;
|
||||
bot_node_ = nullptr;
|
||||
add_order_mutex_->unlock();
|
||||
}
|
||||
|
||||
while (work_node_) {
|
||||
AddOrderNode *delnode = work_node_;
|
||||
work_node_ = work_node_->next;
|
||||
|
||||
AddOrderResult result;
|
||||
result.orderinfo = delnode->orderinfo;
|
||||
result.isok = ProcAddOrder(result.orderinfo);
|
||||
add_order_result_mutex_->lock();
|
||||
add_order_results_[delnode->seqid] = result;
|
||||
add_order_result_mutex_->unlock();
|
||||
|
||||
delete delnode;
|
||||
}
|
||||
}
|
||||
|
||||
void OrderMgr::ProcessReissueMsg()
|
||||
{
|
||||
if (!reissue_work_node_ && reissue_top_node_) {
|
||||
reissue_mutex_->lock();
|
||||
reissue_work_node_ = reissue_top_node_;
|
||||
reissue_top_node_ = nullptr;
|
||||
reissue_bot_node_ = nullptr;
|
||||
reissue_mutex_->unlock();
|
||||
}
|
||||
|
||||
while (reissue_work_node_) {
|
||||
ReissueNode *delnode = reissue_work_node_;
|
||||
reissue_work_node_ = reissue_work_node_->next;
|
||||
|
||||
ProcReissue(delnode->orderid);
|
||||
|
||||
delete delnode;
|
||||
}
|
||||
}
|
||||
|
||||
void OrderMgr::ProcessNotifyMsg()
|
||||
{
|
||||
if (!pay_notify_work_node_ && pay_notify_top_node_) {
|
||||
pay_notify_mutex_->lock();
|
||||
pay_notify_work_node_ = pay_notify_top_node_;
|
||||
pay_notify_top_node_ = nullptr;
|
||||
pay_notify_bot_node_ = nullptr;
|
||||
pay_notify_mutex_->unlock();
|
||||
}
|
||||
|
||||
while (pay_notify_work_node_) {
|
||||
PayNotifyNode *delnode = pay_notify_work_node_;
|
||||
pay_notify_work_node_ = pay_notify_work_node_->next;
|
||||
|
||||
int result = 0;
|
||||
|
||||
switch (delnode->pay_type) {
|
||||
case 1:
|
||||
result = ProcIosPayOrderNotify(delnode);
|
||||
break;
|
||||
case 4:
|
||||
result = ProcOrderNotify(delnode);
|
||||
break;
|
||||
case 5:
|
||||
result = ContinueSubscriptions(delnode);
|
||||
break;
|
||||
}
|
||||
pay_notify_mutex_->lock();
|
||||
pay_notify_results_[delnode->seqid] = result;
|
||||
pay_notify_mutex_->unlock();
|
||||
|
||||
delete delnode;
|
||||
}
|
||||
}
|
||||
|
||||
bool OrderMgr::ProcAddOrder(OrderInfo& orderinfo)
|
||||
{
|
||||
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_accountid
|
||||
});
|
||||
}
|
||||
|
||||
int OrderMgr::ProcOrderNotify(PayNotifyNode* node)
|
||||
{
|
||||
|
||||
if (node->payresult != 0 && node->payresult != 1) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
#if 1
|
||||
return 0;
|
||||
#else
|
||||
int ret = query_->ExecQuery("SELECT orderid, itemid, roleid, rolename, price, sp_pay_result, serverid "
|
||||
"FROM orderinfo WHERE orderid='%s' and sp_confirm_time=0;",
|
||||
{ node->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.lastchecktime = g_nowtime - 60 * 3;
|
||||
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';",
|
||||
{
|
||||
node->payresult,
|
||||
g_nowtime,
|
||||
node->sp_orderid,
|
||||
node->orderid
|
||||
})) {
|
||||
if (node->payresult == 1) {
|
||||
peding_orders_[info.orderid] = info;
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
return 2;
|
||||
}
|
||||
} else {
|
||||
return 3;
|
||||
}
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int OrderMgr::ContinueSubscriptions(PayNotifyNode* node)
|
||||
{
|
||||
#if 1
|
||||
return 0;
|
||||
#else
|
||||
int ret = query_->ExecQuery("SELECT orderid, itemid, roleid, rolename, price, sp_pay_result, serverid "
|
||||
"FROM orderinfo WHERE orderid='%s' ",
|
||||
{ node->orderid });
|
||||
|
||||
if (ret <= 0)
|
||||
return 1;
|
||||
|
||||
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.lastchecktime = g_nowtime - 60 * 3;
|
||||
info.serverid = query_->GetValue(6);
|
||||
peding_orders_[info.orderid] = info;
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int OrderMgr::ProcIosPayOrderNotify(PayNotifyNode* node)
|
||||
{
|
||||
#if 1
|
||||
return 0;
|
||||
#else
|
||||
Template::RechargeCard *cardtpl = g_configtable->GetRechargeCard(node->itemid);
|
||||
if (!cardtpl) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
int retcode = query_->ExecQuery("SELECT orderid FROM orderinfo WHERE channel='%s' and sp_orderid='%s';",
|
||||
{
|
||||
std::string(IOS_CHANNEL),
|
||||
node->sp_orderid
|
||||
});
|
||||
if (retcode < 0) {
|
||||
return 2;
|
||||
}
|
||||
if (retcode > 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
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)"
|
||||
"VALUES('%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, %d, '%s', '%s', %d, 1);",
|
||||
{
|
||||
orderid,
|
||||
node->accountid,
|
||||
node->roleid,
|
||||
node->rolename,
|
||||
IOS_CHANNEL,
|
||||
node->serverid,
|
||||
node->itemid,
|
||||
cardtpl->price * 10,
|
||||
g_nowtime,
|
||||
node->sp_orderid,
|
||||
node->sp_accountid,
|
||||
g_nowtime
|
||||
});
|
||||
if (!ret) {
|
||||
printf("prociospaynotify %s\n", mysql_conn_.GetError().c_str());
|
||||
a8::UdpLog::Instance()->Error("load role_index %s", {mysql_conn_->GetError()});
|
||||
return 3;
|
||||
}
|
||||
OrderInfo info;
|
||||
info.orderid = orderid;
|
||||
info.accountid = node->accountid;
|
||||
info.itemid = node->itemid;
|
||||
info.price = cardtpl->price * 10;
|
||||
info.customprice = info.price;
|
||||
info.serverid = node->serverid;
|
||||
info.roleid = node->roleid;
|
||||
info.rolename = node->rolename;
|
||||
info.sp_accountid = node->sp_accountid;
|
||||
info.channel = IOS_CHANNEL;
|
||||
peding_orders_[info.orderid] = info;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void OrderMgr::ProcReissue(const std::string& orderid)
|
||||
{
|
||||
#if 0
|
||||
//超过30天的不能补发
|
||||
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;",
|
||||
{
|
||||
orderid,
|
||||
g_nowtime
|
||||
});
|
||||
if (ret > 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.lastchecktime = g_nowtime - 60 * 3;
|
||||
info.serverid = query_->GetValue(6);
|
||||
if (query_->ExecScript("UPDATE orderinfo SET status=0, confirmtime=0 WHERE orderid='%s';",
|
||||
{orderid})) {
|
||||
peding_orders_[info.orderid] = info;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void OrderMgr::UpdatePedingOrders()
|
||||
{
|
||||
a8::UdpLog::Instance()->Debug("UpdatePedingOrders peding_orders_ size:%d", { peding_orders_.size() });
|
||||
@ -555,43 +67,11 @@ void OrderMgr::UpdatePedingOrders()
|
||||
info.price,
|
||||
info.rolename
|
||||
);
|
||||
#if 0
|
||||
P2DPayNotify msg;
|
||||
msg.orderid = itr->second.orderid;
|
||||
msg.roleid = itr->second.roleid;
|
||||
msg.name = itr->second.rolename;
|
||||
msg.itemid = itr->second.itemid;
|
||||
msg.price = itr->second.price;
|
||||
msg.serverid = itr->second.serverid;
|
||||
g_dbslistener->SendToDBServer(msg);
|
||||
#endif
|
||||
a8::UdpLog::Instance()->Debug("UpdatePedingOrders orderid:%s roleid:%d name:%s serverid:%d", { info.orderid,info.roleid,info.rolename,info.serverid });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
void OrderMgr::_SSMPing(MsgHdr& hdr, const SSMPing& msg)
|
||||
{
|
||||
SSMPong respmsg;
|
||||
g_dbslistener->SendToDBServer(respmsg);
|
||||
}
|
||||
|
||||
void OrderMgr::_D2PPayNotifyACK(MsgHdr& hdr, const D2PPayNotifyACK& msg)
|
||||
{
|
||||
if (peding_orders_.find(msg.orderid) != peding_orders_.end()) {
|
||||
if (query_->ExecScript("UPDATE orderinfo SET status=%d, confirmtime=%d WHERE orderid='%s';",
|
||||
{
|
||||
1,
|
||||
g_nowtime,
|
||||
msg.orderid
|
||||
})) {
|
||||
peding_orders_.erase(msg.orderid);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//支付成功并且gameserver没有确认的订单
|
||||
void OrderMgr::LoadPedingOrders()
|
||||
{
|
||||
@ -615,15 +95,6 @@ void OrderMgr::LoadPedingOrders()
|
||||
}
|
||||
}
|
||||
|
||||
long OrderMgr::GenSeqId()
|
||||
{
|
||||
long new_seqid = 0;
|
||||
seq_mutex_->lock();
|
||||
new_seqid = ++current_seqid_;
|
||||
seq_mutex_->unlock();
|
||||
return new_seqid;
|
||||
}
|
||||
|
||||
std::string OrderMgr::GenOrderId(int itemid, int price)
|
||||
{
|
||||
char orderid[80] = {0};
|
||||
@ -655,13 +126,6 @@ std::string OrderMgr::GenOrderId(int itemid, int price)
|
||||
}
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
int price = 0;
|
||||
Template::RechargeCard *cardtpl = g_configtable->GetRechargeCard(itemid);
|
||||
if (cardtpl) {
|
||||
price = cardtpl->price * 10;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string strorderid;
|
||||
strorderid = a8::Format("%d_%d_%s",
|
||||
|
@ -49,38 +49,6 @@ class OrderMgr : public a8::Singleton<OrderMgr>
|
||||
void UnInit();
|
||||
|
||||
void Update();
|
||||
bool HasTask();
|
||||
|
||||
int AddOrder(const std::string& seqid,
|
||||
const std::string& accountid,
|
||||
const std::string& roleid,
|
||||
const std::string& rolename,
|
||||
const std::string& channel,
|
||||
const std::string& sp_accountid, int serverid,
|
||||
int productid, int price,
|
||||
const std::string& sp_orderid);
|
||||
bool WaitForAddOrderFinished(int seqid,
|
||||
AddOrderResult& addresult,
|
||||
int seconds);
|
||||
|
||||
int AddPayNotify(
|
||||
int pay_type,
|
||||
const std::string& accountid,
|
||||
const std::string& roleid,
|
||||
const std::string& rolename,
|
||||
int serverid,
|
||||
int itemid,
|
||||
const std::string& itemid_str,
|
||||
const std::string& orderid,
|
||||
const std::string& sp_orderid,
|
||||
double fee,
|
||||
int payresult);
|
||||
bool WaitForPayNotifyFinished(int seqid, int& result, int seconds);
|
||||
|
||||
int AddReissue(const std::string& orderid);
|
||||
bool WaitForReissueFinished(int seqid, int& result, int seconds);
|
||||
|
||||
//new
|
||||
bool AddNewOrder(const std::string& accountid,
|
||||
int serverid,
|
||||
const std::string& roleid,
|
||||
@ -98,26 +66,9 @@ class OrderMgr : public a8::Singleton<OrderMgr>
|
||||
void ExecSql(f8::JsonHttpRequest* request);
|
||||
|
||||
private:
|
||||
void ProcessOrderMsg();
|
||||
void ProcessNotifyMsg();
|
||||
void ProcessReissueMsg();
|
||||
bool ProcAddOrder(OrderInfo& orderinfo);
|
||||
int ProcOrderNotify(PayNotifyNode* node);
|
||||
int ContinueSubscriptions(PayNotifyNode* node);
|
||||
int ProcIosPayOrderNotify(PayNotifyNode* node);
|
||||
void ProcReissue(const std::string& orderid);
|
||||
void UpdatePedingOrders();
|
||||
void LoadPedingOrders();
|
||||
std::string GenOrderId(int itemid, int price = 0);
|
||||
long GenSeqId();
|
||||
|
||||
#if 0
|
||||
void _SSMPing(MsgHdr& hdr, const SSMPing& msg);
|
||||
|
||||
void _D2PPayNotifyACK(MsgHdr& hdr, const D2PPayNotifyACK& msg);
|
||||
#endif
|
||||
|
||||
//new
|
||||
int ProcOrderNotifyNew(int pay_type,
|
||||
const std::string& orderid,
|
||||
int payresult);
|
||||
@ -132,29 +83,9 @@ class OrderMgr : public a8::Singleton<OrderMgr>
|
||||
a8::mysql::Query* query_ = nullptr;
|
||||
a8::tick_t last_ping_db_tick_ = 0;
|
||||
|
||||
std::mutex *add_order_mutex_ = nullptr;
|
||||
AddOrderNode *top_node_ = nullptr;
|
||||
AddOrderNode *bot_node_ = nullptr;
|
||||
AddOrderNode *work_node_ = nullptr;
|
||||
|
||||
std::mutex *pay_notify_mutex_ = nullptr;
|
||||
PayNotifyNode *pay_notify_top_node_ = nullptr;
|
||||
PayNotifyNode *pay_notify_bot_node_ = nullptr;
|
||||
PayNotifyNode *pay_notify_work_node_ = nullptr;
|
||||
|
||||
std::mutex *reissue_mutex_ = nullptr;
|
||||
ReissueNode *reissue_top_node_ = nullptr;
|
||||
ReissueNode *reissue_bot_node_ = nullptr;
|
||||
ReissueNode *reissue_work_node_ = nullptr;
|
||||
|
||||
int last_gen_order_time_ = 0;
|
||||
int sub_orderid_ = 0;
|
||||
|
||||
std::mutex *seq_mutex_ = nullptr;
|
||||
volatile int current_seqid_ = 0;
|
||||
std::mutex *add_order_result_mutex_ = nullptr;
|
||||
std::map<int, AddOrderResult> add_order_results_;
|
||||
|
||||
std::mutex *pay_notify_result_mutex_;
|
||||
std::map<int, int> pay_notify_results_;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user