diff --git a/doc/BlockChain.py b/doc/BlockChain.py index 6e1ce89b..4030351e 100644 --- a/doc/BlockChain.py +++ b/doc/BlockChain.py @@ -102,6 +102,7 @@ class BlockChain(object): 'response': [ _common.RspHead(), ['trans_id', '', '事务id'], + ['order_id', '', '订单id'], ['!params', [''], '合约参数列表'], ] }, diff --git a/webapp/controller/BlockChainController.class.php b/webapp/controller/BlockChainController.class.php index 5c0d001a..5465b2c6 100644 --- a/webapp/controller/BlockChainController.class.php +++ b/webapp/controller/BlockChainController.class.php @@ -34,7 +34,7 @@ use models\BcOrder; use models\Mall; use models\TransactionPrefee; -use services\BlockChainService; +use BlockChainService; class BlockChainController extends BaseAuthedController { @@ -396,22 +396,21 @@ class BlockChainController extends BaseAuthedController { return; } - $rspObj = services\BlockChainService::gameItemMarketBuy( + $rspObj = BlockChainService::gameItemMarketBuy( Transaction::BUY_GOODS_FROM_MARKET_ACTION_TYPE, - $goods['seller_address'], - $goods['currency'], - $goods['price'], - $goods['item_id'], - $goods['item_num'] + $goodsDb['seller_address'], + $goodsDb['currency'], + $goodsDb['price'], + $goodsDb['item_id'], + $goodsDb['item_num'], + $goodsDb['order_id'] ); - if (!$this->markOrderBuyStatus($idx)) { - myself()-_rspErr(1, 'buy failed, update order status failed, idx:' . $idx); - return; - } + Mall::buy($goodsUuid, $address); $this->_rspData(array( 'trans_id' => $rspObj['trans_id'], + 'order_id' => $goodsDb['order_id'], 'params' => $rspObj['params'], )); } diff --git a/webapp/models/Mall.php b/webapp/models/Mall.php index f2846524..b85af783 100644 --- a/webapp/models/Mall.php +++ b/webapp/models/Mall.php @@ -84,6 +84,21 @@ class Mall extends BaseModel { ); } + public static function buy($goodsUuid, $buyer) + { + SqlHelper::update + (myself()->_getMysql(''), + 't_mall', + array( + 'goods_uuid' => $goodsUuid + ), + array( + 'last_buyer' => $buyer, + 'last_buy_time' => myself()->_getNowTime() + ) + ); + } + public static function toDto($row) { $cancelCd = -1; diff --git a/webapp/services/BlockChainService.php b/webapp/services/BlockChainService.php index 91fbea09..3e40c7f0 100644 --- a/webapp/services/BlockChainService.php +++ b/webapp/services/BlockChainService.php @@ -103,7 +103,7 @@ class BlockChainService { c */ - public static function gameItemMarketBuy($actionType, $owner_address, $currency, $price, $itemId, $itemNum) + public static function gameItemMarketBuy($actionType, $owner_address, $currency, $price, $itemId, $itemNum, $orderId) { if (!($actionType > Transaction::BUY_BEGIN_ACTION_TYPE && $actionType < Transaction::BUY_END_ACTION_TYPE)) { @@ -126,6 +126,7 @@ class BlockChainService { 'currency' => $currency, 'price' => $price, 'seller' => $owner_address, + 'order_id' => $orderId, 'net_id' => NET_ID ); {