2025-09-02 09:36:37 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace app\common\model;
|
|
|
|
|
|
|
|
|
|
use support\Model;
|
2025-09-04 18:22:24 +08:00
|
|
|
use app\common\traits\HasMoneyJournal;
|
2025-09-02 09:36:37 +08:00
|
|
|
|
|
|
|
|
class StockOrders 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_orders';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 允许自动填充模型字段
|
|
|
|
|
*/
|
2025-09-04 10:26:28 +08:00
|
|
|
protected $fillable = [
|
|
|
|
|
'id', 'order_no', 'pi_no', 'biz_date', 'salesperson_id', 'salesperson_snapshot',
|
|
|
|
|
'clearance_country_id', 'clearance_country_snapshot', 'ali_order_no',
|
|
|
|
|
'customer_source_id', 'customer_source_snapshot', 'customer_id', 'customer_snapshot',
|
|
|
|
|
'customer_country_id', 'customer_country_snapshot', 'declarant_name', 'eta_ship_date',
|
|
|
|
|
'shipping_method_id', 'shipping_method_snapshot', 'cif_total_amount', 'domestic_port_id', 'domestic_port_snapshot',
|
|
|
|
|
'trade_term_id', 'trade_term_snapshot', 'clearance_port_id', 'clearance_port_snapshot',
|
|
|
|
|
'latest_arrival_date', 'contract_exchange_rate', 'settlement_currency', 'status',
|
|
|
|
|
'remark', 'created_at', 'updated_at', 'deleted_at',
|
2025-09-09 16:15:48 +08:00
|
|
|
'object_id', 'contract', 'is_use', 'is_final', 'approval_status', 'file_url'
|
2025-09-04 10:26:28 +08:00
|
|
|
];
|
2025-09-02 09:36:37 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 不允许自动填充模型字段
|
|
|
|
|
*/
|
|
|
|
|
protected $guarded = [];
|
2025-09-04 11:52:40 +08:00
|
|
|
|
|
|
|
|
|
2025-09-04 18:22:24 +08:00
|
|
|
use HasMoneyJournal;
|
|
|
|
|
// 实现抽象方法
|
|
|
|
|
protected static function moneyObjectScene(): string
|
|
|
|
|
{
|
|
|
|
|
return 'stock_orders';
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-04 11:52:40 +08:00
|
|
|
/**
|
|
|
|
|
* 关联订单项
|
|
|
|
|
*/
|
|
|
|
|
public function items()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(StockOrderItems::class, 'order_id', 'id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 关联订单账户信息
|
|
|
|
|
*/
|
|
|
|
|
public function accounts()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(StockOrderAccounts::class, 'order_id', 'id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 关联货币价值信息(一个订单可以有多个货币价值记录)
|
|
|
|
|
*/
|
|
|
|
|
public function moneyValues()
|
|
|
|
|
{
|
2025-09-08 20:00:12 +08:00
|
|
|
return $this->hasOne(VehMoneyValue::class, 'object_id', 'id')->where('object_scene', 'stock_orders');
|
2025-09-04 11:52:40 +08:00
|
|
|
}
|
2025-09-09 13:42:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
public function salesperson()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasOne(User::class, 'id', 'salesperson_id');
|
|
|
|
|
}
|
2025-09-02 09:36:37 +08:00
|
|
|
}
|