From 875b67337136e7c2661ed87e5f31d6892a5572fe Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 17 Jan 2022 16:19:39 +0800 Subject: [PATCH] 1 --- webapp/controller/MarketController.class.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index b111e4e1..4f6373f3 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -37,6 +37,19 @@ class MarketController extends BaseController { public function prebuy() { + $account = getReqVal('account', ''); + $goodsId = getReqVal('goods_id', ''); + + $goodsMeta = mt\Market::get($goodsId); + if (!$goodsMeta) { + $this->_rspErr(1, 'config error'); + return; + } + $inventory = Goods::getRemainBuyableNum($meta); + if ($inventory < 0) { + $this->_rspErr(2, 'insufficient inventory'); + return; + } } public function sell() @@ -88,7 +101,7 @@ class MarketController extends BaseController { $nft['type'] = 0; $nft['token_id'] = ''; $nft['status'] = 0; - $nft['inventory'] = 0; + $nft['inventory'] = $inventory; $nft['owner_address'] = ''; $nft['owner_id'] = ''; $nft['image_avatar'] = '';