1
This commit is contained in:
parent
e96a0a8bdb
commit
57afca9c1b
@ -12,6 +12,7 @@ require_once('models/UserWalletRecord.php');
|
||||
require_once('models/NftUpEvent.php');
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/Gun.php');
|
||||
require_once('models/Chip.php');
|
||||
require_once('models/DynData.php');
|
||||
|
||||
require_once('phpcommon/bchelper.php');
|
||||
@ -24,10 +25,19 @@ use models\UserWalletRecord;
|
||||
use models\NftUpEvent;
|
||||
use models\Hero;
|
||||
use models\Gun;
|
||||
use models\Chip;
|
||||
use models\DynData;
|
||||
|
||||
class CallbackController extends BaseController {
|
||||
private $accountId;
|
||||
|
||||
public function _handlePre()
|
||||
{
|
||||
$account = strtolower(getReqVal('account', ''));
|
||||
$gameId = 2006;
|
||||
$channel = BC_CHANNEL;
|
||||
$this->accountId = phpcommon\createAccountId($channel, $gameId, $account);
|
||||
}
|
||||
private function isTestMode()
|
||||
{
|
||||
return isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443 && SERVER_ENV == _TEST;
|
||||
@ -146,11 +156,17 @@ class CallbackController extends BaseController {
|
||||
myself()->_rspErr(1, 'param error');
|
||||
return;
|
||||
}
|
||||
if (NftUpEvent::find($transId)){
|
||||
if (NftUpEvent::find($this->accountId,$transId)){
|
||||
myself()->_rspOk();
|
||||
return;
|
||||
}
|
||||
$heroDb = Hero::findByTokenId($tokenId);
|
||||
$heroDb = SqlHelper::ormSelectOne(
|
||||
myself()->_getMysql($this->accountId),
|
||||
't_hero',
|
||||
array(
|
||||
'token_id' => $tokenId,
|
||||
)
|
||||
);
|
||||
if ( !$heroDb ){
|
||||
myself()->_rspErr(1, 'token_id param error');
|
||||
return;
|
||||
@ -160,27 +176,17 @@ class CallbackController extends BaseController {
|
||||
$this->_rspErr(1, 'quality is full');
|
||||
return;
|
||||
}
|
||||
// $idx = 0;
|
||||
// $found = false;
|
||||
// for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) {
|
||||
// $upHeroUniId = DynData::getV(TN_HERO_QUALITY_UP, $i);
|
||||
// if ($upHeroUniId == $heroDb['idx']) {
|
||||
// $idx = $i;
|
||||
// $found = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (!$found) {
|
||||
// $this->_rspErr(1, 'hero does not exist');
|
||||
// return;
|
||||
// }
|
||||
// DynData::setV(TN_HERO_QUALITY_UP, $idx, 0);
|
||||
// DynData::setV(TN_HERO_QUALITY_UP, (int)$idx + 1000, 0);
|
||||
|
||||
$heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($heroDb['quality']);
|
||||
$nextHeroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($quality);
|
||||
$heroTili = \services\FormulaService::Hero_NFT_Maximum_Physical_Strength($heroDb['quality'],$heroLucky);
|
||||
$nextHeroTili = \services\FormulaService::Hero_NFT_Maximum_Physical_Strength($quality,$nextHeroLucky);
|
||||
Hero::updateByTokenId($tokenId,
|
||||
SqlHelper::update
|
||||
( myself()->_getMysql($this->accountId),
|
||||
't_hero',
|
||||
array(
|
||||
'token_id' => $tokenId,
|
||||
),
|
||||
array(
|
||||
'hero_tili' => $heroDb['hero_tili']+($nextHeroTili-$heroTili),
|
||||
'skill_points' => $heroDb['skill_points'] + $nextQualityMeta['skill_point'],
|
||||
@ -191,7 +197,7 @@ class CallbackController extends BaseController {
|
||||
'labour' => 0,
|
||||
)
|
||||
);
|
||||
NftUpEvent::add(
|
||||
NftUpEvent::add($this->accountId,
|
||||
array(
|
||||
'trans_id' => $transId,
|
||||
'token_id' => $tokenId,
|
||||
@ -200,11 +206,6 @@ class CallbackController extends BaseController {
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
)
|
||||
);
|
||||
if ($quality > myself()->_getV(TN_HERO_MAX_QUALITY, 0)) {
|
||||
myself()->_setV(TN_HERO_MAX_QUALITY, 0, $quality);
|
||||
}
|
||||
$rankActivityService = new services\RankActivityService();
|
||||
$rankActivityService->heroUpgradeQuality($quality);
|
||||
myself()->_rspOk();
|
||||
}
|
||||
public function gunUpgradeQuality(){
|
||||
@ -215,11 +216,17 @@ class CallbackController extends BaseController {
|
||||
myself()->_rspErr(1, 'param error');
|
||||
return;
|
||||
}
|
||||
if (NftUpEvent::find($transId)){
|
||||
if (NftUpEvent::find($this->accountId,$transId)){
|
||||
myself()->_rspOk();
|
||||
return;
|
||||
}
|
||||
$gunDb = Gun::findByTokenId($tokenId);
|
||||
$gunDb =SqlHelper::ormSelectOne(
|
||||
myself()->_getMysql($this->accountId),
|
||||
't_gun',
|
||||
array(
|
||||
'token_id' => $tokenId,
|
||||
)
|
||||
);
|
||||
if ( !$gunDb ){
|
||||
myself()->_rspErr(1, 'token_id param error');
|
||||
return;
|
||||
@ -229,28 +236,17 @@ class CallbackController extends BaseController {
|
||||
$this->_rspErr(1, 'quality is full');
|
||||
return;
|
||||
}
|
||||
// $idx = 0;
|
||||
// $found = false;
|
||||
// for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) {
|
||||
// $upGunUniId = DynData::getV(TN_GUN_QUALITY_UP, $i);
|
||||
// if ($upGunUniId == $gunDb['idx']) {
|
||||
// $idx = $i;
|
||||
// $found = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (!$found) {
|
||||
// $this->_rspErr(1, 'gun does not exist');
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// DynData::setV(TN_GUN_QUALITY_UP, $idx, 0);
|
||||
// DynData::setV(TN_GUN_QUALITY_UP, (int)$idx + 1000, 0);
|
||||
$gunLucky = \services\FormulaService::Weapon_Advanced_Lucky_Value($gunDb['quality']);
|
||||
$nextGunLucky = \services\FormulaService::Weapon_Advanced_Lucky_Value($quality);
|
||||
$durability = \services\FormulaService::Weapon_NFT_Maximum_Durability($gunDb['quality'],$gunLucky);
|
||||
$nextDurability = \services\FormulaService::Weapon_NFT_Maximum_Durability($quality,$nextGunLucky);
|
||||
Gun::updateByTokenId($tokenId,
|
||||
|
||||
SqlHelper::update
|
||||
(myself()->_getMysql($this->accountId),
|
||||
't_gun',
|
||||
array(
|
||||
'token_id' => $tokenId,
|
||||
),
|
||||
array(
|
||||
'durability' => $gunDb['durability']+($nextDurability-$durability),
|
||||
'quality' => $quality,
|
||||
@ -259,7 +255,7 @@ class CallbackController extends BaseController {
|
||||
'labour' => 0,
|
||||
)
|
||||
);
|
||||
NftUpEvent::add(
|
||||
NftUpEvent::add($this->accountId,
|
||||
array(
|
||||
'trans_id' => $transId,
|
||||
'token_id' => $tokenId,
|
||||
@ -268,11 +264,71 @@ class CallbackController extends BaseController {
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
)
|
||||
);
|
||||
if ($quality > myself()->_getV(TN_GUN_MAX_QUALITY, 0)) {
|
||||
myself()->_setV(TN_GUN_MAX_QUALITY, 0, $quality);
|
||||
myself()->_rspOk();
|
||||
}
|
||||
|
||||
public function chipUpgradeGrade(){
|
||||
$transId = getReqVal('trans_id', '0');
|
||||
$tokenId = getReqVal('token_id', '0');
|
||||
$grade = getReqVal('grade', '0');
|
||||
if (!$transId || !$tokenId || !$grade){
|
||||
myself()->_rspErr(1, 'param error');
|
||||
return;
|
||||
}
|
||||
$rankActivityService = new services\RankActivityService();
|
||||
$rankActivityService->heroUpgradeQuality($quality);
|
||||
if (NftUpEvent::find($this->accountId,$transId)){
|
||||
myself()->_rspOk();
|
||||
return;
|
||||
}
|
||||
$chipDb = SqlHelper::ormSelectOne(
|
||||
myself()->_getMysql($this->accountId),
|
||||
't_chip',
|
||||
array(
|
||||
'token_id' => $tokenId
|
||||
)
|
||||
);
|
||||
if ( !$chipDb ){
|
||||
myself()->_rspErr(1, 'token_id param error');
|
||||
return;
|
||||
}
|
||||
if ($grade > 15){
|
||||
myself()->_rspErr(1, 'Chip Lv upper limit');
|
||||
return;
|
||||
}
|
||||
if ($grade == 3 || $grade == 5){
|
||||
Chip::updateRandAttr($this->accountId,$chipDb);
|
||||
}
|
||||
$lucky = ltrim(\services\FormulaService::getChipLuckyValue($grade),'-') ;
|
||||
if ($grade>=5){
|
||||
$fieldsKv = array(
|
||||
'lucky_temporary'=>$lucky,
|
||||
'chip_grade'=>$grade,
|
||||
'supper_state'=>1,
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
);
|
||||
}else{
|
||||
$fieldsKv = array(
|
||||
'lucky_temporary'=>$lucky,
|
||||
'chip_grade'=>$grade,
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
);
|
||||
}
|
||||
SqlHelper::update
|
||||
(myself()->_getMysql($this->accountId),
|
||||
't_chip',
|
||||
array(
|
||||
'token_id' => $tokenId,
|
||||
),
|
||||
$fieldsKv
|
||||
);
|
||||
NftUpEvent::add($this->accountId,
|
||||
array(
|
||||
'trans_id' => $transId,
|
||||
'token_id' => $tokenId,
|
||||
'value' => 1,
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
)
|
||||
);
|
||||
myself()->_rspOk();
|
||||
}
|
||||
|
||||
|
@ -834,7 +834,7 @@ class ChipController extends BaseAuthedController
|
||||
private function _upgraded($chip){
|
||||
$new_grade = $chip['chip_grade']+1;
|
||||
if ($new_grade == 3 || $new_grade == 5){
|
||||
Chip::updateRandAttr($chip);
|
||||
Chip::updateRandAttr(myself()->_getAccountId(),$chip);
|
||||
}
|
||||
|
||||
$lucky = ltrim(\services\FormulaService::getChipLuckyValue($new_grade),'-') ;
|
||||
|
@ -298,14 +298,21 @@ class Chip extends BaseModel
|
||||
// );
|
||||
// }
|
||||
|
||||
public static function updateRandAttr($chip){
|
||||
public static function updateRandAttr($accountId,$chip){
|
||||
$attr_pool = mt\ChipAttr::generateOneAttr($chip['chip_type']);
|
||||
$rand_attr = emptyReplace(json_decode($chip['rand_attr'], true), array());
|
||||
array_push($rand_attr,$attr_pool);
|
||||
$fieldsKv = [
|
||||
'rand_attr'=>json_encode($rand_attr)
|
||||
];
|
||||
self::update($chip['token_id'],$fieldsKv);
|
||||
SqlHelper::update(
|
||||
myself()->_getMysql($accountId),
|
||||
't_chip',
|
||||
array(
|
||||
'token_id' => $chip['token_id'],
|
||||
),
|
||||
$fieldsKv
|
||||
);
|
||||
}
|
||||
|
||||
public static function getChipAttr($chip_ids){
|
||||
|
@ -7,10 +7,10 @@ use mt;
|
||||
use phpcommon\SqlHelper;
|
||||
class NftUpEvent extends BaseModel
|
||||
{
|
||||
public static function find($transId)
|
||||
public static function find($accountId,$transId)
|
||||
{
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
myself()->_getMysql($accountId),
|
||||
't_nft_up_event',
|
||||
array(
|
||||
'trans_id' => $transId,
|
||||
@ -19,9 +19,9 @@ class NftUpEvent extends BaseModel
|
||||
return $row;
|
||||
}
|
||||
|
||||
public static function add($fieldKv){
|
||||
public static function add($accountId,$fieldKv){
|
||||
return SqlHelper::insert(
|
||||
myself()->_getSelfMysql(),
|
||||
myself()->_getMysql($accountId),
|
||||
't_nft_up_event',
|
||||
$fieldKv
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user