Files
fdesk/app/common/model/VehMoneyValue.php
T
2025-09-04 10:26:28 +08:00

62 lines
1.3 KiB
PHP

<?php
namespace app\common\model;
use support\Model;
class VehMoneyValue extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'veh_money_value';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
protected $dateFormat = 'U';
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
protected $fillable = [
'object_scene','object_id','field','currency','amount','exchange_rate',
'remark','created_at','updated_at'
];
protected $casts = [
'amount' => 'string',
'exchange_rate' => 'string',
];
/** 按本行汇率换到结算币;无汇率返回 null */
public function amountInSettlement(int $scale = 2): ?string
{
if ($this->exchange_rate === null) return null;
return (string) bcmul((string)$this->amount, (string)$this->exchange_rate, $scale);
}
}