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