82 lines
2.2 KiB
PHP
82 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace app\common\model;
|
|
|
|
use support\Model;
|
|
|
|
/**
|
|
* 物品库存变化记录模型
|
|
*/
|
|
class InvStockLog extends Model
|
|
{
|
|
protected $table = 'inv_stock_log';
|
|
|
|
protected $fillable = [
|
|
'company_id',
|
|
'item_id',
|
|
'item_name_snap',
|
|
'change_type',
|
|
'change_qty',
|
|
'before_qty',
|
|
'after_qty',
|
|
'biz_type',
|
|
'biz_no',
|
|
'operator_id',
|
|
'operator_name',
|
|
'remark',
|
|
'created_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'created_at' => 'timestamp',
|
|
];
|
|
|
|
public const CHANGE_TYPE_IN = 1; // 入库
|
|
public const CHANGE_TYPE_OUT_CLAIM = 2; // 出库(领用)
|
|
public const CHANGE_TYPE_OUT_LOSS = 3; // 出库(损耗)
|
|
public const CHANGE_TYPE_IN_RETURN = 4; // 入库(归还)
|
|
|
|
public const BIZ_TYPE_PURCHASE = 1; // 采购入库
|
|
public const BIZ_TYPE_QR_CLAIM = 2; // 扫码领取
|
|
public const BIZ_TYPE_PROXY_CLAIM = 3; // 管理员代领
|
|
public const BIZ_TYPE_NORMAL_CLAIM = 4; // 正常领用(审批后)
|
|
public const BIZ_TYPE_RETURN = 5; // 归还入库
|
|
public const BIZ_TYPE_LOSS = 6; // 损耗出库
|
|
|
|
/**
|
|
* 变动类型文本
|
|
*/
|
|
public static function getChangeTypeText($type)
|
|
{
|
|
return [
|
|
self::CHANGE_TYPE_IN => '入库',
|
|
self::CHANGE_TYPE_OUT_CLAIM => '出库(领用)',
|
|
self::CHANGE_TYPE_OUT_LOSS => '出库(损耗)',
|
|
self::CHANGE_TYPE_IN_RETURN => '入库(归还)',
|
|
][$type] ?? '未知';
|
|
}
|
|
|
|
/**
|
|
* 业务类型文本
|
|
*/
|
|
public static function getBizTypeText($type)
|
|
{
|
|
return [
|
|
self::BIZ_TYPE_PURCHASE => '采购入库',
|
|
self::BIZ_TYPE_QR_CLAIM => '扫码领取',
|
|
self::BIZ_TYPE_PROXY_CLAIM => '管理员代领',
|
|
self::BIZ_TYPE_NORMAL_CLAIM => '正常领用',
|
|
self::BIZ_TYPE_RETURN => '归还入库',
|
|
self::BIZ_TYPE_LOSS => '损耗出库',
|
|
][$type] ?? '未知';
|
|
}
|
|
|
|
/**
|
|
* 关联物品
|
|
*/
|
|
public function item()
|
|
{
|
|
return $this->belongsTo(InvItem::class, 'item_id', 'id');
|
|
}
|
|
}
|