1
This commit is contained in:
parent
ee8fd40d10
commit
f8cafa49fd
@ -86,6 +86,19 @@ class Bag extends BaseModel {
|
|||||||
'token_id' => $nftDb['token_id'],
|
'token_id' => $nftDb['token_id'],
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
if (!$row) {
|
||||||
|
$itemMeta = mt\Item::get($nftDb['item_id']);
|
||||||
|
if ($itemMeta) {
|
||||||
|
self::addNftItem($nftDb['item_id'], $nftDb['token_id']);
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_bag',
|
||||||
|
array(
|
||||||
|
'token_id' => $nftDb['token_id'],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
if ($row) {
|
if ($row) {
|
||||||
$cb($row);
|
$cb($row);
|
||||||
}
|
}
|
||||||
@ -110,6 +123,24 @@ class Bag extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function addItem($itemId, $itemNum)
|
public static function addItem($itemId, $itemNum)
|
||||||
|
{
|
||||||
|
return self::internalAddItem(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
$gunMeta,
|
||||||
|
myself()->_getAccountId(),
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function addNftItem($itemId, $tokenId)
|
||||||
|
{
|
||||||
|
return self::internalAddItem(
|
||||||
|
myself()->_getMysql($tokenId),
|
||||||
|
$itemId,
|
||||||
|
null,
|
||||||
|
$tokenId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function internalAddItem($conn, $itemId, $itemNum, $accountId, $tokenId)
|
||||||
{
|
{
|
||||||
if (myself()->_isVirtualItem($itemId)) {
|
if (myself()->_isVirtualItem($itemId)) {
|
||||||
return;
|
return;
|
||||||
@ -129,24 +160,31 @@ class Bag extends BaseModel {
|
|||||||
$randAttr = mt\ChipQuality::getRandAttr($qualityMeta);
|
$randAttr = mt\ChipQuality::getRandAttr($qualityMeta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SqlHelper::insert
|
$fieldsKv = array(
|
||||||
(myself()->_getSelfMysql(),
|
|
||||||
't_bag',
|
|
||||||
array(
|
|
||||||
'account_id' => myself()->_getAccountId(),
|
|
||||||
'item_id' => $itemId,
|
'item_id' => $itemId,
|
||||||
'item_num' => 1,
|
'item_num' => 1,
|
||||||
'rand_attr' => json_encode($randAttr),
|
'rand_attr' => json_encode($randAttr),
|
||||||
'createtime' => myself()->_getNowTime(),
|
'createtime' => myself()->_getNowTime(),
|
||||||
'modifytime' => myself()->_getNowTime()
|
'modifytime' => myself()->_getNowTime()
|
||||||
)
|
|
||||||
);
|
);
|
||||||
} else {
|
if ($accountId) {
|
||||||
|
$fieldsKv['account_id'] = $accountId;
|
||||||
|
}
|
||||||
|
if ($tokenId) {
|
||||||
|
$fieldsKv['token_id'] = $tokenId;
|
||||||
|
}
|
||||||
|
|
||||||
|
SqlHelper::insert
|
||||||
|
($conn,
|
||||||
|
't_bag',
|
||||||
|
$fieldsKv
|
||||||
|
);
|
||||||
|
} else if ($accountId){
|
||||||
SqlHelper::upsert
|
SqlHelper::upsert
|
||||||
(myself()->_getSelfMysql(),
|
($conn,
|
||||||
't_bag',
|
't_bag',
|
||||||
array(
|
array(
|
||||||
'account_id' => myself()->_getAccountId(),
|
'account_id' => $accountId,
|
||||||
'item_id' => $itemId
|
'item_id' => $itemId
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
@ -154,7 +192,7 @@ class Bag extends BaseModel {
|
|||||||
'modifytime' => myself()->_getNowTime(),
|
'modifytime' => myself()->_getNowTime(),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'account_id' => myself()->_getAccountId(),
|
'account_id' => $accountId,
|
||||||
'item_id' => $itemId,
|
'item_id' => $itemId,
|
||||||
'item_num' => $itemNum,
|
'item_num' => $itemNum,
|
||||||
'createtime' => myself()->_getNowTime(),
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
@ -4,6 +4,7 @@ namespace models;
|
|||||||
|
|
||||||
require_once('mt/GunLevel.php');
|
require_once('mt/GunLevel.php');
|
||||||
require_once('mt/GunQuality.php');
|
require_once('mt/GunQuality.php');
|
||||||
|
require_once('mt/Item.php');
|
||||||
require_once('models/GunSkin.php');
|
require_once('models/GunSkin.php');
|
||||||
require_once('services/NftService.php');
|
require_once('services/NftService.php');
|
||||||
|
|
||||||
@ -70,6 +71,19 @@ class Gun extends BaseModel {
|
|||||||
'token_id' => $nftDb['token_id'],
|
'token_id' => $nftDb['token_id'],
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
if (!$row) {
|
||||||
|
$itemMeta = mt\Item::get($nftDb['item_id']);
|
||||||
|
if ($itemMeta) {
|
||||||
|
self::addNftGun($itemMeta, $nftDb['token_id']);
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_gun',
|
||||||
|
array(
|
||||||
|
'token_id' => $nftDb['token_id'],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
if ($row) {
|
if ($row) {
|
||||||
$cb($row);
|
$cb($row);
|
||||||
}
|
}
|
||||||
@ -106,6 +120,24 @@ class Gun extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function addGun($gunMeta)
|
public static function addGun($gunMeta)
|
||||||
|
{
|
||||||
|
return self::internalAddGun(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
$gunMeta,
|
||||||
|
myself()->_getAccountId(),
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function addNftGun($gunMeta, $tokenId)
|
||||||
|
{
|
||||||
|
return self::internalAddGun(
|
||||||
|
myself()->_getMysql($tokenId),
|
||||||
|
$gunMeta,
|
||||||
|
null,
|
||||||
|
$tokenId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function internalAddGun($conn, $gunMeta, $accountId, $tokenId)
|
||||||
{
|
{
|
||||||
$randAttr = array();
|
$randAttr = array();
|
||||||
{
|
{
|
||||||
@ -114,11 +146,7 @@ class Gun extends BaseModel {
|
|||||||
$randAttr = mt\GunQuality::getRandAttr($initQualityMeta);
|
$randAttr = mt\GunQuality::getRandAttr($initQualityMeta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SqlHelper::insert(
|
$fieldsKv = array(
|
||||||
myself()->_getSelfMysql(),
|
|
||||||
't_gun',
|
|
||||||
array(
|
|
||||||
'account_id' => myself()->_getAccountId(),
|
|
||||||
'gun_id' => $gunMeta['id'],
|
'gun_id' => $gunMeta['id'],
|
||||||
'gun_lv' => 1,
|
'gun_lv' => 1,
|
||||||
'quality' => 1,
|
'quality' => 1,
|
||||||
@ -129,7 +157,18 @@ class Gun extends BaseModel {
|
|||||||
'unlock_trade_time' => 0,
|
'unlock_trade_time' => 0,
|
||||||
'createtime' => myself()->_getNowTime(),
|
'createtime' => myself()->_getNowTime(),
|
||||||
'modifytime' => myself()->_getNowTime()
|
'modifytime' => myself()->_getNowTime()
|
||||||
)
|
);
|
||||||
|
if (!$accountId) {
|
||||||
|
$fieldsKv['account_id'] = $accountId;
|
||||||
|
}
|
||||||
|
if ($tokenId) {
|
||||||
|
$fieldsKv['token_id'] = $tokenId;
|
||||||
|
}
|
||||||
|
|
||||||
|
SqlHelper::insert(
|
||||||
|
$conn,
|
||||||
|
't_gun',
|
||||||
|
$fieldsKv
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ require_once('mt/Hero.php');
|
|||||||
require_once('mt/HeroLevel.php');
|
require_once('mt/HeroLevel.php');
|
||||||
require_once('mt/HeroQuality.php');
|
require_once('mt/HeroQuality.php');
|
||||||
require_once('mt/AttrHelper.php');
|
require_once('mt/AttrHelper.php');
|
||||||
|
require_once('mt/Item.php');
|
||||||
require_once('models/HeroSkin.php');
|
require_once('models/HeroSkin.php');
|
||||||
require_once('services/NftService.php');
|
require_once('services/NftService.php');
|
||||||
|
|
||||||
@ -72,6 +73,19 @@ class Hero extends BaseModel {
|
|||||||
'token_id' => $nftDb['token_id'],
|
'token_id' => $nftDb['token_id'],
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
if (!$row) {
|
||||||
|
$itemMeta = mt\Item::get($nftDb['item_id']);
|
||||||
|
if ($itemMeta) {
|
||||||
|
self::addNftHero($itemMeta, $nftDb['token_id']);
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_hero',
|
||||||
|
array(
|
||||||
|
'token_id' => $nftDb['token_id'],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
if ($row) {
|
if ($row) {
|
||||||
$cb($row);
|
$cb($row);
|
||||||
}
|
}
|
||||||
@ -113,6 +127,24 @@ class Hero extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function addHero($heroMeta)
|
public static function addHero($heroMeta)
|
||||||
|
{
|
||||||
|
return self::internalAddHero(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
$gunMeta,
|
||||||
|
myself()->_getAccountId(),
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function addNftHero($heroMeta, $tokenId)
|
||||||
|
{
|
||||||
|
return self::internalAddHero(
|
||||||
|
myself()->_getMysql($tokenId),
|
||||||
|
$gunMeta,
|
||||||
|
null,
|
||||||
|
$tokenId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function internalAddHero($conn, $heroMeta, $accountId, $tokenId)
|
||||||
{
|
{
|
||||||
$realHeroMeta = mt\Hero::get($heroMeta['id']);
|
$realHeroMeta = mt\Hero::get($heroMeta['id']);
|
||||||
$randAttr = array();
|
$randAttr = array();
|
||||||
@ -122,11 +154,7 @@ class Hero extends BaseModel {
|
|||||||
$randAttr = mt\HeroQuality::getRandAttr($initQualityMeta);
|
$randAttr = mt\HeroQuality::getRandAttr($initQualityMeta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SqlHelper::insert(
|
$fieldKv = array(
|
||||||
myself()->_getSelfMysql(),
|
|
||||||
't_hero',
|
|
||||||
array(
|
|
||||||
'account_id' => myself()->_getAccountId(),
|
|
||||||
'hero_id' => $heroMeta['id'],
|
'hero_id' => $heroMeta['id'],
|
||||||
'hero_lv' => 1,
|
'hero_lv' => 1,
|
||||||
'quality' => 1,
|
'quality' => 1,
|
||||||
@ -140,7 +168,18 @@ class Hero extends BaseModel {
|
|||||||
'unlock_trade_time' => 0,
|
'unlock_trade_time' => 0,
|
||||||
'createtime' => myself()->_getNowTime(),
|
'createtime' => myself()->_getNowTime(),
|
||||||
'modifytime' => myself()->_getNowTime()
|
'modifytime' => myself()->_getNowTime()
|
||||||
)
|
);
|
||||||
|
if ($accountId) {
|
||||||
|
$fieldsKv['account_id'] = $accountId;
|
||||||
|
}
|
||||||
|
if ($tokenId) {
|
||||||
|
$fieldKv['token_id'] = $tokenId;
|
||||||
|
}
|
||||||
|
|
||||||
|
SqlHelper::insert(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_hero',
|
||||||
|
$fieldKv
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user