game2006api/webapp/controller/OutAppNftController.class.php
hujiabin 0daa3ad939 1
2024-05-09 16:47:55 +08:00

122 lines
4.2 KiB
PHP

<?php
use phpcommon\SqlHelper;
require_once('models/Nft.php');
require_once('models/User.php');
use models\Nft;
use models\User;
class OutAppNftController extends BaseController {
public function getNftList(){
$address = getReqVal('address', '');
$type = getReqVal('type', '');
if ($type){
$nftList = Nft::getNftListByType($address,$type);
}else{
$nftList = Nft::getNftList($address);
}
$listInfo = array();
if ($nftList){
foreach ($nftList as $nft) {
$image = 'https://www.cebg.games/res/avatars/' . $nft['item_id'] . '.png';
$full_image = 'https://www.cebg.games/res/avatars/full_' . $nft['item_id'] . '.png';
$info = array(
"idx" => $nft['idx'],
"owner_address" => $nft['owner_address'],
"item_id" => $nft['item_id'],
"token_id" => $nft['token_id'],
"token_type" => $nft['token_type'],
"contract_address" => $nft['contract_address'],
'image' => $image,
'full_image' => $full_image,
"details" => array(),
);
array_push($listInfo,$info);
}
}
$this->_rspData(array(
'nfts' => $listInfo,
));
}
public function getWebInfo(){
$channel = getReqVal('channel', '');
$openId = getReqVal('openId', '');
$accountId = BC_POLY_CHANNEL.'_'.$this->_getGameId().'_'.$channel.'_'.$openId;
$userDb = User::find($accountId);
if (!$userDb){
$this->_rspErr(1, 'user not found');
return;
}
$info = array(
'loginVal' => 0,
'battleTimes' => 0,
'winTimes' => 0,
'kills' => 0,
'getGoldVal' => 0,
);
$accountBindDb = SqlHelper::ormSelectOne(
myself()->_getMysql($openId),
't_sub_user_bind',
array(
'org_account_id' => $accountId,
)
);
$accountId = $accountBindDb ? $accountBindDb['cur_account_id'] : $accountId ;
$loginDyn = SqlHelper::ormSelectOne(
myself()->_getMysql($openId),
't_dyndata',
array(
'account_id' => $accountId,
'x' => TN_DAILY_LOGINS,
'y' => 0,
)
);
if ($loginDyn){
$info['loginVal'] = $loginDyn['val'];
if (myself()->_getDaySeconds($loginDyn['modifytime']) < myself()->_getNowDaySeconds()) {
$info['loginVal'] = 0;
}
}
$battleDb = SqlHelper::ormSelectOne(
myself()->_getMysql($openId),
't_battle',
array(
'account_id' => $accountId,
)
);
if ($battleDb){
$hisBattleData = json_decode($battleDb['battle_data'], true);
$todayBattleData = getXVal($hisBattleData, 'today_data', array());
if (myself()->_getDaySeconds(getXVal($todayBattleData, 'modifytime', 0)) == myself()->_getNowDaySeconds()) {
$info['battleTimes'] = getXVal($todayBattleData, "total_battle_times", 0);
$info['winTimes'] = getXVal($todayBattleData, "total_win_times", 0);
$info['kills'] = getXVal($todayBattleData, "total_kills_times", 0);
}
}
$getGoldDyn = SqlHelper::ormSelectOne(
myself()->_getMysql($openId),
't_dyndata',
array(
'account_id' => $accountId,
'x' => TN_DAILY_GATHER_GOLD,
'y' => 0,
)
);
if ($getGoldDyn){
$info['getGoldVal'] = $getGoldDyn['val'];
if (myself()->_getDaySeconds($getGoldDyn['modifytime']) < myself()->_getNowDaySeconds()) {
$info['getGoldVal'] = 0;
}
}
$this->_rspData(array(
'info' => $info,
));
}
}