first version
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Modules\SystemUser\Models\SysUserModel;
|
||||
|
||||
/**
|
||||
* 采购单模型(按门店订单汇总生成,按商品+供应商聚合)
|
||||
*/
|
||||
class PurchaseOrderModel extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/** 状态:待发送 */
|
||||
public const STATUS_PENDING = 0;
|
||||
/** 状态:部分发送 */
|
||||
public const STATUS_PART_SENT = 1;
|
||||
/** 状态:全部发送 */
|
||||
public const STATUS_ALL_SENT = 2;
|
||||
/** 状态:已完成 */
|
||||
public const STATUS_COMPLETED = 3;
|
||||
|
||||
protected $table = 'purchase_order';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
protected $fillable = [
|
||||
'purchase_no',
|
||||
'purchase_date',
|
||||
'status',
|
||||
'total_quantity',
|
||||
'total_weight',
|
||||
'estimate_amount',
|
||||
'actual_amount',
|
||||
'operator_id',
|
||||
'remark',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'purchase_date' => 'date:Y-m-d',
|
||||
'status' => 'integer',
|
||||
'total_quantity' => 'decimal:2',
|
||||
'total_weight' => 'decimal:3',
|
||||
'estimate_amount' => 'decimal:2',
|
||||
'actual_amount' => 'decimal:2',
|
||||
'operator_id' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* 制单人(后台系统用户)
|
||||
*/
|
||||
public function operator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SysUserModel::class, 'operator_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 采购明细
|
||||
*/
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(PurchaseOrderItemModel::class, 'purchase_id', 'id')->orderBy('sort');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user