'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); } /** * 关联订单 */ public function order() { return $this->belongsTo(StockOrders::class, 'object_id', 'id'); } /** * 关联订单项(一个货币价值记录可能关联到订单项) */ public function orderItem() { return $this->belongsTo(StockOrderItems::class, 'object_id', 'id'); } /** * 限定查询特定对象类型的货币价值记录 */ public function scopeOfScene($query, $scene) { return $query->where('object_scene', $scene); } }