game2006api/webapp/controller/BlockChainController.class.php
aozhiwei e3e8e95072 1
2022-11-02 10:19:08 +08:00

167 lines
3.9 KiB
PHP

<?php
require_once('mt/Parameter.php');
require_once('mt/Item.php');
require_once('mt/Drop.php');
require_once('mt/Hero.php');
require_once('models/Bag.php');
require_once('models/Hero.php');
require_once('models/Gun.php');
require_once('models/Nft.php');
require_once('models/Transaction.php');
require_once('models/BuyRecord.php');
require_once('services/AwardService.php');
require_once('services/PropertyChgService.php');
require_once('services/NameService.php');
use phpcommon\SqlHelper;
use models\Bag;
use models\Hero;
use models\Gun;
use models\Nft;
use models\Transaction;
use models\BuyRecord;
class BlockChainController extends BaseAuthedController {
public function getTransactionList()
{
$trans = array();
foreach (Transaction::all() as $tran) {
array_push(
$trans,
array(
'trans_id' => $tran['trans_id'],
'item_id' => $tran['item_id'],
'action' => Transaction::getActionDesc($tran['action']),
'status' => Transaction::getActionDesc($tran['status']),
'time' => $tran['createtime'],
)
);
}
$this->_rspData(array(
'transactions' => $trans
));
}
public function active721Nft()
{
$type = getReqVal('type', 0);
$uniid = getReqVal('uniid', 0);
switch ($type) {
case 1:
{
$heroDb = Hero::find($uuid);
if (!$heroDb) {
myself()->_rspErr(1, 'hero not found');
return;
}
if ($heroDb['token_id']) {
myself()->_rspErr(1, 'already activated');
return;
}
$tokenId = $heroDb['active_token_id'];
if (!$tokenId) {
$tokenId = BuyRecord::genOrderId
(
2006,
phpcommon\BC_FUNC_CREATION,
myself()->_getNowTime(),
myself()->_getOpenId()
);
Hero::Update($heroDb['hero_uniid'],
array(
'active_token_id' => $tokenId,
'active_count' => function () {
return 'active_count + 1';
}
));
}
$this->internalActivate721Nft($tokenId, Nft::HERO_TYPE, $heroDb['hero_uniid'], $heroDb['hero_id']);
}
break;
case 2:
{
$gunDb = Gun::find($uuid);
if (!$gunDb) {
myself()->_rspErr(1, 'gun not found');
return;
}
}
break;
default:
{
myself()->_rspErr(1, 'type param error');
return;
}
break;
}
}
public function active1155Nft()
{
}
public function reportActiveResult()
{
}
public function evolve721Nft()
{
}
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(
'account_id' => myself()->_getAccountId(),
'session_id' => myself()->_getSessionId(),
'token_id' => $tokenId,
'token_type' => $tokenType,
'item_uniid' => $itemUniId,
'item_id' => $itemId
);
}
}