From 04e450ce6cf27ee11c3fd3b20d4c370d8edae7e9 Mon Sep 17 00:00:00 2001 From: songliang Date: Mon, 17 Jul 2023 11:27:08 +0800 Subject: [PATCH] ... --- webapp/controller/MarketController.class.php | 33 ++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index bdc2611f..1d5f3e84 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -228,6 +228,8 @@ class MarketController extends BaseAuthedController public function listSellNfts() { + $this->autoRestoreBuyingOrders(); + $account = strtolower(getReqVal('account', '')); $token = getReqVal('token', ''); $start = getReqVal('start', 0); @@ -756,7 +758,7 @@ class MarketController extends BaseAuthedController $goods['amount'] ); - if (!$this->markOrderBuyStatus($idx)) { + if (!$this->markOrderBuying($idx)) { $this->_rspErr(1, 'buy failed, update order status failed, idx:' . $idx); return; } @@ -906,7 +908,7 @@ class MarketController extends BaseAuthedController return $row; } - private function markOrderBuyStatus($idx) + private function markOrderBuying($idx) { $r = SqlHelper::update( myself()->_getSelfMysql(), @@ -925,4 +927,31 @@ class MarketController extends BaseAuthedController return true; } + + private function autoRestoreBuyingOrders() + { + $conn = myself()->_getSelfMysql(); + + $rows = $conn->execQuery( + 'SELECT * FROM t_market_store ' . + 'WHERE status=3 AND buytime<:buytime', + array( + ':buytime' => myself()->_getNowTime() - 3600 * 24 * 1, + ) + ); + + foreach ($rows as $row) { + $r = SqlHelper::update( + myself()->_getSelfMysql(), + 't_market_store', + array( + 'idx' => $row['idx'], + ), + array( + 'status' => 0, + 'buytime' => 0, + ) + ); + } + } }