diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index 682db2a5..74f582a5 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -900,6 +900,48 @@ class MarketController extends BaseController { )); } + public function sell() { + $account = strtolower(getReqVal('account', '')); + $item_id = getReqVal('item_id', ''); + $token = getReqVal('token', ''); + $nft_token = getReqVal('nft_token', ''); + $s_price = getReqVal('s_price', ''); + $amount = getReqVal('amount', 1); + $payment_token_address = getReqVal('payment_token_address', ''); + $nonce = getReqVal('nonce', ''); + $signature = getReqVal('signature', ''); + $net_id = getReqVal('net_id', ''); + + $conn = myself()->_getMysql(''); + + $nftDb = Nft::findNftByOwner($account, $nft_token); + $nftDetail = Nft::toDto($nftDb); + $detail = $this->getNftGameData($nftDb); + $r = SqlHelper::insert( + $conn, + 't_market_store', + array( + 'token_id' => $nft_token, + 'token_type' => $nftDetail['type'], + 'owner' => $account, + 'price' => $s_price, + 'amount' => $amount, + 'payment_token_address' => $payment_token_address, + 'status' => 0, + 'create_time' => time(), + 'update_time' => time(), + ) + ); + if (!$r) { + myself()->_rspErr(1, 'insert error'); + return; + } + $this->_rspData(array( + 'nft' => $nftDetail, + 'detail' => $detail, + )); + } + public function sellMyNft() { $account = strtolower(getReqVal('account', '')); @@ -1334,7 +1376,7 @@ class MarketController extends BaseController { private function listMySelledNfts($account, $type) { error_log('listMySelledNfts ' . $account . ' ' . $type); - + $conn = myself()->_getMarketMysql(''); $rows = $conn->execQuery( diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index f975bc72..206fe569 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -1377,7 +1377,8 @@ class ShopController extends BaseAuthedController if (!empty($goods['free_type'])) { $count = $this->countFreeBuyTimes($goods['free_type'], $goods['id'], $goods['goods_id']); $goods['free_num'] = $goods['free_num'] - $count; - error_log('free_num:' . $goods['free_num']); + } else { + $goods['free_num'] = 0; } $free_num = $goods['free_num'];