From f3f6a73edb00414682ad882493b1984b31f1f5f8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 26 Jul 2023 14:24:26 +0800 Subject: [PATCH] remove BcUser BcShop controller --- doc/BcShop.py | 60 ---- doc/BcUser.py | 23 -- webapp/controller/BcShopController.class.php | 293 ------------------- webapp/controller/BcUserController.class.php | 125 -------- 4 files changed, 501 deletions(-) delete mode 100644 doc/BcShop.py delete mode 100644 doc/BcUser.py delete mode 100644 webapp/controller/BcShopController.class.php delete mode 100644 webapp/controller/BcUserController.class.php diff --git a/doc/BcShop.py b/doc/BcShop.py deleted file mode 100644 index a4eadb88..00000000 --- a/doc/BcShop.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- - -import _common - -class BcShop(object): - - def __init__(self): - self.apis = [ - { - 'name': 'search', - 'desc': '获取出售的商品列表', - 'group': 'BcShop', - 'url': 'webapp/index.php?c=BcShop&a=search', - 'params': [ - ['account', 0, '钱包账号'], - ['page', 0, '获取第几页数据'], - ['sort', '', '排序字段'], - ], - 'response': [ - _common.RspHead(), - ['!rows', [_common.PreSaleBox()], '商品信息'], - ['page', _common.Page(), '分页信息'], - ] - }, - { - 'name': 'buy', - 'desc': '购买', - 'group': 'BcShop', - 'url': 'webapp/index.php?c=BcShop&a=buy', - 'params': [ - ['token', '', 'token'], - ['type', '', '注意是箱子id!!!(box_id)'], - ['buyer_address', '', '购买者账号id'], - ['price', '', 'price'], - ['payment_token_address', '', 'payment_token_address'], - ['nonce', '', 'nonce'], - ['signature', '', '签名soliditySha3(type, payment_token_address, price, nonce), 签名的replace客户端做处理'], - ['net_id', '', '网络id'], - ], - 'response': [ - _common.RspHead(), - ['order_id', '', '订单号(errcode = 0的时候,根据订单号客户端定时调用queryOrder接口)查询状态'], - ] - }, - { - 'name': 'queryOrder', - 'desc': '查询订单状态', - 'group': 'BcShop', - 'url': 'webapp/index.php?c=BcShop&a=queryOrder', - 'params': [ - ['account', 0, '钱包账号'], - ['token', '', 'token'], - ['order_id', 0, '订单id'], - ], - 'response': [ - _common.RspHead(errcode='当errcode!=0的时候客户端不需要再调用(停止定时器)'), - ['state', 0, '0:订单不存在 1:购买成功 2:交易处理中 3:交易失败'], - ] - }, - ] diff --git a/doc/BcUser.py b/doc/BcUser.py deleted file mode 100644 index c581585f..00000000 --- a/doc/BcUser.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- coding: utf-8 -*- - -import _common - -class BcUser(object): - - def __init__(self): - self.apis = [ - { - 'name': 'info', - 'desc': '获取用户信息', - 'group': 'BcUser', - 'url': 'webapp/index.php?c=BcUser&a=login', - 'params': [ - ['account', '', '钱包账号'], - ['token', '', 'token'], - ], - 'response': [ - _common.RspHead(), - _common.BcUserInfo(), - ] - }, - ] diff --git a/webapp/controller/BcShopController.class.php b/webapp/controller/BcShopController.class.php deleted file mode 100644 index 1396ae32..00000000 --- a/webapp/controller/BcShopController.class.php +++ /dev/null @@ -1,293 +0,0 @@ - 0, - 'count' => 0, - 'per_page' => $perPage, - 'current_page' => $page, - 'total_pages' => 0 - ); - $startPos= $pageInfo['per_page'] * ($pageInfo['current_page'] - 1); - - $currBatchMeta = mt\BcShopBatch::getCurrentBatch(); - if ($currBatchMeta) { - $batchMetas = mt\BcShopGoods::getBatchMetas($currBatchMeta['batch_id']); - if ($batchMetas) { - foreach ($batchMetas as $meta) { - $saleBox = $this->fillPresaleBox($currBatchMeta, $meta); - if ($saleBox) { - ++$pageInfo['total']; - if ($pageInfo['total'] > $startPos && - count($rows) < $pageInfo['per_page']) { - array_push($rows, $saleBox); - } - } - } - } - } - - $pageInfo['count'] = count($rows); - $pageInfo['total_pages'] = ceil($pageInfo['total'] / $pageInfo['per_page']); - myself()->_rspData(array( - 'rows' => $rows, - 'page' => $pageInfo, - )); - } - - public function buy() - { - $token = getReqVal('token', ''); - $type = getReqVal('type', ''); - $rawBuyerAddress = getReqVal('buyer_address', ''); - $buyerAddress = strtolower($rawBuyerAddress); - $price = getReqVal('price', ''); - $paymentTokenAddress = getReqVal('payment_token_address', ''); - $nonce = getReqVal('nonce', ''); - $signature = getReqVal('signature', ''); - $netId = getReqVal('net_id', ''); - $gameId = 2006; - $funcId = MarketService::FUNCID_SHOP; - if (!MarketService::isValidToken($buyerAddress, $token)) { - myself()->_rspErr(100, 'invalid token'); - return; - } - MarketService::buyBoxVerifySignature( - $buyerAddress, - $type, - $paymentTokenAddress, - $price, - $nonce, - $signature); - - $batchIdx = 0; - $idx = 0; - $itemId = 0; - if (!phpcommon\extractBoxId($type, $batchIdx, $idx, $itemId)) { - myself()->_rspErr(2, 'type parameter error'); - return; - } - - if (empty($type) || - empty($buyerAddress) || - empty($price) || - empty($paymentTokenAddress) || - empty($signature) || - empty($nonce)) { - myself()->_rspErr(2, 'parameter error'); - return; - } - - $currBatchMeta = mt\MarketBatch::getCurrentBatch(); - if (!$currBatchMeta) { - myself()->_rspErr(500, 'server internal error1'); - return; - } - if ($batchIdx != $currBatchMeta['id']) { - myself()->_rspErr(500, 'server internal error2'); - return; - } - $goodsMeta = mt\MarketGoods::getOnSaleGoods($currBatchMeta['batch_id'], $idx, $itemId); - if (!$goodsMeta) { - myself()->_rspErr(500, 'server internal error3'); - return; - } - /*if ($currBatchMeta['white_list'] && !mt\WhiteList::inWhiteList($buyerAddress)) { - myself()->_rspErr(500, 'not white list user'); - return; - }*/ - $originalPrice = $goodsMeta['price'] * pow(10, MarketService::CURRENCY_DECIMALS); - $discountPrice = $goodsMeta['discount'] * 100 > 0 ? - $originalPrice * $goodsMeta['discount'] : $originalPrice; - - $discountPrice .= MarketService::PRICE_PAD; - error_log('price:' . $price . ' discountPrice:' . $discountPrice); - if (!$discountPrice || strcmp($price, $discountPrice) != 0) { - myself()->_rspErr(500, 'price error'); - return; - } - $itemMeta = mt\Item::get($itemId); - if (!$itemMeta) { - myself()->_rspErr(500, 'server internal error'); - return; - } - $currencyMeta = mt\Currency::get($goodsMeta['currency_id']); - if (!$currencyMeta || $currencyMeta['address'] != $paymentTokenAddress) { - myself()->_rspErr(500, 'currency error'); - return; - } - - if (!phpcommon\isValidBcGameId($gameId)) { - myself()->_rspErr(500, 'server internal error'); - return; - } - - if (!phpcommon\isValidBcTime(myself()->_getNowTime())) { - myself()->_rspErr(500, 'server internal error'); - return; - } - - if (!phpcommon\isValidBcFuncId($funcId)) { - myself()->_rspErr(500, 'server internal error'); - return; - } - - if (!MarketService::isTestMode() && - BoxOrder::isBuyed($buyerAddress, $currBatchMeta['id'])) { - myself()->_rspErr(1, 'account can only choose 1 hero to purchase'); - return; - } - $orderId = BuyRecord::genOrderId($gameId, - $funcId, - myself()->_getNowTime(), - $buyerAddress); - - $fieldsKv = array( - 'game_id' => $gameId, - 'func_id' => $funcId, - 'batch_idx' => $currBatchMeta['id'], - 'type' => $type, - 'raw_buyer_address' => $rawBuyerAddress, - 'buyer_address' => $buyerAddress, - 'price' => $price, - 'payment_token_address' => $paymentTokenAddress, - 'nonce' => $nonce, - 'signature' => $signature, - 'net_id' => $netId, - 'done' => 0, - 'createtime' => myself()->_getNowTime(), - 'modifytime' => myself()->_getNowTime() - ); - $items = array(); - MarketService::openBox($itemMeta, $items); - for ($i = 1; $i <= BoxOrder::MAX_NFT_NUM; ++$i) { - if ($i <= count($items)) { - $tokenId = phpcommon\setOrderIdSubIdx($orderId, $i); - $fieldsKv['bc_mint_tokenid' . $i] = $tokenId; - $fieldsKv['bc_mint_need' . $i] = $items[$i - 1]['need']; - $fieldsKv['bc_mint_itemid' . $i] = $items[$i - 1]['item_id']; - $fieldsKv['bc_mint_token_type' . $i] = $items[$i - 1]['token_type']; - } - } - /*if (MarketService::isTestMode()) { - $fieldsKv['bc_paid'] = 1; - }*/ - $fieldsKv['order_id'] = $orderId; - SqlHelper::insert( - myself()->_getMarketMysql(), - 't_box_order', - $fieldsKv - ); - myself()->_rspData(array( - 'order_id' => $orderId - )); - } - - public function queryOrder() - { - $token = getReqVal('token', ''); - $account = getReqVal('account', ''); - $orderId = getReqVal('order_id', ''); - if (!MarketService::isValidToken($account, $token)) { - myself()->_rspErr(100, 'invalid token'); - return; - } - - $orderDb = BoxOrder::findByOrderId($orderId); - if ($orderDb) { - if (!$orderDb['done']) { - myself()->_rspData(array( - 'state' => 2 - )); - } else { - if ($orderDb['bc_paid'] == 1) { - myself()->_rspData(array( - 'state' => 1 - )); - } else { - myself()->_rspData(array( - 'state' => 3 - )); - } - } - } else { - myself()->_rspData(array( - 'state' => 0 - )); - } - } - - private function fillPresaleBox($batchMeta, $goodsMeta) - { - $currencyMeta = mt\Currency::get($goodsMeta['currency_id']); - if (!$currencyMeta) { - return null; - } - $boxId = phpcommon\genBoxId($batchMeta['id'], - $goodsMeta['id'], - $goodsMeta['item_id']); - - $itemMeta = mt\Item::get($goodsMeta['item_id']); - $originalPrice = $goodsMeta['price'] * pow(10, MarketService::CURRENCY_DECIMALS); - $discountPrice = $goodsMeta['discount'] * 100 > 0 ? - $originalPrice * $goodsMeta['discount'] : $originalPrice; - $name = ''; - $job = 0; - { - $heroMeta = mt\Hero::get($goodsMeta['item_id']); - if ($heroMeta) { - $name = emptyReplace($heroMeta['name'], 'Hill'); - $job = emptyReplace($heroMeta['herotype'], '1'); - } - } - $saleBox = array( - 'box_id' => $boxId, - 'item_id' => $goodsMeta['item_id'], - 'name' => $name, - 'job' => $job, - 'avatar_url' => 'https://www.cebg.games/res/avatars/' . 501 . '.png', - 'currency_list' => array( - array( - 'name' => $currencyMeta['name'], - 'original_price' => $originalPrice, - 'discount_price' => $discountPrice, - 'discount_rate' => $goodsMeta['discount'], - 'decimals' => MarketService::CURRENCY_DECIMALS, - 'contract_address' => $currencyMeta['address'], - ) - )); - return $saleBox; - } - -} diff --git a/webapp/controller/BcUserController.class.php b/webapp/controller/BcUserController.class.php deleted file mode 100644 index dbe49974..00000000 --- a/webapp/controller/BcUserController.class.php +++ /dev/null @@ -1,125 +0,0 @@ -_getMarketMysql($accountId); - $row = SqlHelper::ormSelectOne( - $conn, - 't_user_wallet_offline_temp', - array( - 'account_id' => $accountId, - )); - - $gold = 0; - $diamond = 0; - if ($row) { - $gold = $row['gold']; - $diamond = $row['diamond']; - } - myself()->_rspData(array( - 'gold' => $gold, - 'diamond' => $diamond - )); - } - - private function old_info() - { - $account = strtolower(getReqVal('account', '')); - $token = getReqVal('token', ''); - $gameId = 2006; - $channel = BC_CHANNEL; - $accountId = phpcommon\createAccountId($channel, $gameId, $account); - $conn = myself()->_getMysql($accountId); - $userRow = SqlHelper::ormSelectOne( - $conn, - 't_user', - array( - 'account_id' => $accountId, - )); - $walletOfflineRow = SqlHelper::ormSelectOne( - $conn, - 't_user_wallet_offline', - array( - 'account_id' => $accountId, - )); - if (SERVER_ENV == _TEST) { - if (!$userRow && !$walletOfflineRow) { - SqlHelper::insert( - $conn, - 't_user_wallet_offline', - array( - 'account_id' => $accountId, - 'gold' => 10000, - 'diamond' => 10000, - 'createtime' => myself()->_getNowTime(), - 'modifytime' => myself()->_getNowTime() - ) - ); - } - $userRow = SqlHelper::ormSelectOne( - $conn, - 't_user', - array( - 'account_id' => $accountId, - )); - $walletOfflineRow = SqlHelper::ormSelectOne( - $conn, - 't_user_wallet_offline', - array( - 'account_id' => $accountId, - )); - } - $gold = 0; - $diamond = 0; - if ($userRow) { - $gold += $userRow['gold']; - $diamond += $userRow['diamond']; - } - if ($walletOfflineRow) { - $gold += $walletOfflineRow['gold']; - $diamond += $walletOfflineRow['diamond']; - } - if (SERVER_ENV == _TEST) { - if (!$userRow && !$walletOfflineRow) { - SqlHelper::ormSelectOne( - $conn, - 't_user_wallet_offline', - array( - 'account_id' => $accountId, - )); - } - } - myself()->_rspData(array( - 'account' => $account, - 'gold' => $gold, - 'diamond' => $diamond - )); - } - -}