50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
namespace App\Models\Wallet\Tron;
|
|
|
|
use App\Models\Wallet\Base\WalletBaseModel;
|
|
use App\Tools\Math;
|
|
use App\Tools\Times;
|
|
|
|
class WalletTronBlockModel extends WalletBaseModel
|
|
{
|
|
protected $table = 'wallet_tron_block';
|
|
protected $primaryKey = 'id';
|
|
protected $fillable = [
|
|
'id',
|
|
'status',
|
|
'block_id',
|
|
'block_num',
|
|
'block_timestamp',
|
|
'created_at',
|
|
];
|
|
|
|
const STATUS_WAIT = 1;
|
|
const STATUS_PROCESS = 2;
|
|
const STATUS_FINISH = 3;
|
|
const STATUS_FAIL = 4;
|
|
const STATUS = [
|
|
self::STATUS_WAIT => '等待',
|
|
self::STATUS_PROCESS => '处理中',
|
|
self::STATUS_FINISH => '完成',
|
|
self::STATUS_FAIL => '处理失败',
|
|
];
|
|
|
|
function insertByBlockNum($blockNum): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder|bool
|
|
{
|
|
$data = [
|
|
'block_num' => $blockNum,
|
|
'status' => self::STATUS_WAIT,
|
|
'created_at' => Times::getNowDateTime(),
|
|
|
|
];
|
|
return $this->addItem($data);
|
|
}
|
|
|
|
function getLastBlockNumber()
|
|
{
|
|
return $this->newQuery()->orderBy('block_num', 'desc')->value('block_num');
|
|
}
|
|
|
|
|
|
}
|