diff --git a/doc/BlockChain.py b/doc/BlockChain.py index 4e875a39..cfa4ad37 100644 --- a/doc/BlockChain.py +++ b/doc/BlockChain.py @@ -18,6 +18,19 @@ class BlockChain(object): ['!transactions', [_common.NftTransaction()], '交易列表'] ] }, + { + 'name': 'reportResult', + 'desc': '上报链调用结果', + 'group': 'BlockChain', + 'url': 'webapp/index.php?c=BlockChain&a=reportResult', + 'params': [ + ['trans_id', '', '事务id'], + ['result', '', '合约返回值'], + ], + 'response': [ + _common.RspHead(), + ] + }, { 'name': 'active721Nft', 'desc': '激活721nft', @@ -47,19 +60,6 @@ class BlockChain(object): ['!params', [''], '合约参数列表'], ] }, - { - 'name': 'reportActiveResult', - 'desc': '上报激活结果', - 'group': 'BlockChain', - 'url': 'webapp/index.php?c=BlockChain&a=reportActiveResult', - 'params': [ - ['trans_id', '', '事务id'], - ['result', '', '合约返回值'], - ], - 'response': [ - _common.RspHead(), - ] - }, { 'name': 'evolve721Nft', 'desc': 'nft进阶(英雄,武器)', @@ -76,19 +76,6 @@ class BlockChain(object): ['!params', [''], '合约参数列表'], ] }, - { - 'name': 'reportEvolve721NftResult', - 'desc': '上报nft进阶(英雄、武器)结果', - 'group': 'BlockChain', - 'url': 'webapp/index.php?c=BlockChain&a=reportEvolve721NftResult', - 'params': [ - ['trans_id', '', '事务id'], - ['result', '', '合约返回值'], - ], - 'response': [ - _common.RspHead(), - ] - }, { 'name': 'evolveChip', 'desc': '芯片进阶', @@ -104,19 +91,6 @@ class BlockChain(object): ['!params', [''], '合约参数列表'], ] }, - { - 'name': 'reportEvolveChipResult', - 'desc': '上报芯片进阶结果', - 'group': 'BlockChain', - 'url': 'webapp/index.php?c=BlockChain&a=reportEvolveChipResult', - 'params': [ - ['trans_id', '', '事务id'], - ['result', '', '合约返回值'], - ], - 'response': [ - _common.RspHead(), - ] - }, { 'name': 'mintShardBatchUser', 'desc': '碎片生成', @@ -131,19 +105,6 @@ class BlockChain(object): ['!params', [''], '合约参数列表'], ] }, - { - 'name': 'reportMintShardBatchUserResult', - 'desc': '上报碎片生成结果', - 'group': 'BlockChain', - 'url': 'webapp/index.php?c=BlockChain&a=reportMintShardBatchUserResult', - 'params': [ - ['trans_id', '', '事务id'], - ['result', '', '合约返回值'], - ], - 'response': [ - _common.RspHead(), - ] - }, { 'name': 'shardMixByUser', 'desc': '碎片合成', @@ -158,18 +119,5 @@ class BlockChain(object): ['trans_id', '', '事务id'], ['!params', [''], '合约参数列表'], ] - }, - { - 'name': 'reportShardMixByUserUserResult', - 'desc': '上报碎片合成结果', - 'group': 'BlockChain', - 'url': 'webapp/index.php?c=BlockChain&a=reportShardMixByUserResult', - 'params': [ - ['trans_id', '', '事务id'], - ['result', '', '合约返回值'], - ], - 'response': [ - _common.RspHead(), - ] - }, + } ] diff --git a/doc/Shop.py b/doc/Shop.py index 449e26a4..eb20a346 100644 --- a/doc/Shop.py +++ b/doc/Shop.py @@ -69,7 +69,7 @@ class Shop(object): 'name': 'getShopNames', 'desc': '获取商店名称', 'group': 'Shop', - 'url': 'webapp/index.php?c=Shop&a=getShowNames', + 'url': 'webapp/index.php?c=Shop&a=getShopNames', 'params': [ _common.ReqHead() ], diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 3b2dcfb3..3625d209 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -796,6 +796,7 @@ CREATE TABLE `t_transaction` ( `item_uniid` bigint NOT NULL DEFAULT '0' COMMENT '道具uniid', `item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id', `status` int(11) NOT NULL DEFAULT '0' COMMENT 'status', + `client_result` mediumblob COMMENT 'client_result', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), diff --git a/webapp/controller/BlockChainController.class.php b/webapp/controller/BlockChainController.class.php index 8d7bd8c7..10ffb5d3 100644 --- a/webapp/controller/BlockChainController.class.php +++ b/webapp/controller/BlockChainController.class.php @@ -106,9 +106,12 @@ class BlockChainController extends BaseAuthedController { } - public function reportActiveResult() + public function reportResult() { - + $transId = getReqVal('trans_id', ''); + $result = getReqVal('result', ''); + Transaction::reportResult($transId, $result); + myself()->_rspOk(); } public function evolve721Nft() @@ -116,41 +119,21 @@ class BlockChainController extends BaseAuthedController { } - public function reportEvolve721NftResult() - { - - } - public function evolveChip() { } - public function reportEvolveChipResult() - { - - } - public function mintShardBatchUser() { } - public function reportMintShardBatchUserResult() - { - - } - public function shardMixByUser() { } - public function reportShardMixByUserResult() - { - - } - private function internalActivate721Nft($tokenId, $tokenType, $itemUniId, $itemId) { $params = array( diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index d13cbe97..74228cfb 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -67,13 +67,7 @@ class ShopController extends BaseAuthedController { $token_type = getReqVal('token_type', ''); $goods_num = getReqVal('goods_num', 0); - $row = SqlHelper::ormSelectOne( - $this->_getSelfMysql(), - 't_shop_goods', - array( - 'id' => $id, - ) - ); + $row = mt\ShopGoods::get($id); $desired_token_type = $row['token_type']; $check_token_type = splitStr1($desired_token_type); @@ -93,9 +87,7 @@ class ShopController extends BaseAuthedController { switch ($row['limit_type']) { case ShopController::DAILY_BUY_LIMIT: { - $buyRecord = getXVal($buyRecordHash, $id); - echo "===========".json_encode($buyRecord)."-------".$row['limit_num']."..".getXVal($buyRecord, 'this_day_buy_times', 0); $boughtTimes = $buyRecord ? $buyRecord['this_day_buy_times'] + 1: 1; if ($buyRecord && getXVal($buyRecord, 'this_day_buy_times', 0) >= $row['limit_num']) { $this->_rspErr(2, 'Has reached the maximum number of purchase restrictions today'); @@ -143,14 +135,24 @@ class ShopController extends BaseAuthedController { $price_array = splitStr1($row['price']); $discount_array = splitStr1($row['discount']); - + $need_price = $price_array[$token_pos]; $discount = $discount_array[$token_pos]; + $discount_begin = strtotime($row['discount_begin'].' UTC'); + $discount_end = strtotime($row['discount_end'].' UTC'); + $nowTime = $this->_getNowTime(); + + if ($nowTime>=$discount_begin && $nowTime<$discount_end) { + + $need_price = ceil($need_price * ($discount / 100.0)); + } + $costItemId = $this->getCostItemIdByTokenType($token_type); switch($token_type) { case ShopController::TOKEN_TYPE_CEG: + case ShopController::TOKEN_TYPE_CEC: $costItems = $this->makeCostItems($costItemId, $goods_num*$need_price); $lackItem = null; if (!$this->_hasEnoughItems($costItems, $lackItem)) { @@ -193,11 +195,6 @@ class ShopController extends BaseAuthedController { )); break; - case ShopController::TOKEN_TYPE_CEC: - echo "token type: {$token_type} {$need_price} {$discount}"; - - break; - case ShopController::TOKEN_TYPE_BCEG: break; diff --git a/webapp/models/Transaction.php b/webapp/models/Transaction.php index a462255f..7a2fc2c4 100644 --- a/webapp/models/Transaction.php +++ b/webapp/models/Transaction.php @@ -56,7 +56,9 @@ class Transaction extends BaseModel { 'token_type' => $tokenType, 'item_uniid' => $itemUniId, 'item_id' => $itemId, - 'status' => self::CREATED_STATUS + 'status' => self::CREATED_STATUS, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), ) ); } @@ -118,4 +120,20 @@ class Transaction extends BaseModel { } } + public static function reportResult($transId, $result) + { + SqlHelper::update( + myself()->_getSelfMysql(), + 't_transaction', + array( + 'account_id' => myself()->_getAccountId(), + 'trans_id' => $transId + ), + array( + 'client_result' => $result, + 'modifytime' => myself()->_getNowTime() + ) + ); + } + }