This commit is contained in:
aozhiwei 2023-08-08 09:36:18 +08:00
parent effbf3122e
commit 83fb821a14
4 changed files with 28 additions and 12 deletions

View File

@ -102,6 +102,7 @@ class BlockChain(object):
'response': [
_common.RspHead(),
['trans_id', '', '事务id'],
['order_id', '', '订单id'],
['!params', [''], '合约参数列表'],
]
},

View File

@ -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'],
));
}

View File

@ -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;

View File

@ -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
);
{