79 lines
1.7 KiB
PHP
79 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* 门店对账单明细模型(快照商品名/单价/数量/金额)
|
|
*/
|
|
class StatementItemModel extends Model
|
|
{
|
|
/** 未对账 */
|
|
public const NOT_RECONCILED = 0;
|
|
/** 已对账 */
|
|
public const RECONCILED = 1;
|
|
|
|
protected $table = 'statement_item';
|
|
protected $primaryKey = 'id';
|
|
|
|
protected $fillable = [
|
|
'statement_id',
|
|
'order_id',
|
|
'order_item_id',
|
|
'product_id',
|
|
'product_name',
|
|
'price',
|
|
'quantity',
|
|
'weight',
|
|
'amount',
|
|
'is_reconciled',
|
|
'store_remark',
|
|
];
|
|
|
|
protected $casts = [
|
|
'statement_id' => 'integer',
|
|
'order_id' => 'integer',
|
|
'order_item_id' => 'integer',
|
|
'product_id' => 'integer',
|
|
'price' => 'decimal:2',
|
|
'quantity' => 'decimal:2',
|
|
'weight' => 'decimal:3',
|
|
'amount' => 'decimal:2',
|
|
'is_reconciled' => 'integer',
|
|
];
|
|
|
|
/**
|
|
* 所属对账单
|
|
*/
|
|
public function statement(): BelongsTo
|
|
{
|
|
return $this->belongsTo(StatementModel::class, 'statement_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* 来源订单
|
|
*/
|
|
public function order(): BelongsTo
|
|
{
|
|
return $this->belongsTo(StoreOrderModel::class, 'order_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* 来源订单明细
|
|
*/
|
|
public function orderItem(): BelongsTo
|
|
{
|
|
return $this->belongsTo(StoreOrderItemModel::class, 'order_item_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* 对账商品
|
|
*/
|
|
public function product(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ProductModel::class, 'product_id', 'id');
|
|
}
|
|
}
|