From 372fe79cfdb91b07ecdcfd694714699db3c01888 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 19 Mar 2024 13:35:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=BB=E8=A1=A8=E6=89=B9?= =?UTF-8?q?=E5=8F=91=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/product/ProductRepository.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index 414db3e1..c6382276 100644 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -324,6 +324,15 @@ class ProductRepository extends BaseRepository unset($data['admin_info']); } + if(!empty($settleParams['attrValue'])){ + $wholesalePrices = array_column($settleParams['attrValue'], 'wholesale_price'); + $minWholesalePrice = min($wholesalePrices); + + if($product['wholesale_price'] > $minWholesalePrice){ + $product['wholesale_price'] =$minWholesalePrice; + } + + } return Db::transaction(function () use ($id, $data, $productType, $settleParams, $content, $product, $spuData, $merId) { $productData = $this->save($id, $settleParams, $content, $product, $productType); @@ -514,6 +523,13 @@ class ProductRepository extends BaseRepository } + + $minValues = array_map(function ($item) { + return min($item['price'], $item['ot_price']); + }, $data['attrValue']); + + $minPriceOtPrice = min($minValues); + $result = [ 'store_name' => $data['store_name'], 'image' => $data['image'], @@ -546,7 +562,7 @@ class ProductRepository extends BaseRepository 'refund_switch' => $data['refund_switch'] ?? 0, 'mer_form_id' => $data['mer_form_id'] ?? 0, 'rate' => $data['rate'] ?? 5.0, - 'wholesale_price'=> min($data['attrValue'][0]['ot_price'],$data['attrValue'][0]['price']) + 'wholesale_price'=> $minPriceOtPrice ]; if (isset($data['extend'])) $result['extend'] = $data['extend'] ? json_encode($data['extend'], JSON_UNESCAPED_UNICODE) : '';