77 lines
1.9 KiB
PHP
77 lines
1.9 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;
|
|
|
|
/**
|
|
* 门店回筐记录模型(压筐=生成账单时自动写入并累加门店待回;回筐=门店退回手动登记并扣减待回)
|
|
*/
|
|
class ContainerReturnModel extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
/** 类型:压筐(账单生成压出,系统写入只读) */
|
|
public const int TYPE_PRESS = 1;
|
|
/** 类型:回筐(门店退回,后台手动登记) */
|
|
public const int TYPE_RETURN = 2;
|
|
|
|
/** 类型中文名 */
|
|
public const array TYPE_NAMES = [
|
|
self::TYPE_PRESS => '压筐',
|
|
self::TYPE_RETURN => '回筐',
|
|
];
|
|
|
|
protected $table = 'container_return';
|
|
protected $primaryKey = 'id';
|
|
|
|
protected $fillable = [
|
|
'store_id',
|
|
'bill_id',
|
|
'type',
|
|
'box_num',
|
|
'tray_num',
|
|
'return_date',
|
|
'operator_id',
|
|
'remark',
|
|
];
|
|
|
|
protected $casts = [
|
|
'store_id' => 'integer',
|
|
'bill_id' => 'integer',
|
|
'type' => 'integer',
|
|
'box_num' => 'integer',
|
|
'tray_num' => 'integer',
|
|
'return_date' => 'date:Y-m-d',
|
|
'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');
|
|
}
|
|
}
|