release
parent
8cddb906f5
commit
27940e16d0
|
|
@ -14,6 +14,8 @@ class ProduckSkuResource extends JsonResource
|
|||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
// 商品处于预售状态, 不限制库存
|
||||
$is_pre_sale = $this->spu->is_pre_sale || $this->is_pre_sale;
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
|
|
@ -27,7 +29,7 @@ class ProduckSkuResource extends JsonResource
|
|||
'sales' => $this->sales,
|
||||
'description' => (string) $this->description,
|
||||
'attrs' => $this->attrs,
|
||||
'stock' => $this->saleable_stock,
|
||||
'stock' => $this->when($is_pre_sale, 9999, $this->saleable_stock),
|
||||
'weight' => (int) $this->weight,
|
||||
'is_online' => $this->isOnline(),
|
||||
'buynote' => (string) $this->when($this->relationLoaded('buynote'), function () {
|
||||
|
|
@ -36,7 +38,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,
|
||||
'is_pre_sale' => !!$is_pre_sale,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,11 +160,6 @@ 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'];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue