From 72a2d569d5a18a86a0962e7765dfa20e8bcd3552 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Mon, 11 Sep 2023 17:15:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=91=E5=95=86=E5=93=81sk?= =?UTF-8?q?u=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/product/SpuRepository.php | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/app/common/repositories/store/product/SpuRepository.php b/app/common/repositories/store/product/SpuRepository.php index 163bf456..b03b867f 100644 --- a/app/common/repositories/store/product/SpuRepository.php +++ b/app/common/repositories/store/product/SpuRepository.php @@ -203,16 +203,42 @@ class SpuRepository extends BaseRepository 'merchant' => function ($query) { $query->field($this->merchantFiled)->with(['type_name']); }, - 'issetCoupon', + 'issetCoupon' ]); $list = $query->setOption('field', [])->field($this->productFiled)->page($page)->limit($limit)->select(); $append = ['stop_time','svip_price','show_svip_info','is_svip_price']; - $list->append($append); $list = $this->getBorderList($list); + $productIdArray = $productSkuArray = []; foreach ($list as &$item) { + $productIdArray[] = $item->product_id; $item['referer'] = AesUtils::encrypt($entryMerId . '|' . rand(1, 100), env('app_key')); } + $productAttrList = Db::name('store_product_attr_value')->whereIn('product_id', $productIdArray)->field(['product_id', 'sku', 'price', 'stock', 'image', 'weight', 'volume', 'sales', 'unique', 'bar_code', 'ot_price', 'svip_price'])->select(); + foreach($productAttrList as $prod) { + $productSkuArray[$prod['product_id']][] = [ + $prod['sku'] => [ + "sku" => $prod['sku'], + "price" => $prod['price'], + "stock" => $prod['stock'], + "image" => $prod['image'], + "weight" => $prod['weight'], + "volume" => $prod['volume'], + "sales" => $prod['sales'], + "unique" => $prod['unique'], + "bar_code" => $prod['bar_code'], + "ot_price" => $prod['ot_price'], + "svip_price" => $prod['svip_price'] + ] + ]; + } + foreach ($list as &$item) { + $item['sku'] = (object)[]; + if (!empty($productSkuArray[$item['product_id']])) { + $item['sku'] = $productSkuArray[$item['product_id']]; + } + } + unset($item); return compact('count', 'list'); }