1
This commit is contained in:
parent
6ef16b7a76
commit
e35f979824
@ -171,6 +171,7 @@ CREATE TABLE `t_nft` (
|
||||
`confirm_block_number` bigint NOT NULL DEFAULT '0' COMMENT 'confirm_block_number',
|
||||
`rand_attr` mediumblob COMMENT '随机属性',
|
||||
`tags` varchar(60) NOT NULL DEFAULT '' COMMENT 'tags',
|
||||
`param1` int(11) NOT NULL DEFAULT '0' COMMENT 'param1',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
|
@ -12,6 +12,7 @@ require_once('models/User.php');
|
||||
require_once('models/Nft.php');
|
||||
require_once('models/Parachute.php');
|
||||
require_once('mt/Parameter.php');
|
||||
require_once('mt/RankSeason.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Bag;
|
||||
@ -348,8 +349,25 @@ class BaseAuthedController extends BaseController {
|
||||
break;
|
||||
case mt\Item::RING_TYPE:
|
||||
{
|
||||
Nft::addNft($itemMeta);
|
||||
$propertyService->addUserChg();
|
||||
// Nft::addNft($itemMeta);
|
||||
$currentSeason = mt\RankSeason::getCurrentSeason();
|
||||
if ($currentSeason){
|
||||
SqlHelper::insert(
|
||||
myself()->_getMarketMysql(),
|
||||
't_nft',
|
||||
array(
|
||||
'token_id' => Nft::genTempTokenId(),
|
||||
'token_type' => Nft::getTokenType($itemMeta),
|
||||
'game_id' => 2006,
|
||||
'item_id' => $itemMeta['id'],
|
||||
'param1' => $currentSeason['id']-1,
|
||||
'owner_address' => myself()->_getOpenId(),
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
)
|
||||
);
|
||||
$propertyService->addUserChg();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case mt\Item::PARACHUTE_TYPE:
|
||||
|
@ -5,6 +5,7 @@ require_once('models/Hero.php');
|
||||
require_once('models/Season.php');
|
||||
require_once('models/Nft.php');
|
||||
require_once('models/Gun.php');
|
||||
require_once('models/UserSeasonRing.php');
|
||||
|
||||
require_once('mt/Parameter.php');
|
||||
require_once('mt/Drop.php');
|
||||
@ -27,6 +28,7 @@ use models\Hero;
|
||||
use models\Gun;
|
||||
use models\Season;
|
||||
use models\Nft;
|
||||
use models\UserSeasonRing;
|
||||
|
||||
class UserController extends BaseAuthedController {
|
||||
private $init_rank = 'rank_init_rank';
|
||||
|
@ -127,9 +127,9 @@ class Gun extends BaseModel {
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($row) {
|
||||
$cb($row);
|
||||
if ($row) {
|
||||
$cb($row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,9 +120,9 @@ class Hero extends BaseModel {
|
||||
);
|
||||
User::upsertHeadList($itemMeta);
|
||||
}
|
||||
}
|
||||
if ($row) {
|
||||
$cb($row);
|
||||
if ($row) {
|
||||
$cb($row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ class Nft extends BaseModel {
|
||||
const CHIP_TYPE = 3; //芯片
|
||||
const BLIND_BOX_TYPE = 4;
|
||||
const FRAGMENT_TYPE = 5; //碎片
|
||||
const RING_TYPE = 19; //碎片
|
||||
const RING_TYPE = 19; //戒指
|
||||
|
||||
const GENESIS_TAG = 1;
|
||||
|
||||
|
@ -3,10 +3,12 @@
|
||||
namespace models;
|
||||
|
||||
require_once('mt/Item.php');
|
||||
require_once('models/UserSeasonRing.php');
|
||||
|
||||
use mt;
|
||||
use phpcommon;
|
||||
use phpcommon\SqlHelper;
|
||||
use models\UserSeasonRing;
|
||||
|
||||
class User extends BaseModel {
|
||||
|
||||
@ -92,6 +94,7 @@ class User extends BaseModel {
|
||||
'guild_id' => $row['guild_id'],
|
||||
'guild_job' => $row['guild_job'],
|
||||
'guild_name' => $row['guild_name'],
|
||||
'ring_list' => UserSeasonRing::ringList($row['account_id'])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2,11 +2,103 @@
|
||||
|
||||
|
||||
namespace models;
|
||||
require_once('services/NftService.php');
|
||||
|
||||
use mt;
|
||||
use phpcommon\SqlHelper;
|
||||
use phpcommon;
|
||||
use services\FormulaService;
|
||||
use services\NftService;
|
||||
|
||||
class UserSeasonRing extends BaseModel
|
||||
{
|
||||
public static function ringList($targetId)
|
||||
{
|
||||
$ringList = array();
|
||||
self::getRingList($targetId,function ($row) use(&$ringList) {
|
||||
$list = array(
|
||||
'item_id' =>$row['item_id'],
|
||||
'season_id' =>$row['season'],
|
||||
);
|
||||
array_push($ringList, $list);
|
||||
});
|
||||
return $ringList;
|
||||
}
|
||||
|
||||
public static function getRingList($targetId,$cb)
|
||||
{
|
||||
SqlHelper::ormSelect(
|
||||
myself()->_getSelfMysql(),
|
||||
't_user_season_ring',
|
||||
array(
|
||||
'account_id' => $targetId
|
||||
),
|
||||
function ($row) use($cb) {
|
||||
$cb($row);
|
||||
}
|
||||
);
|
||||
// print_r(NftService::getRing(phpcommon\extractOpenId($targetId)));die;
|
||||
|
||||
foreach (NftService::getRing(phpcommon\extractOpenId($targetId)) as $nftDb) {
|
||||
if (! $nftDb['deleted']){
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_user_season_ring',
|
||||
array(
|
||||
'token_id' => $nftDb['token_id'],
|
||||
)
|
||||
);
|
||||
if (!$row) {
|
||||
$itemMeta = mt\Item::get($nftDb['item_id']);
|
||||
if ($itemMeta) {
|
||||
self::addNftRing($itemMeta, $nftDb['token_id'],$targetId,$nftDb['param1']);
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_user_season_ring',
|
||||
array(
|
||||
'token_id' => $nftDb['token_id'],
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($row) {
|
||||
$cb($row);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function addNftRing($itemMeta, $tokenId,$accountId,$param1)
|
||||
{
|
||||
return self::internalAddHero(
|
||||
myself()->_getMysql($tokenId),
|
||||
$itemMeta,
|
||||
$accountId,
|
||||
$tokenId,
|
||||
$param1);
|
||||
}
|
||||
|
||||
public static function internalAddHero($conn, $itemMeta, $accountId, $tokenId,$param1)
|
||||
{
|
||||
$fieldsKv = array(
|
||||
'season' => $param1,
|
||||
'item_id' => $itemMeta['id'],
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
);
|
||||
if ($accountId) {
|
||||
$fieldsKv['account_id'] = $accountId;
|
||||
}
|
||||
if ($tokenId) {
|
||||
$fieldsKv['token_id'] = $tokenId;
|
||||
}
|
||||
|
||||
SqlHelper::insert(
|
||||
$conn,
|
||||
't_user_season_ring',
|
||||
$fieldsKv
|
||||
);
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@ class NftService extends BaseService {
|
||||
'hero' => Nft::HERO_TYPE,
|
||||
'equip' => Nft::EQUIP_TYPE,
|
||||
'chip' => Nft::CHIP_TYPE,
|
||||
'fragment' => Nft::FRAGMENT_TYPE,
|
||||
'ring' => Nft::RING_TYPE,
|
||||
);
|
||||
|
||||
public static function isHeroOwner($openId, $tokenId)
|
||||
@ -49,9 +49,9 @@ class NftService extends BaseService {
|
||||
return self::internalGetList($openId, 'chip');
|
||||
}
|
||||
|
||||
public static function getFragments($openId)
|
||||
public static function getRing($openId)
|
||||
{
|
||||
return self::internalGetList($openId, 'fragment');
|
||||
return self::internalGetList($openId, 'ring');
|
||||
}
|
||||
|
||||
private static function internalGetList($openId, $name)
|
||||
|
Loading…
x
Reference in New Issue
Block a user