'integer', 'currency_type' => FUND_CURRENCY_TYPE::class, 'trade_date' => 'date', 'open_price' => 'decimal:5', 'close_price' => 'decimal:5', 'high_price' => 'decimal:5', 'low_price' => 'decimal:5', 'avg_price' => 'decimal:5', 'buy_open_price' => 'decimal:5', 'buy_close_price' => 'decimal:5', 'buy_high_price' => 'decimal:5', 'buy_low_price' => 'decimal:5', 'buy_avg_price' => 'decimal:5', 'sell_open_price' => 'decimal:5', 'sell_close_price' => 'decimal:5', 'sell_high_price' => 'decimal:5', 'sell_low_price' => 'decimal:5', 'sell_avg_price' => 'decimal:5', 'total_volume' => 'integer', 'total_amount' => 'decimal:5', 'transaction_count' => 'integer', 'buy_volume' => 'integer', 'sell_volume' => 'integer', 'buy_amount' => 'decimal:5', 'sell_amount' => 'decimal:5', 'admin_inject_volume' => 'integer', 'admin_recycle_volume' => 'integer', 'admin_inject_amount' => 'decimal:5', 'admin_recycle_amount' => 'decimal:5', 'price_change' => 'decimal:5', 'price_change_percent' => 'decimal:4', 'volatility' => 'decimal:4', ]; /** * 获取关联的商品信息 */ public function item(): BelongsTo { return $this->belongsTo(Item::class, 'item_id'); } /** * 获取价格变化趋势描述 */ public function getPriceTrendDescriptionAttribute(): string { if ($this->price_change_percent === null) { return '无变化'; } $percent = abs($this->price_change_percent); $direction = $this->price_change_percent > 0 ? '上涨' : '下跌'; return "{$direction} {$percent}%"; } /** * 获取波动率等级 */ public function getVolatilityLevelAttribute(): string { if ($this->volatility === null) { return '无数据'; } if ($this->volatility < 5) { return '低波动'; } elseif ($this->volatility < 15) { return '中等波动'; } elseif ($this->volatility < 30) { return '高波动'; } else { return '极高波动'; } } }