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

84 lines
2.4 KiB
PHP

<?php
namespace app\common\model;
use support\Model;
use app\common\traits\HasMoneyJournal;
class StockOrderItems extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'stock_order_items';
/**
* 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 $fillable = [
'id', 'order_id', 'product_code', 'sku_id', 'sku_snapshot',
'model_snapshot', 'quantity', 'color_interior_coide', 'color_interior_snapshot',
'color_exterior_coide', 'color_exterior_snapshot', 'remark',
// 'unit_price',
// 'handling_fee',
// 'fob_transport_fee',
// 'port_misc_fee',
// 'retrofit_fee',
// 'total_price',
'created_at', 'updated_at',
// 'unit_price_value_id',
// 'handling_fee_value_id',
// 'fob_transport_fee_value_id',
// 'port_misc_fee_value_id',
// 'retrofit_fee_value_id',
// 'total_price_value_id'
];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
/* ========= 关系 ========= */
use HasMoneyJournal;
// 实现抽象方法
protected static function moneyObjectScene(): string
{
return 'stock_order_items';
}
// 便捷访问器(最新一条的原币金额)
public function getUnitPriceAmountAttribute() { return $this->moneyLatest('unit_price')?->amount; }
public function getHandlingFeeAmountAttribute() { return $this->moneyLatest('handling_fee')?->amount; }
public function getFobTransportFeeAmountAttribute() { return $this->moneyLatest('fob_transport_fee')?->amount; }
public function getPortMiscFeeAmountAttribute() { return $this->moneyLatest('port_misc_fee')?->amount; }
public function getRetrofitFeeAmountAttribute() { return $this->moneyLatest('retrofit_fee')?->amount; }
public function getTotalPriceAmountAttribute() { return $this->moneyLatest('total_price')?->amount; }
}