This commit is contained in:
aozhiwei 2022-03-31 10:05:15 +08:00
parent c0ae79dd0c
commit 686c953e5d
4 changed files with 75 additions and 1 deletions

View File

@ -93,6 +93,7 @@ DROP TABLE IF EXISTS `t_nft`;
CREATE TABLE `t_nft` ( CREATE TABLE `t_nft` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'token_id', `token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'token_id',
`token_type` int(11) NOT NULL DEFAULT '0' COMMENT 'nft类型 0:英雄 1:枪支 2:芯片',
`game_id` int(11) NOT NULL DEFAULT '0' COMMENT 'game id', `game_id` int(11) NOT NULL DEFAULT '0' COMMENT 'game id',
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id', `item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id',
`owner_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'owner_id', `owner_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'owner_id',

View File

@ -1,9 +1,12 @@
<?php <?php
require_once('mt/Item.php');
require_once('services/AwardService.php'); require_once('services/AwardService.php');
require_once('services/PropertyChgService.php'); require_once('services/PropertyChgService.php');
require_once('models/Nft.php');
use phpcommon\SqlHelper; use phpcommon\SqlHelper;
use models\Nft;
class GMController extends BaseAuthedController { class GMController extends BaseAuthedController {
@ -32,6 +35,9 @@ class GMController extends BaseAuthedController {
'.additem' => function () use($params) { '.additem' => function () use($params) {
$this->addItem($params); $this->addItem($params);
}, },
'.addnft' => function () use($params) {
$this->addNft($params);
},
'.addtili' => function () use($params) { '.addtili' => function () use($params) {
$this->addTili($params); $this->addTili($params);
}, },
@ -59,6 +65,7 @@ class GMController extends BaseAuthedController {
.addtili 英雄id 体力值 //添加英雄体力 .addtili 英雄id 体力值 //添加英雄体力
.getsystime //获取服务器时间 .getsystime //获取服务器时间
.setsystime //设置服务器时间,示例:.setsystime 2021-12-08 00:00:00 .setsystime //设置服务器时间,示例:.setsystime 2021-12-08 00:00:00
.addnft 道具id //添加nft
END END
)); ));
} }
@ -82,6 +89,45 @@ END
)); ));
} }
private function addNft($params)
{
$itemId = getXVal($params, 0, 0);
$propertyChgService = new services\PropertyChgService();
$awardService = new services\AwardService();
$itemMeta = mt\Item::get($itemId);
if ($itemMeta) {
$tokenType = Nft::getTokenType($itemMeta);
if ($tokenType == Nft::NONE_TYPE) {
myself()->_rspErr(1, 'param item_id error');
return;
} else {
SqlHelper::insert(
myself()->_getMarketMysql(),
't_nft',
array(
'token_id' => myself()->_getNowTime(),
'token_type' => $tokenType,
'game_id' => 2006,
'item_id' => $itemId,
'owner_address' => myself()->_getOpenId(),
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
)
);
}
} else {
myself()->_rspErr(1, 'param item_id error');
return;
}
$this->_rspData(array(
'text' => 'add nft success',
'award' => $awardService->toDto(),
'property_chg' => $propertyChgService->toDto(),
));
}
private function addTili($params) private function addTili($params)
{ {
$heroId = getXVal($params, 0, 0); $heroId = getXVal($params, 0, 0);

View File

@ -140,7 +140,7 @@ class Hero extends BaseModel {
{ {
return self::internalAddHero( return self::internalAddHero(
myself()->_getMysql($tokenId), myself()->_getMysql($tokenId),
$gunMeta, $heroMeta,
null, null,
$tokenId); $tokenId);
} }

View File

@ -2,15 +2,42 @@
namespace models; namespace models;
require_once('mt/Item.php');
use mt; use mt;
use phpcommon\SqlHelper; use phpcommon\SqlHelper;
class Nft extends BaseModel { class Nft extends BaseModel {
const NONE_TYPE = -1;
const HERO_TYPE = 0; const HERO_TYPE = 0;
const EQUIP_TYPE = 1; const EQUIP_TYPE = 1;
const CHIP_TYPE = 2; const CHIP_TYPE = 2;
public static function getTokenType($itemMeta)
{
switch ($itemMeta['type']) {
case mt\Item::HERO_TYPE:
{
return self::HERO_TYPE;
}
break;
case mt\Item::GUN_TYPE:
{
return self::EQUIP_TYPE;
}
break;
case mt\Item::MATERIAL_TYPE:
{
if ($itemMeta['sub_type'] == mt\Item::MATERIAL_CHIP_SUBTYPE){
return self::CHIP_TYPE;
}
}
break;
}
return self::NONE_TYPE;
}
public function getNftList($account) public function getNftList($account)
{ {
$nftList = array(); $nftList = array();