1
This commit is contained in:
parent
75207e2b32
commit
62312e60f1
@ -33,15 +33,7 @@ use models\NftUpReceive;
|
||||
use models\Transaction;
|
||||
|
||||
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;
|
||||
@ -160,18 +152,17 @@ class CallbackController extends BaseController {
|
||||
myself()->_rspErr(1, 'param error');
|
||||
return;
|
||||
}
|
||||
error_log('Transaction:'.$transId);
|
||||
$tranDb= Transaction::findByAccountId($this->accountId,$transId);
|
||||
$tranDb= Transaction::findEx($transId);
|
||||
if (!$tranDb){
|
||||
myself()->_rspErr(1, 'param error');
|
||||
return;
|
||||
}
|
||||
if (NftUpEvent::find($this->accountId,$transId)){
|
||||
if (NftUpEvent::find($transId)){
|
||||
myself()->_rspOk();
|
||||
return;
|
||||
}
|
||||
if (! $tranDb['result']){
|
||||
NftUpEvent::add($this->accountId,
|
||||
NftUpEvent::add(
|
||||
array(
|
||||
'trans_id' => $transId,
|
||||
'token_id' => $tokenId1,
|
||||
@ -184,7 +175,7 @@ class CallbackController extends BaseController {
|
||||
return;
|
||||
}
|
||||
$heroDb = SqlHelper::ormSelectOne(
|
||||
myself()->_getMysql($this->accountId),
|
||||
myself()->_getMysql(''),
|
||||
't_hero',
|
||||
array(
|
||||
'token_id' => $tokenId1,
|
||||
@ -205,7 +196,7 @@ class CallbackController extends BaseController {
|
||||
$heroTili = \services\FormulaService::Hero_NFT_Maximum_Physical_Strength($heroDb['quality'],$heroLucky);
|
||||
$nextHeroTili = \services\FormulaService::Hero_NFT_Maximum_Physical_Strength($heroDb['quality']+1,$nextHeroLucky);
|
||||
SqlHelper::update
|
||||
( myself()->_getMysql($this->accountId),
|
||||
( myself()->_getMysql(''),
|
||||
't_hero',
|
||||
array(
|
||||
'token_id' => $tokenId1,
|
||||
@ -220,7 +211,7 @@ class CallbackController extends BaseController {
|
||||
'labour' => 0,
|
||||
)
|
||||
);
|
||||
NftUpEvent::add($this->accountId,
|
||||
NftUpEvent::add(
|
||||
array(
|
||||
'trans_id' => $transId,
|
||||
'token_id' => $tokenId1,
|
||||
@ -235,10 +226,10 @@ class CallbackController extends BaseController {
|
||||
'token_id2'=>$tokenId2,
|
||||
'token_type'=>1,
|
||||
);
|
||||
NftUpReceive::upsert($this->accountId,$param);
|
||||
NftUpReceive::upsert($tranDb['account_id'],$param);
|
||||
|
||||
if ($heroDb['quality'] + 1 > $this->_getDynDataV(TN_HERO_MAX_QUALITY, 0)) {
|
||||
$this->_setDynDataV(TN_HERO_MAX_QUALITY, 0, $heroDb['quality'] + 1);
|
||||
if ($heroDb['quality'] + 1 > $this->_getDynDataV($tranDb['account_id'],TN_HERO_MAX_QUALITY, 0)) {
|
||||
$this->_setDynDataV($tranDb['account_id'],TN_HERO_MAX_QUALITY, 0, $heroDb['quality'] + 1);
|
||||
}
|
||||
myself()->_rspOk();
|
||||
}
|
||||
@ -251,17 +242,17 @@ class CallbackController extends BaseController {
|
||||
myself()->_rspErr(1, 'param error');
|
||||
return;
|
||||
}
|
||||
$tranDb= Transaction::findByAccountId($this->accountId,$transId);
|
||||
$tranDb= Transaction::findEx($transId);
|
||||
if (!$tranDb){
|
||||
myself()->_rspErr(1, 'param error');
|
||||
return;
|
||||
}
|
||||
if (NftUpEvent::find($this->accountId,$transId)){
|
||||
if (NftUpEvent::find($transId)){
|
||||
myself()->_rspOk();
|
||||
return;
|
||||
}
|
||||
if (! $tranDb['result']){
|
||||
NftUpEvent::add($this->accountId,
|
||||
NftUpEvent::add(
|
||||
array(
|
||||
'trans_id' => $transId,
|
||||
'token_id' => $tokenId1,
|
||||
@ -274,7 +265,7 @@ class CallbackController extends BaseController {
|
||||
return;
|
||||
}
|
||||
$gunDb =SqlHelper::ormSelectOne(
|
||||
myself()->_getMysql($this->accountId),
|
||||
myself()->_getMysql($tranDb['account_id']),
|
||||
't_gun',
|
||||
array(
|
||||
'token_id' => $tokenId1,
|
||||
@ -295,7 +286,7 @@ class CallbackController extends BaseController {
|
||||
$nextDurability = \services\FormulaService::Weapon_NFT_Maximum_Durability($gunDb['quality']+1,$nextGunLucky);
|
||||
|
||||
SqlHelper::update
|
||||
(myself()->_getMysql($this->accountId),
|
||||
(myself()->_getMysql($tranDb['account_id']),
|
||||
't_gun',
|
||||
array(
|
||||
'token_id' => $tokenId1,
|
||||
@ -308,7 +299,7 @@ class CallbackController extends BaseController {
|
||||
'labour' => 0,
|
||||
)
|
||||
);
|
||||
NftUpEvent::add($this->accountId,
|
||||
NftUpEvent::add(
|
||||
array(
|
||||
'trans_id' => $transId,
|
||||
'token_id' => $tokenId1,
|
||||
@ -323,9 +314,9 @@ class CallbackController extends BaseController {
|
||||
'token_id2'=>$tokenId2,
|
||||
'token_type'=>2,
|
||||
);
|
||||
NftUpReceive::upsert($this->accountId,$param);
|
||||
if ($gunDb['quality'] + 1 > $this->_getDynDataV(TN_GUN_MAX_QUALITY, 0)) {
|
||||
$this->_setDynDataV(TN_GUN_MAX_QUALITY, 0, $gunDb['quality'] + 1);
|
||||
NftUpReceive::upsert($tranDb['account_id'],$param);
|
||||
if ($gunDb['quality'] + 1 > $this->_getDynDataV($tranDb['account_id'],TN_GUN_MAX_QUALITY, 0)) {
|
||||
$this->_setDynDataV($tranDb['account_id'],TN_GUN_MAX_QUALITY, 0, $gunDb['quality'] + 1);
|
||||
}
|
||||
myself()->_rspOk();
|
||||
}
|
||||
@ -338,17 +329,17 @@ class CallbackController extends BaseController {
|
||||
return;
|
||||
}
|
||||
|
||||
$tranDb= Transaction::findByAccountId($this->accountId,$transId);
|
||||
$tranDb= Transaction::findEx($transId);
|
||||
if (!$tranDb){
|
||||
myself()->_rspErr(1, 'param error');
|
||||
return;
|
||||
}
|
||||
if (NftUpEvent::find($this->accountId,$transId)){
|
||||
if (NftUpEvent::find($transId)){
|
||||
myself()->_rspOk();
|
||||
return;
|
||||
}
|
||||
if (! $tranDb['result']){
|
||||
NftUpEvent::add($this->accountId,
|
||||
NftUpEvent::add(
|
||||
array(
|
||||
'trans_id' => $transId,
|
||||
'token_id' => $tokenId,
|
||||
@ -362,7 +353,7 @@ class CallbackController extends BaseController {
|
||||
}
|
||||
|
||||
$chipDb = SqlHelper::ormSelectOne(
|
||||
myself()->_getMysql($this->accountId),
|
||||
myself()->_getMysql($tranDb['account_id']),
|
||||
't_chip',
|
||||
array(
|
||||
'token_id' => $tokenId
|
||||
@ -378,7 +369,7 @@ class CallbackController extends BaseController {
|
||||
return;
|
||||
}
|
||||
if ($nextGrade == 3 || $nextGrade == 5){
|
||||
Chip::updateRandAttr($this->accountId,$chipDb);
|
||||
Chip::updateRandAttr($tranDb['account_id'],$chipDb);
|
||||
}
|
||||
$lucky = ltrim(\services\FormulaService::getChipLuckyValue($nextGrade),'-') ;
|
||||
if ($nextGrade>=5){
|
||||
@ -396,14 +387,14 @@ class CallbackController extends BaseController {
|
||||
);
|
||||
}
|
||||
SqlHelper::update
|
||||
(myself()->_getMysql($this->accountId),
|
||||
(myself()->_getMysql($tranDb['account_id']),
|
||||
't_chip',
|
||||
array(
|
||||
'token_id' => $tokenId,
|
||||
),
|
||||
$fieldsKv
|
||||
);
|
||||
NftUpEvent::add($this->accountId,
|
||||
NftUpEvent::add(
|
||||
array(
|
||||
'trans_id' => $transId,
|
||||
'token_id' => $tokenId,
|
||||
@ -415,23 +406,23 @@ class CallbackController extends BaseController {
|
||||
myself()->_rspOk();
|
||||
}
|
||||
|
||||
private function _getDynDataV($x, $y, $val = 0){
|
||||
private function _getDynDataV($accountId,$x, $y, $val = 0){
|
||||
SqlHelper::ormSelectOne(
|
||||
myself()->_getMysql($this->accountId),
|
||||
myself()->_getMysql($accountId),
|
||||
't_dyndata',
|
||||
array(
|
||||
'account_id' => $this->accountId,
|
||||
'account_id' => $accountId,
|
||||
'x' => $x,
|
||||
'y' => $y,
|
||||
)
|
||||
);
|
||||
}
|
||||
private function _setDynDataV($x, $y, $val = 0){
|
||||
private function _setDynDataV($accountId,$x, $y, $val = 0){
|
||||
SqlHelper::upsert
|
||||
(myself()->_getMysql($this->accountId),
|
||||
(myself()->_getMysql($accountId),
|
||||
't_dyndata',
|
||||
array(
|
||||
'account_id' => $this->accountId,
|
||||
'account_id' => $accountId,
|
||||
'x' => $x,
|
||||
'y' => $y
|
||||
),
|
||||
@ -440,7 +431,7 @@ class CallbackController extends BaseController {
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
),
|
||||
array(
|
||||
'account_id' => $this->accountId,
|
||||
'account_id' => $accountId,
|
||||
'x' => $x,
|
||||
'y' => $y,
|
||||
'val' => $val,
|
||||
|
@ -7,10 +7,10 @@ use mt;
|
||||
use phpcommon\SqlHelper;
|
||||
class NftUpEvent extends BaseModel
|
||||
{
|
||||
public static function find($accountId,$transId)
|
||||
public static function find($transId)
|
||||
{
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getMysql($accountId),
|
||||
myself()->_getMysql($transId),
|
||||
't_nft_up_event',
|
||||
array(
|
||||
'trans_id' => $transId,
|
||||
@ -19,9 +19,9 @@ class NftUpEvent extends BaseModel
|
||||
return $row;
|
||||
}
|
||||
|
||||
public static function add($accountId,$fieldKv){
|
||||
public static function add($fieldKv){
|
||||
return SqlHelper::insert(
|
||||
myself()->_getMysql($accountId),
|
||||
myself()->_getMysql(''),
|
||||
't_nft_up_event',
|
||||
$fieldKv
|
||||
);
|
||||
|
@ -46,13 +46,12 @@ class Transaction extends BaseModel {
|
||||
return $row;
|
||||
}
|
||||
|
||||
public static function findByAccountId($accountId,$transId)
|
||||
public static function findEx($transId)
|
||||
{
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getMysql($accountId),
|
||||
myself()->_getMysql($transId),
|
||||
't_transaction',
|
||||
array(
|
||||
'account_id' => $accountId,
|
||||
'trans_id' => $transId,
|
||||
)
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user