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'] = '';