This commit is contained in:
aozhiwei 2022-11-03 15:32:00 +08:00
parent a6bab7fee4
commit f927e44679

View File

@ -136,6 +136,10 @@ class BlockChainController extends BaseAuthedController {
$itemUniId = getReqVal('item_uniid', 0); $itemUniId = getReqVal('item_uniid', 0);
$num = getReqVal('num', 0); $num = getReqVal('num', 0);
$itemDb = Bag::findByUniId($itemUniId); $itemDb = Bag::findByUniId($itemUniId);
if ($num <= 0) {
myself()->_rspErr(1, 'num paramater error');
return;
}
if (!$itemDb || $itemDb['item_num'] < $num) { if (!$itemDb || $itemDb['item_num'] < $num) {
myself()->_rspErr(1, 'item not enough'); myself()->_rspErr(1, 'item not enough');
return; return;
@ -144,12 +148,12 @@ class BlockChainController extends BaseAuthedController {
switch ($itemMeta['type']) { switch ($itemMeta['type']) {
case mt\Item::FRAGMENT_BOX_TYPE: case mt\Item::FRAGMENT_BOX_TYPE:
{ {
$this->internalOpenChipBox($itemDb); $this->internalOpenChipBox($itemDb, $num);
} }
break; break;
case mt\Item::CHIP_BOX_TYPE: case mt\Item::CHIP_BOX_TYPE:
{ {
$this->internalOpenFragmentBox($itemDb); $this->internalOpenFragmentBox($itemDb, $num);
} }
break; break;
default: default:
@ -213,17 +217,16 @@ class BlockChainController extends BaseAuthedController {
} }
} }
private function internalOpenChipBox($itemDb) { private function internalOpenChipBox($itemDb, $num) {
$params = array( $params = array(
'c' => 'BcService', 'c' => 'BcService',
'a' => 'activate1155Nft', 'a' => 'activate1155Nft',
'account_id' => myself()->_getAccountId(), 'account_id' => myself()->_getAccountId(),
'session_id' => myself()->_getSessionId(), 'session_id' => myself()->_getSessionId(),
'account' => myself()->_getOpenId(), 'account' => myself()->_getOpenId(),
'token_id' => $tokenId, 'item_uniid' => $itemDb['item_uniid'],
'token_type' => $tokenType, 'item_id' => $itemDb['item_id'],
'item_uniid' => $itemUniId, 'num' => $num,
'item_id' => $itemId
); );
{ {
$url = self::getWeb3ServiceUrl(); $url = self::getWeb3ServiceUrl();
@ -259,17 +262,16 @@ class BlockChainController extends BaseAuthedController {
} }
} }
private function internalOpenFragmentBox($itemDb) { private function internalOpenFragmentBox($itemDb, $num) {
$params = array( $params = array(
'c' => 'BcService', 'c' => 'BcService',
'a' => 'mintShardBatchUser', 'a' => 'mintShardBatchUser',
'account_id' => myself()->_getAccountId(), 'account_id' => myself()->_getAccountId(),
'session_id' => myself()->_getSessionId(), 'session_id' => myself()->_getSessionId(),
'account' => myself()->_getOpenId(), 'account' => myself()->_getOpenId(),
'token_id' => $tokenId,
'token_type' => $tokenType,
'item_uniid' => $itemUniId, 'item_uniid' => $itemUniId,
'item_id' => $itemId 'item_id' => $itemId,
'num' => $num
); );
{ {
$url = self::getWeb3ServiceUrl(); $url = self::getWeb3ServiceUrl();