75 lines
1.7 KiB
PHP
75 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Modules\SystemUser\Models\SysUserModel;
|
|
|
|
/**
|
|
* 结算表模型(对账结算按门店聚合生成,可导出存档)
|
|
*/
|
|
class SettlementModel extends Model
|
|
{
|
|
/** 状态:待结算 */
|
|
public const STATUS_PENDING = 0;
|
|
/** 状态:已结算 */
|
|
public const STATUS_SETTLED = 1;
|
|
|
|
protected $table = 'settlement';
|
|
protected $primaryKey = 'id';
|
|
|
|
protected $fillable = [
|
|
'settlement_no',
|
|
'recon_id',
|
|
'store_id',
|
|
'period_start',
|
|
'period_end',
|
|
'total_amount',
|
|
'actual_amount',
|
|
'diff_amount',
|
|
'status',
|
|
'file_path',
|
|
'operator_id',
|
|
'settled_at',
|
|
'remark',
|
|
];
|
|
|
|
protected $casts = [
|
|
'recon_id' => 'integer',
|
|
'store_id' => 'integer',
|
|
'period_start' => 'date:Y-m-d',
|
|
'period_end' => 'date:Y-m-d',
|
|
'total_amount' => 'decimal:2',
|
|
'actual_amount' => 'decimal:2',
|
|
'diff_amount' => 'decimal:2',
|
|
'status' => 'integer',
|
|
'operator_id' => 'integer',
|
|
'settled_at' => 'datetime',
|
|
];
|
|
|
|
/**
|
|
* 来源对账单
|
|
*/
|
|
public function recon(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ReconciliationModel::class, 'recon_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* 结算门店
|
|
*/
|
|
public function store(): BelongsTo
|
|
{
|
|
return $this->belongsTo(StoreModel::class, 'store_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* 制单人(后台系统用户)
|
|
*/
|
|
public function operator(): BelongsTo
|
|
{
|
|
return $this->belongsTo(SysUserModel::class, 'operator_id', 'id');
|
|
}
|
|
}
|