更新排序

This commit is contained in:
mkm 2024-01-04 14:29:40 +08:00
parent 6856704551
commit 2f86f37838
2 changed files with 38 additions and 25 deletions

View File

@ -154,6 +154,16 @@ class SpuRepository extends BaseRepository
]); ]);
$productMake = app()->make(ProductRepository::class); $productMake = app()->make(ProductRepository::class);
$count = $query->fetchSql(false)->count(); $count = $query->fetchSql(false)->count();
if ($limit == 0) {
$list = $query->setOption('field', [])->field($this->productFiled)->select()
->each(function ($item) use ($is_sku, $productMake, $userInfo) {
if ($is_sku == true) {
$sku = $productMake->detailAttrValue($item['product']['attrValue'], $userInfo);
$item['sku'] = $sku;
}
});
} else {
$list = $query->page($page, $limit)->setOption('field', [])->field($this->productFiled)->select() $list = $query->page($page, $limit)->setOption('field', [])->field($this->productFiled)->select()
->each(function ($item) use ($is_sku, $productMake, $userInfo) { ->each(function ($item) use ($is_sku, $productMake, $userInfo) {
if ($is_sku == true) { if ($is_sku == true) {
@ -161,6 +171,9 @@ class SpuRepository extends BaseRepository
$item['sku'] = $sku; $item['sku'] = $sku;
} }
}); });
}
$append = ['stop_time', 'svip_price', 'show_svip_info', 'is_svip_price']; $append = ['stop_time', 'svip_price', 'show_svip_info', 'is_svip_price'];
if ($productMake->getUserIsPromoter($userInfo)) if ($productMake->getUserIsPromoter($userInfo))
$append[] = 'max_extension'; $append[] = 'max_extension';

View File

@ -82,7 +82,7 @@ class CloudWarehouse extends BaseController
$query->whereOr('mer_labels', '') $query->whereOr('mer_labels', '')
->whereOr('mer_labels',',5,'); ->whereOr('mer_labels',',5,');
})->count(); })->count();
$products = $this->spuRepository->getApiSearch($where, $page, 10, false, true); $products = $this->spuRepository->getApiSearch($where, $page, 0, false, true);
if ($products['list']) { if ($products['list']) {
$list = $products['list']; $list = $products['list'];
foreach ($cloud_product_arr as $key => $value) { foreach ($cloud_product_arr as $key => $value) {