From 2629b318bdb5414ecc08b90b0da6ada044f6de6f Mon Sep 17 00:00:00 2001 From: songliang Date: Mon, 3 Jul 2023 13:24:22 +0800 Subject: [PATCH 1/2] ... --- webapp/controller/MarketController.class.php | 44 +++++++++++++++++++- webapp/controller/ShopController.class.php | 2 +- 2 files changed, 44 insertions(+), 2 deletions(-) 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..76d4e184 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -1374,10 +1374,10 @@ class ShopController extends BaseAuthedController } } + $goods['free_num'] = 0; 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']); } $free_num = $goods['free_num']; From e7aada85af33971bd5572d62ea7b376796491f5c Mon Sep 17 00:00:00 2001 From: songliang Date: Mon, 3 Jul 2023 13:28:42 +0800 Subject: [PATCH 2/2] ... --- webapp/controller/ShopController.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 76d4e184..206fe569 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -1374,10 +1374,11 @@ class ShopController extends BaseAuthedController } } - $goods['free_num'] = 0; if (!empty($goods['free_type'])) { $count = $this->countFreeBuyTimes($goods['free_type'], $goods['id'], $goods['goods_id']); $goods['free_num'] = $goods['free_num'] - $count; + } else { + $goods['free_num'] = 0; } $free_num = $goods['free_num'];