game2006api/webapp/models/UserHonor.php
2023-07-10 20:01:15 +08:00

89 lines
2.0 KiB
PHP

<?php
namespace models;
require_once('models/Nft.php');
use mt;
use phpcommon;
use phpcommon\SqlHelper;
class UserHonor
{
public static function find(){
$row = SqlHelper::ormSelectOne
(myself()->_getSelfMysql(),
't_user_honor',
array(
'address' => myself()->_getAddress()
)
);
return $row ? $row : null;
}
public static function info($address){
if (!$address){
return ;
}
$honorDb = self::findByAddress($address);
$data = array();
if ($honorDb){
array_push($data,array(
'token_type' => Nft::HONOR1_TYPE,
'state' => $honorDb['honor1']
));
}
return $data;
}
public static function findByAddress($address){
if (!$address){
return ;
}
$row = SqlHelper::ormSelectOne
(myself()->_getMysql($address),
't_user_honor',
array(
'address' => $address
)
);
return $row ? $row : null;
}
public static function _isValidHonorType($type){
if (!in_array($type,array(
Nft::HONOR1_TYPE,
))){
return false;
}
return true;
}
public static function upsert($tokenType,$state){
$insertKv = array();
$updateKv = array();
switch ($tokenType){
case Nft::HONOR1_TYPE : {
$updateKv = array(
'honor1' => $state,
);
$insertKv = array(
'address' => myself()->_getAddress(),
'honor1' => $state,
);
}
}
SqlHelper::upsert
(myself()->_getSelfMysql(),
't_user_honor',
array(
'address' => myself()->_getAddress()
),
$updateKv,
$insertKv
);
}
}