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(), myself()->_getMarketMysql(),
't_nft', 't_nft',
array( array(
'token_id' => myself()->_getNowTime(), 'token_id' => Nft::genTempTokenId(),
'token_type' => $tokenType, 'token_type' => $tokenType,
'game_id' => 2006, 'game_id' => 2006,
'item_id' => $itemId, 'item_id' => $itemId,

View File

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

View File

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

View File

@ -10,6 +10,8 @@ require_once('mt/GunQuality.php');
use mt; use mt;
use phpcommon\SqlHelper; use phpcommon\SqlHelper;
use phpcommon;
class Nft extends BaseModel { class Nft extends BaseModel {
@ -252,7 +254,7 @@ class Nft extends BaseModel {
myself()->_getMarketMysql(), myself()->_getMarketMysql(),
't_nft', 't_nft',
array( array(
'token_id' => myself()->_getNowTime()+$num, 'token_id' => self::genTempTokenId(),
'token_type' => $tokenType, 'token_type' => $tokenType,
'game_id' => 2006, 'game_id' => 2006,
'item_id' => $itemMeta['include_item_id'], 'item_id' => $itemMeta['include_item_id'],
@ -270,7 +272,7 @@ class Nft extends BaseModel {
public static function addNft($itemMeta){ public static function addNft($itemMeta){
if ($itemMeta) { if ($itemMeta) {
$tokenID = myself()->_getNowTime(); $tokenID = self::genTempTokenId();
$tokenType = Nft::getTokenType($itemMeta); $tokenType = Nft::getTokenType($itemMeta);
if ($tokenType == Nft::NONE_TYPE) { 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;
}
} }