67 lines
2.0 KiB
PHP
67 lines
2.0 KiB
PHP
<?php
|
|
|
|
|
|
namespace models;
|
|
|
|
use mt;
|
|
use phpcommon\SqlHelper;
|
|
class CrystalRecord extends BaseModel
|
|
{
|
|
public static function getCrystalRecordList($cb){
|
|
SqlHelper::ormSelect(
|
|
myself()->_getSelfMysql(),
|
|
't_crystal_exchange_record',
|
|
array(
|
|
'account_id'=>myself()->_getAccountId(),
|
|
'item_id'=>ComputingPower::CRYSTAL_NEW,
|
|
),
|
|
function ($row) use($cb) {
|
|
$cb($row);
|
|
}
|
|
);
|
|
}
|
|
|
|
public static function getCrystalNum($item_id){
|
|
$rows = SqlHelper::ormSelect(
|
|
myself()->_getSelfMysql(),
|
|
't_crystal_exchange_record',
|
|
array(
|
|
'account_id'=>myself()->_getAccountId(),
|
|
'item_id' => $item_id
|
|
)
|
|
);
|
|
|
|
$crystalNum = 0;
|
|
if ($rows){
|
|
foreach ($rows as $row){
|
|
$crystalNum += $row['item_num'];
|
|
}
|
|
}
|
|
return $crystalNum;
|
|
}
|
|
|
|
public static function addCrystalRecord($itemId,$itemNum){
|
|
SqlHelper::insert(
|
|
myself()->_getSelfMysql(),
|
|
't_crystal_exchange_record',
|
|
array(
|
|
'account_id'=>myself()->_getAccountId(),
|
|
'address'=>myself()->_getAddress(),
|
|
'item_id'=>$itemId,
|
|
'item_num' => $itemNum,
|
|
'createtime'=>myself()->_getNowTime(),
|
|
'modifytime'=>myself()->_getNowTime(),
|
|
)
|
|
);
|
|
}
|
|
|
|
public static function getNewestRecordOne($itemId){
|
|
$sql = "select * from t_crystal_exchange_record where `account_id` = :account_id and item_id = :item_id order by idx desc limit 1";
|
|
$rows = myself()->_getMysql('')->execQuery($sql,array(
|
|
'account_id' =>myself()->_getAccountId(),
|
|
'item_id' =>$itemId,
|
|
));
|
|
return count($rows) > 0 ? $rows[0] : array();
|
|
}
|
|
|
|
} |