This commit is contained in:
hujiabin 2022-11-04 14:24:23 +08:00
parent 5ea7b3376c
commit 2ac2470be8
5 changed files with 116 additions and 73 deletions

View File

@ -186,7 +186,7 @@ class BagController extends BaseAuthedController {
$errMsg = 'Parameter error name length must not be less than 3'; $errMsg = 'Parameter error name length must not be less than 3';
return; return;
} }
if (mb_strlen($name, 'utf8') > 16) { if (mb_strlen($name, 'utf8') > 12) {
$errCode = 5; $errCode = 5;
$errMsg = 'Parameter error name length must not be greater than 16'; $errMsg = 'Parameter error name length must not be greater than 16';
return; return;

View File

@ -26,18 +26,22 @@ class ChipController extends BaseAuthedController
{ {
public function chipList() public function chipList()
{ {
$type = getReqVal('type',''); // $type = getReqVal('type','');
if (! $type){ // if (! $type){
$this->_rspErr(1,'Please enter instructions'); // $this->_rspErr(1,'Please enter instructions');
return ; // return ;
} // }
$chipList = Chip::all($type); // $chipList = Chip::all($type);
$chipDtoList = array(); // $chipDtoList = array();
foreach ($chipList as $item) { // foreach ($chipList as $item) {
array_push($chipDtoList, Chip::toDto($item)); // array_push($chipDtoList, Chip::toDto($item));
} // }
$chipList = array();
Chip::getChipList(function ($row) use(&$chipList){
array_push($chipList, Chip::toDto($row));
});
$this->_rspData(array( $this->_rspData(array(
'data' => $chipDtoList, 'data' => $chipList,
)); ));
} }

View File

@ -461,7 +461,7 @@ class GunController extends BaseAuthedController {
} }
public function receive(){ public function receive(){
$this->_rspOk();return;
$type = getReqVal('type', 0); $type = getReqVal('type', 0);
$gunUniId = getReqVal('gun_uniid', 0); $gunUniId = getReqVal('gun_uniid', 0);
$gunDb = Gun::find($gunUniId); $gunDb = Gun::find($gunUniId);
@ -537,6 +537,7 @@ class GunController extends BaseAuthedController {
break; break;
case 2: case 2:
{ {
$this->_rspOk();return;
$idx = 0; $idx = 0;
$found = false; $found = false;
for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) { for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) {

View File

@ -228,7 +228,7 @@ class HeroController extends BaseAuthedController {
public function receive() public function receive()
{ {
$this->_rspOk();return;
$type = getReqVal('type', 0); $type = getReqVal('type', 0);
$heroUniId = getReqVal('hero_uniid', 0); $heroUniId = getReqVal('hero_uniid', 0);
$heroDb = Hero::find($heroUniId); $heroDb = Hero::find($heroUniId);
@ -322,6 +322,7 @@ class HeroController extends BaseAuthedController {
break; break;
case 2: case 2:
{ {
$this->_rspOk();return;
$idx = 0; $idx = 0;
$found = false; $found = false;
for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) { for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) {

View File

@ -30,43 +30,74 @@ class Chip extends BaseModel
public static function getChipList($cb) public static function getChipList($cb)
{ {
// SqlHelper::ormSelect( $sql = "select * from t_nft1155 where owner_address=:owner_address and token_id>10000000 and balance>0";
// myself()->_getSelfMysql(), $whereKv =array(
// 't_chip', 'owner_address' => myself()->_getOpenId(),
// array( );
// 'account_id' => myself()->_getAccountId() foreach (myself()->_getMarketMysql()->execQuery($sql,$whereKv) as $nftDb) {
// ), $row = SqlHelper::ormSelectOne(
// function ($row) use($cb) { myself()->_getSelfMysql(),
// $cb($row); 't_chip',
// } array(
// ); 'token_id' => $nftDb['token_id'],
// foreach (NftService::getChips(myself()->_getOpenId()) as $nftDb) { )
// if (! $nftDb['deleted']){ );
// $row = SqlHelper::ormSelectOne( if ($row){
// myself()->_getSelfMysql(), if (! $row['activate']){
// 't_chip', self::activateChip($row);
// array( $row = SqlHelper::ormSelectOne(
// 'token_id' => $nftDb['token_id'], myself()->_getSelfMysql(),
// ) 't_chip',
// ); array(
// if (!$row) { 'token_id' => $nftDb['token_id'],
// $itemMeta = mt\Item::get($nftDb['item_id']); )
// if ($itemMeta) { );
// self::addChip($nftDb['item_id'], $nftDb['token_id']); $cb($row);
// $row = SqlHelper::ormSelectOne( }else{
// myself()->_getSelfMysql(), $cb($row);
// 't_chip', }
// array( }
// 'token_id' => $nftDb['token_id'],
// ) }
// ); }
// }
// } private static function activateChip($row){
// if ($row) { if (myself()->_isVirtualItem($row['item_id'])) {
// $cb($row); 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) public static function toDto($row)
@ -85,7 +116,7 @@ class Chip extends BaseModel
'attr_id' => $attr['attr_id'], 'attr_id' => $attr['attr_id'],
'type' => 2, '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_name' => $attr['chip_name'],
'chip_type' => $attr['chip_type'], 'chip_type' => $attr['chip_type'],
'attr_num' => $attr['lv'.$row['chip_grade']], 'attr_num' => $attr['lv'.$row['chip_grade']],
@ -102,7 +133,8 @@ class Chip extends BaseModel
} }
public static function belongsToWhere($row){ public static function belongsToWhere($row){
if ($row['chip_type'] == 1){ switch ($row['chip_type']){
case 1:{
$heroDb = array(); $heroDb = array();
Hero::getHeroList(function ($hero) use ($row,&$heroDb) { Hero::getHeroList(function ($hero) use ($row,&$heroDb) {
if ($hero['chip_ids'] && strstr($hero['chip_ids']."|",strval($row['idx']."|")) ){ if ($hero['chip_ids'] && strstr($hero['chip_ids']."|",strval($row['idx']."|")) ){
@ -114,9 +146,9 @@ class Chip extends BaseModel
}else{ }else{
return 0; return 0;
} }
} }
if ($row['chip_type'] == 2){ break;
case 2:{
$gunDb = array(); $gunDb = array();
Gun::getGunList(function ($gun) use($row,&$gunDb) { Gun::getGunList(function ($gun) use($row,&$gunDb) {
if ($gun['chip_ids'] && strstr($gun['chip_ids']."|",strval($row['idx']."|")) ){ if ($gun['chip_ids'] && strstr($gun['chip_ids']."|",strval($row['idx']."|")) ){
@ -129,6 +161,11 @@ class Chip extends BaseModel
return 0; return 0;
} }
} }
break;
default:{
return 0;
}
}
} }
public static function addChip($itemId, $tokenId) public static function addChip($itemId, $tokenId)