6
0
Fork 0

product sku

base
panliang 2023-03-18 18:03:19 +08:00
parent 44dcde1906
commit eb454325de
2 changed files with 4 additions and 5 deletions

View File

@ -96,13 +96,12 @@ class ProductSkuController extends Controller
$key = implode('_', $jSpecs);
$mapSku = $mapSkus->get($key);
$stock = (int) $mapSku?->saleable_stock;
if ($mapSku && $stock > 0) {
if ($mapSku) {
$spuSpecItems[] = [
'name' => $value['name'],
'selected' => $sku->is($mapSku),
'sku_id' => (int) $mapSku->id,
'sku_stock' => $stock,
'sku_stock' => (int) $mapSku?->saleable_stock,
];
}

View File

@ -45,7 +45,7 @@ class StoreController extends Controller
$input['sort'] = '-id';
}
$spuIds = StoreProductSku::where('store_id', $store->id)->where('status', 1)->pluck('product_spu_id')->toArray();
$spuIds = StoreProductSku::where('store_id', $store->id)->where('amount', '>', 0)->where('status', 1)->pluck('product_spu_id')->toArray();
$spuIds = array_unique($spuIds);
$spuIds = array_values($spuIds);
$list = ProductSpu::with(['specs'])->whereIn('id', $spuIds)->filter($input)->simplePaginate(Paginator::resolvePerPage('per_page', 20, 50));
@ -79,7 +79,7 @@ class StoreController extends Controller
$spuSpecs = [];
if (count($original = (array) $sku->specs) > 0) {
$skus = $store->productSkus()->where('product_spu_id', $spu->id)->get();
$skus = $store->productSkus()->where('product_spu_id', $spu->id)->where('status', 1)->get();
$mapSkus = $skus->mapWithKeys(function ($item) {
$key = implode('_', $item->specs) ?: $item->id;