81 lines
2.3 KiB
PHP
81 lines
2.3 KiB
PHP
<?php
|
|
|
|
|
|
namespace models;
|
|
|
|
use mt;
|
|
use phpcommon;
|
|
use phpcommon\SqlHelper;
|
|
class RankingSetRecord
|
|
{
|
|
public static function find(){
|
|
$row = SqlHelper::ormSelectOne
|
|
(myself()->_getSelfMysql(),
|
|
't_ranking_settlement_record',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
)
|
|
);
|
|
if (!$row){
|
|
$row = array();
|
|
}
|
|
return $row;
|
|
}
|
|
|
|
public static function toDto($row){
|
|
$data = array(
|
|
'state' => $row['state'],
|
|
'last_rank' => $row['last_rank'],
|
|
'current_rank' => $row['current_rank'],
|
|
'last_score' => $row['last_score'],
|
|
'current_score' => $row['current_score'],
|
|
'awards' => json_decode($row['awards']),
|
|
);
|
|
self::updateState();
|
|
return $data;
|
|
}
|
|
|
|
public static function updateState(){
|
|
SqlHelper::update
|
|
(myself()->_getSelfMysql(),
|
|
't_ranking_settlement_record',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
),
|
|
array(
|
|
'state' => 0,
|
|
)
|
|
);
|
|
}
|
|
|
|
public static function upsert($fieldKv){
|
|
SqlHelper::upsert
|
|
(myself()->_getSelfMysql(),
|
|
't_ranking_settlement_record',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
),
|
|
array(
|
|
'state' => $fieldKv['state'],
|
|
'last_rank' => $fieldKv['last_rank'],
|
|
'current_rank' => $fieldKv['current_rank'],
|
|
'last_score' => $fieldKv['last_score'],
|
|
'current_score' => $fieldKv['current_score'],
|
|
'awards' => $fieldKv['awards'],
|
|
'modifytime' => myself()->_getNowTime(),
|
|
),
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'state' => $fieldKv['state'],
|
|
'last_rank' => $fieldKv['last_rank'],
|
|
'current_rank' => $fieldKv['current_rank'],
|
|
'last_score' => $fieldKv['last_score'],
|
|
'current_score' => $fieldKv['current_score'],
|
|
'awards' => $fieldKv['awards'],
|
|
'createtime' => myself()->_getNowTime(),
|
|
'modifytime' => myself()->_getNowTime()
|
|
)
|
|
);
|
|
}
|
|
|
|
} |