This commit is contained in:
hujiabin 2022-10-28 15:07:01 +08:00
parent 8d162f3917
commit d1d7f074f1
4 changed files with 74 additions and 41 deletions

View File

@ -110,7 +110,7 @@ END
myself()->_getMarketMysql(),
't_nft',
array(
'token_id' => myself()->_getNowTime(),
'token_id' => Nft::genTempTokenId(),
'token_type' => $tokenType,
'game_id' => 2006,
'item_id' => $itemId,

View File

@ -269,6 +269,8 @@ class RankingController extends BaseAuthedController {
}
private function calcCECSeasonAward($seasonId){
// $users = User::allUser();
$data = SeasonHistory::getDataBySeasonId($seasonId);
$rewardParamMeta = \mt\Parameter::getByName('rank_ring_reward');
$rewardParamMetaValue = $rewardParamMeta ? $rewardParamMeta['param_value'] : '';

View File

@ -89,7 +89,7 @@ class UserController extends BaseAuthedController {
'item_num' => 10000
),
);
$boxMeta=\mt\Item::getMetaListByType(15);
$boxMeta=\mt\Item::getMetaListByType(\mt\Item::FRAGMENT_BOX_TYPE);
foreach ($boxMeta as $box){
array_push($items,array(
'item_id' => $box['id'],
@ -101,56 +101,43 @@ class UserController extends BaseAuthedController {
$this->_addItems($items,$awardService,$propertyChgService);
}
public function test(){
$this->addChip();
}
private function addChip(){
$list1 = [130001,130002,130003,130004,130005,130006,130007,130008];
$list2 = [130011,130012,130013,130014,130015,130016];
$itemMeta = \mt\Item::getMetaListByType(\mt\Item::CHIP_TYPE);
$list1 = [];
$list2 = [];
foreach ($itemMeta as $value){
switch ($value['sub_type']){
case 1:{
array_push($list1,$value['id']);
};break;
case 2:{
array_push($list2,$value['id']);
};break;
default:{}
}
}
for ($i=1;$i<=15;$i++){
$itemId1 = $list1[rand(0,9)];
$itemId1 = $list1[rand(0,count($list1)-1)];
$itemId2 = $list2[rand(0,count($list2)-1)];
$itemMeta = mt\Item::get($itemId1);
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()+$i+5,
'token_type' => $tokenType,
'game_id' => 2006,
'item_id' => $itemId1,
'owner_address' => myself()->_getOpenId(),
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
)
);
Nft::addNft($itemMeta);
}
}
}
for ($i=16;$i<=30;$i++){
$itemId = $list2[rand(0,5)];
$itemMeta = mt\Item::get($itemId);
if ($itemMeta) {
$tokenType = Nft::getTokenType($itemMeta);
$itemMeta2= mt\Item::get($itemId2);
if ($itemMeta2) {
$tokenType = Nft::getTokenType($itemMeta2);
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()+$i+5,
'token_type' => $tokenType,
'game_id' => 2006,
'item_id' => $itemId,
'owner_address' => myself()->_getOpenId(),
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
)
);
Nft::addNft($itemMeta2);
}
}
}
@ -161,6 +148,7 @@ class UserController extends BaseAuthedController {
$heroMeta = mt\Item::get($heroId);
if ($heroMeta) {
Hero::addHero($heroMeta);
// User::upsertHeadList($heroMeta);
}
}
$addItems =array();

View File

@ -10,6 +10,8 @@ require_once('mt/GunQuality.php');
use mt;
use phpcommon\SqlHelper;
use phpcommon;
class Nft extends BaseModel {
@ -252,7 +254,7 @@ class Nft extends BaseModel {
myself()->_getMarketMysql(),
't_nft',
array(
'token_id' => myself()->_getNowTime()+$num,
'token_id' => self::genTempTokenId(),
'token_type' => $tokenType,
'game_id' => 2006,
'item_id' => $itemMeta['include_item_id'],
@ -270,7 +272,7 @@ class Nft extends BaseModel {
public static function addNft($itemMeta){
if ($itemMeta) {
$tokenID = myself()->_getNowTime();
$tokenID = self::genTempTokenId();
$tokenType = Nft::getTokenType($itemMeta);
if ($tokenType == Nft::NONE_TYPE) {
@ -312,4 +314,45 @@ class Nft extends BaseModel {
));
}
public static function genTempTokenId()
{
$row = SqlHelper::ormSelectOne
(myself()->_getSelfMysql(),
't_realtime_data',
array(
'name' => 'last_token_idx'
)
);
$lastTokenIdx = 0;
if ($row) {
$lastTokenIdx = $row['value1'];
}
++$lastTokenIdx;
$tokenId = myself()->_getNowTime() . phpcommon\pad($lastTokenIdx % 999999, 6);
if ($row) {
SqlHelper::update
(myself()->_getSelfMysql(),
't_realtime_data',
array(
'name' => 'last_token_idx'
),
array(
'value1' => $lastTokenIdx
)
);
} else {
SqlHelper::insert
(myself()->_getSelfMysql(),
't_realtime_data',
array(
'name' => 'last_token_idx',
'value1' => $lastTokenIdx,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
)
);
}
return $tokenId;
}
}