6
0
Fork 0

预售库存状态

release
panliang 2022-06-10 14:43:49 +08:00
parent 1797c09e90
commit 48bbcb73a2
2 changed files with 6 additions and 0 deletions

View File

@ -36,6 +36,7 @@ class ProduckSkuResource extends JsonResource
'growth_value' => (int) $this->growth_value,
'sales_value' => (int) $this->sales_value,
'is_bargaing' => $this->isBargaing() ? true : false,
'is_pre_sale' => !!$this->is_pre_sale,
];
}
}

View File

@ -160,6 +160,11 @@ class ProductSku extends Model
*/
public function getSaleableStockAttribute(): int
{
// 商品处于预售状态, 不限制库存
$is_pre_sale = $this->spu->is_pre_sale || $this->is_pre_sale;
if ($is_pre_sale) {
return 9999;
}
if ($this->isOnline()) {
return $this->attributes['stock'];
}