Files
xin-procurement/app/Models/StatementModel.php
T
2026-07-23 20:41:25 +08:00

66 lines
1.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* 门店对账单模型(门店自助生成,快照回款周期:settlement_date = period_end + payment_cycle_days
*/
class StatementModel extends Model
{
/** 状态:待对账 */
public const STATUS_PENDING = 0;
/** 状态:已对账 */
public const STATUS_RECONCILED = 1;
/** 状态:已结算 */
public const STATUS_SETTLED = 2;
protected $table = 'statement';
protected $primaryKey = 'id';
protected $fillable = [
'statement_no',
'store_id',
'period_start',
'period_end',
'total_amount',
'payment_cycle_days',
'settlement_date',
'status',
'reconciled_at',
'settled_at',
'remark',
];
protected $casts = [
'store_id' => 'integer',
'period_start' => 'date:Y-m-d',
'period_end' => 'date:Y-m-d',
'total_amount' => 'decimal:2',
'payment_cycle_days' => 'integer',
'settlement_date' => 'date:Y-m-d',
'status' => 'integer',
'reconciled_at' => 'datetime',
'settled_at' => 'datetime',
];
/**
* 所属门店
*/
public function store(): BelongsTo
{
return $this->belongsTo(StoreModel::class, 'store_id', 'id');
}
/**
* 对账单明细
*/
public function items(): HasMany
{
return $this->hasMany(StatementItemModel::class, 'statement_id', 'id');
}
}