138 lines
3.9 KiB
PHP
138 lines
3.9 KiB
PHP
<?php
|
|
|
|
|
|
namespace models;
|
|
require_once('services/NumberService.php');
|
|
|
|
use mt;
|
|
use phpcommon\SqlHelper;
|
|
use services\NumberService;
|
|
|
|
class ComputingPower extends BaseModel
|
|
{
|
|
const CRYSTAL1 = 260001;
|
|
const CRYSTAL2 = 260002;
|
|
const CRYSTAL3 = 260003;
|
|
const CRYSTAL4 = 260004;
|
|
const CRYSTAL_NEW = 260010;
|
|
|
|
//获取我的算力
|
|
public static function getOwnedBH($period,$account = null){
|
|
if (!$account){
|
|
$account = myself()->_getAccountId();
|
|
}
|
|
$rows = SqlHelper::ormSelect(
|
|
myself()->_getMysql($account),
|
|
't_power_exchange_record',
|
|
array(
|
|
'account_id'=>$account,
|
|
'period' => $period
|
|
)
|
|
);
|
|
$my_total_num = 0;
|
|
if ($rows){
|
|
foreach ($rows as $row){
|
|
$my_total_num += $row['total_num'];
|
|
}
|
|
}
|
|
|
|
return NumberService::ceilEx($my_total_num,6);
|
|
}
|
|
|
|
//获取全服总算力
|
|
public static function getTotalBH($period){
|
|
$rows = SqlHelper::select(
|
|
myself()->_getMysql(''),
|
|
't_power_exchange_record',
|
|
array(
|
|
"period",
|
|
"total_num"
|
|
),
|
|
array(
|
|
'period' => $period
|
|
)
|
|
);
|
|
$total_num = 0;
|
|
if ($rows){
|
|
foreach ($rows as $row){
|
|
$total_num += $row['total_num'];
|
|
}
|
|
}
|
|
return $total_num;
|
|
}
|
|
|
|
//获取我的总算力
|
|
public static function getMyTotalBH(){
|
|
$rows = SqlHelper::select(
|
|
myself()->_getSelfMysql(),
|
|
't_power_exchange_record',
|
|
array(
|
|
"period",
|
|
"total_num"
|
|
),
|
|
array(
|
|
'account_id'=>myself()->_getAccountId(),
|
|
)
|
|
);
|
|
$total_num = 0;
|
|
if ($rows){
|
|
foreach ($rows as $row){
|
|
$total_num += $row['total_num'];
|
|
}
|
|
}
|
|
return $total_num;
|
|
}
|
|
|
|
public static function findByPeriod($period){
|
|
$rows = SqlHelper::ormSelect(
|
|
myself()->_getSelfMysql(),
|
|
't_power_exchange_record',
|
|
array(
|
|
'account_id'=>myself()->_getAccountId(),
|
|
'period' => $period
|
|
)
|
|
);
|
|
$list = array(
|
|
'num1' => 0,
|
|
'num2' => 0,
|
|
'num3' => 0,
|
|
'num4' => 0,
|
|
);
|
|
if ($rows){
|
|
foreach ($rows as $row){
|
|
$list['num1'] += $row['item_num1'];
|
|
$list['num2'] += $row['item_num2'];
|
|
$list['num3'] += $row['item_num3'];
|
|
$list['num4'] += $row['item_num4'];
|
|
}
|
|
}
|
|
return $list;
|
|
}
|
|
|
|
public static function addPowerRecord($fieldKv){
|
|
SqlHelper::insert(
|
|
myself()->_getSelfMysql(),
|
|
't_power_exchange_record',
|
|
array(
|
|
'account_id'=>myself()->_getAccountId(),
|
|
'address'=>myself()->_getAddress(),
|
|
'period'=>$fieldKv['period'],
|
|
'item_num1'=>$fieldKv['item_num1'],
|
|
'item_num2' => $fieldKv['item_num2'],
|
|
'item_num3' => $fieldKv['item_num3'],
|
|
'item_num4' => $fieldKv['item_num4'],
|
|
'total_num' => $fieldKv['total_num'],
|
|
'createtime'=>myself()->_getNowTime(),
|
|
'modifytime'=>myself()->_getNowTime(),
|
|
)
|
|
);
|
|
}
|
|
|
|
public static function getAccountGroup($period){
|
|
$sql = "select account_id,`period` from t_power_exchange_record where `period` = $period group by account_id";
|
|
$rows = myself()->_getMysql('')->execQuery($sql);
|
|
return $rows;
|
|
}
|
|
|
|
|
|
} |