57 lines
1.4 KiB
PHP
57 lines
1.4 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()
|
|
),
|
|
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(),
|
|
)
|
|
);
|
|
}
|
|
|
|
} |