From b4d879504e39bff8c3864bc4250e51796f35530d Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Tue, 20 Jun 2023 11:39:23 +0800 Subject: [PATCH] 1 --- webapp/controller/PassController.class.php | 94 +++++++++++----------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/webapp/controller/PassController.class.php b/webapp/controller/PassController.class.php index 7fa6f1ba..9b94eba2 100644 --- a/webapp/controller/PassController.class.php +++ b/webapp/controller/PassController.class.php @@ -184,53 +184,55 @@ class PassController extends BaseAuthedController { )); } -// public function buyPlatinumPass(){ -// if (empty($this->_getAddress())){ -// $this->_rspErr(1, 'address is empty'); -// return; -// } -// $price = getReqVal('price', ''); -// if ($price != \mt\Parameter::getVal('battlepass_price','')){ -// $this->_rspErr(1, 'The price is wrong'); -// return; -// } -// $response = services\BlockChainService::gameItemMallBuy( -// Transaction::BUY_PASS_ACTION_TYPE,$price,V_ITEM_PASS,1); -// -// $this->_setV(TN_DAILY_BUY_PASS_STATE, 0,1); -// BcOrder::upsert($response['trans_id'],array( -// 'item_id'=>V_ITEM_PASS, -// 'item_num'=>1, -// )); -// $this->_rspData($response); -// } + public function buyPlatinumPass(){ + error_log("buyPlatinumPass : " . json_encode($_REQUEST)); + if (!$this->_isValidAddress()){ + $this->_rspErr(1, 'address is empty'); + return; + } + $price = getReqVal('price', ''); + if ($price != \mt\Parameter::getVal('battlepass_price','')){ + $this->_rspErr(1, 'The price is wrong'); + return; + } + $response = services\BlockChainService::gameItemMallBuy( + Transaction::BUY_PASS_ACTION_TYPE,$price,V_ITEM_PASS,1); -// public function buyLevel(){ -// if (empty($this->_getAddress())){ -// $this->_rspErr(1, 'address is empty'); -// return; -// } -// $level = getReqVal('level', ''); -// $price = getReqVal('price', ''); -// $passMeta = \mt\BattlePass::find($level); -// if (!$passMeta){ -// $this->_rspErr(1, 'param level error or null'); -// return; -// } -// $celPrice = ($passMeta['total_exp'] - $this->userInfo['exp']) * \mt\Parameter::getVal('battlepass_buy_lv_price',''); -// if ($celPrice != $price){ -// $this->_rspErr(1, 'The price is wrong'); -// return; -// } -// $response = services\BlockChainService::gameItemMallBuy( -// Transaction::BUY_EXP_ACTION_TYPE,$price,V_ITEM_EXP,$passMeta['total_exp'] - $this->userInfo['exp']); -// $this->_setV(TN_DAILY_BUY_LEVEL_STATE, 0,1); -// BcOrder::upsert($response['trans_id'],array( -// 'item_id'=>V_ITEM_EXP, -// 'item_num'=>$passMeta['total_exp'] - $this->userInfo['exp'], -// )); -// $this->_rspData($response); -// } + $this->_setV(TN_DAILY_BUY_PASS_STATE, 0,1); + BcOrder::upsert($response['trans_id'],array( + 'item_id'=>V_ITEM_PASS, + 'item_num'=>1, + )); + $this->_rspData($response); + } + + public function buyLevel(){ + error_log("buyLevel : " . json_encode($_REQUEST)); + if (!$this->_isValidAddress()){ + $this->_rspErr(1, 'address is empty'); + return; + } + $level = getReqVal('level', ''); + $price = getReqVal('price', ''); + $passMeta = \mt\BattlePass::find($level); + if (!$passMeta){ + $this->_rspErr(1, 'param level error or null'); + return; + } + $celPrice = ($passMeta['total_exp'] - $this->userInfo['exp']) * \mt\Parameter::getVal('battlepass_buy_lv_price',''); + if ($celPrice != $price){ + $this->_rspErr(1, 'The price is wrong'); + return; + } + $response = services\BlockChainService::gameItemMallBuy( + Transaction::BUY_EXP_ACTION_TYPE,$price,V_ITEM_EXP,$passMeta['total_exp'] - $this->userInfo['exp']); + $this->_setV(TN_DAILY_BUY_LEVEL_STATE, 0,1); + BcOrder::upsert($response['trans_id'],array( + 'item_id'=>V_ITEM_EXP, + 'item_num'=>$passMeta['total_exp'] - $this->userInfo['exp'], + )); + $this->_rspData($response); + } public function resetPassLevel(){