66 lines
1.6 KiB
PHP
66 lines
1.6 KiB
PHP
<?php
|
|
|
|
|
|
namespace models;
|
|
|
|
use phpcommon\SqlHelper;
|
|
class HashRate extends BaseModel
|
|
{
|
|
|
|
public static function find($taskId,$period){
|
|
return SqlHelper::ormSelectOne(
|
|
myself()->_getSelfMysql(),
|
|
't_hash_rate',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'task_id' => $taskId,
|
|
'period' => $period,
|
|
)
|
|
);
|
|
}
|
|
|
|
public static function add($fieldKv){
|
|
SqlHelper::insert(
|
|
myself()->_getSelfMysql(),
|
|
't_hash_rate',
|
|
$fieldKv
|
|
);
|
|
}
|
|
|
|
public static function getMyHashRate($period){
|
|
$rows = SqlHelper::ormSelect(
|
|
myself()->_getSelfMysql(),
|
|
't_hash_rate',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'period' => $period,
|
|
)
|
|
);
|
|
$myHashRate = 0;
|
|
if ($rows){
|
|
foreach ($rows as $row){
|
|
$myHashRate += $row['reward'];
|
|
}
|
|
}
|
|
return $myHashRate;
|
|
}
|
|
|
|
public static function getTotalByAccount($accountId,$period){
|
|
$rows = SqlHelper::ormSelect(
|
|
myself()->_getSelfMysql(),
|
|
't_hash_rate',
|
|
array(
|
|
'account_id' => $accountId,
|
|
'period' => $period,
|
|
)
|
|
);
|
|
$totalHashRate = 0;
|
|
if ($rows){
|
|
foreach ($rows as $row){
|
|
$totalHashRate += $row['reward'];
|
|
}
|
|
}
|
|
return $totalHashRate;
|
|
}
|
|
|
|
} |