69 lines
1.7 KiB
PHP
69 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Modules\SystemUser\Models\SysUserModel;
|
|
|
|
/**
|
|
* 门店压回筐记录模型(周转筐/托盘跟账单走,生成账单时写入完整快照)
|
|
*
|
|
* 数量正数=压筐(附加金额),负数=回筐(抵扣金额);数量为 0 不写记录
|
|
*/
|
|
class ContainerReturnModel extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'container_return';
|
|
protected $primaryKey = 'id';
|
|
|
|
protected $fillable = [
|
|
'store_id',
|
|
'bill_id',
|
|
'box_num',
|
|
'tray_num',
|
|
'box_price',
|
|
'tray_price',
|
|
'amount',
|
|
'operator_id',
|
|
];
|
|
|
|
protected $casts = [
|
|
'store_id' => 'integer',
|
|
'bill_id' => 'integer',
|
|
'box_num' => 'integer',
|
|
'tray_num' => 'integer',
|
|
'box_price' => 'decimal:2',
|
|
'tray_price' => 'decimal:2',
|
|
'amount' => 'decimal:2',
|
|
'operator_id' => 'integer',
|
|
'created_at' => 'datetime:Y-m-d H:i:s',
|
|
];
|
|
|
|
/**
|
|
* 所属门店(含软删除门店,保证历史记录可见)
|
|
*/
|
|
public function store(): BelongsTo
|
|
{
|
|
return $this->belongsTo(StoreModel::class, 'store_id', 'id')->withTrashed();
|
|
}
|
|
|
|
/**
|
|
* 关联账单
|
|
*/
|
|
public function bill(): BelongsTo
|
|
{
|
|
return $this->belongsTo(BillModel::class, 'bill_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* 操作人(后台系统用户)
|
|
*/
|
|
public function operator(): BelongsTo
|
|
{
|
|
return $this->belongsTo(SysUserModel::class, 'operator_id', 'id');
|
|
}
|
|
}
|