From 2ac2470be895a48a413d5ee080ea3ae89f2f4e1b Mon Sep 17 00:00:00 2001 From: hujiabin Date: Fri, 4 Nov 2022 14:24:23 +0800 Subject: [PATCH] 1 --- webapp/controller/BagController.class.php | 2 +- webapp/controller/ChipController.class.php | 26 ++-- webapp/controller/GunController.class.php | 3 +- webapp/controller/HeroController.class.php | 3 +- webapp/models/Chip.php | 155 +++++++++++++-------- 5 files changed, 116 insertions(+), 73 deletions(-) diff --git a/webapp/controller/BagController.class.php b/webapp/controller/BagController.class.php index ed3f1a80..d7051dfa 100644 --- a/webapp/controller/BagController.class.php +++ b/webapp/controller/BagController.class.php @@ -186,7 +186,7 @@ class BagController extends BaseAuthedController { $errMsg = 'Parameter error name length must not be less than 3'; return; } - if (mb_strlen($name, 'utf8') > 16) { + if (mb_strlen($name, 'utf8') > 12) { $errCode = 5; $errMsg = 'Parameter error name length must not be greater than 16'; return; diff --git a/webapp/controller/ChipController.class.php b/webapp/controller/ChipController.class.php index 9951aa7c..e6824dfd 100644 --- a/webapp/controller/ChipController.class.php +++ b/webapp/controller/ChipController.class.php @@ -26,18 +26,22 @@ class ChipController extends BaseAuthedController { public function chipList() { - $type = getReqVal('type',''); - if (! $type){ - $this->_rspErr(1,'Please enter instructions'); - return ; - } - $chipList = Chip::all($type); - $chipDtoList = array(); - foreach ($chipList as $item) { - array_push($chipDtoList, Chip::toDto($item)); - } +// $type = getReqVal('type',''); +// if (! $type){ +// $this->_rspErr(1,'Please enter instructions'); +// return ; +// } +// $chipList = Chip::all($type); +// $chipDtoList = array(); +// foreach ($chipList as $item) { +// array_push($chipDtoList, Chip::toDto($item)); +// } + $chipList = array(); + Chip::getChipList(function ($row) use(&$chipList){ + array_push($chipList, Chip::toDto($row)); + }); $this->_rspData(array( - 'data' => $chipDtoList, + 'data' => $chipList, )); } diff --git a/webapp/controller/GunController.class.php b/webapp/controller/GunController.class.php index 558ef3a1..b2aa1c39 100644 --- a/webapp/controller/GunController.class.php +++ b/webapp/controller/GunController.class.php @@ -461,7 +461,7 @@ class GunController extends BaseAuthedController { } public function receive(){ - $this->_rspOk();return; + $type = getReqVal('type', 0); $gunUniId = getReqVal('gun_uniid', 0); $gunDb = Gun::find($gunUniId); @@ -537,6 +537,7 @@ class GunController extends BaseAuthedController { break; case 2: { + $this->_rspOk();return; $idx = 0; $found = false; for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) { diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index 521d2fa5..82275e25 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -228,7 +228,7 @@ class HeroController extends BaseAuthedController { public function receive() { - $this->_rspOk();return; + $type = getReqVal('type', 0); $heroUniId = getReqVal('hero_uniid', 0); $heroDb = Hero::find($heroUniId); @@ -322,6 +322,7 @@ class HeroController extends BaseAuthedController { break; case 2: { + $this->_rspOk();return; $idx = 0; $found = false; for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) { diff --git a/webapp/models/Chip.php b/webapp/models/Chip.php index 31b5b1d4..fd8b39c4 100644 --- a/webapp/models/Chip.php +++ b/webapp/models/Chip.php @@ -30,43 +30,74 @@ class Chip extends BaseModel public static function getChipList($cb) { -// SqlHelper::ormSelect( -// myself()->_getSelfMysql(), -// 't_chip', -// array( -// 'account_id' => myself()->_getAccountId() -// ), -// function ($row) use($cb) { -// $cb($row); -// } -// ); -// foreach (NftService::getChips(myself()->_getOpenId()) as $nftDb) { -// if (! $nftDb['deleted']){ -// $row = SqlHelper::ormSelectOne( -// myself()->_getSelfMysql(), -// 't_chip', -// array( -// 'token_id' => $nftDb['token_id'], -// ) -// ); -// if (!$row) { -// $itemMeta = mt\Item::get($nftDb['item_id']); -// if ($itemMeta) { -// self::addChip($nftDb['item_id'], $nftDb['token_id']); -// $row = SqlHelper::ormSelectOne( -// myself()->_getSelfMysql(), -// 't_chip', -// array( -// 'token_id' => $nftDb['token_id'], -// ) -// ); -// } -// } -// if ($row) { -// $cb($row); -// } -// } -// } + $sql = "select * from t_nft1155 where owner_address=:owner_address and token_id>10000000 and balance>0"; + $whereKv =array( + 'owner_address' => myself()->_getOpenId(), + ); + foreach (myself()->_getMarketMysql()->execQuery($sql,$whereKv) as $nftDb) { + $row = SqlHelper::ormSelectOne( + myself()->_getSelfMysql(), + 't_chip', + array( + 'token_id' => $nftDb['token_id'], + ) + ); + if ($row){ + if (! $row['activate']){ + self::activateChip($row); + $row = SqlHelper::ormSelectOne( + myself()->_getSelfMysql(), + 't_chip', + array( + 'token_id' => $nftDb['token_id'], + ) + ); + $cb($row); + }else{ + $cb($row); + } + } + + } + } + + private static function activateChip($row){ + if (myself()->_isVirtualItem($row['item_id'])) { + return; + } + if ($row['item_num'] <= 0) { + return; + } + $itemMeta = mt\Item::get($row['item_id']); + if (!$itemMeta) { + return; + } + $randAttr = array(); + if (mt\Item::isRoleChipItem($itemMeta)) { + $randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$row['chip_grade']); + } + if (mt\Item::isGunChipItem($itemMeta)) { + $randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$row['chip_grade']); + } + if ($row['chip_grade'] >= 5){ + $lucky = ltrim(\services\FormulaService::getChipLuckyValue($row['chip_grade']),'-') ; + $fieldsKv = array( + 'supper_state'=>1, + 'lucky_temporary'=>$lucky, + 'chip_type' => $itemMeta['sub_type'], + 'rand_attr' => json_encode($randAttr), + 'activate' => 1, + 'modifytime' => myself()->_getNowTime() + ); + }else{ + $fieldsKv = array( + 'chip_type' => $itemMeta['sub_type'], + 'rand_attr' => json_encode($randAttr), + 'activate' => 1, + 'modifytime' => myself()->_getNowTime() + ); + } + self::update($row['token_id'],$fieldsKv); } public static function toDto($row) @@ -85,7 +116,7 @@ class Chip extends BaseModel 'attr_id' => $attr['attr_id'], 'type' => 2, - 'val' => $attr['lv'.$row['chip_grade']]*$val['attr_pool_number'], + 'val' => strval($attr['lv'.$row['chip_grade']]*$val['attr_pool_number']), // 'chip_name' => $attr['chip_name'], 'chip_type' => $attr['chip_type'], 'attr_num' => $attr['lv'.$row['chip_grade']], @@ -102,30 +133,36 @@ class Chip extends BaseModel } public static function belongsToWhere($row){ - if ($row['chip_type'] == 1){ - $heroDb = array(); - Hero::getHeroList(function ($hero) use ($row,&$heroDb) { - if ($hero['chip_ids'] && strstr($hero['chip_ids']."|",strval($row['idx']."|")) ){ - $heroDb = $hero; + switch ($row['chip_type']){ + case 1:{ + $heroDb = array(); + Hero::getHeroList(function ($hero) use ($row,&$heroDb) { + if ($hero['chip_ids'] && strstr($hero['chip_ids']."|",strval($row['idx']."|")) ){ + $heroDb = $hero; + } + }); + if($heroDb){ + return $heroDb['hero_id']; + }else{ + return 0; } - }); - if($heroDb){ - return $heroDb['hero_id']; - }else{ - return 0; } - - } - if ($row['chip_type'] == 2){ - $gunDb = array(); - Gun::getGunList(function ($gun) use($row,&$gunDb) { - if ($gun['chip_ids'] && strstr($gun['chip_ids']."|",strval($row['idx']."|")) ){ - $gunDb = $gun; + break; + case 2:{ + $gunDb = array(); + Gun::getGunList(function ($gun) use($row,&$gunDb) { + if ($gun['chip_ids'] && strstr($gun['chip_ids']."|",strval($row['idx']."|")) ){ + $gunDb = $gun; + } + }); + if($gunDb){ + return $gunDb['gun_id']; + }else{ + return 0; } - }); - if($gunDb){ - return $gunDb['gun_id']; - }else{ + } + break; + default:{ return 0; } }